]> wimlib.net Git - wimlib/blobdiff - include/wimlib/lzx_constants.h
LZX decompression: Cleanup
[wimlib] / include / wimlib / lzx_constants.h
diff --git a/include/wimlib/lzx_constants.h b/include/wimlib/lzx_constants.h
new file mode 100644 (file)
index 0000000..36e812d
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * lzx_constants.h
+ *
+ * Constants for the LZX compression format.
+ */
+
+#ifndef _LZX_CONSTANTS_H
+#define _LZX_CONSTANTS_H
+
+/* The smallest and largest allowed match lengths.  */
+#define LZX_MIN_MATCH_LEN      2
+#define LZX_MAX_MATCH_LEN      257
+
+/* Number of values an uncompressed literal byte can represent.  */
+#define LZX_NUM_CHARS  256
+
+/* Valid values of the 3-bit block type field.  */
+#define LZX_BLOCKTYPE_VERBATIM       1
+#define LZX_BLOCKTYPE_ALIGNED        2
+#define LZX_BLOCKTYPE_UNCOMPRESSED   3
+
+/* Maximum value of the "length header" portion of a main symbol.  If the length
+ * header has this value, then the match length is at least LZX_NUM_PRIMARY_LENS
+ * + LZX_MIN_MATCH_LEN, and a length symbol follows.  */
+#define LZX_NUM_PRIMARY_LENS         7
+
+/* Maximum number of position slots.  The actual number of position slots will
+ * depend on the window size.  */
+#define LZX_MAX_POSITION_SLOTS 51
+
+#define LZX_MIN_WINDOW_ORDER   15
+#define LZX_MAX_WINDOW_ORDER   21
+#define LZX_MIN_WINDOW_SIZE    (1U << LZX_MIN_WINDOW_ORDER)  /* 32768   */
+#define LZX_MAX_WINDOW_SIZE    (1U << LZX_MAX_WINDOW_ORDER)  /* 2097152 */
+
+/* Maximum number of symbols in the main code.  The actual number of symbols in
+ * the main code will depend on the window size.  */
+#define LZX_MAINCODE_MAX_NUM_SYMBOLS   (LZX_NUM_CHARS + (LZX_MAX_POSITION_SLOTS << 3))
+
+/* Number of symbols in the length code.  */
+#define LZX_LENCODE_NUM_SYMBOLS                249
+
+/* Number of symbols in the pre-code.  */
+#define LZX_PRECODE_NUM_SYMBOLS                20
+
+/* Number of bits in which each pre-code codeword length is represented.  */
+#define LZX_PRECODE_ELEMENT_SIZE       4
+
+/* Number of symbols in the aligned offset code.  */
+#define LZX_ALIGNEDCODE_NUM_SYMBOLS    8
+
+/* Number of bits in which each aligned offset codeword length is represented.  */
+#define LZX_ALIGNEDCODE_ELEMENT_SIZE   3
+
+/* Maximum lengths (in bits) for length-limited Huffman code construction.  */
+#define LZX_MAX_MAIN_CODEWORD_LEN      16
+#define LZX_MAX_LEN_CODEWORD_LEN       16
+#define LZX_MAX_PRE_CODEWORD_LEN       16
+#define LZX_MAX_ALIGNED_CODEWORD_LEN   8
+
+/* For LZX-compressed blocks in WIM resources, this value is always used as the
+ * filesize parameter for the call instruction (0xe8 byte) preprocessing, even
+ * though the blocks themselves are not this size, and the size of the actual
+ * file resource in the WIM file is very likely to be something entirely
+ * different as well.  */
+#define LZX_WIM_MAGIC_FILESIZE 12000000
+
+/* Assumed LZX block size when the encoded block size begins with a 0 bit.
+ * This is probably WIM-specific.  */
+#define LZX_DEFAULT_BLOCK_SIZE 32768
+
+/* Number of offsets in the recent (or "repeat") offsets queue.  */
+#define LZX_NUM_RECENT_OFFSETS 3
+
+/* An offset of n bytes is actually encoded as (n + LZX_OFFSET_OFFSET).  */
+#define LZX_OFFSET_OFFSET      (LZX_NUM_RECENT_OFFSETS - 1)
+
+#endif /* _LZX_CONSTANTS_H */