Mercurial > libavcodec.hg
comparison aaccoder.c @ 9961:c0d721961a7f libavcodec
Replace pow(x, 0.75) with sqrtf(x * sqrtf(x)) for a 33% speedup.
| author | alexc |
|---|---|
| date | Fri, 17 Jul 2009 14:21:49 +0000 |
| parents | bd37369189de |
| children | 27339a7fee03 |
comparison
equal
deleted
inserted
replaced
| 9960:bd37369189de | 9961:c0d721961a7f |
|---|---|
| 59 * @return absolute value of the quantized coefficient | 59 * @return absolute value of the quantized coefficient |
| 60 * @see 3GPP TS26.403 5.6.2 "Scalefactor determination" | 60 * @see 3GPP TS26.403 5.6.2 "Scalefactor determination" |
| 61 */ | 61 */ |
| 62 static av_always_inline int quant(float coef, const float Q) | 62 static 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 |
| 67 static void quantize_bands(int (*out)[2], const float *in, const float *scaled, | 68 static void quantize_bands(int (*out)[2], const float *in, const float *scaled, |
| 68 int size, float Q34, int is_signed, int maxval) | 69 int size, float Q34, int is_signed, int maxval) |
| 69 { | 70 { |
| 82 | 83 |
| 83 static void abs_pow34_v(float *out, const float *in, const int size) | 84 static void abs_pow34_v(float *out, const float *in, const int size) |
| 84 { | 85 { |
| 85 #ifndef USE_REALLY_FULL_SEARCH | 86 #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 |
| 92 static const uint8_t aac_cb_range [12] = {0, 3, 3, 3, 3, 9, 9, 8, 8, 13, 13, 17}; | 95 static const uint8_t aac_cb_range [12] = {0, 3, 3, 3, 3, 9, 9, 8, 8, 13, 13, 17}; |
| 93 static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16}; | 96 static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16}; |
| 108 int i, j, k; | 111 int i, j, k; |
| 109 float cost = 0; | 112 float cost = 0; |
| 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_SEARCH | 115 #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]; |
| 117 #endif /* USE_REALLY_FULL_SEARCH */ | 120 #endif /* USE_REALLY_FULL_SEARCH */ |
| 118 | 121 |
| 223 const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; | 226 const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; |
| 224 const float CLIPPED_ESCAPE = 165140.0f*IQ; | 227 const float CLIPPED_ESCAPE = 165140.0f*IQ; |
| 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_SEARCH | 230 #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]; |
| 232 float *scaled = s->scoefs; | 235 float *scaled = s->scoefs; |
| 233 #endif /* USE_REALLY_FULL_SEARCH */ | 236 #endif /* USE_REALLY_FULL_SEARCH */ |
