Commit 58b3727f authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

exp() and log() are faster than pow() and log10() for dB conversion

parent c994394f
......@@ -71,14 +71,16 @@ static inline celt_word16_t amp2dB(celt_ener_t amp)
static inline celt_ener_t dB2Amp(celt_ener_t dB)
{
celt_ener_t amp;
amp = pow(10, .05*dB)-.3;
/*amp = pow(10, .05*dB)-.3;*/
amp = exp(0.115129f*dB)-.3f;
if (amp < 0)
amp = 0;
return amp;
}
static inline celt_word16_t amp2dB(celt_ener_t amp)
{
return 20*log10(.3+amp);
/*return 20*log10(.3+amp);*/
return 8.68589f*log(.3f+amp);
}
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment