[FFmpeg-devel] [PATCH 2/4] avformat/mxfenc: use track count to generate component instance uuid

Mark Reid mindmark at gmail.com
Tue Nov 28 05:58:02 EET 2017


On Mon, Nov 27, 2017 at 2:14 AM, Tomas Härdin <tjoppen at acc.umu.se> wrote:

> On Sun, 2017-11-26 at 21:42 -0800, Mark Reid wrote:
> > ---
> >  libavformat/mxf.h               |  1 -
> >  libavformat/mxfenc.c            | 45 +++++++++++++++++++++++++----
> > ------------
> >  tests/ref/fate/copy-trac4914    |  2 +-
> >  tests/ref/fate/time_base        |  2 +-
> >  tests/ref/lavf/mxf              |  6 +++---
> >  tests/ref/lavf/mxf_d10          |  2 +-
> >  tests/ref/lavf/mxf_dv25         |  2 +-
> >  tests/ref/lavf/mxf_dvcpro50     |  2 +-
> >  tests/ref/lavf/mxf_opatom       |  2 +-
> >  tests/ref/lavf/mxf_opatom_audio |  2 +-
> >  10 files changed, 38 insertions(+), 28 deletions(-)
> > [...]
> > @@ -846,6 +847,10 @@ static void
> > mxf_write_track(AVFormatContext *s, AVStream *st, MXFPackage *packag
> >      MXFContext *mxf = s->priv_data;
> >      AVIOContext *pb = s->pb;
> >      MXFStreamContext *sc = st->priv_data;
> > +    int instance = package->uuid_offset;
> > +
> > +    if (st != mxf->timecode_track)
> > +        instance += st->index + 1;
> >
> >      mxf_write_metadata_key(pb, 0x013b00);
> >      PRINT_KEY(s, "track key", pb->buf_ptr - 16);
> >
> >  static int mxf_write_essence_container_data(AVFormatContext *s)
> > @@ -1443,11 +1451,12 @@ static int
> > mxf_write_header_metadata_sets(AVFormatContext *s)
> >      AVDictionaryEntry *entry = NULL;
> >      AVStream *st = NULL;
> >      int i;
> > -
> > +    int track_count = 0;
> >      MXFPackage packages[2] = {};
> >      int package_count = 2;
> >      packages[0].type = MaterialPackage;
> >      packages[1].type = SourcePackage;
> > +    packages[1].instance = 1;
> >
> >      if (entry = av_dict_get(s->metadata, "material_package_name",
> > NULL, 0))
> >         packages[0].name = entry->value;
> > @@ -1468,8 +1477,10 @@ static int
> > mxf_write_header_metadata_sets(AVFormatContext *s)
> >      mxf_write_preface(s);
> >      mxf_write_identification(s);
> >      mxf_write_content_storage(s, packages, package_count);
> > -    for (i = 0; i < package_count; i++)
> > -        mxf_write_package(s, &packages[i]);
> > +    for (i = 0; i < package_count; i++) {
> > +        packages[i].uuid_offset = track_count;
> > +        track_count += mxf_write_package(s, &packages[i]);
> > +    }
>
> I see st->index + 1 when deriving instance from uuid_offset, are you
> sure there isn't a potential off-by-one error here? An MP track and SP
> track getting the same UUID or something. I guess type is enough to
> differentiate, but then why does instance need uuid_offset?
>

I don't think so unless AVStream->index could get set incorrectly, is this
possible?
I had to change the old method because it falls apart when you add the 2nd
source package.
Basically the idea is since every 1 track has 1 sequence and 1 component
they can share the same instance number
Rethinking it a little bit I think I have come up with something simple
that achieves the same result, I'll send a new patch.


>
> /Tomas
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>


More information about the ffmpeg-devel mailing list