[FFmpeg-soc] [soc]: r794 - in eac3: ac3.c ac3.h ac3dec.c eac3.h eac3_parser.c eac3dec.c

bwolowiec subversion at mplayerhq.hu
Tue Aug 14 22:36:32 CEST 2007


Author: bwolowiec
Date: Tue Aug 14 22:36:32 2007
New Revision: 794

Log:
change of code which reads snroffst, calculating hebap


Modified:
   eac3/ac3.c
   eac3/ac3.h
   eac3/ac3dec.c
   eac3/eac3.h
   eac3/eac3_parser.c
   eac3/eac3dec.c

Modified: eac3/ac3.c
==============================================================================
--- eac3/ac3.c	(original)
+++ eac3/ac3.c	Tue Aug 14 22:36:32 2007
@@ -173,7 +173,7 @@ 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, uint8_t *bap)
+                               int snroffset, int floor, const uint8_t *baptab, uint8_t *bap)
 {
     int i, j, k, end1, v, address;
 
@@ -190,7 +190,7 @@ void ff_ac3_bit_alloc_calc_bap(int16_t *
         end1 = FFMIN(bndtab[j] + ff_ac3_bndsz[j], end);
         for (k = i; k < end1; k++) {
             address = av_clip((psd[i] - v) >> 5, 0, 63);
-            bap[i] = ff_ac3_baptab[address];
+            bap[i] = baptab[address];
             i++;
         }
     } while (end > bndtab[j++]);
@@ -215,7 +215,7 @@ void ac3_parametric_bit_allocation(AC3Bi
                                deltbae, deltnseg, deltoffst, deltlen, deltba,
                                mask);
 
-    ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snroffset, s->floor, bap);
+    ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snroffset, s->floor, ff_ac3_baptab, bap);
 }
 
 /**

Modified: eac3/ac3.h
==============================================================================
--- eac3/ac3.h	(original)
+++ eac3/ac3.h	Tue Aug 14 22:36:32 2007
@@ -165,10 +165,11 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAl
  * @param[in]  end        ending bin location
  * @param[in]  snroffset  SNR adjustment
  * @param[in]  floor      noise floor
+ * @param[in]  baptab     bit allocation pointer table
  * @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, uint8_t *bap);
+                               int snroffset, int floor, const uint8_t *baptab, uint8_t *bap);
 
 void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
                                    int8_t *exp, int start, int end,

Modified: eac3/ac3dec.c
==============================================================================
--- eac3/ac3dec.c	(original)
+++ eac3/ac3dec.c	Tue Aug 14 22:36:32 2007
@@ -1005,6 +1005,7 @@ static int ac3_parse_audio_block(AC3Deco
                                       ctx->startmant[ch], ctx->endmant[ch],
                                       ctx->snroffst[ch],
                                       ctx->bit_alloc_params.floor,
+                                      ff_ac3_baptab,
                                       ctx->bap[ch]);
         }
     }

Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h	(original)
+++ eac3/eac3.h	Tue Aug 14 22:36:32 2007
@@ -131,6 +131,7 @@ typedef struct EAC3Context{
     int expstre; // 1);              ///< Exponent strategy syntax enabled
     int ahte; // 1);                 ///< Adaptive hybrid transform enabled
     int snroffststr; // 2);          ///< SNR offset strategy
+    int snroffst[AC3_MAX_CHANNELS];  ///< SNR offset
     int transproce; // 1);           ///< Transient pre-noise processing enabled
     int blkswe; // 1);               ///< Block switch syntax enabled
     int dithflage; // 1);            ///< Dither flag syntax enabled
@@ -142,13 +143,10 @@ typedef struct EAC3Context{
     int cplinu[MAX_BLOCKS]; // 1);   ///< Coupling in use
     int cplstre[MAX_BLOCKS]; // 1);  ///< Coupling strategy exists
     int chexpstr[MAX_BLOCKS][MAX_CHANNELS]; // 2); ///< Channel exponent strategy
-    int frmchexpstr[MAX_CHANNELS];   ///< frame based channel exponent strategy
     int convexpstr[MAX_CHANNELS];    ///< Converter channel exponent strategy
     int cplahtinu; // 1);            ///< Coupling channel AHT in use
     int chahtinu[MAX_CHANNELS];      ///< Channel AHT in use
     int lfeahtinu; // 1);            ///< Lfe channel AHT in use
-    int frmcsnroffst; // 6);         ///< Frame coarse SNR offset
-    int frmfsnroffst; // 4);         ///< Frame fine SNR offset
     int chintransproc[MAX_CHANNELS]; ///< Channel in transient pre-noise processing
     int transprocloc[MAX_CHANNELS];  ///< Transient location relative to start of frame
     int transproclen[MAX_CHANNELS];  ///< Transient processing length
@@ -208,12 +206,6 @@ typedef struct EAC3Context{
     int sgaincod; // 2);             ///< Slow gain code
     int dbpbcod; // 2);              ///< dB per bit code
     int floorcod; // 3);             ///< Masking floor code
-    int snroffste; // 1);            ///< SNR offset exists
-    int csnroffst; // 6);            ///< Coarse SNR offset
-    int blkfsnroffst; // 4);         ///< Block fine SNR offset
-    int cplfsnroffst; // 4);         ///< Coupling fine SNR offset
-    int fsnroffst[MAX_CHANNELS];     ///< Channel fine SNR offset
-    int fgaincode; // 1);            ///< Channel fast gain code enabled
     int fgaincod[MAX_CHANNELS];      ///< Channel fast gain code
     int convsnroffste; // 1);        ///< Converter SNR offset exists
     int convsnroffst; // 10);        ///< Converter SNR offset

Modified: eac3/eac3_parser.c
==============================================================================
--- eac3/eac3_parser.c	(original)
+++ eac3/eac3_parser.c	Tue Aug 14 22:36:32 2007
@@ -314,23 +314,24 @@ int ff_eac3_parse_audfrm(GetBitContext *
         for(blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++)
         {
             for(ch = !s->cplinu[blk]; ch <= s->nfchans; ch++) {
-                GET_BITS(s->chexpstr[blk][ch], gbc, 2); // TODO
+                GET_BITS(s->chexpstr[blk][ch], gbc, 2);
             }
         }
     }
     else
     {
+        int frmchexpstr;
         /* cplexpstr[blk] and chexpstr[blk][ch] derived from table lookups. see Table E2.14 */
         if( (s->acmod > 0x1) && (s->ncplblks > 0) ) {
-            GET_BITS(s->frmchexpstr[CPL_CH], gbc, 5);
+            GET_BITS(frmchexpstr, gbc, 5);
             for(blk=0; blk<6; blk++){
-                s->chexpstr[blk][CPL_CH] = ff_eac3_frm_expstr[s->frmchexpstr[0]][blk];
+                s->chexpstr[blk][CPL_CH] = ff_eac3_frm_expstr[frmchexpstr][blk];
             }
         }
         for(ch = 1; ch <= s->nfchans; ch++) {
-            GET_BITS(s->frmchexpstr[ch], gbc, 5);
+            GET_BITS(frmchexpstr, gbc, 5);
             for(blk=0; blk<6; blk++){
-                s->chexpstr[blk][ch] = ff_eac3_frm_expstr[s->frmchexpstr[ch]][blk];
+                s->chexpstr[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk];
             }
         }
     }
