Debian Codegraph @

external/opusfile/opus/celt/arch.h

raw symbols SCIP
1 /* Copyright (c) 2003-2008 Jean-Marc Valin
2 Copyright (c) 2007-2008 CSIRO
3 Copyright (c) 2007-2009 Xiph.Org Foundation
4 Written by Jean-Marc Valin */
5 /**
6 @file arch.h
7 @brief Various architecture definitions for CELT
8 */
9 /*
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions
12 are met:
13
14 - Redistributions of source code must retain the above copyright
15 notice, this list of conditions and the following disclaimer.
16
17 - Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
25 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef ARCH_H
35 #define ARCH_Hcxx . . $ `external/opusfile/opus/celt/arch.h:35:9`!
36
37 #include "opus_types.h"cxx . . $ `<file>/external/opusfile/opus/opus_types.h`/
38 #include "opus_defines.h"cxx . . $ `<file>/external/opusfile/opus/opus_defines.h`/
39
40 # if !defined(__GNUC_PREREQcxx . . $ `<external>/18206667465210621810/features.h:173:10`!)
41 # if defined(__GNUC__)&&defined(__GNUC_MINOR__)
42 # define __GNUC_PREREQ(_maj,_min) \
43 ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
44 # else
45 # define __GNUC_PREREQ(_maj,_min) 0
46 # endif
47 # endif
48
49 #if OPUS_GNUC_PREREQcxx . . $ `external/opusfile/opus/opus_defines.h:82:12`!(3, 0)
50 #define opus_likelycxx . . $ `external/opusfile/opus/celt/arch.h:50:9`!(x) (__builtin_expect(!!(x), 1))
51 #define opus_unlikelycxx . . $ `external/opusfile/opus/celt/arch.h:51:9`!(x) (__builtin_expect(!!(x), 0))
52 #else
53 #define opus_likely(x) (!!(x))
54 #define opus_unlikely(x) (!!(x))
55 #endif
56
57 #define CELT_SIG_SCALEcxx . . $ `external/opusfile/opus/celt/arch.h:57:9`! 32768.f
58
59 #define CELT_FATALcxx . . $ `external/opusfile/opus/celt/arch.h:59:9`!(str) celt_fatal(str, __FILE__, __LINE__);
60
61 #if defined(ENABLE_ASSERTIONS) || defined(ENABLE_HARDENINGcxx . . $ `external/opusfile/opus/opus__config.h:23:9`!)
62 #ifdef __GNUC__cxx . . $ `<built-in>:8:9`!
63 __attribute__((noreturn))
64 #endif
65 void celt_fatalcxx . . $ celt_fatal(82656b814f72824e).(const char *str, const char *file, int line);
66
67 #if defined(CELT_C) && !defined(OVERRIDE_celt_fatal)
68 #include <stdio.h>
69 #include <stdlib.h>
70 #ifdef __GNUC__
71 __attribute__((noreturn))
72 #endif
73 void celt_fatal(const char *str, const char *file, int line)
74 {
75 fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
76 abort();
77 }
78 #endif
79
80 #define celt_assertcxx . . $ `external/opusfile/opus/celt/arch.h:80:9`!(cond) {if (!(cond)) {CELT_FATALcxx . . $ `external/opusfile/opus/celt/arch.h:59:9`!("assertion failed: " #cond);}}
81 #define celt_assert2cxx . . $ `external/opusfile/opus/celt/arch.h:81:9`!(cond, message) {if (!(cond)) {CELT_FATALcxx . . $ `external/opusfile/opus/celt/arch.h:59:9`!("assertion failed: " #cond "\n" message);}}
82 #define MUST_SUCCEEDcxx . . $ `external/opusfile/opus/celt/arch.h:82:9`!(call) celt_assert((call) == OPUS_OK)
83 #else
84 #define celt_assert(cond)
85 #define celt_assert2(cond, message)
86 #define MUST_SUCCEED(call) do {if((call) != OPUS_OK) {RESTORE_STACK; return OPUS_INTERNAL_ERROR;} } while (0)
87 #endif
88
89 #if defined(ENABLE_ASSERTIONS)
90 #define celt_sig_assert(cond) {if (!(cond)) {CELT_FATAL("signal assertion failed: " #cond);}}
91 #else
92 #define celt_sig_assertcxx . . $ `external/opusfile/opus/celt/arch.h:92:9`!(cond)
93 #endif
94
95 #define IMUL32cxx . . $ `external/opusfile/opus/celt/arch.h:95:9`!(a,b) ((a)*(b))
96
97 #define MIN16cxx . . $ `external/opusfile/opus/celt/arch.h:97:9`!(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */
98 #define MAX16cxx . . $ `external/opusfile/opus/celt/arch.h:98:9`!(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */
99 #define MIN32cxx . . $ `external/opusfile/opus/celt/arch.h:99:9`!(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */
100 #define MAX32cxx . . $ `external/opusfile/opus/celt/arch.h:100:9`!(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */
101 #define IMINcxx . . $ `external/opusfile/opus/celt/arch.h:101:9`!(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */
102 #define IMAXcxx . . $ `external/opusfile/opus/celt/arch.h:102:9`!(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */
103 #define UADD32cxx . . $ `external/opusfile/opus/celt/arch.h:103:9`!(a,b) ((a)+(b))
104 #define USUB32cxx . . $ `external/opusfile/opus/celt/arch.h:104:9`!(a,b) ((a)-(b))
105
106 /* Set this if opus_int64 is a native type of the CPU. */
107 /* Assume that all LP64 architectures have fast 64-bit types; also x86_64
108 (which can be ILP32 for x32) and Win64 (which is LLP64). */
109 #if defined(__x86_64__cxx . . $ `<built-in>:374:9`!) || defined(__LP64__cxx . . $ `<built-in>:51:9`!) || defined(_WIN64)
110 #define OPUS_FAST_INT64cxx . . $ `external/opusfile/opus/celt/arch.h:110:9`! 1
111 #else
112 #define OPUS_FAST_INT64 0
113 #endif
114
115 #define PRINT_MIPScxx . . $ `external/opusfile/opus/celt/arch.h:115:9`!(file)
116
117 #ifdef FIXED_POINT
118
119 typedef opus_int16 opus_val16;
120 typedef opus_int32 opus_val32;
121 typedef opus_int64 opus_val64;
122
123 typedef opus_val32 celt_sig;
124 typedef opus_val16 celt_norm;
125 typedef opus_val32 celt_ener;
126
127 #define celt_isnan(x) 0
128
129 #define Q15ONE 32767
130
131 #define SIG_SHIFT 12
132 /* Safe saturation value for 32-bit signals. Should be less than
133 2^31*(1-0.85) to avoid blowing up on DC at deemphasis.*/
134 #define SIG_SAT (300000000)
135
136 #define NORM_SCALING 16384
137
138 #define DB_SHIFT 10
139
140 #define EPSILON 1
141 #define VERY_SMALL 0
142 #define VERY_LARGE16 ((opus_val16)32767)
143 #define Q15_ONE ((opus_val16)32767)
144
145 #define SCALEIN(a) (a)
146 #define SCALEOUT(a) (a)
147
148 #define ABS16(x) ((x) < 0 ? (-(x)) : (x))
149 #define ABS32(x) ((x) < 0 ? (-(x)) : (x))
150
151 static OPUS_INLINE opus_int16 SAT16(opus_int32 x) {
152 return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x;
153 }
154
155 #ifdef FIXED_DEBUG
156 #include "fixed_debug.h"
157 #else
158
159 #include "fixed_generic.h"
160
161 #ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR
162 #include "arm/fixed_arm64.h"
163 #elif defined (OPUS_ARM_INLINE_EDSP)
164 #include "arm/fixed_armv5e.h"
165 #elif defined (OPUS_ARM_INLINE_ASM)
166 #include "arm/fixed_armv4.h"
167 #elif defined (BFIN_ASM)
168 #include "fixed_bfin.h"
169 #elif defined (TI_C5X_ASM)
170 #include "fixed_c5x.h"
171 #elif defined (TI_C6X_ASM)
172 #include "fixed_c6x.h"
173 #endif
174
175 #endif
176
177 #else /* FIXED_POINT */
178
179 typedef float opus_val16cxx . . $ opus_val16#;
180 typedef float opus_val32cxx . . $ opus_val32#;
181 typedef float opus_val64cxx . . $ opus_val64#;
182
183 typedef float celt_sigcxx . . $ celt_sig#;
184 typedef float celt_normcxx . . $ celt_norm#;
185 typedef float celt_enercxx . . $ celt_ener#;
186
187 #ifdef FLOAT_APPROX
188 /* This code should reliably detect NaN/inf even when -ffast-math is used.
189 Assumes IEEE 754 format. */
190 static OPUS_INLINE int celt_isnan(float x)
191 {
192 union {float f; opus_uint32 i;} in;
193 in.f = x;
194 return ((in.i>>23)&0xFF)==0xFF && (in.i&0x007FFFFF)!=0;
195 }
196 #else
197 #ifdef __FAST_MATH__
198 #error Cannot build libopus with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input
199 #endif
200 #define celt_isnancxx . . $ `external/opusfile/opus/celt/arch.h:200:9`!(x) ((x)!=(x))
201 #endif
202
203 #define Q15ONEcxx . . $ `external/opusfile/opus/celt/arch.h:203:9`! 1.0f
204
205 #define NORM_SCALINGcxx . . $ `external/opusfile/opus/celt/arch.h:205:9`! 1.f
206
207 #define EPSILONcxx . . $ `external/opusfile/opus/celt/arch.h:207:9`! 1e-15f
208 #define VERY_SMALLcxx . . $ `external/opusfile/opus/celt/arch.h:208:9`! 1e-30f
209 #define VERY_LARGE16cxx . . $ `external/opusfile/opus/celt/arch.h:209:9`! 1e15f
210 #define Q15_ONEcxx . . $ `external/opusfile/opus/celt/arch.h:210:9`! ((opus_val16)1.f)
211
212 /* This appears to be the same speed as C99's fabsf() but it's more portable. */
213 #define ABS16cxx . . $ `external/opusfile/opus/celt/arch.h:213:9`!(x) ((float)fabs(x))
214 #define ABS32cxx . . $ `external/opusfile/opus/celt/arch.h:214:9`!(x) ((float)fabs(x))
215
216 #define QCONST16cxx . . $ `external/opusfile/opus/celt/arch.h:216:9`!(x,bits) (x)
217 #define QCONST32cxx . . $ `external/opusfile/opus/celt/arch.h:217:9`!(x,bits) (x)
218
219 #define NEG16cxx . . $ `external/opusfile/opus/celt/arch.h:219:9`!(x) (-(x))
220 #define NEG32cxx . . $ `external/opusfile/opus/celt/arch.h:220:9`!(x) (-(x))
221 #define NEG32_ovflwcxx . . $ `external/opusfile/opus/celt/arch.h:221:9`!(x) (-(x))
222 #define EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(x) (x)
223 #define EXTEND32cxx . . $ `external/opusfile/opus/celt/arch.h:223:9`!(x) (x)
224 #define SHR16cxx . . $ `external/opusfile/opus/celt/arch.h:224:9`!(a,shift) (a)
225 #define SHL16cxx . . $ `external/opusfile/opus/celt/arch.h:225:9`!(a,shift) (a)
226 #define SHR32cxx . . $ `external/opusfile/opus/celt/arch.h:226:9`!(a,shift) (a)
227 #define SHL32cxx . . $ `external/opusfile/opus/celt/arch.h:227:9`!(a,shift) (a)
228 #define PSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:228:9`!(a,shift) (a)
229 #define VSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:229:9`!(a,shift) (a)
230
231 #define PSHRcxx . . $ `external/opusfile/opus/celt/arch.h:231:9`!(a,shift) (a)
232 #define SHRcxx . . $ `external/opusfile/opus/celt/arch.h:232:9`!(a,shift) (a)
233 #define SHLcxx . . $ `external/opusfile/opus/celt/arch.h:233:9`!(a,shift) (a)
234 #define SATURATEcxx . . $ `external/opusfile/opus/celt/arch.h:234:9`!(x,a) (x)
235 #define SATURATE16cxx . . $ `external/opusfile/opus/celt/arch.h:235:9`!(x) (x)
236
237 #define ROUND16cxx . . $ `external/opusfile/opus/celt/arch.h:237:9`!(a,shift) (a)
238 #define SROUND16cxx . . $ `external/opusfile/opus/celt/arch.h:238:9`!(a,shift) (a)
239 #define HALF16cxx . . $ `external/opusfile/opus/celt/arch.h:239:9`!(x) (.5f*(x))
240 #define HALF32cxx . . $ `external/opusfile/opus/celt/arch.h:240:9`!(x) (.5f*(x))
241
242 #define ADD16cxx . . $ `external/opusfile/opus/celt/arch.h:242:9`!(a,b) ((a)+(b))
243 #define SUB16cxx . . $ `external/opusfile/opus/celt/arch.h:243:9`!(a,b) ((a)-(b))
244 #define ADD32cxx . . $ `external/opusfile/opus/celt/arch.h:244:9`!(a,b) ((a)+(b))
245 #define SUB32cxx . . $ `external/opusfile/opus/celt/arch.h:245:9`!(a,b) ((a)-(b))
246 #define ADD32_ovflwcxx . . $ `external/opusfile/opus/celt/arch.h:246:9`!(a,b) ((a)+(b))
247 #define SUB32_ovflwcxx . . $ `external/opusfile/opus/celt/arch.h:247:9`!(a,b) ((a)-(b))
248 #define MULT16_16_16cxx . . $ `external/opusfile/opus/celt/arch.h:248:9`!(a,b) ((a)*(b))
249 #define MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(a,b) ((opus_val32)(a)*(opus_val32)(b))
250 #define MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b))
251
252 #define MULT16_32_Q15cxx . . $ `external/opusfile/opus/celt/arch.h:252:9`!(a,b) ((a)*(b))
253 #define MULT16_32_Q16cxx . . $ `external/opusfile/opus/celt/arch.h:253:9`!(a,b) ((a)*(b))
254
255 #define MULT32_32_Q31cxx . . $ `external/opusfile/opus/celt/arch.h:255:9`!(a,b) ((a)*(b))
256
257 #define MAC16_32_Q15cxx . . $ `external/opusfile/opus/celt/arch.h:257:9`!(c,a,b) ((c)+(a)*(b))
258 #define MAC16_32_Q16cxx . . $ `external/opusfile/opus/celt/arch.h:258:9`!(c,a,b) ((c)+(a)*(b))
259
260 #define MULT16_16_Q11_32cxx . . $ `external/opusfile/opus/celt/arch.h:260:9`!(a,b) ((a)*(b))
261 #define MULT16_16_Q11cxx . . $ `external/opusfile/opus/celt/arch.h:261:9`!(a,b) ((a)*(b))
262 #define MULT16_16_Q13cxx . . $ `external/opusfile/opus/celt/arch.h:262:9`!(a,b) ((a)*(b))
263 #define MULT16_16_Q14cxx . . $ `external/opusfile/opus/celt/arch.h:263:9`!(a,b) ((a)*(b))
264 #define MULT16_16_Q15cxx . . $ `external/opusfile/opus/celt/arch.h:264:9`!(a,b) ((a)*(b))
265 #define MULT16_16_P15cxx . . $ `external/opusfile/opus/celt/arch.h:265:9`!(a,b) ((a)*(b))
266 #define MULT16_16_P13cxx . . $ `external/opusfile/opus/celt/arch.h:266:9`!(a,b) ((a)*(b))
267 #define MULT16_16_P14cxx . . $ `external/opusfile/opus/celt/arch.h:267:9`!(a,b) ((a)*(b))
268 #define MULT16_32_P16cxx . . $ `external/opusfile/opus/celt/arch.h:268:9`!(a,b) ((a)*(b))
269
270 #define DIV32_16cxx . . $ `external/opusfile/opus/celt/arch.h:270:9`!(a,b) (((opus_val32)(a))/(opus_val16)(b))
271 #define DIV32cxx . . $ `external/opusfile/opus/celt/arch.h:271:9`!(a,b) (((opus_val32)(a))/(opus_val32)(b))
272
273 #define SCALEINcxx . . $ `external/opusfile/opus/celt/arch.h:273:9`!(a) ((a)*CELT_SIG_SCALE)
274 #define SCALEOUTcxx . . $ `external/opusfile/opus/celt/arch.h:274:9`!(a) ((a)*(1/CELT_SIG_SCALE))
275
276 #define SIG2WORD16cxx . . $ `external/opusfile/opus/celt/arch.h:276:9`!(x) (x)
277
278 #endif /* !FIXED_POINT */
279
280 #ifndef GLOBAL_STACK_SIZE
281 #ifdef FIXED_POINT
282 #define GLOBAL_STACK_SIZE 120000
283 #else
284 #define GLOBAL_STACK_SIZEcxx . . $ `external/opusfile/opus/celt/arch.h:284:9`! 120000
285 #endif
286 #endif
287
288 #endif /* ARCH_H */