Skip to content

Latest commit

 

History

History
710 lines (632 loc) · 20.3 KB

MacroCount.h

File metadata and controls

710 lines (632 loc) · 20.3 KB
 
1
2
3
4
5
6
7
8
9
10
/***********************************************************************
Copyright (c) 2006-2011, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Oct 6, 2019
Oct 6, 2019
11
- Neither the name of Internet Society, IETF or IETF Trust, nor the
12
13
14
names of specific contributors, may be used to endorse or promote
products derived from this software without specific prior written
permission.
Oct 6, 2019
Oct 6, 2019
15
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef SIGPROCFIX_API_MACROCOUNT_H
#define SIGPROCFIX_API_MACROCOUNT_H
#include <stdio.h>
#ifdef silk_MACRO_COUNT
#define varDefine opus_int64 ops_count = 0;
extern opus_int64 ops_count;
Oct 6, 2019
Oct 6, 2019
37
static OPUS_INLINE opus_int64 silk_SaveCount(){
38
39
40
return(ops_count);
}
Oct 6, 2019
Oct 6, 2019
41
static OPUS_INLINE opus_int64 silk_SaveResetCount(){
42
43
44
45
46
47
48
opus_int64 ret;
ret = ops_count;
ops_count = 0;
return(ret);
}
Oct 6, 2019
Oct 6, 2019
49
static OPUS_INLINE silk_PrintCount(){
50
51
52
53
printf("ops_count = %d \n ", (opus_int32)ops_count);
}
#undef silk_MUL
Oct 6, 2019
Oct 6, 2019
54
static OPUS_INLINE opus_int32 silk_MUL(opus_int32 a32, opus_int32 b32){
55
56
57
58
59
60
61
opus_int32 ret;
ops_count += 4;
ret = a32 * b32;
return ret;
}
#undef silk_MUL_uint
Oct 6, 2019
Oct 6, 2019
62
static OPUS_INLINE opus_uint32 silk_MUL_uint(opus_uint32 a32, opus_uint32 b32){
63
64
65
66
67
68
opus_uint32 ret;
ops_count += 4;
ret = a32 * b32;
return ret;
}
#undef silk_MLA
Oct 6, 2019
Oct 6, 2019
69
static OPUS_INLINE opus_int32 silk_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){
70
71
72
73
74
75
76
opus_int32 ret;
ops_count += 4;
ret = a32 + b32 * c32;
return ret;
}
#undef silk_MLA_uint
Oct 6, 2019
Oct 6, 2019
77
static OPUS_INLINE opus_int32 silk_MLA_uint(opus_uint32 a32, opus_uint32 b32, opus_uint32 c32){
78
79
80
81
82
83
84
opus_uint32 ret;
ops_count += 4;
ret = a32 + b32 * c32;
return ret;
}
#undef silk_SMULWB
Oct 6, 2019
Oct 6, 2019
85
static OPUS_INLINE opus_int32 silk_SMULWB(opus_int32 a32, opus_int32 b32){
86
87
88
89
90
91
opus_int32 ret;
ops_count += 5;
ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16);
return ret;
}
#undef silk_SMLAWB
Oct 6, 2019
Oct 6, 2019
92
static OPUS_INLINE opus_int32 silk_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
93
94
95
96
97
98
99
opus_int32 ret;
ops_count += 5;
ret = ((a32) + ((((b32) >> 16) * (opus_int32)((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32))) >> 16)));
return ret;
}
#undef silk_SMULWT
Oct 6, 2019
Oct 6, 2019
100
static OPUS_INLINE opus_int32 silk_SMULWT(opus_int32 a32, opus_int32 b32){
101
102
103
104
105
106
opus_int32 ret;
ops_count += 4;
ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16);
return ret;
}
#undef silk_SMLAWT
Oct 6, 2019
Oct 6, 2019
107
static OPUS_INLINE opus_int32 silk_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
108
109
110
111
112
113
114
opus_int32 ret;
ops_count += 4;
ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16));
return ret;
}
#undef silk_SMULBB
Oct 6, 2019
Oct 6, 2019
115
static OPUS_INLINE opus_int32 silk_SMULBB(opus_int32 a32, opus_int32 b32){
116
117
118
119
120
121
opus_int32 ret;
ops_count += 1;
ret = (opus_int32)((opus_int16)a32) * (opus_int32)((opus_int16)b32);
return ret;
}
#undef silk_SMLABB
Oct 6, 2019
Oct 6, 2019
122
static OPUS_INLINE opus_int32 silk_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
123
124
125
126
127
128
129
opus_int32 ret;
ops_count += 1;
ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32);
return ret;
}
#undef silk_SMULBT
Oct 6, 2019
Oct 6, 2019
130
static OPUS_INLINE opus_int32 silk_SMULBT(opus_int32 a32, opus_int32 b32 ){
131
132
133
134
135
136
137
opus_int32 ret;
ops_count += 4;
ret = ((opus_int32)((opus_int16)a32)) * (b32 >> 16);
return ret;
}
#undef silk_SMLABT
Oct 6, 2019
Oct 6, 2019
138
static OPUS_INLINE opus_int32 silk_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
139
140
141
142
143
144
145
opus_int32 ret;
ops_count += 1;
ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16);
return ret;
}
#undef silk_SMULTT
Oct 6, 2019
Oct 6, 2019
146
static OPUS_INLINE opus_int32 silk_SMULTT(opus_int32 a32, opus_int32 b32){
147
148
149
150
151
152
153
opus_int32 ret;
ops_count += 1;
ret = (a32 >> 16) * (b32 >> 16);
return ret;
}
#undef silk_SMLATT
Oct 6, 2019
Oct 6, 2019
154
static OPUS_INLINE opus_int32 silk_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
opus_int32 ret;
ops_count += 1;
ret = a32 + (b32 >> 16) * (c32 >> 16);
return ret;
}
/* multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)*/
#undef silk_MLA_ovflw
#define silk_MLA_ovflw silk_MLA
#undef silk_SMLABB_ovflw
#define silk_SMLABB_ovflw silk_SMLABB
#undef silk_SMLABT_ovflw
#define silk_SMLABT_ovflw silk_SMLABT
#undef silk_SMLATT_ovflw
#define silk_SMLATT_ovflw silk_SMLATT
#undef silk_SMLAWB_ovflw
#define silk_SMLAWB_ovflw silk_SMLAWB
#undef silk_SMLAWT_ovflw
#define silk_SMLAWT_ovflw silk_SMLAWT
#undef silk_SMULL
Oct 6, 2019
Oct 6, 2019
182
static OPUS_INLINE opus_int64 silk_SMULL(opus_int32 a32, opus_int32 b32){
183
184
185
186
187
188
189
opus_int64 ret;
ops_count += 8;
ret = ((opus_int64)(a32) * /*(opus_int64)*/(b32));
return ret;
}
#undef silk_SMLAL
Oct 6, 2019
Oct 6, 2019
190
static OPUS_INLINE opus_int64 silk_SMLAL(opus_int64 a64, opus_int32 b32, opus_int32 c32){
191
192
193
194
195
196
opus_int64 ret;
ops_count += 8;
ret = a64 + ((opus_int64)(b32) * /*(opus_int64)*/(c32));
return ret;
}
#undef silk_SMLALBB
Oct 6, 2019
Oct 6, 2019
197
static OPUS_INLINE opus_int64 silk_SMLALBB(opus_int64 a64, opus_int16 b16, opus_int16 c16){
198
199
200
201
202
203
204
opus_int64 ret;
ops_count += 4;
ret = a64 + ((opus_int64)(b16) * /*(opus_int64)*/(c16));
return ret;
}
#undef SigProcFIX_CLZ16
Oct 6, 2019
Oct 6, 2019
205
static OPUS_INLINE opus_int32 SigProcFIX_CLZ16(opus_int16 in16)
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
{
opus_int32 out32 = 0;
ops_count += 10;
if( in16 == 0 ) {
return 16;
}
/* test nibbles */
if( in16 & 0xFF00 ) {
if( in16 & 0xF000 ) {
in16 >>= 12;
} else {
out32 += 4;
in16 >>= 8;
}
} else {
if( in16 & 0xFFF0 ) {
out32 += 8;
in16 >>= 4;
} else {
out32 += 12;
}
}
/* test bits and return */
if( in16 & 0xC ) {
if( in16 & 0x8 )
return out32 + 0;
else
return out32 + 1;
} else {
if( in16 & 0xE )
return out32 + 2;
else
return out32 + 3;
}
}
#undef SigProcFIX_CLZ32
Oct 6, 2019
Oct 6, 2019
243
static OPUS_INLINE opus_int32 SigProcFIX_CLZ32(opus_int32 in32)
244
245
246
247
248
249
250
251
252
253
254
{
/* test highest 16 bits and convert to opus_int16 */
ops_count += 2;
if( in32 & 0xFFFF0000 ) {
return SigProcFIX_CLZ16((opus_int16)(in32 >> 16));
} else {
return SigProcFIX_CLZ16((opus_int16)in32) + 16;
}
}
#undef silk_DIV32
Oct 6, 2019
Oct 6, 2019
255
static OPUS_INLINE opus_int32 silk_DIV32(opus_int32 a32, opus_int32 b32){
256
257
258
259
260
ops_count += 64;
return a32 / b32;
}
#undef silk_DIV32_16
Oct 6, 2019
Oct 6, 2019
261
static OPUS_INLINE opus_int32 silk_DIV32_16(opus_int32 a32, opus_int32 b32){
262
263
264
265
266
ops_count += 32;
return a32 / b32;
}
#undef silk_SAT8
Oct 6, 2019
Oct 6, 2019
267
static OPUS_INLINE opus_int8 silk_SAT8(opus_int64 a){
268
269
270
271
272
273
274
275
opus_int8 tmp;
ops_count += 1;
tmp = (opus_int8)((a) > silk_int8_MAX ? silk_int8_MAX : \
((a) < silk_int8_MIN ? silk_int8_MIN : (a)));
return(tmp);
}
#undef silk_SAT16
Oct 6, 2019
Oct 6, 2019
276
static OPUS_INLINE opus_int16 silk_SAT16(opus_int64 a){
277
278
279
280
281
282
283
opus_int16 tmp;
ops_count += 1;
tmp = (opus_int16)((a) > silk_int16_MAX ? silk_int16_MAX : \
((a) < silk_int16_MIN ? silk_int16_MIN : (a)));
return(tmp);
}
#undef silk_SAT32
Oct 6, 2019
Oct 6, 2019
284
static OPUS_INLINE opus_int32 silk_SAT32(opus_int64 a){
285
286
287
288
289
290
291
opus_int32 tmp;
ops_count += 1;
tmp = (opus_int32)((a) > silk_int32_MAX ? silk_int32_MAX : \
((a) < silk_int32_MIN ? silk_int32_MIN : (a)));
return(tmp);
}
#undef silk_POS_SAT32
Oct 6, 2019
Oct 6, 2019
292
static OPUS_INLINE opus_int32 silk_POS_SAT32(opus_int64 a){
293
294
295
296
297
298
299
opus_int32 tmp;
ops_count += 1;
tmp = (opus_int32)((a) > silk_int32_MAX ? silk_int32_MAX : (a));
return(tmp);
}
#undef silk_ADD_POS_SAT8
Oct 6, 2019
Oct 6, 2019
300
static OPUS_INLINE opus_int8 silk_ADD_POS_SAT8(opus_int64 a, opus_int64 b){
301
302
303
304
305
306
opus_int8 tmp;
ops_count += 1;
tmp = (opus_int8)((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b)));
return(tmp);
}
#undef silk_ADD_POS_SAT16
Oct 6, 2019
Oct 6, 2019
307
static OPUS_INLINE opus_int16 silk_ADD_POS_SAT16(opus_int64 a, opus_int64 b){
308
309
310
311
312
313
314
opus_int16 tmp;
ops_count += 1;
tmp = (opus_int16)((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b)));
return(tmp);
}
#undef silk_ADD_POS_SAT32
Oct 6, 2019
Oct 6, 2019
315
static OPUS_INLINE opus_int32 silk_ADD_POS_SAT32(opus_int64 a, opus_int64 b){
316
317
318
319
320
321
322
opus_int32 tmp;
ops_count += 1;
tmp = (opus_int32)((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b)));
return(tmp);
}
#undef silk_LSHIFT8
Oct 6, 2019
Oct 6, 2019
323
static OPUS_INLINE opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){
324
325
326
327
328
329
opus_int8 ret;
ops_count += 1;
ret = a << shift;
return ret;
}
#undef silk_LSHIFT16
Oct 6, 2019
Oct 6, 2019
330
static OPUS_INLINE opus_int16 silk_LSHIFT16(opus_int16 a, opus_int32 shift){
331
332
333
334
335
336
opus_int16 ret;
ops_count += 1;
ret = a << shift;
return ret;
}
#undef silk_LSHIFT32
Oct 6, 2019
Oct 6, 2019
337
static OPUS_INLINE opus_int32 silk_LSHIFT32(opus_int32 a, opus_int32 shift){
338
339
340
341
342
343
opus_int32 ret;
ops_count += 1;
ret = a << shift;
return ret;
}
#undef silk_LSHIFT64
Oct 6, 2019
Oct 6, 2019
344
static OPUS_INLINE opus_int64 silk_LSHIFT64(opus_int64 a, opus_int shift){
345
346
347
348
349
ops_count += 1;
return a << shift;
}
#undef silk_LSHIFT_ovflw
Oct 6, 2019
Oct 6, 2019
350
static OPUS_INLINE opus_int32 silk_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){
351
352
353
354
355
ops_count += 1;
return a << shift;
}
#undef silk_LSHIFT_uint
Oct 6, 2019
Oct 6, 2019
356
static OPUS_INLINE opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){
357
358
359
360
361
362
363
opus_uint32 ret;
ops_count += 1;
ret = a << shift;
return ret;
}
#undef silk_RSHIFT8
Oct 6, 2019
Oct 6, 2019
364
static OPUS_INLINE opus_int8 silk_RSHIFT8(opus_int8 a, opus_int32 shift){
365
366
367
368
ops_count += 1;
return a >> shift;
}
#undef silk_RSHIFT16
Oct 6, 2019
Oct 6, 2019
369
static OPUS_INLINE opus_int16 silk_RSHIFT16(opus_int16 a, opus_int32 shift){
370
371
372
373
ops_count += 1;
return a >> shift;
}
#undef silk_RSHIFT32
Oct 6, 2019
Oct 6, 2019
374
static OPUS_INLINE opus_int32 silk_RSHIFT32(opus_int32 a, opus_int32 shift){
375
376
377
378
ops_count += 1;
return a >> shift;
}
#undef silk_RSHIFT64
Oct 6, 2019
Oct 6, 2019
379
static OPUS_INLINE opus_int64 silk_RSHIFT64(opus_int64 a, opus_int64 shift){
380
381
382
383
384
ops_count += 1;
return a >> shift;
}
#undef silk_RSHIFT_uint
Oct 6, 2019
Oct 6, 2019
385
static OPUS_INLINE opus_uint32 silk_RSHIFT_uint(opus_uint32 a, opus_int32 shift){
386
387
388
389
390
ops_count += 1;
return a >> shift;
}
#undef silk_ADD_LSHIFT
Oct 6, 2019
Oct 6, 2019
391
static OPUS_INLINE opus_int32 silk_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
392
393
394
395
396
397
opus_int32 ret;
ops_count += 1;
ret = a + (b << shift);
return ret; /* shift >= 0*/
}
#undef silk_ADD_LSHIFT32
Oct 6, 2019
Oct 6, 2019
398
static OPUS_INLINE opus_int32 silk_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
399
400
401
402
403
404
opus_int32 ret;
ops_count += 1;
ret = a + (b << shift);
return ret; /* shift >= 0*/
}
#undef silk_ADD_LSHIFT_uint
Oct 6, 2019
Oct 6, 2019
405
static OPUS_INLINE opus_uint32 silk_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
406
407
408
409
410
411
opus_uint32 ret;
ops_count += 1;
ret = a + (b << shift);
return ret; /* shift >= 0*/
}
#undef silk_ADD_RSHIFT
Oct 6, 2019
Oct 6, 2019
412
static OPUS_INLINE opus_int32 silk_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
413
414
415
416
417
418
opus_int32 ret;
ops_count += 1;
ret = a + (b >> shift);
return ret; /* shift > 0*/
}
#undef silk_ADD_RSHIFT32
Oct 6, 2019
Oct 6, 2019
419
static OPUS_INLINE opus_int32 silk_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
420
421
422
423
424
425
opus_int32 ret;
ops_count += 1;
ret = a + (b >> shift);
return ret; /* shift > 0*/
}
#undef silk_ADD_RSHIFT_uint
Oct 6, 2019
Oct 6, 2019
426
static OPUS_INLINE opus_uint32 silk_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
427
428
429
430
431
432
opus_uint32 ret;
ops_count += 1;
ret = a + (b >> shift);
return ret; /* shift > 0*/
}
#undef silk_SUB_LSHIFT32
Oct 6, 2019
Oct 6, 2019
433
static OPUS_INLINE opus_int32 silk_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
434
435
436
437
438
439
opus_int32 ret;
ops_count += 1;
ret = a - (b << shift);
return ret; /* shift >= 0*/
}
#undef silk_SUB_RSHIFT32
Oct 6, 2019
Oct 6, 2019
440
static OPUS_INLINE opus_int32 silk_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
441
442
443
444
445
446
447
opus_int32 ret;
ops_count += 1;
ret = a - (b >> shift);
return ret; /* shift > 0*/
}
#undef silk_RSHIFT_ROUND
Oct 6, 2019
Oct 6, 2019
448
static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){
449
450
451
452
453
454
455
opus_int32 ret;
ops_count += 3;
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
return ret;
}
#undef silk_RSHIFT_ROUND64
Oct 6, 2019
Oct 6, 2019
456
static OPUS_INLINE opus_int64 silk_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){
457
458
459
460
461
462
463
opus_int64 ret;
ops_count += 6;
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
return ret;
}
#undef silk_abs_int64
Oct 6, 2019
Oct 6, 2019
464
static OPUS_INLINE opus_int64 silk_abs_int64(opus_int64 a){
465
466
467
468
469
ops_count += 1;
return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN*/
}
#undef silk_abs_int32
Oct 6, 2019
Oct 6, 2019
470
static OPUS_INLINE opus_int32 silk_abs_int32(opus_int32 a){
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
ops_count += 1;
return silk_abs(a);
}
#undef silk_min
static silk_min(a, b){
ops_count += 1;
return (((a) < (b)) ? (a) : (b));
}
#undef silk_max
static silk_max(a, b){
ops_count += 1;
return (((a) > (b)) ? (a) : (b));
}
#undef silk_sign
static silk_sign(a){
ops_count += 1;
return ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ));
}
#undef silk_ADD16
Oct 6, 2019
Oct 6, 2019
493
static OPUS_INLINE opus_int16 silk_ADD16(opus_int16 a, opus_int16 b){
494
495
496
497
498
499
500
opus_int16 ret;
ops_count += 1;
ret = a + b;
return ret;
}
#undef silk_ADD32
Oct 6, 2019
Oct 6, 2019
501
static OPUS_INLINE opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){
502
503
504
505
506
507
508
opus_int32 ret;
ops_count += 1;
ret = a + b;
return ret;
}
#undef silk_ADD64
Oct 6, 2019
Oct 6, 2019
509
static OPUS_INLINE opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){
510
511
512
513
514
515
516
opus_int64 ret;
ops_count += 2;
ret = a + b;
return ret;
}
#undef silk_SUB16
Oct 6, 2019
Oct 6, 2019
517
static OPUS_INLINE opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){
518
519
520
521
522
523
524
opus_int16 ret;
ops_count += 1;
ret = a - b;
return ret;
}
#undef silk_SUB32
Oct 6, 2019
Oct 6, 2019
525
static OPUS_INLINE opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){
526
527
528
529
530
531
532
opus_int32 ret;
ops_count += 1;
ret = a - b;
return ret;
}
#undef silk_SUB64
Oct 6, 2019
Oct 6, 2019
533
static OPUS_INLINE opus_int64 silk_SUB64(opus_int64 a, opus_int64 b){
534
535
536
537
538
539
540
opus_int64 ret;
ops_count += 2;
ret = a - b;
return ret;
}
#undef silk_ADD_SAT16
Oct 6, 2019
Oct 6, 2019
541
static OPUS_INLINE opus_int16 silk_ADD_SAT16( opus_int16 a16, opus_int16 b16 ) {
542
543
544
545
546
547
548
opus_int16 res;
/* Nb will be counted in AKP_add32 and silk_SAT16*/
res = (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a16), (b16) ) );
return res;
}
#undef silk_ADD_SAT32
Oct 6, 2019
Oct 6, 2019
549
static OPUS_INLINE opus_int32 silk_ADD_SAT32(opus_int32 a32, opus_int32 b32){
550
551
552
553
554
555
556
557
558
opus_int32 res;
ops_count += 1;
res = ((((a32) + (b32)) & 0x80000000) == 0 ? \
((((a32) & (b32)) & 0x80000000) != 0 ? silk_int32_MIN : (a32)+(b32)) : \
((((a32) | (b32)) & 0x80000000) == 0 ? silk_int32_MAX : (a32)+(b32)) );
return res;
}
#undef silk_ADD_SAT64
Oct 6, 2019
Oct 6, 2019
559
static OPUS_INLINE opus_int64 silk_ADD_SAT64( opus_int64 a64, opus_int64 b64 ) {
560
561
562
563
564
565
566
567
568
opus_int64 res;
ops_count += 1;
res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \
((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a64)+(b64)) : \
((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a64)+(b64)) );
return res;
}
#undef silk_SUB_SAT16
Oct 6, 2019
Oct 6, 2019
569
static OPUS_INLINE opus_int16 silk_SUB_SAT16( opus_int16 a16, opus_int16 b16 ) {
570
571
572
573
574
575
576
577
opus_int16 res;
silk_assert(0);
/* Nb will be counted in sub-macros*/
res = (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a16), (b16) ) );
return res;
}
#undef silk_SUB_SAT32
Oct 6, 2019
Oct 6, 2019
578
static OPUS_INLINE opus_int32 silk_SUB_SAT32( opus_int32 a32, opus_int32 b32 ) {
579
580
581
582
583
584
585
586
587
opus_int32 res;
ops_count += 1;
res = ((((a32)-(b32)) & 0x80000000) == 0 ? \
(( (a32) & ((b32)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a32)-(b32)) : \
((((a32)^0x80000000) & (b32) & 0x80000000) ? silk_int32_MAX : (a32)-(b32)) );
return res;
}
#undef silk_SUB_SAT64
Oct 6, 2019
Oct 6, 2019
588
static OPUS_INLINE opus_int64 silk_SUB_SAT64( opus_int64 a64, opus_int64 b64 ) {
589
590
591
592
593
594
595
596
597
598
opus_int64 res;
ops_count += 1;
res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \
(( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a64)-(b64)) : \
((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? silk_int64_MAX : (a64)-(b64)) );
return res;
}
#undef silk_SMULWW
Oct 6, 2019
Oct 6, 2019
599
static OPUS_INLINE opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){
600
601
602
603
604
605
606
opus_int32 ret;
/* Nb will be counted in sub-macros*/
ret = silk_MLA(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16));
return ret;
}
#undef silk_SMLAWW
Oct 6, 2019
Oct 6, 2019
607
static OPUS_INLINE opus_int32 silk_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){
608
609
610
611
612
613
614
opus_int32 ret;
/* Nb will be counted in sub-macros*/
ret = silk_MLA(silk_SMLAWB((a32), (b32), (c32)), (b32), silk_RSHIFT_ROUND((c32), 16));
return ret;
}
#undef silk_min_int
Oct 6, 2019
Oct 6, 2019
615
static OPUS_INLINE opus_int silk_min_int(opus_int a, opus_int b)
616
617
618
619
620
621
{
ops_count += 1;
return (((a) < (b)) ? (a) : (b));
}
#undef silk_min_16
Oct 6, 2019
Oct 6, 2019
622
static OPUS_INLINE opus_int16 silk_min_16(opus_int16 a, opus_int16 b)
623
624
625
626
627
{
ops_count += 1;
return (((a) < (b)) ? (a) : (b));
}
#undef silk_min_32
Oct 6, 2019
Oct 6, 2019
628
static OPUS_INLINE opus_int32 silk_min_32(opus_int32 a, opus_int32 b)
629
630
631
632
633
{
ops_count += 1;
return (((a) < (b)) ? (a) : (b));
}
#undef silk_min_64
Oct 6, 2019
Oct 6, 2019
634
static OPUS_INLINE opus_int64 silk_min_64(opus_int64 a, opus_int64 b)
635
636
637
638
639
640
641
{
ops_count += 1;
return (((a) < (b)) ? (a) : (b));
}
/* silk_min() versions with typecast in the function call */
#undef silk_max_int
Oct 6, 2019
Oct 6, 2019
642
static OPUS_INLINE opus_int silk_max_int(opus_int a, opus_int b)
643
644
645
646
647
{
ops_count += 1;
return (((a) > (b)) ? (a) : (b));
}
#undef silk_max_16
Oct 6, 2019
Oct 6, 2019
648
static OPUS_INLINE opus_int16 silk_max_16(opus_int16 a, opus_int16 b)
649
650
651
652
653
{
ops_count += 1;
return (((a) > (b)) ? (a) : (b));
}
#undef silk_max_32
Oct 6, 2019
Oct 6, 2019
654
static OPUS_INLINE opus_int32 silk_max_32(opus_int32 a, opus_int32 b)
655
656
657
658
659
660
{
ops_count += 1;
return (((a) > (b)) ? (a) : (b));
}
#undef silk_max_64
Oct 6, 2019
Oct 6, 2019
661
static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b)
662
663
664
665
666
667
668
{
ops_count += 1;
return (((a) > (b)) ? (a) : (b));
}
#undef silk_LIMIT_int
Oct 6, 2019
Oct 6, 2019
669
static OPUS_INLINE opus_int silk_LIMIT_int(opus_int a, opus_int limit1, opus_int limit2)
670
671
672
673
674
675
676
677
678
679
680
{
opus_int ret;
ops_count += 6;
ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
: ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))));
return(ret);
}
#undef silk_LIMIT_16
Oct 6, 2019
Oct 6, 2019
681
static OPUS_INLINE opus_int16 silk_LIMIT_16(opus_int16 a, opus_int16 limit1, opus_int16 limit2)
682
683
684
685
686
687
688
689
690
691
692
693
{
opus_int16 ret;
ops_count += 6;
ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
: ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))));
return(ret);
}
#undef silk_LIMIT_32
Oct 6, 2019
Oct 6, 2019
694
static OPUS_INLINE opus_int32 silk_LIMIT_32(opus_int32 a, opus_int32 limit1, opus_int32 limit2)
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
{
opus_int32 ret;
ops_count += 6;
ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
: ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))));
return(ret);
}
#else
#define varDefine
#define silk_SaveCount()
#endif
#endif