avcodec/dovi_rpu: guard ext blocks by dm_metadata_present

In the spec, dm_metadata_present also toggles all extension blocks, so
we need to move them inside the branch.
release/7.1
Niklas Haas 8 months ago
parent 5e778cbfd5
commit d9f902d3a4
  1. 7
      libavcodec/dovi_rpudec.c
  2. 10
      libavcodec/dovi_rpuenc.c

@ -625,9 +625,6 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size,
color->source_min_pq = get_bits(gb, 12);
color->source_max_pq = get_bits(gb, 12);
color->source_diagonal = get_bits(gb, 10);
} else {
s->color = &ff_dovi_color_default;
}
/* Parse extension blocks */
s->num_ext_blocks = 0;
@ -642,6 +639,10 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size,
return ret;
}
}
} else {
s->color = &ff_dovi_color_default;
s->num_ext_blocks = 0;
}
return 0;

@ -508,6 +508,8 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
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)
vdr_dm_metadata_present = 1;
if (vdr_dm_metadata_present && !s->dm) {
s->dm = ff_refstruct_allocz(sizeof(AVDOVIColorMetadata));
@ -657,10 +659,8 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
memcpy(s->dm, color, sizeof(*color));
s->color = s->dm;
} else {
s->color = &ff_dovi_color_default;
}
/* Extension blocks */
set_ue_golomb(pb, num_ext_blocks_v1);
align_put_bits(pb);
for (int i = 0; i < metadata->num_ext_blocks; i++)
@ -672,6 +672,10 @@ 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));
}
} else {
s->color = &ff_dovi_color_default;
s->num_ext_blocks = 0;
}
flush_put_bits(pb);
crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1,

Loading…
Cancel
Save