summaryrefslogtreecommitdiffstats
path: root/apps/plugins/fft
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-09-30 22:48:41 -0400
committerMichael Sevakis <jethead71@rockbox.org>2017-10-01 20:29:38 -0400
commitb2a373eb642077fbf5f1bdbe74d1e82cc534f5f2 (patch)
tree9b86428b3357334b95d18729f1fb870dc3bb302f /apps/plugins/fft
parent679ae2d21c17115c998b1ada6412463c3c7a1db9 (diff)
downloadrockbox-b2a373eb642077fbf5f1bdbe74d1e82cc534f5f2.tar.gz
rockbox-b2a373eb642077fbf5f1bdbe74d1e82cc534f5f2.zip
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
Diffstat (limited to 'apps/plugins/fft')
-rw-r--r--apps/plugins/fft/fft.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c
index 40c251de15..3e88722b23 100644
--- a/apps/plugins/fft/fft.c
+++ b/apps/plugins/fft/fft.c
@@ -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 */
}
}