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

bwolowiec subversion at mplayerhq.hu
Sun Aug 19 07:12:14 CEST 2007


Author: bwolowiec
Date: Sun Aug 19 07:12:14 2007
New Revision: 1010

Log:
removing code duplication


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

Modified: eac3/ac3dec.c
==============================================================================
--- eac3/ac3dec.c	(original)
+++ eac3/ac3dec.c	Sun Aug 19 07:12:14 2007
@@ -651,41 +651,41 @@ void ff_ac3_do_rematrixing(float (*trans
 /**
  * Perform the 256-point IMDCT
  */
-static void do_imdct_256(AC3DecodeContext *ctx, int chindex)
+void ff_ac3_do_imdct_256(float *tmp_output, float *transform_coeffs,
+        MDCTContext *imdct_256, float *tmp_imdct)
 {
     int i, k;
     DECLARE_ALIGNED_16(float, x[128]);
     FFTComplex z[2][64];
-    float *o_ptr = ctx->tmp_output;
 
     for(i=0; i<2; i++) {
         /* de-interleave coefficients */
         for(k=0; k<128; k++) {
-            x[k] = ctx->transform_coeffs[chindex][2*k+i];
+            x[k] = transform_coeffs[2*k+i];
         }
 
         /* run standard IMDCT */
-        ctx->imdct_256.fft.imdct_calc(&ctx->imdct_256, o_ptr, x, ctx->tmp_imdct);
+        imdct_256->fft.imdct_calc(imdct_256, tmp_output, x, tmp_imdct);
 
         /* reverse the post-rotation & reordering from standard IMDCT */
         for(k=0; k<32; k++) {
-            z[i][32+k].re = -o_ptr[128+2*k];
-            z[i][32+k].im = -o_ptr[2*k];
-            z[i][31-k].re =  o_ptr[2*k+1];
-            z[i][31-k].im =  o_ptr[128+2*k+1];
+            z[i][32+k].re = -tmp_output[128+2*k];
+            z[i][32+k].im = -tmp_output[2*k];
+            z[i][31-k].re =  tmp_output[2*k+1];
+            z[i][31-k].im =  tmp_output[128+2*k+1];
         }
     }
 
     /* apply AC-3 post-rotation & reordering */
     for(k=0; k<64; k++) {
-        o_ptr[    2*k  ] = -z[0][   k].im;
-        o_ptr[    2*k+1] =  z[0][63-k].re;
-        o_ptr[128+2*k  ] = -z[0][   k].re;
-        o_ptr[128+2*k+1] =  z[0][63-k].im;
-        o_ptr[256+2*k  ] = -z[1][   k].re;
-        o_ptr[256+2*k+1] =  z[1][63-k].im;
-        o_ptr[384+2*k  ] =  z[1][   k].im;
-        o_ptr[384+2*k+1] = -z[1][63-k].re;
+        tmp_output[    2*k  ] = -z[0][   k].im;
+        tmp_output[    2*k+1] =  z[0][63-k].re;
+        tmp_output[128+2*k  ] = -z[0][   k].re;
+        tmp_output[128+2*k+1] =  z[0][63-k].im;
+        tmp_output[256+2*k  ] = -z[1][   k].re;
+        tmp_output[256+2*k+1] =  z[1][63-k].im;
+        tmp_output[384+2*k  ] =  z[1][   k].im;
+        tmp_output[384+2*k+1] = -z[1][63-k].re;
     }
 }
 
@@ -706,7 +706,8 @@ static inline void do_imdct(AC3DecodeCon
 
     for (ch=1; ch<=nchans; ch++) {
         if (ctx->blksw[ch]) {
-            do_imdct_256(ctx, ch);
+            ff_ac3_do_imdct_256(ctx->tmp_output, ctx->transform_coeffs[ch],
+                    &ctx->imdct_256, ctx->tmp_imdct);
         } else {
             ctx->imdct_512.fft.imdct_calc(&ctx->imdct_512, ctx->tmp_output,
                                           ctx->transform_coeffs[ch],

Modified: eac3/ac3dec.h
==============================================================================
--- eac3/ac3dec.h	(original)
+++ eac3/ac3dec.h	Sun Aug 19 07:12:14 2007
@@ -82,6 +82,9 @@ int ff_ac3_get_transform_coeffs_ch(mant_
 
 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,
+        MDCTContext *imdct_256, float *tmp_imdct);
+
 /** Adjustments in dB gain */
 #define LEVEL_MINUS_3DB         0.7071067811865476
 #define LEVEL_MINUS_4POINT5DB   0.5946035575013605

Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c	(original)
+++ eac3/eac3dec.c	Sun Aug 19 07:12:14 2007
@@ -1273,56 +1273,18 @@ static void get_eac3_transform_coeffs_ch
     }
 }
 
-static void do_imdct_256(EAC3Context *ctx, int ch)
-{
-    int k;
-    float x[128];
-    FFTComplex z[2][64];
-    float *o_ptr = ctx->tmp_output;
-    int i;
-
-    for(i=0; i<2; i++) {
-        /* de-interleave coefficients */
-        for(k=0; k<128; k++) {
-            x[k] = ctx->transform_coeffs[ch][2*k+i];
-        }
-
-        /* run standard IMDCT */
-        ctx->imdct_256.fft.imdct_calc(&ctx->imdct_256, o_ptr, x, ctx->tmp_imdct);
-
-        /* reverse the post-rotation & reordering from standard IMDCT */
-        for(k=0; k<32; k++) {
-            z[i][32+k].re = -o_ptr[128+2*k];
-            z[i][32+k].im = -o_ptr[2*k];
-            z[i][31-k].re =  o_ptr[2*k+1];
-            z[i][31-k].im =  o_ptr[128+2*k+1];
-        }
-    }
-
-    /* apply AC-3 post-rotation & reordering */
-    for(k=0; k<64; k++) {
-        o_ptr[    2*k  ] = -z[0][   k].im;
-        o_ptr[    2*k+1] =  z[0][63-k].re;
-        o_ptr[128+2*k  ] = -z[0][   k].re;
-        o_ptr[128+2*k+1] =  z[0][63-k].im;
-        o_ptr[256+2*k  ] = -z[1][   k].re;
-        o_ptr[256+2*k+1] =  z[1][63-k].im;
-        o_ptr[384+2*k  ] =  z[1][   k].im;
-        o_ptr[384+2*k+1] = -z[1][63-k].re;
-    }
-}
-
 /**
  * Performs Inverse MDCT transform
  */
-void ff_eac3_do_imdct(EAC3Context *ctx)
+static void do_imdct(EAC3Context *ctx)
 {
     int ch;
 
     for(ch=1; ch<=ctx->nfchans+ctx->lfeon; ch++) {
         if(ctx->blksw[ch]) {
             /* 256-point IMDCT */
-            do_imdct_256(ctx, ch);
+            ff_ac3_do_imdct_256(ctx->tmp_output, ctx->transform_coeffs[ch],
+                    &ctx->imdct_256, ctx->tmp_imdct);
         } else {
             /* 512-point IMDCT */
             ctx->imdct_512.fft.imdct_calc(&ctx->imdct_512, ctx->tmp_output,
@@ -1411,7 +1373,7 @@ static int eac3_decode_frame(AVCodecCont
             }
         }
 
-        ff_eac3_do_imdct(c);
+        do_imdct(c);
         //TODO downmix
 
 #ifdef DEBUG



More information about the FFmpeg-soc mailing list