[FFmpeg-devel] [PATCH 2/5] cbs_sei: add ff_cbs_sei_delete_message helper
Eric Lindvall
ffmpegagent at gmail.com
Sat Feb 4 02:41:52 EET 2023
From: Eric Lindvall <eric at 5stops.com>
Signed-off-by: Aman Karmani <aman at tmm1.net>
---
libavcodec/cbs_sei.c | 25 +++++++++++++++++++++++++
libavcodec/cbs_sei.h | 7 +++++++
2 files changed, 32 insertions(+)
diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c
index 50a513f592..1ea2bbc109 100644
--- a/libavcodec/cbs_sei.c
+++ b/libavcodec/cbs_sei.c
@@ -347,6 +347,31 @@ static void cbs_sei_delete_message(SEIRawMessageList *list,
}
}
+int ff_cbs_sei_delete_message(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *au,
+ SEIRawMessage *message)
+{
+ int err, i, j;
+
+ for (i = 0; i < au->nb_units; i++) {
+ CodedBitstreamUnit *unit = &au->units[i];
+ SEIRawMessageList *list;
+
+ err = cbs_sei_get_message_list(ctx, unit, &list);
+ if (err < 0)
+ continue;
+
+ for (j = 0; j < list->nb_messages; j++) {
+ if (message == &list->messages[j]) {
+ cbs_sei_delete_message(list, j);
+ return 0;
+ }
+ }
+ }
+
+ return AVERROR(ENOENT);
+}
+
void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx,
CodedBitstreamFragment *au,
uint32_t payload_type)
diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
index 1c327a4689..96bd116a53 100644
--- a/libavcodec/cbs_sei.h
+++ b/libavcodec/cbs_sei.h
@@ -202,4 +202,11 @@ void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx,
CodedBitstreamFragment *au,
uint32_t payload_type);
+/**
+ * Delete a message from the access unit.
+ */
+int ff_cbs_sei_delete_message(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *au,
+ SEIRawMessage *message);
+
#endif /* AVCODEC_CBS_SEI_H */
--
ffmpeg-codebot
More information about the ffmpeg-devel
mailing list