avcodec/dovi_rpuenc: eliminate unnecessary loop

This struct itself contains vdr_rpu_id, so we can never match it except
in the case of i == vdr_rpu_id. So just directly use this ID.
This commit is contained in:
Niklas Haas 2024-07-18 15:39:45 +02:00
parent bf92441d6a
commit fd00a56653

View File

@ -463,16 +463,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
vdr_rpu_id = -1; vdr_rpu_id = mapping->vdr_rpu_id;
for (int i = 0; i <= DOVI_MAX_DM_ID; i++) {
if (s->vdr[i] && !memcmp(s->vdr[i], mapping, sizeof(*mapping))) {
vdr_rpu_id = i;
break;
} else if (vdr_rpu_id < 0 && (!s->vdr[i] || i == DOVI_MAX_DM_ID)) {
vdr_rpu_id = i;
}
}
if (!s->vdr[vdr_rpu_id]) { if (!s->vdr[vdr_rpu_id]) {
s->vdr[vdr_rpu_id] = ff_refstruct_allocz(sizeof(AVDOVIDataMapping)); s->vdr[vdr_rpu_id] = ff_refstruct_allocz(sizeof(AVDOVIDataMapping));
if (!s->vdr[vdr_rpu_id]) if (!s->vdr[vdr_rpu_id])