[FFmpeg-cvslog] r13587 - trunk/libavcodec/ac3dec.c

jbr subversion
Sat May 31 23:53:31 CEST 2008


Author: jbr
Date: Sat May 31 23:53:31 2008
New Revision: 13587

Log:
only calculate number of exponent groups when exponents are not reused.

Modified:
   trunk/libavcodec/ac3dec.c

Modified: trunk/libavcodec/ac3dec.c
==============================================================================
--- trunk/libavcodec/ac3dec.c	(original)
+++ trunk/libavcodec/ac3dec.c	Sat May 31 23:53:31 2008
@@ -154,6 +154,7 @@ typedef struct {
     int   end_freq[AC3_MAX_CHANNELS];       ///< end frequency bin
     AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters
 
+    int num_exp_groups[AC3_MAX_CHANNELS];   ///< Number of exponent groups
     int8_t  dexps[AC3_MAX_CHANNELS][256];   ///< decoded exponents
     uint8_t bap[AC3_MAX_CHANNELS][256];     ///< bit allocation pointers
     int16_t psd[AC3_MAX_CHANNELS][256];     ///< scaled exponents
@@ -907,6 +908,7 @@ static int ac3_parse_audio_block(AC3Deco
     for (ch = 1; ch <= fbw_channels; ch++) {
         s->start_freq[ch] = 0;
         if (s->exp_strategy[ch] != EXP_REUSE) {
+            int group_size;
             int prev = s->end_freq[ch];
             if (s->channel_in_cpl[ch])
                 s->end_freq[ch] = s->start_freq[CPL_CH];
@@ -918,26 +920,26 @@ static int ac3_parse_audio_block(AC3Deco
                 }
                 s->end_freq[ch] = bandwidth_code * 3 + 73;
             }
+            group_size = 3 << (s->exp_strategy[ch] - 1);
+            s->num_exp_groups[ch] = (s->end_freq[ch]+group_size-4) / group_size;
             if(blk > 0 && s->end_freq[ch] != prev)
                 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
         }
     }
     s->start_freq[s->lfe_ch] = 0;
     s->end_freq[s->lfe_ch] = 7;
+    s->num_exp_groups[s->lfe_ch] = 2;
+    if (s->cpl_in_use && s->exp_strategy[CPL_CH] != EXP_REUSE) {
+        s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) /
+                                    (3 << (s->exp_strategy[CPL_CH] - 1));
+    }
 
     /* decode exponents for each channel */
     for (ch = !s->cpl_in_use; ch <= s->channels; ch++) {
         if (s->exp_strategy[ch] != EXP_REUSE) {
-            int group_size, num_groups;
-            group_size = 3 << (s->exp_strategy[ch] - 1);
-            if(ch == CPL_CH)
-                num_groups = (s->end_freq[ch] - s->start_freq[ch]) / group_size;
-            else if(ch == s->lfe_ch)
-                num_groups = 2;
-            else
-                num_groups = (s->end_freq[ch] + group_size - 4) / group_size;
             s->dexps[ch][0] = get_bits(gbc, 4) << !ch;
-            decode_exponents(gbc, s->exp_strategy[ch], num_groups, s->dexps[ch][0],
+            decode_exponents(gbc, s->exp_strategy[ch],
+                             s->num_exp_groups[ch], s->dexps[ch][0],
                              &s->dexps[ch][s->start_freq[ch]+!!ch]);
             if(ch != CPL_CH && ch != s->lfe_ch)
                 skip_bits(gbc, 2); /* skip gainrng */




More information about the ffmpeg-cvslog mailing list