Mercurial > libavcodec.hg
comparison ra288.c @ 7925:9dc65bb3bd3f libavcodec
Do instead of divising a float by a constant, multiply by its inverse
author | vitor |
---|---|
date | Thu, 25 Sep 2008 20:03:57 +0000 |
parents | 518c86ed8008 |
children | 5b81784c5fe6 |
comparison
equal
deleted
inserted
replaced
7924:926c3a5dcdd3 | 7925:9dc65bb3bd3f |
---|---|
94 /* block 47 of G.728 spec */ | 94 /* block 47 of G.728 spec */ |
95 sum = av_clipf(sum, 0, 60); | 95 sum = av_clipf(sum, 0, 60); |
96 | 96 |
97 /* block 48 of G.728 spec */ | 97 /* block 48 of G.728 spec */ |
98 /* exp(sum * 0.1151292546497) == pow(10.0,sum/20) */ | 98 /* exp(sum * 0.1151292546497) == pow(10.0,sum/20) */ |
99 sumsum = exp(sum * 0.1151292546497) * gain / (2048 * 4096); | 99 sumsum = exp(sum * 0.1151292546497) * gain * (1.0/(1<<23)); |
100 | 100 |
101 for (i=0; i < 5; i++) | 101 for (i=0; i < 5; i++) |
102 buffer[i] = codetable[cb_coef][i] * sumsum; | 102 buffer[i] = codetable[cb_coef][i] * sumsum; |
103 | 103 |
104 sum = (4096 * 4096) * scalar_product_float(buffer, buffer, 5) / 5; | 104 sum = scalar_product_float(buffer, buffer, 5) * ((1<<24)/5.); |
105 | 105 |
106 sum = FFMAX(sum, 1); | 106 sum = FFMAX(sum, 1); |
107 | 107 |
108 /* shift and store */ | 108 /* shift and store */ |
109 memmove(gain_block, gain_block + 1, 9 * sizeof(*gain_block)); | 109 memmove(gain_block, gain_block + 1, 9 * sizeof(*gain_block)); |