Stereo pitch search no longer requires twice the memory/complexity.

This commit is contained in:
Jean-Marc Valin 2008-03-01 20:14:20 +11:00
parent 86cb7e8600
commit a556694e12
2 changed files with 13 additions and 11 deletions

View file

@ -103,8 +103,8 @@ CELTEncoder *celt_encoder_create(const CELTMode *mode)
ec_byte_writeinit(&st->buf); ec_byte_writeinit(&st->buf);
ec_enc_init(&st->enc,&st->buf); ec_enc_init(&st->enc,&st->buf);
st->fft = kiss_fftr_alloc(MAX_PERIOD*C, 0, 0); st->fft = kiss_fftr_alloc(MAX_PERIOD, 0, 0);
psydecay_init(&st->psy, MAX_PERIOD*C/2, st->mode->Fs); psydecay_init(&st->psy, MAX_PERIOD/2, st->mode->Fs);
st->in_mem = celt_alloc(N*C*sizeof(celt_sig_t)); st->in_mem = celt_alloc(N*C*sizeof(celt_sig_t));
st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t)); st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t));

View file

@ -55,29 +55,31 @@ void find_spectral_pitch(kiss_fftr_cfg fft, struct PsyDecay *decay, celt_sig_t *
int n2; int n2;
SAVE_STACK; SAVE_STACK;
n2 = lag/2; n2 = lag/2;
ALLOC(xx, lag*C, celt_word32_t); ALLOC(xx, lag, celt_word32_t);
ALLOC(X, lag*C, celt_word32_t); ALLOC(X, lag, celt_word32_t);
ALLOC(curve, n2*C, celt_mask_t); ALLOC(curve, n2, celt_mask_t);
for (i=0;i<C*lag;i++) for (i=0;i<lag;i++)
xx[i] = 0; xx[i] = 0;
for (c=0;c<C;c++) for (c=0;c<C;c++)
for (i=0;i<len;i++) for (i=0;i<len;i++)
xx[c*lag+i] = x[C*i+c]; xx[i] += SHR32(x[C*i+c],1);
kiss_fftr(fft, xx, X); kiss_fftr(fft, xx, X);
compute_masking(decay, X, curve, lag*C); compute_masking(decay, X, curve, lag);
/* Deferred allocation to reduce peak stack usage */ /* Deferred allocation to reduce peak stack usage */
ALLOC(Y, lag*C, celt_word32_t); ALLOC(Y, lag, celt_word32_t);
for (i=0;i<lag;i++)
xx[i] = 0;
for (c=0;c<C;c++) for (c=0;c<C;c++)
for (i=0;i<lag;i++) for (i=0;i<lag;i++)
xx[c*lag+i] = y[C*i+c]; xx[i] += SHR32(y[C*i+c],1);
kiss_fftr(fft, xx, Y); kiss_fftr(fft, xx, Y);
for (i=1;i<C*n2;i++) for (i=1;i<n2;i++)
{ {
float n, tmp; float n, tmp;
/*n = 1.f/(1e1+sqrt(sqrt((X[2*i-1]*X[2*i-1] + X[2*i ]*X[2*i ])*(Y[2*i-1]*Y[2*i-1] + Y[2*i ]*Y[2*i ]))));*/ /*n = 1.f/(1e1+sqrt(sqrt((X[2*i-1]*X[2*i-1] + X[2*i ]*X[2*i ])*(Y[2*i-1]*Y[2*i-1] + Y[2*i ]*Y[2*i ]))));*/