avformat/mxfdec: do not use AnyType when resolving Descriptors and MultipleDescriptors

By using AnyType for resolving a strong reference we searched among all types,
not just the ones which can be the target of the reference, which in some cases
caused to find the wrong type, if the metadata set UUIDs were not unique.

UUIDs do not have to be unique if their type sets them apart, SMPTE 377M says:

> StrongRef: 'One to One’ relationship between sets and implemented in MXF
> with UUIDs. Strong References are typed which means that the definition
> identifies the kind of set which is the target of the reference.

Fixes ticket #10865.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 68f2b32ef2)
This commit is contained in:
Marton Balint 2024-02-16 21:53:16 +01:00
parent 9e0cfc48ac
commit 2af975f2c1
1 changed files with 8 additions and 11 deletions

View File

@ -2258,16 +2258,14 @@ static MXFPackage* mxf_resolve_source_package(MXFContext *mxf, UID package_ul, U
static MXFDescriptor* mxf_resolve_descriptor(MXFContext *mxf, UID *strong_ref, int track_id) static MXFDescriptor* mxf_resolve_descriptor(MXFContext *mxf, UID *strong_ref, int track_id)
{ {
MXFDescriptor *descriptor, *file_descriptor = NULL; MXFDescriptor *descriptor = mxf_resolve_strong_ref(mxf, strong_ref, Descriptor);
int i; if (descriptor)
return descriptor;
descriptor = mxf_resolve_strong_ref(mxf, strong_ref, AnyType); descriptor = mxf_resolve_strong_ref(mxf, strong_ref, MultipleDescriptor);
if (!descriptor) if (descriptor) {
return NULL; for (int i = 0; i < descriptor->file_descriptors_count; i++) {
MXFDescriptor *file_descriptor = mxf_resolve_strong_ref(mxf, &descriptor->file_descriptors_refs[i], Descriptor);
if (descriptor->meta.type == MultipleDescriptor) {
for (i = 0; i < descriptor->file_descriptors_count; i++) {
file_descriptor = mxf_resolve_strong_ref(mxf, &descriptor->file_descriptors_refs[i], Descriptor);
if (!file_descriptor) { if (!file_descriptor) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve file descriptor strong ref\n"); av_log(mxf->fc, AV_LOG_ERROR, "could not resolve file descriptor strong ref\n");
@ -2277,8 +2275,7 @@ static MXFDescriptor* mxf_resolve_descriptor(MXFContext *mxf, UID *strong_ref, i
return file_descriptor; return file_descriptor;
} }
} }
} else if (descriptor->meta.type == Descriptor) }
return descriptor;
return NULL; return NULL;
} }