[FFmpeg-soc] [soc]: r3308 - aacenc/aacpsy.c

kostya subversion at mplayerhq.hu
Fri Aug 15 09:31:56 CEST 2008


Author: kostya
Date: Fri Aug 15 09:31:55 2008
New Revision: 3308

Log:
Move quantizer selection out of the loop

Modified:
   aacenc/aacpsy.c

Modified: aacenc/aacpsy.c
==============================================================================
--- aacenc/aacpsy.c	(original)
+++ aacenc/aacpsy.c	Fri Aug 15 09:31:55 2008
@@ -48,9 +48,10 @@
 static inline int quantize_coeffs(float *in, int *out, int size, int scale_idx)
 {
     int i, sign, sum = 0;
+    const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
     for(i = 0; i < size; i++){
         sign = in[i] > 0.0;
-        out[i] = (int)(pow(FFABS(in[i]) * ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512], 0.75) + 0.4054);
+        out[i] = (int)(pow(FFABS(in[i]) * Q, 0.75) + 0.4054);
         out[i] = av_clip(out[i], 0, 8191);
         sum += out[i];
         if(sign) out[i] = -out[i];
@@ -63,11 +64,13 @@ static inline float calc_distortion(floa
     int i;
     int q;
     float coef, unquant, sum = 0.0f;
+    const float Q  = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
+    const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
     for(i = 0; i < size; i++){
         coef = FFABS(c[i]);
-        q = (int)(pow(FFABS(coef) * ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512], 0.75) + 0.4054);
+        q = (int)(pow(FFABS(coef) * Q, 0.75) + 0.4054);
         q = av_clip(q, 0, 8191);
-        unquant = (q * cbrt(q)) * ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
+        unquant = (q * cbrt(q)) * IQ;
         sum += (coef - unquant) * (coef - unquant);
     }
     return sum;



More information about the FFmpeg-soc mailing list