/* rc_is_bit_1 is called 9 times */ static speed_inline int rc_is_bit_1(rc_t *rc, uint16_t *p) { rc_normalize(rc); rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); if (rc->code < rc->bound) { rc->range = rc->bound; *p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS; return 0; }
/* Called once */ static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc) { rc_normalize(rc); rc->range >>= 1; if (rc->code >= rc->range) { rc->code -= rc->range; return 1; } return 0; }
/* Why rc_is_bit_0_helper exists? * Because we want to always expose (rc->code < rc->bound) to optimizer */ static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p) { rc_normalize(rc); rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); return rc->bound; }