[FFmpeg-devel] [PATCH 1/2] vf_colorspace: Interpret unspecified color range as limited range

Ronald S. Bultje rsbultje at gmail.com
Thu Sep 15 15:03:06 EEST 2016


Hi,

On Wed, Sep 14, 2016 at 5:09 PM, Vittorio Giovara <
vittorio.giovara at gmail.com> wrote:

> This is the assumption that is made in pixel format conversion do
> throughout the code (in particular swscale and vf_colormatrix).
>
> Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
> ---
>  libavfilter/vf_colorspace.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> index b9ecb5f..7e87cd8 100644
> --- a/libavfilter/vf_colorspace.c
> +++ b/libavfilter/vf_colorspace.c
> @@ -522,6 +522,7 @@ static int get_range_off(int *off, int *y_rng, int
> *uv_rng,
>                           enum AVColorRange rng, int depth)
>  {
>      switch (rng) {
> +    case AVCOL_RANGE_UNSPECIFIED:
>      case AVCOL_RANGE_MPEG:
>          *off = 16 << (depth - 8);
>          *y_rng = 219 << (depth - 8);
> --
> 2.9.3


I'm open to this, but let me explain why I didn't follow the convention
here: the convention is wrong, or rather, the convention is outdated.

Classically, for low-resolution video, this is indeed true. But for modern
video (bt2020 etc., probably even smpte*) at larger resolutions, I feel the
default should be pc/jpeg range, not tv/mpeg range, because that's usually
what it is. I was somewhat tempted to not make automatic decisions that
could have a fairly substantial negative effect on the end result (without
informing the end user about it!). Asking the user to explicitly specify
the pixel range is one way of informing.

(You could also add a av_log(.., WARNING, ..) if the rng is UNSPECIFIED.)

But if others think this is the best solution, I'm OK with it.

Ronald


More information about the ffmpeg-devel mailing list