shithub: opus

Download patch

ref: e0884feb36599f3b3196ca3629bb988c50dc8d26
parent: e7ec933cb8b8ebaeb82f89a3ffc34f290cdd7b02
author: Nils Wallménius <[email protected]>
date: Sat Dec 1 16:11:50 EST 2012

Window both sides of overlap when adding them.

Signed-off-by: Jean-Marc Valin <[email protected]>

--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -495,7 +495,7 @@
          }
 
          /* Move memory one frame to the left */
-         OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap);
+         OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap/2);
 
          /* Extrapolate excitation with the right period, taking decay into account */
          for (i=0;i<len;i++)
@@ -562,11 +562,8 @@
             MDCT of next frames. */
          for (i=0;i<overlap/2;i++)
          {
-            opus_val32 tmp;
-            tmp = MULT16_32_Q15(mode->window[i],           etmp[overlap-1-i]) +
-                  MULT16_32_Q15(mode->window[overlap-i-1], etmp[i          ]);
-            out_mem[c][MAX_PERIOD+i] = MULT16_32_Q15(mode->window[overlap-i-1], tmp);
-            out_mem[c][MAX_PERIOD+overlap-i-1] = MULT16_32_Q15(mode->window[i], tmp);
+            out_mem[c][MAX_PERIOD+i] = MULT16_32_Q15(mode->window[i], etmp[overlap-1-i]) +
+                                       MULT16_32_Q15(mode->window[overlap-i-1], etmp[i]);
          }
       } while (++c<C);
    }
@@ -858,7 +855,7 @@
    denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M);
 
    c=0; do {
-      OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap);
+      OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap/2);
    } while (++c<CC);
 
    c=0; do {
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1741,7 +1741,7 @@
       denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M);
 
       c=0; do {
-         OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap);
+         OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap/2);
       } while (++c<CC);
 
       if (CC==2&&C==1)
--- a/celt/mdct.c
+++ b/celt/mdct.c
@@ -291,10 +291,11 @@
       }
       for(; i < N4; i++)
       {
-         kiss_fft_scalar x1;
+         kiss_fft_scalar x1, x2;
          x1 = *fp1--;
-         *yp1++ +=-MULT16_32_Q15(*wp1, x1);
-         *xp1-- += MULT16_32_Q15(*wp2, x1);
+         x2 = *yp1;
+         *yp1++ = MULT16_32_Q15(*wp2, x2) - MULT16_32_Q15(*wp1, x1);
+         *xp1-- = MULT16_32_Q15(*wp1, x2) + MULT16_32_Q15(*wp2, x1);
          wp1++;
          wp2--;
       }
@@ -302,9 +303,6 @@
    {
       kiss_fft_scalar * OPUS_RESTRICT fp2 = f2+N4;
       kiss_fft_scalar * OPUS_RESTRICT xp2 = out+N2;
-      kiss_fft_scalar * OPUS_RESTRICT yp2 = out+N-1-(N4-overlap/2);
-      const opus_val16 * OPUS_RESTRICT wp1 = window;
-      const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1;
       for(i = 0; i< N4-overlap/2; i++)
       {
          *xp2 = *fp2;
@@ -313,12 +311,7 @@
       }
       for(; i < N4; i++)
       {
-         kiss_fft_scalar x2;
-         x2 = *fp2++;
-         *yp2--  = MULT16_32_Q15(*wp1, x2);
-         *xp2++  = MULT16_32_Q15(*wp2, x2);
-         wp1++;
-         wp2--;
+         *xp2++ = *fp2++;
       }
    }
    RESTORE_STACK;