[FFmpeg-cvslog] avcodec/h2645_sei: Factor out freeing common SEI parts

Andreas Rheinhardt git at videolan.org
Thu Dec 1 12:38:45 EET 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Jul  2 20:52:31 2022 +0200| [f89825e60a38497abe5f39ff3192b6f276599ef9] | committer: Andreas Rheinhardt

avcodec/h2645_sei: Factor out freeing common SEI parts

This commit only factors out freeing the common SEI parts,
not whether the fields indicating whether an SEI is present
shall be reset. H.264 and HEVC differ in this regard
(ff_h264_sei_uninit() really resets, whereas ff_hevc_reset_sei()
only uninits.) and neither actually honours the persistency
as prescribed by the relevant specs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f89825e60a38497abe5f39ff3192b6f276599ef9
---

 libavcodec/h2645_sei.c | 12 ++++++++++++
 libavcodec/h2645_sei.h |  2 ++
 libavcodec/h264_sei.c  |  6 +-----
 libavcodec/hevc_sei.c  | 12 ------------
 libavcodec/hevc_sei.h  |  7 +++++--
 5 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 21208fa920..f37a43ed77 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -418,3 +418,15 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
 
     return 0;
 }
+
+void ff_h2645_sei_reset(H2645SEI *s)
+{
+    av_buffer_unref(&s->a53_caption.buf_ref);
+
+    for (unsigned i = 0; i < s->unregistered.nb_buf_ref; i++)
+        av_buffer_unref(&s->unregistered.buf_ref[i]);
+    s->unregistered.nb_buf_ref = 0;
+    av_freep(&s->unregistered.buf_ref);
+    av_buffer_unref(&s->dynamic_hdr_plus.info);
+    av_buffer_unref(&s->dynamic_hdr_vivid.info);
+}
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index e87a669b3e..3e088f3307 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -132,4 +132,6 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
 
 int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src);
 
+void ff_h2645_sei_reset(H2645SEI *s);
+
 #endif /* AVCODEC_H2645_SEI_H */
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index c62aef9246..f11f8371f6 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -59,11 +59,7 @@ void ff_h264_sei_uninit(H264SEIContext *h)
     h->common.display_orientation.present = 0;
     h->common.afd.present                 =  0;
 
-    av_buffer_unref(&h->common.a53_caption.buf_ref);
-    for (int i = 0; i < h->common.unregistered.nb_buf_ref; i++)
-        av_buffer_unref(&h->common.unregistered.buf_ref[i]);
-    h->common.unregistered.nb_buf_ref = 0;
-    av_freep(&h->common.unregistered.buf_ref);
+    ff_h2645_sei_reset(&h->common);
 }
 
 int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index b0a4a8b035..3c6bde1b62 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -292,15 +292,3 @@ int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
     } while (bytestream2_get_bytes_left(&gbyte) > 0);
     return 1;
 }
-
-void ff_hevc_reset_sei(HEVCSEI *s)
-{
-    av_buffer_unref(&s->common.a53_caption.buf_ref);
-
-    for (int i = 0; i < s->common.unregistered.nb_buf_ref; i++)
-        av_buffer_unref(&s->common.unregistered.buf_ref[i]);
-    s->common.unregistered.nb_buf_ref = 0;
-    av_freep(&s->common.unregistered.buf_ref);
-    av_buffer_unref(&s->common.dynamic_hdr_plus.info);
-    av_buffer_unref(&s->common.dynamic_hdr_vivid.info);
-}
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 2bb6b7e48b..4189f5e6f7 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -117,8 +117,11 @@ static inline int ff_hevc_sei_ctx_replace(HEVCSEI *dst, const HEVCSEI *src)
  * e.g. Caption data that was extracted during NAL
  * parsing.
  *
- * @param s HEVCContext.
+ * @param sei HEVCSEI.
  */
-void ff_hevc_reset_sei(HEVCSEI *s);
+static inline void ff_hevc_reset_sei(HEVCSEI *sei)
+{
+    ff_h2645_sei_reset(&sei->common);
+}
 
 #endif /* AVCODEC_HEVC_SEI_H */



More information about the ffmpeg-cvslog mailing list