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()
397 memmove(dict->buf + dict->pos, b->in + b->in_pos, copy_size); in dict_uncompressed()
398 dict->pos += copy_size; in dict_uncompressed()
400 if (dict->full < dict->pos) in dict_uncompressed()
401 dict->full = dict->pos; in dict_uncompressed()
403 if (DEC_IS_MULTI(dict->mode)) { in dict_uncompressed()
404 if (dict->pos == dict->end) in dict_uncompressed()
405 dict->pos = 0; in dict_uncompressed()
415 dict->start = dict->pos; in dict_uncompressed()
427 static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b) in dict_flush() argument
429 size_t copy_size = dict->pos - dict->start; in dict_flush()
431 if (DEC_IS_MULTI(dict->mode)) { in dict_flush()
432 if (dict->pos == dict->end) in dict_flush()
433 dict->pos = 0; in dict_flush()
441 memcpy(b->out + b->out_pos, dict->buf + dict->start, in dict_flush()
445 dict->start = dict->pos; in dict_flush()
591 uint32_t prev_byte = dict_get(&s->dict, 0); in lzma_literal_probs()
593 uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc; in lzma_literal_probs()
613 match_byte = dict_get(&s->dict, s->lzma.rep0) << 1; in lzma_literal()
631 dict_put(&s->dict, (uint8_t)symbol); in lzma_literal()
747 if (dict_has_space(&s->dict) && s->lzma.len > 0) in lzma_main()
748 dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0); in lzma_main()
754 while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) { in lzma_main()
755 pos_state = s->dict.pos & s->lzma.pos_mask; in lzma_main()
766 if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0)) in lzma_main()
995 dict_reset(&s->dict, b); in xz_dec_lzma2_run()
1087 dict_limit(&s->dict, min_t(size_t, in xz_dec_lzma2_run()
1093 s->lzma2.uncompressed -= dict_flush(&s->dict, b); in xz_dec_lzma2_run()
1113 dict_uncompressed(&s->dict, b, &s->lzma2.compressed); in xz_dec_lzma2_run()
1132 s->dict.mode = mode; in xz_dec_lzma2_create()
1133 s->dict.size_max = dict_max; in xz_dec_lzma2_create()
1136 s->dict.buf = vmalloc(dict_max); in xz_dec_lzma2_create()
1137 if (s->dict.buf == NULL) { in xz_dec_lzma2_create()
1142 s->dict.buf = NULL; in xz_dec_lzma2_create()
1143 s->dict.allocated = 0; in xz_dec_lzma2_create()
1155 s->dict.size = 2 + (props & 1); in xz_dec_lzma2_reset()
1156 s->dict.size <<= (props >> 1) + 11; in xz_dec_lzma2_reset()
1158 if (DEC_IS_MULTI(s->dict.mode)) { in xz_dec_lzma2_reset()
1159 if (s->dict.size > s->dict.size_max) in xz_dec_lzma2_reset()
1162 s->dict.end = s->dict.size; in xz_dec_lzma2_reset()
1164 if (DEC_IS_DYNALLOC(s->dict.mode)) { in xz_dec_lzma2_reset()
1165 if (s->dict.allocated < s->dict.size) { in xz_dec_lzma2_reset()
1166 vfree(s->dict.buf); in xz_dec_lzma2_reset()
1167 s->dict.buf = vmalloc(s->dict.size); in xz_dec_lzma2_reset()
1168 if (s->dict.buf == NULL) { in xz_dec_lzma2_reset()
1169 s->dict.allocated = 0; in xz_dec_lzma2_reset()
1188 if (DEC_IS_MULTI(s->dict.mode)) in xz_dec_lzma2_end()
1189 vfree(s->dict.buf); in xz_dec_lzma2_end()