diff options
| author | Mohamed Tarek <mt@rockbox.org> | 2010-07-05 22:33:37 +0000 |
|---|---|---|
| committer | Mohamed Tarek <mt@rockbox.org> | 2010-07-05 22:33:37 +0000 |
| commit | d884af2b9992f12e98a3e8548aff76b232b5bfb3 (patch) | |
| tree | d3aefbc2195382025105b252c16b00087778beed /apps/codecs/libwmapro/wmapro_math.h | |
| parent | 6a04479d63dd4d7dfc54849e4c925d360d55fa9c (diff) | |
| download | rockbox-d884af2b9992f12e98a3e8548aff76b232b5bfb3.zip rockbox-d884af2b9992f12e98a3e8548aff76b232b5bfb3.tar.gz rockbox-d884af2b9992f12e98a3e8548aff76b232b5bfb3.tar.bz2 rockbox-d884af2b9992f12e98a3e8548aff76b232b5bfb3.tar.xz | |
Partial conversion of the wmapro decoder to fixed point arithmetic. Currently inverse quantization & rescaling,
imdct and windowing are all in fixed point.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27302 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libwmapro/wmapro_math.h')
| -rw-r--r-- | apps/codecs/libwmapro/wmapro_math.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/apps/codecs/libwmapro/wmapro_math.h b/apps/codecs/libwmapro/wmapro_math.h new file mode 100644 index 0000000..83fbb40 --- /dev/null +++ b/apps/codecs/libwmapro/wmapro_math.h @@ -0,0 +1,46 @@ +#include <inttypes.h> +#include "types.h" + +#define fixtof16(x) (float)((float)(x) / (float)(1 << 16)) +#define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5))) + +static inline FIXED fixmulshift(FIXED x, FIXED y, int shamt) +{ + int64_t temp; + temp = x; + temp *= y; + + temp >>= shamt; + + return (int32_t)temp; +} + + +static inline void vector_fixmul_window(FIXED *dst, const FIXED *src0, + const FIXED *src1, const FIXED *win, + FIXED add_bias, int len) +{ + int i, j; + dst += len; + win += len; + src0+= len; + for(i=-len, j=len-1; i<0; i++, j--) { + FIXED s0 = src0[i]; + FIXED s1 = src1[j]; + FIXED wi = win[i]; + FIXED wj = win[j]; + dst[i] = fixmulshift(s0,-1*wj,31) - fixmulshift(s1,-1*wi,31) + (add_bias<<16); + dst[j] = fixmulshift(s0,-1*wi,31) + fixmulshift(s1,-1*wj,31) + (add_bias<<16); + } + +} + +static inline void vector_fixmul_scalar(FIXED *dst, const FIXED *src, FIXED mul, + int len) +{ + int i; + for(i=0; i<len; i++) { + dst[i] = fixmulshift(src[i],mul,32); + } + +} |