summaryrefslogtreecommitdiff
path: root/libavcodec/mpegaudiodec.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2012-05-16 18:39:40 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2012-05-20 10:53:21 +0200
commitb37d945dd4213cb8e92146571b0374cd45d52286 (patch)
treedb7c8b0336d14e44515d90a71567c4a10e5796a8 /libavcodec/mpegaudiodec.c
parent68aef0b481f11931f078dc915a93bdfa680f90a4 (diff)
mp3: fix start band index for block type 2 in 8kHz audio
In hybrid frames long window part ends at 36 samples for most of the cases but at 72 for 8kHz case. For some reason decoder assumed it's 48 or even 36 samples, which caused wrong bitstream decoding for such blocks. l3_25207.mpg from conformance suite demonstrates it the best.
Diffstat (limited to 'libavcodec/mpegaudiodec.c')
-rw-r--r--libavcodec/mpegaudiodec.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index f72e65cb0e..6c1e8af845 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -174,9 +174,12 @@ static void ff_region_offset2size(GranuleDef *g)
static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g)
{
- if (g->block_type == 2)
- g->region_size[0] = (36 / 2);
- else {
+ if (g->block_type == 2) {
+ if (s->sample_rate_index != 8)
+ g->region_size[0] = (36 / 2);
+ else
+ g->region_size[0] = (72 / 2);
+ } else {
if (s->sample_rate_index <= 2)
g->region_size[0] = (36 / 2);
else if (s->sample_rate_index != 8)
@@ -201,14 +204,12 @@ static void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g)
if (g->block_type == 2) {
if (g->switch_point) {
/* if switched mode, we handle the 36 first samples as
- long blocks. For 8000Hz, we handle the 48 first
- exponents as long blocks (XXX: check this!) */
+ long blocks. For 8000Hz, we handle the 72 first
+ exponents as long blocks */
if (s->sample_rate_index <= 2)
g->long_end = 8;
- else if (s->sample_rate_index != 8)
- g->long_end = 6;
else
- g->long_end = 4; /* 8000 Hz */
+ g->long_end = 6;
g->short_start = 2 + (s->sample_rate_index != 8);
} else {
@@ -1018,7 +1019,7 @@ static void reorder_block(MPADecodeContext *s, GranuleDef *g)
if (s->sample_rate_index != 8)
ptr = g->sb_hybrid + 36;
else
- ptr = g->sb_hybrid + 48;
+ ptr = g->sb_hybrid + 72;
} else {
ptr = g->sb_hybrid;
}