Lines Matching full:rc

57 rc_reset(lzma_range_encoder *rc)  in rc_reset()  argument
59 rc->low = 0; in rc_reset()
60 rc->cache_size = 1; in rc_reset()
61 rc->range = UINT32_MAX; in rc_reset()
62 rc->cache = 0; in rc_reset()
63 rc->out_total = 0; in rc_reset()
64 rc->count = 0; in rc_reset()
65 rc->pos = 0; in rc_reset()
70 rc_forget(lzma_range_encoder *rc) in rc_forget() argument
73 assert(rc->pos == 0); in rc_forget()
74 rc->count = 0; in rc_forget()
79 rc_bit(lzma_range_encoder *rc, probability *prob, uint32_t bit) in rc_bit() argument
81 rc->symbols[rc->count] = bit; in rc_bit()
82 rc->probs[rc->count] = prob; in rc_bit()
83 ++rc->count; in rc_bit()
88 rc_bittree(lzma_range_encoder *rc, probability *probs, in rc_bittree() argument
95 rc_bit(rc, &probs[model_index], bit); in rc_bittree()
102 rc_bittree_reverse(lzma_range_encoder *rc, probability *probs, in rc_bittree_reverse() argument
110 rc_bit(rc, &probs[model_index], bit); in rc_bittree_reverse()
117 rc_direct(lzma_range_encoder *rc, in rc_direct() argument
121 rc->symbols[rc->count++] in rc_direct()
128 rc_flush(lzma_range_encoder *rc) in rc_flush() argument
131 rc->symbols[rc->count++] = RC_FLUSH; in rc_flush()
136 rc_shift_low(lzma_range_encoder *rc, in rc_shift_low() argument
139 if ((uint32_t)(rc->low) < (uint32_t)(0xFF000000) in rc_shift_low()
140 || (uint32_t)(rc->low >> 32) != 0) { in rc_shift_low()
145 out[*out_pos] = rc->cache + (uint8_t)(rc->low >> 32); in rc_shift_low()
147 ++rc->out_total; in rc_shift_low()
148 rc->cache = 0xFF; in rc_shift_low()
150 } while (--rc->cache_size != 0); in rc_shift_low()
152 rc->cache = (rc->low >> 24) & 0xFF; in rc_shift_low()
155 ++rc->cache_size; in rc_shift_low()
156 rc->low = (rc->low & 0x00FFFFFF) << RC_SHIFT_BITS; in rc_shift_low()
191 rc_encode(lzma_range_encoder *rc, in rc_encode() argument
194 assert(rc->count <= RC_SYMBOLS_MAX); in rc_encode()
196 while (rc->pos < rc->count) { in rc_encode()
198 if (rc->range < RC_TOP_VALUE) { in rc_encode()
199 if (rc_shift_low(rc, out, out_pos, out_size)) in rc_encode()
202 rc->range <<= RC_SHIFT_BITS; in rc_encode()
206 switch (rc->symbols[rc->pos]) { in rc_encode()
208 probability prob = *rc->probs[rc->pos]; in rc_encode()
209 rc->range = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) in rc_encode()
212 *rc->probs[rc->pos] = prob; in rc_encode()
217 probability prob = *rc->probs[rc->pos]; in rc_encode()
218 const uint32_t bound = prob * (rc->range in rc_encode()
220 rc->low += bound; in rc_encode()
221 rc->range -= bound; in rc_encode()
223 *rc->probs[rc->pos] = prob; in rc_encode()
228 rc->range >>= 1; in rc_encode()
232 rc->range >>= 1; in rc_encode()
233 rc->low += rc->range; in rc_encode()
238 rc->range = UINT32_MAX; in rc_encode()
242 if (rc_shift_low(rc, out, out_pos, out_size)) in rc_encode()
244 } while (++rc->pos < rc->count); in rc_encode()
248 rc_reset(rc); in rc_encode()
256 ++rc->pos; in rc_encode()
259 rc->count = 0; in rc_encode()
260 rc->pos = 0; in rc_encode()
267 rc_encode_dummy(const lzma_range_encoder *rc, uint64_t out_limit) in rc_encode_dummy() argument
269 assert(rc->count <= RC_SYMBOLS_MAX); in rc_encode_dummy()
271 uint64_t low = rc->low; in rc_encode_dummy()
272 uint64_t cache_size = rc->cache_size; in rc_encode_dummy()
273 uint32_t range = rc->range; in rc_encode_dummy()
274 uint8_t cache = rc->cache; in rc_encode_dummy()
275 uint64_t out_pos = rc->out_total; in rc_encode_dummy()
277 size_t pos = rc->pos; in rc_encode_dummy()
291 if (pos == rc->count) in rc_encode_dummy()
295 switch (rc->symbols[pos]) { in rc_encode_dummy()
297 probability prob = *rc->probs[pos]; in rc_encode_dummy()
304 probability prob = *rc->probs[pos]; in rc_encode_dummy()
330 // Flush the last bytes. This isn't in rc->symbols[] so we do in rc_encode_dummy()
344 rc_pending(const lzma_range_encoder *rc) in rc_pending() argument
346 return rc->cache_size + 5 - 1; in rc_pending()