diff options
author | Jens Arnold <amiconn@rockbox.org> | 2009-08-16 12:41:04 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2009-08-16 12:41:04 +0000 |
commit | 3d6f86eb2ff21f12d9f884a8271aa783f5046ae0 (patch) | |
tree | 445686f4dbced712a4c9687e525b54145491d2ed /apps/codecs/libatrac/fixp_math.c | |
parent | 90ea3e97163fc2c34c7d114af8e36e48f4c680f2 (diff) | |
download | rockbox-3d6f86eb2ff21f12d9f884a8271aa783f5046ae0.tar.gz rockbox-3d6f86eb2ff21f12d9f884a8271aa783f5046ae0.zip |
Make those functions actually inline. Around 20% speedup on coldfire, 10% speedup on arm.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22344 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libatrac/fixp_math.c')
-rw-r--r-- | apps/codecs/libatrac/fixp_math.c | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/apps/codecs/libatrac/fixp_math.c b/apps/codecs/libatrac/fixp_math.c deleted file mode 100644 index 3f578a1ade..0000000000 --- a/apps/codecs/libatrac/fixp_math.c +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | #include "fixp_math.h" | ||
2 | |||
3 | inline int32_t fixmul31(int32_t x, int32_t y) | ||
4 | { | ||
5 | int64_t temp; | ||
6 | temp = x; | ||
7 | temp *= y; | ||
8 | |||
9 | temp >>= 31; //16+31-16 = 31 bits | ||
10 | |||
11 | return (int32_t)temp; | ||
12 | } | ||
13 | |||
14 | /* | ||
15 | * Fast integer square root adapted from algorithm, | ||
16 | * Martin Guy @ UKC, June 1985. | ||
17 | * Originally from a book on programming abaci by Mr C. Woo. | ||
18 | * This is taken from : | ||
19 | * http://wiki.forum.nokia.com/index.php/How_to_use_fixed_point_maths#How_to_get_square_root_for_integers | ||
20 | * with a added shift up of the result by 8 bits to return result in 16.16 fixed-point representation. | ||
21 | */ | ||
22 | inline int32_t fastSqrt(int32_t n) | ||
23 | { | ||
24 | /* | ||
25 | * Logically, these are unsigned. | ||
26 | * We need the sign bit to test | ||
27 | * whether (op - res - one) underflowed. | ||
28 | */ | ||
29 | int32_t op, res, one; | ||
30 | op = n; | ||
31 | res = 0; | ||
32 | /* "one" starts at the highest power of four <= than the argument. */ | ||
33 | one = 1 << 30; /* second-to-top bit set */ | ||
34 | while (one > op) one >>= 2; | ||
35 | while (one != 0) | ||
36 | { | ||
37 | if (op >= res + one) | ||
38 | { | ||
39 | op = op - (res + one); | ||
40 | res = res + (one<<1); | ||
41 | } | ||
42 | res >>= 1; | ||
43 | one >>= 2; | ||
44 | } | ||
45 | return(res << 8); | ||
46 | } | ||
47 | |||
48 | inline int32_t fixmul16(int32_t x, int32_t y) | ||
49 | { | ||
50 | int64_t temp; | ||
51 | temp = x; | ||
52 | temp *= y; | ||
53 | |||
54 | temp >>= 16; | ||
55 | |||
56 | return (int32_t)temp; | ||
57 | } | ||
58 | |||
59 | inline int32_t fixdiv16(int32_t x, int32_t y) | ||
60 | { | ||
61 | int64_t temp; | ||
62 | temp = x << 16; | ||
63 | temp /= y; | ||
64 | |||
65 | return (int32_t)temp; | ||
66 | } | ||