Commit f619a7be authored by Stefan Westerfeld's avatar Stefan Westerfeld

Optimize factor -> db conversions, this improves decoding speed.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent b0c51b6d
......@@ -224,12 +224,23 @@ window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
return 0.54 + 0.46 * cos (M_PI * x);
}
/*
* glibc log2f is a lot faster than glibc log10
*/
inline double
log10_approx (double l)
{
constexpr double log2_log10_factor = 0.3010299956639811952; // 1 / log2 (10)
return log2f (l) * log2_log10_factor;
}
double
db_from_factor (double factor, double min_dB)
{
if (factor > 0)
{
double dB = log10 (factor); /* Bell */
double dB = log10_approx (factor); /* Bell */
dB *= 20;
return dB;
}
......
Markdown is supported
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