[FFmpeg-devel] [PATCH v2 1/3] avcodec/jpegxl_parser: add JPEG XL parser

James Almer jamrial at gmail.com
Thu Jun 22 17:19:57 EEST 2023


On 6/21/2023 9:43 PM, Leo Izen wrote:
> +static int jpegxl_parse(AVCodecParserContext *s, AVCodecContext *avctx,
> +                        const uint8_t **poutbuf, int *poutbuf_size,
> +                        const uint8_t *buf, int buf_size)
> +{
> +    JXLParseContext *ctx = s->priv_data;
> +    int ret;
> +
> +    *poutbuf_size = 0;
> +    *poutbuf = NULL;
> +
> +    if (!ctx->parsed_header) {
> +        if (AV_RL64(buf) == FF_JPEGXL_CONTAINER_SIGNATURE_LE) {
> +            int copied;
> +            uint8_t codestream_header[4096];
> +            ret = ff_jpegxl_collect_codestream_header(buf, buf_size, codestream_header,
> +                                                      sizeof(codestream_header), &copied);
> +            if (ret < 0)
> +                return ret;
> +            /* copied may be larger than the bufsize if stuff was skipped */
> +            copied = FFMIN(copied, sizeof(codestream_header));
> +            ret = ff_jpegxl_parse_codestream_header(codestream_header, copied, 0, &ctx->meta);
> +            if (ret < 0)
> +                return ret;
> +        } else {
> +            ret = ff_jpegxl_parse_codestream_header(buf, buf_size, 1, &ctx->meta);
> +            if (ret < 0)
> +                return ret;
> +        }
> +        avctx->width = ctx->meta.width;
> +        avctx->height = ctx->meta.height;

Set s->width and s->height instead. The generic code will set the avctx 
fields if required.


More information about the ffmpeg-devel mailing list