shithub: opus

Download patch

ref: a556694e128a10eb03a0cc8311e6516bdbd88674
parent: 86cb7e860064a384aeb0166bc4a0450d6b0c54ab
author: Jean-Marc Valin <[email protected]>
date: Sat Mar 1 15:14:20 EST 2008

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

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -103,8 +103,8 @@
    ec_byte_writeinit(&st->buf);
    ec_enc_init(&st->enc,&st->buf);
 
-   st->fft = kiss_fftr_alloc(MAX_PERIOD*C, 0, 0);
-   psydecay_init(&st->psy, MAX_PERIOD*C/2, st->mode->Fs);
+   st->fft = kiss_fftr_alloc(MAX_PERIOD, 0, 0);
+   psydecay_init(&st->psy, MAX_PERIOD/2, st->mode->Fs);
    
    st->in_mem = celt_alloc(N*C*sizeof(celt_sig_t));
    st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t));
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -55,29 +55,31 @@
    int n2;
    SAVE_STACK;
    n2 = lag/2;
-   ALLOC(xx, lag*C, celt_word32_t);
-   ALLOC(X, lag*C, celt_word32_t);
-   ALLOC(curve, n2*C, celt_mask_t);
+   ALLOC(xx, lag, celt_word32_t);
+   ALLOC(X, lag, celt_word32_t);
+   ALLOC(curve, n2, celt_mask_t);
    
-   for (i=0;i<C*lag;i++)
+   for (i=0;i<lag;i++)
       xx[i] = 0;
    for (c=0;c<C;c++)
       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);
    
-   compute_masking(decay, X, curve, lag*C);
+   compute_masking(decay, X, curve, lag);
 
    /* 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 (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);
    
    
-   for (i=1;i<C*n2;i++)
+   for (i=1;i<n2;i++)
    {
       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  ]))));*/