aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-06-09 14:43:11 +0200
committerNiklas Haas <git@haasn.dev>2024-06-18 21:18:30 +0200
commite1b91eb195734e3eeffdba39bccd6647e34f70f3 (patch)
treeb6dcebc84cff03e85d4f36e5c271902dbd0fc589
parent954f890f9553fa13baf4cbc58e9359492fbe8b81 (diff)
downloadffmpeg-e1b91eb195734e3eeffdba39bccd6647e34f70f3.tar.gz
avdovi/dovi_rpudec: handle prev_vdr_rpu_id failures
According to the spec, missing previous VDR RPU IDs do not constitute an error, but we should instead fallback first to VDR RPU with ID 0, and failing that, synthesize "neutral" metadata. That's nontrivial though as the resulting metadata will be dependent on other properties of the RPU, and this case is not hit in practice so I'll defer it to a rainy day.
-rw-r--r--libavcodec/dovi_rpudec.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/dovi_rpudec.c b/libavcodec/dovi_rpudec.c
index 306efbb31f..109cef5742 100644
--- a/libavcodec/dovi_rpudec.c
+++ b/libavcodec/dovi_rpudec.c
@@ -456,7 +456,12 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size,
if (use_prev_vdr_rpu) {
int prev_vdr_rpu_id = get_ue_golomb_31(gb);
VALIDATE(prev_vdr_rpu_id, 0, DOVI_MAX_DM_ID);
+ if (!s->vdr[prev_vdr_rpu_id])
+ prev_vdr_rpu_id = 0;
if (!s->vdr[prev_vdr_rpu_id]) {
+ /* FIXME: Technically, the spec says that in this case we should
+ * synthesize "neutral" vdr metadata, but easier to just error
+ * out as this corner case is not hit in practice */
av_log(s->logctx, AV_LOG_ERROR, "Unknown previous RPU ID: %u\n",
prev_vdr_rpu_id);
goto fail;