Lines Matching refs:dict
267 struct dictionary dict; member
289 static void dict_reset(struct dictionary *dict, struct xz_buf *b) in dict_reset() argument
291 if (DEC_IS_SINGLE(dict->mode)) { in dict_reset()
292 dict->buf = b->out + b->out_pos; in dict_reset()
293 dict->end = b->out_size - b->out_pos; in dict_reset()
296 dict->start = 0; in dict_reset()
297 dict->pos = 0; in dict_reset()
298 dict->limit = 0; in dict_reset()
299 dict->full = 0; in dict_reset()
303 static void dict_limit(struct dictionary *dict, size_t out_max) in dict_limit() argument
305 if (dict->end - dict->pos <= out_max) in dict_limit()
306 dict->limit = dict->end; in dict_limit()
308 dict->limit = dict->pos + out_max; in dict_limit()
312 static inline bool dict_has_space(const struct dictionary *dict) in dict_has_space() argument
314 return dict->pos < dict->limit; in dict_has_space()
323 static inline uint32_t dict_get(const struct dictionary *dict, uint32_t dist) in dict_get() argument
325 size_t offset = dict->pos - dist - 1; in dict_get()
327 if (dist >= dict->pos) in dict_get()
328 offset += dict->end; in dict_get()
330 return dict->full > 0 ? dict->buf[offset] : 0; in dict_get()
336 static inline void dict_put(struct dictionary *dict, uint8_t byte) in dict_put() argument
338 dict->buf[dict->pos++] = byte; in dict_put()
340 if (dict->full < dict->pos) in dict_put()
341 dict->full = dict->pos; in dict_put()
349 static bool dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist) in dict_repeat() argument
354 if (dist >= dict->full || dist >= dict->size) in dict_repeat()
357 left = min_t(size_t, dict->limit - dict->pos, *len); in dict_repeat()
360 back = dict->pos - dist - 1; in dict_repeat()
361 if (dist >= dict->pos) in dict_repeat()
362 back += dict->end; in dict_repeat()
365 dict->buf[dict->pos++] = dict->buf[back++]; in dict_repeat()
366 if (back == dict->end) in dict_repeat()
370 if (dict->full < dict->pos) in dict_repeat()
371 dict->full = dict->pos; in dict_repeat()
377 static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b, in dict_uncompressed() argument
386 if (copy_size > dict->end - dict->pos) in dict_uncompressed()
387 copy_size = dict->end - dict->pos; in dict_uncompressed()
400 memmove(dict->buf + dict->pos, b->in + b->in_pos, copy_size); in dict_uncompressed()
401 dict->pos += copy_size; in dict_uncompressed()
403 if (dict->full < dict->pos) in dict_uncompressed()
404 dict->full = dict->pos; in dict_uncompressed()
406 if (DEC_IS_MULTI(dict->mode)) { in dict_uncompressed()
407 if (dict->pos == dict->end) in dict_uncompressed()
408 dict->pos = 0; in dict_uncompressed()
418 dict->start = dict->pos; in dict_uncompressed()
436 static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b) in dict_flush() argument
438 size_t copy_size = dict->pos - dict->start; in dict_flush()
440 if (DEC_IS_MULTI(dict->mode)) { in dict_flush()
441 if (dict->pos == dict->end) in dict_flush()
442 dict->pos = 0; in dict_flush()
455 memcpy(b->out + b->out_pos, dict->buf + dict->start, in dict_flush()
459 dict->start = dict->pos; in dict_flush()
605 uint32_t prev_byte = dict_get(&s->dict, 0); in lzma_literal_probs()
607 uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc; in lzma_literal_probs()
627 match_byte = dict_get(&s->dict, s->lzma.rep0) << 1; in lzma_literal()
645 dict_put(&s->dict, (uint8_t)symbol); in lzma_literal()
761 if (dict_has_space(&s->dict) && s->lzma.len > 0) in lzma_main()
762 dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0); in lzma_main()
768 while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) { in lzma_main()
769 pos_state = s->dict.pos & s->lzma.pos_mask; in lzma_main()
780 if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0)) in lzma_main()
1009 dict_reset(&s->dict, b); in xz_dec_lzma2_run()
1101 dict_limit(&s->dict, min_t(size_t, in xz_dec_lzma2_run()
1107 s->lzma2.uncompressed -= dict_flush(&s->dict, b); in xz_dec_lzma2_run()
1127 dict_uncompressed(&s->dict, b, &s->lzma2.compressed); in xz_dec_lzma2_run()
1145 s->dict.mode = mode; in xz_dec_lzma2_create()
1146 s->dict.size_max = dict_max; in xz_dec_lzma2_create()
1149 s->dict.buf = vmalloc(dict_max); in xz_dec_lzma2_create()
1150 if (s->dict.buf == NULL) { in xz_dec_lzma2_create()
1155 s->dict.buf = NULL; in xz_dec_lzma2_create()
1156 s->dict.allocated = 0; in xz_dec_lzma2_create()
1168 s->dict.size = 2 + (props & 1); in xz_dec_lzma2_reset()
1169 s->dict.size <<= (props >> 1) + 11; in xz_dec_lzma2_reset()
1171 if (DEC_IS_MULTI(s->dict.mode)) { in xz_dec_lzma2_reset()
1172 if (s->dict.size > s->dict.size_max) in xz_dec_lzma2_reset()
1175 s->dict.end = s->dict.size; in xz_dec_lzma2_reset()
1177 if (DEC_IS_DYNALLOC(s->dict.mode)) { in xz_dec_lzma2_reset()
1178 if (s->dict.allocated < s->dict.size) { in xz_dec_lzma2_reset()
1179 s->dict.allocated = s->dict.size; in xz_dec_lzma2_reset()
1180 vfree(s->dict.buf); in xz_dec_lzma2_reset()
1181 s->dict.buf = vmalloc(s->dict.size); in xz_dec_lzma2_reset()
1182 if (s->dict.buf == NULL) { in xz_dec_lzma2_reset()
1183 s->dict.allocated = 0; in xz_dec_lzma2_reset()
1200 if (DEC_IS_MULTI(s->dict.mode)) in xz_dec_lzma2_end()
1201 vfree(s->dict.buf); in xz_dec_lzma2_end()
1255 dict_reset(&s->dict, b); in xz_dec_microlzma_run()
1259 if (DEC_IS_SINGLE(s->dict.mode)) in xz_dec_microlzma_run()
1260 s->dict.end = b->out_size - b->out_pos; in xz_dec_microlzma_run()
1263 dict_limit(&s->dict, min_t(size_t, b->out_size - b->out_pos, in xz_dec_microlzma_run()
1269 s->lzma2.uncompressed -= dict_flush(&s->dict, b); in xz_dec_microlzma_run()
1303 s->s.dict.mode = mode; in xz_dec_microlzma_alloc()
1304 s->s.dict.size = dict_size; in xz_dec_microlzma_alloc()
1307 s->s.dict.end = dict_size; in xz_dec_microlzma_alloc()
1309 s->s.dict.buf = vmalloc(dict_size); in xz_dec_microlzma_alloc()
1310 if (s->s.dict.buf == NULL) { in xz_dec_microlzma_alloc()
1336 if (DEC_IS_MULTI(s->s.dict.mode)) in xz_dec_microlzma_end()
1337 vfree(s->s.dict.buf); in xz_dec_microlzma_end()