diff --git a/celt/celt_lpc.c b/celt/celt_lpc.c index 1838319d..8c6cfecf 100644 --- a/celt/celt_lpc.c +++ b/celt/celt_lpc.c @@ -32,6 +32,7 @@ #include "celt_lpc.h" #include "stack_alloc.h" #include "mathops.h" +#include "pitch.h" void _celt_lpc( opus_val16 *_lpc, /* out: [0...p-1] LPC coefficients */ @@ -147,6 +148,7 @@ void _celt_autocorr( { opus_val32 d; int i; + int fastN=n-lag; VARDECL(opus_val16, xx); SAVE_STACK; ALLOC(xx, n, opus_val16); @@ -177,11 +179,12 @@ void _celt_autocorr( xx[i] = VSHR32(xx[i], shift); } #endif + pitch_xcorr(xx, xx, ac, fastN, lag+1); while (lag>=0) { - for (i = lag, d = 0; i < n; i++) + for (i = lag+fastN, d = 0; i < n; i++) d = MAC16_16(d, xx[i], xx[i-lag]); - ac[lag] = d; + ac[lag] += d; /*printf ("%f ", ac[lag]);*/ lag--; } diff --git a/celt/pitch.c b/celt/pitch.c index 0549804b..d4a3c115 100644 --- a/celt/pitch.c +++ b/celt/pitch.c @@ -217,11 +217,12 @@ void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x #if 0 /* This is a simple version of the pitch correlation that should work well on DSPs like Blackfin and TI C5x/C6x */ -static void pitch_xcorr(opus_val16 *x, opus_val16 *y, opus_val32 *xcorr, int len, int max_pitch #ifdef FIXED_POINT - ,opus_val32 *maxval +opus_val32 +#else +void #endif - ) +pitch_xcorr(opus_val16 *x, opus_val16 *y, opus_val32 *xcorr, int len, int max_pitch) { int i, j; #ifdef FIXED_POINT @@ -232,30 +233,29 @@ static void pitch_xcorr(opus_val16 *x, opus_val16 *y, opus_val32 *xcorr, int len opus_val32 sum = 0; for (j=0;j>2, max_pitch>>2 #ifdef FIXED_POINT - ,&maxcorr + maxcorr = #endif - ); + pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2); find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch #ifdef FIXED_POINT diff --git a/celt/pitch.h b/celt/pitch.h index 2757071a..1d567b07 100644 --- a/celt/pitch.h +++ b/celt/pitch.h @@ -45,4 +45,11 @@ void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, int N, int *T0, int prev_period, opus_val16 prev_gain); +#ifdef FIXED_POINT +opus_val32 +#else +void +#endif +pitch_xcorr(opus_val16 *_x, opus_val16 *_y, opus_val32 *xcorr, int len, int max_pitch); + #endif