Hi
there is already one "alternative", but w.r.t. 8bit CPUs it can be changed like this:
unsigned char prob = upkr_probs[context_index];
int bit = (upkr_state & 255) < prob ? 1 : 0;
if ( bit ) prob = -prob;
upkr_state -= ((upkr_state >> 8)+(bit ^ 1))*prob;
prob -= (prob + 8)>>4;
if ( bit ) prob = -prob;
The difference is the use of char which removes the need for 256-prob.
Another alternative:
int prob = upkr_probs[context_index];
int bit = (upkr_state & 255) < prob ? 1 : 0;
if ( bit ) {
upkr_state = (upkr_state >> 8)*prob+(upkr_state & 0xff);
prob += (256 + 8 - prob) >> 4;
} else {
upkr_state -= ((upkr_state >> 8) + 1)*prob;
prob -= (prob+8)>>4;
}
Maybe add this also to c_unpacker folder.
Hi
there is already one "alternative", but w.r.t. 8bit CPUs it can be changed like this:
The difference is the use of
charwhich removes the need for256-prob.Another alternative:
Maybe add this also to c_unpacker folder.