From a7e54196cc94a71c44dd0bd4b91641740a7caf20 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 14:37:38 +0200 Subject: [PATCH] avcodec/cbs: Only write extradata if there is something to write It is e.g. legal for an ISOBMFF avcc to contain zero parameter sets. In this case the annex B that we produce would be empty and therefore useless. This happens e.g. with mov/frag_overlap.mp4 from the FATE-suite. Signed-off-by: Andreas Rheinhardt --- libavcodec/cbs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 07ae658a4c..8d6e3c3442 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -438,6 +438,10 @@ int ff_cbs_write_extradata(CodedBitstreamContext *ctx, return err; av_freep(&par->extradata); + par->extradata_size = 0; + + if (!frag->data_size) + return 0; par->extradata = av_malloc(frag->data_size + AV_INPUT_BUFFER_PADDING_SIZE);