diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-11-06 00:04:51 +0100 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2014-11-06 01:02:53 +0100 |
commit | c7b64a904ae3f90f3994a4abd599bbc76ca540be (patch) | |
tree | fb6507a5848faf02946ef960190e73dd3c467c6c /libavcodec | |
parent | 9798dc8061c99875fa225b96884b2db1c0ee165a (diff) | |
download | ffmpeg-c7b64a904ae3f90f3994a4abd599bbc76ca540be.tar.gz |
avcodec/mpegaudio_parser: fix off by 1 error in bitrate calculation
Fixes Ticket3918
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 817663897e59f45f60016fa9d3d16e325b803967)
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mpegaudio_parser.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 3d9e94688a..79dbf635b4 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -73,20 +73,21 @@ static int mpegaudio_parse(AVCodecParserContext *s1, if (i > 4) s->header_count = -2; } else { + int header_threshold = avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec_id; 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 > 0 + (avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec_id)) { + if (s->header_count > header_threshold) { avctx->sample_rate= sr; avctx->channels = channels; s1->duration = frame_size; avctx->codec_id = codec_id; if (s->no_bitrate || !avctx->bit_rate) { s->no_bitrate = 1; - avctx->bit_rate += (bit_rate - avctx->bit_rate) / s->header_count; + avctx->bit_rate += (bit_rate - avctx->bit_rate) / (s->header_count - header_threshold); } } break; |