diff options
author | Niklas Haas <[email protected]> | 2024-06-14 15:00:31 +0200 |
---|---|---|
committer | Niklas Haas <[email protected]> | 2024-08-16 11:48:02 +0200 |
commit | bf92441d6a29221ccf38b41207ea53d08e1209ab (patch) | |
tree | 465b9e20a783dcb83f93be983a04f3b16fbbc582 | |
parent | a93801b6266c2170842275271c64a40d015cd03b (diff) |
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.
-rw-r--r-- | libavcodec/dovi_rpuenc.c | 12 |
1 files changed, 12 insertions, 0 deletions
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; |