diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2017-09-30 22:48:41 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2017-10-01 20:29:38 -0400 |
commit | b2a373eb642077fbf5f1bdbe74d1e82cc534f5f2 (patch) | |
tree | 9b86428b3357334b95d18729f1fb870dc3bb302f /apps | |
parent | 679ae2d21c17115c998b1ada6412463c3c7a1db9 (diff) | |
download | rockbox-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')
-rw-r--r-- | apps/plugins/fft/fft.c | 8 |
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) | |||
624 | } | 624 | } |
625 | else | 625 | else |
626 | { | 626 | { |
627 | d = isqrt(d); /* linear scaling, nothing | 627 | d = fp_sqrt(d, 0); /* linear scaling, nothing |
628 | bad should happen */ | 628 | bad should happen */ |
629 | d = fp16_log(d << 16); /* the log function | 629 | d = fp16_log(d << 16); /* the log function |
630 | expects s15.16 values */ | 630 | expects s15.16 values */ |
631 | } | 631 | } |
632 | } | 632 | } |
633 | else | 633 | else |
634 | { | 634 | { |
635 | d = isqrt(d); /* linear scaling, nothing | 635 | d = fp_sqrt(d, 0); /* linear scaling, nothing |
636 | bad should happen */ | 636 | bad should happen */ |
637 | } | 637 | } |
638 | } | 638 | } |
639 | 639 | ||