diff options
author | Timothy B. Terriberry <tterribe@xiph.org> | 2011-11-29 08:03:03 -0800 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-12-02 15:37:29 -0500 |
commit | 6619a736376221f2782cecff55d051c3ecfc2ff7 (patch) | |
tree | 12b324072d512165ec630a0f3e7f7fcd65c4cb00 /celt | |
parent | 92c896e8806ec34c826e638512f7e33f1c9edcd0 (diff) | |
download | libopus-6619a736376221f2782cecff55d051c3ecfc2ff7.tar.gz |
Move nbits_total initialize before renormalization.
The range decoder used to initialize nbits_total after the
renormalization loop, even though the renormalization loop
modifies it.
This was presumably safe, because nothing actually used the value
before it was initialized, but I'm tired of it triggering the
integer overflow checking.
Diffstat (limited to 'celt')
-rw-r--r-- | celt/entdec.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/celt/entdec.c b/celt/entdec.c index ba224e24..8ba09864 100644 --- a/celt/entdec.c +++ b/celt/entdec.c @@ -126,6 +126,11 @@ void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage){ _this->end_offs=0; _this->end_window=0; _this->nend_bits=0; + /*This is the offset from which ec_tell() will subtract partial bits. + The final value after the ec_dec_normalize() call will be the same as in + the encoder, but we have to compensate for the bits that are added there.*/ + _this->nbits_total=EC_CODE_BITS+1 + -((EC_CODE_BITS-EC_CODE_EXTRA)/EC_SYM_BITS)*EC_SYM_BITS; _this->offs=0; _this->rng=1U<<EC_CODE_EXTRA; _this->rem=ec_read_byte(_this); @@ -133,10 +138,6 @@ void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage){ _this->error=0; /*Normalize the interval.*/ ec_dec_normalize(_this); - /*This is the offset from which ec_tell() will subtract partial bits. - This must be after the initial ec_dec_normalize(), or you will have to - compensate for the bits that are read there.*/ - _this->nbits_total=EC_CODE_BITS+1; } unsigned ec_decode(ec_dec *_this,unsigned _ft){ |