Lines Matching refs:dict
264 struct dictionary dict; member
286 static void 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 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 inline bool dict_has_space(const struct dictionary *dict) in dict_has_space() argument
311 return dict->pos < dict->limit; in dict_has_space()
320 static inline uint32_t dict_get(const struct dictionary *dict, uint32_t dist) in dict_get() argument
322 size_t offset = dict->pos - dist - 1; in dict_get()
324 if (dist >= dict->pos) in dict_get()
325 offset += dict->end; in dict_get()
327 return dict->full > 0 ? dict->buf[offset] : 0; in dict_get()
333 static inline void dict_put(struct dictionary *dict, uint8_t byte) in dict_put() argument
335 dict->buf[dict->pos++] = byte; in dict_put()
337 if (dict->full < dict->pos) in dict_put()
338 dict->full = dict->pos; in dict_put()
346 static bool dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist) in dict_repeat() argument
351 if (dist >= dict->full || dist >= dict->size) in dict_repeat()
354 left = min_t(size_t, dict->limit - dict->pos, *len); in dict_repeat()
357 back = dict->pos - dist - 1; in dict_repeat()
358 if (dist >= dict->pos) in dict_repeat()
359 back += dict->end; in dict_repeat()
362 dict->buf[dict->pos++] = dict->buf[back++]; in dict_repeat()
363 if (back == dict->end) in dict_repeat()
367 if (dict->full < dict->pos) in dict_repeat()
368 dict->full = dict->pos; in dict_repeat()
374 static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b, in dict_uncompressed() argument
383 if (copy_size > dict->end - dict->pos) in dict_uncompressed()
384 copy_size = dict->end - dict->pos; in dict_uncompressed()
390 memcpy(dict->buf + dict->pos, b->in + b->in_pos, copy_size); in dict_uncompressed()
391 dict->pos += copy_size; in dict_uncompressed()
393 if (dict->full < dict->pos) in dict_uncompressed()
394 dict->full = dict->pos; in dict_uncompressed()
396 if (DEC_IS_MULTI(dict->mode)) { in dict_uncompressed()
397 if (dict->pos == dict->end) in dict_uncompressed()
398 dict->pos = 0; in dict_uncompressed()
404 dict->start = dict->pos; in dict_uncompressed()
416 static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b) in dict_flush() argument
418 size_t copy_size = dict->pos - dict->start; in dict_flush()
420 if (DEC_IS_MULTI(dict->mode)) { in dict_flush()
421 if (dict->pos == dict->end) in dict_flush()
422 dict->pos = 0; in dict_flush()
424 memcpy(b->out + b->out_pos, dict->buf + dict->start, in dict_flush()
428 dict->start = dict->pos; in dict_flush()
574 uint32_t prev_byte = dict_get(&s->dict, 0); in lzma_literal_probs()
576 uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc; in lzma_literal_probs()
596 match_byte = dict_get(&s->dict, s->lzma.rep0) << 1; in lzma_literal()
614 dict_put(&s->dict, (uint8_t)symbol); in lzma_literal()
730 if (dict_has_space(&s->dict) && s->lzma.len > 0) in lzma_main()
731 dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0); in lzma_main()
737 while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) { in lzma_main()
738 pos_state = s->dict.pos & s->lzma.pos_mask; in lzma_main()
749 if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0)) in lzma_main()
978 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()
1092 dict_uncompressed(&s->dict, b, &s->lzma2.compressed); in xz_dec_lzma2_run()
1111 s->dict.mode = mode; in xz_dec_lzma2_create()
1112 s->dict.size_max = dict_max; in xz_dec_lzma2_create()
1115 s->dict.buf = vmalloc(dict_max); in xz_dec_lzma2_create()
1116 if (s->dict.buf == NULL) { in xz_dec_lzma2_create()
1121 s->dict.buf = NULL; in xz_dec_lzma2_create()
1122 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()