Lines Matching full:rc

69 struct rc {  struct
93 static void INIT rc_read(struct rc *rc) in rc_read() argument
95 rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE); in rc_read()
96 if (rc->buffer_size <= 0) in rc_read()
97 rc->error("unexpected EOF"); in rc_read()
98 rc->ptr = rc->buffer; in rc_read()
99 rc->buffer_end = rc->buffer + rc->buffer_size; in rc_read()
103 static inline void INIT rc_init(struct rc *rc, in rc_init() argument
108 rc->fill = fill; in rc_init()
110 rc->fill = nofill; in rc_init()
111 rc->buffer = (uint8_t *)buffer; in rc_init()
112 rc->buffer_size = buffer_size; in rc_init()
113 rc->buffer_end = rc->buffer + rc->buffer_size; in rc_init()
114 rc->ptr = rc->buffer; in rc_init()
116 rc->code = 0; in rc_init()
117 rc->range = 0xFFFFFFFF; in rc_init()
120 static inline void INIT rc_init_code(struct rc *rc) in rc_init_code() argument
125 if (rc->ptr >= rc->buffer_end) in rc_init_code()
126 rc_read(rc); in rc_init_code()
127 rc->code = (rc->code << 8) | *rc->ptr++; in rc_init_code()
133 static void INIT rc_do_normalize(struct rc *rc) in rc_do_normalize() argument
135 if (rc->ptr >= rc->buffer_end) in rc_do_normalize()
136 rc_read(rc); in rc_do_normalize()
137 rc->range <<= 8; in rc_do_normalize()
138 rc->code = (rc->code << 8) | *rc->ptr++; in rc_do_normalize()
140 static inline void INIT rc_normalize(struct rc *rc) in rc_normalize() argument
142 if (rc->range < (1 << RC_TOP_BITS)) in rc_normalize()
143 rc_do_normalize(rc); in rc_normalize()
148 *Because we want to always expose (rc->code < rc->bound) to optimizer
150 static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p) in rc_is_bit_0_helper() argument
152 rc_normalize(rc); in rc_is_bit_0_helper()
153 rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); in rc_is_bit_0_helper()
154 return rc->bound; in rc_is_bit_0_helper()
156 static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p) in rc_is_bit_0() argument
158 uint32_t t = rc_is_bit_0_helper(rc, p); in rc_is_bit_0()
159 return rc->code < t; in rc_is_bit_0()
163 static inline void INIT rc_update_bit_0(struct rc *rc, uint16_t *p) in rc_update_bit_0() argument
165 rc->range = rc->bound; in rc_update_bit_0()
168 static inline void INIT rc_update_bit_1(struct rc *rc, uint16_t *p) in rc_update_bit_1() argument
170 rc->range -= rc->bound; in rc_update_bit_1()
171 rc->code -= rc->bound; in rc_update_bit_1()
176 static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol) in rc_get_bit() argument
178 if (rc_is_bit_0(rc, p)) { in rc_get_bit()
179 rc_update_bit_0(rc, p); in rc_get_bit()
183 rc_update_bit_1(rc, p); in rc_get_bit()
190 static inline int INIT rc_direct_bit(struct rc *rc) in rc_direct_bit() argument
192 rc_normalize(rc); in rc_direct_bit()
193 rc->range >>= 1; in rc_direct_bit()
194 if (rc->code >= rc->range) { in rc_direct_bit()
195 rc->code -= rc->range; in rc_direct_bit()
203 rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol) in rc_bit_tree_decode() argument
209 rc_get_bit(rc, p + *symbol, symbol); in rc_bit_tree_decode()
349 static inline int INIT process_bit0(struct writer *wr, struct rc *rc, in process_bit0() argument
354 rc_update_bit_0(rc, prob); in process_bit0()
370 if (rc_get_bit(rc, prob_lit, &mi)) { in process_bit0()
381 rc_get_bit(rc, prob_lit, &mi); in process_bit0()
393 static inline int INIT process_bit1(struct writer *wr, struct rc *rc, in process_bit1() argument
401 rc_update_bit_1(rc, prob); in process_bit1()
403 if (rc_is_bit_0(rc, prob)) { in process_bit1()
404 rc_update_bit_0(rc, prob); in process_bit1()
411 rc_update_bit_1(rc, prob); in process_bit1()
413 if (rc_is_bit_0(rc, prob)) { in process_bit1()
414 rc_update_bit_0(rc, prob); in process_bit1()
419 if (rc_is_bit_0(rc, prob)) { in process_bit1()
420 rc_update_bit_0(rc, prob); in process_bit1()
426 rc_update_bit_1(rc, prob); in process_bit1()
431 rc_update_bit_1(rc, prob); in process_bit1()
433 if (rc_is_bit_0(rc, prob)) { in process_bit1()
434 rc_update_bit_0(rc, prob); in process_bit1()
437 rc_update_bit_1(rc, prob); in process_bit1()
439 if (rc_is_bit_0(rc, prob)) { in process_bit1()
440 rc_update_bit_0(rc, prob); in process_bit1()
443 rc_update_bit_1(rc, prob); in process_bit1()
457 if (rc_is_bit_0(rc, prob_len)) { in process_bit1()
458 rc_update_bit_0(rc, prob_len); in process_bit1()
465 rc_update_bit_1(rc, prob_len); in process_bit1()
467 if (rc_is_bit_0(rc, prob_len)) { in process_bit1()
468 rc_update_bit_0(rc, prob_len); in process_bit1()
475 rc_update_bit_1(rc, prob_len); in process_bit1()
483 rc_bit_tree_decode(rc, prob_len, num_bits, &len); in process_bit1()
496 rc_bit_tree_decode(rc, prob, in process_bit1()
511 rc_direct_bit(rc); in process_bit1()
519 if (rc_get_bit(rc, prob + mi, &mi)) in process_bit1()
553 struct rc rc; in unlzma() local
560 rc.error = error; in unlzma()
580 rc_init(&rc, fill, inbuf, in_len); in unlzma()
583 if (rc.ptr >= rc.buffer_end) in unlzma()
584 rc_read(&rc); in unlzma()
585 ((unsigned char *)&header)[i] = *rc.ptr++; in unlzma()
631 rc_init_code(&rc); in unlzma()
637 if (rc_is_bit_0(&rc, prob)) { in unlzma()
638 if (process_bit0(&wr, &rc, &cst, p, pos_state, prob, in unlzma()
644 if (process_bit1(&wr, &rc, &cst, p, pos_state, prob)) { in unlzma()
651 if (rc.buffer_size <= 0) in unlzma()
656 *posp = rc.ptr-rc.buffer; in unlzma()