[FFmpeg-devel] [PATCH] libavformat/mxfdec.c: refactored resolving timecode component

Michael Niedermayer michaelni at gmx.at
Sat Nov 15 02:51:27 CET 2014


On Sat, Nov 15, 2014 at 02:04:56AM +0100, Tomas Härdin wrote:
> On Wed, 2014-11-12 at 12:15 -0800, Mark Reid wrote:
> > ---
> >  libavformat/mxfdec.c | 36 +++++++++++++++++++++++-------------
> >  1 file changed, 23 insertions(+), 13 deletions(-)
> > 
> > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > index b533e2a..87f1e51 100644
> > --- a/libavformat/mxfdec.c
> > +++ b/libavformat/mxfdec.c
> > @@ -1424,6 +1424,27 @@ static int mxf_add_timecode_metadata(AVDictionary **pm, const char *key, AVTimec
> >      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)
> >  {
> >      MXFPackage *temp_package = NULL;
> > @@ -1432,7 +1453,6 @@ static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_t
> >      MXFStructuralComponent *component = NULL;
> >      MXFStructuralComponent *sourceclip = NULL;
> >      MXFTimecodeComponent *mxf_tc = NULL;
> > -    MXFPulldownComponent *mxf_pulldown = NULL;
> >      int i, j, k;
> >      AVTimecode tc;
> >      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++) {
> > -                component = mxf_resolve_strong_ref(mxf, &physical_track->sequence->structural_components_refs[k], TimecodeComponent);
> > -                if (!component){
> > -                    /* 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;
> > -                }
> > +                if (!(mxf_tc = mxf_resolve_timecode_component(mxf, &physical_track->sequence->structural_components_refs[k])))
> > +                    continue;
> >  
> > -                mxf_tc = (MXFTimecodeComponent*)component;
> >                  flags = mxf_tc->drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0;
> >                  /* scale sourceclip start_position to match physical track edit rate */
> >                  start_position = av_rescale_q(sourceclip->start_position,
> 
> Looks simple enough. Good initiative :)

applied

thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141115/eda6cba2/attachment.asc>


More information about the ffmpeg-devel mailing list