From ed627f040d8c8e7ec76f7e6b7fd70b24696a86d1 Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Fri, 19 Oct 2012 19:57:19 -0400
Subject: [PATCH] Attempt to have at least two bands that are coded

This fixes a SWB hybrid issue where band 18 isn't folded and cannot even
be folded because it's wider than band 17. This was causing noise to
be injected instead.
---
 celt/rate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/celt/rate.c b/celt/rate.c
index 249e3f0f5..4e96787f2 100644
--- a/celt/rate.c
+++ b/celt/rate.c
@@ -353,7 +353,7 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int
 #ifdef FUZZING
             if ((rand()&0x1) == 0)
 #else
-            if (band_bits > ((j<prev?7:9)*band_width<<LM<<BITRES)>>4)
+            if (codedBands<=start+2 || band_bits > ((j<prev?7:9)*band_width<<LM<<BITRES)>>4)
 #endif
             {
                ec_enc_bit_logp(ec, 1, 1);
-- 
GitLab