exp() and log() are faster than pow() and log10() for dB conversion
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Sat, 30 Aug 2008 18:53:44 +0000 (14:53 -0400)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Sat, 30 Aug 2008 18:53:44 +0000 (14:53 -0400)
libcelt/quant_bands.c

index 967163d..4a7e493 100644 (file)
@@ -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