Replace fp_sqrt function with one that only uses shift, or and sub.

Simply extends the current isqrt() to be able to do fractional bits
and improves the initial estimate using clz(). iqrt() itself is
no more and is equivalent to fp_sqrt(x, 0). The original also had
a small bug where the guess comparision should have been >=, not >.

Uses no large integer math or division and is very accurate
(simply returns a truncated fraction).

Change-Id: I2ae26e6505df1770dc01e56220f7385369f90ae9
This commit is contained in:
Michael Sevakis 2017-09-30 22:48:41 -04:00
parent 679ae2d21c
commit b2a373eb64
3 changed files with 58 additions and 58 deletions

View file

@ -624,16 +624,16 @@ static unsigned calc_magnitudes(enum fft_amp_scale scale)
}
else
{
d = isqrt(d); /* linear scaling, nothing
bad should happen */
d = fp_sqrt(d, 0); /* linear scaling, nothing
bad should happen */
d = fp16_log(d << 16); /* the log function
expects s15.16 values */
}
}
else
{
d = isqrt(d); /* linear scaling, nothing
bad should happen */
d = fp_sqrt(d, 0); /* linear scaling, nothing
bad should happen */
}
}