Lines Matching refs:rc
263 struct rc_dec rc; member
438 static void rc_reset(struct rc_dec *rc) in rc_reset() argument
440 rc->range = (uint32_t)-1; in rc_reset()
441 rc->code = 0; in rc_reset()
442 rc->init_bytes_left = RC_INIT_BYTES; in rc_reset()
449 static bool rc_read_init(struct rc_dec *rc, struct xz_buf *b) in rc_read_init() argument
451 while (rc->init_bytes_left > 0) { in rc_read_init()
455 rc->code = (rc->code << 8) + b->in[b->in_pos++]; in rc_read_init()
456 --rc->init_bytes_left; in rc_read_init()
463 static inline bool rc_limit_exceeded(const struct rc_dec *rc) in rc_limit_exceeded() argument
465 return rc->in_pos > rc->in_limit; in rc_limit_exceeded()
472 static inline bool rc_is_finished(const struct rc_dec *rc) in rc_is_finished() argument
474 return rc->code == 0; in rc_is_finished()
478 static __always_inline void rc_normalize(struct rc_dec *rc) in rc_normalize() argument
480 if (rc->range < RC_TOP_VALUE) { in rc_normalize()
481 rc->range <<= RC_SHIFT_BITS; in rc_normalize()
482 rc->code = (rc->code << RC_SHIFT_BITS) + rc->in[rc->in_pos++]; in rc_normalize()
497 static __always_inline int rc_bit(struct rc_dec *rc, uint16_t *prob) in rc_bit() argument
502 rc_normalize(rc); in rc_bit()
503 bound = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) * *prob; in rc_bit()
504 if (rc->code < bound) { in rc_bit()
505 rc->range = bound; in rc_bit()
509 rc->range -= bound; in rc_bit()
510 rc->code -= bound; in rc_bit()
519 static __always_inline uint32_t rc_bittree(struct rc_dec *rc, in rc_bittree() argument
525 if (rc_bit(rc, &probs[symbol])) in rc_bittree()
535 static __always_inline void rc_bittree_reverse(struct rc_dec *rc, in rc_bittree_reverse() argument
543 if (rc_bit(rc, &probs[symbol])) { in rc_bittree_reverse()
553 static inline void rc_direct(struct rc_dec *rc, uint32_t *dest, uint32_t limit) in rc_direct() argument
558 rc_normalize(rc); in rc_direct()
559 rc->range >>= 1; in rc_direct()
560 rc->code -= rc->range; in rc_direct()
561 mask = (uint32_t)0 - (rc->code >> 31); in rc_direct()
562 rc->code += rc->range & mask; in rc_direct()
593 symbol = rc_bittree(&s->rc, probs, 0x100); in lzma_literal()
604 if (rc_bit(&s->rc, &probs[i])) { in lzma_literal()
625 if (!rc_bit(&s->rc, &l->choice)) { in lzma_len()
630 if (!rc_bit(&s->rc, &l->choice2)) { in lzma_len()
642 s->lzma.len += rc_bittree(&s->rc, probs, limit) - limit; in lzma_len()
661 dist_slot = rc_bittree(&s->rc, probs, DIST_SLOTS) - DIST_SLOTS; in lzma_match()
673 rc_bittree_reverse(&s->rc, probs, in lzma_match()
676 rc_direct(&s->rc, &s->lzma.rep0, limit - ALIGN_BITS); in lzma_match()
678 rc_bittree_reverse(&s->rc, s->lzma.dist_align, in lzma_match()
692 if (!rc_bit(&s->rc, &s->lzma.is_rep0[s->lzma.state])) { in lzma_rep_match()
693 if (!rc_bit(&s->rc, &s->lzma.is_rep0_long[ in lzma_rep_match()
700 if (!rc_bit(&s->rc, &s->lzma.is_rep1[s->lzma.state])) { in lzma_rep_match()
703 if (!rc_bit(&s->rc, &s->lzma.is_rep2[s->lzma.state])) { in lzma_rep_match()
737 while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) { in lzma_main()
740 if (!rc_bit(&s->rc, &s->lzma.is_match[ in lzma_main()
744 if (rc_bit(&s->rc, &s->lzma.is_rep[s->lzma.state])) in lzma_main()
758 rc_normalize(&s->rc); in lzma_main()
791 rc_reset(&s->rc); in lzma_reset()
865 s->rc.in_limit = s->temp.size + tmp; in lzma2_lzma()
871 s->rc.in_limit = s->temp.size + tmp - LZMA_IN_REQUIRED; in lzma2_lzma()
874 s->rc.in = s->temp.buf; in lzma2_lzma()
875 s->rc.in_pos = 0; in lzma2_lzma()
877 if (!lzma_main(s) || s->rc.in_pos > s->temp.size + tmp) in lzma2_lzma()
880 s->lzma2.compressed -= s->rc.in_pos; in lzma2_lzma()
882 if (s->rc.in_pos < s->temp.size) { in lzma2_lzma()
883 s->temp.size -= s->rc.in_pos; in lzma2_lzma()
884 memmove(s->temp.buf, s->temp.buf + s->rc.in_pos, in lzma2_lzma()
889 b->in_pos += s->rc.in_pos - s->temp.size; in lzma2_lzma()
895 s->rc.in = b->in; in lzma2_lzma()
896 s->rc.in_pos = b->in_pos; in lzma2_lzma()
899 s->rc.in_limit = b->in_pos + s->lzma2.compressed; in lzma2_lzma()
901 s->rc.in_limit = b->in_size - LZMA_IN_REQUIRED; in lzma2_lzma()
906 in_avail = s->rc.in_pos - b->in_pos; in lzma2_lzma()
911 b->in_pos = s->rc.in_pos; in lzma2_lzma()
1052 if (!rc_read_init(&s->rc, b)) in xz_dec_lzma2_run()
1080 || !rc_is_finished(&s->rc)) in xz_dec_lzma2_run()
1083 rc_reset(&s->rc); in xz_dec_lzma2_run()