[FFmpeg-devel] [PATCH] BFI demuxer

Sisir Koppaka sisir.koppaka
Sat Apr 12 16:43:54 CEST 2008


On Sat, Apr 12, 2008 at 6:11 PM, Michael Niedermayer <michaelni at gmx.at>
wrote:

> On Sat, Apr 12, 2008 at 12:27:08PM +0530, Sisir Koppaka wrote:
> > Updated patch attached.
>
> [...]
> > +    int fps, width, height, sample_rate, chunk_header;
>
> 3 of these are unneeded at least
>
Removed width, height and sample_rate.

>
>
> [...]
> > +    /* Setting 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;
> > +    get_le32(pb);
> > +    get_le32(pb);
> > +    get_le32(pb);
> > +    fps              = get_le32(pb);
>
> > +    url_fseek(pb, 12, SEEK_CUR);
>
> url_fskip() :)
>
> :) Changed to fskip...

>
> [...]
> > +    /* Setting up the video codec... */
> > +    av_set_pts_info(vstream, 32, 1, fps);
> > +    vstream->codec->codec_type = CODEC_TYPE_VIDEO;
> > +    vstream->codec->codec_id   = CODEC_ID_BFI;
> > +    vstream->codec->width      = width;
> > +    vstream->codec->height     = height;
> > +    vstream->codec->pix_fmt    = PIX_FMT_PAL8;
> > +
> > +    /* Setting up the audio codec now... */
> > +    astream->codec->codec_type  = CODEC_TYPE_AUDIO;
> > +    astream->codec->codec_id    = CODEC_ID_PCM_U8;
> > +    astream->codec->sample_rate = sample_rate;
> > +    av_log(NULL, AV_LOG_DEBUG, "\n sample_rate = %d",
> > +           astream->codec->sample_rate);
> > +    astream->codec->channels    = 1;
>
> > +    astream->codec->bits_per_sample =
> > +        av_get_bits_per_sample(astream->codec->codec_id);
>
> This still can be simplified
>
I replaced the function call with a constant 8.

>
>
> [...]
> > +        /* Trying to confirm the chunk by matching the header... */
> > +        while (1) {
> > +            c = get_byte(pb);
> > +            if (url_feof(pb))
> > +                return AVERROR(EIO);
> > +            if (c == 'I') {
> > +                if (get_byte(pb) == 'V' && get_byte(pb) == 'A'
> > +                    && get_byte(pb) == 'S')
> > +                    break;
> > +            }
> > +        }
>
> uint32_t state=0;
> while(state != MKTAG('I','V','A','S')){
>     if (url_feof(pb))
>        return AVERROR(EIO);
>     state= 256*state + get_byte(pb);
> }
>
> Nice :) I declared the state variable as you did, as a temporary variable
within the if..else and not at the top because we don't need it in half the
instances of the function.
Funnily enough, though the hexeditor shows IVAS, it looks like we have to
write MKTAG('S','A','V','I') because of little endianess...I made this
change and replaced the while with yours.
-----------------
Sisir Koppaka




More information about the ffmpeg-devel mailing list