diff options
| author | Mohamed Tarek <mt@rockbox.org> | 2009-08-13 20:38:59 +0000 |
|---|---|---|
| committer | Mohamed Tarek <mt@rockbox.org> | 2009-08-13 20:38:59 +0000 |
| commit | 432e2ecc137d4fb4d9f6ac87cbbc38830a1f3c2c (patch) | |
| tree | 27feb800527b18bbebe29c0414fc0b0e529c8ebc /apps/codecs/libatrac/fixp_math.h | |
| parent | c956059ec5a2d85311914fb31a36d5127797fbc2 (diff) | |
| download | rockbox-432e2ecc137d4fb4d9f6ac87cbbc38830a1f3c2c.zip rockbox-432e2ecc137d4fb4d9f6ac87cbbc38830a1f3c2c.tar.gz rockbox-432e2ecc137d4fb4d9f6ac87cbbc38830a1f3c2c.tar.bz2 rockbox-432e2ecc137d4fb4d9f6ac87cbbc38830a1f3c2c.tar.xz | |
Modify libatrac to use fixed-point arithmetic.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22298 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libatrac/fixp_math.h')
| -rw-r--r-- | apps/codecs/libatrac/fixp_math.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/apps/codecs/libatrac/fixp_math.h b/apps/codecs/libatrac/fixp_math.h new file mode 100644 index 0000000..5bfc2c5 --- /dev/null +++ b/apps/codecs/libatrac/fixp_math.h @@ -0,0 +1,14 @@ +#include <stdlib.h> + +/* Macros for converting between various fixed-point representations and floating point. */ +#define ONE_16 (1L << 16) +#define fixtof64(x) (float)((float)(x) / (float)(1 << 16)) //does not work on int64_t! +#define ftofix32(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5 : 0.5))) +#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5 : 0.5))) +#define fix31tof64(x) (float)((float)(x) / (float)(1 << 31)) + +/* Fixed point math routines for use in atrac3.c */ +inline int32_t fixdiv16(int32_t x, int32_t y); +inline int32_t fixmul16(int32_t x, int32_t y); +inline int32_t fixmul31(int32_t x, int32_t y); +inline int32_t fastSqrt(int32_t n); |