diff options
author | Alex Converse <alex.converse@gmail.com> | 2009-07-17 14:21:49 +0000 |
---|---|---|
committer | Alex Converse <alex.converse@gmail.com> | 2009-07-17 14:21:49 +0000 |
commit | 3d51be014c4e50b88985d3e6998438f15bdfc4a1 (patch) | |
tree | 1dfa4dddae685429d7b7b1f3c88670f51446cce6 /libavcodec | |
parent | 4e67aedd6abdb9a84ee54a3c5fe8b54c0d949621 (diff) | |
download | ffmpeg-3d51be014c4e50b88985d3e6998438f15bdfc4a1.tar.gz |
Replace pow(x, 0.75) with sqrtf(x * sqrtf(x)) for a 33% speedup.
Originally committed as revision 19459 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/aaccoder.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 41f7c208a8..3b6ec96876 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -61,7 +61,8 @@ static const uint8_t *run_value_bits[2] = { */ 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 @@ static void abs_pow34_v(float *out, const float *in, const int size) { #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 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, 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 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, 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]; |