diff options
| author | Thom Johansen <thomj@rockbox.org> | 2007-02-05 01:01:15 +0000 |
|---|---|---|
| committer | Thom Johansen <thomj@rockbox.org> | 2007-02-05 01:01:15 +0000 |
| commit | 5f48e1590f16049aaaf916ad72d6016a4e7ffa5c (patch) | |
| tree | 4438397a1a44cf301f0f4675388f92ee1e8ddb38 /apps/plugins/lib | |
| parent | 7170a00daad917993d3fed460f1122f543d2b0ea (diff) | |
| download | rockbox-5f48e1590f16049aaaf916ad72d6016a4e7ffa5c.zip rockbox-5f48e1590f16049aaaf916ad72d6016a4e7ffa5c.tar.gz rockbox-5f48e1590f16049aaaf916ad72d6016a4e7ffa5c.tar.bz2 rockbox-5f48e1590f16049aaaf916ad72d6016a4e7ffa5c.tar.xz | |
Optimise EQ coef calculation routines for both speed and size. Move now unneeded fsqrt function to plugin fixed point library in case it'll be needed. Move all fixed point helper macros to dsp.h. Added FRACMUL_SHL macro to facilitate high-precision shifting of 64 bit multiplies and remove rounding from macsr in main thread to make this work as intended.
Tested quite thorougly, but as always, be careful with your ears.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12203 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
| -rw-r--r-- | apps/plugins/lib/fixedpoint.c | 19 | ||||
| -rw-r--r-- | apps/plugins/lib/fixedpoint.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/apps/plugins/lib/fixedpoint.c b/apps/plugins/lib/fixedpoint.c index 914bc8c..9c34c2a 100644 --- a/apps/plugins/lib/fixedpoint.c +++ b/apps/plugins/lib/fixedpoint.c @@ -117,3 +117,22 @@ long fsincos(unsigned long phase, long *cos) return y; } + +/** + * Fixed point square root via Newton-Raphson. + * @param a square root argument. + * @param fracbits specifies number of fractional bits in argument. + * @return Square root of argument in same fixed point format as input. + */ +long fsqrt(long a, unsigned int fracbits) +{ + long b = a/2 + (1 << fracbits); /* initial approximation */ + unsigned n; + const unsigned iterations = 4; + + for (n = 0; n < iterations; ++n) + b = (b + DIV64(a, b, fracbits))/2; + + return b; +} + diff --git a/apps/plugins/lib/fixedpoint.h b/apps/plugins/lib/fixedpoint.h index 065f9fb..ff773cb 100644 --- a/apps/plugins/lib/fixedpoint.h +++ b/apps/plugins/lib/fixedpoint.h @@ -20,3 +20,5 @@ ****************************************************************************/ long fsincos(unsigned long phase, long *cos); +long fsqrt(long a, unsigned int fracbits); + |