diff mbox series

[FFmpeg-devel,v2,01/18] cbs_sei: Delete SEI NAL units containing no messages

Message ID 20210221195125.1901683-1-sw@jkqxz.net
State New
Headers show
Series [FFmpeg-devel,v2,01/18] cbs_sei: Delete SEI NAL units containing no messages | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Mark Thompson Feb. 21, 2021, 7:51 p.m. UTC
When we remove the last SEI message from a NAL unit, the unit itself
should also be deleted.
---
 libavcodec/cbs_sei.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c
index c49830ad77..14f1cae506 100644
--- a/libavcodec/cbs_sei.c
+++ b/libavcodec/cbs_sei.c
@@ -353,7 +353,7 @@  void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx,
 {
     int err, i, j;
 
-    for (i = 0; i < au->nb_units; i++) {
+    for (i = au->nb_units - 1; i >= 0; i--) {
         CodedBitstreamUnit *unit = &au->units[i];
         SEIRawMessageList *list;
 
@@ -365,5 +365,10 @@  void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx,
             if (list->messages[j].payload_type == payload_type)
                 cbs_sei_delete_message(list, j);
         }
+
+        if (list->nb_messages == 0) {
+            // The SEI NAL unit is now empty, so get rid of it.
+            ff_cbs_delete_unit(au, i);
+        }
     }
 }