[FFmpeg-devel] [PATCH 03/22] avcodec/dovi_rpuenc: also copy ext blocks to dovi ctx

Niklas Haas ffmpeg at haasn.xyz
Sun Jul 28 13:25:08 EEST 2024


From: Niklas Haas <git at haasn.dev>

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.
---
 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;
-- 
2.45.2



More information about the ffmpeg-devel mailing list