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.
Unified · Split
| @@ -506,6 +506,12 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, · 505 unmodified lines | ||
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | + if (metadata->num_ext_blocks && !s->ext_blocks) { | |
| 510 | + s->ext_blocks = ff_refstruct_allocz(sizeof(AVDOVIDmData) * AV_DOVI_MAX_EXT_BLOCKS); | |
| 511 | + if (!s->ext_blocks) | |
| 512 | + return AVERROR(ENOMEM); | |
| 513 | + } | |
| 514 | + | |
| 509 | 515 | vdr_dm_metadata_present = memcmp(color, &ff_dovi_color_default, sizeof(*color)); |
| 510 | 516 | use_prev_vdr_rpu = !memcmp(s->vdr[vdr_rpu_id], mapping, sizeof(*mapping)); |
| 511 | 517 | if (num_ext_blocks_v1 || num_ext_blocks_v2) |
| @@ -636,6 +642,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, · 124 unmodified lines | ||
| 636 | 642 | } |
| 637 | 643 | |
| 638 | 644 | if (vdr_dm_metadata_present) { |
| 645 | + size_t ext_sz; | |
| 639 | 646 | const int denom = profile == 4 ? (1 << 30) : (1 << 28); |
| 640 | 647 | set_ue_golomb(pb, color->dm_metadata_id); /* affected_dm_id */ |
| 641 | 648 | 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, · 31 unmodified lines | ||
| 673 | 680 | for (int i = 0; i < metadata->num_ext_blocks; i++) |
| 674 | 681 | generate_ext_v2(pb, av_dovi_get_ext(metadata, i)); |
| 675 | 682 | } |
| 683 | + | |
| 684 | + ext_sz = FFMIN(sizeof(AVDOVIDmData), metadata->ext_block_size); | |
| 685 | + for (int i = 0; i < metadata->num_ext_blocks; i++) | |
| 686 | + memcpy(&s->ext_blocks[i], av_dovi_get_ext(metadata, i), ext_sz); | |
| 687 | + s->num_ext_blocks = metadata->num_ext_blocks; | |
| 676 | 688 | } else { |
| 677 | 689 | s->color = &ff_dovi_color_default; |
| 678 | 690 | s->num_ext_blocks = 0; |