Optimizes _celt_autocorr() by using pitch_xcorr()

Computes most of the auto-correlation by reusing pitch_xcorr(). We only
need lag*(lag-1)/2 MACs to complete the calculations.
To do this, pitch_xcorr() was modified so that it no longer truncates the
length to a multiple of 4. Also, the xcorr didn't need the floor at -1.
As a side benefit, this speeds up the PLC, which uses a higher order LPC
filter.
This commit is contained in:
Jean-Marc Valin 2013-05-25 02:14:25 -04:00
parent fbf99981a6
commit e8e57a32f6
3 changed files with 58 additions and 22 deletions

View file

@ -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--;
}