[FFmpeg-soc] [soc]: r1548 - in eac3: ac3.c ac3.h ac3dec.c ac3dec.h ac3tab.c ac3tab.h checkout.sh eac3.h eac3dec.c ffmpeg.patch

jbr subversion at mplayerhq.hu
Tue Dec 11 03:38:13 CET 2007


Author: jbr
Date: Tue Dec 11 03:38:13 2007
New Revision: 1548

Log:
update from FFmpeg SVN-r10220 to SVN-r11200

Modified:
   eac3/ac3.c
   eac3/ac3.h
   eac3/ac3dec.c
   eac3/ac3dec.h
   eac3/ac3tab.c
   eac3/ac3tab.h
   eac3/checkout.sh
   eac3/eac3.h
   eac3/eac3dec.c
   eac3/ffmpeg.patch

Modified: eac3/ac3.c
==============================================================================
--- eac3/ac3.c	(original)
+++ eac3/ac3.c	Tue Dec 11 03:38:13 2007
@@ -28,8 +28,8 @@
 #include "ac3.h"
 #include "bitstream.h"
 
-static uint8_t bndtab[51];
-static uint8_t masktab[253];
+static uint8_t band_start_tab[51];
+static uint8_t bin_to_band_tab[253];
 
 static inline int calc_lowcomp1(int a, int b0, int b1, int c)
 {
@@ -53,7 +53,7 @@ static inline int calc_lowcomp(int a, in
 }
 
 void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
-                               int16_t *bndpsd)
+                               int16_t *band_psd)
 {
     int bin, i, j, k, end1, v;
 
@@ -64,26 +64,26 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *e
 
     /* PSD integration */
     j=start;
-    k=masktab[start];
+    k=bin_to_band_tab[start];
     do {
         v=psd[j];
         j++;
-        end1 = FFMIN(bndtab[k+1], end);
+        end1 = FFMIN(band_start_tab[k+1], end);
         for(i=j;i<end1;i++) {
             /* logadd */
             int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255);
-            v = FFMAX(v, psd[j]) + ff_ac3_latab[adr];
+            v = FFMAX(v, psd[j]) + ff_ac3_log_add_tab[adr];
             j++;
         }
-        bndpsd[k]=v;
+        band_psd[k]=v;
         k++;
-    } while (end > bndtab[k]);
+    } while (end > band_start_tab[k]);
 }
 
-void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
-                                int start, int end, int fgain, int is_lfe,
-                                int deltbae, int deltnseg, uint8_t *deltoffst,
-                                uint8_t *deltlen, uint8_t *deltba,
+void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
+                                int start, int end, int fast_gain, int is_lfe,
+                                int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
+                                uint8_t *dba_lengths, uint8_t *dba_values,
                                 int16_t *mask)
 {
     int16_t excite[50]; /* excitation */
@@ -92,24 +92,24 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAl
     int lowcomp, fastleak, slowleak;
 
     /* excitation function */
-    bndstrt = masktab[start];
-    bndend = masktab[end-1] + 1;
+    bndstrt = bin_to_band_tab[start];
+    bndend = bin_to_band_tab[end-1] + 1;
 
     if (bndstrt == 0) {
         lowcomp = 0;
-        lowcomp = calc_lowcomp1(lowcomp, bndpsd[0], bndpsd[1], 384);
-        excite[0] = bndpsd[0] - fgain - lowcomp;
-        lowcomp = calc_lowcomp1(lowcomp, bndpsd[1], bndpsd[2], 384);
-        excite[1] = bndpsd[1] - fgain - lowcomp;
+        lowcomp = calc_lowcomp1(lowcomp, band_psd[0], band_psd[1], 384);
+        excite[0] = band_psd[0] - fast_gain - lowcomp;
+        lowcomp = calc_lowcomp1(lowcomp, band_psd[1], band_psd[2], 384);
+        excite[1] = band_psd[1] - fast_gain - lowcomp;
         begin = 7;
         for (bin = 2; bin < 7; bin++) {
             if (!(is_lfe && bin == 6))
-                lowcomp = calc_lowcomp1(lowcomp, bndpsd[bin], bndpsd[bin+1], 384);
-            fastleak = bndpsd[bin] - fgain;
-            slowleak = bndpsd[bin] - s->sgain;
+                lowcomp = calc_lowcomp1(lowcomp, band_psd[bin], band_psd[bin+1], 384);
+            fastleak = band_psd[bin] - fast_gain;
+            slowleak = band_psd[bin] - s->slow_gain;
             excite[bin] = fastleak - lowcomp;
             if (!(is_lfe && bin == 6)) {
-                if (bndpsd[bin] <= bndpsd[bin+1]) {
+                if (band_psd[bin] <= band_psd[bin+1]) {
                     begin = bin + 1;
                     break;
                 }
@@ -121,10 +121,10 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAl
 
         for (bin = begin; bin < end1; bin++) {
             if (!(is_lfe && bin == 6))
-                lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
+                lowcomp = calc_lowcomp(lowcomp, band_psd[bin], band_psd[bin+1], bin);
 
-            fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain);
-            slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain);
+            fastleak = FFMAX(fastleak - s->fast_decay, band_psd[bin] - fast_gain);
+            slowleak = FFMAX(slowleak - s->slow_decay, band_psd[bin] - s->slow_gain);
             excite[bin] = FFMAX(fastleak - lowcomp, slowleak);
         }
         begin = 22;
@@ -132,39 +132,39 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAl
         /* coupling channel */
         begin = bndstrt;
 
-        fastleak = (s->cplfleak << 8) + 768;
-        slowleak = (s->cplsleak << 8) + 768;
+        fastleak = (s->cpl_fast_leak << 8) + 768;
+        slowleak = (s->cpl_slow_leak << 8) + 768;
     }
 
     for (bin = begin; bin < bndend; bin++) {
-        fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain);
-        slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain);
+        fastleak = FFMAX(fastleak - s->fast_decay, band_psd[bin] - fast_gain);
+        slowleak = FFMAX(slowleak - s->slow_decay, band_psd[bin] - s->slow_gain);
         excite[bin] = FFMAX(fastleak, slowleak);
     }
 
     /* compute masking curve */
 
     for (bin = bndstrt; bin < bndend; bin++) {
-        tmp = s->dbknee - bndpsd[bin];
+        tmp = s->db_per_bit - band_psd[bin];
         if (tmp > 0) {
             excite[bin] += tmp >> 2;
         }
-        mask[bin] = FFMAX(ff_ac3_hth[bin >> s->halfratecod][s->fscod], excite[bin]);
+        mask[bin] = FFMAX(ff_ac3_hearing_threshold_tab[bin >> s->sr_shift][s->sr_code], excite[bin]);
     }
 
     /* delta bit allocation */
 
-    if (deltbae == DBA_REUSE || deltbae == DBA_NEW) {
+    if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) {
         int band, seg, delta;
         band = 0;
-        for (seg = 0; seg < deltnseg; seg++) {
-            band += deltoffst[seg];
-            if (deltba[seg] >= 4) {
-                delta = (deltba[seg] - 3) << 7;
+        for (seg = 0; seg < dba_nsegs; seg++) {
+            band += dba_offsets[seg];
+            if (dba_values[seg] >= 4) {
+                delta = (dba_values[seg] - 3) << 7;
             } else {
-                delta = (deltba[seg] - 4) << 7;
+                delta = (dba_values[seg] - 4) << 7;
             }
-            for (k = 0; k < deltlen[seg]; k++) {
+            for (k = 0; k < dba_lengths[seg]; k++) {
                 mask[band] += delta;
                 band++;
             }
@@ -173,49 +173,51 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAl
 }
 
 void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
-                               int snroffset, int floor, const uint8_t *baptab, uint8_t *bap)
+                               int snr_offset, int floor,
+                               const uint8_t *bap_tab, uint8_t *bap)
 {
     int i, j, k, end1, v, address;
 
-    /* special case, if snroffset is -960, set all bap's to zero */
-    if(snroffset == -960) {
+    /* special case, if snr offset is -960, set all bap's to zero */
+    if(snr_offset == -960) {
         memset(bap, 0, 256);
         return;
     }
 
     i = start;
-    j = masktab[start];
+    j = bin_to_band_tab[start];
     do {
-        v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor;
-        end1 = FFMIN(bndtab[j] + ff_ac3_bndsz[j], end);
+        v = (FFMAX(mask[j] - snr_offset - floor, 0) & 0x1FE0) + floor;
+        end1 = FFMIN(band_start_tab[j] + ff_ac3_critical_band_size_tab[j], end);
         for (k = i; k < end1; k++) {
             address = av_clip((psd[i] - v) >> 5, 0, 63);
-            bap[i] = baptab[address];
+            bap[i] = bap_tab[address];
             i++;
         }
-    } while (end > bndtab[j++]);
+    } while (end > band_start_tab[j++]);
 }
 
 /* AC3 bit allocation. The algorithm is the one described in the AC3
    spec. */
 void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
                                    int8_t *exp, int start, int end,
-                                   int snroffset, int fgain, int is_lfe,
-                                   int deltbae,int deltnseg,
-                                   uint8_t *deltoffst, uint8_t *deltlen,
-                                   uint8_t *deltba)
+                                   int snr_offset, int fast_gain, int is_lfe,
+                                   int dba_mode, int dba_nsegs,
+                                   uint8_t *dba_offsets, uint8_t *dba_lengths,
+                                   uint8_t *dba_values)
 {
     int16_t psd[256];   /* scaled exponents */
-    int16_t bndpsd[50]; /* interpolated exponents */
+    int16_t band_psd[50]; /* interpolated exponents */
     int16_t mask[50];   /* masking value */
 
-    ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, bndpsd);
+    ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, band_psd);
 
-    ff_ac3_bit_alloc_calc_mask(s, bndpsd, start, end, fgain, is_lfe,
-                               deltbae, deltnseg, deltoffst, deltlen, deltba,
+    ff_ac3_bit_alloc_calc_mask(s, band_psd, start, end, fast_gain, is_lfe,
+                               dba_mode, dba_nsegs, dba_offsets, dba_lengths, dba_values,
                                mask);
 
-    ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snroffset, s->floor, ff_ac3_baptab, bap);
+    ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snr_offset, s->floor,
+                              ff_ac3_bap_tab, bap);
 }
 
 /**
@@ -230,10 +232,10 @@ void ac3_common_init(void)
     k = 0;
     l = 0;
     for(i=0;i<50;i++) {
-        bndtab[i] = l;
-        v = ff_ac3_bndsz[i];
-        for(j=0;j<v;j++) masktab[k++]=i;
+        band_start_tab[i] = l;
+        v = ff_ac3_critical_band_size_tab[i];
+        for(j=0;j<v;j++) bin_to_band_tab[k++]=i;
         l += v;
     }
-    bndtab[50] = l;
+    band_start_tab[50] = l;
 }

Modified: eac3/ac3.h
==============================================================================
--- eac3/ac3.h	(original)
+++ eac3/ac3.h	Tue Dec 11 03:38:13 2007
@@ -24,8 +24,8 @@
  * Common code between AC3 encoder and decoder.
  */
 
-#ifndef AC3_H
-#define AC3_H
+#ifndef FFMPEG_AC3_H
+#define FFMPEG_AC3_H
 
 #include "ac3tab.h"
 
@@ -53,21 +53,21 @@ typedef enum {
 
 /** Channel mode (audio coding mode) */
 typedef enum {
-    AC3_ACMOD_DUALMONO = 0,
-    AC3_ACMOD_MONO,
-    AC3_ACMOD_STEREO,
-    AC3_ACMOD_3F,
-    AC3_ACMOD_2F1R,
-    AC3_ACMOD_3F1R,
-    AC3_ACMOD_2F2R,
-    AC3_ACMOD_3F2R
+    AC3_CHMODE_DUALMONO = 0,
+    AC3_CHMODE_MONO,
+    AC3_CHMODE_STEREO,
+    AC3_CHMODE_3F,
+    AC3_CHMODE_2F1R,
+    AC3_CHMODE_3F1R,
+    AC3_CHMODE_2F2R,
+    AC3_CHMODE_3F2R
 } AC3ChannelMode;
 
 typedef struct AC3BitAllocParameters {
-    int fscod; /* frequency */
-    int halfratecod;
-    int sgain, sdecay, fdecay, dbknee, floor;
-    int cplfleak, cplsleak;
+    int sr_code;
+    int sr_shift;
+    int slow_gain, slow_decay, fast_decay, db_per_bit, floor;
+    int cpl_fast_leak, cpl_slow_leak;
 } AC3BitAllocParameters;
 
 /**
@@ -80,21 +80,21 @@ typedef struct {
      */
     uint16_t sync_word;
     uint16_t crc1;
-    uint8_t fscod;
-    uint8_t frmsizecod;
-    uint8_t bsid;
-    uint8_t bsmod;
-    uint8_t acmod;
-    uint8_t cmixlev;
-    uint8_t surmixlev;
-    uint8_t dsurmod;
-    uint8_t lfeon;
+    uint8_t sr_code;
+    uint8_t frame_size_code;
+    uint8_t bitstream_id;
+    uint8_t bitstream_mode;
+    uint8_t channel_mode;
+    uint8_t center_mix_level;
+    uint8_t surround_mix_level;
+    uint8_t dolby_surround_mode;
+    uint8_t lfe_on;
     /** @} */
 
     /** @defgroup derived Derived values
      * @{
      */
-    uint8_t halfratecod;
+    uint8_t sr_shift;
     uint16_t sample_rate;
     uint32_t bit_rate;
     uint8_t channels;
@@ -117,10 +117,10 @@ void ac3_common_init(void);
  * @param[in]  start      starting bin location
  * @param[in]  end        ending bin location
  * @param[out] psd        signal power for each frequency bin
- * @param[out] bndpsd     signal power for each critical band
+ * @param[out] band_psd   signal power for each critical band
  */
 void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
-                               int16_t *bndpsd);
+                               int16_t *band_psd);
 
 /**
  * Calculates the masking curve.
@@ -130,23 +130,23 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *e
  * allocation information is provided, it is used for adjusting the masking
  * curve, usually to give a closer match to a better psychoacoustic model.
  *
- * @param[in]  s          adjustable bit allocation parameters
- * @param[in]  bndpsd     signal power for each critical band
- * @param[in]  start      starting bin location
- * @param[in]  end        ending bin location
- * @param[in]  fgain      fast gain (estimated signal-to-mask ratio)
- * @param[in]  is_lfe     whether or not the channel being processed is the LFE
- * @param[in]  deltbae    delta bit allocation exists (none, reuse, or new)
- * @param[in]  deltnseg   number of delta segments
- * @param[in]  deltoffst  location offsets for each segment
- * @param[in]  deltlen    length of each segment
- * @param[in]  deltba     delta bit allocation for each segment
- * @param[out] mask       calculated masking curve
+ * @param[in]  s            adjustable bit allocation parameters
+ * @param[in]  band_psd     signal power for each critical band
+ * @param[in]  start        starting bin location
+ * @param[in]  end          ending bin location
+ * @param[in]  fast_gain    fast gain (estimated signal-to-mask ratio)
+ * @param[in]  is_lfe       whether or not the channel being processed is the LFE
+ * @param[in]  dba_mode     delta bit allocation mode (none, reuse, or new)
+ * @param[in]  dba_nsegs    number of delta segments
+ * @param[in]  dba_offsets  location offsets for each segment
+ * @param[in]  dba_lengths  length of each segment
+ * @param[in]  dba_values   delta bit allocation for each segment
+ * @param[out] mask         calculated masking curve
  */
