OLD | NEW |
1 /* Copyright 2013 Google Inc. All Rights Reserved. | 1 /* Copyright 2013 Google Inc. All Rights Reserved. |
2 | 2 |
3 Distributed under MIT license. | 3 Distributed under MIT license. |
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
5 */ | 5 */ |
6 | 6 |
7 /* Utilities for building Huffman decoding tables. */ | 7 /* Utilities for building Huffman decoding tables. */ |
8 | 8 |
9 #ifndef BROTLI_DEC_HUFFMAN_H_ | 9 #ifndef BROTLI_DEC_HUFFMAN_H_ |
10 #define BROTLI_DEC_HUFFMAN_H_ | 10 #define BROTLI_DEC_HUFFMAN_H_ |
11 | 11 |
12 #include "./types.h" | 12 #include <brotli/types.h> |
13 #include "./port.h" | 13 #include "./port.h" |
14 | 14 |
15 #if defined(__cplusplus) || defined(c_plusplus) | 15 #if defined(__cplusplus) || defined(c_plusplus) |
16 extern "C" { | 16 extern "C" { |
17 #endif | 17 #endif |
18 | 18 |
19 #define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15 | 19 #define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15 |
20 | 20 |
21 /* For current format this constant equals to kNumInsertAndCopyCodes */ | |
22 #define BROTLI_HUFFMAN_MAX_CODE_LENGTHS_SIZE 704 | |
23 | |
24 /* Maximum possible Huffman table size for an alphabet size of (index * 32), | 21 /* Maximum possible Huffman table size for an alphabet size of (index * 32), |
25 * max code length 15 and root table bits 8. */ | 22 * max code length 15 and root table bits 8. */ |
26 static const uint16_t kMaxHuffmanTableSize[] = { | 23 static const uint16_t kMaxHuffmanTableSize[] = { |
27 256, 402, 436, 468, 500, 534, 566, 598, 630, 662, 694, 726, 758, 790, 822, | 24 256, 402, 436, 468, 500, 534, 566, 598, 630, 662, 694, 726, 758, 790, 822, |
28 854, 886, 920, 952, 984, 1016, 1048, 1080}; | 25 854, 886, 920, 952, 984, 1016, 1048, 1080}; |
| 26 /* BROTLI_NUM_BLOCK_LEN_SYMBOLS == 26 */ |
29 #define BROTLI_HUFFMAN_MAX_SIZE_26 396 | 27 #define BROTLI_HUFFMAN_MAX_SIZE_26 396 |
| 28 /* BROTLI_MAX_BLOCK_TYPE_SYMBOLS == 258 */ |
30 #define BROTLI_HUFFMAN_MAX_SIZE_258 632 | 29 #define BROTLI_HUFFMAN_MAX_SIZE_258 632 |
| 30 /* BROTLI_MAX_CONTEXT_MAP_SYMBOLS == 272 */ |
31 #define BROTLI_HUFFMAN_MAX_SIZE_272 646 | 31 #define BROTLI_HUFFMAN_MAX_SIZE_272 646 |
32 | 32 |
33 #define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5 | 33 #define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5 |
34 | 34 |
35 typedef struct { | 35 typedef struct { |
36 uint8_t bits; /* number of bits used for this symbol */ | 36 uint8_t bits; /* number of bits used for this symbol */ |
37 uint16_t value; /* symbol value or table offset */ | 37 uint16_t value; /* symbol value or table offset */ |
38 } HuffmanCode; | 38 } HuffmanCode; |
39 | 39 |
40 /* Builds Huffman lookup table assuming code lengths are in symbol order. */ | 40 /* Builds Huffman lookup table assuming code lengths are in symbol order. */ |
(...skipping 18 matching lines...) Expand all Loading... |
59 HuffmanCode* codes; | 59 HuffmanCode* codes; |
60 uint16_t alphabet_size; | 60 uint16_t alphabet_size; |
61 uint16_t num_htrees; | 61 uint16_t num_htrees; |
62 } HuffmanTreeGroup; | 62 } HuffmanTreeGroup; |
63 | 63 |
64 #if defined(__cplusplus) || defined(c_plusplus) | 64 #if defined(__cplusplus) || defined(c_plusplus) |
65 } /* extern "C" */ | 65 } /* extern "C" */ |
66 #endif | 66 #endif |
67 | 67 |
68 #endif /* BROTLI_DEC_HUFFMAN_H_ */ | 68 #endif /* BROTLI_DEC_HUFFMAN_H_ */ |
OLD | NEW |