1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libopus/silk/MacroCount.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,718 @@ 1.4 +/*********************************************************************** 1.5 +Copyright (c) 2006-2011, Skype Limited. All rights reserved. 1.6 +Redistribution and use in source and binary forms, with or without 1.7 +modification, are permitted provided that the following conditions 1.8 +are met: 1.9 +- Redistributions of source code must retain the above copyright notice, 1.10 +this list of conditions and the following disclaimer. 1.11 +- Redistributions in binary form must reproduce the above copyright 1.12 +notice, this list of conditions and the following disclaimer in the 1.13 +documentation and/or other materials provided with the distribution. 1.14 +- Neither the name of Internet Society, IETF or IETF Trust, nor the 1.15 +names of specific contributors, may be used to endorse or promote 1.16 +products derived from this software without specific prior written 1.17 +permission. 1.18 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1.19 +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.20 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1.21 +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 1.22 +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 1.23 +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 1.24 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 1.25 +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 1.26 +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 1.27 +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1.28 +POSSIBILITY OF SUCH DAMAGE. 1.29 +***********************************************************************/ 1.30 + 1.31 +#ifndef SIGPROCFIX_API_MACROCOUNT_H 1.32 +#define SIGPROCFIX_API_MACROCOUNT_H 1.33 +#include <stdio.h> 1.34 + 1.35 +#ifdef silk_MACRO_COUNT 1.36 +#define varDefine opus_int64 ops_count = 0; 1.37 + 1.38 +extern opus_int64 ops_count; 1.39 + 1.40 +static OPUS_INLINE opus_int64 silk_SaveCount(){ 1.41 + return(ops_count); 1.42 +} 1.43 + 1.44 +static OPUS_INLINE opus_int64 silk_SaveResetCount(){ 1.45 + opus_int64 ret; 1.46 + 1.47 + ret = ops_count; 1.48 + ops_count = 0; 1.49 + return(ret); 1.50 +} 1.51 + 1.52 +static OPUS_INLINE silk_PrintCount(){ 1.53 + printf("ops_count = %d \n ", (opus_int32)ops_count); 1.54 +} 1.55 + 1.56 +#undef silk_MUL 1.57 +static OPUS_INLINE opus_int32 silk_MUL(opus_int32 a32, opus_int32 b32){ 1.58 + opus_int32 ret; 1.59 + ops_count += 4; 1.60 + ret = a32 * b32; 1.61 + return ret; 1.62 +} 1.63 + 1.64 +#undef silk_MUL_uint 1.65 +static OPUS_INLINE opus_uint32 silk_MUL_uint(opus_uint32 a32, opus_uint32 b32){ 1.66 + opus_uint32 ret; 1.67 + ops_count += 4; 1.68 + ret = a32 * b32; 1.69 + return ret; 1.70 +} 1.71 +#undef silk_MLA 1.72 +static OPUS_INLINE opus_int32 silk_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){ 1.73 + opus_int32 ret; 1.74 + ops_count += 4; 1.75 + ret = a32 + b32 * c32; 1.76 + return ret; 1.77 +} 1.78 + 1.79 +#undef silk_MLA_uint 1.80 +static OPUS_INLINE opus_int32 silk_MLA_uint(opus_uint32 a32, opus_uint32 b32, opus_uint32 c32){ 1.81 + opus_uint32 ret; 1.82 + ops_count += 4; 1.83 + ret = a32 + b32 * c32; 1.84 + return ret; 1.85 +} 1.86 + 1.87 +#undef silk_SMULWB 1.88 +static OPUS_INLINE opus_int32 silk_SMULWB(opus_int32 a32, opus_int32 b32){ 1.89 + opus_int32 ret; 1.90 + ops_count += 5; 1.91 + ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16); 1.92 + return ret; 1.93 +} 1.94 +#undef silk_SMLAWB 1.95 +static OPUS_INLINE opus_int32 silk_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){ 1.96 + opus_int32 ret; 1.97 + ops_count += 5; 1.98 + ret = ((a32) + ((((b32) >> 16) * (opus_int32)((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32))) >> 16))); 1.99 + return ret; 1.100 +} 1.101 + 1.102 +#undef silk_SMULWT 1.103 +static OPUS_INLINE opus_int32 silk_SMULWT(opus_int32 a32, opus_int32 b32){ 1.104 + opus_int32 ret; 1.105 + ops_count += 4; 1.106 + ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16); 1.107 + return ret; 1.108 +} 1.109 +#undef silk_SMLAWT 1.110 +static OPUS_INLINE opus_int32 silk_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ 1.111 + opus_int32 ret; 1.112 + ops_count += 4; 1.113 + ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16)); 1.114 + return ret; 1.115 +} 1.116 + 1.117 +#undef silk_SMULBB 1.118 +static OPUS_INLINE opus_int32 silk_SMULBB(opus_int32 a32, opus_int32 b32){ 1.119 + opus_int32 ret; 1.120 + ops_count += 1; 1.121 + ret = (opus_int32)((opus_int16)a32) * (opus_int32)((opus_int16)b32); 1.122 + return ret; 1.123 +} 1.124 +#undef silk_SMLABB 1.125 +static OPUS_INLINE opus_int32 silk_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32 c32){ 1.126 + opus_int32 ret; 1.127 + ops_count += 1; 1.128 + ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32); 1.129 + return ret; 1.130 +} 1.131 + 1.132 +#undef silk_SMULBT 1.133 +static OPUS_INLINE opus_int32 silk_SMULBT(opus_int32 a32, opus_int32 b32 ){ 1.134 + opus_int32 ret; 1.135 + ops_count += 4; 1.136 + ret = ((opus_int32)((opus_int16)a32)) * (b32 >> 16); 1.137 + return ret; 1.138 +} 1.139 + 1.140 +#undef silk_SMLABT 1.141 +static OPUS_INLINE opus_int32 silk_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ 1.142 + opus_int32 ret; 1.143 + ops_count += 1; 1.144 + ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16); 1.145 + return ret; 1.146 +} 1.147 + 1.148 +#undef silk_SMULTT 1.149 +static OPUS_INLINE opus_int32 silk_SMULTT(opus_int32 a32, opus_int32 b32){ 1.150 + opus_int32 ret; 1.151 + ops_count += 1; 1.152 + ret = (a32 >> 16) * (b32 >> 16); 1.153 + return ret; 1.154 +} 1.155 + 1.156 +#undef silk_SMLATT 1.157 +static OPUS_INLINE opus_int32 silk_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ 1.158 + opus_int32 ret; 1.159 + ops_count += 1; 1.160 + ret = a32 + (b32 >> 16) * (c32 >> 16); 1.161 + return ret; 1.162 +} 1.163 + 1.164 + 1.165 +/* multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)*/ 1.166 +#undef silk_MLA_ovflw 1.167 +#define silk_MLA_ovflw silk_MLA 1.168 + 1.169 +#undef silk_SMLABB_ovflw 1.170 +#define silk_SMLABB_ovflw silk_SMLABB 1.171 + 1.172 +#undef silk_SMLABT_ovflw 1.173 +#define silk_SMLABT_ovflw silk_SMLABT 1.174 + 1.175 +#undef silk_SMLATT_ovflw 1.176 +#define silk_SMLATT_ovflw silk_SMLATT 1.177 + 1.178 +#undef silk_SMLAWB_ovflw 1.179 +#define silk_SMLAWB_ovflw silk_SMLAWB 1.180 + 1.181 +#undef silk_SMLAWT_ovflw 1.182 +#define silk_SMLAWT_ovflw silk_SMLAWT 1.183 + 1.184 +#undef silk_SMULL 1.185 +static OPUS_INLINE opus_int64 silk_SMULL(opus_int32 a32, opus_int32 b32){ 1.186 + opus_int64 ret; 1.187 + ops_count += 8; 1.188 + ret = ((opus_int64)(a32) * /*(opus_int64)*/(b32)); 1.189 + return ret; 1.190 +} 1.191 + 1.192 +#undef silk_SMLAL 1.193 +static OPUS_INLINE opus_int64 silk_SMLAL(opus_int64 a64, opus_int32 b32, opus_int32 c32){ 1.194 + opus_int64 ret; 1.195 + ops_count += 8; 1.196 + ret = a64 + ((opus_int64)(b32) * /*(opus_int64)*/(c32)); 1.197 + return ret; 1.198 +} 1.199 +#undef silk_SMLALBB 1.200 +static OPUS_INLINE opus_int64 silk_SMLALBB(opus_int64 a64, opus_int16 b16, opus_int16 c16){ 1.201 + opus_int64 ret; 1.202 + ops_count += 4; 1.203 + ret = a64 + ((opus_int64)(b16) * /*(opus_int64)*/(c16)); 1.204 + return ret; 1.205 +} 1.206 + 1.207 +#undef SigProcFIX_CLZ16 1.208 +static OPUS_INLINE opus_int32 SigProcFIX_CLZ16(opus_int16 in16) 1.209 +{ 1.210 + opus_int32 out32 = 0; 1.211 + ops_count += 10; 1.212 + if( in16 == 0 ) { 1.213 + return 16; 1.214 + } 1.215 + /* test nibbles */ 1.216 + if( in16 & 0xFF00 ) { 1.217 + if( in16 & 0xF000 ) { 1.218 + in16 >>= 12; 1.219 + } else { 1.220 + out32 += 4; 1.221 + in16 >>= 8; 1.222 + } 1.223 + } else { 1.224 + if( in16 & 0xFFF0 ) { 1.225 + out32 += 8; 1.226 + in16 >>= 4; 1.227 + } else { 1.228 + out32 += 12; 1.229 + } 1.230 + } 1.231 + /* test bits and return */ 1.232 + if( in16 & 0xC ) { 1.233 + if( in16 & 0x8 ) 1.234 + return out32 + 0; 1.235 + else 1.236 + return out32 + 1; 1.237 + } else { 1.238 + if( in16 & 0xE ) 1.239 + return out32 + 2; 1.240 + else 1.241 + return out32 + 3; 1.242 + } 1.243 +} 1.244 + 1.245 +#undef SigProcFIX_CLZ32 1.246 +static OPUS_INLINE opus_int32 SigProcFIX_CLZ32(opus_int32 in32) 1.247 +{ 1.248 + /* test highest 16 bits and convert to opus_int16 */ 1.249 + ops_count += 2; 1.250 + if( in32 & 0xFFFF0000 ) { 1.251 + return SigProcFIX_CLZ16((opus_int16)(in32 >> 16)); 1.252 + } else { 1.253 + return SigProcFIX_CLZ16((opus_int16)in32) + 16; 1.254 + } 1.255 +} 1.256 + 1.257 +#undef silk_DIV32 1.258 +static OPUS_INLINE opus_int32 silk_DIV32(opus_int32 a32, opus_int32 b32){ 1.259 + ops_count += 64; 1.260 + return a32 / b32; 1.261 +} 1.262 + 1.263 +#undef silk_DIV32_16 1.264 +static OPUS_INLINE opus_int32 silk_DIV32_16(opus_int32 a32, opus_int32 b32){ 1.265 + ops_count += 32; 1.266 + return a32 / b32; 1.267 +} 1.268 + 1.269 +#undef silk_SAT8 1.270 +static OPUS_INLINE opus_int8 silk_SAT8(opus_int64 a){ 1.271 + opus_int8 tmp; 1.272 + ops_count += 1; 1.273 + tmp = (opus_int8)((a) > silk_int8_MAX ? silk_int8_MAX : \ 1.274 + ((a) < silk_int8_MIN ? silk_int8_MIN : (a))); 1.275 + return(tmp); 1.276 +} 1.277 + 1.278 +#undef silk_SAT16 1.279 +static OPUS_INLINE opus_int16 silk_SAT16(opus_int64 a){ 1.280 + opus_int16 tmp; 1.281 + ops_count += 1; 1.282 + tmp = (opus_int16)((a) > silk_int16_MAX ? silk_int16_MAX : \ 1.283 + ((a) < silk_int16_MIN ? silk_int16_MIN : (a))); 1.284 + return(tmp); 1.285 +} 1.286 +#undef silk_SAT32 1.287 +static OPUS_INLINE opus_int32 silk_SAT32(opus_int64 a){ 1.288 + opus_int32 tmp; 1.289 + ops_count += 1; 1.290 + tmp = (opus_int32)((a) > silk_int32_MAX ? silk_int32_MAX : \ 1.291 + ((a) < silk_int32_MIN ? silk_int32_MIN : (a))); 1.292 + return(tmp); 1.293 +} 1.294 +#undef silk_POS_SAT32 1.295 +static OPUS_INLINE opus_int32 silk_POS_SAT32(opus_int64 a){ 1.296 + opus_int32 tmp; 1.297 + ops_count += 1; 1.298 + tmp = (opus_int32)((a) > silk_int32_MAX ? silk_int32_MAX : (a)); 1.299 + return(tmp); 1.300 +} 1.301 + 1.302 +#undef silk_ADD_POS_SAT8 1.303 +static OPUS_INLINE opus_int8 silk_ADD_POS_SAT8(opus_int64 a, opus_int64 b){ 1.304 + opus_int8 tmp; 1.305 + ops_count += 1; 1.306 + tmp = (opus_int8)((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b))); 1.307 + return(tmp); 1.308 +} 1.309 +#undef silk_ADD_POS_SAT16 1.310 +static OPUS_INLINE opus_int16 silk_ADD_POS_SAT16(opus_int64 a, opus_int64 b){ 1.311 + opus_int16 tmp; 1.312 + ops_count += 1; 1.313 + tmp = (opus_int16)((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b))); 1.314 + return(tmp); 1.315 +} 1.316 + 1.317 +#undef silk_ADD_POS_SAT32 1.318 +static OPUS_INLINE opus_int32 silk_ADD_POS_SAT32(opus_int64 a, opus_int64 b){ 1.319 + opus_int32 tmp; 1.320 + ops_count += 1; 1.321 + tmp = (opus_int32)((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b))); 1.322 + return(tmp); 1.323 +} 1.324 + 1.325 +#undef silk_ADD_POS_SAT64 1.326 +static OPUS_INLINE opus_int64 silk_ADD_POS_SAT64(opus_int64 a, opus_int64 b){ 1.327 + opus_int64 tmp; 1.328 + ops_count += 1; 1.329 + tmp = ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b))); 1.330 + return(tmp); 1.331 +} 1.332 + 1.333 +#undef silk_LSHIFT8 1.334 +static OPUS_INLINE opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){ 1.335 + opus_int8 ret; 1.336 + ops_count += 1; 1.337 + ret = a << shift; 1.338 + return ret; 1.339 +} 1.340 +#undef silk_LSHIFT16 1.341 +static OPUS_INLINE opus_int16 silk_LSHIFT16(opus_int16 a, opus_int32 shift){ 1.342 + opus_int16 ret; 1.343 + ops_count += 1; 1.344 + ret = a << shift; 1.345 + return ret; 1.346 +} 1.347 +#undef silk_LSHIFT32 1.348 +static OPUS_INLINE opus_int32 silk_LSHIFT32(opus_int32 a, opus_int32 shift){ 1.349 + opus_int32 ret; 1.350 + ops_count += 1; 1.351 + ret = a << shift; 1.352 + return ret; 1.353 +} 1.354 +#undef silk_LSHIFT64 1.355 +static OPUS_INLINE opus_int64 silk_LSHIFT64(opus_int64 a, opus_int shift){ 1.356 + ops_count += 1; 1.357 + return a << shift; 1.358 +} 1.359 + 1.360 +#undef silk_LSHIFT_ovflw 1.361 +static OPUS_INLINE opus_int32 silk_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){ 1.362 + ops_count += 1; 1.363 + return a << shift; 1.364 +} 1.365 + 1.366 +#undef silk_LSHIFT_uint 1.367 +static OPUS_INLINE opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){ 1.368 + opus_uint32 ret; 1.369 + ops_count += 1; 1.370 + ret = a << shift; 1.371 + return ret; 1.372 +} 1.373 + 1.374 +#undef silk_RSHIFT8 1.375 +static OPUS_INLINE opus_int8 silk_RSHIFT8(opus_int8 a, opus_int32 shift){ 1.376 + ops_count += 1; 1.377 + return a >> shift; 1.378 +} 1.379 +#undef silk_RSHIFT16 1.380 +static OPUS_INLINE opus_int16 silk_RSHIFT16(opus_int16 a, opus_int32 shift){ 1.381 + ops_count += 1; 1.382 + return a >> shift; 1.383 +} 1.384 +#undef silk_RSHIFT32 1.385 +static OPUS_INLINE opus_int32 silk_RSHIFT32(opus_int32 a, opus_int32 shift){ 1.386 + ops_count += 1; 1.387 + return a >> shift; 1.388 +} 1.389 +#undef silk_RSHIFT64 1.390 +static OPUS_INLINE opus_int64 silk_RSHIFT64(opus_int64 a, opus_int64 shift){ 1.391 + ops_count += 1; 1.392 + return a >> shift; 1.393 +} 1.394 + 1.395 +#undef silk_RSHIFT_uint 1.396 +static OPUS_INLINE opus_uint32 silk_RSHIFT_uint(opus_uint32 a, opus_int32 shift){ 1.397 + ops_count += 1; 1.398 + return a >> shift; 1.399 +} 1.400 + 1.401 +#undef silk_ADD_LSHIFT 1.402 +static OPUS_INLINE opus_int32 silk_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){ 1.403 + opus_int32 ret; 1.404 + ops_count += 1; 1.405 + ret = a + (b << shift); 1.406 + return ret; /* shift >= 0*/ 1.407 +} 1.408 +#undef silk_ADD_LSHIFT32 1.409 +static OPUS_INLINE opus_int32 silk_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ 1.410 + opus_int32 ret; 1.411 + ops_count += 1; 1.412 + ret = a + (b << shift); 1.413 + return ret; /* shift >= 0*/ 1.414 +} 1.415 +#undef silk_ADD_LSHIFT_uint 1.416 +static OPUS_INLINE opus_uint32 silk_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){ 1.417 + opus_uint32 ret; 1.418 + ops_count += 1; 1.419 + ret = a + (b << shift); 1.420 + return ret; /* shift >= 0*/ 1.421 +} 1.422 +#undef silk_ADD_RSHIFT 1.423 +static OPUS_INLINE opus_int32 silk_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){ 1.424 + opus_int32 ret; 1.425 + ops_count += 1; 1.426 + ret = a + (b >> shift); 1.427 + return ret; /* shift > 0*/ 1.428 +} 1.429 +#undef silk_ADD_RSHIFT32 1.430 +static OPUS_INLINE opus_int32 silk_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ 1.431 + opus_int32 ret; 1.432 + ops_count += 1; 1.433 + ret = a + (b >> shift); 1.434 + return ret; /* shift > 0*/ 1.435 +} 1.436 +#undef silk_ADD_RSHIFT_uint 1.437 +static OPUS_INLINE opus_uint32 silk_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){ 1.438 + opus_uint32 ret; 1.439 + ops_count += 1; 1.440 + ret = a + (b >> shift); 1.441 + return ret; /* shift > 0*/ 1.442 +} 1.443 +#undef silk_SUB_LSHIFT32 1.444 +static OPUS_INLINE opus_int32 silk_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ 1.445 + opus_int32 ret; 1.446 + ops_count += 1; 1.447 + ret = a - (b << shift); 1.448 + return ret; /* shift >= 0*/ 1.449 +} 1.450 +#undef silk_SUB_RSHIFT32 1.451 +static OPUS_INLINE opus_int32 silk_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ 1.452 + opus_int32 ret; 1.453 + ops_count += 1; 1.454 + ret = a - (b >> shift); 1.455 + return ret; /* shift > 0*/ 1.456 +} 1.457 + 1.458 +#undef silk_RSHIFT_ROUND 1.459 +static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){ 1.460 + opus_int32 ret; 1.461 + ops_count += 3; 1.462 + ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; 1.463 + return ret; 1.464 +} 1.465 + 1.466 +#undef silk_RSHIFT_ROUND64 1.467 +static OPUS_INLINE opus_int64 silk_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){ 1.468 + opus_int64 ret; 1.469 + ops_count += 6; 1.470 + ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; 1.471 + return ret; 1.472 +} 1.473 + 1.474 +#undef silk_abs_int64 1.475 +static OPUS_INLINE opus_int64 silk_abs_int64(opus_int64 a){ 1.476 + ops_count += 1; 1.477 + return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN*/ 1.478 +} 1.479 + 1.480 +#undef silk_abs_int32 1.481 +static OPUS_INLINE opus_int32 silk_abs_int32(opus_int32 a){ 1.482 + ops_count += 1; 1.483 + return silk_abs(a); 1.484 +} 1.485 + 1.486 + 1.487 +#undef silk_min 1.488 +static silk_min(a, b){ 1.489 + ops_count += 1; 1.490 + return (((a) < (b)) ? (a) : (b)); 1.491 +} 1.492 +#undef silk_max 1.493 +static silk_max(a, b){ 1.494 + ops_count += 1; 1.495 + return (((a) > (b)) ? (a) : (b)); 1.496 +} 1.497 +#undef silk_sign 1.498 +static silk_sign(a){ 1.499 + ops_count += 1; 1.500 + return ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 )); 1.501 +} 1.502 + 1.503 +#undef silk_ADD16 1.504 +static OPUS_INLINE opus_int16 silk_ADD16(opus_int16 a, opus_int16 b){ 1.505 + opus_int16 ret; 1.506 + ops_count += 1; 1.507 + ret = a + b; 1.508 + return ret; 1.509 +} 1.510 + 1.511 +#undef silk_ADD32 1.512 +static OPUS_INLINE opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){ 1.513 + opus_int32 ret; 1.514 + ops_count += 1; 1.515 + ret = a + b; 1.516 + return ret; 1.517 +} 1.518 + 1.519 +#undef silk_ADD64 1.520 +static OPUS_INLINE opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){ 1.521 + opus_int64 ret; 1.522 + ops_count += 2; 1.523 + ret = a + b; 1.524 + return ret; 1.525 +} 1.526 + 1.527 +#undef silk_SUB16 1.528 +static OPUS_INLINE opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){ 1.529 + opus_int16 ret; 1.530 + ops_count += 1; 1.531 + ret = a - b; 1.532 + return ret; 1.533 +} 1.534 + 1.535 +#undef silk_SUB32 1.536 +static OPUS_INLINE opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){ 1.537 + opus_int32 ret; 1.538 + ops_count += 1; 1.539 + ret = a - b; 1.540 + return ret; 1.541 +} 1.542 + 1.543 +#undef silk_SUB64 1.544 +static OPUS_INLINE opus_int64 silk_SUB64(opus_int64 a, opus_int64 b){ 1.545 + opus_int64 ret; 1.546 + ops_count += 2; 1.547 + ret = a - b; 1.548 + return ret; 1.549 +} 1.550 + 1.551 +#undef silk_ADD_SAT16 1.552 +static OPUS_INLINE opus_int16 silk_ADD_SAT16( opus_int16 a16, opus_int16 b16 ) { 1.553 + opus_int16 res; 1.554 + /* Nb will be counted in AKP_add32 and silk_SAT16*/ 1.555 + res = (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a16), (b16) ) ); 1.556 + return res; 1.557 +} 1.558 + 1.559 +#undef silk_ADD_SAT32 1.560 +static OPUS_INLINE opus_int32 silk_ADD_SAT32(opus_int32 a32, opus_int32 b32){ 1.561 + opus_int32 res; 1.562 + ops_count += 1; 1.563 + res = ((((a32) + (b32)) & 0x80000000) == 0 ? \ 1.564 + ((((a32) & (b32)) & 0x80000000) != 0 ? silk_int32_MIN : (a32)+(b32)) : \ 1.565 + ((((a32) | (b32)) & 0x80000000) == 0 ? silk_int32_MAX : (a32)+(b32)) ); 1.566 + return res; 1.567 +} 1.568 + 1.569 +#undef silk_ADD_SAT64 1.570 +static OPUS_INLINE opus_int64 silk_ADD_SAT64( opus_int64 a64, opus_int64 b64 ) { 1.571 + opus_int64 res; 1.572 + ops_count += 1; 1.573 + res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \ 1.574 + ((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a64)+(b64)) : \ 1.575 + ((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a64)+(b64)) ); 1.576 + return res; 1.577 +} 1.578 + 1.579 +#undef silk_SUB_SAT16 1.580 +static OPUS_INLINE opus_int16 silk_SUB_SAT16( opus_int16 a16, opus_int16 b16 ) { 1.581 + opus_int16 res; 1.582 + silk_assert(0); 1.583 + /* Nb will be counted in sub-macros*/ 1.584 + res = (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a16), (b16) ) ); 1.585 + return res; 1.586 +} 1.587 + 1.588 +#undef silk_SUB_SAT32 1.589 +static OPUS_INLINE opus_int32 silk_SUB_SAT32( opus_int32 a32, opus_int32 b32 ) { 1.590 + opus_int32 res; 1.591 + ops_count += 1; 1.592 + res = ((((a32)-(b32)) & 0x80000000) == 0 ? \ 1.593 + (( (a32) & ((b32)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a32)-(b32)) : \ 1.594 + ((((a32)^0x80000000) & (b32) & 0x80000000) ? silk_int32_MAX : (a32)-(b32)) ); 1.595 + return res; 1.596 +} 1.597 + 1.598 +#undef silk_SUB_SAT64 1.599 +static OPUS_INLINE opus_int64 silk_SUB_SAT64( opus_int64 a64, opus_int64 b64 ) { 1.600 + opus_int64 res; 1.601 + ops_count += 1; 1.602 + res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \ 1.603 + (( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a64)-(b64)) : \ 1.604 + ((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? silk_int64_MAX : (a64)-(b64)) ); 1.605 + 1.606 + return res; 1.607 +} 1.608 + 1.609 +#undef silk_SMULWW 1.610 +static OPUS_INLINE opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){ 1.611 + opus_int32 ret; 1.612 + /* Nb will be counted in sub-macros*/ 1.613 + ret = silk_MLA(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)); 1.614 + return ret; 1.615 +} 1.616 + 1.617 +#undef silk_SMLAWW 1.618 +static OPUS_INLINE opus_int32 silk_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){ 1.619 + opus_int32 ret; 1.620 + /* Nb will be counted in sub-macros*/ 1.621 + ret = silk_MLA(silk_SMLAWB((a32), (b32), (c32)), (b32), silk_RSHIFT_ROUND((c32), 16)); 1.622 + return ret; 1.623 +} 1.624 + 1.625 +#undef silk_min_int 1.626 +static OPUS_INLINE opus_int silk_min_int(opus_int a, opus_int b) 1.627 +{ 1.628 + ops_count += 1; 1.629 + return (((a) < (b)) ? (a) : (b)); 1.630 +} 1.631 + 1.632 +#undef silk_min_16 1.633 +static OPUS_INLINE opus_int16 silk_min_16(opus_int16 a, opus_int16 b) 1.634 +{ 1.635 + ops_count += 1; 1.636 + return (((a) < (b)) ? (a) : (b)); 1.637 +} 1.638 +#undef silk_min_32 1.639 +static OPUS_INLINE opus_int32 silk_min_32(opus_int32 a, opus_int32 b) 1.640 +{ 1.641 + ops_count += 1; 1.642 + return (((a) < (b)) ? (a) : (b)); 1.643 +} 1.644 +#undef silk_min_64 1.645 +static OPUS_INLINE opus_int64 silk_min_64(opus_int64 a, opus_int64 b) 1.646 +{ 1.647 + ops_count += 1; 1.648 + return (((a) < (b)) ? (a) : (b)); 1.649 +} 1.650 + 1.651 +/* silk_min() versions with typecast in the function call */ 1.652 +#undef silk_max_int 1.653 +static OPUS_INLINE opus_int silk_max_int(opus_int a, opus_int b) 1.654 +{ 1.655 + ops_count += 1; 1.656 + return (((a) > (b)) ? (a) : (b)); 1.657 +} 1.658 +#undef silk_max_16 1.659 +static OPUS_INLINE opus_int16 silk_max_16(opus_int16 a, opus_int16 b) 1.660 +{ 1.661 + ops_count += 1; 1.662 + return (((a) > (b)) ? (a) : (b)); 1.663 +} 1.664 +#undef silk_max_32 1.665 +static OPUS_INLINE opus_int32 silk_max_32(opus_int32 a, opus_int32 b) 1.666 +{ 1.667 + ops_count += 1; 1.668 + return (((a) > (b)) ? (a) : (b)); 1.669 +} 1.670 + 1.671 +#undef silk_max_64 1.672 +static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b) 1.673 +{ 1.674 + ops_count += 1; 1.675 + return (((a) > (b)) ? (a) : (b)); 1.676 +} 1.677 + 1.678 + 1.679 +#undef silk_LIMIT_int 1.680 +static OPUS_INLINE opus_int silk_LIMIT_int(opus_int a, opus_int limit1, opus_int limit2) 1.681 +{ 1.682 + opus_int ret; 1.683 + ops_count += 6; 1.684 + 1.685 + ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ 1.686 + : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))); 1.687 + 1.688 + return(ret); 1.689 +} 1.690 + 1.691 +#undef silk_LIMIT_16 1.692 +static OPUS_INLINE opus_int16 silk_LIMIT_16(opus_int16 a, opus_int16 limit1, opus_int16 limit2) 1.693 +{ 1.694 + opus_int16 ret; 1.695 + ops_count += 6; 1.696 + 1.697 + ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ 1.698 + : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))); 1.699 + 1.700 +return(ret); 1.701 +} 1.702 + 1.703 + 1.704 +#undef silk_LIMIT_32 1.705 +static OPUS_INLINE opus_int silk_LIMIT_32(opus_int32 a, opus_int32 limit1, opus_int32 limit2) 1.706 +{ 1.707 + opus_int32 ret; 1.708 + ops_count += 6; 1.709 + 1.710 + ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ 1.711 + : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))); 1.712 + return(ret); 1.713 +} 1.714 + 1.715 +#else 1.716 +#define varDefine 1.717 +#define silk_SaveCount() 1.718 + 1.719 +#endif 1.720 +#endif 1.721 +