916e2fb5d46ee7bd760d5bcda7ccaf6cdfa2eaa9
[wimlib] / include / wimlib / lcpit_matchfinder.h
1 /*
2  * lcpit_matchfinder.h
3  *
4  * A match-finder for Lempel-Ziv compression based on bottom-up construction and
5  * traversal of the Longest Common Prefix (LCP) interval tree.
6  *
7  * Author:      Eric Biggers
8  * Year:        2014, 2015
9  *
10  * The author dedicates this file to the public domain.
11  * You can do whatever you want with this file.
12  */
13
14 #ifndef _LCPIT_MATCHFINDER_H
15 #define _LCPIT_MATCHFINDER_H
16
17 #include "wimlib/types.h"
18
19 struct lcpit_matchfinder {
20         bool huge_mode;
21         u32 cur_pos;
22         u32 *pos_data;
23         union {
24                 u32 *intervals;
25                 u64 *intervals64;
26         };
27         u32 min_match_len;
28         u32 nice_match_len;
29         u32 next[2];
30 };
31
32 struct lz_match {
33         u32 length;
34         u32 offset;
35 };
36
37 extern u64
38 lcpit_matchfinder_get_needed_memory(size_t max_bufsize);
39
40 extern bool
41 lcpit_matchfinder_init(struct lcpit_matchfinder *mf, size_t max_bufsize,
42                        u32 min_match_len, u32 nice_match_len);
43
44 extern void
45 lcpit_matchfinder_load_buffer(struct lcpit_matchfinder *mf, const u8 *T, u32 n);
46
47 extern u32
48 lcpit_matchfinder_get_matches(struct lcpit_matchfinder *mf,
49                               struct lz_match *matches);
50
51 extern void
52 lcpit_matchfinder_skip_bytes(struct lcpit_matchfinder *mf, u32 count);
53
54 extern void
55 lcpit_matchfinder_destroy(struct lcpit_matchfinder *mf);
56
57 #endif /* _LCPIT_MATCHFINDER_H */