diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-01-04 02:01:18 -0600 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-04-23 14:23:04 +0000 |
commit | 14c6bb798d6bebc80f07e863236adbaf8d156a9c (patch) | |
tree | 551a4b641906c2626af844fa3239c1b2b1ff0ad3 /lib/rbcodec/codecs/libopus/celt/mathops.h | |
parent | 75d93937965ec4df70d37df6d4feea04577c996b (diff) | |
download | rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.tar.gz rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.zip |
Sync opus codec to upstream git
Change-Id: I0cfcc0005c4ad7bfbb1aaf454188ce70fb043dc1
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/mathops.h')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/mathops.h | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/mathops.h b/lib/rbcodec/codecs/libopus/celt/mathops.h index a0525a9610..f3e5246a39 100644 --- a/lib/rbcodec/codecs/libopus/celt/mathops.h +++ b/lib/rbcodec/codecs/libopus/celt/mathops.h | |||
@@ -38,11 +38,48 @@ | |||
38 | #include "entcode.h" | 38 | #include "entcode.h" |
39 | #include "os_support.h" | 39 | #include "os_support.h" |
40 | 40 | ||
41 | #define PI 3.141592653f | ||
42 | |||
43 | #ifndef ABS | ||
44 | #define ABS(a)(((a) < 0) ? - (a) :(a)) | ||
45 | #endif | ||
46 | |||
41 | /* Multiplies two 16-bit fractional values. Bit-exactness of this macro is important */ | 47 | /* Multiplies two 16-bit fractional values. Bit-exactness of this macro is important */ |
42 | #define FRAC_MUL16(a,b) ((16384+((opus_int32)(opus_int16)(a)*(opus_int16)(b)))>>15) | 48 | #define FRAC_MUL16(a,b) ((16384+((opus_int32)(opus_int16)(a)*(opus_int16)(b)))>>15) |
43 | 49 | ||
44 | unsigned isqrt32(opus_uint32 _val); | 50 | unsigned isqrt32(opus_uint32 _val); |
45 | 51 | ||
52 | /* CELT doesn't need it for fixed-point, by analysis.c does. */ | ||
53 | #if !defined(FIXED_POINT) || defined(ANALYSIS_C) | ||
54 | #define cA 0.43157974f | ||
55 | #define cB 0.67848403f | ||
56 | #define cC 0.08595542f | ||
57 | #define cE ((float)PI/2) | ||
58 | static OPUS_INLINE float fast_atan2f(float y, float x) { | ||
59 | float x2, y2; | ||
60 | x2 = x*x; | ||
61 | y2 = y*y; | ||
62 | /* For very small values, we don't care about the answer, so | ||
63 | we can just return 0. */ | ||
64 | if (x2 + y2 < 1e-18f) | ||
65 | { | ||
66 | return 0; | ||
67 | } | ||
68 | if(x2<y2){ | ||
69 | float den = (y2 + cB*x2) * (y2 + cC*x2); | ||
70 | return -x*y*(y2 + cA*x2) / den + (y<0 ? -cE : cE); | ||
71 | }else{ | ||
72 | float den = (x2 + cB*y2) * (x2 + cC*y2); | ||
73 | return x*y*(x2 + cA*y2) / den + (y<0 ? -cE : cE) - (x*y<0 ? -cE : cE); | ||
74 | } | ||
75 | } | ||
76 | #undef cA | ||
77 | #undef cB | ||
78 | #undef cC | ||
79 | #undef cE | ||
80 | #endif | ||
81 | |||
82 | |||
46 | #ifndef OVERRIDE_CELT_MAXABS16 | 83 | #ifndef OVERRIDE_CELT_MAXABS16 |
47 | static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len) | 84 | static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len) |
48 | { | 85 | { |
@@ -80,7 +117,6 @@ static OPUS_INLINE opus_val32 celt_maxabs32(const opus_val32 *x, int len) | |||
80 | 117 | ||
81 | #ifndef FIXED_POINT | 118 | #ifndef FIXED_POINT |
82 | 119 | ||
83 | #define PI 3.141592653f | ||
84 | #define celt_sqrt(x) ((float)sqrt(x)) | 120 | #define celt_sqrt(x) ((float)sqrt(x)) |
85 | #define celt_rsqrt(x) (1.f/celt_sqrt(x)) | 121 | #define celt_rsqrt(x) (1.f/celt_sqrt(x)) |
86 | #define celt_rsqrt_norm(x) (celt_rsqrt(x)) | 122 | #define celt_rsqrt_norm(x) (celt_rsqrt(x)) |
@@ -147,7 +183,7 @@ static OPUS_INLINE float celt_exp2(float x) | |||
147 | /** Integer log in base2. Undefined for zero and negative numbers */ | 183 | /** Integer log in base2. Undefined for zero and negative numbers */ |
148 | static OPUS_INLINE opus_int16 celt_ilog2(opus_int32 x) | 184 | static OPUS_INLINE opus_int16 celt_ilog2(opus_int32 x) |
149 | { | 185 | { |
150 | celt_assert2(x>0, "celt_ilog2() only defined for strictly positive numbers"); | 186 | celt_sig_assert(x>0); |
151 | return EC_ILOG(x)-1; | 187 | return EC_ILOG(x)-1; |
152 | } | 188 | } |
153 | #endif | 189 | #endif |