summaryrefslogtreecommitdiff
path: root/apps/codecs/libatrac/fixp_math.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libatrac/fixp_math.h')
-rw-r--r--apps/codecs/libatrac/fixp_math.h14
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 0000000000..5bfc2c5703
--- /dev/null
+++ b/apps/codecs/libatrac/fixp_math.h
@@ -0,0 +1,14 @@
1#include <stdlib.h>
2
3/* Macros for converting between various fixed-point representations and floating point. */
4#define ONE_16 (1L << 16)
5#define fixtof64(x) (float)((float)(x) / (float)(1 << 16)) //does not work on int64_t!
6#define ftofix32(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5 : 0.5)))
7#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5 : 0.5)))
8#define fix31tof64(x) (float)((float)(x) / (float)(1 << 31))
9
10/* Fixed point math routines for use in atrac3.c */
11inline int32_t fixdiv16(int32_t x, int32_t y);
12inline int32_t fixmul16(int32_t x, int32_t y);
13inline int32_t fixmul31(int32_t x, int32_t y);
14inline int32_t fastSqrt(int32_t n);