]> wimlib.net Git - wimlib/blob - include/wimlib/lzx_constants.h
Header fixes
[wimlib] / include / wimlib / lzx_constants.h
1 /*
2  * lzx_constants.h
3  *
4  * Constants for the LZX compression format.
5  */
6
7 #ifndef _LZX_CONSTANTS_H
8 #define _LZX_CONSTANTS_H
9
10 /* The smallest and largest allowed match lengths.  */
11 #define LZX_MIN_MATCH_LEN       2
12 #define LZX_MAX_MATCH_LEN       257
13
14 /* Number of values an uncompressed literal byte can represent.  */
15 #define LZX_NUM_CHARS   256
16
17 /* Valid values of the 3-bit block type field.  */
18 #define LZX_BLOCKTYPE_VERBATIM       1
19 #define LZX_BLOCKTYPE_ALIGNED        2
20 #define LZX_BLOCKTYPE_UNCOMPRESSED   3
21
22 /* Maximum value of the "length header" portion of a main symbol.  If the length
23  * header has this value, then the match length is at least LZX_NUM_PRIMARY_LENS
24  * + LZX_MIN_MATCH_LEN, and a length symbol follows.  */
25 #define LZX_NUM_PRIMARY_LENS         7
26
27 /* Maximum number of offset slots.  The actual number of offset slots will
28  * depend on the window size.  */
29 #define LZX_MAX_OFFSET_SLOTS    51
30
31 #define LZX_MIN_WINDOW_ORDER    15
32 #define LZX_MAX_WINDOW_ORDER    21
33 #define LZX_MIN_WINDOW_SIZE     (1U << LZX_MIN_WINDOW_ORDER)  /* 32768   */
34 #define LZX_MAX_WINDOW_SIZE     (1U << LZX_MAX_WINDOW_ORDER)  /* 2097152 */
35
36 /* Maximum number of symbols in the main code.  The actual number of symbols in
37  * the main code will depend on the window size.  */
38 #define LZX_MAINCODE_MAX_NUM_SYMBOLS    (LZX_NUM_CHARS + (LZX_MAX_OFFSET_SLOTS << 3))
39
40 /* Number of symbols in the length code.  */
41 #define LZX_LENCODE_NUM_SYMBOLS         249
42
43 /* Number of symbols in the pre-code.  */
44 #define LZX_PRECODE_NUM_SYMBOLS         20
45
46 /* Number of bits in which each pre-code codeword length is represented.  */
47 #define LZX_PRECODE_ELEMENT_SIZE        4
48
49 /* Number of symbols in the aligned offset code.  */
50 #define LZX_ALIGNEDCODE_NUM_SYMBOLS     8
51
52 /* Number of bits in which each aligned offset codeword length is represented.  */
53 #define LZX_ALIGNEDCODE_ELEMENT_SIZE    3
54
55 /* Maximum lengths (in bits) for length-limited Huffman code construction.  */
56 #define LZX_MAX_MAIN_CODEWORD_LEN       16
57 #define LZX_MAX_LEN_CODEWORD_LEN        16
58 #define LZX_MAX_PRE_CODEWORD_LEN        16
59 #define LZX_MAX_ALIGNED_CODEWORD_LEN    8
60
61 /* For LZX-compressed blocks in WIM resources, this value is always used as the
62  * filesize parameter for the call instruction (0xe8 byte) preprocessing, even
63  * though the blocks themselves are not this size, and the size of the actual
64  * file resource in the WIM file is very likely to be something entirely
65  * different as well.  */
66 #define LZX_WIM_MAGIC_FILESIZE  12000000
67
68 /* Assumed LZX block size when the encoded block size begins with a 0 bit.
69  * This is probably WIM-specific.  */
70 #define LZX_DEFAULT_BLOCK_SIZE  32768
71
72 /* Number of offsets in the recent (or "repeat") offsets queue.  */
73 #define LZX_NUM_RECENT_OFFSETS  3
74
75 /* An offset of n bytes is actually encoded as (n + LZX_OFFSET_OFFSET).  */
76 #define LZX_OFFSET_OFFSET       (LZX_NUM_RECENT_OFFSETS - 1)
77
78 #endif /* _LZX_CONSTANTS_H */