-void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
-                                int start, int end, int fgain, int is_lfe,
-                                int deltbae, int deltnseg, uint8_t *deltoffst,
-                                uint8_t *deltlen, uint8_t *deltba,
+void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
+                                int start, int end, int fast_gain, int is_lfe,
+                                int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
+                                uint8_t *dba_lengths, uint8_t *dba_values,
                                 int16_t *mask);
 
 /**
@@ -159,18 +159,20 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAl
  * @param[in]  psd        signal power for each frequency bin
  * @param[in]  start      starting bin location
  * @param[in]  end        ending bin location
- * @param[in]  snroffset  SNR adjustment
+ * @param[in]  snr_offset SNR adjustment
  * @param[in]  floor      noise floor
- * @param[in]  baptab     bit allocation pointer table
+ * @param[in]  bap_tab    look-up table for bit allocation pointers
  * @param[out] bap        bit allocation pointers
  */
 void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
-                               int snroffset, int floor, const uint8_t *baptab, uint8_t *bap);
+                               int snr_offset, int floor,
+                               const uint8_t *bap_tab, uint8_t *bap);
 
 void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
                                    int8_t *exp, int start, int end,
-                                   int snroffset, int fgain, int is_lfe,
-                                   int deltbae,int deltnseg,
-                                   uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba);
+                                   int snr_offset, int fast_gain, int is_lfe,
+                                   int dba_mode, int dba_nsegs,
+                                   uint8_t *dba_offsets, uint8_t *dba_lengths,
+                                   uint8_t *dba_values);
 
-#endif /* AC3_H */
+#endif /* FFMPEG_AC3_H */

Modified: eac3/ac3dec.c
==============================================================================
--- eac3/ac3dec.c	(original)
+++ eac3/ac3dec.c	Tue Dec 11 03:38:13 2007
@@ -46,30 +46,29 @@
 float ff_ac3_scale_factors[25];
 
 /** table for grouping exponents */
-uint8_t ff_ac3_exp_ungroup_tbl[128][3];
-
+static uint8_t exp_ungroup_tab[128][3];
 
 /** tables for ungrouping mantissas */
-float ff_ac3_b1_mantissas[32][3];
-float ff_ac3_b2_mantissas[128][3];
-float ff_ac3_b3_mantissas[8];
-float ff_ac3_b4_mantissas[128][2];
-float ff_ac3_b5_mantissas[16];
+static float b1_mantissas[32][3];
+static float b2_mantissas[128][3];
+static float b3_mantissas[8];
+static float b4_mantissas[128][2];
+static float b5_mantissas[16];
 
 /**
  * Quantization table: levels for symmetric. bits for asymmetric.
  * reference: Table 7.18 Mapping of bap to Quantizer
  */
