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 /* Lookup tables to map prefix codes to value ranges. This is used during | 7 /* Lookup tables to map prefix codes to value ranges. This is used during |
8 decoding of the block lengths, literal insertion lengths and copy lengths. | 8 decoding of the block lengths, literal insertion lengths and copy lengths. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef BROTLI_DEC_PREFIX_H_ | 11 #ifndef BROTLI_DEC_PREFIX_H_ |
12 #define BROTLI_DEC_PREFIX_H_ | 12 #define BROTLI_DEC_PREFIX_H_ |
13 | 13 |
14 #include "./types.h" | 14 #include "../common/constants.h" |
| 15 #include <brotli/types.h> |
15 | 16 |
16 /* Represents the range of values belonging to a prefix code: */ | 17 /* Represents the range of values belonging to a prefix code: */ |
17 /* [offset, offset + 2^nbits) */ | 18 /* [offset, offset + 2^nbits) */ |
18 struct PrefixCodeRange { | 19 struct PrefixCodeRange { |
19 uint16_t offset; | 20 uint16_t offset; |
20 uint8_t nbits; | 21 uint8_t nbits; |
21 }; | 22 }; |
22 | 23 |
23 static const struct PrefixCodeRange kBlockLengthPrefixCode[] = { | 24 static const struct PrefixCodeRange |
| 25 kBlockLengthPrefixCode[BROTLI_NUM_BLOCK_LEN_SYMBOLS] = { |
24 { 1, 2}, { 5, 2}, { 9, 2}, { 13, 2}, | 26 { 1, 2}, { 5, 2}, { 9, 2}, { 13, 2}, |
25 { 17, 3}, { 25, 3}, { 33, 3}, { 41, 3}, | 27 { 17, 3}, { 25, 3}, { 33, 3}, { 41, 3}, |
26 { 49, 4}, { 65, 4}, { 81, 4}, { 97, 4}, | 28 { 49, 4}, { 65, 4}, { 81, 4}, { 97, 4}, |
27 { 113, 5}, { 145, 5}, { 177, 5}, { 209, 5}, | 29 { 113, 5}, { 145, 5}, { 177, 5}, { 209, 5}, |
28 { 241, 6}, { 305, 6}, { 369, 7}, { 497, 8}, | 30 { 241, 6}, { 305, 6}, { 369, 7}, { 497, 8}, |
29 { 753, 9}, { 1265, 10}, {2289, 11}, {4337, 12}, | 31 { 753, 9}, { 1265, 10}, {2289, 11}, {4337, 12}, |
30 {8433, 13}, {16625, 24} | 32 {8433, 13}, {16625, 24} |
31 }; | 33 }; |
32 | 34 |
33 typedef struct CmdLutElement { | 35 typedef struct CmdLutElement { |
34 uint8_t insert_len_extra_bits; | 36 uint8_t insert_len_extra_bits; |
35 uint8_t copy_len_extra_bits; | 37 uint8_t copy_len_extra_bits; |
36 int8_t distance_code; | 38 int8_t distance_code; |
37 uint8_t context; | 39 uint8_t context; |
38 uint16_t insert_len_offset; | 40 uint16_t insert_len_offset; |
39 uint16_t copy_len_offset; | 41 uint16_t copy_len_offset; |
40 } CmdLutElement; | 42 } CmdLutElement; |
41 | 43 |
42 static const CmdLutElement kCmdLut[704] = { | 44 static const CmdLutElement kCmdLut[BROTLI_NUM_COMMAND_SYMBOLS] = { |
43 { 0x00, 0x00, 0, 0x00, 0x0000, 0x0002 }, | 45 { 0x00, 0x00, 0, 0x00, 0x0000, 0x0002 }, |
44 { 0x00, 0x00, 0, 0x01, 0x0000, 0x0003 }, | 46 { 0x00, 0x00, 0, 0x01, 0x0000, 0x0003 }, |
45 { 0x00, 0x00, 0, 0x02, 0x0000, 0x0004 }, | 47 { 0x00, 0x00, 0, 0x02, 0x0000, 0x0004 }, |
46 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0005 }, | 48 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0005 }, |
47 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0006 }, | 49 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0006 }, |
48 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0007 }, | 50 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0007 }, |
49 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0008 }, | 51 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0008 }, |
50 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0009 }, | 52 { 0x00, 0x00, 0, 0x03, 0x0000, 0x0009 }, |
51 { 0x00, 0x00, 0, 0x00, 0x0001, 0x0002 }, | 53 { 0x00, 0x00, 0, 0x00, 0x0001, 0x0002 }, |
52 { 0x00, 0x00, 0, 0x01, 0x0001, 0x0003 }, | 54 { 0x00, 0x00, 0, 0x01, 0x0001, 0x0003 }, |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 { 0x18, 0x05, -1, 0x03, 0x5842, 0x0066 }, | 742 { 0x18, 0x05, -1, 0x03, 0x5842, 0x0066 }, |
741 { 0x18, 0x06, -1, 0x03, 0x5842, 0x0086 }, | 743 { 0x18, 0x06, -1, 0x03, 0x5842, 0x0086 }, |
742 { 0x18, 0x07, -1, 0x03, 0x5842, 0x00c6 }, | 744 { 0x18, 0x07, -1, 0x03, 0x5842, 0x00c6 }, |
743 { 0x18, 0x08, -1, 0x03, 0x5842, 0x0146 }, | 745 { 0x18, 0x08, -1, 0x03, 0x5842, 0x0146 }, |
744 { 0x18, 0x09, -1, 0x03, 0x5842, 0x0246 }, | 746 { 0x18, 0x09, -1, 0x03, 0x5842, 0x0246 }, |
745 { 0x18, 0x0a, -1, 0x03, 0x5842, 0x0446 }, | 747 { 0x18, 0x0a, -1, 0x03, 0x5842, 0x0446 }, |
746 { 0x18, 0x18, -1, 0x03, 0x5842, 0x0846 }, | 748 { 0x18, 0x18, -1, 0x03, 0x5842, 0x0846 }, |
747 }; | 749 }; |
748 | 750 |
749 #endif /* BROTLI_DEC_PREFIX_H_ */ | 751 #endif /* BROTLI_DEC_PREFIX_H_ */ |
OLD | NEW |