github.com/Schaudge/grailbase@v0.0.0-20240223061707-44c758a471c0/compress/libdeflate/deflate_constants.h (about) 1 /* 2 * deflate_constants.h - constants for the DEFLATE compression format 3 */ 4 5 #ifndef LIB_DEFLATE_CONSTANTS_H 6 #define LIB_DEFLATE_CONSTANTS_H 7 8 /* Valid block types */ 9 #define DEFLATE_BLOCKTYPE_UNCOMPRESSED 0 10 #define DEFLATE_BLOCKTYPE_STATIC_HUFFMAN 1 11 #define DEFLATE_BLOCKTYPE_DYNAMIC_HUFFMAN 2 12 13 /* Minimum and maximum supported match lengths (in bytes) */ 14 #define DEFLATE_MIN_MATCH_LEN 3 15 #define DEFLATE_MAX_MATCH_LEN 258 16 17 /* Minimum and maximum supported match offsets (in bytes) */ 18 #define DEFLATE_MIN_MATCH_OFFSET 1 19 #define DEFLATE_MAX_MATCH_OFFSET 32768 20 21 #define DEFLATE_MAX_WINDOW_SIZE 32768 22 23 /* Number of symbols in each Huffman code. Note: for the literal/length 24 * and offset codes, these are actually the maximum values; a given block 25 * might use fewer symbols. */ 26 #define DEFLATE_NUM_PRECODE_SYMS 19 27 #define DEFLATE_NUM_LITLEN_SYMS 288 28 #define DEFLATE_NUM_OFFSET_SYMS 32 29 30 /* The maximum number of symbols across all codes */ 31 #define DEFLATE_MAX_NUM_SYMS 288 32 33 /* Division of symbols in the literal/length code */ 34 #define DEFLATE_NUM_LITERALS 256 35 #define DEFLATE_END_OF_BLOCK 256 36 #define DEFLATE_NUM_LEN_SYMS 31 37 38 /* Maximum codeword length, in bits, within each Huffman code */ 39 #define DEFLATE_MAX_PRE_CODEWORD_LEN 7 40 #define DEFLATE_MAX_LITLEN_CODEWORD_LEN 15 41 #define DEFLATE_MAX_OFFSET_CODEWORD_LEN 15 42 43 /* The maximum codeword length across all codes */ 44 #define DEFLATE_MAX_CODEWORD_LEN 15 45 46 /* Maximum possible overrun when decoding codeword lengths */ 47 #define DEFLATE_MAX_LENS_OVERRUN 137 48 49 /* 50 * Maximum number of extra bits that may be required to represent a match 51 * length or offset. 52 * 53 * TODO: are we going to have full DEFLATE64 support? If so, up to 16 54 * length bits must be supported. 55 */ 56 #define DEFLATE_MAX_EXTRA_LENGTH_BITS 5 57 #define DEFLATE_MAX_EXTRA_OFFSET_BITS 14 58 59 /* The maximum number of bits in which a match can be represented. This 60 * is the absolute worst case, which assumes the longest possible Huffman 61 * codewords and the maximum numbers of extra bits. */ 62 #define DEFLATE_MAX_MATCH_BITS \ 63 (DEFLATE_MAX_LITLEN_CODEWORD_LEN + DEFLATE_MAX_EXTRA_LENGTH_BITS + \ 64 DEFLATE_MAX_OFFSET_CODEWORD_LEN + DEFLATE_MAX_EXTRA_OFFSET_BITS) 65 66 #endif /* LIB_DEFLATE_CONSTANTS_H */