I am working with some audio dsp code that is using floating point numbers, ranging from 1.0e-8 to 1000. I want to convert this value to a dB value, which will be an integer value from -160 to 60. The usual formula is:
result = log10(value) * 20
I currently do this with some code that looks like this:
where x6 = a constant value of 6. This works, but it seems that the fyl2x instruction eats up a ton of cycles. I've got to do this a LOT in the code, and it needs to be very fast. I'm not opposed to large lookup tables, if that's what it takes.
How can I improve on this? The result only needs to be integer values - no fractional amounts are needed. Code will be run on Pentium 4 and higher CPUs only.