[FFmpeg-devel] [PATCH v2 01/18] cbs_sei: Delete SEI NAL units containing no messages
Mark Thompson
sw at jkqxz.net
Sun Feb 21 21:51:08 EET 2021
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 --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);
+ }
}
}
--
2.30.0
More information about the ffmpeg-devel
mailing list