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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 mem[0]=mem0; | 139 mem[0]=mem0; |
140 mem[1]=mem1; | 140 mem[1]=mem1; |
141 mem[2]=mem2; | 141 mem[2]=mem2; |
142 mem[3]=mem3; | 142 mem[3]=mem3; |
143 mem[4]=mem4; | 143 mem[4]=mem4; |
144 } | 144 } |
145 | 145 |
146 | 146 |
147 void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x
_lp, | 147 void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x
_lp, |
148 int len, int C) | 148 int len, int C, int arch) |
149 { | 149 { |
150 int i; | 150 int i; |
151 opus_val32 ac[5]; | 151 opus_val32 ac[5]; |
152 opus_val16 tmp=Q15ONE; | 152 opus_val16 tmp=Q15ONE; |
153 opus_val16 lpc[4], mem[5]={0,0,0,0,0}; | 153 opus_val16 lpc[4], mem[5]={0,0,0,0,0}; |
154 opus_val16 lpc2[5]; | 154 opus_val16 lpc2[5]; |
155 opus_val16 c1 = QCONST16(.8f,15); | 155 opus_val16 c1 = QCONST16(.8f,15); |
156 #ifdef FIXED_POINT | 156 #ifdef FIXED_POINT |
157 int shift; | 157 int shift; |
158 opus_val32 maxabs = celt_maxabs32(x[0], len); | 158 opus_val32 maxabs = celt_maxabs32(x[0], len); |
(...skipping 14 matching lines...) Expand all Loading... |
173 x_lp[i] = SHR32(HALF32(HALF32(x[0][(2*i-1)]+x[0][(2*i+1)])+x[0][2*i]), shi
ft); | 173 x_lp[i] = SHR32(HALF32(HALF32(x[0][(2*i-1)]+x[0][(2*i+1)])+x[0][2*i]), shi
ft); |
174 x_lp[0] = SHR32(HALF32(HALF32(x[0][1])+x[0][0]), shift); | 174 x_lp[0] = SHR32(HALF32(HALF32(x[0][1])+x[0][0]), shift); |
175 if (C==2) | 175 if (C==2) |
176 { | 176 { |
177 for (i=1;i<len>>1;i++) | 177 for (i=1;i<len>>1;i++) |
178 x_lp[i] += SHR32(HALF32(HALF32(x[1][(2*i-1)]+x[1][(2*i+1)])+x[1][2*i]),
shift); | 178 x_lp[i] += SHR32(HALF32(HALF32(x[1][(2*i-1)]+x[1][(2*i+1)])+x[1][2*i]),
shift); |
179 x_lp[0] += SHR32(HALF32(HALF32(x[1][1])+x[1][0]), shift); | 179 x_lp[0] += SHR32(HALF32(HALF32(x[1][1])+x[1][0]), shift); |
180 } | 180 } |
181 | 181 |
182 _celt_autocorr(x_lp, ac, NULL, 0, | 182 _celt_autocorr(x_lp, ac, NULL, 0, |
183 4, len>>1); | 183 4, len>>1, arch); |
184 | 184 |
185 /* Noise floor -40 dB */ | 185 /* Noise floor -40 dB */ |
186 #ifdef FIXED_POINT | 186 #ifdef FIXED_POINT |
187 ac[0] += SHR32(ac[0],13); | 187 ac[0] += SHR32(ac[0],13); |
188 #else | 188 #else |
189 ac[0] *= 1.0001f; | 189 ac[0] *= 1.0001f; |
190 #endif | 190 #endif |
191 /* Lag windowing */ | 191 /* Lag windowing */ |
192 for (i=1;i<=4;i++) | 192 for (i=1;i<=4;i++) |
193 { | 193 { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 #endif | 243 #endif |
244 } | 244 } |
245 | 245 |
246 #else /* Unrolled version of the pitch correlation -- runs faster on x86 and ARM
*/ | 246 #else /* Unrolled version of the pitch correlation -- runs faster on x86 and ARM
*/ |
247 | 247 |
248 #ifdef FIXED_POINT | 248 #ifdef FIXED_POINT |
249 opus_val32 | 249 opus_val32 |
250 #else | 250 #else |
251 void | 251 void |
252 #endif | 252 #endif |
253 celt_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr,
int len, int max_pitch) | 253 celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr
, int len, int max_pitch) |
254 { | 254 { |
255 int i,j; | 255 int i,j; |
| 256 /*The EDSP version requires that max_pitch is at least 1, and that _x is |
| 257 32-bit aligned. |
| 258 Since it's hard to put asserts in assembly, put them here.*/ |
| 259 celt_assert(max_pitch>0); |
| 260 celt_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0); |
256 #ifdef FIXED_POINT | 261 #ifdef FIXED_POINT |
257 opus_val32 maxcorr=1; | 262 opus_val32 maxcorr=1; |
258 #endif | 263 #endif |
259 for (i=0;i<max_pitch-3;i+=4) | 264 for (i=0;i<max_pitch-3;i+=4) |
260 { | 265 { |
261 opus_val32 sum[4]={0,0,0,0}; | 266 opus_val32 sum[4]={0,0,0,0}; |
262 xcorr_kernel(_x, _y+i, sum, len); | 267 xcorr_kernel(_x, _y+i, sum, len); |
263 xcorr[i]=sum[0]; | 268 xcorr[i]=sum[0]; |
264 xcorr[i+1]=sum[1]; | 269 xcorr[i+1]=sum[1]; |
265 xcorr[i+2]=sum[2]; | 270 xcorr[i+2]=sum[2]; |
(...skipping 16 matching lines...) Expand all Loading... |
282 maxcorr = MAX32(maxcorr, sum); | 287 maxcorr = MAX32(maxcorr, sum); |
283 #endif | 288 #endif |
284 } | 289 } |
285 #ifdef FIXED_POINT | 290 #ifdef FIXED_POINT |
286 return maxcorr; | 291 return maxcorr; |
287 #endif | 292 #endif |
288 } | 293 } |
289 | 294 |
290 #endif | 295 #endif |
291 void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR
ICT y, | 296 void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR
ICT y, |
292 int len, int max_pitch, int *pitch) | 297 int len, int max_pitch, int *pitch, int arch) |
293 { | 298 { |
294 int i, j; | 299 int i, j; |
295 int lag; | 300 int lag; |
296 int best_pitch[2]={0,0}; | 301 int best_pitch[2]={0,0}; |
297 VARDECL(opus_val16, x_lp4); | 302 VARDECL(opus_val16, x_lp4); |
298 VARDECL(opus_val16, y_lp4); | 303 VARDECL(opus_val16, y_lp4); |
299 VARDECL(opus_val32, xcorr); | 304 VARDECL(opus_val32, xcorr); |
300 #ifdef FIXED_POINT | 305 #ifdef FIXED_POINT |
301 opus_val32 maxcorr; | 306 opus_val32 maxcorr; |
302 opus_val32 xmax, ymax; | 307 opus_val32 xmax, ymax; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } else { | 340 } else { |
336 shift = 0; | 341 shift = 0; |
337 } | 342 } |
338 #endif | 343 #endif |
339 | 344 |
340 /* Coarse search with 4x decimation */ | 345 /* Coarse search with 4x decimation */ |
341 | 346 |
342 #ifdef FIXED_POINT | 347 #ifdef FIXED_POINT |
343 maxcorr = | 348 maxcorr = |
344 #endif | 349 #endif |
345 celt_pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2); | 350 celt_pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2, arch); |
346 | 351 |
347 find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch | 352 find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch |
348 #ifdef FIXED_POINT | 353 #ifdef FIXED_POINT |
349 , 0, maxcorr | 354 , 0, maxcorr |
350 #endif | 355 #endif |
351 ); | 356 ); |
352 | 357 |
353 /* Finer search with 2x decimation */ | 358 /* Finer search with 2x decimation */ |
354 #ifdef FIXED_POINT | 359 #ifdef FIXED_POINT |
355 maxcorr=1; | 360 maxcorr=1; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 offset = 0; | 528 offset = 0; |
524 if (pg > g) | 529 if (pg > g) |
525 pg = g; | 530 pg = g; |
526 *T0_ = 2*T+offset; | 531 *T0_ = 2*T+offset; |
527 | 532 |
528 if (*T0_<minperiod0) | 533 if (*T0_<minperiod0) |
529 *T0_=minperiod0; | 534 *T0_=minperiod0; |
530 RESTORE_STACK; | 535 RESTORE_STACK; |
531 return pg; | 536 return pg; |
532 } | 537 } |
OLD | NEW |