changeset 808:e9bfaabcf07d libavcodec

fixed nb_block_sizes detection - fixed codec_id test (avctx->codec_id does not need to be initialized)
author bellard
date Thu, 31 Oct 2002 00:07:13 +0000
parents 0e1d375c537f
children 79de6308c34d
files wmadec.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/wmadec.c	Wed Oct 30 22:55:07 2002 +0000
+++ b/wmadec.c	Thu Oct 31 00:07:13 2002 +0000
@@ -245,7 +245,7 @@
     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 @@
     }
     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 @@
            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 */