1 | /* |
2 | Copyright (c) 2015-2016, Apple Inc. All rights reserved. |
3 | |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
5 | |
6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
7 | |
8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer |
9 | in the documentation and/or other materials provided with the distribution. |
10 | |
11 | 3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived |
12 | from this software without specific prior written permission. |
13 | |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
15 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
16 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
17 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
18 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
19 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
20 | */ |
21 | |
22 | #ifndef LZFSE_TUNABLES_H |
23 | #define LZFSE_TUNABLES_H |
24 | |
25 | // Parameters controlling details of the LZ-style match search. These values |
26 | // may be modified to fine tune compression ratio vs. encoding speed, while |
27 | // keeping the compressed format compatible with LZFSE. Note that |
28 | // modifying them will also change the amount of work space required by |
29 | // the encoder. The values here are those used in the compression library |
30 | // on iOS and OS X. |
31 | |
32 | // Number of bits for hash function to produce. Should be in the range |
33 | // [10, 16]. Larger values reduce the number of false-positive found during |
34 | // the match search, and expand the history table, which may allow additional |
35 | // matches to be found, generally improving the achieved compression ratio. |
36 | // Larger values also increase the workspace size, and make it less likely |
37 | // that the history table will be present in cache, which reduces performance. |
38 | #define LZFSE_ENCODE_HASH_BITS 14 |
39 | |
40 | // Number of positions to store for each line in the history table. May |
41 | // be either 4 or 8. Using 8 doubles the size of the history table, which |
42 | // increases the chance of finding matches (thus improving compression ratio), |
43 | // but also increases the workspace size. |
44 | #define LZFSE_ENCODE_HASH_WIDTH 4 |
45 | |
46 | // Match length in bytes to cause immediate emission. Generally speaking, |
47 | // LZFSE maintains multiple candidate matches and waits to decide which match |
48 | // to emit until more information is available. When a match exceeds this |
49 | // threshold, it is emitted immediately. Thus, smaller values may give |
50 | // somewhat better performance, and larger values may give somewhat better |
51 | // compression ratios. |
52 | #define LZFSE_ENCODE_GOOD_MATCH 40 |
53 | |
54 | // When the source buffer is very small, LZFSE doesn't compress as well as |
55 | // some simpler algorithms. To maintain reasonable compression for these |
56 | // cases, we transition to use LZVN instead if the size of the source buffer |
57 | // is below this threshold. |
58 | #define LZFSE_ENCODE_LZVN_THRESHOLD 4096 |
59 | |
60 | #endif // LZFSE_TUNABLES_H |
61 | |