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

bwolowiec subversion at mplayerhq.hu
Wed Aug 15 13:39:10 CEST 2007


Author: bwolowiec
Date: Wed Aug 15 13:39:10 2007
New Revision: 809

Log:
removal of redundant variables, clearing the code.


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

Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h	(original)
+++ eac3/eac3.h	Wed Aug 15 13:39:10 2007
@@ -100,7 +100,6 @@ typedef struct EAC3Context{
     int extpgmscl; // 6);            ///< External program scale factor
     int mixdef; // 2);               ///< Mix control type
     int mixdeflen; // 5);            ///< Length of mixing parameter data field
-//    int *mixdata; // 8*(mixdeflen+2));
     int paninfo; // 14);             ///< Pan information
     int paninfo2; // 14);            ///< Pan information 2
     int frmmixcfginfoe; // 1);       ///< Frame mixing configuration information exists
@@ -196,18 +195,12 @@ typedef struct EAC3Context{
     int ecpltrans[MAX_CHANNELS];     ///< Enhanced coupling transient present
     int rematstr; // 1);             ///< Rematrixing strategy
     int rematflg[TODO_SIZE]; // 1);  ///< Rematrixing flag
-    int chbwcod[MAX_CHANNELS];       ///< Rematrixing strategy
     int cplabsexp; // 4);            ///< Coupling absolute exponent
 
     int gainrng[MAX_CHANNELS];  ///< Channel Gain range code
 //    int lfeexps[3]; // 7); // 0...nlfegrps = const 0...2
     int baie; // 1);                 ///< Bit allocation information exists
-    int sdcycod; // 2);              ///< Slow decay code
-    int fdcycod; // 2);              ///< Fast decay code
-    int sgaincod; // 2);             ///< Slow gain code
-    int dbpbcod; // 2);              ///< dB per bit code
-    int floorcod; // 3);             ///< Masking floor code
-    int fgaincod[MAX_CHANNELS];      ///< Channel fast gain code
+    int fgain[MAX_CHANNELS];         ///< Channel fast gain
     int convsnroffste; // 1);        ///< Converter SNR offset exists
     int convsnroffst; // 10);        ///< Converter SNR offset
     int cplleake; // 1);             ///< Coupling leak initialization exists
@@ -225,17 +218,8 @@ typedef struct EAC3Context{
 
     int got_cplchan;
     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 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
-    int lfegaqmod;                              ///<  Lfe channel gain adaptive quantization mode
-    int lfegaqgain[TODO_SIZE];                  ///<  LFE channel gain adaptive quantization mode
-    int pre_lfemant[6][TODO_SIZE];              ///< Pre lfe channel mantissas
-
-
-
+    int chgaqgain[MAX_CHANNELS][256];           ///< Channel gain adaptive quantization gain
+    float pre_chmant[6][MAX_CHANNELS][256];     ///< Pre channel mantissas
 
     int firstspxcos[MAX_CHANNELS]; // TODO type ? ///< First spectral extension coordinates states
     int firstcplcos[MAX_CHANNELS]; // TODO type ? ///< First coupling coordinates states
@@ -244,11 +228,7 @@ typedef struct EAC3Context{
 
 
     // TODO
-    int lfegaqbin[TODO_SIZE];
-    int lfegaqsections;
-    int cplgaqbin[TODO_SIZE];
-    int cplgaqsections;
-    int chgaqbin[MAX_CHANNELS][TODO_SIZE]; // [][nchmant]
+    int chgaqbin[MAX_CHANNELS][256]; // [][nchmant]
     int chgaqsections[MAX_CHANNELS];
     int chactivegaqbins[MAX_CHANNELS];
     int nchmant[MAX_CHANNELS];         ///< Number of fbw channel mantissas

Modified: eac3/eac3_parser.c
==============================================================================
--- eac3/eac3_parser.c	(original)
+++ eac3/eac3_parser.c	Wed Aug 15 13:39:10 2007
@@ -42,6 +42,8 @@
 void spectral_extension(EAC3Context *s);
 void get_transform_coeffs_aht_ch(GetBitContext *gbc, EAC3Context *s, int ch);
 void dct_transform_coeffs_ch(EAC3Context *s, int ch, int blk);
+void get_eac3_transform_coeffs_ch(GetBitContext *gbc, EAC3Context *s, int blk,
+        int ch, mant_groups *m);
 
 int ff_eac3_parse_syncinfo(GetBitContext *gbc, EAC3Context *s){
     GET_BITS(s->syncword, gbc, 16);
@@ -385,12 +387,11 @@ int ff_eac3_parse_audfrm(GetBitContext *
         */
 
         if( (s->ncplblks == 6) && (s->ncplregs ==1) ) {
-            GET_BITS(s->cplahtinu, gbc, 1);
+            GET_BITS(s->chahtinu[CPL_CH], gbc, 1);
         }
         else {
-            s->cplahtinu = 0;
+            s->chahtinu[CPL_CH] = 0;
         }
-        s->chahtinu[0] = s->cplahtinu;
 
         for(ch = 1; ch <= s->nfchans; ch++)
         {
@@ -406,12 +407,11 @@ int ff_eac3_parse_audfrm(GetBitContext *
         if(s->lfeon)
         {
             if(s->nchregs[s->lfe_channel] == 1) {
-                GET_BITS(s->lfeahtinu, gbc, 1);
+                GET_BITS(s->chahtinu[s->lfe_channel], gbc, 1);
             }
             else {
-                s->lfeahtinu = 0;
+                s->chahtinu[s->lfe_channel] = 0;
             }
-            s->chahtinu[s->lfe_channel] = s->lfeahtinu;
         }
 #endif
     }else{
@@ -429,6 +429,9 @@ int ff_eac3_parse_audfrm(GetBitContext *
     /* These fields for audio frame transient pre-noise processing data */
     if(s->transproce)
     {
+        av_log(s->avctx, AV_LOG_ERROR, "transient pre-noise processing NOT IMPLEMENTED\n");
+        return -1;
+#if 0
         for(ch = 1; ch <= s->nfchans; ch++)
         {
             GET_BITS(s->chintransproc[ch], gbc, 1);
@@ -438,6 +441,7 @@ int ff_eac3_parse_audfrm(GetBitContext *
                 GET_BITS(s->transproclen[ch], gbc, 8);
             }
         }
+#endif
     }
     /* These fields for spectral extension attenuation data */
     if(s->spxattene)
@@ -484,7 +488,7 @@ int ff_eac3_parse_audfrm(GetBitContext *
 
 int ff_eac3_parse_audblk(GetBitContext *gbc, EAC3Context *s, const int blk){
     //int grp, sbnd, n, bin;
-    int seg, bnd, ch, i;
+    int seg, bnd, ch, i, chbwcod, grpsize;
     int got_cplchan;
     mant_groups m;
 
@@ -924,29 +928,24 @@ int ff_eac3_parse_audblk(GetBitContext *
         }
         if(s->chexpstr[blk][ch] != EXP_REUSE)
         {
-            if((!s->chincpl[ch]) && (!s->chinspx[ch])) {
-                GET_BITS(s->chbwcod[ch], gbc, 6);
-              if(s->chbwcod[ch] > 60){
-                  av_log(s->avctx, AV_LOG_ERROR, "s->chbwcod[ch] > 60\n");
-                  return -1;
-              }
+            grpsize = 3 << (s->chexpstr[blk][ch] - 1);
+            if(s->chincpl[ch]){
+                s->endmant[ch] = s->strtmant[CPL_CH]; /* channel is coupled */
+            }else if(s->chinspx[ch]){
+                //TODO endmant for Spectral extension
+            }else{
+                GET_BITS(chbwcod, gbc, 6);
+                if(chbwcod > 60){
+                    av_log(s->avctx, AV_LOG_ERROR, "chbwcod > 60\n");
+                    return -1;
+                }
+                s->endmant[ch] = ((chbwcod + 12) * 3) + 37; /* (ch is not coupled) */
             }
+            grpsize = 3 << (s->chexpstr[blk][ch] - 1);
+            s->nchgrps[ch] = (s->endmant[ch] + grpsize - 4) / grpsize;
         }
     }
 
-    // calc
-    for(ch = 1; ch<=s->nfchans; ch++){
-        int grpsize = 3 << (s->chexpstr[blk][ch] - 1);
-
-        s->strtmant[ch] = 0;
-        if(s->chincpl[ch])
-            s->endmant[ch] = s->strtmant[CPL_CH]; /* channel is coupled */
-        else
-            s->endmant[ch] = ((s->chbwcod[ch] + 12) * 3) + 37; /* (ch is not coupled) */
-
-        s->nchgrps[ch] = (s->endmant[ch] + grpsize - 4) / grpsize;
-    }
-
     /* These fields for exponents */
     if(s->cplinu[blk]) /* exponents for the coupling channel */
     {
@@ -1042,13 +1041,13 @@ int ff_eac3_parse_audblk(GetBitContext *
 
     if(s->frmfgaincode && get_bits1(gbc)) {
         for(ch = !s->cplinu[blk]; ch <= s->nfchans+s->lfeon; ch++)
-            GET_BITS(s->fgaincod[ch], gbc, 3);
+            s->fgain[ch] = ff_fgaintab[get_bits(gbc, 3)];
     }
     else
     {
         if(!blk){
             for(ch = !s->cplinu[blk]; ch <= s->nfchans+s->lfeon; ch++)
-                s->fgaincod[ch] = 0x4;
+                s->fgain[ch] = ff_fgaintab[0x4];
         }
     }
     if(s->strmtyp == 0x0)
@@ -1150,9 +1149,8 @@ int ff_eac3_parse_audblk(GetBitContext *
         s->bit_alloc_params.halfratecod = 0;
 
         {
-            int fgain = ff_fgaintab[s->fgaincod[ch]];
             ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params,
-                    s->bndpsd[ch], start, end, fgain,
+                    s->bndpsd[ch], start, end, s->fgain[ch],
                     (ch == s->lfe_channel),
                     s->deltbae[ch], s->deltnseg[ch],
                     s->deltoffst[ch], s->deltlen[ch],
@@ -1184,34 +1182,11 @@ int ff_eac3_parse_audblk(GetBitContext *
 
     for(ch = 1; ch <= s->nfchans; ch++)
     {
-        if(s->chahtinu[ch] == 0)
-        {
-            ff_ac3_get_transform_coeffs_ch(&m, gbc, s->dexps[ch], s->bap[ch], s->transform_coeffs[ch], s->strtmant[ch], s->endmant[ch], &s->dith_state);
-            //memset(s->transform_coeffs[ch], 0, (256)*sizeof(float));
-        }
-        else if(s->chahtinu[ch] == 1)
-        {
-            get_transform_coeffs_aht_ch(gbc, s, ch);
-            s->chahtinu[ch] = -1; /* AHT info for this frame has been read ? do not read again */
-        }
-        if(s->chahtinu[ch] != 0){
-            dct_transform_coeffs_ch(s, ch, blk);
-        }
+        get_eac3_transform_coeffs_ch(gbc, s, blk, ch, &m);
         if(s->cplinu[blk] && s->chincpl[ch] && !got_cplchan)
         {
-            if(s->cplahtinu == 0)
-            {
-                ff_ac3_get_transform_coeffs_ch(&m, gbc, s->dexps[CPL_CH], s->bap[CPL_CH], s->transform_coeffs[CPL_CH], s->strtmant[CPL_CH], s->endmant[CPL_CH], &s->dith_state);
-            }
-            else if(s->cplahtinu == 1)
-            {
-                get_transform_coeffs_aht_ch(gbc, s, CPL_CH);
-                s->cplahtinu = -1; /* AHT info for this frame has been read ? do not read again */
-            }
+            get_eac3_transform_coeffs_ch(gbc, s, blk, CPL_CH, &m);
             got_cplchan = 1;
-            if(s->cplahtinu != 0){
-                dct_transform_coeffs_ch(s, CPL_CH, blk);
-            }
         }
 
     }
@@ -1256,20 +1231,8 @@ int ff_eac3_parse_audblk(GetBitContext *
         spectral_extension(s);
 
     if(s->lfeon) /* mantissas of low frequency effects channel */
-    {
-        if(s->lfeahtinu == 0)
-        {
-            ff_ac3_get_transform_coeffs_ch(&m, gbc, s->dexps[s->lfe_channel], s->bap[s->lfe_channel], s->transform_coeffs[s->lfe_channel], s->strtmant[s->lfe_channel], s->endmant[s->lfe_channel], &s->dith_state);
-        }
-        else if(s->lfeahtinu == 1)
-        {
-            get_transform_coeffs_aht_ch(gbc, s, s->lfe_channel);
-            s->lfeahtinu = -1;
-        }
-        if(s->chahtinu[s->lfe_channel] != 0){
-            dct_transform_coeffs_ch(s, s->lfe_channel, blk);
-        }
-    }
+        get_eac3_transform_coeffs_ch(gbc, s, blk, s->lfe_channel, &m);
+
     return 0;
 }
 
@@ -1397,6 +1360,8 @@ void spectral_extension(EAC3Context *s){
 
 
 void get_transform_coeffs_aht_ch(GetBitContext *gbc, EAC3Context *s, int ch){
+    //Now turned off, because there are no samples for testing it.
+#if 0
     int endbap, bin, n, m;
     int bg, g, bits, pre_chmant, remap;
     float mant;
@@ -1524,6 +1489,7 @@ void get_transform_coeffs_aht_ch(GetBitC
             }
         }
     }
+#endif
 }
 
 void dct_transform_coeffs_ch(EAC3Context *s, int ch, int blk){
@@ -1538,3 +1504,18 @@ void dct_transform_coeffs_ch(EAC3Context
         s->transform_coeffs[ch][bin] = tmp;
     }
 }
+
+void get_eac3_transform_coeffs_ch(GetBitContext *gbc, EAC3Context *s, int blk,
+        int ch, mant_groups *m){
+    if(s->chahtinu[ch] == 0){
+        ff_ac3_get_transform_coeffs_ch(m, gbc, s->dexps[ch], s->bap[ch],
+                s->transform_coeffs[ch], s->strtmant[ch], s->endmant[ch],
+                &s->dith_state);
+    }else if(s->chahtinu[ch] == 1){
+        get_transform_coeffs_aht_ch(gbc, s, ch);
+        s->chahtinu[ch] = -1; /* AHT info for this frame has been read - do not read again */
+    }
+    if(s->chahtinu[ch] != 0){
+        dct_transform_coeffs_ch(s, ch, blk);
+    }
+}



More information about the FFmpeg-soc mailing list