[FFmpeg-soc] [Patch]MXF muxer version 0.0.3

zhentan feng spyfeng at gmail.com
Tue Aug 19 15:45:14 CEST 2008


Hi

2008/8/19 Michael Niedermayer <michaelni at gmx.at>

> On Tue, Aug 19, 2008 at 08:45:54PM +0800, zhentan feng wrote:
> > Hi
> >
> > 2008/8/19 Michael Niedermayer <michaelni at gmx.at>
> [...]
> > > [...]
> > > > +static int mxf_write_track(AVFormatContext *s, int stream_index,
> enum
> > > MXFMetadataSetType type, int *track_number_sign)
> > > > +{
> > > > +    ByteIOContext *pb = s->pb;
> > > > +    AVStream *st;
> > > > +    MXFStreamContext *sc;
> > > > +    const MXFCodecUL *element;
> > > > +    int i = 0;
> > > > +
> > > > +    mxf_write_metadata_key(pb, 0x013b00);
> > > > +#ifdef DEBUG
> > > > +    PRINT_KEY(s, "track key", pb->buf_ptr - 16);
> > > > +#endif
> > > > +    klv_encode_ber_length(pb, 80);
> > > > +
> > > > +    st = s->streams[stream_index];
> > > > +    sc = st->priv_data;
> > > > +
> > > > +    // write track uid
> > > > +    mxf_write_local_tag(pb, 16, 0x3C0A);
> > > > +    mxf_write_uuid(pb, Track * type, stream_index);
> > > > +#ifdef DEBUG
> > > > +    PRINT_KEY(s, "track uid", pb->buf_ptr - 16);
> > > > +#endif
> > > > +    // write track id
> > > > +    mxf_write_local_tag(pb, 4, 0x4801);
> > > > +    put_be32(pb, stream_index);
> > > > +
> > >
> > > > +    mxf_write_local_tag(pb, 4, 0x4804);
> > > > +    if (type != MaterialPackage) {
> > > > +        for (element = mxf_essence_element_key; element->id !=
> > > CODEC_ID_NONE; element++) {
> > > > +            if (st->codec->codec_id== element->id) {
> > > > +                // write track number
> > > > +                put_buffer(pb, element->uid + 12, 3);
> > > > +                put_byte(pb, element->uid[15] +
> track_number_sign[i]);
> > > > +                track_number_sign[i] ++;
> > > > +
> > > > +                // set essence_element key
> > >
> > > > +                memcpy(sc->track_essence_element_key, element->uid,
> 16);
> > >
> > > shouldnt [15] of track_essence_element_key be set to
> track_number_sign[i]
> > > as
> > > well?
> > >
> > I am not clear about your suggestion, could you please explain more?
> > thanks.
> >
> > and I explain my intention here:
> > last 4 bytes of essence element key is the track number.
> > the last byte ,ie byte 16, is the index of different essence element to
> > distinguish different track has the same element key.
> >
> > track_number_sign[i] record the  times of  the "i"th element key, when
> meet
> > the same element key , track_number_sign[i]++ , and be added on
> > track_essence_element[15], so the whole 16 bytes are used as element key.
>
> sc->track_essence_element_key is a copy of element->uid
> element->uid is from a static const table, thus it does not contain the
> "track number".
> The track number was just directly stored here with put_byte() it is
> missing
> from sc->track_essence_element_key
>
>
>
> >
> >
> > > > +                break;
> > > > +            }
> > > > +            i++;
> > > > +        }
> > > > +    } else {
> > > > +        put_be32(pb, 0); // track number of material package is 0
> > > > +    }
> > > > +
> > > > +    mxf_write_local_tag(pb, 8, 0x4B01);
> > > > +    put_be32(pb, st->time_base.den);
> > > > +    put_be32(pb, st->time_base.num);
> > > > +
> > > > +    // write origin
> > > > +    mxf_write_local_tag(pb, 8, 0x4B02);
> > > > +    put_be64(pb, 0);
> > > > +
> > > > +    // write sequence refs
> > > > +    mxf_write_local_tag(pb, 16, 0x4803);
> > >
> > > > +    mxf_write_uuid(pb, Sequence * Track * type, stream_index);
> > >
> > > Is it intended to multiply the values of 2 enums with the type ?
> > >
> > yes. we choose the value of the enum represent the type of the metadata
> set.
> > it will generate a type to represent Sequence set, because the enum value
> of
> > Sequence is not big enough, it may confilict with other metadata set.
>
> mxf_write_uuid(pb, type==SourcePackage ? FooBar : BarFoo, stream_index);
> seems much cleaner to me
> also it is less likely to break when more enums are added and something
> else happens to match Sequence * Track * type
>
> ok, I totaly understand.
thanks

-- 
Best wishes~



More information about the FFmpeg-soc mailing list