Lines Matching refs:rc

55 rc_reset(lzma_range_encoder *rc)  in rc_reset()  argument
57 rc->low = 0; in rc_reset()
58 rc->cache_size = 1; in rc_reset()
59 rc->range = UINT32_MAX; in rc_reset()
60 rc->cache = 0; in rc_reset()
61 rc->count = 0; in rc_reset()
62 rc->pos = 0; in rc_reset()
67 rc_bit(lzma_range_encoder *rc, probability *prob, uint32_t bit) in rc_bit() argument
69 rc->symbols[rc->count] = bit; in rc_bit()
70 rc->probs[rc->count] = prob; in rc_bit()
71 ++rc->count; in rc_bit()
76 rc_bittree(lzma_range_encoder *rc, probability *probs, in rc_bittree() argument
83 rc_bit(rc, &probs[model_index], bit); in rc_bittree()
90 rc_bittree_reverse(lzma_range_encoder *rc, probability *probs, in rc_bittree_reverse() argument
98 rc_bit(rc, &probs[model_index], bit); in rc_bittree_reverse()
105 rc_direct(lzma_range_encoder *rc, in rc_direct() argument
109 rc->symbols[rc->count++] in rc_direct()
116 rc_flush(lzma_range_encoder *rc) in rc_flush() argument
119 rc->symbols[rc->count++] = RC_FLUSH; in rc_flush()
124 rc_shift_low(lzma_range_encoder *rc, in rc_shift_low() argument
127 if ((uint32_t)(rc->low) < (uint32_t)(0xFF000000) in rc_shift_low()
128 || (uint32_t)(rc->low >> 32) != 0) { in rc_shift_low()
133 out[*out_pos] = rc->cache + (uint8_t)(rc->low >> 32); in rc_shift_low()
135 rc->cache = 0xFF; in rc_shift_low()
137 } while (--rc->cache_size != 0); in rc_shift_low()
139 rc->cache = (rc->low >> 24) & 0xFF; in rc_shift_low()
142 ++rc->cache_size; in rc_shift_low()
143 rc->low = (rc->low & 0x00FFFFFF) << RC_SHIFT_BITS; in rc_shift_low()
150 rc_encode(lzma_range_encoder *rc, in rc_encode() argument
153 assert(rc->count <= RC_SYMBOLS_MAX); in rc_encode()
155 while (rc->pos < rc->count) { in rc_encode()
157 if (rc->range < RC_TOP_VALUE) { in rc_encode()
158 if (rc_shift_low(rc, out, out_pos, out_size)) in rc_encode()
161 rc->range <<= RC_SHIFT_BITS; in rc_encode()
165 switch (rc->symbols[rc->pos]) { in rc_encode()
167 probability prob = *rc->probs[rc->pos]; in rc_encode()
168 rc->range = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) in rc_encode()
171 *rc->probs[rc->pos] = prob; in rc_encode()
176 probability prob = *rc->probs[rc->pos]; in rc_encode()
177 const uint32_t bound = prob * (rc->range in rc_encode()
179 rc->low += bound; in rc_encode()
180 rc->range -= bound; in rc_encode()
182 *rc->probs[rc->pos] = prob; in rc_encode()
187 rc->range >>= 1; in rc_encode()
191 rc->range >>= 1; in rc_encode()
192 rc->low += rc->range; in rc_encode()
197 rc->range = UINT32_MAX; in rc_encode()
201 if (rc_shift_low(rc, out, out_pos, out_size)) in rc_encode()
203 } while (++rc->pos < rc->count); in rc_encode()
207 rc_reset(rc); in rc_encode()
215 ++rc->pos; in rc_encode()
218 rc->count = 0; in rc_encode()
219 rc->pos = 0; in rc_encode()
226 rc_pending(const lzma_range_encoder *rc) in rc_pending() argument
228 return rc->cache_size + 5 - 1; in rc_pending()