diff mbox series

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

Message ID GV1P250MB07377F53DE38EBEC167F708F8F4C9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit a7e54196cc94a71c44dd0bd4b91641740a7caf20
Headers show
Series [FFmpeg-devel,v2,1/4] avcodec/h264_redundant_pps_bsf: Don't remove PPS | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/configure_x86 warning Failed to run configure

Commit Message

Andreas Rheinhardt Sept. 20, 2022, 4:46 p.m. UTC
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@outlook.com>
---
Maybe check for the number of units to write instead?

 libavcodec/cbs.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

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