diff options
author | Bojan Zivkovic <bojan@mips.com> | 2013-03-06 14:55:03 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-07 03:23:33 +0100 |
commit | 1f5b5b8062706c20da0f8ca048917ae5f19107b2 (patch) | |
tree | e9af5cdbf1aef3743f8629c34af2debd31641e8c /libavcodec/aacpsy.c | |
parent | d95143ec82a026967e10a4521a5de78fb5cb2ec1 (diff) | |
download | ffmpeg-1f5b5b8062706c20da0f8ca048917ae5f19107b2.tar.gz |
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@mips.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/aacpsy.c')
-rw-r--r-- | libavcodec/aacpsy.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index d77b3de4e4..e399be545d 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]; } |