Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 08/20] avcodec/h2645_sei: Factor updating H.2645 SEIs out
Date: Sun,  3 Jul 2022 00:21:48 +0200
Message-ID: <DB6PR0101MB2214686018F6D91D39FF66798FBC9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <DB6PR0101MB2214F50F230E6F64A2428AED8FBC9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com>

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h2645_sei.c  | 29 +++++++++++++++++++++++++++++
 libavcodec/h2645_sei.h  |  2 ++
 libavcodec/h264_sei.h   |  6 ++++++
 libavcodec/h264_slice.c | 21 +--------------------
 libavcodec/hevc_sei.h   |  5 +++++
 libavcodec/hevcdec.c    | 22 +---------------------
 6 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 5ff62bfac1..21208fa920 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -389,3 +389,32 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
         return FF_H2645_SEI_MESSAGE_UNHANDLED;
     }
 }
+
+int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
+{
+    int ret = av_buffer_replace(&dst->a53_caption.buf_ref,
+                                 src->a53_caption.buf_ref);
+    if (ret < 0)
+        return ret;
+
+    for (unsigned i = 0; i < dst->unregistered.nb_buf_ref; i++)
+        av_buffer_unref(&dst->unregistered.buf_ref[i]);
+    dst->unregistered.nb_buf_ref = 0;
+
+    if (src->unregistered.nb_buf_ref) {
+        ret = av_reallocp_array(&dst->unregistered.buf_ref,
+                                src->unregistered.nb_buf_ref,
+                                sizeof(*dst->unregistered.buf_ref));
+        if (ret < 0)
+            return ret;
+
+        for (unsigned i = 0; i < src->unregistered.nb_buf_ref; i++) {
+            dst->unregistered.buf_ref[i] = av_buffer_ref(src->unregistered.buf_ref[i]);
+            if (!dst->unregistered.buf_ref[i])
+                return AVERROR(ENOMEM);
+            dst->unregistered.nb_buf_ref++;
+        }
+    }
+
+    return 0;
+}
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 4128ff7940..e87a669b3e 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -130,4 +130,6 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
                                 enum AVCodecID codec_id, GetBitContext *gb,
                                 GetByteContext *gbyte, void *logctx);
 
+int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src);
+
 #endif /* AVCODEC_H2645_SEI_H */
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index 7a53d01ac5..003f427ac3 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -142,6 +142,12 @@ struct H264ParamSets;
 int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
                        const struct H264ParamSets *ps, void *logctx);
 
+static inline int ff_h264_sei_ctx_replace(H264SEIContext *dst,
+                                   const H264SEIContext *src)
+{
+    return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
+}
+
 /**
  * Reset SEI values at the beginning of the frame.
  */
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index a6d8d2bdac..fb7aed998b 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -433,29 +433,10 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
 
     h->frame_recovered       = h1->frame_recovered;
 
-    ret = av_buffer_replace(&h->sei.common.a53_caption.buf_ref,
-                            h1->sei.common.a53_caption.buf_ref);
+    ret = ff_h264_sei_ctx_replace(&h->sei, &h1->sei);
     if (ret < 0)
         return ret;
 
-    for (i = 0; i < h->sei.common.unregistered.nb_buf_ref; i++)
-        av_buffer_unref(&h->sei.common.unregistered.buf_ref[i]);
-    h->sei.common.unregistered.nb_buf_ref = 0;
-
-    if (h1->sei.common.unregistered.nb_buf_ref) {
-        ret = av_reallocp_array(&h->sei.common.unregistered.buf_ref,
-                                h1->sei.common.unregistered.nb_buf_ref,
-                                sizeof(*h->sei.common.unregistered.buf_ref));
-        if (ret < 0)
-            return ret;
-
-        for (i = 0; i < h1->sei.common.unregistered.nb_buf_ref; i++) {
-            h->sei.common.unregistered.buf_ref[i] = av_buffer_ref(h1->sei.common.unregistered.buf_ref[i]);
-            if (!h->sei.common.unregistered.buf_ref[i])
-                return AVERROR(ENOMEM);
-            h->sei.common.unregistered.nb_buf_ref++;
-        }
-    }
     h->sei.common.unregistered.x264_build = h1->sei.common.unregistered.x264_build;
 
     if (!h->cur_pic_ptr)
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 8ea0245802..2bb6b7e48b 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -107,6 +107,11 @@ struct HEVCParamSets;
 int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
                            const struct HEVCParamSets *ps, enum HEVCNALUnitType type);
 
