[FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size

Baptiste Coudurier baptiste.coudurier at gmail.com
Wed Aug 22 18:11:53 EEST 2018


On Wed, Jul 4, 2018 at 6:21 PM, Michael Niedermayer <michael at niedermayer.cc>
wrote:

> On Wed, Jul 04, 2018 at 11:35:03AM -0700, Baptiste Coudurier wrote:
> > ---
> >  libavformat/mxfenc.c | 80 +++++++++++++++++++++-----------------------
> >  1 file changed, 39 insertions(+), 41 deletions(-)
> >
> > diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> > index 77f60f5874..b98d234f03 100644
> > --- a/libavformat/mxfenc.c
> > +++ b/libavformat/mxfenc.c
> > @@ -1104,14 +1104,16 @@ static void mxf_write_multi_descriptor(AVFormatContext
> *s)
> >          mxf_write_uuid(pb, SubDescriptor, i);
> >  }
> >
> > -static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st,
> const UID key, unsigned size)
> > +static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream
> *st, const UID key)
> >  {
> >      MXFContext *mxf = s->priv_data;
> >      MXFStreamContext *sc = st->priv_data;
> >      AVIOContext *pb = s->pb;
> > +    int64_t pos;
> >
> >      avio_write(pb, key, 16);
> > -    klv_encode_ber4_length(pb, size+20+8+12+20);
> > +    klv_encode_ber4_length(pb, 0);
> > +    pos = avio_tell(pb);
> >
> >      mxf_write_local_tag(pb, 16, 0x3C0A);
> >      mxf_write_uuid(pb, SubDescriptor, st->index);
> > @@ -1136,6 +1138,8 @@ static void mxf_write_generic_desc(AVFormatContext
> *s, AVStream *st, const UID k
> >
> >      mxf_write_local_tag(pb, 16, 0x3004);
> >      avio_write(pb, mxf_essence_container_uls[sc->index].container_ul,
> 16);
> > +
> > +    return pos;
> >  }
> >
> >  static const UID mxf_mpegvideo_descriptor_key = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00
> };
> > @@ -1172,7 +1176,7 @@ static int get_trc(UID ul, enum
> AVColorTransferCharacteristic trc)
> >      }
> >  }
> >
> > -static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st,
> const UID key, unsigned size)
> > +static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st,
> const UID key)
> >  {
> >      MXFStreamContext *sc = st->priv_data;
> >      AVIOContext *pb = s->pb;
> > @@ -1180,25 +1184,10 @@ static void mxf_write_cdci_common(AVFormatContext
> *s, AVStream *st, const UID ke
> >      int stored_height = (st->codecpar->height+15)/16*16;
> >      int display_height;
> >      int f1, f2;
> > -    unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5 + 5*8 + 6;
> >      UID transfer_ul = {0};
> > +    int64_t pos = mxf_write_generic_desc(s, st, key);
> >
> > -    if (sc->interlaced && sc->field_dominance)
> > -        desc_size += 5;
> > -    if (sc->signal_standard)
> > -        desc_size += 5;
> > -    if (sc->interlaced)
> > -        desc_size += 8;
> > -    if (sc->v_chroma_sub_sample)
> > -        desc_size += 8;
> > -    if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED)
> > -        desc_size += 8 * 3;
> > -    if (s->oformat == &ff_mxf_d10_muxer)
> > -        desc_size += 8 + 8 + 8;
> > -    if (get_trc(transfer_ul, st->codecpar->color_trc) >= 0)
> > -        desc_size += 20;
> > -
> > -    mxf_write_generic_desc(s, st, key, desc_size);
> > +    get_trc(transfer_ul, st->codecpar->color_trc);
>
> nice simplification!
>

Applied.

-- 
Baptiste


More information about the ffmpeg-devel mailing list