Change ec_{enc|dec}_bit_prob to take probabilities in units of 1/65536 instead of 1/256. This allows them to use a single 16x16->32 multiply instead of a 24x8->32 multiply. Also change the time-frequency resolution flag coding to ensure that "0" is always the most-probable symbol (i.e., that prob("1")<50%), as that's where all the rounding error accumulates.

This commit is contained in:
Timothy B. Terriberry 2010-05-29 23:02:33 -04:00 committed by Jean-Marc Valin
parent 299747ee24
commit 43e9406201
5 changed files with 14 additions and 14 deletions

View file

@ -186,15 +186,15 @@ void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){
ec_dec_normalize(_this);
}
/*The probability of having a "one" is given in 1/256.*/
int ec_dec_bit_prob(ec_dec *_this,int _prob){
/*The probability of having a "one" is given in 1/65536.*/
int ec_dec_bit_prob(ec_dec *_this,unsigned _prob){
ec_uint32 r;
ec_uint32 s;
ec_uint32 d;
int val;
r=_this->rng;
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;