[FFmpeg-soc] [soc]: r4475 - in aacenc: aaccoder.c aacenc.h

alexc subversion at mplayerhq.hu
Thu Jun 18 06:15:40 CEST 2009


Author: alexc
Date: Thu Jun 18 06:15:40 2009
New Revision: 4475

Log:
Split quantize_bands into abs_pow34_v (which exponentiates a vector of
coefficients) and quantize_bands (which now just quantizes and clips).

Modified:
   aacenc/aaccoder.c
   aacenc/aacenc.h

Modified: aacenc/aaccoder.c
==============================================================================
--- aacenc/aaccoder.c	Thu Jun 18 06:15:00 2009	(r4474)
+++ aacenc/aaccoder.c	Thu Jun 18 06:15:40 2009	(r4475)
@@ -64,12 +64,12 @@ static av_always_inline int quant(float 
     return pow(coef * Q, 0.75) + 0.4054;
 }
 
-static void quantize_bands(int (*out)[2], const float* in, int size, float Q, int is_signed, int maxval)
+static void quantize_bands(int (*out)[2], const float *in, const float *scaled, int size, float Q34, int is_signed, int maxval)
 {
     int i;
     double qc;
     for (i = 0; i < size; i++) {
-        qc = pow(fabsf(in[i]) * Q, 0.75);
+        qc = scaled[i] * Q34;
         out[i][0] = (int)FFMIN((int)qc, maxval);
         out[i][1] = (int)FFMIN((int)(qc + 0.4054), maxval);
         if (is_signed && in[i] < 0.0f) {
@@ -79,6 +79,14 @@ static void quantize_bands(int (*out)[2]
     }
 }
 
+static void abs_pow34_v(float *out, const float* in, const int size)
+{
+    int i;
+    for (i = 0; i < size; i++) {
+        out[i] = pow(fabsf(in[i]), 0.75);
+    }
+}
+
 static av_always_inline int quant2(float coef, const float Q)
 {
     return pow(coef * Q, 0.75);
@@ -103,9 +111,11 @@ static float quantize_band_cost(struct A
     const int dim = cb < FIRST_PAIR_BT ? 4 : 2;
     int resbits = 0;
 #ifndef USE_REALLY_FULL_SEARCH
+    const float  Q34 = pow(Q, 0.75);
     const int range = aac_cb_range[cb];
     const int maxval = aac_cb_maxval[cb];
     int offs[4];
+    float *scaled = s->scoefs;
 #endif /* USE_REALLY_FULL_SEARCH */
 
     if(!cb){
@@ -117,7 +127,8 @@ static float quantize_band_cost(struct A
     offs[0] = 1;
     for(i = 1; i < dim; i++)
         offs[i] = offs[i-1]*range;
-    quantize_bands(s->qcoefs, in, size, Q, !IS_CODEBOOK_UNSIGNED(cb), maxval);
+    abs_pow34_v(scaled, in, size);
+    quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
 #endif /* USE_REALLY_FULL_SEARCH */
     for(i = 0; i < size; i += dim){
         float mincost;
@@ -215,9 +226,11 @@ static void quantize_and_encode_band(str
     const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2;
     int i, j, k;
 #ifndef USE_REALLY_FULL_SEARCH
+    const float  Q34 = pow(Q, 0.75);
     const int range = aac_cb_range[cb];
     const int maxval = aac_cb_maxval[cb];
     int offs[4];
+    float *scaled = s->scoefs;
 #endif /* USE_REALLY_FULL_SEARCH */
 
 //START_TIMER
@@ -228,7 +241,8 @@ static void quantize_and_encode_band(str
     offs[0] = 1;
     for(i = 1; i < dim; i++)
         offs[i] = offs[i-1]*range;
-    quantize_bands(s->qcoefs, in, size, Q, !IS_CODEBOOK_UNSIGNED(cb), maxval);
+    abs_pow34_v(scaled, in, size);
+    quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
 #endif /* USE_REALLY_FULL_SEARCH */
     for(i = 0; i < size; i += dim){
         float mincost;

Modified: aacenc/aacenc.h
==============================================================================
--- aacenc/aacenc.h	Thu Jun 18 06:15:00 2009	(r4474)
+++ aacenc/aacenc.h	Thu Jun 18 06:15:40 2009	(r4475)
@@ -65,6 +65,7 @@ typedef struct AACEncContext {
     int last_frame;
     float lambda;
     DECLARE_ALIGNED_16(int,   qcoefs[96][2]);    ///< quantized coefficients
+    DECLARE_ALIGNED_16(float, scoefs[1024]);     ///< scaled coefficients
 } AACEncContext;
 
 #endif /* AVCODEC_AACENC_H */


More information about the FFmpeg-soc mailing list