changeset 5497:377e9152aa9b libavcodec

use array for dynamic range scaling factors
author jbr
date Sun, 05 Aug 2007 21:10:09 +0000
parents f966fc154841
children 9971ba9c30a3
files ac3dec.c
diffstat 1 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ac3dec.c	Sun Aug 05 20:03:37 2007 +0000
+++ b/ac3dec.c	Sun Aug 05 21:10:09 2007 +0000
@@ -163,8 +163,7 @@
 
     float    downmix_coeffs[AC3_MAX_CHANNELS][2];   ///< stereo downmix coefficients
     float    dialnorm[2];                       ///< dialogue normalization
-    float    dynrng;            //dynamic range gain
-    float    dynrng2;           //dynamic range gain for 1+1 mode
+    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
@@ -782,19 +781,15 @@
             ctx->dither_all = 0;
     }
 
-    if (get_bits1(gb)) { /* dynamic range */
-        ctx->dynrng = dynrng_tbl[get_bits(gb, 8)];
-    } else if(blk == 0) {
-        ctx->dynrng = 1.0;
-    }
-
-    if(acmod == AC3_ACMOD_DUALMONO) { /* dynamic range 1+1 mode */
+    /* dynamic range */
+    i = !(ctx->acmod);
+    do {
         if(get_bits1(gb)) {
-            ctx->dynrng2 = dynrng_tbl[get_bits(gb, 8)];
+            ctx->dynrng[i] = dynrng_tbl[get_bits(gb, 8)];
         } else if(blk == 0) {
-            ctx->dynrng2 = 1.0;
+            ctx->dynrng[i] = 1.0f;
         }
-    }
+    } while(i--);
 
     if (get_bits1(gb)) { /* coupling strategy */
         memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
@@ -1022,10 +1017,10 @@
     /* apply scaling to coefficients (headroom, dialnorm, dynrng) */
     for(ch=1; ch<=ctx->nchans; ch++) {
         float gain = 2.0f * ctx->mul_bias;
-        if(ctx->acmod == AC3_ACMOD_DUALMONO && ch == 2) {
-            gain *= ctx->dialnorm[ch-1] * ctx->dynrng2;
+        if(ctx->acmod == AC3_ACMOD_DUALMONO) {
+            gain *= ctx->dialnorm[ch-1] * ctx->dynrng[ch-1];
         } else {
-            gain *= ctx->dialnorm[0] * ctx->dynrng;
+            gain *= ctx->dialnorm[0] * ctx->dynrng[0];
         }
         for(i=0; i<ctx->endmant[ch]; i++) {
             ctx->transform_coeffs[ch][i] *= gain;