From d17bc2e8cb2e5e43a1bbd1a0d17ae49ce7e3c365 Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Thu, 27 Oct 2011 16:46:34 -0400
Subject: [PATCH] Make CBR code a bit less aggressive about low rate

---
 src/opus_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 3263ffafe..76fca8fe0 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -897,7 +897,7 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
         {
            st->silk_mode.maxBits = (st->silk_mode.bitRate * frame_size / (st->Fs * 8))*8;
            /* Reduce the initial target to make it easier to reach the CBR rate */
-           st->silk_mode.bitRate = 1;
+           st->silk_mode.bitRate = IMAX(1, st->silk_mode.bitRate-2000);
         }
         if (redundancy)
            st->silk_mode.maxBits -= st->silk_mode.maxBits/(1 + frame_size/(st->Fs/200));
-- 
GitLab