From 4707cb07e1ceb0d1a518eda08fbf0d4035ea7745 Mon Sep 17 00:00:00 2001 From: Fabrice Bellard Date: Thu, 31 Oct 2002 00:07:13 +0000 Subject: [PATCH] fixed nb_block_sizes detection - fixed codec_id test (avctx->codec_id does not need to be initialized) Originally committed as revision 1121 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/wmadec.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index f48f09727..b2288cedc 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -245,7 +245,7 @@ static int wma_decode_init(AVCodecContext * avctx) s->bit_rate = avctx->bit_rate; s->block_align = avctx->block_align; - if (avctx->codec_id == CODEC_ID_WMAV1) { + if (avctx->codec->id == CODEC_ID_WMAV1) { s->version = 1; } else { s->version = 2; @@ -278,7 +278,14 @@ static int wma_decode_init(AVCodecContext * avctx) } s->frame_len = 1 << s->frame_len_bits; if (s->use_variable_block_len) { - s->nb_block_sizes = s->frame_len_bits - BLOCK_MIN_BITS + 1; + int nb_max, nb; + nb = ((flags2 >> 3) & 3) + 1; + if ((s->bit_rate / s->nb_channels) >= 32000) + nb += 2; + nb_max = s->frame_len_bits - BLOCK_MIN_BITS; + if (nb > nb_max) + nb = nb_max; + s->nb_block_sizes = nb + 1; } else { s->nb_block_sizes = 1; } @@ -353,8 +360,8 @@ static int wma_decode_init(AVCodecContext * avctx) s->block_align); printf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n", bps, bps1, high_freq, s->byte_offset_bits); - printf("use_noise_coding=%d use_exp_vlc=%d\n", - s->use_noise_coding, s->use_exp_vlc); + printf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n", + s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes); #endif /* compute the scale factor band sizes for each MDCT block size */ -- 2.11.0