Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: silk/MacroDebug.h

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « silk/MacroCount.h ('k') | silk/NLSF2A.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*********************************************************************** 1 /***********************************************************************
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 Copyright (C) 2012 Xiph.Org Foundation 3 Copyright (C) 2012 Xiph.Org Foundation
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions 5 modification, are permitted provided that the following conditions
6 are met: 6 are met:
7 - Redistributions of source code must retain the above copyright notice, 7 - Redistributions of source code must retain the above copyright notice,
8 this list of conditions and the following disclaimer. 8 this list of conditions and the following disclaimer.
9 - Redistributions in binary form must reproduce the above copyright 9 - Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the 10 notice, this list of conditions and the following disclaimer in the
(...skipping 18 matching lines...) Expand all
29 #ifndef MACRO_DEBUG_H 29 #ifndef MACRO_DEBUG_H
30 #define MACRO_DEBUG_H 30 #define MACRO_DEBUG_H
31 31
32 /* Redefine macro functions with extensive assertion in DEBUG mode. 32 /* Redefine macro functions with extensive assertion in DEBUG mode.
33 As functions can't be undefined, this file can't work with SigProcFIX_MacroCo unt.h */ 33 As functions can't be undefined, this file can't work with SigProcFIX_MacroCo unt.h */
34 34
35 #if ( defined (FIXED_DEBUG) || ( 0 && defined (_DEBUG) ) ) && !defined (silk_MAC RO_COUNT) 35 #if ( defined (FIXED_DEBUG) || ( 0 && defined (_DEBUG) ) ) && !defined (silk_MAC RO_COUNT)
36 36
37 #undef silk_ADD16 37 #undef silk_ADD16
38 #define silk_ADD16(a,b) silk_ADD16_((a), (b), __FILE__, __LINE__) 38 #define silk_ADD16(a,b) silk_ADD16_((a), (b), __FILE__, __LINE__)
39 static inline opus_int16 silk_ADD16_(opus_int16 a, opus_int16 b, char *file, int line){ 39 static OPUS_INLINE opus_int16 silk_ADD16_(opus_int16 a, opus_int16 b, char *file , int line){
40 opus_int16 ret; 40 opus_int16 ret;
41 41
42 ret = a + b; 42 ret = a + b;
43 if ( ret != silk_ADD_SAT16( a, b ) ) 43 if ( ret != silk_ADD_SAT16( a, b ) )
44 { 44 {
45 fprintf (stderr, "silk_ADD16(%d, %d) in %s: line %d\n", a, b, file, line ); 45 fprintf (stderr, "silk_ADD16(%d, %d) in %s: line %d\n", a, b, file, line );
46 #ifdef FIXED_DEBUG_ASSERT 46 #ifdef FIXED_DEBUG_ASSERT
47 silk_assert( 0 ); 47 silk_assert( 0 );
48 #endif 48 #endif
49 } 49 }
50 return ret; 50 return ret;
51 } 51 }
52 52
53 #undef silk_ADD32 53 #undef silk_ADD32
54 #define silk_ADD32(a,b) silk_ADD32_((a), (b), __FILE__, __LINE__) 54 #define silk_ADD32(a,b) silk_ADD32_((a), (b), __FILE__, __LINE__)
55 static inline opus_int32 silk_ADD32_(opus_int32 a, opus_int32 b, char *file, int line){ 55 static OPUS_INLINE opus_int32 silk_ADD32_(opus_int32 a, opus_int32 b, char *file , int line){
56 opus_int32 ret; 56 opus_int32 ret;
57 57
58 ret = a + b; 58 ret = a + b;
59 if ( ret != silk_ADD_SAT32( a, b ) ) 59 if ( ret != silk_ADD_SAT32( a, b ) )
60 { 60 {
61 fprintf (stderr, "silk_ADD32(%d, %d) in %s: line %d\n", a, b, file, line ); 61 fprintf (stderr, "silk_ADD32(%d, %d) in %s: line %d\n", a, b, file, line );
62 #ifdef FIXED_DEBUG_ASSERT 62 #ifdef FIXED_DEBUG_ASSERT
63 silk_assert( 0 ); 63 silk_assert( 0 );
64 #endif 64 #endif
65 } 65 }
66 return ret; 66 return ret;
67 } 67 }
68 68
69 #undef silk_ADD64 69 #undef silk_ADD64
70 #define silk_ADD64(a,b) silk_ADD64_((a), (b), __FILE__, __LINE__) 70 #define silk_ADD64(a,b) silk_ADD64_((a), (b), __FILE__, __LINE__)
71 static inline opus_int64 silk_ADD64_(opus_int64 a, opus_int64 b, char *file, int line){ 71 static OPUS_INLINE opus_int64 silk_ADD64_(opus_int64 a, opus_int64 b, char *file , int line){
72 opus_int64 ret; 72 opus_int64 ret;
73 73
74 ret = a + b; 74 ret = a + b;
75 if ( ret != silk_ADD_SAT64( a, b ) ) 75 if ( ret != silk_ADD_SAT64( a, b ) )
76 { 76 {
77 fprintf (stderr, "silk_ADD64(%lld, %lld) in %s: line %d\n", (long long)a , (long long)b, file, line); 77 fprintf (stderr, "silk_ADD64(%lld, %lld) in %s: line %d\n", (long long)a , (long long)b, file, line);
78 #ifdef FIXED_DEBUG_ASSERT 78 #ifdef FIXED_DEBUG_ASSERT
79 silk_assert( 0 ); 79 silk_assert( 0 );
80 #endif 80 #endif
81 } 81 }
82 return ret; 82 return ret;
83 } 83 }
84 84
85 #undef silk_SUB16 85 #undef silk_SUB16
86 #define silk_SUB16(a,b) silk_SUB16_((a), (b), __FILE__, __LINE__) 86 #define silk_SUB16(a,b) silk_SUB16_((a), (b), __FILE__, __LINE__)
87 static inline opus_int16 silk_SUB16_(opus_int16 a, opus_int16 b, char *file, int line){ 87 static OPUS_INLINE opus_int16 silk_SUB16_(opus_int16 a, opus_int16 b, char *file , int line){
88 opus_int16 ret; 88 opus_int16 ret;
89 89
90 ret = a - b; 90 ret = a - b;
91 if ( ret != silk_SUB_SAT16( a, b ) ) 91 if ( ret != silk_SUB_SAT16( a, b ) )
92 { 92 {
93 fprintf (stderr, "silk_SUB16(%d, %d) in %s: line %d\n", a, b, file, line ); 93 fprintf (stderr, "silk_SUB16(%d, %d) in %s: line %d\n", a, b, file, line );
94 #ifdef FIXED_DEBUG_ASSERT 94 #ifdef FIXED_DEBUG_ASSERT
95 silk_assert( 0 ); 95 silk_assert( 0 );
96 #endif 96 #endif
97 } 97 }
98 return ret; 98 return ret;
99 } 99 }
100 100
101 #undef silk_SUB32 101 #undef silk_SUB32
102 #define silk_SUB32(a,b) silk_SUB32_((a), (b), __FILE__, __LINE__) 102 #define silk_SUB32(a,b) silk_SUB32_((a), (b), __FILE__, __LINE__)
103 static inline opus_int32 silk_SUB32_(opus_int32 a, opus_int32 b, char *file, int line){ 103 static OPUS_INLINE opus_int32 silk_SUB32_(opus_int32 a, opus_int32 b, char *file , int line){
104 opus_int32 ret; 104 opus_int32 ret;
105 105
106 ret = a - b; 106 ret = a - b;
107 if ( ret != silk_SUB_SAT32( a, b ) ) 107 if ( ret != silk_SUB_SAT32( a, b ) )
108 { 108 {
109 fprintf (stderr, "silk_SUB32(%d, %d) in %s: line %d\n", a, b, file, line ); 109 fprintf (stderr, "silk_SUB32(%d, %d) in %s: line %d\n", a, b, file, line );
110 #ifdef FIXED_DEBUG_ASSERT 110 #ifdef FIXED_DEBUG_ASSERT
111 silk_assert( 0 ); 111 silk_assert( 0 );
112 #endif 112 #endif
113 } 113 }
114 return ret; 114 return ret;
115 } 115 }
116 116
117 #undef silk_SUB64 117 #undef silk_SUB64
118 #define silk_SUB64(a,b) silk_SUB64_((a), (b), __FILE__, __LINE__) 118 #define silk_SUB64(a,b) silk_SUB64_((a), (b), __FILE__, __LINE__)
119 static inline opus_int64 silk_SUB64_(opus_int64 a, opus_int64 b, char *file, int line){ 119 static OPUS_INLINE opus_int64 silk_SUB64_(opus_int64 a, opus_int64 b, char *file , int line){
120 opus_int64 ret; 120 opus_int64 ret;
121 121
122 ret = a - b; 122 ret = a - b;
123 if ( ret != silk_SUB_SAT64( a, b ) ) 123 if ( ret != silk_SUB_SAT64( a, b ) )
124 { 124 {
125 fprintf (stderr, "silk_SUB64(%lld, %lld) in %s: line %d\n", (long long)a , (long long)b, file, line); 125 fprintf (stderr, "silk_SUB64(%lld, %lld) in %s: line %d\n", (long long)a , (long long)b, file, line);
126 #ifdef FIXED_DEBUG_ASSERT 126 #ifdef FIXED_DEBUG_ASSERT
127 silk_assert( 0 ); 127 silk_assert( 0 );
128 #endif 128 #endif
129 } 129 }
130 return ret; 130 return ret;
131 } 131 }
132 132
133 #undef silk_ADD_SAT16 133 #undef silk_ADD_SAT16
134 #define silk_ADD_SAT16(a,b) silk_ADD_SAT16_((a), (b), __FILE__, __LINE__) 134 #define silk_ADD_SAT16(a,b) silk_ADD_SAT16_((a), (b), __FILE__, __LINE__)
135 static inline opus_int16 silk_ADD_SAT16_( opus_int16 a16, opus_int16 b16, char * file, int line) { 135 static OPUS_INLINE opus_int16 silk_ADD_SAT16_( opus_int16 a16, opus_int16 b16, c har *file, int line) {
136 opus_int16 res; 136 opus_int16 res;
137 res = (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a16), (b16) ) ); 137 res = (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a16), (b16) ) );
138 if ( res != silk_SAT16( (opus_int32)a16 + (opus_int32)b16 ) ) 138 if ( res != silk_SAT16( (opus_int32)a16 + (opus_int32)b16 ) )
139 { 139 {
140 fprintf (stderr, "silk_ADD_SAT16(%d, %d) in %s: line %d\n", a16, b16, fi le, line); 140 fprintf (stderr, "silk_ADD_SAT16(%d, %d) in %s: line %d\n", a16, b16, fi le, line);
141 #ifdef FIXED_DEBUG_ASSERT 141 #ifdef FIXED_DEBUG_ASSERT
142 silk_assert( 0 ); 142 silk_assert( 0 );
143 #endif 143 #endif
144 } 144 }
145 return res; 145 return res;
146 } 146 }
147 147
148 #undef silk_ADD_SAT32 148 #undef silk_ADD_SAT32
149 #define silk_ADD_SAT32(a,b) silk_ADD_SAT32_((a), (b), __FILE__, __LINE__) 149 #define silk_ADD_SAT32(a,b) silk_ADD_SAT32_((a), (b), __FILE__, __LINE__)
150 static inline opus_int32 silk_ADD_SAT32_(opus_int32 a32, opus_int32 b32, char *f ile, int line){ 150 static OPUS_INLINE opus_int32 silk_ADD_SAT32_(opus_int32 a32, opus_int32 b32, ch ar *file, int line){
151 opus_int32 res; 151 opus_int32 res;
152 res = ((((opus_uint32)(a32) + (opus_uint32)(b32)) & 0x80000000) == 0 ? \ 152 res = ((((opus_uint32)(a32) + (opus_uint32)(b32)) & 0x80000000) == 0 ? \
153 ((((a32) & (b32)) & 0x80000000) != 0 ? silk_int32_MIN : (a32)+(b32)) : \ 153 ((((a32) & (b32)) & 0x80000000) != 0 ? silk_int32_MIN : (a32)+(b32)) : \
154 ((((a32) | (b32)) & 0x80000000) == 0 ? silk_int32_MAX : (a32)+(b32)) ); 154 ((((a32) | (b32)) & 0x80000000) == 0 ? silk_int32_MAX : (a32)+(b32)) );
155 if ( res != silk_SAT32( (opus_int64)a32 + (opus_int64)b32 ) ) 155 if ( res != silk_SAT32( (opus_int64)a32 + (opus_int64)b32 ) )
156 { 156 {
157 fprintf (stderr, "silk_ADD_SAT32(%d, %d) in %s: line %d\n", a32, b32, fi le, line); 157 fprintf (stderr, "silk_ADD_SAT32(%d, %d) in %s: line %d\n", a32, b32, fi le, line);
158 #ifdef FIXED_DEBUG_ASSERT 158 #ifdef FIXED_DEBUG_ASSERT
159 silk_assert( 0 ); 159 silk_assert( 0 );
160 #endif 160 #endif
161 } 161 }
162 return res; 162 return res;
163 } 163 }
164 164
165 #undef silk_ADD_SAT64 165 #undef silk_ADD_SAT64
166 #define silk_ADD_SAT64(a,b) silk_ADD_SAT64_((a), (b), __FILE__, __LINE__) 166 #define silk_ADD_SAT64(a,b) silk_ADD_SAT64_((a), (b), __FILE__, __LINE__)
167 static inline opus_int64 silk_ADD_SAT64_( opus_int64 a64, opus_int64 b64, char * file, int line) { 167 static OPUS_INLINE opus_int64 silk_ADD_SAT64_( opus_int64 a64, opus_int64 b64, c har *file, int line) {
168 opus_int64 res; 168 opus_int64 res;
169 int fail = 0; 169 int fail = 0;
170 res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \ 170 res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \
171 ((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a 64)+(b64)) : \ 171 ((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a 64)+(b64)) : \
172 ((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a 64)+(b64)) ); 172 ((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a 64)+(b64)) );
173 if( res != a64 + b64 ) { 173 if( res != a64 + b64 ) {
174 /* Check that we saturated to the correct extreme value */ 174 /* Check that we saturated to the correct extreme value */
175 if ( !(( res == silk_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( silk _int64_MAX >> 3 ) ) ) || 175 if ( !(( res == silk_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( silk _int64_MAX >> 3 ) ) ) ||
176 ( res == silk_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( silk _int64_MIN >> 3 ) ) ) ) ) 176 ( res == silk_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( silk _int64_MIN >> 3 ) ) ) ) )
177 { 177 {
178 fail = 1; 178 fail = 1;
179 } 179 }
180 } else { 180 } else {
181 /* Saturation not necessary */ 181 /* Saturation not necessary */
182 fail = res != a64 + b64; 182 fail = res != a64 + b64;
183 } 183 }
184 if ( fail ) 184 if ( fail )
185 { 185 {
186 fprintf (stderr, "silk_ADD_SAT64(%lld, %lld) in %s: line %d\n", (long lo ng)a64, (long long)b64, file, line); 186 fprintf (stderr, "silk_ADD_SAT64(%lld, %lld) in %s: line %d\n", (long lo ng)a64, (long long)b64, file, line);
187 #ifdef FIXED_DEBUG_ASSERT 187 #ifdef FIXED_DEBUG_ASSERT
188 silk_assert( 0 ); 188 silk_assert( 0 );
189 #endif 189 #endif
190 } 190 }
191 return res; 191 return res;
192 } 192 }
193 193
194 #undef silk_SUB_SAT16 194 #undef silk_SUB_SAT16
195 #define silk_SUB_SAT16(a,b) silk_SUB_SAT16_((a), (b), __FILE__, __LINE__) 195 #define silk_SUB_SAT16(a,b) silk_SUB_SAT16_((a), (b), __FILE__, __LINE__)
196 static inline opus_int16 silk_SUB_SAT16_( opus_int16 a16, opus_int16 b16, char * file, int line ) { 196 static OPUS_INLINE opus_int16 silk_SUB_SAT16_( opus_int16 a16, opus_int16 b16, c har *file, int line ) {
197 opus_int16 res; 197 opus_int16 res;
198 res = (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a16), (b16) ) ); 198 res = (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a16), (b16) ) );
199 if ( res != silk_SAT16( (opus_int32)a16 - (opus_int32)b16 ) ) 199 if ( res != silk_SAT16( (opus_int32)a16 - (opus_int32)b16 ) )
200 { 200 {
201 fprintf (stderr, "silk_SUB_SAT16(%d, %d) in %s: line %d\n", a16, b16, fi le, line); 201 fprintf (stderr, "silk_SUB_SAT16(%d, %d) in %s: line %d\n", a16, b16, fi le, line);
202 #ifdef FIXED_DEBUG_ASSERT 202 #ifdef FIXED_DEBUG_ASSERT
203 silk_assert( 0 ); 203 silk_assert( 0 );
204 #endif 204 #endif
205 } 205 }
206 return res; 206 return res;
207 } 207 }
208 208
209 #undef silk_SUB_SAT32 209 #undef silk_SUB_SAT32
210 #define silk_SUB_SAT32(a,b) silk_SUB_SAT32_((a), (b), __FILE__, __LINE__) 210 #define silk_SUB_SAT32(a,b) silk_SUB_SAT32_((a), (b), __FILE__, __LINE__)
211 static inline opus_int32 silk_SUB_SAT32_( opus_int32 a32, opus_int32 b32, char * file, int line ) { 211 static OPUS_INLINE opus_int32 silk_SUB_SAT32_( opus_int32 a32, opus_int32 b32, c har *file, int line ) {
212 opus_int32 res; 212 opus_int32 res;
213 res = ((((opus_uint32)(a32)-(opus_uint32)(b32)) & 0x80000000) == 0 ? \ 213 res = ((((opus_uint32)(a32)-(opus_uint32)(b32)) & 0x80000000) == 0 ? \
214 (( (a32) & ((b32)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a32) -(b32)) : \ 214 (( (a32) & ((b32)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a32) -(b32)) : \
215 ((((a32)^0x80000000) & (b32) & 0x80000000) ? silk_int32_MAX : (a32) -(b32)) ); 215 ((((a32)^0x80000000) & (b32) & 0x80000000) ? silk_int32_MAX : (a32) -(b32)) );
216 if ( res != silk_SAT32( (opus_int64)a32 - (opus_int64)b32 ) ) 216 if ( res != silk_SAT32( (opus_int64)a32 - (opus_int64)b32 ) )
217 { 217 {
218 fprintf (stderr, "silk_SUB_SAT32(%d, %d) in %s: line %d\n", a32, b32, fi le, line); 218 fprintf (stderr, "silk_SUB_SAT32(%d, %d) in %s: line %d\n", a32, b32, fi le, line);
219 #ifdef FIXED_DEBUG_ASSERT 219 #ifdef FIXED_DEBUG_ASSERT
220 silk_assert( 0 ); 220 silk_assert( 0 );
221 #endif 221 #endif
222 } 222 }
223 return res; 223 return res;
224 } 224 }
225 225
226 #undef silk_SUB_SAT64 226 #undef silk_SUB_SAT64
227 #define silk_SUB_SAT64(a,b) silk_SUB_SAT64_((a), (b), __FILE__, __LINE__) 227 #define silk_SUB_SAT64(a,b) silk_SUB_SAT64_((a), (b), __FILE__, __LINE__)
228 static inline opus_int64 silk_SUB_SAT64_( opus_int64 a64, opus_int64 b64, char * file, int line ) { 228 static OPUS_INLINE opus_int64 silk_SUB_SAT64_( opus_int64 a64, opus_int64 b64, c har *file, int line ) {
229 opus_int64 res; 229 opus_int64 res;
230 int fail = 0; 230 int fail = 0;
231 res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \ 231 res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \
232 (( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? si lk_int64_MIN : (a64)-(b64)) : \ 232 (( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? si lk_int64_MIN : (a64)-(b64)) : \
233 ((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? si lk_int64_MAX : (a64)-(b64)) ); 233 ((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? si lk_int64_MAX : (a64)-(b64)) );
234 if( res != a64 - b64 ) { 234 if( res != a64 - b64 ) {
235 /* Check that we saturated to the correct extreme value */ 235 /* Check that we saturated to the correct extreme value */
236 if( !(( res == silk_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( silk_ int64_MAX >> 3 ) ) ) || 236 if( !(( res == silk_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( silk_ int64_MAX >> 3 ) ) ) ||
237 ( res == silk_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( silk_ int64_MIN >> 3 ) ) ) )) 237 ( res == silk_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( silk_ int64_MIN >> 3 ) ) ) ))
238 { 238 {
239 fail = 1; 239 fail = 1;
240 } 240 }
241 } else { 241 } else {
242 /* Saturation not necessary */ 242 /* Saturation not necessary */
243 fail = res != a64 - b64; 243 fail = res != a64 - b64;
244 } 244 }
245 if ( fail ) 245 if ( fail )
246 { 246 {
247 fprintf (stderr, "silk_SUB_SAT64(%lld, %lld) in %s: line %d\n", (long lo ng)a64, (long long)b64, file, line); 247 fprintf (stderr, "silk_SUB_SAT64(%lld, %lld) in %s: line %d\n", (long lo ng)a64, (long long)b64, file, line);
248 #ifdef FIXED_DEBUG_ASSERT 248 #ifdef FIXED_DEBUG_ASSERT
249 silk_assert( 0 ); 249 silk_assert( 0 );
250 #endif 250 #endif
251 } 251 }
252 return res; 252 return res;
253 } 253 }
254 254
255 #undef silk_MUL 255 #undef silk_MUL
256 #define silk_MUL(a,b) silk_MUL_((a), (b), __FILE__, __LINE__) 256 #define silk_MUL(a,b) silk_MUL_((a), (b), __FILE__, __LINE__)
257 static inline opus_int32 silk_MUL_(opus_int32 a32, opus_int32 b32, char *file, i nt line){ 257 static OPUS_INLINE opus_int32 silk_MUL_(opus_int32 a32, opus_int32 b32, char *fi le, int line){
258 opus_int32 ret; 258 opus_int32 ret;
259 opus_int64 ret64; 259 opus_int64 ret64;
260 ret = a32 * b32; 260 ret = a32 * b32;
261 ret64 = (opus_int64)a32 * (opus_int64)b32; 261 ret64 = (opus_int64)a32 * (opus_int64)b32;
262 if ( (opus_int64)ret != ret64 ) 262 if ( (opus_int64)ret != ret64 )
263 { 263 {
264 fprintf (stderr, "silk_MUL(%d, %d) in %s: line %d\n", a32, b32, file, li ne); 264 fprintf (stderr, "silk_MUL(%d, %d) in %s: line %d\n", a32, b32, file, li ne);
265 #ifdef FIXED_DEBUG_ASSERT 265 #ifdef FIXED_DEBUG_ASSERT
266 silk_assert( 0 ); 266 silk_assert( 0 );
267 #endif 267 #endif
268 } 268 }
269 return ret; 269 return ret;
270 } 270 }
271 271
272 #undef silk_MUL_uint 272 #undef silk_MUL_uint
273 #define silk_MUL_uint(a,b) silk_MUL_uint_((a), (b), __FILE__, __LINE__) 273 #define silk_MUL_uint(a,b) silk_MUL_uint_((a), (b), __FILE__, __LINE__)
274 static inline opus_uint32 silk_MUL_uint_(opus_uint32 a32, opus_uint32 b32, char *file, int line){ 274 static OPUS_INLINE opus_uint32 silk_MUL_uint_(opus_uint32 a32, opus_uint32 b32, char *file, int line){
275 opus_uint32 ret; 275 opus_uint32 ret;
276 ret = a32 * b32; 276 ret = a32 * b32;
277 if ( (opus_uint64)ret != (opus_uint64)a32 * (opus_uint64)b32 ) 277 if ( (opus_uint64)ret != (opus_uint64)a32 * (opus_uint64)b32 )
278 { 278 {
279 fprintf (stderr, "silk_MUL_uint(%u, %u) in %s: line %d\n", a32, b32, fil e, line); 279 fprintf (stderr, "silk_MUL_uint(%u, %u) in %s: line %d\n", a32, b32, fil e, line);
280 #ifdef FIXED_DEBUG_ASSERT 280 #ifdef FIXED_DEBUG_ASSERT
281 silk_assert( 0 ); 281 silk_assert( 0 );
282 #endif 282 #endif
283 } 283 }
284 return ret; 284 return ret;
285 } 285 }
286 286
287 #undef silk_MLA 287 #undef silk_MLA
288 #define silk_MLA(a,b,c) silk_MLA_((a), (b), (c), __FILE__, __LINE__) 288 #define silk_MLA(a,b,c) silk_MLA_((a), (b), (c), __FILE__, __LINE__)
289 static inline opus_int32 silk_MLA_(opus_int32 a32, opus_int32 b32, opus_int32 c3 2, char *file, int line){ 289 static OPUS_INLINE opus_int32 silk_MLA_(opus_int32 a32, opus_int32 b32, opus_int 32 c32, char *file, int line){
290 opus_int32 ret; 290 opus_int32 ret;
291 ret = a32 + b32 * c32; 291 ret = a32 + b32 * c32;
292 if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32 ) 292 if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32 )
293 { 293 {
294 fprintf (stderr, "silk_MLA(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 294 fprintf (stderr, "silk_MLA(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line);
295 #ifdef FIXED_DEBUG_ASSERT 295 #ifdef FIXED_DEBUG_ASSERT
296 silk_assert( 0 ); 296 silk_assert( 0 );
297 #endif 297 #endif
298 } 298 }
299 return ret; 299 return ret;
300 } 300 }
301 301
302 #undef silk_MLA_uint 302 #undef silk_MLA_uint
303 #define silk_MLA_uint(a,b,c) silk_MLA_uint_((a), (b), (c), __FILE__, __LINE__) 303 #define silk_MLA_uint(a,b,c) silk_MLA_uint_((a), (b), (c), __FILE__, __LINE__)
304 static inline opus_int32 silk_MLA_uint_(opus_uint32 a32, opus_uint32 b32, opus_u int32 c32, char *file, int line){ 304 static OPUS_INLINE opus_int32 silk_MLA_uint_(opus_uint32 a32, opus_uint32 b32, o pus_uint32 c32, char *file, int line){
305 opus_uint32 ret; 305 opus_uint32 ret;
306 ret = a32 + b32 * c32; 306 ret = a32 + b32 * c32;
307 if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32 ) 307 if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32 )
308 { 308 {
309 fprintf (stderr, "silk_MLA_uint(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); 309 fprintf (stderr, "silk_MLA_uint(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line);
310 #ifdef FIXED_DEBUG_ASSERT 310 #ifdef FIXED_DEBUG_ASSERT
311 silk_assert( 0 ); 311 silk_assert( 0 );
312 #endif 312 #endif
313 } 313 }
314 return ret; 314 return ret;
315 } 315 }
316 316
317 #undef silk_SMULWB 317 #undef silk_SMULWB
318 #define silk_SMULWB(a,b) silk_SMULWB_((a), (b), __FILE__, __LINE__) 318 #define silk_SMULWB(a,b) silk_SMULWB_((a), (b), __FILE__, __LINE__)
319 static inline opus_int32 silk_SMULWB_(opus_int32 a32, opus_int32 b32, char *file , int line){ 319 static OPUS_INLINE opus_int32 silk_SMULWB_(opus_int32 a32, opus_int32 b32, char *file, int line){
320 opus_int32 ret; 320 opus_int32 ret;
321 ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * ( opus_int32)((opus_int16)b32)) >> 16); 321 ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * ( opus_int32)((opus_int16)b32)) >> 16);
322 if ( (opus_int64)ret != ((opus_int64)a32 * (opus_int16)b32) >> 16 ) 322 if ( (opus_int64)ret != ((opus_int64)a32 * (opus_int16)b32) >> 16 )
323 { 323 {
324 fprintf (stderr, "silk_SMULWB(%d, %d) in %s: line %d\n", a32, b32, file, line); 324 fprintf (stderr, "silk_SMULWB(%d, %d) in %s: line %d\n", a32, b32, file, line);
325 #ifdef FIXED_DEBUG_ASSERT 325 #ifdef FIXED_DEBUG_ASSERT
326 silk_assert( 0 ); 326 silk_assert( 0 );
327 #endif 327 #endif
328 } 328 }
329 return ret; 329 return ret;
330 } 330 }
331 331
332 #undef silk_SMLAWB 332 #undef silk_SMLAWB
333 #define silk_SMLAWB(a,b,c) silk_SMLAWB_((a), (b), (c), __FILE__, __LINE__) 333 #define silk_SMLAWB(a,b,c) silk_SMLAWB_((a), (b), (c), __FILE__, __LINE__)
334 static inline opus_int32 silk_SMLAWB_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 334 static OPUS_INLINE opus_int32 silk_SMLAWB_(opus_int32 a32, opus_int32 b32, opus_ int32 c32, char *file, int line){
335 opus_int32 ret; 335 opus_int32 ret;
336 ret = silk_ADD32( a32, silk_SMULWB( b32, c32 ) ); 336 ret = silk_ADD32( a32, silk_SMULWB( b32, c32 ) );
337 if ( silk_ADD32( a32, silk_SMULWB( b32, c32 ) ) != silk_ADD_SAT32( a32, silk _SMULWB( b32, c32 ) ) ) 337 if ( silk_ADD32( a32, silk_SMULWB( b32, c32 ) ) != silk_ADD_SAT32( a32, silk _SMULWB( b32, c32 ) ) )
338 { 338 {
339 fprintf (stderr, "silk_SMLAWB(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line); 339 fprintf (stderr, "silk_SMLAWB(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line);
340 #ifdef FIXED_DEBUG_ASSERT 340 #ifdef FIXED_DEBUG_ASSERT
341 silk_assert( 0 ); 341 silk_assert( 0 );
342 #endif 342 #endif
343 } 343 }
344 return ret; 344 return ret;
345 } 345 }
346 346
347 #undef silk_SMULWT 347 #undef silk_SMULWT
348 #define silk_SMULWT(a,b) silk_SMULWT_((a), (b), __FILE__, __LINE__) 348 #define silk_SMULWT(a,b) silk_SMULWT_((a), (b), __FILE__, __LINE__)
349 static inline opus_int32 silk_SMULWT_(opus_int32 a32, opus_int32 b32, char *file , int line){ 349 static OPUS_INLINE opus_int32 silk_SMULWT_(opus_int32 a32, opus_int32 b32, char *file, int line){
350 opus_int32 ret; 350 opus_int32 ret;
351 ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16) ; 351 ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16) ;
352 if ( (opus_int64)ret != ((opus_int64)a32 * (b32 >> 16)) >> 16 ) 352 if ( (opus_int64)ret != ((opus_int64)a32 * (b32 >> 16)) >> 16 )
353 { 353 {
354 fprintf (stderr, "silk_SMULWT(%d, %d) in %s: line %d\n", a32, b32, file, line); 354 fprintf (stderr, "silk_SMULWT(%d, %d) in %s: line %d\n", a32, b32, file, line);
355 #ifdef FIXED_DEBUG_ASSERT 355 #ifdef FIXED_DEBUG_ASSERT
356 silk_assert( 0 ); 356 silk_assert( 0 );
357 #endif 357 #endif
358 } 358 }
359 return ret; 359 return ret;
360 } 360 }
361 361
362 #undef silk_SMLAWT 362 #undef silk_SMLAWT
363 #define silk_SMLAWT(a,b,c) silk_SMLAWT_((a), (b), (c), __FILE__, __LINE__) 363 #define silk_SMLAWT(a,b,c) silk_SMLAWT_((a), (b), (c), __FILE__, __LINE__)
364 static inline opus_int32 silk_SMLAWT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 364 static OPUS_INLINE opus_int32 silk_SMLAWT_(opus_int32 a32, opus_int32 b32, opus_ int32 c32, char *file, int line){
365 opus_int32 ret; 365 opus_int32 ret;
366 ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16 )) >> 16)); 366 ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16 )) >> 16));
367 if ( (opus_int64)ret != (opus_int64)a32 + (((opus_int64)b32 * (c32 >> 16)) > > 16) ) 367 if ( (opus_int64)ret != (opus_int64)a32 + (((opus_int64)b32 * (c32 >> 16)) > > 16) )
368 { 368 {
369 fprintf (stderr, "silk_SMLAWT(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line); 369 fprintf (stderr, "silk_SMLAWT(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line);
370 #ifdef FIXED_DEBUG_ASSERT 370 #ifdef FIXED_DEBUG_ASSERT
371 silk_assert( 0 ); 371 silk_assert( 0 );
372 #endif 372 #endif
373 } 373 }
374 return ret; 374 return ret;
375 } 375 }
376 376
377 #undef silk_SMULL 377 #undef silk_SMULL
378 #define silk_SMULL(a,b) silk_SMULL_((a), (b), __FILE__, __LINE__) 378 #define silk_SMULL(a,b) silk_SMULL_((a), (b), __FILE__, __LINE__)
379 static inline opus_int64 silk_SMULL_(opus_int64 a64, opus_int64 b64, char *file, int line){ 379 static OPUS_INLINE opus_int64 silk_SMULL_(opus_int64 a64, opus_int64 b64, char * file, int line){
380 opus_int64 ret64; 380 opus_int64 ret64;
381 int fail = 0; 381 int fail = 0;
382 ret64 = a64 * b64; 382 ret64 = a64 * b64;
383 if( b64 != 0 ) { 383 if( b64 != 0 ) {
384 fail = a64 != (ret64 / b64); 384 fail = a64 != (ret64 / b64);
385 } else if( a64 != 0 ) { 385 } else if( a64 != 0 ) {
386 fail = b64 != (ret64 / a64); 386 fail = b64 != (ret64 / a64);
387 } 387 }
388 if ( fail ) 388 if ( fail )
389 { 389 {
390 fprintf (stderr, "silk_SMULL(%lld, %lld) in %s: line %d\n", (long long)a 64, (long long)b64, file, line); 390 fprintf (stderr, "silk_SMULL(%lld, %lld) in %s: line %d\n", (long long)a 64, (long long)b64, file, line);
391 #ifdef FIXED_DEBUG_ASSERT 391 #ifdef FIXED_DEBUG_ASSERT
392 silk_assert( 0 ); 392 silk_assert( 0 );
393 #endif 393 #endif
394 } 394 }
395 return ret64; 395 return ret64;
396 } 396 }
397 397
398 /* no checking needed for silk_SMULBB */ 398 /* no checking needed for silk_SMULBB */
399 #undef silk_SMLABB 399 #undef silk_SMLABB
400 #define silk_SMLABB(a,b,c) silk_SMLABB_((a), (b), (c), __FILE__, __LINE__) 400 #define silk_SMLABB(a,b,c) silk_SMLABB_((a), (b), (c), __FILE__, __LINE__)
401 static inline opus_int32 silk_SMLABB_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 401 static OPUS_INLINE opus_int32 silk_SMLABB_(opus_int32 a32, opus_int32 b32, opus_ int32 c32, char *file, int line){
402 opus_int32 ret; 402 opus_int32 ret;
403 ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32); 403 ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32);
404 if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int16)c32 ) 404 if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int16)c32 )
405 { 405 {
406 fprintf (stderr, "silk_SMLABB(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line); 406 fprintf (stderr, "silk_SMLABB(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line);
407 #ifdef FIXED_DEBUG_ASSERT 407 #ifdef FIXED_DEBUG_ASSERT
408 silk_assert( 0 ); 408 silk_assert( 0 );
409 #endif 409 #endif
410 } 410 }
411 return ret; 411 return ret;
412 } 412 }
413 413
414 /* no checking needed for silk_SMULBT */ 414 /* no checking needed for silk_SMULBT */
415 #undef silk_SMLABT 415 #undef silk_SMLABT
416 #define silk_SMLABT(a,b,c) silk_SMLABT_((a), (b), (c), __FILE__, __LINE__) 416 #define silk_SMLABT(a,b,c) silk_SMLABT_((a), (b), (c), __FILE__, __LINE__)
417 static inline opus_int32 silk_SMLABT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 417 static OPUS_INLINE opus_int32 silk_SMLABT_(opus_int32 a32, opus_int32 b32, opus_ int32 c32, char *file, int line){
418 opus_int32 ret; 418 opus_int32 ret;
419 ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16); 419 ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16);
420 if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (c32 >> 16) ) 420 if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (c32 >> 16) )
421 { 421 {
422 fprintf (stderr, "silk_SMLABT(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line); 422 fprintf (stderr, "silk_SMLABT(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line);
423 #ifdef FIXED_DEBUG_ASSERT 423 #ifdef FIXED_DEBUG_ASSERT
424 silk_assert( 0 ); 424 silk_assert( 0 );
425 #endif 425 #endif
426 } 426 }
427 return ret; 427 return ret;
428 } 428 }
429 429
430 /* no checking needed for silk_SMULTT */ 430 /* no checking needed for silk_SMULTT */
431 #undef silk_SMLATT 431 #undef silk_SMLATT
432 #define silk_SMLATT(a,b,c) silk_SMLATT_((a), (b), (c), __FILE__, __LINE__) 432 #define silk_SMLATT(a,b,c) silk_SMLATT_((a), (b), (c), __FILE__, __LINE__)
433 static inline opus_int32 silk_SMLATT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 433 static OPUS_INLINE opus_int32 silk_SMLATT_(opus_int32 a32, opus_int32 b32, opus_ int32 c32, char *file, int line){
434 opus_int32 ret; 434 opus_int32 ret;
435 ret = a32 + (b32 >> 16) * (c32 >> 16); 435 ret = a32 + (b32 >> 16) * (c32 >> 16);
436 if ( (opus_int64)ret != (opus_int64)a32 + (b32 >> 16) * (c32 >> 16) ) 436 if ( (opus_int64)ret != (opus_int64)a32 + (b32 >> 16) * (c32 >> 16) )
437 { 437 {
438 fprintf (stderr, "silk_SMLATT(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line); 438 fprintf (stderr, "silk_SMLATT(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line);
439 #ifdef FIXED_DEBUG_ASSERT 439 #ifdef FIXED_DEBUG_ASSERT
440 silk_assert( 0 ); 440 silk_assert( 0 );
441 #endif 441 #endif
442 } 442 }
443 return ret; 443 return ret;
444 } 444 }
445 445
446 #undef silk_SMULWW 446 #undef silk_SMULWW
447 #define silk_SMULWW(a,b) silk_SMULWW_((a), (b), __FILE__, __LINE__) 447 #define silk_SMULWW(a,b) silk_SMULWW_((a), (b), __FILE__, __LINE__)
448 static inline opus_int32 silk_SMULWW_(opus_int32 a32, opus_int32 b32, char *file , int line){ 448 static OPUS_INLINE opus_int32 silk_SMULWW_(opus_int32 a32, opus_int32 b32, char *file, int line){
449 opus_int32 ret, tmp1, tmp2; 449 opus_int32 ret, tmp1, tmp2;
450 opus_int64 ret64; 450 opus_int64 ret64;
451 int fail = 0; 451 int fail = 0;
452 452
453 ret = silk_SMULWB( a32, b32 ); 453 ret = silk_SMULWB( a32, b32 );
454 tmp1 = silk_RSHIFT_ROUND( b32, 16 ); 454 tmp1 = silk_RSHIFT_ROUND( b32, 16 );
455 tmp2 = silk_MUL( a32, tmp1 ); 455 tmp2 = silk_MUL( a32, tmp1 );
456 456
457 fail |= (opus_int64)tmp2 != (opus_int64) a32 * (opus_int64) tmp1; 457 fail |= (opus_int64)tmp2 != (opus_int64) a32 * (opus_int64) tmp1;
458 458
(...skipping 10 matching lines...) Expand all
469 #ifdef FIXED_DEBUG_ASSERT 469 #ifdef FIXED_DEBUG_ASSERT
470 silk_assert( 0 ); 470 silk_assert( 0 );
471 #endif 471 #endif
472 } 472 }
473 473
474 return ret; 474 return ret;
475 } 475 }
476 476
477 #undef silk_SMLAWW 477 #undef silk_SMLAWW
478 #define silk_SMLAWW(a,b,c) silk_SMLAWW_((a), (b), (c), __FILE__, __LINE__) 478 #define silk_SMLAWW(a,b,c) silk_SMLAWW_((a), (b), (c), __FILE__, __LINE__)
479 static inline opus_int32 silk_SMLAWW_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ 479 static OPUS_INLINE opus_int32 silk_SMLAWW_(opus_int32 a32, opus_int32 b32, opus_ int32 c32, char *file, int line){
480 opus_int32 ret, tmp; 480 opus_int32 ret, tmp;
481 481
482 tmp = silk_SMULWW( b32, c32 ); 482 tmp = silk_SMULWW( b32, c32 );
483 ret = silk_ADD32( a32, tmp ); 483 ret = silk_ADD32( a32, tmp );
484 if ( ret != silk_ADD_SAT32( a32, tmp ) ) 484 if ( ret != silk_ADD_SAT32( a32, tmp ) )
485 { 485 {
486 fprintf (stderr, "silk_SMLAWW(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line); 486 fprintf (stderr, "silk_SMLAWW(%d, %d, %d) in %s: line %d\n", a32, b32, c 32, file, line);
487 #ifdef FIXED_DEBUG_ASSERT 487 #ifdef FIXED_DEBUG_ASSERT
488 silk_assert( 0 ); 488 silk_assert( 0 );
489 #endif 489 #endif
490 } 490 }
491 return ret; 491 return ret;
492 } 492 }
493 493
494 /* Multiply-accumulate macros that allow overflow in the addition (ie, no assert s in debug mode) */ 494 /* Multiply-accumulate macros that allow overflow in the addition (ie, no assert s in debug mode) */
495 #undef silk_MLA_ovflw 495 #undef silk_MLA_ovflw
496 #define silk_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32))) 496 #define silk_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32)))
497 #undef silk_SMLABB_ovflw 497 #undef silk_SMLABB_ovflw
498 #define silk_SMLABB_ovflw(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)( b32))) * (opus_int32)((opus_int16)(c32))) 498 #define silk_SMLABB_ovflw(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)( b32))) * (opus_int32)((opus_int16)(c32)))
499 499
500 /* no checking needed for silk_SMULL 500 /* no checking needed for silk_SMULL
501 no checking needed for silk_SMLAL 501 no checking needed for silk_SMLAL
502 no checking needed for silk_SMLALBB 502 no checking needed for silk_SMLALBB
503 no checking needed for SigProcFIX_CLZ16 503 no checking needed for SigProcFIX_CLZ16
504 no checking needed for SigProcFIX_CLZ32*/ 504 no checking needed for SigProcFIX_CLZ32*/
505 505
506 #undef silk_DIV32 506 #undef silk_DIV32
507 #define silk_DIV32(a,b) silk_DIV32_((a), (b), __FILE__, __LINE__) 507 #define silk_DIV32(a,b) silk_DIV32_((a), (b), __FILE__, __LINE__)
508 static inline opus_int32 silk_DIV32_(opus_int32 a32, opus_int32 b32, char *file, int line){ 508 static OPUS_INLINE opus_int32 silk_DIV32_(opus_int32 a32, opus_int32 b32, char * file, int line){
509 if ( b32 == 0 ) 509 if ( b32 == 0 )
510 { 510 {
511 fprintf (stderr, "silk_DIV32(%d, %d) in %s: line %d\n", a32, b32, file, line); 511 fprintf (stderr, "silk_DIV32(%d, %d) in %s: line %d\n", a32, b32, file, line);
512 #ifdef FIXED_DEBUG_ASSERT 512 #ifdef FIXED_DEBUG_ASSERT
513 silk_assert( 0 ); 513 silk_assert( 0 );
514 #endif 514 #endif
515 } 515 }
516 return a32 / b32; 516 return a32 / b32;
517 } 517 }
518 518
519 #undef silk_DIV32_16 519 #undef silk_DIV32_16
520 #define silk_DIV32_16(a,b) silk_DIV32_16_((a), (b), __FILE__, __LINE__) 520 #define silk_DIV32_16(a,b) silk_DIV32_16_((a), (b), __FILE__, __LINE__)
521 static inline opus_int32 silk_DIV32_16_(opus_int32 a32, opus_int32 b32, char *fi le, int line){ 521 static OPUS_INLINE opus_int32 silk_DIV32_16_(opus_int32 a32, opus_int32 b32, cha r *file, int line){
522 int fail = 0; 522 int fail = 0;
523 fail |= b32 == 0; 523 fail |= b32 == 0;
524 fail |= b32 > silk_int16_MAX; 524 fail |= b32 > silk_int16_MAX;
525 fail |= b32 < silk_int16_MIN; 525 fail |= b32 < silk_int16_MIN;
526 if ( fail ) 526 if ( fail )
527 { 527 {
528 fprintf (stderr, "silk_DIV32_16(%d, %d) in %s: line %d\n", a32, b32, fil e, line); 528 fprintf (stderr, "silk_DIV32_16(%d, %d) in %s: line %d\n", a32, b32, fil e, line);
529 #ifdef FIXED_DEBUG_ASSERT 529 #ifdef FIXED_DEBUG_ASSERT
530 silk_assert( 0 ); 530 silk_assert( 0 );
531 #endif 531 #endif
532 } 532 }
533 return a32 / b32; 533 return a32 / b32;
534 } 534 }
535 535
536 /* no checking needed for silk_SAT8 536 /* no checking needed for silk_SAT8
537 no checking needed for silk_SAT16 537 no checking needed for silk_SAT16
538 no checking needed for silk_SAT32 538 no checking needed for silk_SAT32
539 no checking needed for silk_POS_SAT32 539 no checking needed for silk_POS_SAT32
540 no checking needed for silk_ADD_POS_SAT8 540 no checking needed for silk_ADD_POS_SAT8
541 no checking needed for silk_ADD_POS_SAT16 541 no checking needed for silk_ADD_POS_SAT16
542 no checking needed for silk_ADD_POS_SAT32 542 no checking needed for silk_ADD_POS_SAT32
543 no checking needed for silk_ADD_POS_SAT64 */ 543 no checking needed for silk_ADD_POS_SAT64 */
544 544
545 #undef silk_LSHIFT8 545 #undef silk_LSHIFT8
546 #define silk_LSHIFT8(a,b) silk_LSHIFT8_((a), (b), __FILE__, __LINE__) 546 #define silk_LSHIFT8(a,b) silk_LSHIFT8_((a), (b), __FILE__, __LINE__)
547 static inline opus_int8 silk_LSHIFT8_(opus_int8 a, opus_int32 shift, char *file, int line){ 547 static OPUS_INLINE opus_int8 silk_LSHIFT8_(opus_int8 a, opus_int32 shift, char * file, int line){
548 opus_int8 ret; 548 opus_int8 ret;
549 int fail = 0; 549 int fail = 0;
550 ret = a << shift; 550 ret = a << shift;
551 fail |= shift < 0; 551 fail |= shift < 0;
552 fail |= shift >= 8; 552 fail |= shift >= 8;
553 fail |= (opus_int64)ret != ((opus_int64)a) << shift; 553 fail |= (opus_int64)ret != ((opus_int64)a) << shift;
554 if ( fail ) 554 if ( fail )
555 { 555 {
556 fprintf (stderr, "silk_LSHIFT8(%d, %d) in %s: line %d\n", a, shift, file , line); 556 fprintf (stderr, "silk_LSHIFT8(%d, %d) in %s: line %d\n", a, shift, file , line);
557 #ifdef FIXED_DEBUG_ASSERT 557 #ifdef FIXED_DEBUG_ASSERT
558 silk_assert( 0 ); 558 silk_assert( 0 );
559 #endif 559 #endif
560 } 560 }
561 return ret; 561 return ret;
562 } 562 }
563 563
564 #undef silk_LSHIFT16 564 #undef silk_LSHIFT16
565 #define silk_LSHIFT16(a,b) silk_LSHIFT16_((a), (b), __FILE__, __LINE__) 565 #define silk_LSHIFT16(a,b) silk_LSHIFT16_((a), (b), __FILE__, __LINE__)
566 static inline opus_int16 silk_LSHIFT16_(opus_int16 a, opus_int32 shift, char *fi le, int line){ 566 static OPUS_INLINE opus_int16 silk_LSHIFT16_(opus_int16 a, opus_int32 shift, cha r *file, int line){
567 opus_int16 ret; 567 opus_int16 ret;
568 int fail = 0; 568 int fail = 0;
569 ret = a << shift; 569 ret = a << shift;
570 fail |= shift < 0; 570 fail |= shift < 0;
571 fail |= shift >= 16; 571 fail |= shift >= 16;
572 fail |= (opus_int64)ret != ((opus_int64)a) << shift; 572 fail |= (opus_int64)ret != ((opus_int64)a) << shift;
573 if ( fail ) 573 if ( fail )
574 { 574 {
575 fprintf (stderr, "silk_LSHIFT16(%d, %d) in %s: line %d\n", a, shift, fil e, line); 575 fprintf (stderr, "silk_LSHIFT16(%d, %d) in %s: line %d\n", a, shift, fil e, line);
576 #ifdef FIXED_DEBUG_ASSERT 576 #ifdef FIXED_DEBUG_ASSERT
577 silk_assert( 0 ); 577 silk_assert( 0 );
578 #endif 578 #endif
579 } 579 }
580 return ret; 580 return ret;
581 } 581 }
582 582
583 #undef silk_LSHIFT32 583 #undef silk_LSHIFT32
584 #define silk_LSHIFT32(a,b) silk_LSHIFT32_((a), (b), __FILE__, __LINE__) 584 #define silk_LSHIFT32(a,b) silk_LSHIFT32_((a), (b), __FILE__, __LINE__)
585 static inline opus_int32 silk_LSHIFT32_(opus_int32 a, opus_int32 shift, char *fi le, int line){ 585 static OPUS_INLINE opus_int32 silk_LSHIFT32_(opus_int32 a, opus_int32 shift, cha r *file, int line){
586 opus_int32 ret; 586 opus_int32 ret;
587 int fail = 0; 587 int fail = 0;
588 ret = a << shift; 588 ret = a << shift;
589 fail |= shift < 0; 589 fail |= shift < 0;
590 fail |= shift >= 32; 590 fail |= shift >= 32;
591 fail |= (opus_int64)ret != ((opus_int64)a) << shift; 591 fail |= (opus_int64)ret != ((opus_int64)a) << shift;
592 if ( fail ) 592 if ( fail )
593 { 593 {
594 fprintf (stderr, "silk_LSHIFT32(%d, %d) in %s: line %d\n", a, shift, fil e, line); 594 fprintf (stderr, "silk_LSHIFT32(%d, %d) in %s: line %d\n", a, shift, fil e, line);
595 #ifdef FIXED_DEBUG_ASSERT 595 #ifdef FIXED_DEBUG_ASSERT
596 silk_assert( 0 ); 596 silk_assert( 0 );
597 #endif 597 #endif
598 } 598 }
599 return ret; 599 return ret;
600 } 600 }
601 601
602 #undef silk_LSHIFT64 602 #undef silk_LSHIFT64
603 #define silk_LSHIFT64(a,b) silk_LSHIFT64_((a), (b), __FILE__, __LINE__) 603 #define silk_LSHIFT64(a,b) silk_LSHIFT64_((a), (b), __FILE__, __LINE__)
604 static inline opus_int64 silk_LSHIFT64_(opus_int64 a, opus_int shift, char *file , int line){ 604 static OPUS_INLINE opus_int64 silk_LSHIFT64_(opus_int64 a, opus_int shift, char *file, int line){
605 opus_int64 ret; 605 opus_int64 ret;
606 int fail = 0; 606 int fail = 0;
607 ret = a << shift; 607 ret = a << shift;
608 fail |= shift < 0; 608 fail |= shift < 0;
609 fail |= shift >= 64; 609 fail |= shift >= 64;
610 fail |= (ret>>shift) != ((opus_int64)a); 610 fail |= (ret>>shift) != ((opus_int64)a);
611 if ( fail ) 611 if ( fail )
612 { 612 {
613 fprintf (stderr, "silk_LSHIFT64(%lld, %d) in %s: line %d\n", (long long) a, shift, file, line); 613 fprintf (stderr, "silk_LSHIFT64(%lld, %d) in %s: line %d\n", (long long) a, shift, file, line);
614 #ifdef FIXED_DEBUG_ASSERT 614 #ifdef FIXED_DEBUG_ASSERT
615 silk_assert( 0 ); 615 silk_assert( 0 );
616 #endif 616 #endif
617 } 617 }
618 return ret; 618 return ret;
619 } 619 }
620 620
621 #undef silk_LSHIFT_ovflw 621 #undef silk_LSHIFT_ovflw
622 #define silk_LSHIFT_ovflw(a,b) silk_LSHIFT_ovflw_((a), (b), __FILE__, __LINE__) 622 #define silk_LSHIFT_ovflw(a,b) silk_LSHIFT_ovflw_((a), (b), __FILE__, __LINE__)
623 static inline opus_int32 silk_LSHIFT_ovflw_(opus_int32 a, opus_int32 shift, char *file, int line){ 623 static OPUS_INLINE opus_int32 silk_LSHIFT_ovflw_(opus_int32 a, opus_int32 shift, char *file, int line){
624 if ( (shift < 0) || (shift >= 32) ) /* no check for overflow */ 624 if ( (shift < 0) || (shift >= 32) ) /* no check for overflow */
625 { 625 {
626 fprintf (stderr, "silk_LSHIFT_ovflw(%d, %d) in %s: line %d\n", a, shift, file, line); 626 fprintf (stderr, "silk_LSHIFT_ovflw(%d, %d) in %s: line %d\n", a, shift, file, line);
627 #ifdef FIXED_DEBUG_ASSERT 627 #ifdef FIXED_DEBUG_ASSERT
628 silk_assert( 0 ); 628 silk_assert( 0 );
629 #endif 629 #endif
630 } 630 }
631 return a << shift; 631 return a << shift;
632 } 632 }
633 633
634 #undef silk_LSHIFT_uint 634 #undef silk_LSHIFT_uint
635 #define silk_LSHIFT_uint(a,b) silk_LSHIFT_uint_((a), (b), __FILE__, __LINE__) 635 #define silk_LSHIFT_uint(a,b) silk_LSHIFT_uint_((a), (b), __FILE__, __LINE__)
636 static inline opus_uint32 silk_LSHIFT_uint_(opus_uint32 a, opus_int32 shift, cha r *file, int line){ 636 static OPUS_INLINE opus_uint32 silk_LSHIFT_uint_(opus_uint32 a, opus_int32 shift , char *file, int line){
637 opus_uint32 ret; 637 opus_uint32 ret;
638 ret = a << shift; 638 ret = a << shift;
639 if ( (shift < 0) || ((opus_int64)ret != ((opus_int64)a) << shift)) 639 if ( (shift < 0) || ((opus_int64)ret != ((opus_int64)a) << shift))
640 { 640 {
641 fprintf (stderr, "silk_LSHIFT_uint(%u, %d) in %s: line %d\n", a, shift, file, line); 641 fprintf (stderr, "silk_LSHIFT_uint(%u, %d) in %s: line %d\n", a, shift, file, line);
642 #ifdef FIXED_DEBUG_ASSERT 642 #ifdef FIXED_DEBUG_ASSERT
643 silk_assert( 0 ); 643 silk_assert( 0 );
644 #endif 644 #endif
645 } 645 }
646 return ret; 646 return ret;
647 } 647 }
648 648
649 #undef silk_RSHIFT8 649 #undef silk_RSHIFT8
650 #define silk_RSHITF8(a,b) silk_RSHIFT8_((a), (b), __FILE__, __LINE__) 650 #define silk_RSHITF8(a,b) silk_RSHIFT8_((a), (b), __FILE__, __LINE__)
651 static inline opus_int8 silk_RSHIFT8_(opus_int8 a, opus_int32 shift, char *file, int line){ 651 static OPUS_INLINE opus_int8 silk_RSHIFT8_(opus_int8 a, opus_int32 shift, char * file, int line){
652 if ( (shift < 0) || (shift>=8) ) 652 if ( (shift < 0) || (shift>=8) )
653 { 653 {
654 fprintf (stderr, "silk_RSHITF8(%d, %d) in %s: line %d\n", a, shift, file , line); 654 fprintf (stderr, "silk_RSHITF8(%d, %d) in %s: line %d\n", a, shift, file , line);
655 #ifdef FIXED_DEBUG_ASSERT 655 #ifdef FIXED_DEBUG_ASSERT
656 silk_assert( 0 ); 656 silk_assert( 0 );
657 #endif 657 #endif
658 } 658 }
659 return a >> shift; 659 return a >> shift;
660 } 660 }
661 661
662 #undef silk_RSHIFT16 662 #undef silk_RSHIFT16
663 #define silk_RSHITF16(a,b) silk_RSHIFT16_((a), (b), __FILE__, __LINE__) 663 #define silk_RSHITF16(a,b) silk_RSHIFT16_((a), (b), __FILE__, __LINE__)
664 static inline opus_int16 silk_RSHIFT16_(opus_int16 a, opus_int32 shift, char *fi le, int line){ 664 static OPUS_INLINE opus_int16 silk_RSHIFT16_(opus_int16 a, opus_int32 shift, cha r *file, int line){
665 if ( (shift < 0) || (shift>=16) ) 665 if ( (shift < 0) || (shift>=16) )
666 { 666 {
667 fprintf (stderr, "silk_RSHITF16(%d, %d) in %s: line %d\n", a, shift, fil e, line); 667 fprintf (stderr, "silk_RSHITF16(%d, %d) in %s: line %d\n", a, shift, fil e, line);
668 #ifdef FIXED_DEBUG_ASSERT 668 #ifdef FIXED_DEBUG_ASSERT
669 silk_assert( 0 ); 669 silk_assert( 0 );
670 #endif 670 #endif
671 } 671 }
672 return a >> shift; 672 return a >> shift;
673 } 673 }
674 674
675 #undef silk_RSHIFT32 675 #undef silk_RSHIFT32
676 #define silk_RSHIFT32(a,b) silk_RSHIFT32_((a), (b), __FILE__, __LINE__) 676 #define silk_RSHIFT32(a,b) silk_RSHIFT32_((a), (b), __FILE__, __LINE__)
677 static inline opus_int32 silk_RSHIFT32_(opus_int32 a, opus_int32 shift, char *fi le, int line){ 677 static OPUS_INLINE opus_int32 silk_RSHIFT32_(opus_int32 a, opus_int32 shift, cha r *file, int line){
678 if ( (shift < 0) || (shift>=32) ) 678 if ( (shift < 0) || (shift>=32) )
679 { 679 {
680 fprintf (stderr, "silk_RSHITF32(%d, %d) in %s: line %d\n", a, shift, fil e, line); 680 fprintf (stderr, "silk_RSHITF32(%d, %d) in %s: line %d\n", a, shift, fil e, line);
681 #ifdef FIXED_DEBUG_ASSERT 681 #ifdef FIXED_DEBUG_ASSERT
682 silk_assert( 0 ); 682 silk_assert( 0 );
683 #endif 683 #endif
684 } 684 }
685 return a >> shift; 685 return a >> shift;
686 } 686 }
687 687
688 #undef silk_RSHIFT64 688 #undef silk_RSHIFT64
689 #define silk_RSHIFT64(a,b) silk_RSHIFT64_((a), (b), __FILE__, __LINE__) 689 #define silk_RSHIFT64(a,b) silk_RSHIFT64_((a), (b), __FILE__, __LINE__)
690 static inline opus_int64 silk_RSHIFT64_(opus_int64 a, opus_int64 shift, char *fi le, int line){ 690 static OPUS_INLINE opus_int64 silk_RSHIFT64_(opus_int64 a, opus_int64 shift, cha r *file, int line){
691 if ( (shift < 0) || (shift>=64) ) 691 if ( (shift < 0) || (shift>=64) )
692 { 692 {
693 fprintf (stderr, "silk_RSHITF64(%lld, %lld) in %s: line %d\n", (long lon g)a, (long long)shift, file, line); 693 fprintf (stderr, "silk_RSHITF64(%lld, %lld) in %s: line %d\n", (long lon g)a, (long long)shift, file, line);
694 #ifdef FIXED_DEBUG_ASSERT 694 #ifdef FIXED_DEBUG_ASSERT
695 silk_assert( 0 ); 695 silk_assert( 0 );
696 #endif 696 #endif
697 } 697 }
698 return a >> shift; 698 return a >> shift;
699 } 699 }
700 700
701 #undef silk_RSHIFT_uint 701 #undef silk_RSHIFT_uint
702 #define silk_RSHIFT_uint(a,b) silk_RSHIFT_uint_((a), (b), __FILE__, __LINE__) 702 #define silk_RSHIFT_uint(a,b) silk_RSHIFT_uint_((a), (b), __FILE__, __LINE__)
703 static inline opus_uint32 silk_RSHIFT_uint_(opus_uint32 a, opus_int32 shift, cha r *file, int line){ 703 static OPUS_INLINE opus_uint32 silk_RSHIFT_uint_(opus_uint32 a, opus_int32 shift , char *file, int line){
704 if ( (shift < 0) || (shift>32) ) 704 if ( (shift < 0) || (shift>32) )
705 { 705 {
706 fprintf (stderr, "silk_RSHIFT_uint(%u, %d) in %s: line %d\n", a, shift, file, line); 706 fprintf (stderr, "silk_RSHIFT_uint(%u, %d) in %s: line %d\n", a, shift, file, line);
707 #ifdef FIXED_DEBUG_ASSERT 707 #ifdef FIXED_DEBUG_ASSERT
708 silk_assert( 0 ); 708 silk_assert( 0 );
709 #endif 709 #endif
710 } 710 }
711 return a >> shift; 711 return a >> shift;
712 } 712 }
713 713
714 #undef silk_ADD_LSHIFT 714 #undef silk_ADD_LSHIFT
715 #define silk_ADD_LSHIFT(a,b,c) silk_ADD_LSHIFT_((a), (b), (c), __FILE__, __LINE_ _) 715 #define silk_ADD_LSHIFT(a,b,c) silk_ADD_LSHIFT_((a), (b), (c), __FILE__, __LINE_ _)
716 static inline int silk_ADD_LSHIFT_(int a, int b, int shift, char *file, int line ){ 716 static OPUS_INLINE int silk_ADD_LSHIFT_(int a, int b, int shift, char *file, int line){
717 opus_int16 ret; 717 opus_int16 ret;
718 ret = a + (b << shift); 718 ret = a + (b << shift);
719 if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) << shift)) ) 719 if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) << shift)) )
720 { 720 {
721 fprintf (stderr, "silk_ADD_LSHIFT(%d, %d, %d) in %s: line %d\n", a, b, s hift, file, line); 721 fprintf (stderr, "silk_ADD_LSHIFT(%d, %d, %d) in %s: line %d\n", a, b, s hift, file, line);
722 #ifdef FIXED_DEBUG_ASSERT 722 #ifdef FIXED_DEBUG_ASSERT
723 silk_assert( 0 ); 723 silk_assert( 0 );
724 #endif 724 #endif
725 } 725 }
726 return ret; /* shift >= 0 */ 726 return ret; /* shift >= 0 */
727 } 727 }
728 728
729 #undef silk_ADD_LSHIFT32 729 #undef silk_ADD_LSHIFT32
730 #define silk_ADD_LSHIFT32(a,b,c) silk_ADD_LSHIFT32_((a), (b), (c), __FILE__, __L INE__) 730 #define silk_ADD_LSHIFT32(a,b,c) silk_ADD_LSHIFT32_((a), (b), (c), __FILE__, __L INE__)
731 static inline opus_int32 silk_ADD_LSHIFT32_(opus_int32 a, opus_int32 b, opus_int 32 shift, char *file, int line){ 731 static OPUS_INLINE opus_int32 silk_ADD_LSHIFT32_(opus_int32 a, opus_int32 b, opu s_int32 shift, char *file, int line){
732 opus_int32 ret; 732 opus_int32 ret;
733 ret = a + (b << shift); 733 ret = a + (b << shift);
734 if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) << shift)) ) 734 if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) << shift)) )
735 { 735 {
736 fprintf (stderr, "silk_ADD_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 736 fprintf (stderr, "silk_ADD_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
737 #ifdef FIXED_DEBUG_ASSERT 737 #ifdef FIXED_DEBUG_ASSERT
738 silk_assert( 0 ); 738 silk_assert( 0 );
739 #endif 739 #endif
740 } 740 }
741 return ret; /* shift >= 0 */ 741 return ret; /* shift >= 0 */
742 } 742 }
743 743
744 #undef silk_ADD_LSHIFT_uint 744 #undef silk_ADD_LSHIFT_uint
745 #define silk_ADD_LSHIFT_uint(a,b,c) silk_ADD_LSHIFT_uint_((a), (b), (c), __FILE_ _, __LINE__) 745 #define silk_ADD_LSHIFT_uint(a,b,c) silk_ADD_LSHIFT_uint_((a), (b), (c), __FILE_ _, __LINE__)
746 static inline opus_uint32 silk_ADD_LSHIFT_uint_(opus_uint32 a, opus_uint32 b, op us_int32 shift, char *file, int line){ 746 static OPUS_INLINE opus_uint32 silk_ADD_LSHIFT_uint_(opus_uint32 a, opus_uint32 b, opus_int32 shift, char *file, int line){
747 opus_uint32 ret; 747 opus_uint32 ret;
748 ret = a + (b << shift); 748 ret = a + (b << shift);
749 if ( (shift < 0) || (shift>32) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) << shift)) ) 749 if ( (shift < 0) || (shift>32) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) << shift)) )
750 { 750 {
751 fprintf (stderr, "silk_ADD_LSHIFT_uint(%u, %u, %d) in %s: line %d\n", a, b, shift, file, line); 751 fprintf (stderr, "silk_ADD_LSHIFT_uint(%u, %u, %d) in %s: line %d\n", a, b, shift, file, line);
752 #ifdef FIXED_DEBUG_ASSERT 752 #ifdef FIXED_DEBUG_ASSERT
753 silk_assert( 0 ); 753 silk_assert( 0 );
754 #endif 754 #endif
755 } 755 }
756 return ret; /* shift >= 0 */ 756 return ret; /* shift >= 0 */
757 } 757 }
758 758
759 #undef silk_ADD_RSHIFT 759 #undef silk_ADD_RSHIFT
760 #define silk_ADD_RSHIFT(a,b,c) silk_ADD_RSHIFT_((a), (b), (c), __FILE__, __LINE_ _) 760 #define silk_ADD_RSHIFT(a,b,c) silk_ADD_RSHIFT_((a), (b), (c), __FILE__, __LINE_ _)
761 static inline int silk_ADD_RSHIFT_(int a, int b, int shift, char *file, int line ){ 761 static OPUS_INLINE int silk_ADD_RSHIFT_(int a, int b, int shift, char *file, int line){
762 opus_int16 ret; 762 opus_int16 ret;
763 ret = a + (b >> shift); 763 ret = a + (b >> shift);
764 if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) >> shift)) ) 764 if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) >> shift)) )
765 { 765 {
766 fprintf (stderr, "silk_ADD_RSHIFT(%d, %d, %d) in %s: line %d\n", a, b, s hift, file, line); 766 fprintf (stderr, "silk_ADD_RSHIFT(%d, %d, %d) in %s: line %d\n", a, b, s hift, file, line);
767 #ifdef FIXED_DEBUG_ASSERT 767 #ifdef FIXED_DEBUG_ASSERT
768 silk_assert( 0 ); 768 silk_assert( 0 );
769 #endif 769 #endif
770 } 770 }
771 return ret; /* shift > 0 */ 771 return ret; /* shift > 0 */
772 } 772 }
773 773
774 #undef silk_ADD_RSHIFT32 774 #undef silk_ADD_RSHIFT32
775 #define silk_ADD_RSHIFT32(a,b,c) silk_ADD_RSHIFT32_((a), (b), (c), __FILE__, __L INE__) 775 #define silk_ADD_RSHIFT32(a,b,c) silk_ADD_RSHIFT32_((a), (b), (c), __FILE__, __L INE__)
776 static inline opus_int32 silk_ADD_RSHIFT32_(opus_int32 a, opus_int32 b, opus_int 32 shift, char *file, int line){ 776 static OPUS_INLINE opus_int32 silk_ADD_RSHIFT32_(opus_int32 a, opus_int32 b, opu s_int32 shift, char *file, int line){
777 opus_int32 ret; 777 opus_int32 ret;
778 ret = a + (b >> shift); 778 ret = a + (b >> shift);
779 if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) >> shift)) ) 779 if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) >> shift)) )
780 { 780 {
781 fprintf (stderr, "silk_ADD_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 781 fprintf (stderr, "silk_ADD_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
782 #ifdef FIXED_DEBUG_ASSERT 782 #ifdef FIXED_DEBUG_ASSERT
783 silk_assert( 0 ); 783 silk_assert( 0 );
784 #endif 784 #endif
785 } 785 }
786 return ret; /* shift > 0 */ 786 return ret; /* shift > 0 */
787 } 787 }
788 788
789 #undef silk_ADD_RSHIFT_uint 789 #undef silk_ADD_RSHIFT_uint
790 #define silk_ADD_RSHIFT_uint(a,b,c) silk_ADD_RSHIFT_uint_((a), (b), (c), __FILE_ _, __LINE__) 790 #define silk_ADD_RSHIFT_uint(a,b,c) silk_ADD_RSHIFT_uint_((a), (b), (c), __FILE_ _, __LINE__)
791 static inline opus_uint32 silk_ADD_RSHIFT_uint_(opus_uint32 a, opus_uint32 b, op us_int32 shift, char *file, int line){ 791 static OPUS_INLINE opus_uint32 silk_ADD_RSHIFT_uint_(opus_uint32 a, opus_uint32 b, opus_int32 shift, char *file, int line){
792 opus_uint32 ret; 792 opus_uint32 ret;
793 ret = a + (b >> shift); 793 ret = a + (b >> shift);
794 if ( (shift < 0) || (shift>32) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) >> shift)) ) 794 if ( (shift < 0) || (shift>32) || ((opus_int64)ret != (opus_int64)a + (((opu s_int64)b) >> shift)) )
795 { 795 {
796 fprintf (stderr, "silk_ADD_RSHIFT_uint(%u, %u, %d) in %s: line %d\n", a, b, shift, file, line); 796 fprintf (stderr, "silk_ADD_RSHIFT_uint(%u, %u, %d) in %s: line %d\n", a, b, shift, file, line);
797 #ifdef FIXED_DEBUG_ASSERT 797 #ifdef FIXED_DEBUG_ASSERT
798 silk_assert( 0 ); 798 silk_assert( 0 );
799 #endif 799 #endif
800 } 800 }
801 return ret; /* shift > 0 */ 801 return ret; /* shift > 0 */
802 } 802 }
803 803
804 #undef silk_SUB_LSHIFT32 804 #undef silk_SUB_LSHIFT32
805 #define silk_SUB_LSHIFT32(a,b,c) silk_SUB_LSHIFT32_((a), (b), (c), __FILE__, __L INE__) 805 #define silk_SUB_LSHIFT32(a,b,c) silk_SUB_LSHIFT32_((a), (b), (c), __FILE__, __L INE__)
806 static inline opus_int32 silk_SUB_LSHIFT32_(opus_int32 a, opus_int32 b, opus_int 32 shift, char *file, int line){ 806 static OPUS_INLINE opus_int32 silk_SUB_LSHIFT32_(opus_int32 a, opus_int32 b, opu s_int32 shift, char *file, int line){
807 opus_int32 ret; 807 opus_int32 ret;
808 ret = a - (b << shift); 808 ret = a - (b << shift);
809 if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opu s_int64)b) << shift)) ) 809 if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opu s_int64)b) << shift)) )
810 { 810 {
811 fprintf (stderr, "silk_SUB_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 811 fprintf (stderr, "silk_SUB_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
812 #ifdef FIXED_DEBUG_ASSERT 812 #ifdef FIXED_DEBUG_ASSERT
813 silk_assert( 0 ); 813 silk_assert( 0 );
814 #endif 814 #endif
815 } 815 }
816 return ret; /* shift >= 0 */ 816 return ret; /* shift >= 0 */
817 } 817 }
818 818
819 #undef silk_SUB_RSHIFT32 819 #undef silk_SUB_RSHIFT32
820 #define silk_SUB_RSHIFT32(a,b,c) silk_SUB_RSHIFT32_((a), (b), (c), __FILE__, __L INE__) 820 #define silk_SUB_RSHIFT32(a,b,c) silk_SUB_RSHIFT32_((a), (b), (c), __FILE__, __L INE__)
821 static inline opus_int32 silk_SUB_RSHIFT32_(opus_int32 a, opus_int32 b, opus_int 32 shift, char *file, int line){ 821 static OPUS_INLINE opus_int32 silk_SUB_RSHIFT32_(opus_int32 a, opus_int32 b, opu s_int32 shift, char *file, int line){
822 opus_int32 ret; 822 opus_int32 ret;
823 ret = a - (b >> shift); 823 ret = a - (b >> shift);
824 if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opu s_int64)b) >> shift)) ) 824 if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opu s_int64)b) >> shift)) )
825 { 825 {
826 fprintf (stderr, "silk_SUB_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); 826 fprintf (stderr, "silk_SUB_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
827 #ifdef FIXED_DEBUG_ASSERT 827 #ifdef FIXED_DEBUG_ASSERT
828 silk_assert( 0 ); 828 silk_assert( 0 );
829 #endif 829 #endif
830 } 830 }
831 return ret; /* shift > 0 */ 831 return ret; /* shift > 0 */
832 } 832 }
833 833
834 #undef silk_RSHIFT_ROUND 834 #undef silk_RSHIFT_ROUND
835 #define silk_RSHIFT_ROUND(a,b) silk_RSHIFT_ROUND_((a), (b), __FILE__, __LINE__) 835 #define silk_RSHIFT_ROUND(a,b) silk_RSHIFT_ROUND_((a), (b), __FILE__, __LINE__)
836 static inline opus_int32 silk_RSHIFT_ROUND_(opus_int32 a, opus_int32 shift, char *file, int line){ 836 static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND_(opus_int32 a, opus_int32 shift, char *file, int line){
837 opus_int32 ret; 837 opus_int32 ret;
838 ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; 838 ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
839 /* the marco definition can't handle a shift of zero */ 839 /* the marco definition can't handle a shift of zero */
840 if ( (shift <= 0) || (shift>31) || ((opus_int64)ret != ((opus_int64)a + ((op us_int64)1 << (shift - 1))) >> shift) ) 840 if ( (shift <= 0) || (shift>31) || ((opus_int64)ret != ((opus_int64)a + ((op us_int64)1 << (shift - 1))) >> shift) )
841 { 841 {
842 fprintf (stderr, "silk_RSHIFT_ROUND(%d, %d) in %s: line %d\n", a, shift, file, line); 842 fprintf (stderr, "silk_RSHIFT_ROUND(%d, %d) in %s: line %d\n", a, shift, file, line);
843 #ifdef FIXED_DEBUG_ASSERT 843 #ifdef FIXED_DEBUG_ASSERT
844 silk_assert( 0 ); 844 silk_assert( 0 );
845 #endif 845 #endif
846 } 846 }
847 return ret; 847 return ret;
848 } 848 }
849 849
850 #undef silk_RSHIFT_ROUND64 850 #undef silk_RSHIFT_ROUND64
851 #define silk_RSHIFT_ROUND64(a,b) silk_RSHIFT_ROUND64_((a), (b), __FILE__, __LINE __) 851 #define silk_RSHIFT_ROUND64(a,b) silk_RSHIFT_ROUND64_((a), (b), __FILE__, __LINE __)
852 static inline opus_int64 silk_RSHIFT_ROUND64_(opus_int64 a, opus_int32 shift, ch ar *file, int line){ 852 static OPUS_INLINE opus_int64 silk_RSHIFT_ROUND64_(opus_int64 a, opus_int32 shif t, char *file, int line){
853 opus_int64 ret; 853 opus_int64 ret;
854 /* the marco definition can't handle a shift of zero */ 854 /* the marco definition can't handle a shift of zero */
855 if ( (shift <= 0) || (shift>=64) ) 855 if ( (shift <= 0) || (shift>=64) )
856 { 856 {
857 fprintf (stderr, "silk_RSHIFT_ROUND64(%lld, %d) in %s: line %d\n", (long long)a, shift, file, line); 857 fprintf (stderr, "silk_RSHIFT_ROUND64(%lld, %d) in %s: line %d\n", (long long)a, shift, file, line);
858 #ifdef FIXED_DEBUG_ASSERT 858 #ifdef FIXED_DEBUG_ASSERT
859 silk_assert( 0 ); 859 silk_assert( 0 );
860 #endif 860 #endif
861 } 861 }
862 ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; 862 ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
863 return ret; 863 return ret;
864 } 864 }
865 865
866 /* silk_abs is used on floats also, so doesn't work... */ 866 /* silk_abs is used on floats also, so doesn't work... */
867 /*#undef silk_abs 867 /*#undef silk_abs
868 static inline opus_int32 silk_abs(opus_int32 a){ 868 static OPUS_INLINE opus_int32 silk_abs(opus_int32 a){
869 silk_assert(a != 0x80000000); 869 silk_assert(a != 0x80000000);
870 return (((a) > 0) ? (a) : -(a)); // Be careful, silk_abs return s wrong when input equals to silk_intXX_MIN 870 return (((a) > 0) ? (a) : -(a)); // Be careful, silk_abs return s wrong when input equals to silk_intXX_MIN
871 }*/ 871 }*/
872 872
873 #undef silk_abs_int64 873 #undef silk_abs_int64
874 #define silk_abs_int64(a) silk_abs_int64_((a), __FILE__, __LINE__) 874 #define silk_abs_int64(a) silk_abs_int64_((a), __FILE__, __LINE__)
875 static inline opus_int64 silk_abs_int64_(opus_int64 a, char *file, int line){ 875 static OPUS_INLINE opus_int64 silk_abs_int64_(opus_int64 a, char *file, int line ){
876 if ( a == silk_int64_MIN ) 876 if ( a == silk_int64_MIN )
877 { 877 {
878 fprintf (stderr, "silk_abs_int64(%lld) in %s: line %d\n", (long long)a, file, line); 878 fprintf (stderr, "silk_abs_int64(%lld) in %s: line %d\n", (long long)a, file, line);
879 #ifdef FIXED_DEBUG_ASSERT 879 #ifdef FIXED_DEBUG_ASSERT
880 silk_assert( 0 ); 880 silk_assert( 0 );
881 #endif 881 #endif
882 } 882 }
883 return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs return s wrong when input equals to silk_intXX_MIN */ 883 return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs return s wrong when input equals to silk_intXX_MIN */
884 } 884 }
885 885
886 #undef silk_abs_int32 886 #undef silk_abs_int32
887 #define silk_abs_int32(a) silk_abs_int32_((a), __FILE__, __LINE__) 887 #define silk_abs_int32(a) silk_abs_int32_((a), __FILE__, __LINE__)
888 static inline opus_int32 silk_abs_int32_(opus_int32 a, char *file, int line){ 888 static OPUS_INLINE opus_int32 silk_abs_int32_(opus_int32 a, char *file, int line ){
889 if ( a == silk_int32_MIN ) 889 if ( a == silk_int32_MIN )
890 { 890 {
891 fprintf (stderr, "silk_abs_int32(%d) in %s: line %d\n", a, file, line); 891 fprintf (stderr, "silk_abs_int32(%d) in %s: line %d\n", a, file, line);
892 #ifdef FIXED_DEBUG_ASSERT 892 #ifdef FIXED_DEBUG_ASSERT
893 silk_assert( 0 ); 893 silk_assert( 0 );
894 #endif 894 #endif
895 } 895 }
896 return silk_abs(a); 896 return silk_abs(a);
897 } 897 }
898 898
899 #undef silk_CHECK_FIT8 899 #undef silk_CHECK_FIT8
900 #define silk_CHECK_FIT8(a) silk_CHECK_FIT8_((a), __FILE__, __LINE__) 900 #define silk_CHECK_FIT8(a) silk_CHECK_FIT8_((a), __FILE__, __LINE__)
901 static inline opus_int8 silk_CHECK_FIT8_( opus_int64 a, char *file, int line ){ 901 static OPUS_INLINE opus_int8 silk_CHECK_FIT8_( opus_int64 a, char *file, int lin e ){
902 opus_int8 ret; 902 opus_int8 ret;
903 ret = (opus_int8)a; 903 ret = (opus_int8)a;
904 if ( (opus_int64)ret != a ) 904 if ( (opus_int64)ret != a )
905 { 905 {
906 fprintf (stderr, "silk_CHECK_FIT8(%lld) in %s: line %d\n", (long long)a, file, line); 906 fprintf (stderr, "silk_CHECK_FIT8(%lld) in %s: line %d\n", (long long)a, file, line);
907 #ifdef FIXED_DEBUG_ASSERT 907 #ifdef FIXED_DEBUG_ASSERT
908 silk_assert( 0 ); 908 silk_assert( 0 );
909 #endif 909 #endif
910 } 910 }
911 return( ret ); 911 return( ret );
912 } 912 }
913 913
914 #undef silk_CHECK_FIT16 914 #undef silk_CHECK_FIT16
915 #define silk_CHECK_FIT16(a) silk_CHECK_FIT16_((a), __FILE__, __LINE__) 915 #define silk_CHECK_FIT16(a) silk_CHECK_FIT16_((a), __FILE__, __LINE__)
916 static inline opus_int16 silk_CHECK_FIT16_( opus_int64 a, char *file, int line ) { 916 static OPUS_INLINE opus_int16 silk_CHECK_FIT16_( opus_int64 a, char *file, int l ine ){
917 opus_int16 ret; 917 opus_int16 ret;
918 ret = (opus_int16)a; 918 ret = (opus_int16)a;
919 if ( (opus_int64)ret != a ) 919 if ( (opus_int64)ret != a )
920 { 920 {
921 fprintf (stderr, "silk_CHECK_FIT16(%lld) in %s: line %d\n", (long long)a , file, line); 921 fprintf (stderr, "silk_CHECK_FIT16(%lld) in %s: line %d\n", (long long)a , file, line);
922 #ifdef FIXED_DEBUG_ASSERT 922 #ifdef FIXED_DEBUG_ASSERT
923 silk_assert( 0 ); 923 silk_assert( 0 );
924 #endif 924 #endif
925 } 925 }
926 return( ret ); 926 return( ret );
927 } 927 }
928 928
929 #undef silk_CHECK_FIT32 929 #undef silk_CHECK_FIT32
930 #define silk_CHECK_FIT32(a) silk_CHECK_FIT32_((a), __FILE__, __LINE__) 930 #define silk_CHECK_FIT32(a) silk_CHECK_FIT32_((a), __FILE__, __LINE__)
931 static inline opus_int32 silk_CHECK_FIT32_( opus_int64 a, char *file, int line ) { 931 static OPUS_INLINE opus_int32 silk_CHECK_FIT32_( opus_int64 a, char *file, int l ine ){
932 opus_int32 ret; 932 opus_int32 ret;
933 ret = (opus_int32)a; 933 ret = (opus_int32)a;
934 if ( (opus_int64)ret != a ) 934 if ( (opus_int64)ret != a )
935 { 935 {
936 fprintf (stderr, "silk_CHECK_FIT32(%lld) in %s: line %d\n", (long long)a , file, line); 936 fprintf (stderr, "silk_CHECK_FIT32(%lld) in %s: line %d\n", (long long)a , file, line);
937 #ifdef FIXED_DEBUG_ASSERT 937 #ifdef FIXED_DEBUG_ASSERT
938 silk_assert( 0 ); 938 silk_assert( 0 );
939 #endif 939 #endif
940 } 940 }
941 return( ret ); 941 return( ret );
942 } 942 }
943 943
944 /* no checking for silk_NSHIFT_MUL_32_32 944 /* no checking for silk_NSHIFT_MUL_32_32
945 no checking for silk_NSHIFT_MUL_16_16 945 no checking for silk_NSHIFT_MUL_16_16
946 no checking needed for silk_min 946 no checking needed for silk_min
947 no checking needed for silk_max 947 no checking needed for silk_max
948 no checking needed for silk_sign 948 no checking needed for silk_sign
949 */ 949 */
950 950
951 #endif 951 #endif
952 #endif /* MACRO_DEBUG_H */ 952 #endif /* MACRO_DEBUG_H */
OLDNEW
« no previous file with comments | « silk/MacroCount.h ('k') | silk/NLSF2A.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698