annotate src/opus-1.3/silk/MacroCount.h @ 77:4edcd14160a5 pa_catalina

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