1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libopus/silk/MacroDebug.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,952 @@ 1.4 +/*********************************************************************** 1.5 +Copyright (c) 2006-2011, Skype Limited. All rights reserved. 1.6 +Copyright (C) 2012 Xiph.Org Foundation 1.7 +Redistribution and use in source and binary forms, with or without 1.8 +modification, are permitted provided that the following conditions 1.9 +are met: 1.10 +- Redistributions of source code must retain the above copyright notice, 1.11 +this list of conditions and the following disclaimer. 1.12 +- Redistributions in binary form must reproduce the above copyright 1.13 +notice, this list of conditions and the following disclaimer in the 1.14 +documentation and/or other materials provided with the distribution. 1.15 +- Neither the name of Internet Society, IETF or IETF Trust, nor the 1.16 +names of specific contributors, may be used to endorse or promote 1.17 +products derived from this software without specific prior written 1.18 +permission. 1.19 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1.20 +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.21 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1.22 +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 1.23 +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 1.24 +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 1.25 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 1.26 +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 1.27 +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 1.28 +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1.29 +POSSIBILITY OF SUCH DAMAGE. 1.30 +***********************************************************************/ 1.31 + 1.32 +#ifndef MACRO_DEBUG_H 1.33 +#define MACRO_DEBUG_H 1.34 + 1.35 +/* Redefine macro functions with extensive assertion in DEBUG mode. 1.36 + As functions can't be undefined, this file can't work with SigProcFIX_MacroCount.h */ 1.37 + 1.38 +#if ( defined (FIXED_DEBUG) || ( 0 && defined (_DEBUG) ) ) && !defined (silk_MACRO_COUNT) 1.39 + 1.40 +#undef silk_ADD16 1.41 +#define silk_ADD16(a,b) silk_ADD16_((a), (b), __FILE__, __LINE__) 1.42 +static OPUS_INLINE opus_int16 silk_ADD16_(opus_int16 a, opus_int16 b, char *file, int line){ 1.43 + opus_int16 ret; 1.44 + 1.45 + ret = a + b; 1.46 + if ( ret != silk_ADD_SAT16( a, b ) ) 1.47 + { 1.48 + fprintf (stderr, "silk_ADD16(%d, %d) in %s: line %d\n", a, b, file, line); 1.49 +#ifdef FIXED_DEBUG_ASSERT 1.50 + silk_assert( 0 ); 1.51 +#endif 1.52 + } 1.53 + return ret; 1.54 +} 1.55 + 1.56 +#undef silk_ADD32 1.57 +#define silk_ADD32(a,b) silk_ADD32_((a), (b), __FILE__, __LINE__) 1.58 +static OPUS_INLINE opus_int32 silk_ADD32_(opus_int32 a, opus_int32 b, char *file, int line){ 1.59 + opus_int32 ret; 1.60 + 1.61 + ret = a + b; 1.62 + if ( ret != silk_ADD_SAT32( a, b ) ) 1.63 + { 1.64 + fprintf (stderr, "silk_ADD32(%d, %d) in %s: line %d\n", a, b, file, line); 1.65 +#ifdef FIXED_DEBUG_ASSERT 1.66 + silk_assert( 0 ); 1.67 +#endif 1.68 + } 1.69 + return ret; 1.70 +} 1.71 + 1.72 +#undef silk_ADD64 1.73 +#define silk_ADD64(a,b) silk_ADD64_((a), (b), __FILE__, __LINE__) 1.74 +static OPUS_INLINE opus_int64 silk_ADD64_(opus_int64 a, opus_int64 b, char *file, int line){ 1.75 + opus_int64 ret; 1.76 + 1.77 + ret = a + b; 1.78 + if ( ret != silk_ADD_SAT64( a, b ) ) 1.79 + { 1.80 + fprintf (stderr, "silk_ADD64(%lld, %lld) in %s: line %d\n", (long long)a, (long long)b, file, line); 1.81 +#ifdef FIXED_DEBUG_ASSERT 1.82 + silk_assert( 0 ); 1.83 +#endif 1.84 + } 1.85 + return ret; 1.86 +} 1.87 + 1.88 +#undef silk_SUB16 1.89 +#define silk_SUB16(a,b) silk_SUB16_((a), (b), __FILE__, __LINE__) 1.90 +static OPUS_INLINE opus_int16 silk_SUB16_(opus_int16 a, opus_int16 b, char *file, int line){ 1.91 + opus_int16 ret; 1.92 + 1.93 + ret = a - b; 1.94 + if ( ret != silk_SUB_SAT16( a, b ) ) 1.95 + { 1.96 + fprintf (stderr, "silk_SUB16(%d, %d) in %s: line %d\n", a, b, file, line); 1.97 +#ifdef FIXED_DEBUG_ASSERT 1.98 + silk_assert( 0 ); 1.99 +#endif 1.100 + } 1.101 + return ret; 1.102 +} 1.103 + 1.104 +#undef silk_SUB32 1.105 +#define silk_SUB32(a,b) silk_SUB32_((a), (b), __FILE__, __LINE__) 1.106 +static OPUS_INLINE opus_int32 silk_SUB32_(opus_int32 a, opus_int32 b, char *file, int line){ 1.107 + opus_int32 ret; 1.108 + 1.109 + ret = a - b; 1.110 + if ( ret != silk_SUB_SAT32( a, b ) ) 1.111 + { 1.112 + fprintf (stderr, "silk_SUB32(%d, %d) in %s: line %d\n", a, b, file, line); 1.113 +#ifdef FIXED_DEBUG_ASSERT 1.114 + silk_assert( 0 ); 1.115 +#endif 1.116 + } 1.117 + return ret; 1.118 +} 1.119 + 1.120 +#undef silk_SUB64 1.121 +#define silk_SUB64(a,b) silk_SUB64_((a), (b), __FILE__, __LINE__) 1.122 +static OPUS_INLINE opus_int64 silk_SUB64_(opus_int64 a, opus_int64 b, char *file, int line){ 1.123 + opus_int64 ret; 1.124 + 1.125 + ret = a - b; 1.126 + if ( ret != silk_SUB_SAT64( a, b ) ) 1.127 + { 1.128 + fprintf (stderr, "silk_SUB64(%lld, %lld) in %s: line %d\n", (long long)a, (long long)b, file, line); 1.129 +#ifdef FIXED_DEBUG_ASSERT 1.130 + silk_assert( 0 ); 1.131 +#endif 1.132 + } 1.133 + return ret; 1.134 +} 1.135 + 1.136 +#undef silk_ADD_SAT16 1.137 +#define silk_ADD_SAT16(a,b) silk_ADD_SAT16_((a), (b), __FILE__, __LINE__) 1.138 +static OPUS_INLINE opus_int16 silk_ADD_SAT16_( opus_int16 a16, opus_int16 b16, char *file, int line) { 1.139 + opus_int16 res; 1.140 + res = (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a16), (b16) ) ); 1.141 + if ( res != silk_SAT16( (opus_int32)a16 + (opus_int32)b16 ) ) 1.142 + { 1.143 + fprintf (stderr, "silk_ADD_SAT16(%d, %d) in %s: line %d\n", a16, b16, file, line); 1.144 +#ifdef FIXED_DEBUG_ASSERT 1.145 + silk_assert( 0 ); 1.146 +#endif 1.147 + } 1.148 + return res; 1.149 +} 1.150 + 1.151 +#undef silk_ADD_SAT32 1.152 +#define silk_ADD_SAT32(a,b) silk_ADD_SAT32_((a), (b), __FILE__, __LINE__) 1.153 +static OPUS_INLINE opus_int32 silk_ADD_SAT32_(opus_int32 a32, opus_int32 b32, char *file, int line){ 1.154 + opus_int32 res; 1.155 + res = ((((opus_uint32)(a32) + (opus_uint32)(b32)) & 0x80000000) == 0 ? \ 1.156 + ((((a32) & (b32)) & 0x80000000) != 0 ? silk_int32_MIN : (a32)+(b32)) : \ 1.157 + ((((a32) | (b32)) & 0x80000000) == 0 ? silk_int32_MAX : (a32)+(b32)) ); 1.158 + if ( res != silk_SAT32( (opus_int64)a32 + (opus_int64)b32 ) ) 1.159 + { 1.160 + fprintf (stderr, "silk_ADD_SAT32(%d, %d) in %s: line %d\n", a32, b32, file, line); 1.161 +#ifdef FIXED_DEBUG_ASSERT 1.162 + silk_assert( 0 ); 1.163 +#endif 1.164 + } 1.165 + return res; 1.166 +} 1.167 + 1.168 +#undef silk_ADD_SAT64 1.169 +#define silk_ADD_SAT64(a,b) silk_ADD_SAT64_((a), (b), __FILE__, __LINE__) 1.170 +static OPUS_INLINE opus_int64 silk_ADD_SAT64_( opus_int64 a64, opus_int64 b64, char *file, int line) { 1.171 + opus_int64 res; 1.172 + int fail = 0; 1.173 + res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \ 1.174 + ((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a64)+(b64)) : \ 1.175 + ((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a64)+(b64)) ); 1.176 + if( res != a64 + b64 ) { 1.177 + /* Check that we saturated to the correct extreme value */ 1.178 + if ( !(( res == silk_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( silk_int64_MAX >> 3 ) ) ) || 1.179 + ( res == silk_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( silk_int64_MIN >> 3 ) ) ) ) ) 1.180 + { 1.181 + fail = 1; 1.182 + } 1.183 + } else { 1.184 + /* Saturation not necessary */ 1.185 + fail = res != a64 + b64; 1.186 + } 1.187 + if ( fail ) 1.188 + { 1.189 + fprintf (stderr, "silk_ADD_SAT64(%lld, %lld) in %s: line %d\n", (long long)a64, (long long)b64, file, line); 1.190 +#ifdef FIXED_DEBUG_ASSERT 1.191 + silk_assert( 0 ); 1.192 +#endif 1.193 + } 1.194 + return res; 1.195 +} 1.196 + 1.197 +#undef silk_SUB_SAT16 1.198 +#define silk_SUB_SAT16(a,b) silk_SUB_SAT16_((a), (b), __FILE__, __LINE__) 1.199 +static OPUS_INLINE opus_int16 silk_SUB_SAT16_( opus_int16 a16, opus_int16 b16, char *file, int line ) { 1.200 + opus_int16 res; 1.201 + res = (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a16), (b16) ) ); 1.202 + if ( res != silk_SAT16( (opus_int32)a16 - (opus_int32)b16 ) ) 1.203 + { 1.204 + fprintf (stderr, "silk_SUB_SAT16(%d, %d) in %s: line %d\n", a16, b16, file, line); 1.205 +#ifdef FIXED_DEBUG_ASSERT 1.206 + silk_assert( 0 ); 1.207 +#endif 1.208 + } 1.209 + return res; 1.210 +} 1.211 + 1.212 +#undef silk_SUB_SAT32 1.213 +#define silk_SUB_SAT32(a,b) silk_SUB_SAT32_((a), (b), __FILE__, __LINE__) 1.214 +static OPUS_INLINE opus_int32 silk_SUB_SAT32_( opus_int32 a32, opus_int32 b32, char *file, int line ) { 1.215 + opus_int32 res; 1.216 + res = ((((opus_uint32)(a32)-(opus_uint32)(b32)) & 0x80000000) == 0 ? \ 1.217 + (( (a32) & ((b32)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a32)-(b32)) : \ 1.218 + ((((a32)^0x80000000) & (b32) & 0x80000000) ? silk_int32_MAX : (a32)-(b32)) ); 1.219 + if ( res != silk_SAT32( (opus_int64)a32 - (opus_int64)b32 ) ) 1.220 + { 1.221 + fprintf (stderr, "silk_SUB_SAT32(%d, %d) in %s: line %d\n", a32, b32, file, line); 1.222 +#ifdef FIXED_DEBUG_ASSERT 1.223 + silk_assert( 0 ); 1.224 +#endif 1.225 + } 1.226 + return res; 1.227 +} 1.228 + 1.229 +#undef silk_SUB_SAT64 1.230 +#define silk_SUB_SAT64(a,b) silk_SUB_SAT64_((a), (b), __FILE__, __LINE__) 1.231 +static OPUS_INLINE opus_int64 silk_SUB_SAT64_( opus_int64 a64, opus_int64 b64, char *file, int line ) { 1.232 + opus_int64 res; 1.233 + int fail = 0; 1.234 + res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \ 1.235 + (( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a64)-(b64)) : \ 1.236 + ((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? silk_int64_MAX : (a64)-(b64)) ); 1.237 + if( res != a64 - b64 ) { 1.238 + /* Check that we saturated to the correct extreme value */ 1.239 + if( !(( res == silk_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( silk_int64_MAX >> 3 ) ) ) || 1.240 + ( res == silk_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( silk_int64_MIN >> 3 ) ) ) )) 1.241 + { 1.242 + fail = 1; 1.243 + } 1.244 + } else { 1.245 + /* Saturation not necessary */ 1.246 + fail = res != a64 - b64; 1.247 + } 1.248 + if ( fail ) 1.249 + { 1.250 + fprintf (stderr, "silk_SUB_SAT64(%lld, %lld) in %s: line %d\n", (long long)a64, (long long)b64, file, line); 1.251 +#ifdef FIXED_DEBUG_ASSERT 1.252 + silk_assert( 0 ); 1.253 +#endif 1.254 + } 1.255 + return res; 1.256 +} 1.257 + 1.258 +#undef silk_MUL 1.259 +#define silk_MUL(a,b) silk_MUL_((a), (b), __FILE__, __LINE__) 1.260 +static OPUS_INLINE opus_int32 silk_MUL_(opus_int32 a32, opus_int32 b32, char *file, int line){ 1.261 + opus_int32 ret; 1.262 + opus_int64 ret64; 1.263 + ret = a32 * b32; 1.264 + ret64 = (opus_int64)a32 * (opus_int64)b32; 1.265 + if ( (opus_int64)ret != ret64 ) 1.266 + { 1.267 + fprintf (stderr, "silk_MUL(%d, %d) in %s: line %d\n", a32, b32, file, line); 1.268 +#ifdef FIXED_DEBUG_ASSERT 1.269 + silk_assert( 0 ); 1.270 +#endif 1.271 + } 1.272 + return ret; 1.273 +} 1.274 + 1.275 +#undef silk_MUL_uint 1.276 +#define silk_MUL_uint(a,b) silk_MUL_uint_((a), (b), __FILE__, __LINE__) 1.277 +static OPUS_INLINE opus_uint32 silk_MUL_uint_(opus_uint32 a32, opus_uint32 b32, char *file, int line){ 1.278 + opus_uint32 ret; 1.279 + ret = a32 * b32; 1.280 + if ( (opus_uint64)ret != (opus_uint64)a32 * (opus_uint64)b32 ) 1.281 + { 1.282 + fprintf (stderr, "silk_MUL_uint(%u, %u) in %s: line %d\n", a32, b32, file, line); 1.283 +#ifdef FIXED_DEBUG_ASSERT 1.284 + silk_assert( 0 ); 1.285 +#endif 1.286 + } 1.287 + return ret; 1.288 +} 1.289 + 1.290 +#undef silk_MLA 1.291 +#define silk_MLA(a,b,c) silk_MLA_((a), (b), (c), __FILE__, __LINE__) 1.292 +static OPUS_INLINE opus_int32 silk_MLA_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 1.293 + opus_int32 ret; 1.294 + ret = a32 + b32 * c32; 1.295 + if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32 ) 1.296 + { 1.297 + fprintf (stderr, "silk_MLA(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 1.298 +#ifdef FIXED_DEBUG_ASSERT 1.299 + silk_assert( 0 ); 1.300 +#endif 1.301 + } 1.302 + return ret; 1.303 +} 1.304 + 1.305 +#undef silk_MLA_uint 1.306 +#define silk_MLA_uint(a,b,c) silk_MLA_uint_((a), (b), (c), __FILE__, __LINE__) 1.307 +static OPUS_INLINE opus_int32 silk_MLA_uint_(opus_uint32 a32, opus_uint32 b32, opus_uint32 c32, char *file, int line){ 1.308 + opus_uint32 ret; 1.309 + ret = a32 + b32 * c32; 1.310 + if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32 ) 1.311 + { 1.312 + fprintf (stderr, "silk_MLA_uint(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 1.313 +#ifdef FIXED_DEBUG_ASSERT 1.314 + silk_assert( 0 ); 1.315 +#endif 1.316 + } 1.317 + return ret; 1.318 +} 1.319 + 1.320 +#undef silk_SMULWB 1.321 +#define silk_SMULWB(a,b) silk_SMULWB_((a), (b), __FILE__, __LINE__) 1.322 +static OPUS_INLINE opus_int32 silk_SMULWB_(opus_int32 a32, opus_int32 b32, char *file, int line){ 1.323 + opus_int32 ret; 1.324 + ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16); 1.325 + if ( (opus_int64)ret != ((opus_int64)a32 * (opus_int16)b32) >> 16 ) 1.326 + { 1.327 + fprintf (stderr, "silk_SMULWB(%d, %d) in %s: line %d\n", a32, b32, file, line); 1.328 +#ifdef FIXED_DEBUG_ASSERT 1.329 + silk_assert( 0 ); 1.330 +#endif 1.331 + } 1.332 + return ret; 1.333 +} 1.334 + 1.335 +#undef silk_SMLAWB 1.336 +#define silk_SMLAWB(a,b,c) silk_SMLAWB_((a), (b), (c), __FILE__, __LINE__) 1.337 +static OPUS_INLINE opus_int32 silk_SMLAWB_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 1.338 + opus_int32 ret; 1.339 + ret = silk_ADD32( a32, silk_SMULWB( b32, c32 ) ); 1.340 + if ( silk_ADD32( a32, silk_SMULWB( b32, c32 ) ) != silk_ADD_SAT32( a32, silk_SMULWB( b32, c32 ) ) ) 1.341 + { 1.342 + fprintf (stderr, "silk_SMLAWB(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 1.343 +#ifdef FIXED_DEBUG_ASSERT 1.344 + silk_assert( 0 ); 1.345 +#endif 1.346 + } 1.347 + return ret; 1.348 +} 1.349 + 1.350 +#undef silk_SMULWT 1.351 +#define silk_SMULWT(a,b) silk_SMULWT_((a), (b), __FILE__, __LINE__) 1.352 +static OPUS_INLINE opus_int32 silk_SMULWT_(opus_int32 a32, opus_int32 b32, char *file, int line){ 1.353 + opus_int32 ret; 1.354 + ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16); 1.355 + if ( (opus_int64)ret != ((opus_int64)a32 * (b32 >> 16)) >> 16 ) 1.356 + { 1.357 + fprintf (stderr, "silk_SMULWT(%d, %d) in %s: line %d\n", a32, b32, file, line); 1.358 +#ifdef FIXED_DEBUG_ASSERT 1.359 + silk_assert( 0 ); 1.360 +#endif 1.361 + } 1.362 + return ret; 1.363 +} 1.364 + 1.365 +#undef silk_SMLAWT 1.366 +#define silk_SMLAWT(a,b,c) silk_SMLAWT_((a), (b), (c), __FILE__, __LINE__) 1.367 +static OPUS_INLINE opus_int32 silk_SMLAWT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 1.368 + opus_int32 ret; 1.369 + ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16)); 1.370 + if ( (opus_int64)ret != (opus_int64)a32 + (((opus_int64)b32 * (c32 >> 16)) >> 16) ) 1.371 + { 1.372 + fprintf (stderr, "silk_SMLAWT(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 1.373 +#ifdef FIXED_DEBUG_ASSERT 1.374 + silk_assert( 0 ); 1.375 +#endif 1.376 + } 1.377 + return ret; 1.378 +} 1.379 + 1.380 +#undef silk_SMULL 1.381 +#define silk_SMULL(a,b) silk_SMULL_((a), (b), __FILE__, __LINE__) 1.382 +static OPUS_INLINE opus_int64 silk_SMULL_(opus_int64 a64, opus_int64 b64, char *file, int line){ 1.383 + opus_int64 ret64; 1.384 + int fail = 0; 1.385 + ret64 = a64 * b64; 1.386 + if( b64 != 0 ) { 1.387 + fail = a64 != (ret64 / b64); 1.388 + } else if( a64 != 0 ) { 1.389 + fail = b64 != (ret64 / a64); 1.390 + } 1.391 + if ( fail ) 1.392 + { 1.393 + fprintf (stderr, "silk_SMULL(%lld, %lld) in %s: line %d\n", (long long)a64, (long long)b64, file, line); 1.394 +#ifdef FIXED_DEBUG_ASSERT 1.395 + silk_assert( 0 ); 1.396 +#endif 1.397 + } 1.398 + return ret64; 1.399 +} 1.400 + 1.401 +/* no checking needed for silk_SMULBB */ 1.402 +#undef silk_SMLABB 1.403 +#define silk_SMLABB(a,b,c) silk_SMLABB_((a), (b), (c), __FILE__, __LINE__) 1.404 +static OPUS_INLINE opus_int32 silk_SMLABB_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 1.405 + opus_int32 ret; 1.406 + ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32); 1.407 + if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int16)c32 ) 1.408 + { 1.409 + fprintf (stderr, "silk_SMLABB(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 1.410 +#ifdef FIXED_DEBUG_ASSERT 1.411 + silk_assert( 0 ); 1.412 +#endif 1.413 + } 1.414 + return ret; 1.415 +} 1.416 + 1.417 +/* no checking needed for silk_SMULBT */ 1.418 +#undef silk_SMLABT 1.419 +#define silk_SMLABT(a,b,c) silk_SMLABT_((a), (b), (c), __FILE__, __LINE__) 1.420 +static OPUS_INLINE opus_int32 silk_SMLABT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 1.421 + opus_int32 ret; 1.422 + ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16); 1.423 + if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (c32 >> 16) ) 1.424 + { 1.425 + fprintf (stderr, "silk_SMLABT(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 1.426 +#ifdef FIXED_DEBUG_ASSERT 1.427 + silk_assert( 0 ); 1.428 +#endif 1.429 + } 1.430 + return ret; 1.431 +} 1.432 + 1.433 +/* no checking needed for silk_SMULTT */ 1.434 +#undef silk_SMLATT 1.435 +#define silk_SMLATT(a,b,c) silk_SMLATT_((a), (b), (c), __FILE__, __LINE__) 1.436 +static OPUS_INLINE opus_int32 silk_SMLATT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 1.437 + opus_int32 ret; 1.438 + ret = a32 + (b32 >> 16) * (c32 >> 16); 1.439 + if ( (opus_int64)ret != (opus_int64)a32 + (b32 >> 16) * (c32 >> 16) ) 1.440 + { 1.441 + fprintf (stderr, "silk_SMLATT(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 1.442 +#ifdef FIXED_DEBUG_ASSERT 1.443 + silk_assert( 0 ); 1.444 +#endif 1.445 + } 1.446 + return ret; 1.447 +} 1.448 + 1.449 +#undef silk_SMULWW 1.450 +#define silk_SMULWW(a,b) silk_SMULWW_((a), (b), __FILE__, __LINE__) 1.451 +static OPUS_INLINE opus_int32 silk_SMULWW_(opus_int32 a32, opus_int32 b32, char *file, int line){ 1.452 + opus_int32 ret, tmp1, tmp2; 1.453 + opus_int64 ret64; 1.454 + int fail = 0; 1.455 + 1.456 + ret = silk_SMULWB( a32, b32 ); 1.457 + tmp1 = silk_RSHIFT_ROUND( b32, 16 ); 1.458 + tmp2 = silk_MUL( a32, tmp1 ); 1.459 + 1.460 + fail |= (opus_int64)tmp2 != (opus_int64) a32 * (opus_int64) tmp1; 1.461 + 1.462 + tmp1 = ret; 1.463 + ret = silk_ADD32( tmp1, tmp2 ); 1.464 + fail |= silk_ADD32( tmp1, tmp2 ) != silk_ADD_SAT32( tmp1, tmp2 ); 1.465 + 1.466 + ret64 = silk_RSHIFT64( silk_SMULL( a32, b32 ), 16 ); 1.467 + fail |= (opus_int64)ret != ret64; 1.468 + 1.469 + if ( fail ) 1.470 + { 1.471 + fprintf (stderr, "silk_SMULWT(%d, %d) in %s: line %d\n", a32, b32, file, line); 1.472 +#ifdef FIXED_DEBUG_ASSERT 1.473 + silk_assert( 0 ); 1.474 +#endif 1.475 + } 1.476 + 1.477 + return ret; 1.478 +} 1.479 + 1.480 +#undef silk_SMLAWW 1.481 +#define silk_SMLAWW(a,b,c) silk_SMLAWW_((a), (b), (c), __FILE__, __LINE__) 1.482 +static OPUS_INLINE opus_int32 silk_SMLAWW_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 1.483 + opus_int32 ret, tmp; 1.484 + 1.485 + tmp = silk_SMULWW( b32, c32 ); 1.486 + ret = silk_ADD32( a32, tmp ); 1.487 + if ( ret != silk_ADD_SAT32( a32, tmp ) ) 1.488 + { 1.489 + fprintf (stderr, "silk_SMLAWW(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 1.490 +#ifdef FIXED_DEBUG_ASSERT 1.491 + silk_assert( 0 ); 1.492 +#endif 1.493 + } 1.494 + return ret; 1.495 +} 1.496 + 1.497 +/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) */ 1.498 +#undef silk_MLA_ovflw 1.499 +#define silk_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32))) 1.500 +#undef silk_SMLABB_ovflw 1.501 +#define silk_SMLABB_ovflw(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32))) 1.502 + 1.503 +/* no checking needed for silk_SMULL 1.504 + no checking needed for silk_SMLAL 1.505 + no checking needed for silk_SMLALBB 1.506 + no checking needed for SigProcFIX_CLZ16 1.507 + no checking needed for SigProcFIX_CLZ32*/ 1.508 + 1.509 +#undef silk_DIV32 1.510 +#define silk_DIV32(a,b) silk_DIV32_((a), (b), __FILE__, __LINE__) 1.511 +static OPUS_INLINE opus_int32 silk_DIV32_(opus_int32 a32, opus_int32 b32, char *file, int line){ 1.512 + if ( b32 == 0 ) 1.513 + { 1.514 + fprintf (stderr, "silk_DIV32(%d, %d) in %s: line %d\n", a32, b32, file, line); 1.515 +#ifdef FIXED_DEBUG_ASSERT 1.516 + silk_assert( 0 ); 1.517 +#endif 1.518 + } 1.519 + return a32 / b32; 1.520 +} 1.521 + 1.522 +#undef silk_DIV32_16 1.523 +#define silk_DIV32_16(a,b) silk_DIV32_16_((a), (b), __FILE__, __LINE__) 1.524 +static OPUS_INLINE opus_int32 silk_DIV32_16_(opus_int32 a32, opus_int32 b32, char *file, int line){ 1.525 + int fail = 0; 1.526 + fail |= b32 == 0; 1.527 + fail |= b32 > silk_int16_MAX; 1.528 + fail |= b32 < silk_int16_MIN; 1.529 + if ( fail ) 1.530 + { 1.531 + fprintf (stderr, "silk_DIV32_16(%d, %d) in %s: line %d\n", a32, b32, file, line); 1.532 +#ifdef FIXED_DEBUG_ASSERT 1.533 + silk_assert( 0 ); 1.534 +#endif 1.535 + } 1.536 + return a32 / b32; 1.537 +} 1.538 + 1.539 +/* no checking needed for silk_SAT8 1.540 + no checking needed for silk_SAT16 1.541 + no checking needed for silk_SAT32 1.542 + no checking needed for silk_POS_SAT32 1.543 + no checking needed for silk_ADD_POS_SAT8 1.544 + no checking needed for silk_ADD_POS_SAT16 1.545 + no checking needed for silk_ADD_POS_SAT32 1.546 + no checking needed for silk_ADD_POS_SAT64 */ 1.547 + 1.548 +#undef silk_LSHIFT8 1.549 +#define silk_LSHIFT8(a,b) silk_LSHIFT8_((a), (b), __FILE__, __LINE__) 1.550 +static OPUS_INLINE opus_int8 silk_LSHIFT8_(opus_int8 a, opus_int32 shift, char *file, int line){ 1.551 + opus_int8 ret; 1.552 + int fail = 0; 1.553 + ret = a << shift; 1.554 + fail |= shift < 0; 1.555 + fail |= shift >= 8; 1.556 + fail |= (opus_int64)ret != ((opus_int64)a) << shift; 1.557 + if ( fail ) 1.558 + { 1.559 + fprintf (stderr, "silk_LSHIFT8(%d, %d) in %s: line %d\n", a, shift, file, line); 1.560 +#ifdef FIXED_DEBUG_ASSERT 1.561 + silk_assert( 0 ); 1.562 +#endif 1.563 + } 1.564 + return ret; 1.565 +} 1.566 + 1.567 +#undef silk_LSHIFT16 1.568 +#define silk_LSHIFT16(a,b) silk_LSHIFT16_((a), (b), __FILE__, __LINE__) 1.569 +static OPUS_INLINE opus_int16 silk_LSHIFT16_(opus_int16 a, opus_int32 shift, char *file, int line){ 1.570 + opus_int16 ret; 1.571 + int fail = 0; 1.572 + ret = a << shift; 1.573 + fail |= shift < 0; 1.574 + fail |= shift >= 16; 1.575 + fail |= (opus_int64)ret != ((opus_int64)a) << shift; 1.576 + if ( fail ) 1.577 + { 1.578 + fprintf (stderr, "silk_LSHIFT16(%d, %d) in %s: line %d\n", a, shift, file, line); 1.579 +#ifdef FIXED_DEBUG_ASSERT 1.580 + silk_assert( 0 ); 1.581 +#endif 1.582 + } 1.583 + return ret; 1.584 +} 1.585 + 1.586 +#undef silk_LSHIFT32 1.587 +#define silk_LSHIFT32(a,b) silk_LSHIFT32_((a), (b), __FILE__, __LINE__) 1.588 +static OPUS_INLINE opus_int32 silk_LSHIFT32_(opus_int32 a, opus_int32 shift, char *file, int line){ 1.589 + opus_int32 ret; 1.590 + int fail = 0; 1.591 + ret = a << shift; 1.592 + fail |= shift < 0; 1.593 + fail |= shift >= 32; 1.594 + fail |= (opus_int64)ret != ((opus_int64)a) << shift; 1.595 + if ( fail ) 1.596 + { 1.597 + fprintf (stderr, "silk_LSHIFT32(%d, %d) in %s: line %d\n", a, shift, file, line); 1.598 +#ifdef FIXED_DEBUG_ASSERT 1.599 + silk_assert( 0 ); 1.600 +#endif 1.601 + } 1.602 + return ret; 1.603 +} 1.604 + 1.605 +#undef silk_LSHIFT64 1.606 +#define silk_LSHIFT64(a,b) silk_LSHIFT64_((a), (b), __FILE__, __LINE__) 1.607 +static OPUS_INLINE opus_int64 silk_LSHIFT64_(opus_int64 a, opus_int shift, char *file, int line){ 1.608 + opus_int64 ret; 1.609 + int fail = 0; 1.610 + ret = a << shift; 1.611 + fail |= shift < 0; 1.612 + fail |= shift >= 64; 1.613 + fail |= (ret>>shift) != ((opus_int64)a); 1.614 + if ( fail ) 1.615 + { 1.616 + fprintf (stderr, "silk_LSHIFT64(%lld, %d) in %s: line %d\n", (long long)a, shift, file, line); 1.617 +#ifdef FIXED_DEBUG_ASSERT 1.618 + silk_assert( 0 ); 1.619 +#endif 1.620 + } 1.621 + return ret; 1.622 +} 1.623 + 1.624 +#undef silk_LSHIFT_ovflw 1.625 +#define silk_LSHIFT_ovflw(a,b) silk_LSHIFT_ovflw_((a), (b), __FILE__, __LINE__) 1.626 +static OPUS_INLINE opus_int32 silk_LSHIFT_ovflw_(opus_int32 a, opus_int32 shift, char *file, int line){ 1.627 + if ( (shift < 0) || (shift >= 32) ) /* no check for overflow */ 1.628 + { 1.629 + fprintf (stderr, "silk_LSHIFT_ovflw(%d, %d) in %s: line %d\n", a, shift, file, line); 1.630 +#ifdef FIXED_DEBUG_ASSERT 1.631 + silk_assert( 0 ); 1.632 +#endif 1.633 + } 1.634 + return a << shift; 1.635 +} 1.636 + 1.637 +#undef silk_LSHIFT_uint 1.638 +#define silk_LSHIFT_uint(a,b) silk_LSHIFT_uint_((a), (b), __FILE__, __LINE__) 1.639 +static OPUS_INLINE opus_uint32 silk_LSHIFT_uint_(opus_uint32 a, opus_int32 shift, char *file, int line){ 1.640 + opus_uint32 ret; 1.641 + ret = a << shift; 1.642 + if ( (shift < 0) || ((opus_int64)ret != ((opus_int64)a) << shift)) 1.643 + { 1.644 + fprintf (stderr, "silk_LSHIFT_uint(%u, %d) in %s: line %d\n", a, shift, file, line); 1.645 +#ifdef FIXED_DEBUG_ASSERT 1.646 + silk_assert( 0 ); 1.647 +#endif 1.648 + } 1.649 + return ret; 1.650 +} 1.651 + 1.652 +#undef silk_RSHIFT8 1.653 +#define silk_RSHITF8(a,b) silk_RSHIFT8_((a), (b), __FILE__, __LINE__) 1.654 +static OPUS_INLINE opus_int8 silk_RSHIFT8_(opus_int8 a, opus_int32 shift, char *file, int line){ 1.655 + if ( (shift < 0) || (shift>=8) ) 1.656 + { 1.657 + fprintf (stderr, "silk_RSHITF8(%d, %d) in %s: line %d\n", a, shift, file, line); 1.658 +#ifdef FIXED_DEBUG_ASSERT 1.659 + silk_assert( 0 ); 1.660 +#endif 1.661 + } 1.662 + return a >> shift; 1.663 +} 1.664 + 1.665 +#undef silk_RSHIFT16 1.666 +#define silk_RSHITF16(a,b) silk_RSHIFT16_((a), (b), __FILE__, __LINE__) 1.667 +static OPUS_INLINE opus_int16 silk_RSHIFT16_(opus_int16 a, opus_int32 shift, char *file, int line){ 1.668 + if ( (shift < 0) || (shift>=16) ) 1.669 + { 1.670 + fprintf (stderr, "silk_RSHITF16(%d, %d) in %s: line %d\n", a, shift, file, line); 1.671 +#ifdef FIXED_DEBUG_ASSERT 1.672 + silk_assert( 0 ); 1.673 +#endif 1.674 + } 1.675 + return a >> shift; 1.676 +} 1.677 + 1.678 +#undef silk_RSHIFT32 1.679 +#define silk_RSHIFT32(a,b) silk_RSHIFT32_((a), (b), __FILE__, __LINE__) 1.680 +static OPUS_INLINE opus_int32 silk_RSHIFT32_(opus_int32 a, opus_int32 shift, char *file, int line){ 1.681 + if ( (shift < 0) || (shift>=32) ) 1.682 + { 1.683 + fprintf (stderr, "silk_RSHITF32(%d, %d) in %s: line %d\n", a, shift, file, line); 1.684 +#ifdef FIXED_DEBUG_ASSERT 1.685 + silk_assert( 0 ); 1.686 +#endif 1.687 + } 1.688 + return a >> shift; 1.689 +} 1.690 + 1.691 +#undef silk_RSHIFT64 1.692 +#define silk_RSHIFT64(a,b) silk_RSHIFT64_((a), (b), __FILE__, __LINE__) 1.693 +static OPUS_INLINE opus_int64 silk_RSHIFT64_(opus_int64 a, opus_int64 shift, char *file, int line){ 1.694 + if ( (shift < 0) || (shift>=64) ) 1.695 + { 1.696 + fprintf (stderr, "silk_RSHITF64(%lld, %lld) in %s: line %d\n", (long long)a, (long long)shift, file, line); 1.697 +#ifdef FIXED_DEBUG_ASSERT 1.698 + silk_assert( 0 ); 1.699 +#endif 1.700 + } 1.701 + return a >> shift; 1.702 +} 1.703 + 1.704 +#undef silk_RSHIFT_uint 1.705 +#define silk_RSHIFT_uint(a,b) silk_RSHIFT_uint_((a), (b), __FILE__, __LINE__) 1.706 +static OPUS_INLINE opus_uint32 silk_RSHIFT_uint_(opus_uint32 a, opus_int32 shift, char *file, int line){ 1.707 + if ( (shift < 0) || (shift>32) ) 1.708 + { 1.709 + fprintf (stderr, "silk_RSHIFT_uint(%u, %d) in %s: line %d\n", a, shift, file, line); 1.710 +#ifdef FIXED_DEBUG_ASSERT 1.711 + silk_assert( 0 ); 1.712 +#endif 1.713 + } 1.714 + return a >> shift; 1.715 +} 1.716 + 1.717 +#undef silk_ADD_LSHIFT 1.718 +#define silk_ADD_LSHIFT(a,b,c) silk_ADD_LSHIFT_((a), (b), (c), __FILE__, __LINE__) 1.719 +static OPUS_INLINE int silk_ADD_LSHIFT_(int a, int b, int shift, char *file, int line){ 1.720 + opus_int16 ret; 1.721 + ret = a + (b << shift); 1.722 + if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) << shift)) ) 1.723 + { 1.724 + fprintf (stderr, "silk_ADD_LSHIFT(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 1.725 +#ifdef FIXED_DEBUG_ASSERT 1.726 + silk_assert( 0 ); 1.727 +#endif 1.728 + } 1.729 + return ret; /* shift >= 0 */ 1.730 +} 1.731 + 1.732 +#undef silk_ADD_LSHIFT32 1.733 +#define silk_ADD_LSHIFT32(a,b,c) silk_ADD_LSHIFT32_((a), (b), (c), __FILE__, __LINE__) 1.734 +static OPUS_INLINE opus_int32 silk_ADD_LSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){ 1.735 + opus_int32 ret; 1.736 + ret = a + (b << shift); 1.737 + if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) << shift)) ) 1.738 + { 1.739 + fprintf (stderr, "silk_ADD_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 1.740 +#ifdef FIXED_DEBUG_ASSERT 1.741 + silk_assert( 0 ); 1.742 +#endif 1.743 + } 1.744 + return ret; /* shift >= 0 */ 1.745 +} 1.746 + 1.747 +#undef silk_ADD_LSHIFT_uint 1.748 +#define silk_ADD_LSHIFT_uint(a,b,c) silk_ADD_LSHIFT_uint_((a), (b), (c), __FILE__, __LINE__) 1.749 +static OPUS_INLINE opus_uint32 silk_ADD_LSHIFT_uint_(opus_uint32 a, opus_uint32 b, opus_int32 shift, char *file, int line){ 1.750 + opus_uint32 ret; 1.751 + ret = a + (b << shift); 1.752 + if ( (shift < 0) || (shift>32) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) << shift)) ) 1.753 + { 1.754 + fprintf (stderr, "silk_ADD_LSHIFT_uint(%u, %u, %d) in %s: line %d\n", a, b, shift, file, line); 1.755 +#ifdef FIXED_DEBUG_ASSERT 1.756 + silk_assert( 0 ); 1.757 +#endif 1.758 + } 1.759 + return ret; /* shift >= 0 */ 1.760 +} 1.761 + 1.762 +#undef silk_ADD_RSHIFT 1.763 +#define silk_ADD_RSHIFT(a,b,c) silk_ADD_RSHIFT_((a), (b), (c), __FILE__, __LINE__) 1.764 +static OPUS_INLINE int silk_ADD_RSHIFT_(int a, int b, int shift, char *file, int line){ 1.765 + opus_int16 ret; 1.766 + ret = a + (b >> shift); 1.767 + if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) >> shift)) ) 1.768 + { 1.769 + fprintf (stderr, "silk_ADD_RSHIFT(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 1.770 +#ifdef FIXED_DEBUG_ASSERT 1.771 + silk_assert( 0 ); 1.772 +#endif 1.773 + } 1.774 + return ret; /* shift > 0 */ 1.775 +} 1.776 + 1.777 +#undef silk_ADD_RSHIFT32 1.778 +#define silk_ADD_RSHIFT32(a,b,c) silk_ADD_RSHIFT32_((a), (b), (c), __FILE__, __LINE__) 1.779 +static OPUS_INLINE opus_int32 silk_ADD_RSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){ 1.780 + opus_int32 ret; 1.781 + ret = a + (b >> shift); 1.782 + if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) >> shift)) ) 1.783 + { 1.784 + fprintf (stderr, "silk_ADD_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 1.785 +#ifdef FIXED_DEBUG_ASSERT 1.786 + silk_assert( 0 ); 1.787 +#endif 1.788 + } 1.789 + return ret; /* shift > 0 */ 1.790 +} 1.791 + 1.792 +#undef silk_ADD_RSHIFT_uint 1.793 +#define silk_ADD_RSHIFT_uint(a,b,c) silk_ADD_RSHIFT_uint_((a), (b), (c), __FILE__, __LINE__) 1.794 +static OPUS_INLINE opus_uint32 silk_ADD_RSHIFT_uint_(opus_uint32 a, opus_uint32 b, opus_int32 shift, char *file, int line){ 1.795 + opus_uint32 ret; 1.796 + ret = a + (b >> shift); 1.797 + if ( (shift < 0) || (shift>32) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) >> shift)) ) 1.798 + { 1.799 + fprintf (stderr, "silk_ADD_RSHIFT_uint(%u, %u, %d) in %s: line %d\n", a, b, shift, file, line); 1.800 +#ifdef FIXED_DEBUG_ASSERT 1.801 + silk_assert( 0 ); 1.802 +#endif 1.803 + } 1.804 + return ret; /* shift > 0 */ 1.805 +} 1.806 + 1.807 +#undef silk_SUB_LSHIFT32 1.808 +#define silk_SUB_LSHIFT32(a,b,c) silk_SUB_LSHIFT32_((a), (b), (c), __FILE__, __LINE__) 1.809 +static OPUS_INLINE opus_int32 silk_SUB_LSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){ 1.810 + opus_int32 ret; 1.811 + ret = a - (b << shift); 1.812 + if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opus_int64)b) << shift)) ) 1.813 + { 1.814 + fprintf (stderr, "silk_SUB_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 1.815 +#ifdef FIXED_DEBUG_ASSERT 1.816 + silk_assert( 0 ); 1.817 +#endif 1.818 + } 1.819 + return ret; /* shift >= 0 */ 1.820 +} 1.821 + 1.822 +#undef silk_SUB_RSHIFT32 1.823 +#define silk_SUB_RSHIFT32(a,b,c) silk_SUB_RSHIFT32_((a), (b), (c), __FILE__, __LINE__) 1.824 +static OPUS_INLINE opus_int32 silk_SUB_RSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){ 1.825 + opus_int32 ret; 1.826 + ret = a - (b >> shift); 1.827 + if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opus_int64)b) >> shift)) ) 1.828 + { 1.829 + fprintf (stderr, "silk_SUB_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 1.830 +#ifdef FIXED_DEBUG_ASSERT 1.831 + silk_assert( 0 ); 1.832 +#endif 1.833 + } 1.834 + return ret; /* shift > 0 */ 1.835 +} 1.836 + 1.837 +#undef silk_RSHIFT_ROUND 1.838 +#define silk_RSHIFT_ROUND(a,b) silk_RSHIFT_ROUND_((a), (b), __FILE__, __LINE__) 1.839 +static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND_(opus_int32 a, opus_int32 shift, char *file, int line){ 1.840 + opus_int32 ret; 1.841 + ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; 1.842 + /* the marco definition can't handle a shift of zero */ 1.843 + if ( (shift <= 0) || (shift>31) || ((opus_int64)ret != ((opus_int64)a + ((opus_int64)1 << (shift - 1))) >> shift) ) 1.844 + { 1.845 + fprintf (stderr, "silk_RSHIFT_ROUND(%d, %d) in %s: line %d\n", a, shift, file, line); 1.846 +#ifdef FIXED_DEBUG_ASSERT 1.847 + silk_assert( 0 ); 1.848 +#endif 1.849 + } 1.850 + return ret; 1.851 +} 1.852 + 1.853 +#undef silk_RSHIFT_ROUND64 1.854 +#define silk_RSHIFT_ROUND64(a,b) silk_RSHIFT_ROUND64_((a), (b), __FILE__, __LINE__) 1.855 +static OPUS_INLINE opus_int64 silk_RSHIFT_ROUND64_(opus_int64 a, opus_int32 shift, char *file, int line){ 1.856 + opus_int64 ret; 1.857 + /* the marco definition can't handle a shift of zero */ 1.858 + if ( (shift <= 0) || (shift>=64) ) 1.859 + { 1.860 + fprintf (stderr, "silk_RSHIFT_ROUND64(%lld, %d) in %s: line %d\n", (long long)a, shift, file, line); 1.861 +#ifdef FIXED_DEBUG_ASSERT 1.862 + silk_assert( 0 ); 1.863 +#endif 1.864 + } 1.865 + ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; 1.866 + return ret; 1.867 +} 1.868 + 1.869 +/* silk_abs is used on floats also, so doesn't work... */ 1.870 +/*#undef silk_abs 1.871 +static OPUS_INLINE opus_int32 silk_abs(opus_int32 a){ 1.872 + silk_assert(a != 0x80000000); 1.873 + return (((a) > 0) ? (a) : -(a)); // Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN 1.874 +}*/ 1.875 + 1.876 +#undef silk_abs_int64 1.877 +#define silk_abs_int64(a) silk_abs_int64_((a), __FILE__, __LINE__) 1.878 +static OPUS_INLINE opus_int64 silk_abs_int64_(opus_int64 a, char *file, int line){ 1.879 + if ( a == silk_int64_MIN ) 1.880 + { 1.881 + fprintf (stderr, "silk_abs_int64(%lld) in %s: line %d\n", (long long)a, file, line); 1.882 +#ifdef FIXED_DEBUG_ASSERT 1.883 + silk_assert( 0 ); 1.884 +#endif 1.885 + } 1.886 + return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */ 1.887 +} 1.888 + 1.889 +#undef silk_abs_int32 1.890 +#define silk_abs_int32(a) silk_abs_int32_((a), __FILE__, __LINE__) 1.891 +static OPUS_INLINE opus_int32 silk_abs_int32_(opus_int32 a, char *file, int line){ 1.892 + if ( a == silk_int32_MIN ) 1.893 + { 1.894 + fprintf (stderr, "silk_abs_int32(%d) in %s: line %d\n", a, file, line); 1.895 +#ifdef FIXED_DEBUG_ASSERT 1.896 + silk_assert( 0 ); 1.897 +#endif 1.898 + } 1.899 + return silk_abs(a); 1.900 +} 1.901 + 1.902 +#undef silk_CHECK_FIT8 1.903 +#define silk_CHECK_FIT8(a) silk_CHECK_FIT8_((a), __FILE__, __LINE__) 1.904 +static OPUS_INLINE opus_int8 silk_CHECK_FIT8_( opus_int64 a, char *file, int line ){ 1.905 + opus_int8 ret; 1.906 + ret = (opus_int8)a; 1.907 + if ( (opus_int64)ret != a ) 1.908 + { 1.909 + fprintf (stderr, "silk_CHECK_FIT8(%lld) in %s: line %d\n", (long long)a, file, line); 1.910 +#ifdef FIXED_DEBUG_ASSERT 1.911 + silk_assert( 0 ); 1.912 +#endif 1.913 + } 1.914 + return( ret ); 1.915 +} 1.916 + 1.917 +#undef silk_CHECK_FIT16 1.918 +#define silk_CHECK_FIT16(a) silk_CHECK_FIT16_((a), __FILE__, __LINE__) 1.919 +static OPUS_INLINE opus_int16 silk_CHECK_FIT16_( opus_int64 a, char *file, int line ){ 1.920 + opus_int16 ret; 1.921 + ret = (opus_int16)a; 1.922 + if ( (opus_int64)ret != a ) 1.923 + { 1.924 + fprintf (stderr, "silk_CHECK_FIT16(%lld) in %s: line %d\n", (long long)a, file, line); 1.925 +#ifdef FIXED_DEBUG_ASSERT 1.926 + silk_assert( 0 ); 1.927 +#endif 1.928 + } 1.929 + return( ret ); 1.930 +} 1.931 + 1.932 +#undef silk_CHECK_FIT32 1.933 +#define silk_CHECK_FIT32(a) silk_CHECK_FIT32_((a), __FILE__, __LINE__) 1.934 +static OPUS_INLINE opus_int32 silk_CHECK_FIT32_( opus_int64 a, char *file, int line ){ 1.935 + opus_int32 ret; 1.936 + ret = (opus_int32)a; 1.937 + if ( (opus_int64)ret != a ) 1.938 + { 1.939 + fprintf (stderr, "silk_CHECK_FIT32(%lld) in %s: line %d\n", (long long)a, file, line); 1.940 +#ifdef FIXED_DEBUG_ASSERT 1.941 + silk_assert( 0 ); 1.942 +#endif 1.943 + } 1.944 + return( ret ); 1.945 +} 1.946 + 1.947 +/* no checking for silk_NSHIFT_MUL_32_32 1.948 + no checking for silk_NSHIFT_MUL_16_16 1.949 + no checking needed for silk_min 1.950 + no checking needed for silk_max 1.951 + no checking needed for silk_sign 1.952 +*/ 1.953 + 1.954 +#endif 1.955 +#endif /* MACRO_DEBUG_H */