[FFmpeg-devel] [PATCH] avcodec/avcodec: Allow up to seven codec ids per parser
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Sep 1 23:29:20 EEST 2021
Andreas Rheinhardt:
> ff_pnm_parser and ff_vp3_parser already hit the current limit;
> an addition to the former (to handle pfm) is planned.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
> If this API were not intended to be deprecated soon, I would make
> the codec_ids an array of enum AVCodecID and change av_parser_init()
> accordingly. Furthermore, AVCodecParser needs a public-private
> demarkation line. Finally, some AVCodecParserContext are marked as
> private despite not being at the end of said context.
>
> Missing version bump.
>
> doc/APIchanges | 3 +++
> libavcodec/avcodec.h | 2 +-
> libavcodec/parser.c | 8 ++++++--
> 3 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 63bf95233f..5c0113a2ea 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,9 @@ libavutil: 2021-04-27
>
> API changes, most recent first:
>
> +2021-09-01 - xxxxxxxxxx - lavc 59.yyyyy - avcodec.h
> + Incremented the number of elements of AVCodecParser.codec_ids to seven.
> +
> 2021-08-24 - xxxxxxxxxx - lavc 59.6.100 - avcodec.h
> Add FF_CODEC_PROPERTY_FILM_GRAIN
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index f3f401871b..ffd58c333f 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2927,7 +2927,7 @@ typedef struct AVCodecParserContext {
> } AVCodecParserContext;
>
> typedef struct AVCodecParser {
> - int codec_ids[5]; /* several codec IDs are permitted */
> + int codec_ids[7]; /* several codec IDs are permitted */
> int priv_data_size;
> int (*parser_init)(AVCodecParserContext *s);
> /* This callback never returns an error, a negative value means that
> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> index fc57246965..3b459cc125 100644
> --- a/libavcodec/parser.c
> +++ b/libavcodec/parser.c
> @@ -46,7 +46,9 @@ AVCodecParserContext *av_parser_init(int codec_id)
> parser->codec_ids[1] == codec_id ||
> parser->codec_ids[2] == codec_id ||
> parser->codec_ids[3] == codec_id ||
> - parser->codec_ids[4] == codec_id)
> + parser->codec_ids[4] == codec_id ||
> + parser->codec_ids[5] == codec_id ||
> + parser->codec_ids[6] == codec_id)
> goto found;
> }
> return NULL;
> @@ -127,7 +129,9 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
> avctx->codec_id == s->parser->codec_ids[1] ||
> avctx->codec_id == s->parser->codec_ids[2] ||
> avctx->codec_id == s->parser->codec_ids[3] ||
> - avctx->codec_id == s->parser->codec_ids[4]);
> + avctx->codec_id == s->parser->codec_ids[4] ||
> + avctx->codec_id == s->parser->codec_ids[5] ||
> + avctx->codec_id == s->parser->codec_ids[6]);
>
> if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
> s->next_frame_offset =
>
Given that this has been lgtm'ed I will apply it tomorrow unless there
are objections.
- Andreas
More information about the ffmpeg-devel
mailing list