Lines Matching refs:rc

58 rc_reset(lzma_range_encoder *rc)  in rc_reset()  argument
60 rc->low = 0; in rc_reset()
61 rc->cache_size = 1; in rc_reset()
62 rc->range = UINT32_MAX; in rc_reset()
63 rc->cache = 0; in rc_reset()
64 rc->out_total = 0; in rc_reset()
65 rc->count = 0; in rc_reset()
66 rc->pos = 0; in rc_reset()
71 rc_forget(lzma_range_encoder *rc) in rc_forget() argument
74 assert(rc->pos == 0); in rc_forget()
75 rc->count = 0; in rc_forget()
80 rc_bit(lzma_range_encoder *rc, probability *prob, uint32_t bit) in rc_bit() argument
82 rc->symbols[rc->count] = bit; in rc_bit()
83 rc->probs[rc->count] = prob; in rc_bit()
84 ++rc->count; in rc_bit()
89 rc_bittree(lzma_range_encoder *rc, probability *probs, in rc_bittree() argument
96 rc_bit(rc, &probs[model_index], bit); in rc_bittree()
103 rc_bittree_reverse(lzma_range_encoder *rc, probability *probs, in rc_bittree_reverse() argument
111 rc_bit(rc, &probs[model_index], bit); in rc_bittree_reverse()
118 rc_direct(lzma_range_encoder *rc, in rc_direct() argument
122 rc->symbols[rc->count++] in rc_direct()
129 rc_flush(lzma_range_encoder *rc) in rc_flush() argument
132 rc->symbols[rc->count++] = RC_FLUSH; in rc_flush()
137 rc_shift_low(lzma_range_encoder *rc, in rc_shift_low() argument
140 if ((uint32_t)(rc->low) < (uint32_t)(0xFF000000) in rc_shift_low()
141 || (uint32_t)(rc->low >> 32) != 0) { in rc_shift_low()
146 out[*out_pos] = rc->cache + (uint8_t)(rc->low >> 32); in rc_shift_low()
148 ++rc->out_total; in rc_shift_low()
149 rc->cache = 0xFF; in rc_shift_low()
151 } while (--rc->cache_size != 0); in rc_shift_low()
153 rc->cache = (rc->low >> 24) & 0xFF; in rc_shift_low()
156 ++rc->cache_size; in rc_shift_low()
157 rc->low = (rc->low & 0x00FFFFFF) << RC_SHIFT_BITS; in rc_shift_low()
192 rc_encode(lzma_range_encoder *rc, in rc_encode() argument
195 assert(rc->count <= RC_SYMBOLS_MAX); in rc_encode()
197 while (rc->pos < rc->count) { in rc_encode()
199 if (rc->range < RC_TOP_VALUE) { in rc_encode()
200 if (rc_shift_low(rc, out, out_pos, out_size)) in rc_encode()
203 rc->range <<= RC_SHIFT_BITS; in rc_encode()
207 switch (rc->symbols[rc->pos]) { in rc_encode()
209 probability prob = *rc->probs[rc->pos]; in rc_encode()
210 rc->range = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) in rc_encode()
213 *rc->probs[rc->pos] = prob; in rc_encode()
218 probability prob = *rc->probs[rc->pos]; in rc_encode()
219 const uint32_t bound = prob * (rc->range in rc_encode()
221 rc->low += bound; in rc_encode()
222 rc->range -= bound; in rc_encode()
224 *rc->probs[rc->pos] = prob; in rc_encode()
229 rc->range >>= 1; in rc_encode()
233 rc->range >>= 1; in rc_encode()
234 rc->low += rc->range; in rc_encode()
239 rc->range = UINT32_MAX; in rc_encode()
243 if (rc_shift_low(rc, out, out_pos, out_size)) in rc_encode()
245 } while (++rc->pos < rc->count); in rc_encode()
249 rc_reset(rc); in rc_encode()
257 ++rc->pos; in rc_encode()
260 rc->count = 0; in rc_encode()
261 rc->pos = 0; in rc_encode()
268 rc_encode_dummy(const lzma_range_encoder *rc, uint64_t out_limit) in rc_encode_dummy() argument
270 assert(rc->count <= RC_SYMBOLS_MAX); in rc_encode_dummy()
272 uint64_t low = rc->low; in rc_encode_dummy()
273 uint64_t cache_size = rc->cache_size; in rc_encode_dummy()
274 uint32_t range = rc->range; in rc_encode_dummy()
275 uint8_t cache = rc->cache; in rc_encode_dummy()
276 uint64_t out_pos = rc->out_total; in rc_encode_dummy()
278 size_t pos = rc->pos; in rc_encode_dummy()
292 if (pos == rc->count) in rc_encode_dummy()
296 switch (rc->symbols[pos]) { in rc_encode_dummy()
298 probability prob = *rc->probs[pos]; in rc_encode_dummy()
305 probability prob = *rc->probs[pos]; in rc_encode_dummy()
345 rc_pending(const lzma_range_encoder *rc) in rc_pending() argument
347 return rc->cache_size + 5 - 1; in rc_pending()