diff --git a/libcelt/celt.c b/libcelt/celt.c index 2613b5af..559720bf 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -615,11 +615,11 @@ static void tf_encode(celt_word16 *bandLogE, celt_word16 *oldBandE, int len, int else tf_res[i] = path0[i+1]; } - ec_enc_bit_prob(enc, tf_res[0], isTransient ? 64 : 16); + ec_enc_bit_prob(enc, tf_res[0], isTransient ? 16384 : 4096); curr = tf_res[0]; for (i=1;irng; d=_this->dif; - s=IMUL32(r>>8,_prob); + s=(r>>16)*_prob; val=d<=s; if(!val)_this->dif=d-s; _this->rng=val?s:r-s; diff --git a/libcelt/rangeenc.c b/libcelt/rangeenc.c index f7f171ba..68ff6c4a 100644 --- a/libcelt/rangeenc.c +++ b/libcelt/rangeenc.c @@ -138,14 +138,14 @@ void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ ec_enc_normalize(_this); } -/*The probability of having a "one" is given in 1/256.*/ -void ec_enc_bit_prob(ec_enc *_this,int _val,int _prob){ +/*The probability of having a "one" is given in 1/65536.*/ +void ec_enc_bit_prob(ec_enc *_this,int _val,unsigned _prob){ ec_uint32 r; ec_uint32 s; ec_uint32 l; r=_this->rng; l=_this->low; - s=IMUL32(r>>8,_prob); + s=(r>>16)*_prob; r-=s; if(_val)_this->low=l+r; _this->rng=_val?s:r;