diff options
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/arch.h')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/arch.h | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/arch.h b/lib/rbcodec/codecs/libopus/celt/arch.h index b2d26c4ee4..035b92ff29 100644 --- a/lib/rbcodec/codecs/libopus/celt/arch.h +++ b/lib/rbcodec/codecs/libopus/celt/arch.h | |||
@@ -69,11 +69,9 @@ static OPUS_INLINE void _celt_fatal(const char *str, const char *file, int line) | |||
69 | 69 | ||
70 | #define IMUL32(a,b) ((a)*(b)) | 70 | #define IMUL32(a,b) ((a)*(b)) |
71 | 71 | ||
72 | #define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ | 72 | #define ABS(x) ((x) < 0 ? (-(x)) : (x)) |
73 | #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ | ||
74 | #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ | 73 | #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ |
75 | #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ | 74 | #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ |
76 | #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ | ||
77 | #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ | 75 | #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ |
78 | #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ | 76 | #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ |
79 | #define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ | 77 | #define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ |
@@ -108,6 +106,13 @@ typedef opus_val32 celt_ener; | |||
108 | #define SCALEIN(a) (a) | 106 | #define SCALEIN(a) (a) |
109 | #define SCALEOUT(a) (a) | 107 | #define SCALEOUT(a) (a) |
110 | 108 | ||
109 | #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) | ||
110 | #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) | ||
111 | |||
112 | static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { | ||
113 | return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; | ||
114 | } | ||
115 | |||
111 | #ifdef FIXED_DEBUG | 116 | #ifdef FIXED_DEBUG |
112 | #include "fixed_debug.h" | 117 | #include "fixed_debug.h" |
113 | #else | 118 | #else |
@@ -139,6 +144,22 @@ typedef float celt_sig; | |||
139 | typedef float celt_norm; | 144 | typedef float celt_norm; |
140 | typedef float celt_ener; | 145 | typedef float celt_ener; |
141 | 146 | ||
147 | #ifdef FLOAT_APPROX | ||
148 | /* This code should reliably detect NaN/inf even when -ffast-math is used. | ||
149 | Assumes IEEE 754 format. */ | ||
150 | static OPUS_INLINE int celt_isnan(float x) | ||
151 | { | ||
152 | union {float f; opus_uint32 i;} in; | ||
153 | in.f = x; | ||
154 | return ((in.i>>23)&0xFF)==0xFF && (in.i&0x007FFFFF)!=0; | ||
155 | } | ||
156 | #else | ||
157 | #ifdef __FAST_MATH__ | ||
158 | #error Cannot build libopus with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input | ||
159 | #endif | ||
160 | #define celt_isnan(x) ((x)!=(x)) | ||
161 | #endif | ||
162 | |||
142 | #define Q15ONE 1.0f | 163 | #define Q15ONE 1.0f |
143 | 164 | ||
144 | #define NORM_SCALING 1.f | 165 | #define NORM_SCALING 1.f |
@@ -148,6 +169,10 @@ typedef float celt_ener; | |||
148 | #define VERY_LARGE16 1e15f | 169 | #define VERY_LARGE16 1e15f |
149 | #define Q15_ONE ((opus_val16)1.f) | 170 | #define Q15_ONE ((opus_val16)1.f) |
150 | 171 | ||
172 | /* This appears to be the same speed as C99's fabsf() but it's more portable. */ | ||
173 | #define ABS16(x) ((float)fabs(x)) | ||
174 | #define ABS32(x) ((float)fabs(x)) | ||
175 | |||
151 | #define QCONST16(x,bits) (x) | 176 | #define QCONST16(x,bits) (x) |
152 | #define QCONST32(x,bits) (x) | 177 | #define QCONST32(x,bits) (x) |
153 | 178 | ||
@@ -186,6 +211,7 @@ typedef float celt_ener; | |||
186 | #define MULT32_32_Q31(a,b) ((a)*(b)) | 211 | #define MULT32_32_Q31(a,b) ((a)*(b)) |
187 | 212 | ||
188 | #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) | 213 | #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) |
214 | #define MAC16_32_Q16(c,a,b) ((c)+(a)*(b)) | ||
189 | 215 | ||
190 | #define MULT16_16_Q11_32(a,b) ((a)*(b)) | 216 | #define MULT16_16_Q11_32(a,b) ((a)*(b)) |
191 | #define MULT16_16_Q11(a,b) ((a)*(b)) | 217 | #define MULT16_16_Q11(a,b) ((a)*(b)) |
@@ -203,6 +229,8 @@ typedef float celt_ener; | |||
203 | #define SCALEIN(a) ((a)*CELT_SIG_SCALE) | 229 | #define SCALEIN(a) ((a)*CELT_SIG_SCALE) |
204 | #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) | 230 | #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) |
205 | 231 | ||
232 | #define SIG2WORD16(x) (x) | ||
233 | |||
206 | #endif /* !FIXED_POINT */ | 234 | #endif /* !FIXED_POINT */ |
207 | 235 | ||
208 | #ifndef GLOBAL_STACK_SIZE | 236 | #ifndef GLOBAL_STACK_SIZE |