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

jbr subversion at mplayerhq.hu
Sun Dec 30 17:42:30 CET 2007


Author: jbr
Date: Sun Dec 30 17:42:30 2007
New Revision: 1708

Log:
share function to remove dithering 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	Sun Dec 30 17:42:30 2007
@@ -205,6 +205,8 @@ void ff_ac3_tables_init(void)
 static int ac3_decode_init(AVCodecContext *avctx)
 {
     AC3DecodeContext *ctx = avctx->priv_data;
+
+    memset(ctx, 0, sizeof(*ctx));
     ctx->avctx = avctx;
 
     ac3_common_init();
@@ -460,28 +462,34 @@ int ff_ac3_get_transform_coeffs_ch(mant_
  * Remove random dithering from coefficients with zero-bit mantissas
  * reference: Section 7.3.4 Dither for Zero Bit Mantissas (bap=0)
  */
-static void remove_dithering(AC3DecodeContext *ctx) {
+void ff_ac3_remove_dithering(AC3DecodeContext *s) {
     int ch, i;
     int end=0;
     float *coeffs;
     uint8_t *bap;
+    uint8_t *hebap;
+    int aht;
 
-    for(ch=1; ch<=ctx->fbw_channels; ch++) {
-        if(!ctx->dither_flag[ch]) {
-            coeffs = ctx->transform_coeffs[ch];
-            bap = ctx->bap[ch];
-            if(ctx->channel_in_cpl[ch])
-                end = ctx->start_freq[CPL_CH];
+    for(ch=1; ch<=s->fbw_channels; ch++) {
+        if(!s->dither_flag[ch]) {
+            coeffs = s->transform_coeffs[ch];
+            bap = s->bap[ch];
+            hebap = s->hebap[ch];
+            aht = s->channel_uses_aht[ch];
+            if(s->channel_in_cpl[ch])
+                end = s->start_freq[CPL_CH];
             else
-                end = ctx->end_freq[ch];
+                end = s->end_freq[ch];
             for(i=0; i<end; i++) {
-                if(bap[i] == 0)
+                if(aht ? !hebap[i] : !bap[i])
                     coeffs[i] = 0.0f;
             }
-            if(ctx->channel_in_cpl[ch]) {
-                bap = ctx->bap[CPL_CH];
-                for(; i<ctx->end_freq[CPL_CH]; i++) {
-                    if(bap[i] == 0)
+            if(s->channel_in_cpl[ch]) {
+                bap = s->bap[CPL_CH];
+                hebap = s->hebap[CPL_CH];
+                aht = s->channel_uses_aht[CPL_CH];
+                for(; i<s->end_freq[CPL_CH]; i++) {
+                    if(aht ? !hebap[i] : !bap[i])
                         coeffs[i] = 0.0f;
                 }
             }
@@ -536,7 +544,7 @@ static int get_transform_coeffs(AC3Decod
 
     /* if any channel doesn't use dithering, zero appropriate coefficients */
     if(!ctx->dither_all)
-        remove_dithering(ctx);
+        ff_ac3_remove_dithering(ctx);
 
     return 0;
 }

Modified: eac3/ac3dec.h
==============================================================================
--- eac3/ac3dec.h	(original)
+++ eac3/ac3dec.h	Sun Dec 30 17:42:30 2007
@@ -253,6 +253,8 @@ void ff_ac3_uncouple_channels(int fbw_ch
             float transform_coeffs[AC3_MAX_CHANNELS][256],
             float cpl_coords[AC3_MAX_CHANNELS][18]);
 
+void ff_ac3_remove_dithering(AC3DecodeContext *s);
+
 void ff_ac3_do_rematrixing(float (*transform_coeffs)[256], int end, int nrematbnd, int *rematflg);
 
 void ff_ac3_do_imdct_256(float *tmp_output, float *transform_coeffs,

Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c	(original)
+++ eac3/eac3dec.c	Sun Dec 30 17:42:30 2007
@@ -293,42 +293,6 @@ static void get_eac3_transform_coeffs_ch
            s->end_freq[ch] * sizeof(*s->transform_coeffs[ch]));
 }
 
-static void remove_dithering(AC3DecodeContext *s) {
-    /* TODO: merge with same function in ac3dec.c */
-    int ch, i;
-    int end=0;
-    float *coeffs;
-    uint8_t *bap;
-    uint8_t *hebap;
-    int aht;
-
-    for(ch=1; ch<=s->fbw_channels; ch++) {
-        if(!s->dither_flag[ch]) {
-            coeffs = s->transform_coeffs[ch];
-            bap = s->bap[ch];
-            hebap = s->hebap[ch];
-            aht = s->channel_uses_aht[ch];
-            if(s->channel_in_cpl[ch])
-                end = s->start_freq[CPL_CH];
-            else
-                end = s->end_freq[ch];
-            for(i=0; i<end; i++) {
-                if(aht ? !hebap[i] : !bap[i])
-                    coeffs[i] = 0.0f;
-            }
-            if(s->channel_in_cpl[ch]) {
-                bap = s->bap[CPL_CH];
-                hebap = s->hebap[CPL_CH];
-                aht = s->channel_uses_aht[CPL_CH];
-                for(; i<s->end_freq[CPL_CH]; i++) {
-                    if(aht ? !hebap[i] : !bap[i])
-                        coeffs[i] = 0.0f;
-                }
-            }
-        }
-    }
-}
-
 static int parse_bsi(AC3DecodeContext *s){
     int i, blk;
     GetBitContext *gbc = &s->gbc;
@@ -1197,7 +1161,7 @@ static int parse_audblk(AC3DecodeContext
     }
 
     if(!s->dither_all)
-        remove_dithering(s);
+        ff_ac3_remove_dithering(s);
 
 #if 0
     //apply spectral extension



More information about the FFmpeg-soc mailing list