[FFmpeg-soc] MXF muxer version 0.0.4

Michael Niedermayer michaelni at gmx.at
Mon Aug 25 16:24:37 CEST 2008


On Mon, Aug 25, 2008 at 08:13:21PM +0800, zhentan feng wrote:
> Hi
> 
> 2008/8/23 Michael Niedermayer <michaelni at gmx.at>
> 
> 
> > [...]
> > > +static int mxf_write_essence_container_refs(AVFormatContext *s, int
> > write)
> > > +{
> >
> > > +    MXFContext *mxf = s->priv_data;
> >
> > unused
> >
> >
> > > +    ByteIOContext *pb = s->pb;
> > > +    AVStream *st;
> > > +    int i, count = 0, j = 0;
> >
> > > +    int essence_container_ul_sign[32] = { 0 };
> >
> > the size 32, could be too small when more entries are added to
> > ff_mxf_essence_container_uls and there are more than 32 streams.
> >
> >
> > [...]
> >
> 
> here is the new patch version 0.0.7 for this issue.
> please review.
> thanks.
> -- 
> Best wishes~

> Index: libavformat/mxfenc.c
> ===================================================================
> --- libavformat/mxfenc.c	(revision 14965)
> +++ libavformat/mxfenc.c	(working copy)
> @@ -245,6 +245,42 @@
>      return uls;
>  }
>  
> +static int mxf_write_essence_container_refs(AVFormatContext *s, int write)
> +{
> +    ByteIOContext *pb = s->pb;
> +    AVStream *st;
> +    int i, count = 0, j = 0;
> +    int essence_container_ul_sign[1024] = { 0 };

this doesnt solve the problem
the size of this array should match that of ff_mxf_essence_container_uls


> +    const MXFCodecUL *codec_ul;
> +
> +    for (codec_ul = ff_mxf_essence_container_uls; codec_ul->id; codec_ul++) {
> +        for (i = 0; i < s->nb_streams; i++) {
> +            st = s->streams[i];
> +            if (st->codec->codec_id == codec_ul->id) {
> +                essence_container_ul_sign[count] = j;
> +                count++;
> +                break;
> +            }
> +        }
> +        j++;
> +        // considering WAV/AES3 frame wrapped, when get the first CODEC_ID_PCM_S16LE, break;
> +        // this is a temporary method, when we can get  more information, modofy this.
> +        if (codec_ul->id == CODEC_ID_PCM_S16LE)
> +            break;
> +    }
> +
> +    if (write) {
> +        mxf_write_refs_count(pb, count);
> +        for (i = 0; i < count; i++) {
> +            put_buffer(pb, ff_mxf_essence_container_uls[essence_container_ul_sign[i]].uid, 16);
> +        }
> +        av_log(s,AV_LOG_DEBUG, "essence container count:%d\n", count);
> +        for (i = 0; i < count; i++)
> +            PRINT_KEY(s, "essence container ul:\n", ff_mxf_essence_container_uls[essence_container_ul_sign[i]].uid);
> +    }
> +    return count;
> +}
> +
>  static void mxf_write_preface(AVFormatContext *s)
>  {
>      MXFContext *mxf = s->priv_data;

> @@ -468,20 +504,6 @@
>      put_be64(pb, st->duration);
>  }
>  
> -static int mux_write_packet(AVFormatContext *s, AVPacket *pkt)
> -{
> -    ByteIOContext *pb = s->pb;
> -    AVStream *st = s->streams[pkt->stream_index];
> -    MXFStreamContext *sc = st->priv_data;
> -
> -    put_buffer(pb, sc->track_essence_element_key, 16); // write key
> -    klv_encode_ber_length(pb, pkt->size); // write length
> -    put_buffer(pb, pkt->data, pkt->size); // write value
> -
> -    put_flush_packet(pb);
> -    return 0;
> -}
> -
>  static void mxf_write_sequence(AVFormatContext *s, int stream_index, enum MXFMetadataSetType type)
>  {
>      ByteIOContext *pb = s->pb;

ok


> @@ -612,8 +634,8 @@
>      put_be32(pb, st->codec->height);
>  
>      mxf_write_local_tag(pb, 8, 0x320E);
> -    put_be32(pb, st->codec->height * st->sample_aspect_ratio.den);
> -    put_be32(pb, st->codec->width  * st->sample_aspect_ratio.num);
> +    put_be32(pb, st->codec->height * st->codec->sample_aspect_ratio.den);
> +    put_be32(pb, st->codec->width * st->codec->sample_aspect_ratio.num);
>  
>      // tmp write, will modified later
>      mxf_write_local_tag(pb, 16, 0x3201);

This should not be needed
st->sample_aspect_ratio and st->codec->sample_aspect_ratio should be
identical
if they are not, then there is a bug elsewhere in libavformat



> @@ -773,6 +795,20 @@
>      return -1;
>  }
>  
> +static int mux_write_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +    ByteIOContext *pb = s->pb;
> +    AVStream *st = s->streams[pkt->stream_index];
> +    MXFStreamContext *sc = st->priv_data;
> +
> +    put_buffer(pb, sc->track_essence_element_key, 16); // write key
> +    klv_encode_ber_length(pb, pkt->size); // write length
> +    put_buffer(pb, pkt->data, pkt->size); // write value
> +
> +    put_flush_packet(pb);
> +    return 0;
> +}
> +
>  static void mxf_update_header_partition(AVFormatContext *s, int64_t footer_partition_offset)
>  {
>      MXFContext *mxf = s->priv_data;

ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Thouse who are best at talking, realize last or never when they are wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080825/8b03bdf6/attachment.pgp>


More information about the FFmpeg-soc mailing list