[FFmpeg-devel] [PATCH v11 1/5] avcodec/jpegxl: add Jpeg XL image codec and parser

Lynne dev at lynne.ee
Fri Apr 1 05:13:41 EEST 2022


1 Apr 2022, 02:20 by leo.izen at gmail.com:

> This commit adds support to libavcodec to read and parse
> encoded Jpeg XL images. Jpeg XL is intended to be an
> extended-life replacement to legacy mjpeg.
> ---
>  MAINTAINERS                |   2 +
>  libavcodec/Makefile        |   1 +
>  libavcodec/codec_desc.c    |   9 +
>  libavcodec/codec_id.h      |   1 +
>  libavcodec/jpegxl.h        |  43 ++
>  libavcodec/jpegxl_parser.c | 951 +++++++++++++++++++++++++++++++++++++ 
> +        }
> +    }
> +    if (header->color_space == FF_JPEGXL_CS_GRAY) {
> +        if (header->bits_per_sample <= 8)
> +            return alpha ? AV_PIX_FMT_YA8 : AV_PIX_FMT_GRAY8;
> +        if (header->bits_per_sample > 16 || header->exp_bits_per_sample)
> +            return alpha ? AV_PIX_FMT_NONE : AV_PIX_FMT_GRAYF32;
> +        return alpha ? AV_PIX_FMT_YA16 : AV_PIX_FMT_GRAY16;
> +    } else if (header->color_space == FF_JPEGXL_CS_RGB
> +            || header->color_space == FF_JPEGXL_CS_XYB) {
> +        if (header->bits_per_sample <= 8)
> +            return alpha ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB24;
> +        if (header->bits_per_sample > 16 || header->exp_bits_per_sample)
> +            return alpha ? AV_PIX_FMT_GBRAPF32 : AV_PIX_FMT_GBRPF32;
> +        return alpha ? AV_PIX_FMT_RGBA64 : AV_PIX_FMT_RGB48;
> +    }
> +    return AV_PIX_FMT_NONE;
>

YUV is supported, via the do_YCbCr flag in the spec. I think
we ought to set the pixel format to YUV444P/16 in that case,
as the codec requires YUV to be upsampled during decoding,
and doing unnecessary colorspace conversions inside
decoders is something we don't want.
Decoders are free to change what the parser sets, so if
users link to libjxl, then RGB will be reported as lavf will
decode the first frame during probing.
Otherwise, the native decoder would match what the parser
reports and output YUV444-frames when signalled.


More information about the ffmpeg-devel mailing list