[FFmpeg-cvslog] avcodec/dovi_rpuenc: also copy ext blocks to dovi ctx

Niklas Haas git at videolan.org
Fri Aug 16 12:51:48 EEST 2024


ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Fri Jun 14 15:00:31 2024 +0200| [bf92441d6a29221ccf38b41207ea53d08e1209ab] | committer: Niklas Haas

avcodec/dovi_rpuenc: also copy ext blocks to dovi ctx

As the comment implies, DOVIContext.ext_blocks should also reflect the
current state after ff_dovi_rpu_generate().

Fluff for now, but will be needed once we start implementing metadata
compression for extension blocks as well.

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

 libavcodec/dovi_rpuenc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
index a14c9cc181..f0cfecc91b 100644
--- a/libavcodec/dovi_rpuenc.c
+++ b/libavcodec/dovi_rpuenc.c
@@ -506,6 +506,12 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
         }
     }
 
+    if (metadata->num_ext_blocks && !s->ext_blocks) {
+        s->ext_blocks = ff_refstruct_allocz(sizeof(AVDOVIDmData) * AV_DOVI_MAX_EXT_BLOCKS);
+        if (!s->ext_blocks)
+            return AVERROR(ENOMEM);
+    }
+
     vdr_dm_metadata_present = memcmp(color, &ff_dovi_color_default, sizeof(*color));
     use_prev_vdr_rpu = !memcmp(s->vdr[vdr_rpu_id], mapping, sizeof(*mapping));
     if (num_ext_blocks_v1 || num_ext_blocks_v2)
@@ -636,6 +642,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
     }
 
     if (vdr_dm_metadata_present) {
+        size_t ext_sz;
         const int denom = profile == 4 ? (1 << 30) : (1 << 28);
         set_ue_golomb(pb, color->dm_metadata_id); /* affected_dm_id */
         set_ue_golomb(pb, color->dm_metadata_id); /* current_dm_id */
@@ -673,6 +680,11 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
             for (int i = 0; i < metadata->num_ext_blocks; i++)
                 generate_ext_v2(pb, av_dovi_get_ext(metadata, i));
         }
+
+        ext_sz = FFMIN(sizeof(AVDOVIDmData), metadata->ext_block_size);
+        for (int i = 0; i < metadata->num_ext_blocks; i++)
+            memcpy(&s->ext_blocks[i], av_dovi_get_ext(metadata, i), ext_sz);
+        s->num_ext_blocks = metadata->num_ext_blocks;
     } else {
         s->color = &ff_dovi_color_default;
         s->num_ext_blocks = 0;



More information about the ffmpeg-cvslog mailing list