[FFmpeg-devel] [PATCH 8/8] avcodec/pnm: explicitly tag color range

Vittorio Giovara vittorio.giovara at gmail.com
Fri Oct 27 21:34:41 EEST 2023


On Fri, Oct 27, 2023 at 10:06 AM Niklas Haas <ffmpeg at haasn.xyz> wrote:

> From: Niklas Haas <git at haasn.dev>
>
> PGMYUV seems to be always limited range. This was a format originally
> invented by FFmpeg at a time when YUVJ distinguished limited from full
> range YUV, and this codec never appeared to output YUVJ in any
> circumstance, so hard-coding limited range preserves the status quo.
>
> The other formats are explicitly documented to be full range RGB/gray
> formats. That said, don't tag them yet, due to outstanding bugs w.r.t
> grayscale formats and color range handling.
>
> This change in behavior updates a bunch of FATE tests in trivial ways
> (added tagging being the only difference).
> ---
>  libavcodec/pnm.c              |  5 ++++
>  tests/ref/lavf/mkv            |  4 ++--
>  tests/ref/lavf/mkv_attachment |  4 ++--
>  tests/ref/lavf/mxf            |  6 ++---
>  tests/ref/lavf/y4m            |  4 ++--
>  tests/ref/seek/lavf-mkv       | 44 +++++++++++++++++------------------
>  tests/ref/seek/lavf-y4m       | 22 +++++++++---------
>  7 files changed, 47 insertions(+), 42 deletions(-)
>
> diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
> index 77d24eeaf7..bc51f94b1c 100644
> --- a/libavcodec/pnm.c
> +++ b/libavcodec/pnm.c
> @@ -240,5 +240,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx,
> PNMContext * const s)
>          h /= 3;
>          avctx->height = h;
>      }
> +
> +    /* PGMYUV is always limited range */
> +    if (avctx->codec_id == AV_CODEC_ID_PGMYUV)
> +        avctx->color_range = AVCOL_RANGE_MPEG;
>

Why does this check for the codec_id?
-- 
Vittorio


More information about the ffmpeg-devel mailing list