diff options
Diffstat (limited to 'apps/codecs/libspeex/math_approx.h')
-rw-r--r-- | apps/codecs/libspeex/math_approx.h | 23 |
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 @@ | |||
45 | #define spx_cos_norm(x) (cos((.5f*M_PI)*(x))) | 45 | #define spx_cos_norm(x) (cos((.5f*M_PI)*(x))) |
46 | #define spx_atan atan | 46 | #define spx_atan atan |
47 | 47 | ||
48 | #endif | 48 | /** Generate a pseudo-random number */ |
49 | static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed) | ||
50 | { | ||
51 | const unsigned int jflone = 0x3f800000; | ||
52 | const unsigned int jflmsk = 0x007fffff; | ||
53 | union {int i; float f;} ran; | ||
54 | *seed = 1664525 * *seed + 1013904223; | ||
55 | ran.i = jflone | (jflmsk & *seed); | ||
56 | ran.f -= 1.5; | ||
57 | return 3.4642*std*ran.f; | ||
58 | } | ||
59 | |||
49 | 60 | ||
61 | #endif | ||
50 | 62 | ||
51 | 63 | ||
52 | static inline spx_int16_t spx_ilog2(spx_uint32_t x) | 64 | 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) | |||
106 | 118 | ||
107 | #ifdef FIXED_POINT | 119 | #ifdef FIXED_POINT |
108 | 120 | ||
121 | /** Generate a pseudo-random number */ | ||
122 | static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed) | ||
123 | { | ||
124 | spx_word32_t res; | ||
125 | *seed = 1664525 * *seed + 1013904223; | ||
126 | res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std); | ||
127 | return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14)); | ||
128 | } | ||
129 | |||
109 | /* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */ | 130 | /* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */ |
110 | /*#define C0 3634 | 131 | /*#define C0 3634 |
111 | #define C1 21173 | 132 | #define C1 21173 |