libavformat/mxfdec.c: refactored resolving timecode component

Reviewed-by: Tomas Härdin <tomas.hardin@codemill.se>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Mark Reid 2014-11-12 12:15:21 -08:00 committed by Michael Niedermayer
parent 05e0ea6050
commit 933eca91e6
1 changed files with 23 additions and 13 deletions

View File

@ -1424,6 +1424,27 @@ static int mxf_add_timecode_metadata(AVDictionary **pm, const char *key, AVTimec
return 0; return 0;
} }
static MXFTimecodeComponent* mxf_resolve_timecode_component(MXFContext *mxf, UID *strong_ref)
{
MXFStructuralComponent *component = NULL;
MXFPulldownComponent *pulldown = NULL;
component = mxf_resolve_strong_ref(mxf, strong_ref, AnyType);
if (!component)
return NULL;
switch (component->type) {
case TimecodeComponent:
return (MXFTimecodeComponent*)component;
case PulldownComponent: /* timcode component may be located on a pulldown component */
pulldown = (MXFPulldownComponent*)component;
return mxf_resolve_strong_ref(mxf, &pulldown->input_segment_ref, TimecodeComponent);
default:
break;
}
return NULL;
}
static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_track, AVStream *st) static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_track, AVStream *st)
{ {
MXFPackage *temp_package = NULL; MXFPackage *temp_package = NULL;
@ -1432,7 +1453,6 @@ static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_t
MXFStructuralComponent *component = NULL; MXFStructuralComponent *component = NULL;
MXFStructuralComponent *sourceclip = NULL; MXFStructuralComponent *sourceclip = NULL;
MXFTimecodeComponent *mxf_tc = NULL; MXFTimecodeComponent *mxf_tc = NULL;
MXFPulldownComponent *mxf_pulldown = NULL;
int i, j, k; int i, j, k;
AVTimecode tc; AVTimecode tc;
int flags; int flags;
@ -1475,19 +1495,9 @@ static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_t
} }
for (k = 0; k < physical_track->sequence->structural_components_count; k++) { for (k = 0; k < physical_track->sequence->structural_components_count; k++) {
component = mxf_resolve_strong_ref(mxf, &physical_track->sequence->structural_components_refs[k], TimecodeComponent); if (!(mxf_tc = mxf_resolve_timecode_component(mxf, &physical_track->sequence->structural_components_refs[k])))
if (!component){ continue;
/* timcode component may be located on a pulldown component */
component = mxf_resolve_strong_ref(mxf, &physical_track->sequence->structural_components_refs[k], PulldownComponent);
if (!component)
continue;
mxf_pulldown = (MXFPulldownComponent*)component;
component = mxf_resolve_strong_ref(mxf, &mxf_pulldown->input_segment_ref, TimecodeComponent);
if (!component)
continue;
}
mxf_tc = (MXFTimecodeComponent*)component;
flags = mxf_tc->drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0; flags = mxf_tc->drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0;
/* scale sourceclip start_position to match physical track edit rate */ /* scale sourceclip start_position to match physical track edit rate */
start_position = av_rescale_q(sourceclip->start_position, start_position = av_rescale_q(sourceclip->start_position,