API for Brotli decompression.
| 36 | * API for Brotli decompression. |
| 37 | */ |
| 38 | final class Decode { |
| 39 | |
| 40 | static final int MIN_LARGE_WINDOW_BITS = 10; |
| 41 | /* Maximum was chosen to be 30 to allow efficient decoder implementation. |
| 42 | * Format allows bigger window, but Java does not support 2G+ arrays. */ |
| 43 | static final int MAX_LARGE_WINDOW_BITS = 30; |
| 44 | |
| 45 | //---------------------------------------------------------------------------- |
| 46 | // RunningState |
| 47 | //---------------------------------------------------------------------------- |
| 48 | // NB: negative values are used for errors. |
| 49 | private static final int UNINITIALIZED = 0; |
| 50 | private static final int INITIALIZED = 1; |
| 51 | private static final int BLOCK_START = 2; |
| 52 | private static final int COMPRESSED_BLOCK_START = 3; |
| 53 | private static final int MAIN_LOOP = 4; |
| 54 | private static final int READ_METADATA = 5; |
| 55 | private static final int COPY_UNCOMPRESSED = 6; |
| 56 | private static final int INSERT_LOOP = 7; |
| 57 | private static final int COPY_LOOP = 8; |
| 58 | private static final int USE_DICTIONARY = 9; |
| 59 | private static final int FINISHED = 10; |
| 60 | private static final int CLOSED = 11; |
| 61 | private static final int INIT_WRITE = 12; |
| 62 | private static final int WRITE = 13; |
| 63 | private static final int COPY_FROM_COMPOUND_DICTIONARY = 14; |
| 64 | |
| 65 | private static final int DEFAULT_CODE_LENGTH = 8; |
| 66 | private static final int CODE_LENGTH_REPEAT_CODE = 16; |
| 67 | private static final int NUM_LITERAL_CODES = 256; |
| 68 | private static final int NUM_COMMAND_CODES = 704; |
| 69 | private static final int NUM_BLOCK_LENGTH_CODES = 26; |
| 70 | private static final int LITERAL_CONTEXT_BITS = 6; |
| 71 | private static final int DISTANCE_CONTEXT_BITS = 2; |
| 72 | |
| 73 | private static final int CD_BLOCK_MAP_BITS = 8; |
| 74 | private static final int HUFFMAN_TABLE_BITS = 8; |
| 75 | private static final int HUFFMAN_TABLE_MASK = 0xFF; |
| 76 | |
| 77 | /** |
| 78 | * Maximum possible Huffman table size for an alphabet size of (index * 32), |
| 79 | * max code length 15 and root table bits 8. |
| 80 | * The biggest alphabet is "command" - 704 symbols. Though "distance" alphabet could theoretically |
| 81 | * outreach that limit (for 62 extra bit distances), practically it is limited by |
| 82 | * MAX_ALLOWED_DISTANCE and never gets bigger than 544 symbols. |
| 83 | */ |
| 84 | static final int[] MAX_HUFFMAN_TABLE_SIZE = { |
| 85 | 256, 402, 436, 468, 500, 534, 566, 598, 630, 662, 694, 726, 758, 790, 822, |
| 86 | 854, 886, 920, 952, 984, 1016, 1048, 1080 |
| 87 | }; |
| 88 | |
| 89 | private static final int HUFFMAN_TABLE_SIZE_26 = 396; |
| 90 | private static final int HUFFMAN_TABLE_SIZE_258 = 632; |
| 91 | |
| 92 | private static final int CODE_LENGTH_CODES = 18; |
| 93 | private static final int[] CODE_LENGTH_CODE_ORDER = { |
| 94 | 1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 95 | }; |
nothing calls this directly
no test coverage detected
searching dependent graphs…