1
0
Fork 0
forked from len0rd/rockbox

Modify libatrac to use fixed-point arithmetic.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22298 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Mohamed Tarek 2009-08-13 20:38:59 +00:00
parent c956059ec5
commit 432e2ecc13
10 changed files with 324 additions and 5756 deletions

View file

@ -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);