]> wimlib.net Git - wimlib/blob - include/wimlib/lcpit_matchfinder.h
v1.14.4
[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  * The following copying information applies to this specific source code file:
8  *
9  * Written in 2014-2015 by Eric Biggers <ebiggers3@gmail.com>
10  *
11  * To the extent possible under law, the author(s) have dedicated all copyright
12  * and related and neighboring rights to this software to the public domain
13  * worldwide via the Creative Commons Zero 1.0 Universal Public Domain
14  * Dedication (the "CC0").
15  *
16  * This software is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE. See the CC0 for more details.
19  *
20  * You should have received a copy of the CC0 along with this software; if not
21  * see <http://creativecommons.org/publicdomain/zero/1.0/>.
22  */
23
24 #ifndef _LCPIT_MATCHFINDER_H
25 #define _LCPIT_MATCHFINDER_H
26
27 #include "wimlib/types.h"
28
29 struct lcpit_matchfinder {
30         bool huge_mode;
31         u32 cur_pos;
32         u32 *pos_data;
33         union {
34                 u32 *intervals;
35                 u64 *intervals64;
36         };
37         u32 min_match_len;
38         u32 nice_match_len;
39         u32 next[2];
40         u32 orig_nice_match_len;
41 };
42
43 struct lz_match {
44         u32 length;
45         u32 offset;
46 };
47
48 extern u64
49 lcpit_matchfinder_get_needed_memory(size_t max_bufsize);
50
51 extern bool
52 lcpit_matchfinder_init(struct lcpit_matchfinder *mf, size_t max_bufsize,
53                        u32 min_match_len, u32 nice_match_len);
54
55 extern void
56 lcpit_matchfinder_load_buffer(struct lcpit_matchfinder *mf, const u8 *T, u32 n);
57
58 extern u32
59 lcpit_matchfinder_get_matches(struct lcpit_matchfinder *mf,
60                               struct lz_match *matches);
61
62 extern void
63 lcpit_matchfinder_skip_bytes(struct lcpit_matchfinder *mf, u32 count);
64
65 extern void
66 lcpit_matchfinder_destroy(struct lcpit_matchfinder *mf);
67
68 #endif /* _LCPIT_MATCHFINDER_H */