[FFmpeg-devel] [PATCH v23 02/10] avcodec/evc_parser: Added parser implementation for EVC format

James Almer jamrial at gmail.com
Mon May 29 15:48:56 EEST 2023


On 5/26/2023 7:31 AM, Dawid Kozinski wrote:
> +static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx,
> +                     const uint8_t **poutbuf, int *poutbuf_size,
> +                     const uint8_t *buf, int buf_size)
> +{
> +    int next;
> +    EVCParserContext *ev = s->priv_data;
> +    ParseContext *pc = &ev->pc;
> +
> +    if (avctx->extradata && !ev->parsed_extradata) {
> +        decode_extradata(s, avctx, avctx->extradata, avctx->extradata_size);
> +        ev->parsed_extradata = 1;
> +    }
> +
> +    if (s->flags & PARSER_FLAG_COMPLETE_FRAMES)
> +        next = buf_size;
> +    else {

As the parser no longer has the job to assemble an AU, this code below 
and evc_find_frame_end() can be removed.

And like i said in my last review, you can share the NALU parsing code 
between this parser and the frame_merge bsf, to reduce code duplication, 
as they both reside in libavcodec.
Simply put it in a new file called for example evc_parse.{c,h}. You can 
follow he example from h26* parsers, which define and reuse 
ff_h***_decode_nal_*ps().

> +        next = evc_find_frame_end(s, buf, buf_size, avctx);
> +        if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
> +            *poutbuf      = NULL;
> +            *poutbuf_size = 0;
> +            return buf_size;
> +        }
> +    }


More information about the ffmpeg-devel mailing list