+static inline int ff_hevc_sei_ctx_replace(HEVCSEI *dst, const HEVCSEI *src)
+{
+    return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
+}
+
 /**
  * Reset SEI values that are stored on the Context.
  * e.g. Caption data that was extracted during NAL
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 69e65482dd..698fb50a6c 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -3745,30 +3745,10 @@ static int hevc_update_thread_context(AVCodecContext *dst,
         s->max_ra = INT_MAX;
     }
 
-    ret = av_buffer_replace(&s->sei.common.a53_caption.buf_ref,
-                            s0->sei.common.a53_caption.buf_ref);
+    ret = ff_h2645_sei_ctx_replace(&s->sei.common, &s0->sei.common);
     if (ret < 0)
         return ret;
 
-    for (i = 0; i < s->sei.common.unregistered.nb_buf_ref; i++)
-        av_buffer_unref(&s->sei.common.unregistered.buf_ref[i]);
-    s->sei.common.unregistered.nb_buf_ref = 0;
-
-    if (s0->sei.common.unregistered.nb_buf_ref) {
-        ret = av_reallocp_array(&s->sei.common.unregistered.buf_ref,
-                                s0->sei.common.unregistered.nb_buf_ref,
-                                sizeof(*s->sei.common.unregistered.buf_ref));
-        if (ret < 0)
-            return ret;
-
-        for (i = 0; i < s0->sei.common.unregistered.nb_buf_ref; i++) {
-            s->sei.common.unregistered.buf_ref[i] = av_buffer_ref(s0->sei.common.unregistered.buf_ref[i]);
-            if (!s->sei.common.unregistered.buf_ref[i])
-                return AVERROR(ENOMEM);
-            s->sei.common.unregistered.nb_buf_ref++;
-        }
-    }
-
     ret = av_buffer_replace(&s->sei.common.dynamic_hdr_plus.info,
                             s0->sei.common.dynamic_hdr_plus.info);
     if (ret < 0)
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-07-02 22:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 02/20] avcodec/h264_sei: Don't use GetBit-API for byte-aligned reads Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 03/20] configure: Add (h264|hevc)_sei subsystems Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 04/20] avcodec/sei: Add tag to SEI enumeration Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 05/20] fftools/ffprobe: Improve description of AFD side data Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 06/20] fate/h264: Add Active Format Descriptor test Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 07/20] avcodec/h2645_sei: Factor parsing common SEI messages out Andreas Rheinhardt
2022-07-02 22:21 ` Andreas Rheinhardt [this message]
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 09/20] avcodec/h2645_sei: Factor out freeing common SEI parts Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 10/20] avcodec/h2645_sei: Factor out applying SEIs to frames Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 11/20] avcodec/h264_sei, sei: Make H264_SEI_FpaType generic Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 12/20] avcodec/h2645_sei: Attach AVStereo3D side data generically Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 13/20] avcodec/h2645_sei: Also support Active Format Descriptor for HEVC Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 14/20] avcodec/h264_ps: Don't error out on unknown aspect ratio Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 15/20] avcodec/h264data: Deduplicate H.26[45] aspect ratio table Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 16/20] avcodec/hevc_ps: Fix wrong copyright years Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 17/20] avcodec/h264_ps: Don't output invalid chroma location Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 18/20] avcodec/h26[45]_metadata_bsf: Fix range of chroma_sample_loc_type Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 19/20] avcodec/(h264|hevc)_ps: Factor common VUI code out Andreas Rheinhardt
2022-07-02 22:22 ` [FFmpeg-devel] [PATCH 20/20] avcodec/h2645_sei: Factor attaching film grain side-data to frame out Andreas Rheinhardt
2022-07-02 23:28 ` [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Soft Works
2022-11-23  3:19   ` Andreas Rheinhardt
2022-11-23  4:15     ` Soft Works
2022-11-23  5:05     ` Soft Works

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB6PR0101MB2214686018F6D91D39FF66798FBC9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git