[FFmpeg-cvslog] libavcodec: changed mathematical functions in aacpsy.c

Bojan Zivkovic git at videolan.org
Thu Mar 7 03:24:19 CET 2013


ffmpeg | branch: master | Bojan Zivkovic <bojan at mips.com> | Wed Mar  6 14:55:03 2013 +0100| [1f5b5b8062706c20da0f8ca048917ae5f19107b2] | committer: Michael Niedermayer

libavcodec: changed mathematical functions in aacpsy.c

This patch changes existing mathematical functions with faster
ones. Speeds up encoding more than 10%. Tested on x86 and
MIPS platforms.

Signed-off-by: Bojan Zivkovic <bojan at mips.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f5b5b8062706c20da0f8ca048917ae5f19107b2
---

 libavcodec/aacpsy.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index d77b3de..e399be5 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -541,8 +541,10 @@ static float calc_reduced_thr_3gpp(AacPsyBand *band, float min_snr,
     float thr = band->thr;
 
     if (band->energy > thr) {
-        thr = powf(thr, 0.25f) + reduction;
-        thr = powf(thr, 4.0f);
+        thr = sqrtf(thr);
+        thr = sqrtf(thr) + reduction;
+        thr *= thr;
+        thr *= thr;
 
         /* This deviates from the 3GPP spec to match the reference encoder.
          * It performs min(thr_reduced, max(thr, energy/min_snr)) only for bands
@@ -582,13 +584,15 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
             AacPsyBand *band = &pch->band[w+g];
 
             float form_factor = 0.0f;
+            float Temp;
             band->energy = 0.0f;
             for (i = 0; i < band_sizes[g]; i++) {
                 band->energy += coefs[start+i] * coefs[start+i];
                 form_factor  += sqrtf(fabs(coefs[start+i]));
             }
+            Temp = band->energy > 0 ? sqrtf((float)band_sizes[g] / band->energy) : 0;
             band->thr      = band->energy * 0.001258925f;
-            band->nz_lines = band->energy>0 ? form_factor / powf(band->energy / band_sizes[g], 0.25f) : 0;
+            band->nz_lines = form_factor * sqrtf(Temp);
 
             start += band_sizes[g];
         }



More information about the ffmpeg-cvslog mailing list