[FFmpeg-devel] BFI Demuxer

Michael Niedermayer michaelni
Tue Apr 1 12:32:14 CEST 2008


On Tue, Apr 01, 2008 at 02:52:04PM +0530, Sisir Koppaka wrote:
> Hi,
> I got the BFI demuxer without video support(only audio support) working a
> few days ago. I then added the video stream and now the video stream plays
> but not the audio one! I think I may have done some mistake with the stream
> handling.
> Setting the pts(I went through this -
> http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2007-March/025999.html ,
> but still...) is another thing I'm not sure about. But it did play the audio
> well at one point of time so, I guess I'm doing something wrong now.
> I've also attached a log of the shell output (I used av_logs for
> debugging...) if it may be required. From the logs it looks like the packets
> are definitely going to the audio decoder...so haven't been able to figure
> out why the audio isn't coming out. I'm working on the video decoder...which
> I think is still not worthy of FFmpeg-devel so I'll post it later today in
> FFmpeg-soc along with my doubts and it's current status.
> 
> Fixed indentation and removed, hopefully, all the trailing whitespaces.

[...]

> +/*
> + * Based on http://wiki.multimedia.cx/index.php?title=BFI
> + */

comment is not doxygen compatible


> +
> +#include "avformat.h"
> +
> +typedef struct BFIContext {
> +    int nframes;
> +    int palette_set;
> +    int width;
> +    int height;
> +    int chunk_header;
> +    int audio_offset;
> +    int video_offset;
> +    int audio_size;
> +    int video_size;
> +    int chunk_size;
> +    int audio_index;
> +    int video_index;
> +    int avflag;

> +    int buffer_size;

unused


> +    int sample_rate;
> +    int channels;

duplicate


[...]
> +static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap)
> +{
> +    BFIContext *bfi = s->priv_data;
> +    ByteIOContext *pb = s->pb;
> +    AVStream *vstream;
> +    AVStream *astream;
> +    int i;
> +    /* Setting total number of frames, nframes will change while nframesOrig will not over the course of execution */

> +    url_fseek(pb, 8, SEEK_SET);

url_fskip()


[...]
> +    /*Improving colour depth */
> +    for (i = 0; i < vstream->codec->extradata_size; i++)
> +        ((uint8_t *) vstream->codec->extradata)[i] =
> +            ((uint8_t *) vstream->codec->extradata)[i] << 2;

senseless casts, and the comment makes no sense.


> +    av_set_pts_info(vstream, 32, 1, bfi->fps);
> +    vstream->codec->codec_type = CODEC_TYPE_VIDEO;
> +    vstream->codec->codec_id = CODEC_ID_BFI;
> +    vstream->codec->width = bfi->width;
> +    vstream->codec->height = bfi->height;
> +    vstream->codec->pix_fmt = PIX_FMT_PAL8;
> +    /* Setting up the audio codec now... */
> +    astream = av_new_stream(s, 0);      /* shouldn't 0 be 1 here */
> +    if (!astream)
> +        return AVERROR(ENOMEM);

> +    bfi->audio_index = astream->index;

unneeded


[...]
> +        while (get_byte(pb) != 'I') {
> +            continue;
> +        }

infinite loop


> +        url_fseek(pb, -1, SEEK_CUR);

breaks unseekable input


> +        av_log(NULL, AV_LOG_INFO, "\nFound a chunk...");
> +        if (get_le32(pb) == MKTAG('I', 'V', 'A', 'S')) {
> +            av_log(NULL, AV_LOG_INFO,
> +                   "\nChunk number %d confirmed with IVAS identifier...",
> +                   bfi->nframes);
> +            bfi->chunk_size = get_le32(pb);
> +            av_log(NULL, AV_LOG_INFO, "\nNext chunk header offset is %d",
> +                   bfi->chunk_size);
> +            get_le32(pb);
> +            bfi->audio_offset = get_le32(pb);
> +            av_log(NULL, AV_LOG_INFO, "\nAudio offset is %d",
> +                   bfi->audio_offset);
> +            get_le32(pb);
> +            bfi->video_offset = get_le32(pb);
> +            av_log(NULL, AV_LOG_INFO, "\nVideo offset is %d",
> +                   bfi->video_offset);
> +            bfi->audio_size = bfi->video_offset - bfi->audio_offset;
> +            bfi->video_size = bfi->chunk_size - bfi->video_offset;
> +            bfi->chunk_header = bfi->chunk_size - bfi->video_offset;
> +            //url_fseek(pb,bfi->audio_offset - 16, SEEK_CUR);
> +            av_log(NULL, AV_LOG_INFO, "\nReading audio of this chunk...");
> +//        bfi->remaining_size = bfi->video_offset - bfi->audio_offset;
> +        } else
> +            goto move;
> +    }
> +    switch (bfi->avflag) {
> +    case 0:                    //Audio will be sent now.
> +        pkt->stream_index = bfi->audio_index;

> +        pkt->pts = 1;

as has already been pointet out, this is wrong


> +        cod->codec_id = CODEC_ID_PCM_U8;
> +        cod->sample_rate = bfi->sample_rate;
> +        cod->bits_per_sample = bfi->bits_per_sample;
> +        cod->bit_rate = cod->sample_rate * cod->bits_per_sample;        // * cod->channels ;
> +        cod->channels = 1;

doing that for each packet makes no sense


[...]

> +static int bfi_read_close(AVFormatContext * s)
> +{
> +    BFIContext *bfi = s->priv_data;
> +    av_free(s->streams[bfi->video_index]->codec->extradata);

this is wrong

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- 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/20080401/1c2d88b5/attachment.pgp>



More information about the ffmpeg-devel mailing list