1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

Extend mxf_resolve_strong_ref by a type parameter, to avoid modify something

that actually has a different type.

Originally committed as revision 7448 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Reimar Döffinger 2007-01-13 18:54:48 +00:00
parent 717f1019a8
commit 2d193b2ea0

View File

@ -741,14 +741,15 @@ static enum CodecType mxf_get_codec_type(const MXFDataDefinitionUL *uls, UID *ui
return uls->type; return uls->type;
} }
static void *mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref) static void *mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref, enum MXFMetadataSetType type)
{ {
int i; int i;
if (!strong_ref) if (!strong_ref)
return NULL; return NULL;
for (i = 0; i < mxf->metadata_sets_count; i++) { for (i = 0; i < mxf->metadata_sets_count; i++) {
if (!memcmp(*strong_ref, mxf->metadata_sets[i]->uid, 16)) { if (!memcmp(*strong_ref, mxf->metadata_sets[i]->uid, 16) &&
mxf->metadata_sets[i]->type == type) {
return mxf->metadata_sets[i]; return mxf->metadata_sets[i];
} }
} }
@ -764,14 +765,8 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
dprintf("metadata sets count %d\n", mxf->metadata_sets_count); dprintf("metadata sets count %d\n", mxf->metadata_sets_count);
/* TODO: handle multiple material packages (OP3x) */ /* TODO: handle multiple material packages (OP3x) */
for (i = 0; i < mxf->packages_count; i++) { for (i = 0; i < mxf->packages_count; i++) {
if (!(temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i]))) { material_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], MaterialPackage);
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve package strong ref\n"); if (material_package) break;
return -1;
}
if (temp_package->type == MaterialPackage) {
material_package = temp_package;
break;
}
} }
if (!material_package) { if (!material_package) {
av_log(mxf->fc, AV_LOG_ERROR, "no material package found\n"); av_log(mxf->fc, AV_LOG_ERROR, "no material package found\n");
@ -789,12 +784,12 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
const MXFCodecUL *container_ul = NULL; const MXFCodecUL *container_ul = NULL;
AVStream *st; AVStream *st;
if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i]))) { if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i], Track))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track strong ref\n"); av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track strong ref\n");
continue; continue;
} }
if (!(material_track->sequence = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref))) { if (!(material_track->sequence = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref, Sequence))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track sequence strong ref\n"); av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track sequence strong ref\n");
return -1; return -1;
} }
@ -802,15 +797,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
/* TODO: handle multiple source clips */ /* TODO: handle multiple source clips */
for (j = 0; j < material_track->sequence->structural_components_count; j++) { for (j = 0; j < material_track->sequence->structural_components_count; j++) {
/* TODO: handle timecode component */ /* TODO: handle timecode component */
component = mxf_resolve_strong_ref(mxf, &material_track->sequence->structural_components_refs[j]); component = mxf_resolve_strong_ref(mxf, &material_track->sequence->structural_components_refs[j], SourceClip);
if (!component || component->type != SourceClip) if (!component)
continue; continue;
for (k = 0; k < mxf->packages_count; k++) { for (k = 0; k < mxf->packages_count; k++) {
if (!(temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[k]))) { temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[k], SourcePackage);
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve package strong ref\n"); if (!temp_package)
return -1; continue;
}
if (!memcmp(temp_package->package_uid, component->source_package_uid, 16)) { if (!memcmp(temp_package->package_uid, component->source_package_uid, 16)) {
source_package = temp_package; source_package = temp_package;
break; break;
@ -821,7 +815,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
break; break;
} }
for (k = 0; k < source_package->tracks_count; k++) { for (k = 0; k < source_package->tracks_count; k++) {
if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k]))) { if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k], Track))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n"); av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
return -1; return -1;
} }
@ -846,7 +840,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
st->start_time = component->start_position; st->start_time = component->start_position;
av_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den); av_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den);
if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref))) { if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref, Sequence))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n"); av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n");
return -1; return -1;
} }
@ -856,11 +850,11 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
#endif #endif
st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul); st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref); source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref, Descriptor);
if (source_package->descriptor) { if (source_package->descriptor) {
if (source_package->descriptor->type == MultipleDescriptor) { if (source_package->descriptor->type == MultipleDescriptor) {
for (j = 0; j < source_package->descriptor->sub_descriptors_count; j++) { for (j = 0; j < source_package->descriptor->sub_descriptors_count; j++) {
MXFDescriptor *sub_descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor->sub_descriptors_refs[j]); MXFDescriptor *sub_descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor->sub_descriptors_refs[j], Descriptor);
if (!sub_descriptor) { if (!sub_descriptor) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve sub descriptor strong ref\n"); av_log(mxf->fc, AV_LOG_ERROR, "could not resolve sub descriptor strong ref\n");