summaryrefslogtreecommitdiff
path: root/apps/codecs/libatrac/fixp_math.h
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-02-15 13:00:02 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-02-15 13:00:02 +0000
commit57461d7c4f612bed0e8cd9644a0689dbfe56d684 (patch)
treef3d574b7f7b9433d3aef18b828c5687993a9ea0f /apps/codecs/libatrac/fixp_math.h
parent651b55488ef2c35c0b0a17781a466bf14cc1f71a (diff)
downloadrockbox-57461d7c4f612bed0e8cd9644a0689dbfe56d684.tar.gz
rockbox-57461d7c4f612bed0e8cd9644a0689dbfe56d684.zip
Work on atrac Joint Stereo mode. Correct calculation in getChannelWeights(), introduce lookup table and remove obsolete code. Optimize interpolation macro.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24665 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libatrac/fixp_math.h')
-rw-r--r--apps/codecs/libatrac/fixp_math.h43
1 files changed, 0 insertions, 43 deletions
diff --git a/apps/codecs/libatrac/fixp_math.h b/apps/codecs/libatrac/fixp_math.h
index 5174cc7cc6..29d47a9e53 100644
--- a/apps/codecs/libatrac/fixp_math.h
+++ b/apps/codecs/libatrac/fixp_math.h
@@ -91,46 +91,3 @@
91 return (int32_t)temp; 91 return (int32_t)temp;
92 } 92 }
93#endif 93#endif
94
95static inline int32_t fixdiv16(int32_t x, int32_t y)
96{
97 int64_t temp;
98 temp = x << 16;
99 temp /= y;
100
101 return (int32_t)temp;
102}
103
104/*
105 * Fast integer square root adapted from algorithm,
106 * Martin Guy @ UKC, June 1985.
107 * Originally from a book on programming abaci by Mr C. Woo.
108 * This is taken from :
109 * http://wiki.forum.nokia.com/index.php/How_to_use_fixed_point_maths#How_to_get_square_root_for_integers
110 * with a added shift up of the result by 8 bits to return result in 16.16 fixed-point representation.
111 */
112static inline int32_t fastSqrt(int32_t n)
113{
114 /*
115 * Logically, these are unsigned.
116 * We need the sign bit to test
117 * whether (op - res - one) underflowed.
118 */
119 int32_t op, res, one;
120 op = n;
121 res = 0;
122 /* "one" starts at the highest power of four <= than the argument. */
123 one = 1 << 30; /* second-to-top bit set */
124 while (one > op) one >>= 2;
125 while (one != 0)
126 {
127 if (op >= res + one)
128 {
129 op = op - (res + one);
130 res = res + (one<<1);
131 }
132 res >>= 1;
133 one >>= 2;
134 }
135 return(res << 8);
136}