[FFmpeg-cvslog] r25967 - in trunk/libavcodec: ac3.c ac3.h ac3dec.h ac3enc.c

jbr subversion
Tue Dec 14 15:51:40 CET 2010


Author: jbr
Date: Tue Dec 14 15:51:40 2010
New Revision: 25967

Log:
define AC3_CRITICAL_BANDS and use it in the AC-3 encoder and decoder.

Modified:
   trunk/libavcodec/ac3.c
   trunk/libavcodec/ac3.h
   trunk/libavcodec/ac3dec.h
   trunk/libavcodec/ac3enc.c

Modified: trunk/libavcodec/ac3.c
==============================================================================
--- trunk/libavcodec/ac3.c	Tue Dec 14 15:51:36 2010	(r25966)
+++ trunk/libavcodec/ac3.c	Tue Dec 14 15:51:40 2010	(r25967)
@@ -33,7 +33,7 @@
 /**
  * Starting frequency coefficient bin for each critical band.
  */
-static const uint8_t band_start_tab[51] = {
+static const uint8_t band_start_tab[AC3_CRITICAL_BANDS+1] = {
       0,  1,   2,   3,   4,   5,   6,   7,   8,   9,
      10,  11, 12,  13,  14,  15,  16,  17,  18,  19,
      20,  21, 22,  23,  24,  25,  26,  27,  28,  31,
@@ -127,7 +127,7 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAll
                                uint8_t *dba_lengths, uint8_t *dba_values,
                                int16_t *mask)
 {
-    int16_t excite[50]; /* excitation */
+    int16_t excite[AC3_CRITICAL_BANDS]; /* excitation */
     int band;
     int band_start, band_end, begin, end1;
     int lowcomp, fastleak, slowleak;
@@ -198,7 +198,7 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAll
         band = 0;
         for (seg = 0; seg < dba_nsegs; seg++) {
             band += dba_offsets[seg];
-            if (band >= 50 || dba_lengths[seg] > 50-band)
+            if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band)
                 return -1;
             if (dba_values[seg] >= 4) {
                 delta = (dba_values[seg] - 3) << 7;
@@ -247,8 +247,8 @@ void ac3_parametric_bit_allocation(AC3Bi
                                    uint8_t *dba_values)
 {
     int16_t psd[256];   /* scaled exponents */
-    int16_t band_psd[50]; /* interpolated exponents */
-    int16_t mask[50];   /* masking value */
+    int16_t band_psd[AC3_CRITICAL_BANDS]; /* interpolated exponents */
+    int16_t mask[AC3_CRITICAL_BANDS];   /* masking value */
 
     ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, band_psd);
 
@@ -270,12 +270,12 @@ av_cold void ac3_common_init(void)
 #if !CONFIG_HARDCODED_TABLES
     /* compute bndtab and masktab from bandsz */
     int bin = 0, band;
-    for (band = 0; band < 50; band++) {
+    for (band = 0; band < AC3_CRITICAL_BANDS; band++) {
         int band_end = bin + ff_ac3_critical_band_size_tab[band];
         band_start_tab[band] = bin;
         while (bin < band_end)
             bin_to_band_tab[bin++] = band;
     }
-    band_start_tab[50] = bin;
+    band_start_tab[AC3_CRITICAL_BANDS] = bin;
 #endif /* !CONFIG_HARDCODED_TABLES */
 }

Modified: trunk/libavcodec/ac3.h
==============================================================================
--- trunk/libavcodec/ac3.h	Tue Dec 14 15:51:36 2010	(r25966)
+++ trunk/libavcodec/ac3.h	Tue Dec 14 15:51:40 2010	(r25967)
@@ -37,6 +37,7 @@
 #define AC3_MAX_BLOCKS    6
 #define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256)
 #define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2)
+#define AC3_CRITICAL_BANDS 50
 
 /* exponent encoding strategy */
 #define EXP_REUSE 0

Modified: trunk/libavcodec/ac3dec.h
==============================================================================
--- trunk/libavcodec/ac3dec.h	Tue Dec 14 15:51:36 2010	(r25966)
+++ trunk/libavcodec/ac3dec.h	Tue Dec 14 15:51:40 2010	(r25967)
@@ -168,8 +168,8 @@ typedef struct {
     int fast_gain[AC3_MAX_CHANNELS];                ///< fast gain values/SMR's         (fgain)
     uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS];   ///< bit allocation pointers
     int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS];   ///< scaled exponents
-    int16_t band_psd[AC3_MAX_CHANNELS][50];         ///< interpolated exponents
-    int16_t mask[AC3_MAX_CHANNELS][50];             ///< masking curve values
+    int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< interpolated exponents
+    int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];     ///< masking curve values
     int dba_mode[AC3_MAX_CHANNELS];                 ///< delta bit allocation mode
     int dba_nsegs[AC3_MAX_CHANNELS];                ///< number of delta segments
     uint8_t dba_offsets[AC3_MAX_CHANNELS][8];       ///< delta segment offsets

Modified: trunk/libavcodec/ac3enc.c
==============================================================================
--- trunk/libavcodec/ac3enc.c	Tue Dec 14 15:51:36 2010	(r25966)
+++ trunk/libavcodec/ac3enc.c	Tue Dec 14 15:51:40 2010	(r25967)
@@ -506,16 +506,16 @@ static void bit_alloc_masking(AC3EncodeC
                               uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
                               uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS],
                               int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
-                              int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][50])
+                              int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS])
 {
     int blk, ch;
-    int16_t band_psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][50];
+    int16_t band_psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
 
     for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
         for (ch = 0; ch < s->channels; ch++) {
             if(exp_strategy[blk][ch] == EXP_REUSE) {
                 memcpy(psd[blk][ch],  psd[blk-1][ch],  AC3_MAX_COEFS*sizeof(psd[0][0][0]));
-                memcpy(mask[blk][ch], mask[blk-1][ch], 50*sizeof(mask[0][0][0]));
+                memcpy(mask[blk][ch], mask[blk-1][ch], AC3_CRITICAL_BANDS*sizeof(mask[0][0][0]));
             } else {
                 ff_ac3_bit_alloc_calc_psd(encoded_exp[blk][ch], 0,
                                           s->nb_coefs[ch],
@@ -540,7 +540,7 @@ static void bit_alloc_masking(AC3EncodeC
  *         SNR offset is used to quantize the mantissas.
  */
 static int bit_alloc(AC3EncodeContext *s,
-                     int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][50],
+                     int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS],
                      int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
                      uint8_t bap[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
                      int frame_bits, int coarse_snr_offset, int fine_snr_offset)
@@ -584,7 +584,7 @@ static int compute_bit_allocation(AC3Enc
     int coarse_snr_offset, fine_snr_offset;
     uint8_t bap1[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];
     int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];
-    int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][50];
+    int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
     static const int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 };
 
     /* init default parameters */



More information about the ffmpeg-cvslog mailing list