From 432e2ecc137d4fb4d9f6ac87cbbc38830a1f3c2c Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Thu, 13 Aug 2009 20:38:59 +0000 Subject: Modify libatrac to use fixed-point arithmetic. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22298 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libatrac/fixp_math.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 apps/codecs/libatrac/fixp_math.h (limited to 'apps/codecs/libatrac/fixp_math.h') diff --git a/apps/codecs/libatrac/fixp_math.h b/apps/codecs/libatrac/fixp_math.h new file mode 100644 index 0000000000..5bfc2c5703 --- /dev/null +++ b/apps/codecs/libatrac/fixp_math.h @@ -0,0 +1,14 @@ +#include + +/* 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); -- cgit v1.2.3