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

Unified · Split

libavcodec/aaccoder.c+8−5
@@ -61,7 +61,8 @@ static const uint8_t *run_value_bits[2] = { · 60 unmodified lines
6161 */
6262 static av_always_inline int quant(float coef, const float Q)
6363 {
64− return pow(coef * Q, 0.75) + 0.4054;
64+ float a = coef * Q;
65+ return sqrtf(a * sqrtf(a)) + 0.4054;
6566 }
6667
6768 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) · 16 unmodified lines
8485 {
8586 #ifndef USE_REALLY_FULL_SEARCH
8687 int i;
87− for (i = 0; i < size; i++)
88− out[i] = pow(fabsf(in[i]), 0.75);
88+ for (i = 0; i < size; i++) {
89+ float a = fabsf(in[i]);
90+ out[i] = sqrtf(a * sqrtf(a));
91+ }
8992 #endif /* USE_REALLY_FULL_SEARCH */
9093 }
9194
@@ -110,7 +113,7 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, · 18 unmodified lines
110113 const int dim = cb < FIRST_PAIR_BT ? 4 : 2;
111114 int resbits = 0;
112115 #ifndef USE_REALLY_FULL_SEARCH
113− const float Q34 = pow(Q, 0.75);
116+ const float Q34 = sqrtf(Q * sqrtf(Q));
114117 const int range = aac_cb_range[cb];
115118 const int maxval = aac_cb_maxval[cb];
116119 int offs[4];
@@ -225,7 +228,7 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 108 unmodified lines
225228 const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2;
226229 int i, j, k;
227230 #ifndef USE_REALLY_FULL_SEARCH
228− const float Q34 = pow(Q, 0.75);
231+ const float Q34 = sqrtf(Q * sqrtf(Q));
229232 const int range = aac_cb_range[cb];
230233 const int maxval = aac_cb_maxval[cb];
231234 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