-static const uint8_t qntztab[16] = {
+static const uint8_t quantization_tab[16] = {
     0, 3, 5, 7, 11, 15,
     5, 6, 7, 8, 9, 10, 11, 12, 14, 16
 };
 
 /** dynamic range table. converts codes to scale factors. */
-float ff_ac3_dynrng_tbl[256];
+float ff_ac3_dynamic_range_tab[256];
 
-/** dialogue normalization table */
-float ff_ac3_dialnorm_tbl[32];
+/** dialog normalization table */
+float ff_ac3_dialog_norm_tab[32];
 
 static const float gain_levels[6] = {
     LEVEL_ZERO,
@@ -84,13 +83,13 @@ static const float gain_levels[6] = {
  * Table for center mix levels
  * reference: Section 5.4.2.4 cmixlev
  */
-static const uint8_t clevs[4] = { 2, 3, 4, 3 };
+static const uint8_t center_levels[4] = { 2, 3, 4, 3 };
 
 /**
  * Table for surround mix levels
  * reference: Section 5.4.2.5 surmixlev
  */
-static const uint8_t slevs[4] = { 2, 4, 0, 4 };
+static const uint8_t surround_levels[4] = { 2, 4, 0, 4 };
 
 /**
  * Table for default stereo downmixing coefficients
@@ -114,52 +113,52 @@ static const uint8_t ac3_default_coeffs[
 #define AC3_OUTPUT_LFEON  8
 
 typedef struct {
-    int acmod;                              ///< audio coding mode
-    int dsurmod;                            ///< dolby surround mode
-    int blksw[AC3_MAX_CHANNELS];            ///< block switch flags
-    int dithflag[AC3_MAX_CHANNELS];         ///< dither flags
+    int channel_mode;                       ///< channel mode (acmod)
+    int dolby_surround_mode;                ///< dolby surround mode
+    int block_switch[AC3_MAX_CHANNELS];     ///< block switch flags
+    int dither_flag[AC3_MAX_CHANNELS];      ///< dither flags
     int dither_all;                         ///< true if all channels are dithered
-    int cplinu;                             ///< coupling in use
-    int chincpl[AC3_MAX_CHANNELS];          ///< channel in coupling
-    int phsflginu;                          ///< phase flags in use
-    int cplbndstrc[18];                     ///< coupling band structure
-    int rematstr;                           ///< rematrixing strategy
-    int nrematbnd;                          ///< number of rematrixing bands
-    int rematflg[4];                        ///< rematrixing flags
-    int expstr[AC3_MAX_CHANNELS];           ///< exponent strategies
-    int snroffst[AC3_MAX_CHANNELS];         ///< signal-to-noise ratio offsets
-    int fgain[AC3_MAX_CHANNELS];            ///< fast gain values (signal-to-mask ratio)
-    int deltbae[AC3_MAX_CHANNELS];          ///< delta bit allocation exists
-    int deltnseg[AC3_MAX_CHANNELS];         ///< number of delta segments
-    uint8_t deltoffst[AC3_MAX_CHANNELS][8]; ///< delta segment offsets
-    uint8_t deltlen[AC3_MAX_CHANNELS][8];   ///< delta segment lengths
-    uint8_t deltba[AC3_MAX_CHANNELS][8];    ///< delta values for each segment
+    int cpl_in_use;                         ///< coupling in use
+    int channel_in_cpl[AC3_MAX_CHANNELS];   ///< channel in coupling
+    int phase_flags_in_use;                 ///< phase flags in use
+    int cpl_band_struct[18];                ///< coupling band structure
+    int rematrixing_strategy;               ///< rematrixing strategy
+    int num_rematrixing_bands;              ///< number of rematrixing bands
+    int rematrixing_flags[4];               ///< rematrixing flags
+    int exp_strategy[AC3_MAX_CHANNELS];     ///< exponent strategies
+    int snr_offset[AC3_MAX_CHANNELS];       ///< signal-to-noise ratio offsets
+    int fast_gain[AC3_MAX_CHANNELS];        ///< fast gain values (signal-to-mask ratio)
+    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
+    uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; ///< delta segment lengths
+    uint8_t dba_values[AC3_MAX_CHANNELS][8];  ///< delta values for each segment
 
     int sampling_rate;                      ///< sample frequency, in Hz
     int bit_rate;                           ///< stream bit rate, in bits-per-second
     int frame_size;                         ///< current frame size, in bytes
 
-    int nchans;                             ///< number of total channels
-    int nfchans;                            ///< number of full-bandwidth channels
-    int lfeon;                              ///< lfe channel in use
+    int channels;                           ///< number of total channels
+    int fbw_channels;                       ///< number of full-bandwidth channels
+    int lfe_on;                             ///< lfe channel in use
     int lfe_ch;                             ///< index of LFE channel
     int output_mode;                        ///< output channel configuration
     int out_channels;                       ///< number of output channels
 
     float downmix_coeffs[AC3_MAX_CHANNELS][2];  ///< stereo downmix coefficients
-    float dialnorm[2];                      ///< dialogue normalization
-    float dynrng[2];                        ///< dynamic range
-    float cplco[AC3_MAX_CHANNELS][18];      ///< coupling coordinates
-    int   ncplbnd;                          ///< number of coupling bands
-    int   ncplsubnd;                        ///< number of coupling sub bands
-    int   startmant[AC3_MAX_CHANNELS];      ///< start frequency bin
-    int   endmant[AC3_MAX_CHANNELS];        ///< end frequency bin
+    float dialog_norm[2];                   ///< dialog normalization
+    float dynamic_range[2];                 ///< dynamic range
+    float cpl_coords[AC3_MAX_CHANNELS][18]; ///< coupling coordinates
+    int   num_cpl_bands;                    ///< number of coupling bands
+    int   num_cpl_subbands;                 ///< number of coupling sub bands
+    int   start_freq[AC3_MAX_CHANNELS];     ///< start frequency bin
+    int   end_freq[AC3_MAX_CHANNELS];       ///< end frequency bin
     AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters
 
     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
-    int16_t bndpsd[AC3_MAX_CHANNELS][50];   ///< interpolated exponents
+    int16_t band_psd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents
     int16_t mask[AC3_MAX_CHANNELS][50];     ///< masking curve values
 
     DECLARE_ALIGNED_16(float, transform_coeffs[AC3_MAX_CHANNELS][256]);  ///< transform coefficients
@@ -230,45 +229,45 @@ void ff_ac3_tables_init(void)
        reference: Section 7.3.5 Ungrouping of Mantissas */
     for(i=0; i<32; i++) {
         /* bap=1 mantissas */
-        ff_ac3_b1_mantissas[i][0] = symmetric_dequant( i / 9     , 3);
-        ff_ac3_b1_mantissas[i][1] = symmetric_dequant((i % 9) / 3, 3);
-        ff_ac3_b1_mantissas[i][2] = symmetric_dequant((i % 9) % 3, 3);
+        b1_mantissas[i][0] = symmetric_dequant( i / 9     , 3);
+        b1_mantissas[i][1] = symmetric_dequant((i % 9) / 3, 3);
+        b1_mantissas[i][2] = symmetric_dequant((i % 9) % 3, 3);
     }
     for(i=0; i<128; i++) {
         /* bap=2 mantissas */
-        ff_ac3_b2_mantissas[i][0] = symmetric_dequant( i / 25     , 5);
-        ff_ac3_b2_mantissas[i][1] = symmetric_dequant((i % 25) / 5, 5);
-        ff_ac3_b2_mantissas[i][2] = symmetric_dequant((i % 25) % 5, 5);
+        b2_mantissas[i][0] = symmetric_dequant( i / 25     , 5);
+        b2_mantissas[i][1] = symmetric_dequant((i % 25) / 5, 5);
+        b2_mantissas[i][2] = symmetric_dequant((i % 25) % 5, 5);
 
         /* bap=4 mantissas */
-        ff_ac3_b4_mantissas[i][0] = symmetric_dequant(i / 11, 11);
-        ff_ac3_b4_mantissas[i][1] = symmetric_dequant(i % 11, 11);
+        b4_mantissas[i][0] = symmetric_dequant(i / 11, 11);
+        b4_mantissas[i][1] = symmetric_dequant(i % 11, 11);
     }
     /* generate ungrouped mantissa tables
        reference: Tables 7.21 and 7.23 */
     for(i=0; i<7; i++) {
         /* bap=3 mantissas */
-        ff_ac3_b3_mantissas[i] = symmetric_dequant(i, 7);
+        b3_mantissas[i] = symmetric_dequant(i, 7);
     }
     for(i=0; i<15; i++) {
         /* bap=5 mantissas */
-        ff_ac3_b5_mantissas[i] = symmetric_dequant(i, 15);
+        b5_mantissas[i] = symmetric_dequant(i, 15);
     }
 
     /* generate dynamic range table
        reference: Section 7.7.1 Dynamic Range Control */
     for(i=0; i<256; i++) {
         int v = (i >> 5) - ((i >> 7) << 3) - 5;
-        ff_ac3_dynrng_tbl[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20);
+        ff_ac3_dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20);
     }
 
-    /* generate dialogue normalization table
+    /* generate dialog normalization table
        references: Section 5.4.2.8 dialnorm
                    Section 7.6 Dialogue Normalization */
     for(i=1; i<32; i++) {
-        ff_ac3_dialnorm_tbl[i] = expf((i-31) * M_LN10 / 20.0f);
+        ff_ac3_dialog_norm_tab[i] = expf((i-31) * M_LN10 / 20.0f);
     }
-    ff_ac3_dialnorm_tbl[0] = ff_ac3_dialnorm_tbl[31];
+    ff_ac3_dialog_norm_tab[0] = ff_ac3_dialog_norm_tab[31];
 
     /* generate scale factors for exponents and asymmetrical dequantization
        reference: Section 7.3.2 Expansion of Mantissas for Asymmetric Quantization */
@@ -278,9 +277,9 @@ void ff_ac3_tables_init(void)
     /* generate exponent tables
        reference: Section 7.1.3 Exponent Decoding */
     for(i=0; i<128; i++) {
-        ff_ac3_exp_ungroup_tbl[i][0] =  i / 25;
-        ff_ac3_exp_ungroup_tbl[i][1] = (i % 25) / 5;
-        ff_ac3_exp_ungroup_tbl[i][2] = (i % 25) % 5;
+        exp_ungroup_tab[i][0] =  i / 25;
+        exp_ungroup_tab[i][1] = (i % 25) / 5;
+        exp_ungroup_tab[i][2] = (i % 25) % 5;
     }
 }
 
@@ -322,7 +321,7 @@ static int ac3_parse_header(AC3DecodeCon
 {
     AC3HeaderInfo hdr;
     GetBitContext *gb = &ctx->gb;
-    float cmixlev, surmixlev;
+    float center_mix_level, surround_mix_level;
     int err, i;
 
     err = ff_ac3_parse_header(gb->buffer, &hdr);
@@ -330,24 +329,24 @@ static int ac3_parse_header(AC3DecodeCon
         return err;
 
     /* get decoding parameters from header info */
-    ctx->bit_alloc_params.fscod       = hdr.fscod;
-    ctx->acmod                        = hdr.acmod;
-    cmixlev                           = gain_levels[clevs[hdr.cmixlev]];
-    surmixlev                         = gain_levels[slevs[hdr.surmixlev]];
-    ctx->dsurmod                      = hdr.dsurmod;
-    ctx->lfeon                        = hdr.lfeon;
-    ctx->bit_alloc_params.halfratecod = hdr.halfratecod;
+    ctx->bit_alloc_params.sr_code     = hdr.sr_code;
+    ctx->channel_mode                 = hdr.channel_mode;
+    center_mix_level                  = gain_levels[center_levels[hdr.center_mix_level]];
+    surround_mix_level                = gain_levels[surround_levels[hdr.surround_mix_level]];
+    ctx->dolby_surround_mode          = hdr.dolby_surround_mode;
+    ctx->lfe_on                        = hdr.lfe_on;
+    ctx->bit_alloc_params.sr_shift    = hdr.sr_shift;
     ctx->sampling_rate                = hdr.sample_rate;
     ctx->bit_rate                     = hdr.bit_rate;
-    ctx->nchans                       = hdr.channels;
-    ctx->nfchans                      = ctx->nchans - ctx->lfeon;
-    ctx->lfe_ch                       = ctx->nfchans + 1;
+    ctx->channels                     = hdr.channels;
+    ctx->fbw_channels                 = ctx->channels - ctx->lfe_on;
+    ctx->lfe_ch                       = ctx->fbw_channels + 1;
     ctx->frame_size                   = hdr.frame_size;
 
     /* set default output to all source channels */
-    ctx->out_channels = ctx->nchans;
-    ctx->output_mode = ctx->acmod;
-    if(ctx->lfeon)
+    ctx->out_channels = ctx->channels;
+    ctx->output_mode = ctx->channel_mode;
+    if(ctx->lfe_on)
         ctx->output_mode |= AC3_OUTPUT_LFEON;
 
     /* skip over portion of header which has already been read */
@@ -355,20 +354,20 @@ static int ac3_parse_header(AC3DecodeCon
     skip_bits(gb, 16); // skip crc1
     skip_bits(gb, 8);  // skip fscod and frmsizecod
     skip_bits(gb, 11); // skip bsid, bsmod, and acmod
-    if(ctx->acmod == AC3_ACMOD_STEREO) {
+    if(ctx->channel_mode == AC3_CHMODE_STEREO) {
         skip_bits(gb, 2); // skip dsurmod
     } else {
-        if((ctx->acmod & 1) && ctx->acmod != AC3_ACMOD_MONO)
+        if((ctx->channel_mode & 1) && ctx->channel_mode != AC3_CHMODE_MONO)
             skip_bits(gb, 2); // skip cmixlev
-        if(ctx->acmod & 4)
+        if(ctx->channel_mode & 4)
             skip_bits(gb, 2); // skip surmixlev
     }
     skip_bits1(gb); // skip lfeon
 
     /* read the rest of the bsi. read twice for dual mono mode. */
-    i = !(ctx->acmod);
+    i = !(ctx->channel_mode);
     do {
-        ctx->dialnorm[i] = ff_ac3_dialnorm_tbl[get_bits(gb, 5)]; // dialogue normalization
+        ctx->dialog_norm[i] = ff_ac3_dialog_norm_tab[get_bits(gb, 5)]; // dialog normalization
         if (get_bits1(gb))
             skip_bits(gb, 8); //skip compression
         if (get_bits1(gb))
@@ -396,20 +395,20 @@ static int ac3_parse_header(AC3DecodeCon
 
     /* set stereo downmixing coefficients
        reference: Section 7.8.2 Downmixing Into Two Channels */
-    for(i=0; i<ctx->nfchans; i++) {
-        ctx->downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[ctx->acmod][i][0]];
-        ctx->downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[ctx->acmod][i][1]];
+    for(i=0; i<ctx->fbw_channels; i++) {
+        ctx->downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[ctx->channel_mode][i][0]];
+        ctx->downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[ctx->channel_mode][i][1]];
     }
-    if(ctx->acmod > 1 && ctx->acmod & 1) {
-        ctx->downmix_coeffs[1][0] = ctx->downmix_coeffs[1][1] = cmixlev;
+    if(ctx->channel_mode > 1 && ctx->channel_mode & 1) {
+        ctx->downmix_coeffs[1][0] = ctx->downmix_coeffs[1][1] = center_mix_level;
     }
-    if(ctx->acmod == AC3_ACMOD_2F1R || ctx->acmod == AC3_ACMOD_3F1R) {
-        int nf = ctx->acmod - 2;
-        ctx->downmix_coeffs[nf][0] = ctx->downmix_coeffs[nf][1] = surmixlev * LEVEL_MINUS_3DB;
+    if(ctx->channel_mode == AC3_CHMODE_2F1R || ctx->channel_mode == AC3_CHMODE_3F1R) {
+        int nf = ctx->channel_mode - 2;
+        ctx->downmix_coeffs[nf][0] = ctx->downmix_coeffs[nf][1] = surround_mix_level * LEVEL_MINUS_3DB;
     }
-    if(ctx->acmod == AC3_ACMOD_2F2R || ctx->acmod == AC3_ACMOD_3F2R) {
-        int nf = ctx->acmod - 4;
-        ctx->downmix_coeffs[nf][0] = ctx->downmix_coeffs[nf+1][1] = surmixlev;
+    if(ctx->channel_mode == AC3_CHMODE_2F2R || ctx->channel_mode == AC3_CHMODE_3F2R) {
+        int nf = ctx->channel_mode - 4;
+        ctx->downmix_coeffs[nf][0] = ctx->downmix_coeffs[nf+1][1] = surround_mix_level;
     }
 
     return 0;
@@ -419,28 +418,28 @@ static int ac3_parse_header(AC3DecodeCon
  * Decode the grouped exponents according to exponent strategy.
  * reference: Section 7.1.3 Exponent Decoding
  */
-void ff_ac3_decode_exponents(GetBitContext *gb, int expstr, int ngrps,
+void ff_ac3_decode_exponents(GetBitContext *gb, int exp_strategy, int ngrps,
                              uint8_t absexp, int8_t *dexps)
 {
-    int i, j, grp, grpsize;
+    int i, j, grp, group_size;
     int dexp[256];
     int expacc, prevexp;
 
     /* unpack groups */
-    grpsize = expstr + (expstr == EXP_D45);
+    group_size = exp_strategy + (exp_strategy == EXP_D45);
     for(grp=0,i=0; grp<ngrps; grp++) {
         expacc = get_bits(gb, 7);
-        dexp[i++] = ff_ac3_exp_ungroup_tbl[expacc][0];
-        dexp[i++] = ff_ac3_exp_ungroup_tbl[expacc][1];
-        dexp[i++] = ff_ac3_exp_ungroup_tbl[expacc][2];
+        dexp[i++] = exp_ungroup_tab[expacc][0];
+        dexp[i++] = exp_ungroup_tab[expacc][1];
+        dexp[i++] = exp_ungroup_tab[expacc][2];
     }
 
     /* convert to absolute exps and expand groups */
     prevexp = absexp;
     for(i=0; i<ngrps*3; i++) {
         prevexp = av_clip(prevexp + dexp[i]-2, 0, 24);
-        for(j=0; j<grpsize; j++) {
-            dexps[(i*grpsize)+j] = prevexp;
+        for(j=0; j<group_size; j++) {
+            dexps[(i*group_size)+j] = prevexp;
         }
     }
 }
@@ -455,18 +454,18 @@ static void uncouple_channels(AC3DecodeC
     int i, j, ch, bnd, subbnd;
 
     subbnd = -1;
-    i = ctx->startmant[CPL_CH];
-    for(bnd=0; bnd<ctx->ncplbnd; bnd++) {
+    i = ctx->start_freq[CPL_CH];
+    for(bnd=0; bnd<ctx->num_cpl_bands; bnd++) {
         do {
             subbnd++;
             for(j=0; j<12; j++) {
-                for(ch=1; ch<=ctx->nfchans; ch++) {
-                    if(ctx->chincpl[ch])
-                        ctx->transform_coeffs[ch][i] = ctx->transform_coeffs[CPL_CH][i] * ctx->cplco[ch][bnd] * 8.0f;
+                for(ch=1; ch<=ctx->fbw_channels; ch++) {
+                    if(ctx->channel_in_cpl[ch])
+                        ctx->transform_coeffs[ch][i] = ctx->transform_coeffs[CPL_CH][i] * ctx->cpl_coords[ch][bnd] * 8.0f;
                 }
                 i++;
             }
-        } while(ctx->cplbndstrc[subbnd]);
+        } while(ctx->cpl_band_struct[subbnd]);
     }
 }
 
@@ -474,9 +473,9 @@ static void uncouple_channels(AC3DecodeC
  * Get the transform coefficients for a particular channel
  * reference: Section 7.3 Quantization and Decoding of Mantissas
  */
-int ff_ac3_get_transform_coeffs_ch(mant_groups *m, GetBitContext *gb,
-        uint8_t *exps, uint8_t *bap, float *coeffs, int start, int end,
-        AVRandomState *dith_state)
+int ff_ac3_get_transform_coeffs_ch(mant_groups *m, GetBitContext *gb, uint8_t *exps,
+                                   uint8_t *bap, float *coeffs, int start,
+                                   int end, AVRandomState *dith_state)
 {
     int i, gcode, tbap;
 
@@ -484,15 +483,15 @@ int ff_ac3_get_transform_coeffs_ch(mant_
         tbap = bap[i];
         switch (tbap) {
             case 0:
-                coeffs[i] = ((av_random(dith_state) & 0xFFFF) * LEVEL_MINUS_3DB) / 32768.0f;
+                coeffs[i] = ((av_random(dith_state) & 0xFFFF) / 65535.0f) - 0.5f;
                 break;
 
             case 1:
                 if(m->b1ptr > 2) {
                     gcode = get_bits(gb, 5);
-                    m->b1_mant[0] = ff_ac3_b1_mantissas[gcode][0];
-                    m->b1_mant[1] = ff_ac3_b1_mantissas[gcode][1];
-                    m->b1_mant[2] = ff_ac3_b1_mantissas[gcode][2];
+                    m->b1_mant[0] = b1_mantissas[gcode][0];
+                    m->b1_mant[1] = b1_mantissas[gcode][1];
+                    m->b1_mant[2] = b1_mantissas[gcode][2];
                     m->b1ptr = 0;
                 }
                 coeffs[i] = m->b1_mant[m->b1ptr++];
@@ -501,35 +500,35 @@ int ff_ac3_get_transform_coeffs_ch(mant_
             case 2:
                 if(m->b2ptr > 2) {
                     gcode = get_bits(gb, 7);
-                    m->b2_mant[0] = ff_ac3_b2_mantissas[gcode][0];
-                    m->b2_mant[1] = ff_ac3_b2_mantissas[gcode][1];
-                    m->b2_mant[2] = ff_ac3_b2_mantissas[gcode][2];
+                    m->b2_mant[0] = b2_mantissas[gcode][0];
+                    m->b2_mant[1] = b2_mantissas[gcode][1];
+                    m->b2_mant[2] = b2_mantissas[gcode][2];
                     m->b2ptr = 0;
                 }
                 coeffs[i] = m->b2_mant[m->b2ptr++];
                 break;
 
             case 3:
-                coeffs[i] = ff_ac3_b3_mantissas[get_bits(gb, 3)];
+                coeffs[i] = b3_mantissas[get_bits(gb, 3)];
                 break;
 
             case 4:
                 if(m->b4ptr > 1) {
                     gcode = get_bits(gb, 7);
-                    m->b4_mant[0] = ff_ac3_b4_mantissas[gcode][0];
-                    m->b4_mant[1] = ff_ac3_b4_mantissas[gcode][1];
+                    m->b4_mant[0] = b4_mantissas[gcode][0];
+                    m->b4_mant[1] = b4_mantissas[gcode][1];
                     m->b4ptr = 0;
                 }
                 coeffs[i] = m->b4_mant[m->b4ptr++];
                 break;
 
             case 5:
-                coeffs[i] = ff_ac3_b5_mantissas[get_bits(gb, 4)];
+                coeffs[i] = b5_mantissas[get_bits(gb, 4)];
                 break;
 
             default:
                 /* asymmetric dequantization */
-                coeffs[i] = get_sbits(gb, qntztab[tbap]) * ff_ac3_scale_factors[qntztab[tbap]-1];
+                coeffs[i] = get_sbits(gb, quantization_tab[tbap]) * ff_ac3_scale_factors[quantization_tab[tbap]-1];
                 break;
         }
         coeffs[i] *= ff_ac3_scale_factors[exps[i]];
@@ -548,21 +547,21 @@ static void remove_dithering(AC3DecodeCo
     float *coeffs;
     uint8_t *bap;
 
-    for(ch=1; ch<=ctx->nfchans; ch++) {
-        if(!ctx->dithflag[ch]) {
+    for(ch=1; ch<=ctx->fbw_channels; ch++) {
+        if(!ctx->dither_flag[ch]) {
             coeffs = ctx->transform_coeffs[ch];
             bap = ctx->bap[ch];
-            if(ctx->chincpl[ch])
-                end = ctx->startmant[CPL_CH];
+            if(ctx->channel_in_cpl[ch])
+                end = ctx->start_freq[CPL_CH];
             else
-                end = ctx->endmant[ch];
+                end = ctx->end_freq[ch];
             for(i=0; i<end; i++) {
                 if(bap[i] == 0)
                     coeffs[i] = 0.0f;
             }
-            if(ctx->chincpl[ch]) {
+            if(ctx->channel_in_cpl[ch]) {
                 bap = ctx->bap[CPL_CH];
-                for(; i<ctx->endmant[CPL_CH]; i++) {
+                for(; i<ctx->end_freq[CPL_CH]; i++) {
                     if(bap[i] == 0)
                         coeffs[i] = 0.0f;
                 }
@@ -582,30 +581,31 @@ static int get_transform_coeffs(AC3Decod
 
     m.b1ptr = m.b2ptr = m.b4ptr = 3;
 
-    for (ch = 1; ch <= ctx->nchans; ch++) {
+    for (ch = 1; ch <= ctx->channels; ch++) {
         /* transform coefficients for full-bandwidth channel */
-        if (ff_ac3_get_transform_coeffs_ch(&m, &ctx->gb, ctx->dexps[ch],
-                    ctx->bap[ch], ctx->transform_coeffs[ch], ctx->startmant[ch],
-                    ctx->endmant[ch], &ctx->dith_state))
+        //if (get_transform_coeffs_ch(ctx, ch, &m))
+        if(ff_ac3_get_transform_coeffs_ch(&m, &ctx->gb, ctx->dexps[ch],
+                    ctx->bap[ch], ctx->transform_coeffs[ch], ctx->start_freq[ch],
+                    ctx->end_freq[ch], &ctx->dith_state))
             return -1;
         /* tranform coefficients for coupling channel come right after the
            coefficients for the first coupled channel*/
-        if (ctx->chincpl[ch])  {
+        if (ctx->channel_in_cpl[ch])  {
             if (!got_cplchan) {
                 if (ff_ac3_get_transform_coeffs_ch(&m, &ctx->gb,
-                            ctx->dexps[CPL_CH], ctx->bap[CPL_CH],
-                            ctx->transform_coeffs[CPL_CH],
-                            ctx->startmant[CPL_CH], ctx->endmant[CPL_CH],
-                            &ctx->dith_state)){
+                                ctx->dexps[CPL_CH], ctx->bap[CPL_CH],
+                                ctx->transform_coeffs[CPL_CH],
+                                ctx->start_freq[CPL_CH], ctx->end_freq[CPL_CH],
+                                &ctx->dith_state)) {
                     av_log(ctx->avctx, AV_LOG_ERROR, "error in decoupling channels\n");
                     return -1;
                 }
                 uncouple_channels(ctx);
                 got_cplchan = 1;
             }
-            end = ctx->endmant[CPL_CH];
+            end = ctx->end_freq[CPL_CH];
         } else {
-            end = ctx->endmant[ch];
+            end = ctx->end_freq[ch];
         }
         do
             ctx->transform_coeffs[ch][end] = 0;
@@ -623,16 +623,17 @@ static int get_transform_coeffs(AC3Decod
  * Stereo rematrixing.
  * reference: Section 7.5.4 Rematrixing : Decoding Technique
  */
-void ff_ac3_do_rematrixing(float (*transform_coeffs)[256], int end, int nrematbnd, int *rematflg)
+void ff_ac3_do_rematrixing(float (*transform_coeffs)[256], int end,
+                           int num_rematrixing_bands, int *rematrixing_flags)
 {
     int bnd, i;
     int bndend;
     float tmp0, tmp1;
 
-    for(bnd=0; bnd<nrematbnd; bnd++) {
-        if(rematflg[bnd]) {
-            bndend = FFMIN(end, ff_ac3_rematrix_band_tbl[bnd+1]);
-            for(i=ff_ac3_rematrix_band_tbl[bnd]; i<bndend; i++) {
+    for(bnd=0; bnd<num_rematrixing_bands; bnd++) {
+        if(rematrixing_flags[bnd]) {
+            bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd+1]);
+            for(i=ff_ac3_rematrix_band_tab[bnd]; i<bndend; i++) {
                 tmp0 = transform_coeffs[1][i];
                 tmp1 = transform_coeffs[2][i];
                 transform_coeffs[1][i] = tmp0 + tmp1;
@@ -645,8 +646,8 @@ void ff_ac3_do_rematrixing(float (*trans
 /**
  * Perform the 256-point IMDCT
  */
-void ff_ac3_do_imdct_256(float *tmp_output, float *transform_coeffs,
-        MDCTContext *imdct_256, float *tmp_imdct)
+void ff_ac3_do_imdct_256(float *o_ptr, float *transform_coeffs,
+                         MDCTContext *imdct_256, float *tmp_imdct)
 {
     int i, k;
     DECLARE_ALIGNED_16(float, x[128]);
@@ -659,27 +660,27 @@ void ff_ac3_do_imdct_256(float *tmp_outp
         }
 
         /* run standard IMDCT */
-        imdct_256->fft.imdct_calc(imdct_256, tmp_output, x, tmp_imdct);
+        imdct_256->fft.imdct_calc(imdct_256, o_ptr, x, tmp_imdct);
 
         /* reverse the post-rotation & reordering from standard IMDCT */
         for(k=0; k<32; k++) {
-            z[i][32+k].re = -tmp_output[128+2*k];
-            z[i][32+k].im = -tmp_output[2*k];
-            z[i][31-k].re =  tmp_output[2*k+1];
-            z[i][31-k].im =  tmp_output[128+2*k+1];
+            z[i][32+k].re = -o_ptr[128+2*k];
+            z[i][32+k].im = -o_ptr[2*k];
+            z[i][31-k].re =  o_ptr[2*k+1];
+            z[i][31-k].im =  o_ptr[128+2*k+1];
         }
     }
 
     /* apply AC-3 post-rotation & reordering */
     for(k=0; k<64; k++) {
-        tmp_output[    2*k  ] = -z[0][   k].im;
-        tmp_output[    2*k+1] =  z[0][63-k].re;
-        tmp_output[128+2*k  ] = -z[0][   k].re;
-        tmp_output[128+2*k+1] =  z[0][63-k].im;
-        tmp_output[256+2*k  ] = -z[1][   k].re;
-        tmp_output[256+2*k+1] =  z[1][63-k].im;
-        tmp_output[384+2*k  ] =  z[1][   k].im;
-        tmp_output[384+2*k+1] = -z[1][63-k].re;
+        o_ptr[    2*k  ] = -z[0][   k].im;
+        o_ptr[    2*k+1] =  z[0][63-k].re;
+        o_ptr[128+2*k  ] = -z[0][   k].re;
+        o_ptr[128+2*k+1] =  z[0][63-k].im;
+        o_ptr[256+2*k  ] = -z[1][   k].re;
+        o_ptr[256+2*k+1] =  z[1][63-k].im;
+        o_ptr[384+2*k  ] =  z[1][   k].im;
+        o_ptr[384+2*k+1] = -z[1][63-k].re;
     }
 }
 
@@ -691,17 +692,17 @@ void ff_ac3_do_imdct_256(float *tmp_outp
 static inline void do_imdct(AC3DecodeContext *ctx)
 {
     int ch;
-    int nchans;
+    int channels;
 
     /* Don't perform the IMDCT on the LFE channel unless it's used in the output */
-    nchans = ctx->nfchans;
+    channels = ctx->fbw_channels;
     if(ctx->output_mode & AC3_OUTPUT_LFEON)
-        nchans++;
+        channels++;
 
-    for (ch=1; ch<=nchans; ch++) {
-        if (ctx->blksw[ch]) {
+    for (ch=1; ch<=channels; ch++) {
+        if (ctx->block_switch[ch]) {
             ff_ac3_do_imdct_256(ctx->tmp_output, ctx->transform_coeffs[ch],
-                    &ctx->imdct_256, ctx->tmp_imdct);
+                                &ctx->imdct_256, ctx->tmp_imdct);
         } else {
             ctx->imdct_512.fft.imdct_calc(&ctx->imdct_512, ctx->tmp_output,
                                           ctx->transform_coeffs[ch],
@@ -721,7 +722,7 @@ static inline void do_imdct(AC3DecodeCon
 /**
  * Downmix the output to mono or stereo.
  */
-void ff_ac3_downmix(float samples[AC3_MAX_CHANNELS][256], int nfchans,
+void ff_ac3_downmix(float samples[AC3_MAX_CHANNELS][256], int fbw_channels,
                         int output_mode, float coef[AC3_MAX_CHANNELS][2])
 {
     int i, j;
@@ -729,7 +730,7 @@ void ff_ac3_downmix(float samples[AC3_MA
 
     for(i=0; i<256; i++) {
         v0 = v1 = s0 = s1 = 0.0f;
-        for(j=0; j<nfchans; j++) {
+        for(j=0; j<fbw_channels; j++) {
             v0 += samples[j][i] * coef[j][0];
             v1 += samples[j][i] * coef[j][1];
             s0 += coef[j][0];
@@ -737,9 +738,9 @@ void ff_ac3_downmix(float samples[AC3_MA
         }
         v0 /= s0;
         v1 /= s1;
-        if(output_mode == AC3_ACMOD_MONO) {
+        if(output_mode == AC3_CHMODE_MONO) {
             samples[0][i] = (v0 + v1) * LEVEL_MINUS_3DB;
-        } else if(output_mode == AC3_ACMOD_STEREO) {
+        } else if(output_mode == AC3_CHMODE_STEREO) {
             samples[0][i] = v0;
             samples[1][i] = v1;
         }
@@ -751,8 +752,8 @@ void ff_ac3_downmix(float samples[AC3_MA
  */
 static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
 {
-    int nfchans = ctx->nfchans;
-    int acmod = ctx->acmod;
+    int fbw_channels = ctx->fbw_channels;
+    int channel_mode = ctx->channel_mode;
     int i, bnd, seg, ch;
     GetBitContext *gb = &ctx->gb;
     uint8_t bit_alloc_stages[AC3_MAX_CHANNELS];
@@ -760,157 +761,157 @@ static int ac3_parse_audio_block(AC3Deco
     memset(bit_alloc_stages, 0, AC3_MAX_CHANNELS);
 
     /* block switch flags */
-    for (ch = 1; ch <= nfchans; ch++)
-        ctx->blksw[ch] = get_bits1(gb);
+    for (ch = 1; ch <= fbw_channels; ch++)
+        ctx->block_switch[ch] = get_bits1(gb);
 
     /* dithering flags */
     ctx->dither_all = 1;
-    for (ch = 1; ch <= nfchans; ch++) {
-        ctx->dithflag[ch] = get_bits1(gb);
-        if(!ctx->dithflag[ch])
+    for (ch = 1; ch <= fbw_channels; ch++) {
+        ctx->dither_flag[ch] = get_bits1(gb);
+        if(!ctx->dither_flag[ch])
             ctx->dither_all = 0;
     }
 
     /* dynamic range */
-    i = !(ctx->acmod);
+    i = !(ctx->channel_mode);
     do {
         if(get_bits1(gb)) {
-            ctx->dynrng[i] = ff_ac3_dynrng_tbl[get_bits(gb, 8)];
+            ctx->dynamic_range[i] = ff_ac3_dynamic_range_tab[get_bits(gb, 8)];
         } else if(blk == 0) {
-            ctx->dynrng[i] = 1.0f;
+            ctx->dynamic_range[i] = 1.0f;
         }
     } while(i--);
 
     /* coupling strategy */
     if (get_bits1(gb)) {
         memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
-        ctx->cplinu = get_bits1(gb);
-        if (ctx->cplinu) {
+        ctx->cpl_in_use = get_bits1(gb);
+        if (ctx->cpl_in_use) {
             /* coupling in use */
-            int cplbegf, cplendf;
+            int cpl_begin_freq, cpl_end_freq;
 
             /* determine which channels are coupled */
-            for (ch = 1; ch <= nfchans; ch++)
-                ctx->chincpl[ch] = get_bits1(gb);
+            for (ch = 1; ch <= fbw_channels; ch++)
+                ctx->channel_in_cpl[ch] = get_bits1(gb);
 
             /* phase flags in use */
-            if (acmod == AC3_ACMOD_STEREO)
-                ctx->phsflginu = get_bits1(gb);
+            if (channel_mode == AC3_CHMODE_STEREO)
+                ctx->phase_flags_in_use = get_bits1(gb);
 
             /* coupling frequency range and band structure */
-            cplbegf = get_bits(gb, 4);
-            cplendf = get_bits(gb, 4);
-            if (3 + cplendf - cplbegf < 0) {
-                av_log(ctx->avctx, AV_LOG_ERROR, "cplendf = %d < cplbegf = %d\n", cplendf, cplbegf);
+            cpl_begin_freq = get_bits(gb, 4);
+            cpl_end_freq = get_bits(gb, 4);
+            if (3 + cpl_end_freq - cpl_begin_freq < 0) {
+                av_log(ctx->avctx, AV_LOG_ERROR, "3+cplendf = %d < cplbegf = %d\n", 3+cpl_end_freq, cpl_begin_freq);
                 return -1;
             }
-            ctx->ncplbnd = ctx->ncplsubnd = 3 + cplendf - cplbegf;
-            ctx->startmant[CPL_CH] = cplbegf * 12 + 37;
-            ctx->endmant[CPL_CH] = cplendf * 12 + 73;
-            for (bnd = 0; bnd < ctx->ncplsubnd - 1; bnd++) {
+            ctx->num_cpl_bands = ctx->num_cpl_subbands = 3 + cpl_end_freq - cpl_begin_freq;
+            ctx->start_freq[CPL_CH] = cpl_begin_freq * 12 + 37;
+            ctx->end_freq[CPL_CH] = cpl_end_freq * 12 + 73;
+            for (bnd = 0; bnd < ctx->num_cpl_subbands - 1; bnd++) {
                 if (get_bits1(gb)) {
-                    ctx->cplbndstrc[bnd] = 1;
-                    ctx->ncplbnd--;
+                    ctx->cpl_band_struct[bnd] = 1;
+                    ctx->num_cpl_bands--;
                 }
             }
         } else {
             /* coupling not in use */
-            for (ch = 1; ch <= nfchans; ch++)
-                ctx->chincpl[ch] = 0;
+            for (ch = 1; ch <= fbw_channels; ch++)
+                ctx->channel_in_cpl[ch] = 0;
         }
     }
 
     /* coupling coordinates */
-    if (ctx->cplinu) {
-        int cplcoe = 0;
+    if (ctx->cpl_in_use) {
+        int cpl_coords_exist = 0;
 
-        for (ch = 1; ch <= nfchans; ch++) {
-            if (ctx->chincpl[ch]) {
+        for (ch = 1; ch <= fbw_channels; ch++) {
+            if (ctx->channel_in_cpl[ch]) {
                 if (get_bits1(gb)) {
-                    int mstrcplco, cplcoexp, cplcomant;
-                    cplcoe = 1;
-                    mstrcplco = 3 * get_bits(gb, 2);
-                    for (bnd = 0; bnd < ctx->ncplbnd; bnd++) {
-                        cplcoexp = get_bits(gb, 4);
-                        cplcomant = get_bits(gb, 4);
-                        if (cplcoexp == 15)
-                            ctx->cplco[ch][bnd] = cplcomant / 16.0f;
+                    int master_cpl_coord, cpl_coord_exp, cpl_coord_mant;
+                    cpl_coords_exist = 1;
+                    master_cpl_coord = 3 * get_bits(gb, 2);
+                    for (bnd = 0; bnd < ctx->num_cpl_bands; bnd++) {
+                        cpl_coord_exp = get_bits(gb, 4);
+                        cpl_coord_mant = get_bits(gb, 4);
+                        if (cpl_coord_exp == 15)
+                            ctx->cpl_coords[ch][bnd] = cpl_coord_mant / 16.0f;
                         else
-                            ctx->cplco[ch][bnd] = (cplcomant + 16.0f) / 32.0f;
-                        ctx->cplco[ch][bnd] *= ff_ac3_scale_factors[cplcoexp + mstrcplco];
+                            ctx->cpl_coords[ch][bnd] = (cpl_coord_mant + 16.0f) / 32.0f;
+                        ctx->cpl_coords[ch][bnd] *= ff_ac3_scale_factors[cpl_coord_exp + master_cpl_coord];
                     }
                 }
             }
         }
         /* phase flags */
-        if (acmod == AC3_ACMOD_STEREO && ctx->phsflginu && cplcoe) {
-            for (bnd = 0; bnd < ctx->ncplbnd; bnd++) {
+        if (channel_mode == AC3_CHMODE_STEREO && ctx->phase_flags_in_use && cpl_coords_exist) {
+            for (bnd = 0; bnd < ctx->num_cpl_bands; bnd++) {
                 if (get_bits1(gb))
-                    ctx->cplco[2][bnd] = -ctx->cplco[2][bnd];
+                    ctx->cpl_coords[2][bnd] = -ctx->cpl_coords[2][bnd];
             }
         }
     }
 
     /* stereo rematrixing strategy and band structure */
-    if (acmod == AC3_ACMOD_STEREO) {
-        ctx->rematstr = get_bits1(gb);
-        if (ctx->rematstr) {
-            ctx->nrematbnd = 4;
-            if(ctx->cplinu && ctx->startmant[CPL_CH] <= 61)
-                ctx->nrematbnd -= 1 + (ctx->startmant[CPL_CH] == 37);
-            for(bnd=0; bnd<ctx->nrematbnd; bnd++)
-                ctx->rematflg[bnd] = get_bits1(gb);
+    if (channel_mode == AC3_CHMODE_STEREO) {
+        ctx->rematrixing_strategy = get_bits1(gb);
+        if (ctx->rematrixing_strategy) {
+            ctx->num_rematrixing_bands = 4;
+            if(ctx->cpl_in_use && ctx->start_freq[CPL_CH] <= 61)
+                ctx->num_rematrixing_bands -= 1 + (ctx->start_freq[CPL_CH] == 37);
+            for(bnd=0; bnd<ctx->num_rematrixing_bands; bnd++)
+                ctx->rematrixing_flags[bnd] = get_bits1(gb);
         }
     }
 
     /* exponent strategies for each channel */
-    ctx->expstr[CPL_CH] = EXP_REUSE;
-    ctx->expstr[ctx->lfe_ch] = EXP_REUSE;
-    for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) {
+    ctx->exp_strategy[CPL_CH] = EXP_REUSE;
+    ctx->exp_strategy[ctx->lfe_ch] = EXP_REUSE;
+    for (ch = !ctx->cpl_in_use; ch <= ctx->channels; ch++) {
         if(ch == ctx->lfe_ch)
-            ctx->expstr[ch] = get_bits(gb, 1);
+            ctx->exp_strategy[ch] = get_bits(gb, 1);
         else
-            ctx->expstr[ch] = get_bits(gb, 2);
-        if(ctx->expstr[ch] != EXP_REUSE)
+            ctx->exp_strategy[ch] = get_bits(gb, 2);
+        if(ctx->exp_strategy[ch] != EXP_REUSE)
             bit_alloc_stages[ch] = 3;
     }
 
     /* channel bandwidth */
-    for (ch = 1; ch <= nfchans; ch++) {
-        ctx->startmant[ch] = 0;
-        if (ctx->expstr[ch] != EXP_REUSE) {
-            int prev = ctx->endmant[ch];
-            if (ctx->chincpl[ch])
-                ctx->endmant[ch] = ctx->startmant[CPL_CH];
+    for (ch = 1; ch <= fbw_channels; ch++) {
+        ctx->start_freq[ch] = 0;
+        if (ctx->exp_strategy[ch] != EXP_REUSE) {
+            int prev = ctx->end_freq[ch];
+            if (ctx->channel_in_cpl[ch])
+                ctx->end_freq[ch] = ctx->start_freq[CPL_CH];
             else {
-                int chbwcod = get_bits(gb, 6);
-                if (chbwcod > 60) {
-                    av_log(ctx->avctx, AV_LOG_ERROR, "chbwcod = %d > 60", chbwcod);
+                int bandwidth_code = get_bits(gb, 6);
+                if (bandwidth_code > 60) {
+                    av_log(ctx->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60", bandwidth_code);
                     return -1;
                 }
-                ctx->endmant[ch] = chbwcod * 3 + 73;
+                ctx->end_freq[ch] = bandwidth_code * 3 + 73;
             }
-            if(blk > 0 && ctx->endmant[ch] != prev)
+            if(blk > 0 && ctx->end_freq[ch] != prev)
                 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
         }
     }
-    ctx->startmant[ctx->lfe_ch] = 0;
-    ctx->endmant[ctx->lfe_ch] = 7;
+    ctx->start_freq[ctx->lfe_ch] = 0;
+    ctx->end_freq[ctx->lfe_ch] = 7;
 
     /* decode exponents for each channel */
-    for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) {
-        if (ctx->expstr[ch] != EXP_REUSE) {
-            int grpsize, ngrps;
-            grpsize = 3 << (ctx->expstr[ch] - 1);
+    for (ch = !ctx->cpl_in_use; ch <= ctx->channels; ch++) {
+        if (ctx->exp_strategy[ch] != EXP_REUSE) {
+            int group_size, num_groups;
+            group_size = 3 << (ctx->exp_strategy[ch] - 1);
             if(ch == CPL_CH)
-                ngrps = (ctx->endmant[ch] - ctx->startmant[ch]) / grpsize;
+                num_groups = (ctx->end_freq[ch] - ctx->start_freq[ch]) / group_size;
             else if(ch == ctx->lfe_ch)
-                ngrps = 2;
+                num_groups = 2;
             else
-                ngrps = (ctx->endmant[ch] + grpsize - 4) / grpsize;
+                num_groups = (ctx->end_freq[ch] + group_size - 4) / group_size;
             ctx->dexps[ch][0] = get_bits(gb, 4) << !ch;
-            ff_ac3_decode_exponents(gb, ctx->expstr[ch], ngrps, ctx->dexps[ch][0],
-                             &ctx->dexps[ch][ctx->startmant[ch]+!!ch]);
+            ff_ac3_decode_exponents(gb, ctx->exp_strategy[ch], num_groups, ctx->dexps[ch][0],
+                             &ctx->dexps[ch][ctx->start_freq[ch]+!!ch]);
             if(ch != CPL_CH && ch != ctx->lfe_ch)
                 skip_bits(gb, 2); /* skip gainrng */
         }
@@ -918,12 +919,12 @@ static int ac3_parse_audio_block(AC3Deco
 
     /* bit allocation information */
     if (get_bits1(gb)) {
-        ctx->bit_alloc_params.sdecay = ff_sdecaytab[get_bits(gb, 2)];
-        ctx->bit_alloc_params.fdecay = ff_fdecaytab[get_bits(gb, 2)];
-        ctx->bit_alloc_params.sgain  = ff_sgaintab[get_bits(gb, 2)];
-        ctx->bit_alloc_params.dbknee = ff_dbkneetab[get_bits(gb, 2)];
-        ctx->bit_alloc_params.floor  = ff_floortab[get_bits(gb, 3)];
-        for(ch=!ctx->cplinu; ch<=ctx->nchans; ch++) {
+        ctx->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[get_bits(gb, 2)] >> ctx->bit_alloc_params.sr_shift;
+        ctx->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[get_bits(gb, 2)] >> ctx->bit_alloc_params.sr_shift;
+        ctx->bit_alloc_params.slow_gain  = ff_ac3_slow_gain_tab[get_bits(gb, 2)];
+        ctx->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gb, 2)];
+        ctx->bit_alloc_params.floor  = ff_ac3_floor_tab[get_bits(gb, 3)];
+        for(ch=!ctx->cpl_in_use; ch<=ctx->channels; ch++) {
             bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
         }
     }
@@ -932,74 +933,73 @@ static int ac3_parse_audio_block(AC3Deco
     if (get_bits1(gb)) {
         int csnr;
         csnr = (get_bits(gb, 6) - 15) << 4;
-        for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) { /* snr offset and fast gain */
-            ctx->snroffst[ch] = (csnr + get_bits(gb, 4)) << 2;
-            ctx->fgain[ch] = ff_fgaintab[get_bits(gb, 3)];
+        for (ch = !ctx->cpl_in_use; ch <= ctx->channels; ch++) { /* snr offset and fast gain */
+            ctx->snr_offset[ch] = (csnr + get_bits(gb, 4)) << 2;
+            ctx->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gb, 3)];
         }
         memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
     }
 
     /* coupling leak information */
-    if (ctx->cplinu && get_bits1(gb)) {
-        ctx->bit_alloc_params.cplfleak = get_bits(gb, 3);
-        ctx->bit_alloc_params.cplsleak = get_bits(gb, 3);
+    if (ctx->cpl_in_use && get_bits1(gb)) {
+        ctx->bit_alloc_params.cpl_fast_leak = get_bits(gb, 3);
+        ctx->bit_alloc_params.cpl_slow_leak = get_bits(gb, 3);
         bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2);
     }
 
     /* delta bit allocation information */
     if (get_bits1(gb)) {
         /* delta bit allocation exists (strategy) */
-        for (ch = !ctx->cplinu; ch <= nfchans; ch++) {
-            ctx->deltbae[ch] = get_bits(gb, 2);
-            if (ctx->deltbae[ch] == DBA_RESERVED) {
+        for (ch = !ctx->cpl_in_use; ch <= fbw_channels; ch++) {
+            ctx->dba_mode[ch] = get_bits(gb, 2);
+            if (ctx->dba_mode[ch] == DBA_RESERVED) {
                 av_log(ctx->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
                 return -1;
             }
             bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
         }
         /* channel delta offset, len and bit allocation */
-        for (ch = !ctx->cplinu; ch <= nfchans; ch++) {
-            if (ctx->deltbae[ch] == DBA_NEW) {
-                ctx->deltnseg[ch] = get_bits(gb, 3);
-                for (seg = 0; seg <= ctx->deltnseg[ch]; seg++) {
-                    ctx->deltoffst[ch][seg] = get_bits(gb, 5);
-                    ctx->deltlen[ch][seg] = get_bits(gb, 4);
-                    ctx->deltba[ch][seg] = get_bits(gb, 3);
+        for (ch = !ctx->cpl_in_use; ch <= fbw_channels; ch++) {
+            if (ctx->dba_mode[ch] == DBA_NEW) {
+                ctx->dba_nsegs[ch] = get_bits(gb, 3);
+                for (seg = 0; seg <= ctx->dba_nsegs[ch]; seg++) {
+                    ctx->dba_offsets[ch][seg] = get_bits(gb, 5);
+                    ctx->dba_lengths[ch][seg] = get_bits(gb, 4);
+                    ctx->dba_values[ch][seg] = get_bits(gb, 3);
                 }
             }
         }
     } else if(blk == 0) {
-        for(ch=0; ch<=ctx->nchans; ch++) {
-            ctx->deltbae[ch] = DBA_NONE;
+        for(ch=0; ch<=ctx->channels; ch++) {
+            ctx->dba_mode[ch] = DBA_NONE;
         }
     }
 
     /* Bit allocation */
-    for(ch=!ctx->cplinu; ch<=ctx->nchans; ch++) {
+    for(ch=!ctx->cpl_in_use; ch<=ctx->channels; ch++) {
         if(bit_alloc_stages[ch] > 2) {
             /* Exponent mapping into PSD and PSD integration */
             ff_ac3_bit_alloc_calc_psd(ctx->dexps[ch],
-                                      ctx->startmant[ch], ctx->endmant[ch],
-                                      ctx->psd[ch], ctx->bndpsd[ch]);
+                                      ctx->start_freq[ch], ctx->end_freq[ch],
+                                      ctx->psd[ch], ctx->band_psd[ch]);
         }
         if(bit_alloc_stages[ch] > 1) {
             /* Compute excitation function, Compute masking curve, and
                Apply delta bit allocation */
-            ff_ac3_bit_alloc_calc_mask(&ctx->bit_alloc_params, ctx->bndpsd[ch],
-                                       ctx->startmant[ch], ctx->endmant[ch],
-                                       ctx->fgain[ch], (ch == ctx->lfe_ch),
-                                       ctx->deltbae[ch], ctx->deltnseg[ch],
-                                       ctx->deltoffst[ch], ctx->deltlen[ch],
-                                       ctx->deltba[ch], ctx->mask[ch]);
+            ff_ac3_bit_alloc_calc_mask(&ctx->bit_alloc_params, ctx->band_psd[ch],
+                                       ctx->start_freq[ch], ctx->end_freq[ch],
+                                       ctx->fast_gain[ch], (ch == ctx->lfe_ch),
+                                       ctx->dba_mode[ch], ctx->dba_nsegs[ch],
+                                       ctx->dba_offsets[ch], ctx->dba_lengths[ch],
+                                       ctx->dba_values[ch], ctx->mask[ch]);
         }
         if(bit_alloc_stages[ch] > 0) {
             /* Compute bit allocation */
             ff_ac3_bit_alloc_calc_bap(ctx->mask[ch], ctx->psd[ch],
-                                      ctx->startmant[ch], ctx->endmant[ch],
-                                      ctx->snroffst[ch],
+                                      ctx->start_freq[ch], ctx->end_freq[ch],
+                                      ctx->snr_offset[ch],
                                       ctx->bit_alloc_params.floor,
-                                      ff_ac3_baptab,
-                                      ctx->bap[ch]);
+                                      ff_ac3_bap_tab, ctx->bap[ch]);
         }
     }
 
@@ -1018,20 +1018,21 @@ static int ac3_parse_audio_block(AC3Deco
     }
 
     /* recover coefficients if rematrixing is in use */
-    if(ctx->acmod == AC3_ACMOD_STEREO)
+    if(ctx->channel_mode == AC3_CHMODE_STEREO) {
         ff_ac3_do_rematrixing(ctx->transform_coeffs,
-                FFMIN(ctx->endmant[1], ctx->endmant[2]),
-                ctx->nrematbnd, ctx->rematflg);
+                              FFMIN(ctx->end_freq[1], ctx->end_freq[2]),
+                              ctx->num_rematrixing_bands, ctx->rematrixing_flags);
+    }
 
     /* apply scaling to coefficients (headroom, dialnorm, dynrng) */
-    for(ch=1; ch<=ctx->nchans; ch++) {
+    for(ch=1; ch<=ctx->channels; ch++) {
         float gain = 2.0f * ctx->mul_bias;
-        if(ctx->acmod == AC3_ACMOD_DUALMONO) {
-            gain *= ctx->dialnorm[ch-1] * ctx->dynrng[ch-1];
+        if(ctx->channel_mode == AC3_CHMODE_DUALMONO) {
+            gain *= ctx->dialog_norm[ch-1] * ctx->dynamic_range[ch-1];
         } else {
-            gain *= ctx->dialnorm[0] * ctx->dynrng[0];
+            gain *= ctx->dialog_norm[0] * ctx->dynamic_range[0];
         }
-        for(i=0; i<ctx->endmant[ch]; i++) {
+        for(i=0; i<ctx->end_freq[ch]; i++) {
             ctx->transform_coeffs[ch][i] *= gain;
         }
     }
@@ -1039,9 +1040,9 @@ static int ac3_parse_audio_block(AC3Deco
     do_imdct(ctx);
 
     /* downmix output if needed */
-    if(ctx->nchans != ctx->out_channels && !((ctx->output_mode & AC3_OUTPUT_LFEON) &&
-            ctx->nfchans == ctx->out_channels)) {
-        ff_ac3_downmix(ctx->output, ctx->nfchans, ctx->output_mode,
+    if(ctx->channels != ctx->out_channels && !((ctx->output_mode & AC3_OUTPUT_LFEON) &&
+            ctx->fbw_channels == ctx->out_channels)) {
+        ff_ac3_downmix(ctx->output, ctx->fbw_channels, ctx->output_mode,
                     ctx->downmix_coeffs);
     }
 
@@ -1063,23 +1064,45 @@ static int ac3_decode_frame(AVCodecConte
 {
     AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data;
     int16_t *out_samples = (int16_t *)data;
-    int i, blk, ch;
+    int i, blk, ch, err;
 
     /* initialize the GetBitContext with the start of valid AC-3 Frame */
     init_get_bits(&ctx->gb, buf, buf_size * 8);
 
     /* parse the syncinfo */
-    if (ac3_parse_header(ctx)) {
-        av_log(avctx, AV_LOG_ERROR, "\n");
-        *data_size = 0;
-        return buf_size;
+    err = ac3_parse_header(ctx);
+    if(err) {
+        switch(err) {
+            case AC3_PARSE_ERROR_SYNC:
+                av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
+                break;
+            case AC3_PARSE_ERROR_BSID:
+                av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n");
+                break;
+            case AC3_PARSE_ERROR_SAMPLE_RATE:
+                av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n");
+                break;
+            case AC3_PARSE_ERROR_FRAME_SIZE:
+                av_log(avctx, AV_LOG_ERROR, "invalid frame size\n");
+                break;
+            default:
+                av_log(avctx, AV_LOG_ERROR, "invalid header\n");
+                break;
+        }
+        return -1;
     }
 
     avctx->sample_rate = ctx->sampling_rate;
     avctx->bit_rate = ctx->bit_rate;
 
+    /* check that reported frame size fits in input buffer */
+    if(ctx->frame_size > buf_size) {
+        av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
+        return -1;
+    }
+
     /* channel config */
-    ctx->out_channels = ctx->nchans;
+    ctx->out_channels = ctx->channels;
     if (avctx->channels == 0) {
         avctx->channels = ctx->out_channels;
     } else if(ctx->out_channels < avctx->channels) {
@@ -1088,9 +1111,9 @@ static int ac3_decode_frame(AVCodecConte
         return -1;
     }
     if(avctx->channels == 2) {
-        ctx->output_mode = AC3_ACMOD_STEREO;
+        ctx->output_mode = AC3_CHMODE_STEREO;
     } else if(avctx->channels == 1) {
-        ctx->output_mode = AC3_ACMOD_MONO;
+        ctx->output_mode = AC3_CHMODE_MONO;
     } else if(avctx->channels != ctx->out_channels) {
         av_log(avctx, AV_LOG_ERROR, "Cannot downmix AC3 from %d to %d channels.\n",
                ctx->out_channels, avctx->channels);

Modified: eac3/ac3dec.h
==============================================================================
--- eac3/ac3dec.h	(original)
+++ eac3/ac3dec.h	Tue Dec 11 03:38:13 2007
@@ -36,18 +36,11 @@
 void ff_ac3_window_init(float *window);
 void ff_ac3_tables_init(void);
 
-/** tables for ungrouping mantissas */
-extern float ff_ac3_b1_mantissas[32][3];
-extern float ff_ac3_b2_mantissas[128][3];
-extern float ff_ac3_b3_mantissas[8];
-extern float ff_ac3_b4_mantissas[128][2];
-extern float ff_ac3_b5_mantissas[16];
-
 /** dynamic range table. converts codes to scale factors. */
-extern float ff_ac3_dynrng_tbl[256];
+extern float ff_ac3_dynamic_range_tab[256];
 
-/** dialogue normalization table */
-extern float ff_ac3_dialnorm_tbl[32];
+/** dialog normalization table */
+extern float ff_ac3_dialog_norm_tab[32];
 
 /**
  * table for exponent to scale_factor mapping
@@ -55,14 +48,11 @@ extern float ff_ac3_dialnorm_tbl[32];
  */
 extern float ff_ac3_scale_factors[25];
 
-/** table for grouping exponents */
-extern uint8_t ff_ac3_exp_ungroup_tbl[128][3];
-
 /**
  * Decode the grouped exponents according to exponent strategy.
  * reference: Section 7.1.3 Exponent Decoding
  */
-void ff_ac3_decode_exponents(GetBitContext *gb, int expstr, int ngrps,
+void ff_ac3_decode_exponents(GetBitContext *gb, int exp_strategy, int ngrps,
                              uint8_t absexp, int8_t *dexps);
 
 /**

Modified: eac3/ac3tab.c
==============================================================================
--- eac3/ac3tab.c	(original)
+++ eac3/ac3tab.c	Tue Dec 11 03:38:13 2007
@@ -31,7 +31,7 @@
  * Possible frame sizes.
  * from ATSC A/52 Table 5.18 Frame Size Code Table.
  */
-const uint16_t ff_ac3_frame_sizes[38][3] = {
+const uint16_t ff_ac3_frame_size_tab[38][3] = {
     { 64,   69,   96   },
     { 64,   70,   96   },
     { 80,   87,   120  },
@@ -76,15 +76,15 @@ const uint16_t ff_ac3_frame_sizes[38][3]
  * Maps audio coding mode (acmod) to number of full-bandwidth channels.
  * from ATSC A/52 Table 5.8 Audio Coding Mode
  */
-const uint8_t ff_ac3_channels[8] = {
+const uint8_t ff_ac3_channels_tab[8] = {
     2, 1, 2, 3, 3, 4, 4, 5
 };
 
 /* possible frequencies */
-const uint16_t ff_ac3_freqs[3] = { 48000, 44100, 32000 };
+const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 };
 
 /* possible bitrates */
-const uint16_t ff_ac3_bitratetab[19] = {
+const uint16_t ff_ac3_bitrate_tab[19] = {
     32, 40, 48, 56, 64, 80, 96, 112, 128,
     160, 192, 224, 256, 320, 384, 448, 512, 576, 640
 };
@@ -127,36 +127,36 @@ const int16_t ff_ac3_window[256] = {
 32767,32767,32767,32767,32767,32767,32767,32767,
 };
 
-const uint8_t ff_ac3_latab[260]= {
-0x0040,0x003f,0x003e,0x003d,0x003c,0x003b,0x003a,0x0039,0x0038,0x0037,
-0x0036,0x0035,0x0034,0x0034,0x0033,0x0032,0x0031,0x0030,0x002f,0x002f,
-0x002e,0x002d,0x002c,0x002c,0x002b,0x002a,0x0029,0x0029,0x0028,0x0027,
-0x0026,0x0026,0x0025,0x0024,0x0024,0x0023,0x0023,0x0022,0x0021,0x0021,
-0x0020,0x0020,0x001f,0x001e,0x001e,0x001d,0x001d,0x001c,0x001c,0x001b,
-0x001b,0x001a,0x001a,0x0019,0x0019,0x0018,0x0018,0x0017,0x0017,0x0016,
-0x0016,0x0015,0x0015,0x0015,0x0014,0x0014,0x0013,0x0013,0x0013,0x0012,
-0x0012,0x0012,0x0011,0x0011,0x0011,0x0010,0x0010,0x0010,0x000f,0x000f,
-0x000f,0x000e,0x000e,0x000e,0x000d,0x000d,0x000d,0x000d,0x000c,0x000c,
-0x000c,0x000c,0x000b,0x000b,0x000b,0x000b,0x000a,0x000a,0x000a,0x000a,
-0x000a,0x0009,0x0009,0x0009,0x0009,0x0009,0x0008,0x0008,0x0008,0x0008,
-0x0008,0x0008,0x0007,0x0007,0x0007,0x0007,0x0007,0x0007,0x0006,0x0006,
-0x0006,0x0006,0x0006,0x0006,0x0006,0x0006,0x0005,0x0005,0x0005,0x0005,
-0x0005,0x0005,0x0005,0x0005,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
-0x0004,0x0004,0x0004,0x0004,0x0004,0x0003,0x0003,0x0003,0x0003,0x0003,
-0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0002,
-0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
-0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0001,0x0001,
-0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
-0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
-0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
+const uint8_t ff_ac3_log_add_tab[260]= {
+0x40,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37,
+0x36,0x35,0x34,0x34,0x33,0x32,0x31,0x30,0x2f,0x2f,
+0x2e,0x2d,0x2c,0x2c,0x2b,0x2a,0x29,0x29,0x28,0x27,
+0x26,0x26,0x25,0x24,0x24,0x23,0x23,0x22,0x21,0x21,
+0x20,0x20,0x1f,0x1e,0x1e,0x1d,0x1d,0x1c,0x1c,0x1b,
+0x1b,0x1a,0x1a,0x19,0x19,0x18,0x18,0x17,0x17,0x16,
+0x16,0x15,0x15,0x15,0x14,0x14,0x13,0x13,0x13,0x12,
+0x12,0x12,0x11,0x11,0x11,0x10,0x10,0x10,0x0f,0x0f,
+0x0f,0x0e,0x0e,0x0e,0x0d,0x0d,0x0d,0x0d,0x0c,0x0c,
+0x0c,0x0c,0x0b,0x0b,0x0b,0x0b,0x0a,0x0a,0x0a,0x0a,
+0x0a,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x08,0x08,
+0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x06,0x06,
+0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x05,0x05,0x05,
+0x05,0x05,0x05,0x05,0x04,0x04,0x04,0x04,0x04,0x04,
+0x04,0x04,0x04,0x04,0x04,0x03,0x03,0x03,0x03,0x03,
+0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 };
 
-const uint16_t ff_ac3_hth[50][3]= {
+const uint16_t ff_ac3_hearing_threshold_tab[50][3]= {
 { 0x04d0,0x04f0,0x0580 },
 { 0x04d0,0x04f0,0x0580 },
 { 0x0440,0x0460,0x04b0 },
@@ -219,7 +219,7 @@ const uint8_t ff_ac3_hebaptab[64] = {
     19, 19, 19, 19,
 };
 
-const uint8_t ff_ac3_baptab[64]= {
+const uint8_t ff_ac3_bap_tab[64]= {
     0, 1, 1, 1, 1, 1, 2, 2, 3, 3,
     3, 4, 4, 5, 5, 6, 6, 6, 6, 7,
     7, 7, 7, 8, 8, 8, 8, 9, 9, 9,
@@ -234,51 +234,40 @@ const uint8_t ff_bits_vs_hebap[20] = {
     5,  6,  7,  8,  9, 10, 11, 12, 14, 16,
 };
 
-const uint8_t ff_sdecaytab[4]={
+const uint8_t ff_ac3_slow_decay_tab[4]={
     0x0f, 0x11, 0x13, 0x15,
 };
 
-const uint8_t ff_fdecaytab[4]={
+const uint8_t ff_ac3_fast_decay_tab[4]={
     0x3f, 0x53, 0x67, 0x7b,
 };
 
-const uint16_t ff_sgaintab[4]= {
+const uint16_t ff_ac3_slow_gain_tab[4]= {
     0x540, 0x4d8, 0x478, 0x410,
 };
 
-const uint16_t ff_dbkneetab[4]= {
+const uint16_t ff_ac3_db_per_bit_tab[4]= {
     0x000, 0x700, 0x900, 0xb00,
 };
 
-const int16_t ff_floortab[8]= {
+const int16_t ff_ac3_floor_tab[8]= {
     0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800,
 };
 
-const uint16_t ff_fgaintab[8]= {
+const uint16_t ff_ac3_fast_gain_tab[8]= {
     0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
 };
 
-const uint8_t ff_ac3_bndsz[50]={
+const uint8_t ff_ac3_critical_band_size_tab[50]={
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
     3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
 };
 
-/**
- * Quantization table: levels for symmetric. bits for asymmetric.
- * reference: Table 7.18 Mapping of bap to Quantizer
- */
-const uint8_t ff_qntztab[16] = {
-    0, 3, 5, 7, 11, 15,
-    5, 6, 7, 8, 9, 10, 11, 12, 14, 16
-};
-
 const uint8_t ff_eac3_blocks[4] = {
     1, 2, 3, 6
 };
 
-const uint8_t ff_nfchans_tbl[8] = { 2, 1, 2, 3, 3, 4, 4, 5 };
-
 /**
  * Table E3.6
  * Large mantissa inverse quantization (remapping) constants
@@ -1403,5 +1392,4 @@ const float ff_eac3_spxattentab[32][3] =
  * Table of bin locations for rematrixing bands
  * reference: Section 7.5.2 Rematrixing : Frequency Band Definitions
  */
-const uint8_t ff_ac3_rematrix_band_tbl[5] = { 13, 25, 37, 61, 253 };
-
+const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 };

Modified: eac3/ac3tab.h
==============================================================================
--- eac3/ac3tab.h	(original)
+++ eac3/ac3tab.h	Tue Dec 11 03:38:13 2007
@@ -19,29 +19,27 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AC3TAB_H
-#define AC3TAB_H
+#ifndef FFMPEG_AC3TAB_H
+#define FFMPEG_AC3TAB_H
 
 #include "common.h"
 
-extern const uint16_t ff_ac3_frame_sizes[38][3];
-extern const uint8_t  ff_ac3_channels[8];
-extern const uint16_t ff_ac3_freqs[3];
-extern const uint16_t ff_ac3_bitratetab[19];
+extern const uint16_t ff_ac3_frame_size_tab[38][3];
+extern const uint8_t  ff_ac3_channels_tab[8];
+extern const uint16_t ff_ac3_sample_rate_tab[3];
+extern const uint16_t ff_ac3_bitrate_tab[19];
 extern const int16_t  ff_ac3_window[256];
-extern const uint8_t  ff_ac3_latab[260];
-extern const uint16_t ff_ac3_hth[50][3];
+extern const uint8_t  ff_ac3_log_add_tab[260];
+extern const uint16_t ff_ac3_hearing_threshold_tab[50][3];
 extern const uint8_t  ff_ac3_hebaptab[64];
-extern const uint8_t  ff_ac3_baptab[64];
-extern const uint8_t  ff_sdecaytab[4];
-extern const uint8_t  ff_fdecaytab[4];
-extern const uint16_t ff_sgaintab[4];
-extern const uint16_t ff_dbkneetab[4];
-extern const int16_t  ff_floortab[8];
-extern const uint16_t ff_fgaintab[8];
-extern const uint8_t  ff_ac3_bndsz[50];
-extern const uint8_t  ff_qntztab[16];
-extern const uint8_t ff_nfchans_tbl[8];
+extern const uint8_t  ff_ac3_bap_tab[64];
+extern const uint8_t  ff_ac3_slow_decay_tab[4];
+extern const uint8_t  ff_ac3_fast_decay_tab[4];
+extern const uint16_t ff_ac3_slow_gain_tab[4];
+extern const uint16_t ff_ac3_db_per_bit_tab[4];
+extern const int16_t  ff_ac3_floor_tab[8];
+extern const uint16_t ff_ac3_fast_gain_tab[8];
+extern const uint8_t  ff_ac3_critical_band_size_tab[50];
 extern const uint8_t ff_eac3_blocks[4];
 extern const uint8_t ff_bits_vs_hebap[20];
 extern const int16_t ff_eac3_gaq_remap[12][2][3][2];
@@ -61,6 +59,6 @@ extern const uint8_t ff_eac3_defspxbndst
 extern const uint8_t ff_eac3_defecplbndstrc[22];
 extern const float   ff_eac3_spxattentab[32][3];
 
-extern const uint8_t ff_ac3_rematrix_band_tbl[5];
+extern const uint8_t ff_ac3_rematrix_band_tab[5];
 
-#endif /* AC3TAB_H */
+#endif /* FFMPEG_AC3TAB_H */

Modified: eac3/checkout.sh
==============================================================================
--- eac3/checkout.sh	(original)
+++ eac3/checkout.sh	Tue Dec 11 03:38:13 2007
@@ -4,7 +4,7 @@ echo "checking out ffmpeg svn"
 for i in $FILES ac3_parser.c Makefile aac_ac3_parser.c aac_ac3_parser.h aac_parser.c allcodecs.c avcodec.h ../libavformat/allformats.h ../libavformat/raw.c allcodecs.h ac3enc.c ../ffmpeg.c; do
     rm -f ffmpeg/libavcodec/$i
 done
-svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk/ ffmpeg -r 10220
+svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk/ ffmpeg -r 11200
 echo "patching ffmpeg"
 cd ffmpeg
 patch -p0 <../ffmpeg.patch

Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h	(original)
+++ eac3/eac3.h	Tue Dec 11 03:38:13 2007
@@ -18,8 +18,8 @@
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-#ifndef EAC3_H
-#define EAC3_H
+#ifndef FFMPEG_EAC3_H
+#define FFMPEG_EAC3_H
 
 #include "dsputil.h"
 #include "avcodec.h"

Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c	(original)
+++ eac3/eac3dec.c	Tue Dec 11 03:38:13 2007
@@ -354,7 +354,7 @@ static int parse_bsi(GetBitContext *gbc,
     s->lfeon = get_bits1(gbc);
 
     // calculate number of channels
-    s->nfchans = ff_ac3_channels[s->acmod];
+    s->nfchans = ff_ac3_channels_tab[s->acmod];
     s->num_channels = s->nfchans;
     s->lfe_channel = s->num_channels+1;
     if (s->lfeon) {
@@ -372,7 +372,7 @@ static int parse_bsi(GetBitContext *gbc,
     }
 
     for (i = 0; i < (s->acmod ? 1 : 2); i++) {
-        s->dialnorm[i] = ff_ac3_dialnorm_tbl[get_bits(gbc, 5)];
+        s->dialnorm[i] = ff_ac3_dialog_norm_tab[get_bits(gbc, 5)];
         if (get_bits1(gbc)) {
             skip_bits(gbc, 8); //skip Compression gain word
         }
@@ -484,7 +484,7 @@ static int parse_bsi(GetBitContext *gbc,
         /* Informational metadata */
         skip_bits(gbc, 3); //skip Bit stream mode
         skip_bits(gbc, 2); //skip copyright bit and original bitstream bit
-        if (s->acmod == AC3_ACMOD_STEREO) { /* if in 2/0 mode */
+        if (s->acmod == AC3_CHMODE_STEREO) { /* if in 2/0 mode */
             skip_bits(gbc, 4); //skip Dolby surround and headphone mode
         }
         if (s->acmod >= 6) {
@@ -700,7 +700,7 @@ static int parse_audblk(GetBitContext *g
     /* Dynamic range control */
     for (i = 0; i < (s->acmod ? 1 : 2); i++) {
         if (get_bits1(gbc)) {
-            s->dynrng[i] = ff_ac3_dynrng_tbl[get_bits(gbc, 8)];
+            s->dynrng[i] = ff_ac3_dynamic_range_tab[get_bits(gbc, 8)];
         } else {
             if (!blk) {
                 s->dynrng[i] = 1.0f;
@@ -714,7 +714,7 @@ static int parse_audblk(GetBitContext *g
             log_missing_feature(s->avctx, "Spectral extension");
             return -1;
 #if 0
-            if (s->acmod == AC3_ACMOD_MONO) {
+            if (s->acmod == AC3_CHMODE_MONO) {
                 s->chinspx[1] = 1;
             } else {
                 for (ch = 1; ch <= s->nfchans; ch++) {
@@ -821,7 +821,7 @@ static int parse_audblk(GetBitContext *g
     if (s->cplstre[blk]) {
         if (s->cplinu[blk]) {
             s->ecplinu = get_bits1(gbc);
-            if (s->acmod == AC3_ACMOD_STEREO) {
+            if (s->acmod == AC3_CHMODE_STEREO) {
                 s->chincpl[1] = 1;
                 s->chincpl[2] = 1;
             } else {
@@ -831,7 +831,7 @@ static int parse_audblk(GetBitContext *g
             }
             if (!s->ecplinu) {
                 /* standard coupling in use */
-                if (s->acmod == AC3_ACMOD_STEREO) { /* if in 2/0 mode */
+                if (s->acmod == AC3_CHMODE_STEREO) { /* if in 2/0 mode */
                     s->phsflginu = get_bits1(gbc);
                 }
                 s->cplbegf = get_bits(gbc, 4);
@@ -965,7 +965,7 @@ static int parse_audblk(GetBitContext *g
                     s->firstcplcos[ch] = 1;
                 }
             } /* ch */
-            if ((s->acmod == AC3_ACMOD_STEREO) && s->phsflginu
+            if ((s->acmod == AC3_CHMODE_STEREO) && s->phsflginu
                     && (s->cplcoe[1] || s->cplcoe[2])) {
                 for (bnd = 0; bnd < s->ncplbnd; bnd++) {
                     s->phsflg[bnd] = get_bits1(gbc);
@@ -1026,13 +1026,13 @@ static int parse_audblk(GetBitContext *g
         } /* ecplinu[blk] */
     } /* cplinu[blk] */
     /* Rematrixing operation in the 2/0 mode */
-    if (s->acmod == AC3_ACMOD_STEREO) { /* if in 2/0 mode */
+    if (s->acmod == AC3_CHMODE_STEREO) { /* if in 2/0 mode */
         if (!blk || get_bits1(gbc)) {
             /* nrematbnds determined from cplinu, ecplinu, spxinu, cplbegf, ecplbegf and spxbegf */
             // TODO spx in one channel
             int end = (s->cplinu[blk] || s->spxinu) ?
-                FFMIN(s->endmant[1], s->endmant[2]) : (ff_ac3_rematrix_band_tbl[4]-1);
-            for (bnd = 0; ff_ac3_rematrix_band_tbl[bnd] <= end; bnd++) {
+                FFMIN(s->endmant[1], s->endmant[2]) : (ff_ac3_rematrix_band_tab[4]-1);
+            for (bnd = 0; ff_ac3_rematrix_band_tab[bnd] <= end; bnd++) {
                 s->rematflg[bnd] = get_bits1(gbc);
             }
             s->nrematbnds = bnd;
@@ -1073,11 +1073,11 @@ static int parse_audblk(GetBitContext *g
     /* Bit-allocation parametric information */
     if (s->bamode) {
         if (get_bits1(gbc)) {
-            s->bit_alloc_params.sdecay = ff_sdecaytab[get_bits(gbc, 2)];   /* Table 7.6 */
-            s->bit_alloc_params.fdecay = ff_fdecaytab[get_bits(gbc, 2)];   /* Table 7.7 */
-            s->bit_alloc_params.sgain  = ff_sgaintab [get_bits(gbc, 2)];   /* Table 7.8 */
-            s->bit_alloc_params.dbknee = ff_dbkneetab[get_bits(gbc, 2)];   /* Table 7.9 */
-            s->bit_alloc_params.floor  = ff_floortab [get_bits(gbc, 3)];   /* Table 7.10 */
+            s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[get_bits(gbc, 2)];   /* Table 7.6 */
+            s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[get_bits(gbc, 2)];   /* Table 7.7 */
+            s->bit_alloc_params.slow_gain  = ff_ac3_slow_gain_tab [get_bits(gbc, 2)];   /* Table 7.8 */
+            s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)];   /* Table 7.9 */
+            s->bit_alloc_params.floor      = ff_ac3_floor_tab     [get_bits(gbc, 3)];   /* Table 7.10 */
         } else {
             if (!blk) {
                 av_log(s->avctx, AV_LOG_ERROR, "no bit allocation information in first block\n");
@@ -1085,11 +1085,11 @@ static int parse_audblk(GetBitContext *g
             }
         }
     } else {
-        s->bit_alloc_params.sdecay = ff_sdecaytab[2];   /* Table 7.6 */
-        s->bit_alloc_params.fdecay = ff_fdecaytab[1];   /* Table 7.7 */
-        s->bit_alloc_params.sgain  = ff_sgaintab[1];    /* Table 7.8 */
-        s->bit_alloc_params.dbknee = ff_dbkneetab[2];   /* Table 7.9 */
-        s->bit_alloc_params.floor  = ff_floortab[7];    /* Table 7.10 */
+        s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2];  /* Table 7.6 */
+        s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1];  /* Table 7.7 */
+        s->bit_alloc_params.slow_gain  = ff_ac3_slow_gain_tab [1];  /* Table 7.8 */
+        s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2];  /* Table 7.9 */
+        s->bit_alloc_params.floor      = ff_ac3_floor_tab     [7];  /* Table 7.10 */
     }
 
     if (s->snroffststr) {
@@ -1106,11 +1106,11 @@ static int parse_audblk(GetBitContext *g
 
     if (s->frmfgaincode && get_bits1(gbc)) {
         for (ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
-            s->fgain[ch] = ff_fgaintab[get_bits(gbc, 3)];
+            s->fgain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];
     } else {
         if (!blk) {
             for (ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
-                s->fgain[ch] = ff_fgaintab[4];
+                s->fgain[ch] = ff_ac3_fast_gain_tab[4];
         }
     }
     if (!s->strmtyp) {
@@ -1127,8 +1127,8 @@ static int parse_audblk(GetBitContext *g
             s->cplleake = get_bits1(gbc);
         }
         if (s->cplleake) {
-            s->bit_alloc_params.cplfleak = get_bits(gbc, 3);
-            s->bit_alloc_params.cplsleak = get_bits(gbc, 3);
+            s->bit_alloc_params.cpl_fast_leak = get_bits(gbc, 3);
+            s->bit_alloc_params.cpl_slow_leak = get_bits(gbc, 3);
         }
     }
     /* Delta bit allocation information */
@@ -1167,8 +1167,8 @@ static int parse_audblk(GetBitContext *g
         ff_ac3_bit_alloc_calc_psd((int8_t *)s->dexps[ch], s->strtmant[ch],
                 s->endmant[ch], s->psd[ch], s->bndpsd[ch]);
 
-        s->bit_alloc_params.fscod = s->fscod;
-        s->bit_alloc_params.halfratecod = 0;
+        s->bit_alloc_params.sr_code = s->fscod;
+        s->bit_alloc_params.sr_shift = 0;
 
         ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params,
                 s->bndpsd[ch], s->strtmant[ch], s->endmant[ch], s->fgain[ch],
@@ -1179,7 +1179,7 @@ static int parse_audblk(GetBitContext *g
 
         if (s->chahtinu[ch] == 0)
             ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], s->strtmant[ch],
-                    s->endmant[ch], s->snroffst[ch], s->bit_alloc_params.floor, ff_ac3_baptab,
+                    s->endmant[ch], s->snroffst[ch], s->bit_alloc_params.floor, ff_ac3_bap_tab,
                     s->bap[ch]);
         else
             if (s->chahtinu[ch] == 1)
@@ -1255,9 +1255,9 @@ static int eac3_decode_frame(AVCodecCont
         return -1;
 
     if (c->fscod == 3) {
-        avctx->sample_rate = ff_ac3_freqs[c->fscod2] / 2;
+        avctx->sample_rate = ff_ac3_sample_rate_tab[c->fscod2] / 2;
     } else {
-        avctx->sample_rate = ff_ac3_freqs[c->fscod];
+        avctx->sample_rate = ff_ac3_sample_rate_tab[c->fscod];
     }
 
     avctx->bit_rate = (c->frmsiz * avctx->sample_rate * 16 / ( ff_eac3_blocks[c->numblkscod] * 256)) / 1000;
@@ -1289,7 +1289,7 @@ static int eac3_decode_frame(AVCodecCont
         }
 
         /* recover coefficients if rematrixing is in use */
-        if (c->acmod == AC3_ACMOD_STEREO)
+        if (c->acmod == AC3_CHMODE_STEREO)
             ff_ac3_do_rematrixing(c->transform_coeffs,
                     FFMIN(c->endmant[1], c->endmant[2]),
                     c->nrematbnds, c->rematflg);
@@ -1297,7 +1297,7 @@ static int eac3_decode_frame(AVCodecCont
         /* apply scaling to coefficients (dialnorm, dynrng) */
         for (ch = 1; ch <= c->nfchans + c->lfeon; ch++) {
             float gain=2.0f;
-            if (c->acmod == AC3_ACMOD_DUALMONO) {
+            if (c->acmod == AC3_CHMODE_DUALMONO) {
                 gain *= c->dialnorm[ch-1] * c->dynrng[ch-1];
             } else {
                 gain *= c->dialnorm[0] * c->dynrng[0];

Modified: eac3/ffmpeg.patch
==============================================================================
--- eac3/ffmpeg.patch	(original)
+++ eac3/ffmpeg.patch	Tue Dec 11 03:38:13 2007
@@ -1,73 +1,49 @@
-Index: libavcodec/ac3_parser.c
+Index: ffmpeg.c
 ===================================================================
---- libavcodec/ac3_parser.c	(wersja 10220)
-+++ libavcodec/ac3_parser.c	(kopia robocza)
-@@ -84,7 +84,7 @@
-     return 0;
- }
- 
--static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
-+static int ac3_sync(AVCodecContext *avctx, const uint8_t *buf, int *channels, int *sample_rate,
-                     int *bit_rate, int *samples)
- {
-     int err;
-@@ -100,12 +100,16 @@
- 
-     bsid = hdr.bsid;
-     if(bsid <= 10) {             /* Normal AC-3 */
-+        if(avctx->codec_id == CODEC_ID_EAC3)
-+            avctx->codec_id = CODEC_ID_AC3;
-         *sample_rate = hdr.sample_rate;
-         *bit_rate = hdr.bit_rate;
-         *channels = hdr.channels;
-         *samples = AC3_FRAME_SIZE;
-         return hdr.frame_size;
-     } else if (bsid > 10 && bsid <= 16) { /* Enhanced AC-3 */
-+        if(avctx->codec_id == CODEC_ID_AC3)
-+            avctx->codec_id = CODEC_ID_EAC3;
-         init_get_bits(&bits, &buf[2], (AC3_HEADER_SIZE-2) * 8);
-         strmtyp = get_bits(&bits, 2);
-         substreamid = get_bits(&bits, 3);
-@@ -152,6 +156,13 @@
-     return 0;
- }
- 
-+AVCodecParser eac3_parser = {
-+    { CODEC_ID_EAC3 },
-+    sizeof(AACAC3ParseContext),
-+    ac3_parse_init,
-+    ff_aac_ac3_parse,
-+    NULL,
-+};
- 
- AVCodecParser ac3_parser = {
-     { CODEC_ID_AC3 },
+--- ffmpeg.c (FFmpeg SVN-r11200)
++++ ffmpeg.c (working copy)
+@@ -1621,6 +1621,7 @@ static int av_encode(AVFormatContext **output_files,
+                 } else {
+                     if (codec->channels != icodec->channels &&
+                         (icodec->codec_id == CODEC_ID_AC3 ||
++                         icodec->codec_id == CODEC_ID_EAC3 ||
+                          icodec->codec_id == CODEC_ID_DTS)) {
+                         /* Special case for 5:1 AC3 and DTS input */
+                         /* and mono or stereo output      */
 Index: libavcodec/Makefile
 ===================================================================
---- libavcodec/Makefile	(wersja 10220)
-+++ libavcodec/Makefile	(kopia robocza)
-@@ -63,6 +63,7 @@
+--- libavcodec/Makefile (FFmpeg SVN-r11200)
++++ libavcodec/Makefile (working copy)
+@@ -67,6 +67,7 @@ OBJS-$(CONFIG_DVDSUB_ENCODER)          += dvdsubenc.o
  OBJS-$(CONFIG_DVVIDEO_DECODER)         += dv.o
  OBJS-$(CONFIG_DVVIDEO_ENCODER)         += dv.o
  OBJS-$(CONFIG_DXA_DECODER)             += dxa.o
-+OBJS-$(CONFIG_EAC3_DECODER)            += eac3dec.o ac3dec.o
++OBJS-$(CONFIG_EAC3_DECODER)            += eac3dec.o ac3dec.o ac3tab.o ac3.o mdct.o fft.o
  OBJS-$(CONFIG_EIGHTBPS_DECODER)        += 8bps.o
  OBJS-$(CONFIG_FFV1_DECODER)            += ffv1.o rangecoder.o golomb.o
  OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o rangecoder.o
+@@ -316,6 +317,7 @@ OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs_parser.o
+ OBJS-$(CONFIG_DCA_PARSER)              += dca_parser.o
+ OBJS-$(CONFIG_DVBSUB_PARSER)           += dvbsub_parser.o
+ OBJS-$(CONFIG_DVDSUB_PARSER)           += dvdsub_parser.o
++OBJS-$(CONFIG_EAC3_PARSER)             += ac3_parser.o ac3tab.o aac_ac3_parser.o
+ OBJS-$(CONFIG_H261_PARSER)             += h261_parser.o
+ OBJS-$(CONFIG_H263_PARSER)             += h263_parser.o
+ OBJS-$(CONFIG_H264_PARSER)             += h264_parser.o
 Index: libavcodec/aac_ac3_parser.c
 ===================================================================
---- libavcodec/aac_ac3_parser.c	(wersja 10220)
-+++ libavcodec/aac_ac3_parser.c	(kopia robocza)
-@@ -48,7 +48,7 @@
-             s->inbuf_ptr += len;
-             buf_size -= len;
+--- libavcodec/aac_ac3_parser.c (FFmpeg SVN-r11200)
++++ libavcodec/aac_ac3_parser.c (working copy)
+@@ -50,7 +50,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
+ 
+         if (s->frame_size == 0) {
              if ((s->inbuf_ptr - s->inbuf) == s->header_size) {
 -                len = s->sync(s->inbuf, &channels, &sample_rate, &bit_rate,
 +                len = s->sync(avctx, s->inbuf, &channels, &sample_rate, &bit_rate,
                                &samples);
                  if (len == 0) {
                      /* no sync found : move by one byte (inefficient, but simple!) */
-@@ -59,7 +59,7 @@
+@@ -61,7 +61,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
                      /* update codec info */
                      avctx->sample_rate = sample_rate;
                      /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */
@@ -78,9 +54,9 @@ Index: libavcodec/aac_ac3_parser.c
                          }
 Index: libavcodec/aac_ac3_parser.h
 ===================================================================
---- libavcodec/aac_ac3_parser.h	(wersja 10220)
-+++ libavcodec/aac_ac3_parser.h	(kopia robocza)
-@@ -30,7 +30,7 @@
+--- libavcodec/aac_ac3_parser.h (FFmpeg SVN-r11200)
++++ libavcodec/aac_ac3_parser.h (working copy)
+@@ -30,7 +30,7 @@ typedef struct AACAC3ParseContext {
      uint8_t *inbuf_ptr;
      int frame_size;
      int header_size;
@@ -91,9 +67,9 @@ Index: libavcodec/aac_ac3_parser.h
  } AACAC3ParseContext;
 Index: libavcodec/aac_parser.c
 ===================================================================
---- libavcodec/aac_parser.c	(wersja 10220)
-+++ libavcodec/aac_parser.c	(kopia robocza)
-@@ -38,7 +38,7 @@
+--- libavcodec/aac_parser.c (FFmpeg SVN-r11200)
++++ libavcodec/aac_parser.c (working copy)
+@@ -38,7 +38,7 @@ static const int aac_channels[8] = {
  };
  
  
@@ -102,81 +78,91 @@ Index: libavcodec/aac_parser.c
                      int *bit_rate, int *samples)
  {
      GetBitContext bits;
-Index: libavcodec/allcodecs.c
-===================================================================
---- libavcodec/allcodecs.c	(wersja 10220)
-+++ libavcodec/allcodecs.c	(kopia robocza)
-@@ -172,6 +172,7 @@
-     REGISTER_DECODER(COOK, cook);
-     REGISTER_DECODER(DCA, dca);
-     REGISTER_DECODER(DSICINAUDIO, dsicinaudio);
-+    REGISTER_DECODER(EAC3, eac3);
-     REGISTER_ENCDEC (FLAC, flac);
-     REGISTER_DECODER(IMC, imc);
-     REGISTER_ENCDEC (LIBAMR_NB, libamr_nb);
-@@ -266,6 +267,7 @@
-     REGISTER_PARSER (DCA, dca);
-     REGISTER_PARSER (DVBSUB, dvbsub);
-     REGISTER_PARSER (DVDSUB, dvdsub);
-+    REGISTER_PARSER (EAC3, eac3);
-     REGISTER_PARSER (H261, h261);
-     REGISTER_PARSER (H263, h263);
-     REGISTER_PARSER (H264, h264);
-Index: libavcodec/avcodec.h
+Index: libavcodec/ac3_parser.c
 ===================================================================
---- libavcodec/avcodec.h	(wersja 10220)
-+++ libavcodec/avcodec.h	(kopia robocza)
-@@ -260,6 +260,7 @@
-     CODEC_ID_GSM_MS, /* as found in WAV */
-     CODEC_ID_ATRAC3,
-     CODEC_ID_VOXWARE,
-+    CODEC_ID_EAC3,
+--- libavcodec/ac3_parser.c (FFmpeg SVN-r11200)
++++ libavcodec/ac3_parser.c (working copy)
+@@ -84,7 +84,7 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
+     return 0;
+ }
  
-     /* subtitle codecs */
-     CODEC_ID_DVD_SUBTITLE= 0x17000,
-Index: libavcodec/allcodecs.h
-===================================================================
---- libavcodec/allcodecs.h	(wersja 10220)
-+++ libavcodec/allcodecs.h	(kopia robocza)
-@@ -98,6 +98,7 @@
- extern AVCodec dsicinvideo_decoder;
- extern AVCodec dvvideo_decoder;
- extern AVCodec dxa_decoder;
-+extern AVCodec eac3_decoder;
- extern AVCodec eightbps_decoder;
- extern AVCodec ffv1_decoder;
- extern AVCodec ffvhuff_decoder;
-@@ -295,6 +296,7 @@
- extern AVCodecParser dca_parser;
- extern AVCodecParser dvbsub_parser;
- extern AVCodecParser dvdsub_parser;
-+extern AVCodecParser eac3_parser;
- extern AVCodecParser h261_parser;
- extern AVCodecParser h263_parser;
- extern AVCodecParser h264_parser;
+-static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
++static int ac3_sync(AVCodecContext *avctx, const uint8_t *buf, int *channels, int *sample_rate,
+                     int *bit_rate, int *samples)
+ {
+     int err;
+@@ -100,12 +100,16 @@ static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
+ 
+     bitstream_id = hdr.bitstream_id;
+     if(bitstream_id <= 10) {             /* Normal AC-3 */
++        if(avctx->codec_id == CODEC_ID_EAC3)
++            avctx->codec_id = CODEC_ID_AC3;
+         *sample_rate = hdr.sample_rate;
+         *bit_rate = hdr.bit_rate;
+         *channels = hdr.channels;
+         *samples = AC3_FRAME_SIZE;
+         return hdr.frame_size;
+     } else if (bitstream_id > 10 && bitstream_id <= 16) { /* Enhanced AC-3 */
++        if(avctx->codec_id == CODEC_ID_AC3)
++            avctx->codec_id = CODEC_ID_EAC3;
+         init_get_bits(&bits, &buf[2], (AC3_HEADER_SIZE-2) * 8);
+         stream_type = get_bits(&bits, 2);
+         substream_id = get_bits(&bits, 3);
+@@ -163,3 +167,11 @@ AVCodecParser ac3_parser = {
+     ff_aac_ac3_parse,
+     NULL,
+ };
++
++AVCodecParser eac3_parser = {
++    { CODEC_ID_EAC3 },
++    sizeof(AACAC3ParseContext),
++    ac3_parse_init,
++    ff_aac_ac3_parse,
++    NULL,
++};
 Index: libavcodec/ac3enc.c
 ===================================================================
---- libavcodec/ac3enc.c	(wersja 10220)
-+++ libavcodec/ac3enc.c	(kopia robocza)
-@@ -479,7 +479,8 @@
+--- libavcodec/ac3enc.c (FFmpeg SVN-r11200)
++++ libavcodec/ac3enc.c (working copy)
+@@ -479,7 +479,8 @@ static int bit_alloc(AC3EncodeContext *s,
          for(ch=0;ch<s->nb_all_channels;ch++) {
              ff_ac3_bit_alloc_calc_bap(mask[i][ch], psd[i][ch], 0,
-                                       s->nb_coefs[ch], snroffset,
+                                       s->nb_coefs[ch], snr_offset,
 -                                      s->bit_alloc.floor, bap[i][ch]);
-+                                      s->bit_alloc.floor, ff_ac3_baptab,
++                                      s->bit_alloc.floor, ff_ac3_bap_tab,
 +                                      bap[i][ch]);
              frame_bits += compute_mantissa_size(s, bap[i][ch],
                                                   s->nb_coefs[ch]);
          }
-Index: ffmpeg.c
+Index: libavcodec/allcodecs.c
 ===================================================================
---- ffmpeg.c	(wersja 10220)
-+++ ffmpeg.c	(kopia robocza)
-@@ -1577,6 +1577,7 @@
-                 } else {
-                     if (codec->channels != icodec->channels &&
-                         (icodec->codec_id == CODEC_ID_AC3 ||
-+                         icodec->codec_id == CODEC_ID_EAC3 ||
-                          icodec->codec_id == CODEC_ID_DTS)) {
-                         /* Special case for 5:1 AC3 and DTS input */
-                         /* and mono or stereo output      */
+--- libavcodec/allcodecs.c (FFmpeg SVN-r11200)
++++ libavcodec/allcodecs.c (working copy)
+@@ -178,6 +178,7 @@ void avcodec_register_all(void)
+     REGISTER_DECODER (COOK, cook);
+     REGISTER_DECODER (DCA, dca);
+     REGISTER_DECODER (DSICINAUDIO, dsicinaudio);
++    REGISTER_DECODER (EAC3, eac3);
+     REGISTER_ENCDEC  (FLAC, flac);
+     REGISTER_DECODER (IMC, imc);
+     REGISTER_DECODER (MACE3, mace3);
+@@ -285,6 +286,7 @@ void avcodec_register_all(void)
+     REGISTER_PARSER  (DCA, dca);
+     REGISTER_PARSER  (DVBSUB, dvbsub);
+     REGISTER_PARSER  (DVDSUB, dvdsub);
++    REGISTER_PARSER  (EAC3, eac3);
+     REGISTER_PARSER  (H261, h261);
+     REGISTER_PARSER  (H263, h263);
+     REGISTER_PARSER  (H264, h264);
+Index: libavcodec/avcodec.h
+===================================================================
+--- libavcodec/avcodec.h (FFmpeg SVN-r11200)
++++ libavcodec/avcodec.h (working copy)
+@@ -274,6 +274,7 @@ enum CodecID {
+     CODEC_ID_APE,
+     CODEC_ID_NELLYMOSER,
+     CODEC_ID_MUSEPACK8,
++    CODEC_ID_EAC3,
+ 
+     /* subtitle codecs */
+     CODEC_ID_DVD_SUBTITLE= 0x17000,



More information about the FFmpeg-soc mailing list