From dc4f83bef59b66608b4274c229dedf21b3fa6ecb Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Tue, 14 Aug 2012 00:37:47 -0400
Subject: [PATCH] Fixes a silly bug where only the left channel was used for
 depth estimation

Result was that stereo files with silence on the left would result in an
extremely low bitrate
---
 celt/celt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/celt/celt.c b/celt/celt.c
index f3db223ab..b3d3508f2 100644
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -1470,7 +1470,7 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
                   +QCONST16(.5f,DB_SHIFT)+SHL16(9-st->lsb_depth,DB_SHIFT)-SHL16(eMeans[i],6)
                   +MULT16_16(QCONST16(.0062,DB_SHIFT),(i+5)*(i+5));
             follower[c*st->mode->nbEBands+i] = MAX16(follower[c*st->mode->nbEBands+i], noise_floor);
-            maxDepth = MAX16(maxDepth, bandLogE[i]-noise_floor);
+            maxDepth = MAX16(maxDepth, bandLogE[c*st->mode->nbEBands+i]-noise_floor);
          }
       } while (++c<C);
       if (C==2)
-- 
GitLab