From 37e135677afb86a7b0136d038e534553e34e243e Mon Sep 17 00:00:00 2001
From: Gregory Maxwell <greg@xiph.org>
Date: Sat, 5 May 2012 23:12:50 -0400
Subject: [PATCH] Avoid the unnecessary resynth averaging on intensity switch
 when encoding.

Prevents some arithmetic on uninitialized memory that may contain nans.
---
 celt/bands.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/celt/bands.c b/celt/bands.c
index ff15adcb8..ebe04aee0 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -1267,8 +1267,9 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
 
          /* Switch off dual stereo to do intensity */
          dual_stereo = 0;
-         for (j=M*eBands[start];j<M*eBands[i];j++)
-            norm[j] = HALF32(norm[j]+norm2[j]);
+         if (resynth)
+            for (j=M*eBands[start];j<M*eBands[i];j++)
+               norm[j] = HALF32(norm[j]+norm2[j]);
       }
       if (dual_stereo)
       {
-- 
GitLab