Lines Matching refs:dict
264 struct dictionary dict; member
286 static void XZ_FUNC dict_reset(struct dictionary *dict, struct xz_buf *b) in dict_reset() argument
288 if (DEC_IS_SINGLE(dict->mode)) { in dict_reset()
289 dict->buf = b->out + b->out_pos; in dict_reset()
290 dict->end = b->out_size - b->out_pos; in dict_reset()
293 dict->start = 0; in dict_reset()
294 dict->pos = 0; in dict_reset()
295 dict->limit = 0; in dict_reset()
296 dict->full = 0; in dict_reset()
300 static void XZ_FUNC dict_limit(struct dictionary *dict, size_t out_max) in dict_limit() argument
302 if (dict->end - dict->pos <= out_max) in dict_limit()
303 dict->limit = dict->end; in dict_limit()
305 dict->limit = dict->pos + out_max; in dict_limit()
309 static __always_inline bool XZ_FUNC dict_has_space(const struct dictionary *dict) in dict_has_space() argument
311 return dict->pos < dict->limit; in dict_has_space()
321 const struct dictionary *dict, uint32_t dist) in dict_get() argument
323 size_t offset = dict->pos - dist - 1; in dict_get()
325 if (dist >= dict->pos) in dict_get()
326 offset += dict->end; in dict_get()
328 return dict->full > 0 ? dict->buf[offset] : 0; in dict_get()
334 static inline void XZ_FUNC dict_put(struct dictionary *dict, uint8_t byte) in dict_put() argument
336 dict->buf[dict->pos++] = byte; in dict_put()
338 if (dict->full < dict->pos) in dict_put()
339 dict->full = dict->pos; in dict_put()
348 struct dictionary *dict, uint32_t *len, uint32_t dist) in dict_repeat() argument
353 if (dist >= dict->full || dist >= dict->size) in dict_repeat()
356 left = min_t(size_t, dict->limit - dict->pos, *len); in dict_repeat()
359 back = dict->pos - dist - 1; in dict_repeat()
360 if (dist >= dict->pos) in dict_repeat()
361 back += dict->end; in dict_repeat()
364 dict->buf[dict->pos++] = dict->buf[back++]; in dict_repeat()
365 if (back == dict->end) in dict_repeat()
369 if (dict->full < dict->pos) in dict_repeat()
370 dict->full = dict->pos; in dict_repeat()
377 struct dictionary *dict, struct xz_buf *b, uint32_t *left) in dict_uncompressed() argument
385 if (copy_size > dict->end - dict->pos) in dict_uncompressed()
386 copy_size = dict->end - dict->pos; in dict_uncompressed()
392 memcpy(dict->buf + dict->pos, b->in + b->in_pos, copy_size); in dict_uncompressed()
393 dict->pos += copy_size; in dict_uncompressed()
395 if (dict->full < dict->pos) in dict_uncompressed()
396 dict->full = dict->pos; in dict_uncompressed()
398 if (DEC_IS_MULTI(dict->mode)) { in dict_uncompressed()
399 if (dict->pos == dict->end) in dict_uncompressed()
400 dict->pos = 0; in dict_uncompressed()
406 dict->start = dict->pos; in dict_uncompressed()
418 static uint32_t XZ_FUNC dict_flush(struct dictionary *dict, struct xz_buf *b) in dict_flush() argument
420 size_t copy_size = dict->pos - dict->start; in dict_flush()
422 if (DEC_IS_MULTI(dict->mode)) { in dict_flush()
423 if (dict->pos == dict->end) in dict_flush()
424 dict->pos = 0; in dict_flush()
426 memcpy(b->out + b->out_pos, dict->buf + dict->start, in dict_flush()
430 dict->start = dict->pos; in dict_flush()
576 uint32_t prev_byte = dict_get(&s->dict, 0); in lzma_literal_probs()
578 uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc; in lzma_literal_probs()
598 match_byte = dict_get(&s->dict, s->lzma.rep0) << 1; in lzma_literal()
616 dict_put(&s->dict, (uint8_t)symbol); in lzma_literal()
732 if (dict_has_space(&s->dict) && s->lzma.len > 0) in lzma_main()
733 dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0); in lzma_main()
739 while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) { in lzma_main()
740 pos_state = s->dict.pos & s->lzma.pos_mask; in lzma_main()
751 if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0)) in lzma_main()
980 dict_reset(&s->dict, b); in xz_dec_lzma2_run()
1066 dict_limit(&s->dict, min_t(size_t, in xz_dec_lzma2_run()
1072 s->lzma2.uncompressed -= dict_flush(&s->dict, b); in xz_dec_lzma2_run()
1091 dict_uncompressed(&s->dict, b, &s->lzma2.compressed); in xz_dec_lzma2_run()
1110 s->dict.mode = mode; in xz_dec_lzma2_create()
1111 s->dict.size_max = dict_max; in xz_dec_lzma2_create()
1114 s->dict.buf = vmalloc(dict_max); in xz_dec_lzma2_create()
1115 if (s->dict.buf == NULL) { in xz_dec_lzma2_create()
1120 s->dict.buf = NULL; in xz_dec_lzma2_create()
1121 s->dict.allocated = 0; in xz_dec_lzma2_create()
1134 s->dict.size = 2 + (props & 1); in xz_dec_lzma2_reset()
1135 s->dict.size <<= (props >> 1) + 11; in xz_dec_lzma2_reset()
1137 if (DEC_IS_MULTI(s->dict.mode)) { in xz_dec_lzma2_reset()
1138 if (s->dict.size > s->dict.size_max) in xz_dec_lzma2_reset()
1141 s->dict.end = s->dict.size; in xz_dec_lzma2_reset()
1143 if (DEC_IS_DYNALLOC(s->dict.mode)) { in xz_dec_lzma2_reset()
1144 if (s->dict.allocated < s->dict.size) { in xz_dec_lzma2_reset()
1145 vfree(s->dict.buf); in xz_dec_lzma2_reset()
1146 s->dict.buf = vmalloc(s->dict.size); in xz_dec_lzma2_reset()
1147 if (s->dict.buf == NULL) { in xz_dec_lzma2_reset()
1148 s->dict.allocated = 0; in xz_dec_lzma2_reset()
1167 if (DEC_IS_MULTI(s->dict.mode)) in xz_dec_lzma2_end()
1168 vfree(s->dict.buf); in xz_dec_lzma2_end()