shithub: opus

Download patch

ref: 8ccaefd39b5c3f36412aad507127b10a71562e27
parent: f77e86a235b228f456452f945287d7620bd683a4
author: Jean-Marc Valin <[email protected]>
date: Tue Oct 23 12:14:49 EDT 2012

Take the PLC out of the stack size critical path

--- a/celt/celt.c
+++ b/celt/celt.c
@@ -2448,6 +2448,8 @@
       compute_inv_mdcts(st->mode, 0, freq, out_syn, overlap_mem, C, LM);
    } else {
       /* Pitch-based PLC */
+      VARDECL(opus_val32, e);
+
       if (st->loss_count == 0)
       {
          opus_val16 pitch_buf[DECODE_BUFFER_SIZE>>1];
@@ -2465,8 +2467,8 @@
          fade = QCONST16(.8f,15);
       }
 
+      ALLOC(e, MAX_PERIOD+2*st->mode->overlap, opus_val32);
       c=0; do {
-         VARDECL(opus_val32, e);
          opus_val16 exc[MAX_PERIOD];
          opus_val32 ac[LPC_ORDER+1];
          opus_val16 decay = 1;
@@ -2473,8 +2475,6 @@
          opus_val32 S1=0;
          opus_val16 mem[LPC_ORDER]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 
-         ALLOC(e, MAX_PERIOD+2*st->mode->overlap, opus_val32);
-
          offset = MAX_PERIOD-pitch_index;
          for (i=0;i<MAX_PERIOD;i++)
             exc[i] = ROUND16(out_mem[c][i], SIG_SHIFT);
@@ -2708,6 +2708,13 @@
    if (effEnd > st->mode->effEBands)
       effEnd = st->mode->effEBands;
 
+   if (data == NULL || len<=1)
+   {
+      celt_decode_lost(st, pcm, N, LM);
+      RESTORE_STACK;
+      return frame_size/st->downsample;
+   }
+
    ALLOC(freq, IMAX(CC,C)*N, celt_sig); /**< Interleaved signal MDCTs */
    ALLOC(X, C*N, celt_norm);   /**< Interleaved normalised MDCTs */
    ALLOC(bandE, st->mode->nbEBands*C, celt_ener);
@@ -2719,13 +2726,6 @@
       for (i=M*st->mode->eBands[effEnd];i<N;i++)
          X[c*N+i] = 0;
    while (++c<C);
-
-   if (data == NULL || len<=1)
-   {
-      celt_decode_lost(st, pcm, N, LM);
-      RESTORE_STACK;
-      return frame_size/st->downsample;
-   }
 
    if (dec == NULL)
    {