diff options
author | Alexander Kojevnikov <alexander@kojevnikov.com> | 2013-02-27 09:47:11 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-05 16:06:01 +0400 |
commit | 29d8cd265a536063420afe78375b2176a9e1abc5 (patch) | |
tree | 89d1f5303bf7e7654e3fc8ebe8de1f9cadd1742c /libavcodec | |
parent | d2b0b839b9e39ec98cb3f36dd692448f93a8b6d7 (diff) |
mp3dec: Fix VBR bit rate parsing
When parsing the Xing/Info tag, don't set the bit rate if it's an Info tag.
When parsing the stream, don't override the bit rate if it's already set,
otherwise calculate the mean bit rate from parsed frames. This way, the bit
rate will be set correctly both for CBR and VBR streams.
Signed-off-by: Alexander Kojevnikov <alexander@kojevnikov.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mpegaudio_parser.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 5f97d711c6..bb4d75c066 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -30,6 +30,7 @@ typedef struct MpegAudioParseContext { int frame_size; uint32_t header; int header_count; + int no_bitrate; } MpegAudioParseContext; #define MPA_HEADER_SIZE 4 @@ -74,15 +75,18 @@ static int mpegaudio_parse(AVCodecParserContext *s1, if((state&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header) s->header_count= -3; s->header= state; - s->header_count++; s->frame_size = ret-4; - if (s->header_count > 1) { + if (s->header_count > 0) { avctx->sample_rate= sr; avctx->channels = channels; s1->duration = frame_size; - avctx->bit_rate = bit_rate; + if (s->no_bitrate || !avctx->bit_rate) { + s->no_bitrate = 1; + avctx->bit_rate += (bit_rate - avctx->bit_rate) / s->header_count; + } } + s->header_count++; break; } } |