History

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

Alex Converse committed 17 years ago

Commit 3d51be01 parent 4e67aed1 file · +8 −5Browse files

Showing the changes to libavcodec/aaccoder.c (1 of 1 file). Show all

Unified · Split

libavcodec/aaccoder.c+8−5
@@ -61,7 +61,8 @@ static const uint8_t *run_value_bits[2] = { · 60 unmodified lines
61 */61 */
62static av_always_inline int quant(float coef, const float Q)62static av_always_inline int quant(float coef, const float Q)
63{63{
64 return pow(coef * Q, 0.75) + 0.4054;64 float a = coef * Q;
65 return sqrtf(a * sqrtf(a)) + 0.4054;
65}66}
66 67
67static void quantize_bands(int (*out)[2], const float *in, const float *scaled,68static 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) · 16 unmodified lines
84{85{
85#ifndef USE_REALLY_FULL_SEARCH86#ifndef USE_REALLY_FULL_SEARCH
86 int i;87 int i;
87 for (i = 0; i < size; i++)88 for (i = 0; i < size; i++) {
88 out[i] = pow(fabsf(in[i]), 0.75);89 float a = fabsf(in[i]);
90 out[i] = sqrtf(a * sqrtf(a));
91 }
89#endif /* USE_REALLY_FULL_SEARCH */92#endif /* USE_REALLY_FULL_SEARCH */
90}93}
91 94
@@ -110,7 +113,7 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, · 18 unmodified lines
110 const int dim = cb < FIRST_PAIR_BT ? 4 : 2;113 const int dim = cb < FIRST_PAIR_BT ? 4 : 2;
111 int resbits = 0;114 int resbits = 0;
112#ifndef USE_REALLY_FULL_SEARCH115#ifndef USE_REALLY_FULL_SEARCH
113 const float Q34 = pow(Q, 0.75);116 const float Q34 = sqrtf(Q * sqrtf(Q));
114 const int range = aac_cb_range[cb];117 const int range = aac_cb_range[cb];
115 const int maxval = aac_cb_maxval[cb];118 const int maxval = aac_cb_maxval[cb];
116 int offs[4];119 int offs[4];
@@ -225,7 +228,7 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 108 unmodified lines
225 const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2;228 const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2;
226 int i, j, k;229 int i, j, k;
227#ifndef USE_REALLY_FULL_SEARCH230#ifndef USE_REALLY_FULL_SEARCH
228 const float Q34 = pow(Q, 0.75);231 const float Q34 = sqrtf(Q * sqrtf(Q));
229 const int range = aac_cb_range[cb];232 const int range = aac_cb_range[cb];
230 const int maxval = aac_cb_maxval[cb];233 const int maxval = aac_cb_maxval[cb];
231 int offs[4];234 int offs[4];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t