[FFmpeg-devel] [PATCH] BFI demuxer

Michael Niedermayer michaelni
Sat Apr 12 21:36:07 CEST 2008


On Sun, Apr 13, 2008 at 12:34:10AM +0530, Sisir Koppaka wrote:
> Updated patch attached. Made the superfluous () change  and edited the close
> function. Is this one ok?
> 
> On Sun, Apr 13, 2008 at 12:17 AM, Michael Niedermayer <michaelni at gmx.at>
> wrote:
> 
> > On Sat, Apr 12, 2008 at 11:22:07PM +0530, Sisir Koppaka wrote:
> > > I suppose it's wrong because it's only supposed to close the stream and
> > not
> > > free AVFormatContext etc...I saw some of the other demuxers and they are
> > > freeing any pointers that they created in their local structures(in
> > > priv_data) but since I didn't do any, can I just return 0; ?
> >
> > yes
> >
> Fixed :)
[...]
> +static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap)
> +{
> +    BFIContext *bfi = s->priv_data;
> +    ByteIOContext *pb = s->pb;
> +    AVStream *vstream;
> +    AVStream *astream;
> +    int fps, chunk_header;
> +
> +    /* Initialize the video codec... */
> +    vstream = av_new_stream(s, 0);
> +    if (!vstream)
> +        return AVERROR(ENOMEM);
> +
> +    /* Initialize the audio codec... */
> +    astream = av_new_stream(s, 0);
> +    if (!astream)
> +        return AVERROR(ENOMEM);
> +
> +    /* Set the total number of frames. */
> +    url_fskip(pb, 8);
> +    chunk_header     = get_le32(pb);
> +    bfi->nframes     = get_le32(pb);

> +    bfi->audio_frame = 0;
> +    bfi->video_frame = 0;

The context is automatically initalized to 0 thus these are unneeded.


[...]
> +static int bfi_read_close(AVFormatContext *s)
> +{
> +    return 0;
> +}
> +
> +AVInputFormat bfi_demuxer = {
> +    "bfi",
> +    "Brute Force & Ignorance",
> +    sizeof(BFIContext),
> +    bfi_probe,
> +    bfi_read_header,
> +    bfi_read_packet,
> +    bfi_read_close,

as bfi_read_close() does nothing now, you can as well just use NULL instead
of it. And trailing NULL in a struct initalization can be omited.

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- 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-devel/attachments/20080412/8ee5b25f/attachment.pgp>



More information about the ffmpeg-devel mailing list