From 53454f4910d6b580a89c9d7fc03036af24627b2c Mon Sep 17 00:00:00 2001 From: "Timothy B. Terriberry" Date: Sat, 18 Dec 2010 04:51:55 -0800 Subject: [PATCH] More simplifications to the decoder renormalization loop. This removes an XOR, an ADD, and an AND, and replaces them with an AND NOT in ec_dec_normalize(). Also, simplify the loop structure of ec_dec_cdf() and eliminate a CMOV. --- libcelt/rangedec.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libcelt/rangedec.c b/libcelt/rangedec.c index 262c0ebd..a1952b5f 100644 --- a/libcelt/rangedec.c +++ b/libcelt/rangedec.c @@ -121,16 +121,13 @@ static inline void ec_dec_normalize(ec_dec *_this){ int sym; _this->rng<<=EC_SYM_BITS; /*Use up the remaining bits from our last symbol.*/ - sym=_this->rem<rem<rem=ec_dec_in(_this); /*Take the rest of the bits we need from this new symbol.*/ sym|=_this->rem>>EC_SYM_BITS-EC_CODE_EXTRA; - _this->dif=(_this->dif<dif>=EC_CODE_TOP)_this->dif-=EC_CODE_TOP;*/ - _this->dif^=_this->dif&EC_CODE_TOP; + /*And subtract them from dif, capped to be less than EC_CODE_TOP.*/ + _this->dif=(_this->dif<rng>>_ftb; + s=_this->rng; d=_this->dif; - _cdf++; + r=s>>_ftb; val=0; - t=0; - s=IMUL32(r,(1<<_ftb)-_cdf[0]); - while(ddif=d-s; - _this->rng=(val?t:_this->rng)-s; + _this->rng=t-s; ec_dec_normalize(_this); - return val; + return val-1; } ec_uint32 ec_dec_tell(ec_dec *_this,int _b){