From 16abc6fe6e515fd2b6f78e61fd92c57bf3868eed Mon Sep 17 00:00:00 2001
From: "Timothy B. Terriberry" <tterribe@xiph.org>
Date: Fri, 28 Oct 2011 06:25:38 -0700
Subject: [PATCH] Fix for ec_enc_patch_initial_bits().

The test to make sure that _nbits had been encoded was checking for
 8-_nbits instead of _nbits.
This only affected cases when less than 8 bits had ever been
 encoded by the time the initial bits were patched.
---
 celt/entenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/celt/entenc.c b/celt/entenc.c
index bff2d8992..2e20c3578 100644
--- a/celt/entenc.c
+++ b/celt/entenc.c
@@ -225,7 +225,7 @@ void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){
     /*The first byte is still awaiting carry propagation.*/
     _this->rem=(_this->rem&~mask)|_val<<shift;
   }
-  else if(_this->rng<=(EC_CODE_TOP>>shift)){
+  else if(_this->rng<=(EC_CODE_TOP>>_nbits)){
     /*The renormalization loop has never been run.*/
     _this->val=(_this->val&~((opus_uint32)mask<<EC_CODE_SHIFT))|
      (opus_uint32)_val<<(EC_CODE_SHIFT+shift);
-- 
GitLab