summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2009-08-16 12:41:04 +0000
committerJens Arnold <amiconn@rockbox.org>2009-08-16 12:41:04 +0000
commit3d6f86eb2ff21f12d9f884a8271aa783f5046ae0 (patch)
tree445686f4dbced712a4c9687e525b54145491d2ed /apps/codecs
parent90ea3e97163fc2c34c7d114af8e36e48f4c680f2 (diff)
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')
-rw-r--r--apps/codecs/libatrac/SOURCES1
-rw-r--r--apps/codecs/libatrac/fixp_math.c66
-rw-r--r--apps/codecs/libatrac/fixp_math.h69
3 files changed, 65 insertions, 71 deletions
diff --git a/apps/codecs/libatrac/SOURCES b/apps/codecs/libatrac/SOURCES
index 76e0385186..972f9621fc 100644
--- a/apps/codecs/libatrac/SOURCES
+++ b/apps/codecs/libatrac/SOURCES
@@ -1,3 +1,2 @@
atrac3.c
-fixp_math.c
../lib/ffmpeg_bitstream.c
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 @@
-#include "fixp_math.h"
-
-inline int32_t fixmul31(int32_t x, int32_t y)
-{
- int64_t temp;
- temp = x;
- temp *= y;
-
- temp >>= 31; //16+31-16 = 31 bits
-
- return (int32_t)temp;
-}
-
-/*
- * Fast integer square root adapted from algorithm,
- * Martin Guy @ UKC, June 1985.
- * Originally from a book on programming abaci by Mr C. Woo.
- * This is taken from :
- * http://wiki.forum.nokia.com/index.php/How_to_use_fixed_point_maths#How_to_get_square_root_for_integers
- * with a added shift up of the result by 8 bits to return result in 16.16 fixed-point representation.
- */
-inline int32_t fastSqrt(int32_t n)
-{
- /*
- * Logically, these are unsigned.
- * We need the sign bit to test
- * whether (op - res - one) underflowed.
- */
- int32_t op, res, one;
- op = n;
- res = 0;
- /* "one" starts at the highest power of four <= than the argument. */
- one = 1 << 30; /* second-to-top bit set */
- while (one > op) one >>= 2;
- while (one != 0)
- {
- if (op >= res + one)
- {
- op = op - (res + one);
- res = res + (one<<1);
- }
- res >>= 1;
- one >>= 2;
- }
- return(res << 8);
-}
-
-inline int32_t fixmul16(int32_t x, int32_t y)
-{
- int64_t temp;
- temp = x;
- temp *= y;
-
- temp >>= 16;
-
- return (int32_t)temp;
-}
-
-inline int32_t fixdiv16(int32_t x, int32_t y)
-{
- int64_t temp;
- temp = x << 16;
- temp /= y;
-
- return (int32_t)temp;
-}
diff --git a/apps/codecs/libatrac/fixp_math.h b/apps/codecs/libatrac/fixp_math.h
index b6621b6f1a..8a734f6b68 100644
--- a/apps/codecs/libatrac/fixp_math.h
+++ b/apps/codecs/libatrac/fixp_math.h
@@ -9,7 +9,68 @@
#define fix31tof64(x) (float)((float)(x) / (float)(1 << 31))
/* Fixed point math routines for use in atrac3.c */
-inline int32_t fixmul16(int32_t x, int32_t y);
-inline int32_t fixmul31(int32_t x, int32_t y);
-inline int32_t fixdiv16(int32_t x, int32_t y);
-inline int32_t fastSqrt(int32_t n);
+
+static inline int32_t fixmul16(int32_t x, int32_t y)
+{
+ int64_t temp;
+ temp = x;
+ temp *= y;
+
+ temp >>= 16;
+
+ return (int32_t)temp;
+}
+
+static inline int32_t fixmul31(int32_t x, int32_t y)
+{
+ int64_t temp;
+ temp = x;
+ temp *= y;
+
+ temp >>= 31; //16+31-16 = 31 bits
+
+ return (int32_t)temp;
+}
+
+static inline int32_t fixdiv16(int32_t x, int32_t y)
+{
+ int64_t temp;
+ temp = x << 16;
+ temp /= y;
+
+ return (int32_t)temp;
+}
+
+/*
+ * Fast integer square root adapted from algorithm,
+ * Martin Guy @ UKC, June 1985.
+ * Originally from a book on programming abaci by Mr C. Woo.
+ * This is taken from :
+ * http://wiki.forum.nokia.com/index.php/How_to_use_fixed_point_maths#How_to_get_square_root_for_integers
+ * with a added shift up of the result by 8 bits to return result in 16.16 fixed-point representation.
+ */
+static inline int32_t fastSqrt(int32_t n)
+{
+ /*
+ * Logically, these are unsigned.
+ * We need the sign bit to test
+ * whether (op - res - one) underflowed.
+ */
+ int32_t op, res, one;
+ op = n;
+ res = 0;
+ /* "one" starts at the highest power of four <= than the argument. */
+ one = 1 << 30; /* second-to-top bit set */
+ while (one > op) one >>= 2;
+ while (one != 0)
+ {
+ if (op >= res + one)
+ {
+ op = op - (res + one);
+ res = res + (one<<1);
+ }
+ res >>= 1;
+ one >>= 2;
+ }
+ return(res << 8);
+}