[FFmpeg-devel] [PATCH v2 2/4] avcodec/cbs: Only write extradata if there is something to write

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Sep 20 19:46:43 EEST 2022


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 <andreas.rheinhardt at outlook.com>
---
Maybe check for the number of units to write instead?

 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);
-- 
2.34.1



More information about the ffmpeg-devel mailing list