- Timestamp:
- Nov 23, 2006 10:19:46 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/speex/fixed_debug.h
r628 r823 92 92 if (!VERIFY_SHORT(x)) 93 93 { 94 fprintf (stderr, "EXT RACT16: input is not short: %d\n", x);94 fprintf (stderr, "EXTEND32: input is not short: %d\n", x); 95 95 } 96 96 res = x; … … 117 117 if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) 118 118 { 119 fprintf (stderr, "SH R16: inputs are not short: %d %d\n", a, shift);119 fprintf (stderr, "SHL16: inputs are not short: %d %d\n", a, shift); 120 120 } 121 121 res = a<<shift; 122 122 if (!VERIFY_SHORT(res)) 123 fprintf (stderr, "SH R16: output is not short: %d\n", res);123 fprintf (stderr, "SHL16: output is not short: %d\n", res); 124 124 spx_mips++; 125 125 return res; … … 135 135 res = a>>shift; 136 136 if (!VERIFY_INT(res)) 137 { 137 138 fprintf (stderr, "SHR32: output is not int: %d\n", (int)res); 139 } 138 140 spx_mips++; 139 141 return res; … … 144 146 if (!VERIFY_INT(a) || !VERIFY_SHORT(shift)) 145 147 { 146 fprintf (stderr, "SH R32: inputs are not int: %d %d\n", (int)a, shift);148 fprintf (stderr, "SHL32: inputs are not int: %d %d\n", (int)a, shift); 147 149 } 148 150 res = a<<shift; 149 151 if (!VERIFY_INT(res)) 150 fprintf (stderr, "SHR32: output is not int: %d\n", (int)res); 151 spx_mips++; 152 return res; 153 } 154 155 156 #define PSHR16(a,shift) (SHR16(ADD16(a,(1<<((shift)-1))),shift)) 157 #define PSHR32(a,shift) (SHR32(ADD32(a,(1<<((shift)-1))),shift)) 152 { 153 fprintf (stderr, "SHL32: output is not int: %d\n", (int)res); 154 } 155 spx_mips++; 156 return res; 157 } 158 159 #define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) 160 #define PSHR32(a,shift) (SHR32((a)+((1<<((shift))>>1)),shift)) 161 #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) 162 158 163 #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) 159 164 #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) … … 171 176 res = a+b; 172 177 if (!VERIFY_SHORT(res)) 173 fprintf (stderr, "ADD16: output is not short: %d+%d=%d\n", a,b,res); 178 { 179 fprintf (stderr, "ADD16: output is not short: %d+%d=%d\n", a,b,res); 180 } 174 181 spx_mips++; 175 182 return res; … … 221 228 #define ADD64(a,b) (MIPS_INC(a)+(b)) 222 229 223 #define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift)) 224 230 #define PSHR(a,shift) (SHR((a)+((1<<((shift))>>1)),shift)) 225 231 /* result fits in 16 bits */ 226 232 static inline short MULT16_16_16(int a, int b) … … 265 271 fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b); 266 272 } 273 if (ABS32(b)>=(1<<(15+Q))) 274 fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b); 267 275 res = (((long long)a)*(long long)b) >> Q; 268 276 if (!VERIFY_INT(res)) 269 277 fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res); 278 spx_mips+=5; 279 return res; 280 } 281 282 static inline int MULT16_32_PX(int a, long long b, int Q) 283 { 284 long long res; 285 if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) 286 { 287 fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b); 288 } 289 if (ABS32(b)>=(1<<(15+Q))) 290 fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b); 291 res = ((((long long)a)*(long long)b) + ((1<<Q)>>1))>> Q; 292 if (!VERIFY_INT(res)) 293 fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res); 270 294 spx_mips+=5; 271 295 return res; … … 279 303 #define MULT16_32_Q14(a,b) MULT16_32_QX(a,b,14) 280 304 #define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15) 305 #define MULT16_32_P15(a,b) MULT16_32_PX(a,b,15) 281 306 #define MAC16_32_Q15(c,a,b) ADD32((c),MULT16_32_Q15((a),(b))) 282 307 … … 342 367 res >>= 15; 343 368 if (!VERIFY_SHORT(res)) 369 { 344 370 fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int)res); 371 } 345 372 spx_mips+=3; 346 373 return res;
Note: See TracChangeset
for help on using the changeset viewer.