[FFmpeg-soc] [soc]: r1582 - in eac3: ac3dec.c ac3dec.h eac3dec.c

jbr subversion at mplayerhq.hu
Sat Dec 15 04:01:54 CET 2007


Author: jbr
Date: Sat Dec 15 04:01:53 2007
New Revision: 1582

Log:
share downmixing tables between ac3 and eac3 decoders

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

Modified: eac3/ac3dec.c
==============================================================================
--- eac3/ac3dec.c	(original)
+++ eac3/ac3dec.c	Sat Dec 15 04:01:53 2007
@@ -70,12 +70,15 @@ float ff_ac3_dynamic_range_tab[256];
 /** dialog normalization table */
 float ff_ac3_dialog_norm_tab[32];
 
-static const float gain_levels[6] = {
-    LEVEL_ZERO,
+const float ff_ac3_mix_levels[9] = {
+    LEVEL_PLUS_3DB,
+    LEVEL_PLUS_1POINT5DB,
     LEVEL_ONE,
+    LEVEL_MINUS_1POINT5DB,
     LEVEL_MINUS_3DB,
     LEVEL_MINUS_4POINT5DB,
     LEVEL_MINUS_6DB,
+    LEVEL_ZERO,
     LEVEL_MINUS_9DB
 };
 
@@ -83,27 +86,27 @@ static const float gain_levels[6] = {
  * Table for center mix levels
  * reference: Section 5.4.2.4 cmixlev
  */
-static const uint8_t center_levels[4] = { 2, 3, 4, 3 };
+static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
 
 /**
  * Table for surround mix levels
  * reference: Section 5.4.2.5 surmixlev
  */
-static const uint8_t surround_levels[4] = { 2, 4, 0, 4 };
+static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
 
 /**
  * Table for default stereo downmixing coefficients
  * reference: Section 7.8.2 Downmixing Into Two Channels
  */
-static const uint8_t ac3_default_coeffs[8][5][2] = {
-    { { 1, 0 }, { 0, 1 },                               },
-    { { 2, 2 },                                         },
-    { { 1, 0 }, { 0, 1 },                               },
-    { { 1, 0 }, { 3, 3 }, { 0, 1 },                     },
-    { { 1, 0 }, { 0, 1 }, { 4, 4 },                     },
-    { { 1, 0 }, { 3, 3 }, { 0, 1 }, { 5, 5 },           },
-    { { 1, 0 }, { 0, 1 }, { 4, 0 }, { 0, 4 },           },
-    { { 1, 0 }, { 3, 3 }, { 0, 1 }, { 4, 0 }, { 0, 4 }, },
+const uint8_t ff_ac3_default_coeffs[8][5][2] = {
+    { { 2, 7 }, { 7, 2 },                               },
+    { { 4, 4 },                                         },
+    { { 2, 7 }, { 7, 2 },                               },
+    { { 2, 7 }, { 5, 5 }, { 7, 2 },                     },
+    { { 2, 7 }, { 7, 2 }, { 6, 6 },                     },
+    { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 },           },
+    { { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 },           },
+    { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
 };
 
 /* override ac3.h to include coupling channel */
@@ -331,8 +334,8 @@ static int ac3_parse_header(AC3DecodeCon
     /* get decoding parameters from header info */
     ctx->bit_alloc_params.sr_code     = hdr.sr_code;
     ctx->channel_mode                 = hdr.channel_mode;
-    center_mix_level                  = gain_levels[center_levels[hdr.center_mix_level]];
-    surround_mix_level                = gain_levels[surround_levels[hdr.surround_mix_level]];
+    center_mix_level                  = ff_ac3_mix_levels[center_levels[hdr.center_mix_level]];
+    surround_mix_level                = ff_ac3_mix_levels[surround_levels[hdr.surround_mix_level]];
     ctx->dolby_surround_mode          = hdr.dolby_surround_mode;
     ctx->lfe_on                        = hdr.lfe_on;
     ctx->bit_alloc_params.sr_shift    = hdr.sr_shift;
@@ -396,8 +399,8 @@ static int ac3_parse_header(AC3DecodeCon
     /* set stereo downmixing coefficients
        reference: Section 7.8.2 Downmixing Into Two Channels */
     for(i=0; i<ctx->fbw_channels; i++) {
-        ctx->downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[ctx->channel_mode][i][0]];
-        ctx->downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[ctx->channel_mode][i][1]];
+        ctx->downmix_coeffs[i][0] = ff_ac3_mix_levels[ff_ac3_default_coeffs[ctx->channel_mode][i][0]];
+        ctx->downmix_coeffs[i][1] = ff_ac3_mix_levels[ff_ac3_default_coeffs[ctx->channel_mode][i][1]];
     }
     if(ctx->channel_mode > 1 && ctx->channel_mode & 1) {
         ctx->downmix_coeffs[1][0] = ctx->downmix_coeffs[1][1] = center_mix_level;

Modified: eac3/ac3dec.h
==============================================================================
--- eac3/ac3dec.h	(original)
+++ eac3/ac3dec.h	Sat Dec 15 04:01:53 2007
@@ -48,6 +48,12 @@ extern float ff_ac3_dialog_norm_tab[32];
  */
 extern float ff_ac3_scale_factors[25];
 
+/** channel mix levels */
+extern const float ff_ac3_mix_levels[9];
+
+/** default stereo downmixing coefficients */
+extern const uint8_t ff_ac3_default_coeffs[8][5][2];
+
 /**
  * Decode the grouped exponents according to exponent strategy.
  * reference: Section 7.1.3 Exponent Decoding

Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c	(original)
+++ eac3/eac3dec.c	Sat Dec 15 04:01:53 2007
@@ -24,33 +24,6 @@
 #include "ac3dec.h"
 #include "ac3.h"
 
-/**
- * Table for default stereo downmixing coefficients
- * reference: Section 7.8.2 Downmixing Into Two Channels
- */
-static const uint8_t eac3_default_coeffs[8][5][2] = {
-    { { 2, 7 }, { 7, 2 },                               },
-    { { 4, 4 },                                         },
-    { { 2, 7 }, { 7, 2 },                               },
-    { { 2, 7 }, { 5, 5 }, { 7, 2 },                     },
-    { { 2, 7 }, { 7, 2 }, { 6, 6 },                     },
-    { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 },           },
-    { { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 },           },
-    { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
-};
-
-static const float mixlevels[9] = {
-    LEVEL_PLUS_3DB,
-    LEVEL_PLUS_1POINT5DB,
-    LEVEL_ONE,
-    LEVEL_MINUS_1POINT5DB,
-    LEVEL_MINUS_3DB,
-    LEVEL_MINUS_4POINT5DB,
-    LEVEL_MINUS_6DB,
-    LEVEL_ZERO,
-    LEVEL_MINUS_9DB
-};
-
 static float idct_cos_tab[6][5];
 
 static void log_missing_feature(AVCodecContext *avctx, const char *log){
@@ -401,8 +374,8 @@ static int parse_bsi(GetBitContext *gbc,
     /* set stereo downmixing coefficients
        reference: Section 7.8.2 Downmixing Into Two Channels */
     for (i = 0; i < s->nfchans; i++) {
-        s->downmix_coeffs[i][0] = mixlevels[eac3_default_coeffs[s->channel_mode][i][0]];
-        s->downmix_coeffs[i][1] = mixlevels[eac3_default_coeffs[s->channel_mode][i][1]];
+        s->downmix_coeffs[i][0] = ff_ac3_mix_levels[ff_ac3_default_coeffs[s->channel_mode][i][0]];
+        s->downmix_coeffs[i][1] = ff_ac3_mix_levels[ff_ac3_default_coeffs[s->channel_mode][i][1]];
     }
 
     if (get_bits1(gbc)) {
@@ -414,13 +387,13 @@ static int parse_bsi(GetBitContext *gbc,
             if (s->channel_mode & 1) {
                 /* if three front channels exist */
                 skip_bits(gbc, 3); //skip Lt/Rt center mix level
-                s->downmix_coeffs[1][0] = s->downmix_coeffs[1][1] = mixlevels[get_bits(gbc, 3)];
+                s->downmix_coeffs[1][0] = s->downmix_coeffs[1][1] = ff_ac3_mix_levels[get_bits(gbc, 3)];
             }
             if (s->channel_mode & 4) {
                 /* if a surround channel exists */
                 float surmixlev;
                 skip_bits(gbc, 3); //skip Lt/Rt surround mix level
-                surmixlev = mixlevels[get_bits(gbc, 3)];
+                surmixlev = ff_ac3_mix_levels[get_bits(gbc, 3)];
                 if (s->channel_mode & 2) {
                     //two surround channels
                     s->downmix_coeffs[s->channel_mode-4][0] = s->downmix_coeffs[s->channel_mode-3][1] =



More information about the FFmpeg-soc mailing list