[FFmpeg-devel] [PATCH] mp3dec: Fix VBR bit rate parsing

Alexander Kojevnikov alexander at kojevnikov.com
Wed Feb 27 07:28:42 CET 2013


Commit 6776a8f[0] introduced a regression in calculation[1] of the bit
rate of VBR streams. Instead of keeping the bit rate from the Xiph
tag, it now overrides it during parsing with the bit rate from one of
the frames.

Attached patch should fix it. It relies on the assumption[2] that the
Xiph/Info tag has "Xiph" id string for VBR streams and "Info" for CBR.

To reproduce, take any VBR MP3 file and run this code on it:

    int main()
    {
        AVFormatContext *format_context = NULL;
        unsigned int i;

        av_register_all();
        avformat_open_input(&format_context, "test.mp3", NULL, NULL);
        avformat_find_stream_info(format_context, NULL);

        for (i = 0; i < format_context->nb_streams; i++) {
            if (format_context->streams[i]->codec->codec_type ==
AVMEDIA_TYPE_AUDIO) {
                AVCodecContext *codec_context =
format_context->streams[i]->codec;
                printf("bit_rate: %d\n", codec_context->bit_rate);
            }
        }

        return 0;
    }

[0]: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=6776a8f
[1]: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=49d7ef2
[2]: http://gabriel.mp3-tech.org/mp3infotag.html#layout
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mp3dec-Fix-VBR-bit-rate-parsing.patch
Type: application/octet-stream
Size: 2580 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130226/4fb9eeb4/attachment.obj>


More information about the ffmpeg-devel mailing list