diff options
author | Thom Johansen <thomj@rockbox.org> | 2007-10-19 12:27:38 +0000 |
---|---|---|
committer | Thom Johansen <thomj@rockbox.org> | 2007-10-19 12:27:38 +0000 |
commit | 877ea486bad40bde6f8b969acc8af50f244884c0 (patch) | |
tree | a287e4a5348275592b331d65b466a9e241c02fd1 /apps | |
parent | d332601135f75dd4a06c1bc8347f0155dc2867f1 (diff) |
Move multiply routines into the header. Give Coldfire a fixmul32b(). Remove some tabs and empty lines.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15205 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/libwma/wmafixed.c | 54 | ||||
-rw-r--r-- | apps/codecs/libwma/wmafixed.h | 69 |
2 files changed, 46 insertions, 77 deletions
diff --git a/apps/codecs/libwma/wmafixed.c b/apps/codecs/libwma/wmafixed.c index b53a1da607..9c3b211f59 100644 --- a/apps/codecs/libwma/wmafixed.c +++ b/apps/codecs/libwma/wmafixed.c @@ -43,56 +43,8 @@ fixed64 Fixed32To64(fixed32 x) return (fixed64)x; } - -/* - Fixed precision multiply code. - -*/ - -/*Sign-15.16 format */ -#ifdef CPU_ARM -/* these are defines in wmafixed.h*/ -#elif defined(CPU_COLDFIRE) - -#else - -fixed32 fixmul32(fixed32 x, fixed32 y) -{ - fixed64 temp; - temp = x; - temp *= y; - - temp >>= PRECISION; - - return (fixed32)temp; -} - -#endif -/* - Special fixmul32 that does a 16.16 x 1.31 multiply that returns a 16.16 value. - this is needed because the fft constants are all normalized to be less then 1 - and can't fit into a 16 bit number without excessive rounding - - -*/ -#ifndef CPU_ARM -fixed32 fixmul32b(fixed32 x, fixed32 y) -{ - fixed64 temp; - - temp = x; - temp *= y; - - temp >>= 31; //16+31-16 = 31 bits - - return (fixed32)temp; -} -#endif - - - /* - Not performance senstitive code here + Not performance senstitive code here */ @@ -204,7 +156,7 @@ static const unsigned long atan_table[] = { /* - Below here functions do not use standard fixed precision! + Below here functions do not use standard fixed precision! */ @@ -270,7 +222,7 @@ long fsincos(unsigned long phase, fixed32 *cos) /* - Old trig functions. Still used in 1 place each. + Old trig functions. Still used in 1 place each. */ diff --git a/apps/codecs/libwma/wmafixed.h b/apps/codecs/libwma/wmafixed.h index 32386dc9bd..b92c12a50a 100644 --- a/apps/codecs/libwma/wmafixed.h +++ b/apps/codecs/libwma/wmafixed.h @@ -1,9 +1,9 @@ -/* fixed precision code. We use a combination of Sign 15.16 and Sign.31 - precision here. +/* fixed precision code. We use a combination of Sign 15.16 and Sign.31 + precision here. - The WMA decoder does not always follow this convention, and occasionally - renormalizes values to other formats in order to maximize precision. - However, only the two precisions above are provided in this file. + The WMA decoder does not always follow this convention, and occasionally + renormalizes values to other formats in order to maximize precision. + However, only the two precisions above are provided in this file. */ @@ -35,17 +35,8 @@ fixed32 fixsin32(fixed32 x); fixed32 fixcos32(fixed32 x); long fsincos(unsigned long phase, fixed32 *cos); - - - - #ifdef CPU_ARM -/* - Fixed precision multiply code ASM. - -*/ - /*Sign-15.16 format */ #define fixmul32(x, y) \ @@ -62,8 +53,7 @@ long fsincos(unsigned long phase, fixed32 *cos); __result; \ }) - - #define fixmul32b(x, y) \ +#define fixmul32b(x, y) \ ({ int32_t __hi; \ uint32_t __lo; \ int32_t __result; \ @@ -76,6 +66,7 @@ long fsincos(unsigned long phase, fixed32 *cos); }) #elif defined(CPU_COLDFIRE) + static inline int32_t fixmul32(int32_t x, int32_t y) { #if PRECISION != 16 @@ -89,22 +80,49 @@ static inline int32_t fixmul32(int32_t x, int32_t y) "lsr.l #1, %[t1] \n" "move.w %[t1], %[x] \n" "swap %[x] \n" - : /* outputs */ - [t1]"=&d"(t1), - [x] "+d" (x) - : /* inputs */ - [y] "d" (y) + : [t1] "=&d" (t1), [x] "+d" (x) + : [y] "d" (y) + ); + return x; +} + +static inline int32_t fixmul32b(int32_t x, int32_t y) +{ + asm ( + "mac.l %[x], %[y], %%acc0 \n" /* multiply */ + "movclr.l %%acc0, %[x] \n" /* get higher half */ + : [x] "+d" (x) + : [y] "d" (y) ); return x; } -fixed32 fixmul32b(fixed32 x, fixed32 y); #else -fixed32 fixmul32(fixed32 x, fixed32 y); -fixed32 fixmul32b(fixed32 x, fixed32 y); -#endif +static inline fixed32 fixmul32(fixed32 x, fixed32 y) +{ + fixed64 temp; + temp = x; + temp *= y; + + temp >>= PRECISION; + + return (fixed32)temp; +} +static inline fixed32 fixmul32b(fixed32 x, fixed32 y) +{ + fixed64 temp; + + temp = x; + temp *= y; + + temp >>= 31; //16+31-16 = 31 bits + + return (fixed32)temp; +} + +#endif #ifdef CPU_ARM static inline @@ -148,7 +166,6 @@ void CMUL(fixed32 *x, fixed32 *y, : "cc", "memory"); } #else -// PJJ : reinstate macro static inline void CMUL(fixed32 *pre, fixed32 *pim, |