Lines Matching refs:rc
267 struct rc_dec rc; member
470 static void rc_reset(struct rc_dec *rc) in rc_reset() argument
472 rc->range = (uint32_t)-1; in rc_reset()
473 rc->code = 0; in rc_reset()
474 rc->init_bytes_left = RC_INIT_BYTES; in rc_reset()
481 static bool rc_read_init(struct rc_dec *rc, struct xz_buf *b) in rc_read_init() argument
483 while (rc->init_bytes_left > 0) { in rc_read_init()
487 rc->code = (rc->code << 8) + b->in[b->in_pos++]; in rc_read_init()
488 --rc->init_bytes_left; in rc_read_init()
495 static inline bool rc_limit_exceeded(const struct rc_dec *rc) in rc_limit_exceeded() argument
497 return rc->in_pos > rc->in_limit; in rc_limit_exceeded()
504 static inline bool rc_is_finished(const struct rc_dec *rc) in rc_is_finished() argument
506 return rc->code == 0; in rc_is_finished()
510 static __always_inline void rc_normalize(struct rc_dec *rc) in rc_normalize() argument
512 if (rc->range < RC_TOP_VALUE) { in rc_normalize()
513 rc->range <<= RC_SHIFT_BITS; in rc_normalize()
514 rc->code = (rc->code << RC_SHIFT_BITS) + rc->in[rc->in_pos++]; in rc_normalize()
529 static __always_inline int rc_bit(struct rc_dec *rc, uint16_t *prob) in rc_bit() argument
534 rc_normalize(rc); in rc_bit()
535 bound = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) * *prob; in rc_bit()
536 if (rc->code < bound) { in rc_bit()
537 rc->range = bound; in rc_bit()
541 rc->range -= bound; in rc_bit()
542 rc->code -= bound; in rc_bit()
551 static __always_inline uint32_t rc_bittree(struct rc_dec *rc, in rc_bittree() argument
557 if (rc_bit(rc, &probs[symbol])) in rc_bittree()
567 static __always_inline void rc_bittree_reverse(struct rc_dec *rc, in rc_bittree_reverse() argument
575 if (rc_bit(rc, &probs[symbol])) { in rc_bittree_reverse()
585 static inline void rc_direct(struct rc_dec *rc, uint32_t *dest, uint32_t limit) in rc_direct() argument
590 rc_normalize(rc); in rc_direct()
591 rc->range >>= 1; in rc_direct()
592 rc->code -= rc->range; in rc_direct()
593 mask = (uint32_t)0 - (rc->code >> 31); in rc_direct()
594 rc->code += rc->range & mask; in rc_direct()
625 symbol = rc_bittree(&s->rc, probs, 0x100); in lzma_literal()
636 if (rc_bit(&s->rc, &probs[i])) { in lzma_literal()
657 if (!rc_bit(&s->rc, &l->choice)) { in lzma_len()
662 if (!rc_bit(&s->rc, &l->choice2)) { in lzma_len()
674 s->lzma.len += rc_bittree(&s->rc, probs, limit) - limit; in lzma_len()
693 dist_slot = rc_bittree(&s->rc, probs, DIST_SLOTS) - DIST_SLOTS; in lzma_match()
705 rc_bittree_reverse(&s->rc, probs, in lzma_match()
708 rc_direct(&s->rc, &s->lzma.rep0, limit - ALIGN_BITS); in lzma_match()
710 rc_bittree_reverse(&s->rc, s->lzma.dist_align, in lzma_match()
724 if (!rc_bit(&s->rc, &s->lzma.is_rep0[s->lzma.state])) { in lzma_rep_match()
725 if (!rc_bit(&s->rc, &s->lzma.is_rep0_long[ in lzma_rep_match()
732 if (!rc_bit(&s->rc, &s->lzma.is_rep1[s->lzma.state])) { in lzma_rep_match()
735 if (!rc_bit(&s->rc, &s->lzma.is_rep2[s->lzma.state])) { in lzma_rep_match()
769 while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) { in lzma_main()
772 if (!rc_bit(&s->rc, &s->lzma.is_match[ in lzma_main()
776 if (rc_bit(&s->rc, &s->lzma.is_rep[s->lzma.state])) in lzma_main()
790 rc_normalize(&s->rc); in lzma_main()
824 rc_reset(&s->rc); in lzma_reset()
898 s->rc.in_limit = s->temp.size + tmp; in lzma2_lzma()
904 s->rc.in_limit = s->temp.size + tmp - LZMA_IN_REQUIRED; in lzma2_lzma()
907 s->rc.in = s->temp.buf; in lzma2_lzma()
908 s->rc.in_pos = 0; in lzma2_lzma()
910 if (!lzma_main(s) || s->rc.in_pos > s->temp.size + tmp) in lzma2_lzma()
913 s->lzma2.compressed -= s->rc.in_pos; in lzma2_lzma()
915 if (s->rc.in_pos < s->temp.size) { in lzma2_lzma()
916 s->temp.size -= s->rc.in_pos; in lzma2_lzma()
917 memmove(s->temp.buf, s->temp.buf + s->rc.in_pos, in lzma2_lzma()
922 b->in_pos += s->rc.in_pos - s->temp.size; in lzma2_lzma()
928 s->rc.in = b->in; in lzma2_lzma()
929 s->rc.in_pos = b->in_pos; in lzma2_lzma()
932 s->rc.in_limit = b->in_pos + s->lzma2.compressed; in lzma2_lzma()
934 s->rc.in_limit = b->in_size - LZMA_IN_REQUIRED; in lzma2_lzma()
939 in_avail = s->rc.in_pos - b->in_pos; in lzma2_lzma()
944 b->in_pos = s->rc.in_pos; in lzma2_lzma()
1085 if (!rc_read_init(&s->rc, b)) in xz_dec_lzma2_run()
1113 || !rc_is_finished(&s->rc)) in xz_dec_lzma2_run()
1116 rc_reset(&s->rc); in xz_dec_lzma2_run()
1252 if (!rc_read_init(&s->rc, b)) in xz_dec_microlzma_run()
1277 || !rc_is_finished(&s->rc)) in xz_dec_microlzma_run()