[FFmpeg-soc] [soc]: r722 - in eac3: eac3.h eac3_parser.c

bwolowiec subversion at mplayerhq.hu
Sun Aug 12 17:03:07 CEST 2007


Author: bwolowiec
Date: Sun Aug 12 17:03:07 2007
New Revision: 722

Log:
removal of redundant variables, clearing the code


Modified:
   eac3/eac3.h
   eac3/eac3_parser.c

Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h	(original)
+++ eac3/eac3.h	Sun Aug 12 17:03:07 2007
@@ -141,9 +141,7 @@ typedef struct EAC3Context{
     int spxattene; // 1);            ///< Spectral extension attenuation enabled
     int cplinu[MAX_BLOCKS]; // 1);   ///< Coupling in use
     int cplstre[MAX_BLOCKS]; // 1);  ///< Coupling strategy exists
-    int cplexpstr[MAX_BLOCKS]; // 2);///< Coupling exponents strategy
     int chexpstr[MAX_BLOCKS][MAX_CHANNELS]; // 2); ///< Channel exponent strategy
-    int frmcplexpstr; // 5);         ///< Frame based coupling exponent strategy
     int frmchexpstr[MAX_CHANNELS];   ///< frame based channel exponent strategy
     int lfeexpstr[MAX_BLOCKS];       ///< Lfe exponent strategy
     int convexpstr[MAX_CHANNELS];    ///< Converter channel exponent strategy
@@ -193,10 +191,7 @@ typedef struct EAC3Context{
     int ecplbndstrce; // 1);         ///< Enhanced coupling band structure exists
     int ecplbndstrc[TODO_SIZE];      ///< Enhanced coupling band structure
     int cplcoe[MAX_CHANNELS];        ///< Coupling coordinates exists
-    int mstrcplco[MAX_CHANNELS];     ///< Master coupling coordinates
-    int cplcoexp[MAX_CHANNELS][TODO_SIZE]; ///< Coupling coordinate exponent
-    int cplcomant[MAX_CHANNELS][TODO_SIZE]; ///< Coupling coordinate mantissa
-    int phsflg[TODO_SIZE]; // 1);    ///< Phase flag
+    int phsflg[18]; // 1);           ///< Phase flag
     int ecplangleintrp; // 1);       ///< Enhanced coupling angle interpolation flag
     int ecplparam1e[MAX_CHANNELS];   ///< Enhanced coupling parameters 1 exists
     int ecplparam2e[MAX_CHANNELS];   ///< Enhanced coupling parameters 2 exists
@@ -208,7 +203,6 @@ typedef struct EAC3Context{
     int rematflg[TODO_SIZE]; // 1);  ///< Rematrixing flag
     int chbwcod[MAX_CHANNELS];       ///< Rematrixing strategy
     int cplabsexp; // 4);            ///< Coupling absolute exponent
-    int cplexps[TODO_SIZE]; // 7);   ///< Coupling exponent
 
     int gainrng[MAX_CHANNELS];  ///< Channel Gain range code
 //    int lfeexps[3]; // 7); // 0...nlfegrps = const 0...2
@@ -225,14 +219,10 @@ typedef struct EAC3Context{
     int fsnroffst[MAX_CHANNELS];     ///< Channel fine SNR offset
     int lfefsnroffst; // 4);         ///< Lfe fine SNR offset
     int fgaincode; // 1);            ///< Channel fast gain code enabled
-    int cplfgaincod; // 3);          ///< Coupling fast gain code code
     int fgaincod[MAX_CHANNELS];      ///< Channel fast gain code
-    int lfefgaincod; // 3);          ///< Lfe fast gain code
     int convsnroffste; // 1);        ///< Converter SNR offset exists
     int convsnroffst; // 10);        ///< Converter SNR offset
     int cplleake; // 1);             ///< Coupling leak initialization exists
-    int cplfleak; // 3);             ///< Coupling fast leak initialization
-    int cplsleak; // 3);             ///< Coupling slow leak initialization
     int deltbaie; // 1);             ///< Delta bit allocation information exists
     int cpldeltbae; // 2);           ///< Coupling delta bit allocation exists
     uint8_t deltbae[MAX_CHANNELS];   ///< Delta bit allocation exists
@@ -244,16 +234,11 @@ typedef struct EAC3Context{
     uint8_t deltoffst[MAX_CHANNELS][9]; ///< Channel delta bit allocation offset
     uint8_t deltlen[MAX_CHANNELS][9];   ///< Channel delta bit allocation length
     uint8_t deltba[MAX_CHANNELS][9];    ///< Channel delta bit allocation
-    int skiple; // 1);               ///< Skip length exists
-    int skipl; // 9);                ///< Skip length
-    int skipfld; // TODO skipl * 8); ///< Skip field
 
     int got_cplchan;
-//    int chmant[MAX_CHANNELS][TODO_SIZE];
     int chgaqmod[MAX_CHANNELS];                 ///< Channel gain adaptive quantization mode
     int chgaqgain[MAX_CHANNELS][TODO_SIZE];     ///< Channel gain adaptive quantization gain
     float pre_chmant[6][MAX_CHANNELS][TODO_SIZE];///< Pre channel mantissas
-    int cplmant[TODO_SIZE]; // cplmant          ///< Coupling mantisass
     int cplgaqmod;                              ///< Coupling channel gain adaptive quantization mode
     int cplgaqgain[TODO_SIZE];                  ///< Coupling gain adaptive quantization gain
     int pre_cplmant[6][TODO_SIZE];              ///< Pre coupling channel_mantissas
@@ -282,15 +267,10 @@ typedef struct EAC3Context{
     int ncplsubnd;                     ///< Number of coupling sub-bands
     int ncplbnd;                       ///< Number of structured coupled bands
     int nrematbnds;
-    int ncplgrps;                      ///< Number of coupled exponent groups
-    int ncplmant;                      ///< Number of coupled mantissas
 
-    int nlfemant;                      ///< Number of lfe mantissas
     int nchgrps[MAX_CHANNELS];         ///< Number of fbw channel exponent groups
     uint8_t dexps[MAX_CHANNELS][AC3_MAX_COEFS]; ///< Differential exponents
 
-    int cplstrtmant;
-    int cplendmant;
     int endmant[MAX_CHANNELS];
     int strtmant[MAX_CHANNELS];
     int firstchincpl;

Modified: eac3/eac3_parser.c
==============================================================================
--- eac3/eac3_parser.c	(original)
+++ eac3/eac3_parser.c	Sun Aug 12 17:03:07 2007
@@ -72,7 +72,6 @@ int ff_eac3_parse_bsi(GetBitContext *gbc
     s->ntchans = s->nfchans;
     s->lfe_channel = s->ntchans+1;
     if(s->lfeon){
-        s->nlfemant = 7;
         s->strtmant[s->lfe_channel] = 0;
         s->endmant[s->lfe_channel] = 7;
         s->nchgrps[s->lfe_channel] = 2;
@@ -310,12 +309,7 @@ int ff_eac3_parse_audfrm(GetBitContext *
     {
         for(blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++)
         {
-            if(s->cplinu[blk] == 1) {
-                GET_BITS(s->cplexpstr[blk], gbc, 2);
-                s->chexpstr[blk][CPL_CH] = s->cplexpstr[blk];
-            }
-
-            for(ch = 1; ch <= s->nfchans; ch++) {
+            for(ch = !s->cplinu[blk]; ch <= s->nfchans; ch++) {
                 GET_BITS(s->chexpstr[blk][ch], gbc, 2); // TODO
             }
         }
@@ -324,11 +318,9 @@ int ff_eac3_parse_audfrm(GetBitContext *
     {
         /* cplexpstr[blk] and chexpstr[blk][ch] derived from table lookups. see Table E2.14 */
         if( (s->acmod > 0x1) && (s->ncplblks > 0) ) {
-            GET_BITS(s->frmcplexpstr, gbc, 5);
-            s->frmchexpstr[0] = s->frmcplexpstr;
+            GET_BITS(s->frmchexpstr[CPL_CH], gbc, 5);
             for(blk=0; blk<6; blk++){
                 s->chexpstr[blk][CPL_CH] = ff_eac3_frm_expstr[s->frmchexpstr[0]][blk];
-                s->cplexpstr[blk] = s->chexpstr[blk][CPL_CH];
             }
         }
         for(ch = 1; ch <= s->nfchans; ch++) {
@@ -362,11 +354,12 @@ int ff_eac3_parse_audfrm(GetBitContext *
         av_log(s->avctx, AV_LOG_ERROR, "AHT NOT IMPLEMENTED");
         return -1;
 
+#if 0
         /* AHT is only available in 6 block mode (numblkscod ==0x3) */
 
         s->ncplregs = 0;
         for(blk = 0; blk < 6; blk++){
-            if(s->cplstre[blk]==1 || s->cplexpstr[blk] != EXP_REUSE)
+            if(s->cplstre[blk]==1 || s->chexpstr[blk][CPL_CH] != EXP_REUSE)
                 s->ncplregs++;
         }
         s->nchregs[0] = s->ncplregs;
@@ -416,7 +409,7 @@ int ff_eac3_parse_audfrm(GetBitContext *
             }
             s->chahtinu[s->lfe_channel] = s->lfeahtinu;
         }
-
+#endif
     }
     /* These fields for audio frame SNR offset data */
     if(s->snroffststr == 0x0)
@@ -690,9 +683,6 @@ int ff_eac3_parse_audblk(GetBitContext *
                     return -1;
                 }
 
-                s->cplstrtmant = s->strtmant[CPL_CH];
-                s->cplendmant = s->endmant[CPL_CH];
-
                 GET_BITS(s->cplbndstrce, gbc, 1);
                 if(s->cplbndstrce)
                 {
@@ -793,20 +783,19 @@ int ff_eac3_parse_audblk(GetBitContext *
                     }
                     if(s->cplcoe[ch])
                     {
-                        int mstrcplco;
-                        GET_BITS(s->mstrcplco[ch], gbc, 2);
-                        mstrcplco = 3 * s->mstrcplco[ch];
+                        int cplcoexp, cplcomant, mstrcplco;
+                        GET_BITS(mstrcplco, gbc, 2);
+                        mstrcplco = 3 * mstrcplco;
                         /* ncplbnd derived from cplbegf, cplendf, and cplbndstrc */
                         for(bnd = 0; bnd < s->ncplbnd; bnd++)
                         {
-                            GET_BITS(s->cplcoexp[ch][bnd], gbc, 4);
-                            GET_BITS(s->cplcomant[ch][bnd], gbc, 4);
-                            if(s->cplcoexp[ch][bnd]==15)
-                                s->cplco[ch][bnd] = s->cplcomant[ch][bnd] / 16.0f;
+                            GET_BITS(cplcoexp, gbc, 4);
+                            GET_BITS(cplcomant, gbc, 4);
+                            if(cplcoexp==15)
+                                s->cplco[ch][bnd] = cplcomant / 16.0f;
                             else
-                                s->cplco[ch][bnd] = (s->cplcomant[ch][bnd] + 16.0f) / 32.0f;
-                            //TODO = scale_factors[cplcoexp+mstrcplco];
-                            s->cplco[ch][bnd] *=  pow(2.0, -(s->cplcoexp[ch][bnd]+mstrcplco));
+                                s->cplco[ch][bnd] = (cplcomant + 16.0f) / 32.0f;
+                            s->cplco[ch][bnd] *=  ff_ac3_scale_factors[cplcoexp + mstrcplco];
                         }
                     } /* cplcoe[ch] */
                     else{
@@ -830,6 +819,7 @@ int ff_eac3_parse_audblk(GetBitContext *
         }
         else /* enhanced coupling in use */
         {
+#if 0
             s->firstchincpl = -1;
             GET_BITS(s->ecplangleintrp, gbc, 1);
             for(ch = 1; ch <= s->nfchans; ch++)
@@ -885,6 +875,7 @@ int ff_eac3_parse_audblk(GetBitContext *
                     s->firstcplcos[ch] = 1;
                 }
             } /* ch */
+#endif
         } /* ecplinu[blk] */
     } /* cplinu[blk] */
     /* These fields for rematrixing operation in the 2/0 mode */
@@ -930,7 +921,7 @@ int ff_eac3_parse_audblk(GetBitContext *
 
         s->strtmant[ch] = 0;
         if(s->chincpl[ch])
-            s->endmant[ch] = s->cplstrtmant; /* channel is coupled */
+            s->endmant[ch] = s->strtmant[CPL_CH]; /* channel is coupled */
         else
             s->endmant[ch] = ((s->chbwcod[ch] + 12) * 3) + 37; /* (ch is not coupled) */
 
@@ -940,7 +931,7 @@ int ff_eac3_parse_audblk(GetBitContext *
     /* These fields for exponents */
     if(s->cplinu[blk]) /* exponents for the coupling channel */
     {
-        if(s->cplexpstr[blk] != EXP_REUSE)
+        if(s->chexpstr[blk][CPL_CH] != EXP_REUSE)
         {
             /* ncplgrps derived from cplbegf, ecplbegf, cplendf, ecplendf, and cplexpstr */
             /* TODO add support for enhanced coupling */
@@ -955,7 +946,6 @@ int ff_eac3_parse_audblk(GetBitContext *
                     s->nchgrps[CPL_CH] = (s->endmant[CPL_CH] - s->strtmant[CPL_CH])/12;
                     break;
             }
-            s->ncplgrps = s->nchgrps[CPL_CH];
             GET_BITS(s->cplabsexp, gbc, 4);
 /*            for(grp = 0; grp < s->nchgrps[CPL_CH]; grp++) {
                 GET_BITS(s->cplexps[grp], gbc, 7);
@@ -1080,31 +1070,13 @@ int ff_eac3_parse_audblk(GetBitContext *
     }
     if(s->fgaincode)
     {
-        if(s->cplinu[blk]) {
-            GET_BITS(s->cplfgaincod, gbc, 3);
-        }
-        for(ch = 1; ch <= s->nfchans; ch++) {
+        for(ch = !s->cplinu[blk]; ch <= s->nfchans+s->lfeon; ch++)
             GET_BITS(s->fgaincod[ch], gbc, 3);
-        }
-        if(s->lfeon) {
-            GET_BITS(s->lfefgaincod, gbc, 3);
-        }
     }
     else
     {
-        if(s->cplinu[blk]) {
-            s->cplfgaincod = 0x4;
-        }
-        for(ch = 1; ch <= s->nfchans; ch++) {
+        for(ch = !s->cplinu[blk]; ch <= s->nfchans+s->lfeon; ch++)
             s->fgaincod[ch] = 0x4;
-        }
-        if(s->lfeon) {
-            s->lfefgaincod = 0x4;
-        }
-    }
-    s->fgaincod[CPL_CH] = s->cplfgaincod;
-    if(s->lfeon){
-        s->fgaincod[s->lfe_channel] = s->lfefgaincod;
     }
     if(s->strmtyp == 0x0)
     {
@@ -1126,8 +1098,8 @@ int ff_eac3_parse_audblk(GetBitContext *
         }
         if(s->cplleake)
         {
-            GET_BITS(s->cplfleak, gbc, 3);
-            GET_BITS(s->cplsleak, gbc, 3);
+            GET_BITS(s->bit_alloc_params.cplfleak, gbc, 3);
+            GET_BITS(s->bit_alloc_params.cplsleak, gbc, 3);
         }
     }
     /* Delta bit allocation information */
@@ -1184,13 +1156,9 @@ int ff_eac3_parse_audblk(GetBitContext *
     /* These fields for inclusion of unused dummy data */
     if(s->skipflde)
     {
-        GET_BITS(s->skiple, gbc, 1);
-        if(s->skiple)
-        {
-            GET_BITS(s->skipl, gbc, 9);
-            // TODO skip :)
-            for(i=0; i<s->skipl; i++)
-                GET_BITS(s->skipfld, gbc, 8);
+        if(get_bits1(gbc)){
+            int skipl = get_bits(gbc, 9);
+            while(skipl--) skip_bits(gbc, 8);
         }
     }
 
@@ -1213,8 +1181,6 @@ int ff_eac3_parse_audblk(GetBitContext *
         // TODO hmm... :)
         s->bit_alloc_params.fscod = s->fscod;
         s->bit_alloc_params.halfratecod = 0; // TODO
-        s->bit_alloc_params.cplfleak = s->cplfleak;
-        s->bit_alloc_params.cplsleak = s->cplsleak;
 
         {
             int fgain = ff_fgaintab[s->fgaincod[ch]];
@@ -1323,6 +1289,7 @@ int ff_eac3_parse_audblk(GetBitContext *
 
             // TODO test VQ and GAQ
             m=0;
+            ///TODO calculate nchmant
             for(bin = 0; bin < s->nchmant[ch]; bin++)
             {
                 if(s->chgaqbin[ch][bin]!=0)



More information about the FFmpeg-soc mailing list