From 5f807c176fd9bc395f5e1cd030dfca3f0b14ba9f Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Tue, 7 Jan 2014 04:48:42 -0500
Subject: [PATCH] Adds SMALL_FOOTPRINT hack to the CELT PLC too

---
 celt/celt_decoder.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c
index 7ee657b35..4be14dee7 100644
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -442,7 +442,11 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
    if (noise_based)
    {
       /* Noise-based PLC/CNG */
+#ifdef SMALL_FOOTPRINT
+      celt_norm *X;
+#else
       VARDECL(celt_norm, X);
+#endif
       opus_uint32 seed;
       opus_val16 *plcLogE;
       int end;
@@ -451,9 +455,13 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
       end = st->end;
       effEnd = IMAX(start, IMIN(end, mode->effEBands));
 
-      /* Share the interleaved signal MDCT coefficient buffer with the
-         deemphasis scratch buffer. */
+#ifdef SMALL_FOOTPRINT
+      /* This is an ugly hack that breaks aliasing rules and would be easily broken,
+         but it saves almost 4kB of stack. */
+      X = (celt_norm*)(out_syn[C-1]+overlap/2);
+#else
       ALLOC(X, C*N, celt_norm);   /**< Interleaved normalised MDCTs */
+#endif
 
       if (loss_count >= 5)
          plcLogE = backgroundLogE;
-- 
GitLab