changeset 9961:c0d721961a7f libavcodec

Replace pow(x, 0.75) with sqrtf(x * sqrtf(x)) for a 33% speedup.
author alexc
date Fri, 17 Jul 2009 14:21:49 +0000
parents bd37369189de
children 8a16d8418f64
files aaccoder.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/aaccoder.c	Fri Jul 17 14:06:53 2009 +0000
+++ b/aaccoder.c	Fri Jul 17 14:21:49 2009 +0000
@@ -61,7 +61,8 @@
  */
 static av_always_inline int quant(float coef, const float Q)
 {
-    return pow(coef * Q, 0.75) + 0.4054;
+    float a = coef * Q;
+    return sqrtf(a * sqrtf(a)) + 0.4054;
 }
 
 static void quantize_bands(int (*out)[2], const float *in, const float *scaled,
@@ -84,8 +85,10 @@
 {
 #ifndef USE_REALLY_FULL_SEARCH
     int i;
-    for (i = 0; i < size; i++)
-        out[i] = pow(fabsf(in[i]), 0.75);
+    for (i = 0; i < size; i++) {
+        float a = fabsf(in[i]);
+        out[i] = sqrtf(a * sqrtf(a));
+    }
 #endif /* USE_REALLY_FULL_SEARCH */
 }
 
@@ -110,7 +113,7 @@
     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 float  Q34 = sqrtf(Q * sqrtf(Q));
     const int range  = aac_cb_range[cb];
     const int maxval = aac_cb_maxval[cb];
     int offs[4];
@@ -225,7 +228,7 @@
     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 float  Q34 = sqrtf(Q * sqrtf(Q));
     const int range  = aac_cb_range[cb];
     const int maxval = aac_cb_maxval[cb];
     int offs[4];