]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/BrotliCompress/common/constants.h
BaseTools: Copy Brotli algorithm 3rd party source code for tool
[mirror_edk2.git] / BaseTools / Source / C / BrotliCompress / common / constants.h
1 /* Copyright 2016 Google Inc. All Rights Reserved.
2
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 */
6
7 #ifndef BROTLI_COMMON_CONSTANTS_H_
8 #define BROTLI_COMMON_CONSTANTS_H_
9
10 /* Specification: 7.3. Encoding of the context map */
11 #define BROTLI_CONTEXT_MAP_MAX_RLE 16
12
13 /* Specification: 2. Compressed representation overview */
14 #define BROTLI_MAX_NUMBER_OF_BLOCK_TYPES 256
15
16 /* Specification: 3.3. Alphabet sizes: insert-and-copy length */
17 #define BROTLI_NUM_LITERAL_SYMBOLS 256
18 #define BROTLI_NUM_COMMAND_SYMBOLS 704
19 #define BROTLI_NUM_BLOCK_LEN_SYMBOLS 26
20 #define BROTLI_MAX_CONTEXT_MAP_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + \
21 BROTLI_CONTEXT_MAP_MAX_RLE)
22 #define BROTLI_MAX_BLOCK_TYPE_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + 2)
23
24 /* Specification: 3.5. Complex prefix codes */
25 #define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16
26 #define BROTLI_REPEAT_ZERO_CODE_LENGTH 17
27 #define BROTLI_CODE_LENGTH_CODES (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1)
28 /* "code length of 8 is repeated" */
29 #define BROTLI_INITIAL_REPEATED_CODE_LENGTH 8
30
31 /* Specification: 4. Encoding of distances */
32 #define BROTLI_NUM_DISTANCE_SHORT_CODES 16
33 #define BROTLI_MAX_NPOSTFIX 3
34 #define BROTLI_MAX_NDIRECT 120
35 /* BROTLI_NUM_DISTANCE_SYMBOLS == 520 */
36 #define BROTLI_NUM_DISTANCE_SYMBOLS (BROTLI_NUM_DISTANCE_SHORT_CODES + \
37 BROTLI_MAX_NDIRECT + \
38 (24 << (BROTLI_MAX_NPOSTFIX + 1)))
39
40 /* 7.1. Context modes and context ID lookup for literals */
41 /* "context IDs for literals are in the range of 0..63" */
42 #define BROTLI_LITERAL_CONTEXT_BITS 6
43
44 /* 7.2. Context ID for distances */
45 #define BROTLI_DISTANCE_CONTEXT_BITS 2
46
47 #endif /* BROTLI_COMMON_CONSTANTS_H_ */