@@ -413,12 +414,17 @@ int ff_eac3_parse_audfrm(GetBitContext *
             s->chahtinu[s->lfe_channel] = s->lfeahtinu;
         }
 #endif
+    }else{
+        for(ch=!s->cplinu; ch<=s->nfchans+s->lfeon; ch++)
+            s->chahtinu[ch] = 0;
     }
     /* These fields for audio frame SNR offset data */
     if(s->snroffststr == 0x0)
     {
-        GET_BITS(s->frmcsnroffst, gbc, 6);
-        GET_BITS(s->frmfsnroffst, gbc, 4);
+        int csnroffst = (get_bits(gbc, 6) - 15) << 4;
+        int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
+        for(ch=!s->cplinu[blk]; ch<= s->nfchans+s->lfeon; ch++)
+            s->snroffst[ch] = snroffst;
     }
     /* These fields for audio frame transient pre-noise processing data */
     if(s->transproce)
@@ -538,7 +544,7 @@ int ff_eac3_parse_audblk(GetBitContext *
         GET_BITS(s->spxinu, gbc, 1);
         if(s->spxinu)
         {
-//            av_log(s->avctx, AV_LOG_INFO, "Spectral extension in use\n");
+            av_log(s->avctx, AV_LOG_INFO, "Spectral extension in use\n");
             if(s->acmod == 0x1)
             {
                 s->chinspx[1] = 1;
@@ -980,7 +986,6 @@ int ff_eac3_parse_audblk(GetBitContext *
             ff_ac3_decode_exponents(gbc, s->chexpstr[blk][ch], s->nchgrps[ch], s->dexps[ch][0],
                     s->dexps[ch] + 1);
 
-
             GET_BITS(s->gainrng[ch], gbc, 2);
         }
     }
@@ -988,10 +993,9 @@ int ff_eac3_parse_audblk(GetBitContext *
     {
         if(s->chexpstr[blk][s->lfe_channel] != EXP_REUSE)
         {
-            ch = s->lfe_channel;
-            GET_BITS(s->dexps[ch][0], gbc, 4);
-            ff_ac3_decode_exponents(gbc, s->chexpstr[blk][s->lfe_channel], s->nchgrps[s->lfe_channel], s->dexps[ch][0],
-                    s->dexps[ch] + 1);
+            GET_BITS(s->dexps[s->lfe_channel][0], gbc, 4);
+            ff_ac3_decode_exponents(gbc, s->chexpstr[blk][s->lfe_channel], s->nchgrps[s->lfe_channel],
+                    s->dexps[s->lfe_channel][0], s->dexps[s->lfe_channel] + 1);
         }
     }
     /* These fields for bit-allocation parametric information */
@@ -1020,64 +1024,23 @@ int ff_eac3_parse_audblk(GetBitContext *
         s->bit_alloc_params.floor = ff_floortab[0x7];     /* Table 7.10 */
     }
 
-    if(s->snroffststr == 0x0)
-    {
-        if(s->cplinu[blk]) {
-            s->cplfsnroffst = s->frmfsnroffst;
-        }
-        s->csnroffst = s->frmcsnroffst;
-        for(ch = 1; ch <= s->nfchans; ch++) {
-            s->fsnroffst[ch] = s->frmfsnroffst;
-        }
-        if(s->lfeon) {
-            s->fsnroffst[s->lfe_channel] = s->frmfsnroffst;
-        }
-    }
-    else
-    {
-        av_log(s->avctx, AV_LOG_INFO, "NOT TESTED");
-        if(blk == 0) {
-            s->snroffste = 1;
-        }
-        else {
-            GET_BITS(s->snroffste, gbc, 1);
-        }
-        if(s->snroffste)
-        {
-            GET_BITS(s->csnroffst, gbc, 6);
-            if(s->snroffststr == 0x1)
-            {
-                GET_BITS(s->blkfsnroffst, gbc, 4);
-                s->cplfsnroffst = s->blkfsnroffst;
-                for(ch = 1; ch <= s->nfchans; ch++) {
-                    s->fsnroffst[ch] = s->blkfsnroffst;
-                }
-                s->fsnroffst[s->lfe_channel] = s->blkfsnroffst;
+    if(s->snroffststr != 0x0){
+        av_log(s->avctx, AV_LOG_INFO, "NOT TESTED\n");
+        if(!blk || get_bits1(gbc) ){
+            int csnroffst = (get_bits(gbc, 6) - 15) << 4;
+            if(s->snroffststr == 0x1){
+                int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
+                for(ch=!s->cplinu[blk]; ch<= s->nfchans+s->lfeon; ch++)
+                    s->snroffst[ch] = snroffst;
             }
-            else if(s->snroffststr == 0x2)
-            {
-                if(s->cplinu[blk]) {
-                    GET_BITS(s->cplfsnroffst, gbc, 4);
-                }
-                for(ch = 1; ch <= s->nfchans; ch++) {
-                    GET_BITS(s->fsnroffst[ch], gbc, 4);
-                }
-                if(s->lfeon) {
-                    GET_BITS(s->fsnroffst[s->lfe_channel], gbc, 4);
-                }
+            else if(s->snroffststr == 0x2){
+                for(ch=!s->cplinu[blk]; ch<= s->nfchans+s->lfeon; ch++)
+                    s->snroffst[ch] = (csnroffst + get_bits(gbc, 4)) << 2;
             }
         }
     }
-    s->fsnroffst[CPL_CH] = s->cplfsnroffst;
 
-    if(s->frmfgaincode) {
-        GET_BITS(s->fgaincode, gbc, 1);
-    }
-    else {
-        s->fgaincode = 0;
-    }
-    if(s->fgaincode)
-    {
+    if(s->frmfgaincode && get_bits1(gbc)) {
         for(ch = !s->cplinu[blk]; ch <= s->nfchans+s->lfeon; ch++)
             GET_BITS(s->fgaincod[ch], gbc, 3);
     }
@@ -1173,11 +1136,6 @@ int ff_eac3_parse_audblk(GetBitContext *
     }
 
     /* run bit allocation */
-    /*if(s->cplinu[blk]) {
-        av_log(s->avctx, AV_LOG_ERROR,  "NOT IMPLEMENTED (cplinu && run bit allocation)");
-        return -1;
-    }*/
-
     for(ch = !s->cplinu[blk]; ch<=s->nfchans+s->lfeon; ch++) {
 
         int start=0, end=0;
@@ -1202,14 +1160,14 @@ int ff_eac3_parse_audblk(GetBitContext *
         }
 
         {
-            int snroffst = (((s->csnroffst - 15) << 4) + s->fsnroffst[ch]) << 2;
-            //av_log(s->avctx, AV_LOG_INFO, "s->csnroffst=%i s->fsnroffst=%i snroffst = %i\n",
-             //       s->csnroffst, s->fsnroffst[ch], snroffst);
-
-            // TODO calculate hebap
-            ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], start, end,
-                    snroffst, s->bit_alloc_params.floor,
-                    s->bap[ch]);
+            if(s->chahtinu[ch]==0)
+                ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], start, end,
+                        s->snroffst[ch], s->bit_alloc_params.floor, ff_ac3_baptab,
+                        s->bap[ch]);
+            else if(s->chahtinu[ch]==1)
+                ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], start, end,
+                        s->snroffst[ch], s->bit_alloc_params.floor, ff_ac3_hebaptab,
+                        s->hebap[ch]);
         }
 
 
@@ -1219,7 +1177,6 @@ int ff_eac3_parse_audblk(GetBitContext *
     /* These fields for quantized mantissa values */
 
     got_cplchan = 0;
-//    ff_ac3_get_transform_coeffs(gbc, s->bap, s->dexps, s->nfchans+s->lfeon, s->chincpl, s->dithflag, s->transform_coeffs, s->strtmant, s->endmant, &s->dith_state, s->ncplbnd, s->cplbndstrc, s->cplco);
 
     // TODO only for debug
     for(ch=0; ch<=s->nfchans+s->lfeon; ch++)

Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c	(original)
+++ eac3/eac3dec.c	Tue Aug 14 22:36:32 2007
@@ -98,7 +98,6 @@ static int eac3_decode_frame(AVCodecCont
 
     c->gbc = &gbc;
     c->syncword = 0;
-    c->csnroffst  = -1;
 
     init_get_bits(&gbc, buf, buf_size*8);
     ff_eac3_parse_syncinfo(&gbc, c);



More information about the FFmpeg-soc mailing list