OLD | NEW |
1 /* Copyright (c) 2007-2008 CSIRO | 1 /* Copyright (c) 2007-2008 CSIRO |
2 Copyright (c) 2007-2009 Xiph.Org Foundation | 2 Copyright (c) 2007-2009 Xiph.Org Foundation |
3 Written by Jean-Marc Valin */ | 3 Written by Jean-Marc Valin */ |
4 /** | 4 /** |
5 @file pitch.c | 5 @file pitch.c |
6 @brief Pitch analysis | 6 @brief Pitch analysis |
7 */ | 7 */ |
8 | 8 |
9 /* | 9 /* |
10 Redistribution and use in source and binary forms, with or without | 10 Redistribution and use in source and binary forms, with or without |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 lpc2[4] = MULT16_16_Q15(c1,lpc[3]); | 213 lpc2[4] = MULT16_16_Q15(c1,lpc[3]); |
214 celt_fir5(x_lp, lpc2, x_lp, len>>1, mem); | 214 celt_fir5(x_lp, lpc2, x_lp, len>>1, mem); |
215 } | 215 } |
216 | 216 |
217 /* Pure C implementation. */ | 217 /* Pure C implementation. */ |
218 #ifdef FIXED_POINT | 218 #ifdef FIXED_POINT |
219 opus_val32 | 219 opus_val32 |
220 #else | 220 #else |
221 void | 221 void |
222 #endif | 222 #endif |
223 #if defined(OVERRIDE_PITCH_XCORR) | |
224 celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, | 223 celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, |
225 opus_val32 *xcorr, int len, int max_pitch) | |
226 #else | |
227 celt_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y, | |
228 opus_val32 *xcorr, int len, int max_pitch, int arch) | 224 opus_val32 *xcorr, int len, int max_pitch, int arch) |
229 #endif | |
230 { | 225 { |
231 | 226 |
232 #if 0 /* This is a simple version of the pitch correlation that should work | 227 #if 0 /* This is a simple version of the pitch correlation that should work |
233 well on DSPs like Blackfin and TI C5x/C6x */ | 228 well on DSPs like Blackfin and TI C5x/C6x */ |
234 int i, j; | 229 int i, j; |
235 #ifdef FIXED_POINT | 230 #ifdef FIXED_POINT |
236 opus_val32 maxcorr=1; | 231 opus_val32 maxcorr=1; |
237 #endif | 232 #endif |
238 #if !defined(OVERRIDE_PITCH_XCORR) | 233 #if !defined(OVERRIDE_PITCH_XCORR) |
239 (void)arch; | 234 (void)arch; |
(...skipping 18 matching lines...) Expand all Loading... |
258 32-bit aligned. | 253 32-bit aligned. |
259 Since it's hard to put asserts in assembly, put them here.*/ | 254 Since it's hard to put asserts in assembly, put them here.*/ |
260 #ifdef FIXED_POINT | 255 #ifdef FIXED_POINT |
261 opus_val32 maxcorr=1; | 256 opus_val32 maxcorr=1; |
262 #endif | 257 #endif |
263 celt_assert(max_pitch>0); | 258 celt_assert(max_pitch>0); |
264 celt_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0); | 259 celt_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0); |
265 for (i=0;i<max_pitch-3;i+=4) | 260 for (i=0;i<max_pitch-3;i+=4) |
266 { | 261 { |
267 opus_val32 sum[4]={0,0,0,0}; | 262 opus_val32 sum[4]={0,0,0,0}; |
268 #if defined(OVERRIDE_PITCH_XCORR) | |
269 xcorr_kernel_c(_x, _y+i, sum, len); | |
270 #else | |
271 xcorr_kernel(_x, _y+i, sum, len, arch); | 263 xcorr_kernel(_x, _y+i, sum, len, arch); |
272 #endif | |
273 xcorr[i]=sum[0]; | 264 xcorr[i]=sum[0]; |
274 xcorr[i+1]=sum[1]; | 265 xcorr[i+1]=sum[1]; |
275 xcorr[i+2]=sum[2]; | 266 xcorr[i+2]=sum[2]; |
276 xcorr[i+3]=sum[3]; | 267 xcorr[i+3]=sum[3]; |
277 #ifdef FIXED_POINT | 268 #ifdef FIXED_POINT |
278 sum[0] = MAX32(sum[0], sum[1]); | 269 sum[0] = MAX32(sum[0], sum[1]); |
279 sum[2] = MAX32(sum[2], sum[3]); | 270 sum[2] = MAX32(sum[2], sum[3]); |
280 sum[0] = MAX32(sum[0], sum[2]); | 271 sum[0] = MAX32(sum[0], sum[2]); |
281 maxcorr = MAX32(maxcorr, sum[0]); | 272 maxcorr = MAX32(maxcorr, sum[0]); |
282 #endif | 273 #endif |
283 } | 274 } |
284 /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */ | 275 /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */ |
285 for (;i<max_pitch;i++) | 276 for (;i<max_pitch;i++) |
286 { | 277 { |
287 opus_val32 sum; | 278 opus_val32 sum; |
288 #if defined(OVERRIDE_PITCH_XCORR) | |
289 sum = celt_inner_prod_c(_x, _y+i, len); | |
290 #else | |
291 sum = celt_inner_prod(_x, _y+i, len, arch); | 279 sum = celt_inner_prod(_x, _y+i, len, arch); |
292 #endif | |
293 xcorr[i] = sum; | 280 xcorr[i] = sum; |
294 #ifdef FIXED_POINT | 281 #ifdef FIXED_POINT |
295 maxcorr = MAX32(maxcorr, sum); | 282 maxcorr = MAX32(maxcorr, sum); |
296 #endif | 283 #endif |
297 } | 284 } |
298 #ifdef FIXED_POINT | 285 #ifdef FIXED_POINT |
299 return maxcorr; | 286 return maxcorr; |
300 #endif | 287 #endif |
301 #endif | 288 #endif |
302 } | 289 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 { | 358 { |
372 opus_val32 sum; | 359 opus_val32 sum; |
373 xcorr[i] = 0; | 360 xcorr[i] = 0; |
374 if (abs(i-2*best_pitch[0])>2 && abs(i-2*best_pitch[1])>2) | 361 if (abs(i-2*best_pitch[0])>2 && abs(i-2*best_pitch[1])>2) |
375 continue; | 362 continue; |
376 #ifdef FIXED_POINT | 363 #ifdef FIXED_POINT |
377 sum = 0; | 364 sum = 0; |
378 for (j=0;j<len>>1;j++) | 365 for (j=0;j<len>>1;j++) |
379 sum += SHR32(MULT16_16(x_lp[j],y[i+j]), shift); | 366 sum += SHR32(MULT16_16(x_lp[j],y[i+j]), shift); |
380 #else | 367 #else |
381 sum = celt_inner_prod_c(x_lp, y+i, len>>1); | 368 sum = celt_inner_prod(x_lp, y+i, len>>1, arch); |
382 #endif | 369 #endif |
383 xcorr[i] = MAX32(-1, sum); | 370 xcorr[i] = MAX32(-1, sum); |
384 #ifdef FIXED_POINT | 371 #ifdef FIXED_POINT |
385 maxcorr = MAX32(maxcorr, sum); | 372 maxcorr = MAX32(maxcorr, sum); |
386 #endif | 373 #endif |
387 } | 374 } |
388 find_best_pitch(xcorr, y, len>>1, max_pitch>>1, best_pitch | 375 find_best_pitch(xcorr, y, len>>1, max_pitch>>1, best_pitch |
389 #ifdef FIXED_POINT | 376 #ifdef FIXED_POINT |
390 , shift+1, maxcorr | 377 , shift+1, maxcorr |
391 #endif | 378 #endif |
(...skipping 25 matching lines...) Expand all Loading... |
417 { | 404 { |
418 opus_val32 x2y2; | 405 opus_val32 x2y2; |
419 int sx, sy, shift; | 406 int sx, sy, shift; |
420 opus_val32 g; | 407 opus_val32 g; |
421 opus_val16 den; | 408 opus_val16 den; |
422 if (xy == 0 || xx == 0 || yy == 0) | 409 if (xy == 0 || xx == 0 || yy == 0) |
423 return 0; | 410 return 0; |
424 sx = celt_ilog2(xx)-14; | 411 sx = celt_ilog2(xx)-14; |
425 sy = celt_ilog2(yy)-14; | 412 sy = celt_ilog2(yy)-14; |
426 shift = sx + sy; | 413 shift = sx + sy; |
427 x2y2 = MULT16_16_Q14(VSHR32(xx, sx), VSHR32(yy, sy)); | 414 x2y2 = SHR32(MULT16_16(VSHR32(xx, sx), VSHR32(yy, sy)), 14); |
428 if (shift & 1) { | 415 if (shift & 1) { |
429 if (x2y2 < 32768) | 416 if (x2y2 < 32768) |
430 { | 417 { |
431 x2y2 <<= 1; | 418 x2y2 <<= 1; |
432 shift--; | 419 shift--; |
433 } else { | 420 } else { |
434 x2y2 >>= 1; | 421 x2y2 >>= 1; |
435 shift++; | 422 shift++; |
436 } | 423 } |
437 } | 424 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 offset = 0; | 535 offset = 0; |
549 if (pg > g) | 536 if (pg > g) |
550 pg = g; | 537 pg = g; |
551 *T0_ = 2*T+offset; | 538 *T0_ = 2*T+offset; |
552 | 539 |
553 if (*T0_<minperiod0) | 540 if (*T0_<minperiod0) |
554 *T0_=minperiod0; | 541 *T0_=minperiod0; |
555 RESTORE_STACK; | 542 RESTORE_STACK; |
556 return pg; | 543 return pg; |
557 } | 544 } |
OLD | NEW |