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

bwolowiec subversion at mplayerhq.hu
Fri Jul 13 15:36:31 CEST 2007


Author: bwolowiec
Date: Fri Jul 13 15:36:31 2007
New Revision: 393

Log:
Added dialogue normalization and dynamic range gain support


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

Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h	(original)
+++ eac3/eac3.h	Fri Jul 13 15:36:31 2007
@@ -85,10 +85,9 @@ typedef struct EAC3Context{
     int acmod; // 3);                ///< Audio coding mode
     int lfeon; // 1);                ///< Low frequency effect channel on
     int bsid; // 5);                 ///< Bit stream identification
-    int dialnorm; // 5);             ///<Dialogue normalization
+    int dialnorm[2]; // 5);          ///< Dialogue normalization
     int compre; // 1);               ///< Compression gain word exists
     int compr; // 8);                ///< Compression gain word
-    int dialnorm2; // 5);            ///< Dialog normalization ch2
     int compr2e; // 1);              ///< Compression gain word ch2 exists
     int compr2; // 8);               ///< Compression gain word ch2
     int chanmape; // 1);             ///< Custom channel map exists
@@ -180,10 +179,8 @@ typedef struct EAC3Context{
 // EAC3Audblk
     int blksw[MAX_CHANNELS]; // 1);  ///< Block switch flag
     int dithflag[MAX_CHANNELS];      ///< Dither flag
-    int dynrnge; // 1);              ///< Dynamic range gain word exists
-    int dynrng; // 8);               ///< Dynamic range gain word
-    int dynrng2e; // 1);             ///< Dynamic range gain word exists, ch2
-    int dynrng2; // 8);              ///< Dynamic range gain word
+    int dynrnge[2]; // 1);           ///< Dynamic range gain word exists
+    int dynrng[2]; // 8);            ///< Dynamic range gain word
     int spxstre; // 1);              ///< Spectral extension strategy exists
     int spxinu; // 1);               ///< spectral extension in use
     int chinspx[MAX_CHANNELS];       ///< Channel in spectral extension

Modified: eac3/eac3_parser.c
==============================================================================
--- eac3/eac3_parser.c	(original)
+++ eac3/eac3_parser.c	Fri Jul 13 15:36:31 2007
@@ -81,14 +81,14 @@ int ff_eac3_parse_bsi(GetBitContext *gbc
         return -1;
     }
 
-    GET_BITS(s->dialnorm, gbc, 5);
+    GET_BITS(s->dialnorm[0], gbc, 5);
     GET_BITS(s->compre, gbc, 1);
     if(s->compre) {
         GET_BITS(s->compr, gbc, 8);
     }
     if(s->acmod == 0x0) /* if 1+1 mode (dual mono, so some items need a second value) */
     {
-        GET_BITS(s->dialnorm2, gbc, 5);
+        GET_BITS(s->dialnorm[1], gbc, 5);
         GET_BITS(s->compr2e, gbc, 1);
         if(s->compr2e) {
             GET_BITS(s->compr2, gbc, 8);
@@ -484,15 +484,15 @@ int ff_eac3_parse_audblk(GetBitContext *
         }
     }
     /* These fields for dynamic range control */
-    GET_BITS(s->dynrnge, gbc, 1);
-    if(s->dynrnge) {
-        GET_BITS(s->dynrng, gbc, 8);
-    }
-    if(s->acmod == 0x0) /* if 1+1 mode */
-    {
-        GET_BITS(s->dynrng2e, gbc, 1);
-        if(s->dynrng2e) {
-            GET_BITS(s->dynrng2, gbc, 8);
+
+    for(i = 0; i < (s->acmod?1:2); i++){
+        GET_BITS(s->dynrnge[i], gbc, 1);
+        if(s->dynrnge[i]){
+            GET_BITS(s->dynrng[i], gbc, 8);
+        }else{
+            if(blk==0){
+                s->dynrng[i] = 0;
+            }
         }
     }
     /* These fields for spectral extension strategy information */

Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c	(original)
+++ eac3/eac3dec.c	Fri Jul 13 15:36:31 2007
@@ -138,7 +138,19 @@ static int eac3_decode_frame(AVCodecCont
 #endif
         //TODO rematrixing
         //TODO downmix_scaling...
-        //TODO scale
+
+        /* apply scaling to coefficients (dialnorm, dynrng) */
+        for(ch=1; ch<=c->nfchans + c->lfeon; ch++) {
+            float gain=2.0f;
+            if(c->acmod == AC3_CHANNEL_MODE_DUALMONO) {
+                gain *= ff_ac3_dialnorm_tbl[c->dialnorm[ch-1]] * ff_ac3_dynrng_tbl[c->dynrng[ch-1]];
+            } else {
+                gain *= ff_ac3_dialnorm_tbl[c->dialnorm[0]] * ff_ac3_dynrng_tbl[c->dynrng[0]];
+            }
+            for(i=0; i<c->endmant[ch]; i++) {
+                c->transform_coeffs[ch][i] *= gain;
+            }
+        }
 
         ff_eac3_do_imdct(c);
         //TODO downmix



More information about the FFmpeg-soc mailing list