summaryrefslogtreecommitdiffstats
path: root/apps/codecs/libspeex/math_approx.h
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2007-10-26 01:16:55 +0000
committerThom Johansen <thomj@rockbox.org>2007-10-26 01:16:55 +0000
commitfa971b142d794c9620b823d6b9d1937397c1f1e1 (patch)
tree55565a0765c15be5d1df4cfb1c04dc92de50fe5d /apps/codecs/libspeex/math_approx.h
parent14da611cd32d084813bb0d2e2318b81c3ea2953a (diff)
downloadrockbox-fa971b142d794c9620b823d6b9d1937397c1f1e1.tar.gz
rockbox-fa971b142d794c9620b823d6b9d1937397c1f1e1.zip
Sync with Speex SVN. Syntactic change in filters_cf.S.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15310 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libspeex/math_approx.h')
-rw-r--r--apps/codecs/libspeex/math_approx.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/apps/codecs/libspeex/math_approx.h b/apps/codecs/libspeex/math_approx.h
index 8421d634bb..4f61e8645a 100644
--- a/apps/codecs/libspeex/math_approx.h
+++ b/apps/codecs/libspeex/math_approx.h
@@ -45,8 +45,20 @@
#define spx_cos_norm(x) (cos((.5f*M_PI)*(x)))
#define spx_atan atan
-#endif
+/** Generate a pseudo-random number */
+static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+{
+ const unsigned int jflone = 0x3f800000;
+ const unsigned int jflmsk = 0x007fffff;
+ union {int i; float f;} ran;
+ *seed = 1664525 * *seed + 1013904223;
+ ran.i = jflone | (jflmsk & *seed);
+ ran.f -= 1.5;
+ return 3.4642*std*ran.f;
+}
+
+#endif
static inline spx_int16_t spx_ilog2(spx_uint32_t x)
@@ -106,6 +118,15 @@ static inline spx_int16_t spx_ilog4(spx_uint32_t x)
#ifdef FIXED_POINT
+/** Generate a pseudo-random number */
+static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+{
+ spx_word32_t res;
+ *seed = 1664525 * *seed + 1013904223;
+ res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std);
+ return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14));
+}
+
/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */
/*#define C0 3634
#define C1 21173