[FFmpeg-devel] [patch][GSoC]WTV muxer (2_wtvenc.patch, 3_add_wtv_muxer.patch)

zhentan feng spyfeng at gmail.com
Tue Sep 13 11:54:44 CEST 2011


hi

On Fri, Sep 9, 2011 at 10:38 AM, Michael Niedermayer <michaelni at gmx.at>wrote:

> Hi
>
> On Tue, Aug 23, 2011 at 09:37:35PM +0800, zhentan feng wrote:
> [...]
> > diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> > index a9fa117..c11d744 100644
> > --- a/libavformat/allformats.c
> > +++ b/libavformat/allformats.c
> > @@ -224,7 +224,7 @@ void av_register_all(void)
> >      REGISTER_MUXER    (WEBM, webm);
> >      REGISTER_DEMUXER  (WSAUD, wsaud);
> >      REGISTER_DEMUXER  (WSVQA, wsvqa);
> > -    REGISTER_DEMUXER  (WTV, wtv);
> > +    REGISTER_MUXDEMUX (WTV, wtv);
>
> trailing whitespace
>
>

removed.


> [...]
> > +typedef struct {
> > +    int64_t timeline_start_pos;
> > +    WtvFile file[WTV_FILES];
> > +    int64_t serial;         // chunk serial number
> > +    int64_t last_chunk_pos; // last chunk position
>
> not doxygen compatible comments
>
>

fixed.

>
> [...]
> > +/**
> > + * Write chunk header. If header chunk (0x80000000 set) then add to list
> of header chunks
> > + */
> > +static void write_chunk_header(AVFormatContext *s, const ff_asf_guid
> *guid, int length, int stream_id)
> > +{
> > +    WtvContext *wctx = s->priv_data;
> > +    AVIOContext *pb = s->pb;
> > +
> > +    wctx->last_chunk_pos = avio_tell(pb) - wctx->timeline_start_pos;
> > +    put_guid(pb, guid);
> > +    avio_wl32(pb, 32 + length);
> > +    avio_wl32(pb, stream_id);
> > +    avio_wl64(pb, wctx->serial);
> > +
> > +    if ((stream_id & 0x80000000) && guid != &index_guid) {
>
> please add a check here that makes sure nb_index is not too large
> i dont know if it can become too large but i think its safer to
> check than to risk overwriting memory
>
>

Yes, the value for nb_index is constrained by MAX_NB_INDEX.
nb_index will be reset to zero in write_index().
IMHO, it's safe here.

>
> > +        WtvChunkEntry *t = wctx->index + wctx->nb_index;
> > +        t->pos       = wctx->last_chunk_pos;
> > +        t->serial    = wctx->serial;
> > +        t->guid      = guid;
> > +        t->stream_id = stream_id & 0x3FFFFFFF;
> > +        wctx->nb_index++;
> > +    }
> > +}
> > +
> > +static void write_chunk_header2(AVFormatContext *s, const ff_asf_guid
> *guid, int stream_id)
> > +{
> > +    WtvContext *wctx = s->priv_data;
> > +    AVIOContext *pb = s->pb;
> > +
> > +    int64_t last_chunk_pos = wctx->last_chunk_pos;
> > +    write_chunk_header(s, guid, 0, stream_id); // lenth updated later
>
> length
>




fixed.

Please review the latest patch.
thanks
zhentan
-- 
Best wishes~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wtv_muxer.patch
Type: application/octet-stream
Size: 24536 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110913/4868504b/attachment.obj>


More information about the ffmpeg-devel mailing list