Revert of ui: Clean up damaged rects and clear them after painting. (patchset #2...
[chromium-blink-merge.git] / third_party / brotli / dec / state.h
blob3b985ec081e4fc015efa46f14eed95159113ca33
1 /* Copyright 2015 Google Inc. All Rights Reserved.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
16 /* Brotli state for partial streaming decoding. */
18 #ifndef BROTLI_DEC_STATE_H_
19 #define BROTLI_DEC_STATE_H_
21 #include <stdio.h>
22 #include "./bit_reader.h"
23 #include "./huffman.h"
24 #include "./streams.h"
25 #include "./types.h"
27 #if defined(__cplusplus) || defined(c_plusplus)
28 extern "C" {
29 #endif
31 typedef enum {
32 BROTLI_STATE_UNINITED = 0,
33 BROTLI_STATE_BITREADER_WARMUP = 1,
34 BROTLI_STATE_METABLOCK_BEGIN = 10,
35 BROTLI_STATE_METABLOCK_HEADER_1 = 11,
36 BROTLI_STATE_METABLOCK_HEADER_2 = 12,
37 BROTLI_STATE_BLOCK_BEGIN = 13,
38 BROTLI_STATE_BLOCK_INNER = 14,
39 BROTLI_STATE_BLOCK_DISTANCE = 15,
40 BROTLI_STATE_BLOCK_POST = 16,
41 BROTLI_STATE_UNCOMPRESSED = 17,
42 BROTLI_STATE_METABLOCK_DONE = 20,
43 BROTLI_STATE_HUFFMAN_CODE_0 = 30,
44 BROTLI_STATE_HUFFMAN_CODE_1 = 31,
45 BROTLI_STATE_HUFFMAN_CODE_2 = 32,
46 BROTLI_STATE_CONTEXT_MAP_1 = 33,
47 BROTLI_STATE_CONTEXT_MAP_2 = 34,
48 BROTLI_STATE_TREE_GROUP = 35,
49 BROTLI_STATE_SUB_NONE = 50,
50 BROTLI_STATE_SUB_UNCOMPRESSED_SHORT = 51,
51 BROTLI_STATE_SUB_UNCOMPRESSED_FILL = 52,
52 BROTLI_STATE_SUB_UNCOMPRESSED_COPY = 53,
53 BROTLI_STATE_SUB_UNCOMPRESSED_WARMUP = 54,
54 BROTLI_STATE_SUB_HUFFMAN_LENGTH_BEGIN = 60,
55 BROTLI_STATE_SUB_HUFFMAN_LENGTH_SYMBOLS = 61,
56 BROTLI_STATE_SUB_HUFFMAN_DONE = 62,
57 BROTLI_STATE_SUB_TREE_GROUP = 70,
58 BROTLI_STATE_SUB_CONTEXT_MAP_HUFFMAN = 80,
59 BROTLI_STATE_SUB_CONTEXT_MAPS = 81,
60 BROTLI_STATE_DONE = 100
61 } BrotliRunningState;
63 typedef struct {
64 BrotliRunningState state;
65 BrotliRunningState sub_state[2]; /* State inside function call */
67 int pos;
68 int input_end;
69 int window_bits;
70 int max_backward_distance;
71 int max_distance;
72 int ringbuffer_size;
73 int ringbuffer_mask;
74 uint8_t* ringbuffer;
75 uint8_t* ringbuffer_end;
76 /* This ring buffer holds a few past copy distances that will be used by */
77 /* some special distance codes. */
78 int dist_rb[4];
79 int dist_rb_idx;
80 /* The previous 2 bytes used for context. */
81 uint8_t prev_byte1;
82 uint8_t prev_byte2;
83 HuffmanTreeGroup hgroup[3];
84 HuffmanCode* block_type_trees;
85 HuffmanCode* block_len_trees;
86 BrotliBitReader br;
87 /* This counter is reused for several disjoint loops. */
88 int loop_counter;
89 /* This is true if the literal context map histogram type always matches the
90 block type. It is then not needed to keep the context (faster decoding). */
91 int trivial_literal_context;
93 int meta_block_remaining_len;
94 int is_uncompressed;
95 int block_length[3];
96 int block_type[3];
97 int num_block_types[3];
98 int block_type_rb[6];
99 int block_type_rb_index[3];
100 int distance_postfix_bits;
101 int num_direct_distance_codes;
102 int distance_postfix_mask;
103 int num_distance_codes;
104 uint8_t* context_map;
105 uint8_t* context_modes;
106 int num_literal_htrees;
107 uint8_t* dist_context_map;
108 int num_dist_htrees;
109 int context_offset;
110 uint8_t* context_map_slice;
111 uint8_t literal_htree_index;
112 int dist_context_offset;
113 uint8_t* dist_context_map_slice;
114 uint8_t dist_htree_index;
115 int context_lookup_offset1;
116 int context_lookup_offset2;
117 uint8_t context_mode;
118 HuffmanCode* htree_command;
120 int cmd_code;
121 int range_idx;
122 int insert_code;
123 int copy_code;
124 int insert_length;
125 int copy_length;
126 int distance_code;
127 int distance;
128 const uint8_t* copy_src;
129 uint8_t* copy_dst;
131 /* For CopyUncompressedBlockToOutput */
132 int nbytes;
134 /* For HuffmanTreeGroupDecode */
135 int htrees_decoded;
137 /* For ReadHuffmanCodeLengths */
138 int symbol;
139 uint8_t prev_code_len;
140 int repeat;
141 uint8_t repeat_code_len;
142 int space;
143 HuffmanCode table[32];
144 uint8_t code_length_code_lengths[18];
146 /* For ReadHuffmanCode */
147 int simple_code_or_skip;
148 uint8_t* code_lengths;
150 /* For HuffmanTreeGroupDecode */
151 int htree_index;
152 HuffmanCode* next;
154 /* For DecodeContextMap */
155 int context_index;
156 int max_run_length_prefix;
157 HuffmanCode* context_map_table;
158 } BrotliState;
160 void BrotliStateInit(BrotliState* s);
161 void BrotliStateCleanup(BrotliState* s);
163 #if defined(__cplusplus) || defined(c_plusplus)
164 } /* extern "C" */
165 #endif
167 #endif /* BROTLI_DEC_STATE_H_ */