Lines Matching refs:rc

67 struct rc {  struct
91 static void INIT rc_read(struct rc *rc) in rc_read() argument
93 rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE); in rc_read()
94 if (rc->buffer_size <= 0) in rc_read()
95 rc->error("unexpected EOF"); in rc_read()
96 rc->ptr = rc->buffer; in rc_read()
97 rc->buffer_end = rc->buffer + rc->buffer_size; in rc_read()
101 static inline void INIT rc_init(struct rc *rc, in rc_init() argument
106 rc->fill = fill; in rc_init()
108 rc->fill = nofill; in rc_init()
109 rc->buffer = (uint8_t *)buffer; in rc_init()
110 rc->buffer_size = buffer_size; in rc_init()
111 rc->buffer_end = rc->buffer + rc->buffer_size; in rc_init()
112 rc->ptr = rc->buffer; in rc_init()
114 rc->code = 0; in rc_init()
115 rc->range = 0xFFFFFFFF; in rc_init()
118 static inline void INIT rc_init_code(struct rc *rc) in rc_init_code() argument
123 if (rc->ptr >= rc->buffer_end) in rc_init_code()
124 rc_read(rc); in rc_init_code()
125 rc->code = (rc->code << 8) | *rc->ptr++; in rc_init_code()
131 static void INIT rc_do_normalize(struct rc *rc) in rc_do_normalize() argument
133 if (rc->ptr >= rc->buffer_end) in rc_do_normalize()
134 rc_read(rc); in rc_do_normalize()
135 rc->range <<= 8; in rc_do_normalize()
136 rc->code = (rc->code << 8) | *rc->ptr++; in rc_do_normalize()
138 static inline void INIT rc_normalize(struct rc *rc) in rc_normalize() argument
140 if (rc->range < (1 << RC_TOP_BITS)) in rc_normalize()
141 rc_do_normalize(rc); in rc_normalize()
148 static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p) in rc_is_bit_0_helper() argument
150 rc_normalize(rc); in rc_is_bit_0_helper()
151 rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); in rc_is_bit_0_helper()
152 return rc->bound; in rc_is_bit_0_helper()
154 static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p) in rc_is_bit_0() argument
156 uint32_t t = rc_is_bit_0_helper(rc, p); in rc_is_bit_0()
157 return rc->code < t; in rc_is_bit_0()
161 static inline void INIT rc_update_bit_0(struct rc *rc, uint16_t *p) in rc_update_bit_0() argument
163 rc->range = rc->bound; in rc_update_bit_0()
166 static inline void INIT rc_update_bit_1(struct rc *rc, uint16_t *p) in rc_update_bit_1() argument
168 rc->range -= rc->bound; in rc_update_bit_1()
169 rc->code -= rc->bound; in rc_update_bit_1()
174 static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol) in rc_get_bit() argument
176 if (rc_is_bit_0(rc, p)) { in rc_get_bit()
177 rc_update_bit_0(rc, p); in rc_get_bit()
181 rc_update_bit_1(rc, p); in rc_get_bit()
188 static inline int INIT rc_direct_bit(struct rc *rc) in rc_direct_bit() argument
190 rc_normalize(rc); in rc_direct_bit()
191 rc->range >>= 1; in rc_direct_bit()
192 if (rc->code >= rc->range) { in rc_direct_bit()
193 rc->code -= rc->range; in rc_direct_bit()
201 rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol) in rc_bit_tree_decode() argument
207 rc_get_bit(rc, p + *symbol, symbol); in rc_bit_tree_decode()
347 static inline int INIT process_bit0(struct writer *wr, struct rc *rc, in process_bit0() argument
352 rc_update_bit_0(rc, prob); in process_bit0()
368 if (rc_get_bit(rc, prob_lit, &mi)) { in process_bit0()
379 rc_get_bit(rc, prob_lit, &mi); in process_bit0()
391 static inline int INIT process_bit1(struct writer *wr, struct rc *rc, in process_bit1() argument
399 rc_update_bit_1(rc, prob); in process_bit1()
401 if (rc_is_bit_0(rc, prob)) { in process_bit1()
402 rc_update_bit_0(rc, prob); in process_bit1()
409 rc_update_bit_1(rc, prob); in process_bit1()
411 if (rc_is_bit_0(rc, prob)) { in process_bit1()
412 rc_update_bit_0(rc, prob); in process_bit1()
417 if (rc_is_bit_0(rc, prob)) { in process_bit1()
418 rc_update_bit_0(rc, prob); in process_bit1()
424 rc_update_bit_1(rc, prob); in process_bit1()
429 rc_update_bit_1(rc, prob); in process_bit1()
431 if (rc_is_bit_0(rc, prob)) { in process_bit1()
432 rc_update_bit_0(rc, prob); in process_bit1()
435 rc_update_bit_1(rc, prob); in process_bit1()
437 if (rc_is_bit_0(rc, prob)) { in process_bit1()
438 rc_update_bit_0(rc, prob); in process_bit1()
441 rc_update_bit_1(rc, prob); in process_bit1()
455 if (rc_is_bit_0(rc, prob_len)) { in process_bit1()
456 rc_update_bit_0(rc, prob_len); in process_bit1()
463 rc_update_bit_1(rc, prob_len); in process_bit1()
465 if (rc_is_bit_0(rc, prob_len)) { in process_bit1()
466 rc_update_bit_0(rc, prob_len); in process_bit1()
473 rc_update_bit_1(rc, prob_len); in process_bit1()
481 rc_bit_tree_decode(rc, prob_len, num_bits, &len); in process_bit1()
494 rc_bit_tree_decode(rc, prob, in process_bit1()
509 rc_direct_bit(rc); in process_bit1()
517 if (rc_get_bit(rc, prob + mi, &mi)) in process_bit1()
551 struct rc rc; in unlzma() local
558 rc.error = error; in unlzma()
578 rc_init(&rc, fill, inbuf, in_len); in unlzma()
581 if (rc.ptr >= rc.buffer_end) in unlzma()
582 rc_read(&rc); in unlzma()
583 ((unsigned char *)&header)[i] = *rc.ptr++; in unlzma()
629 rc_init_code(&rc); in unlzma()
635 if (rc_is_bit_0(&rc, prob)) { in unlzma()
636 if (process_bit0(&wr, &rc, &cst, p, pos_state, prob, in unlzma()
642 if (process_bit1(&wr, &rc, &cst, p, pos_state, prob)) { in unlzma()
649 if (rc.buffer_size <= 0) in unlzma()
654 *posp = rc.ptr-rc.buffer; in unlzma()