| OLD | NEW |
| 1 /* Copyright 2015 Google Inc. All Rights Reserved. | 1 /* Copyright 2015 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 /* Brotli state for partial streaming decoding. */ | 7 /* Brotli state for partial streaming decoding. */ |
| 8 | 8 |
| 9 #ifndef BROTLI_DEC_STATE_H_ | 9 #ifndef BROTLI_DEC_STATE_H_ |
| 10 #define BROTLI_DEC_STATE_H_ | 10 #define BROTLI_DEC_STATE_H_ |
| 11 | 11 |
| 12 #include "./bit_reader.h" | 12 #include "./bit_reader.h" |
| 13 #include "./huffman.h" | 13 #include "./huffman.h" |
| 14 #include "./types.h" | 14 #include "./types.h" |
| 15 #include "./port.h" |
| 15 | 16 |
| 16 #if defined(__cplusplus) || defined(c_plusplus) | 17 #if defined(__cplusplus) || defined(c_plusplus) |
| 17 extern "C" { | 18 extern "C" { |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 typedef enum { | 21 typedef enum { |
| 21 BROTLI_STATE_UNINITED, | 22 BROTLI_STATE_UNINITED, |
| 22 BROTLI_STATE_METABLOCK_BEGIN, | 23 BROTLI_STATE_METABLOCK_BEGIN, |
| 23 BROTLI_STATE_METABLOCK_HEADER, | 24 BROTLI_STATE_METABLOCK_HEADER, |
| 24 BROTLI_STATE_METABLOCK_HEADER_2, | 25 BROTLI_STATE_METABLOCK_HEADER_2, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 uint32_t num_direct_distance_codes; | 150 uint32_t num_direct_distance_codes; |
| 150 int distance_postfix_mask; | 151 int distance_postfix_mask; |
| 151 uint32_t num_dist_htrees; | 152 uint32_t num_dist_htrees; |
| 152 uint8_t* dist_context_map; | 153 uint8_t* dist_context_map; |
| 153 HuffmanCode* literal_htree; | 154 HuffmanCode* literal_htree; |
| 154 uint8_t literal_htree_index; | 155 uint8_t literal_htree_index; |
| 155 uint8_t dist_htree_index; | 156 uint8_t dist_htree_index; |
| 156 uint32_t repeat_code_len; | 157 uint32_t repeat_code_len; |
| 157 uint32_t prev_code_len; | 158 uint32_t prev_code_len; |
| 158 | 159 |
| 159 | |
| 160 int copy_length; | 160 int copy_length; |
| 161 int distance_code; | 161 int distance_code; |
| 162 | 162 |
| 163 /* For partial write operations */ | 163 /* For partial write operations */ |
| 164 size_t rb_roundtrips; /* How many times we went around the ringbuffer */ | 164 size_t rb_roundtrips; /* How many times we went around the ringbuffer */ |
| 165 size_t partial_pos_out; /* How much output to the user in total (<= rb) */ | 165 size_t partial_pos_out; /* How much output to the user in total (<= rb) */ |
| 166 | 166 |
| 167 /* For ReadHuffmanCode */ | 167 /* For ReadHuffmanCode */ |
| 168 uint32_t symbol; | 168 uint32_t symbol; |
| 169 uint32_t repeat; | 169 uint32_t repeat; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 uint8_t is_uncompressed; | 213 uint8_t is_uncompressed; |
| 214 uint8_t is_metadata; | 214 uint8_t is_metadata; |
| 215 uint8_t size_nibbles; | 215 uint8_t size_nibbles; |
| 216 uint32_t window_bits; | 216 uint32_t window_bits; |
| 217 | 217 |
| 218 uint32_t num_literal_htrees; | 218 uint32_t num_literal_htrees; |
| 219 uint8_t* context_map; | 219 uint8_t* context_map; |
| 220 uint8_t* context_modes; | 220 uint8_t* context_modes; |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 typedef struct BrotliStateStruct BrotliState; | 223 typedef struct BrotliStateStruct BrotliStateInternal; |
| 224 #define BrotliState BrotliStateInternal |
| 224 | 225 |
| 225 void BrotliStateInit(BrotliState* s); | 226 BROTLI_INTERNAL void BrotliStateInit(BrotliState* s); |
| 226 void BrotliStateInitWithCustomAllocators(BrotliState* s, | 227 BROTLI_INTERNAL void BrotliStateInitWithCustomAllocators(BrotliState* s, |
| 227 brotli_alloc_func alloc_func, | 228 brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque); |
| 228 brotli_free_func free_func, | 229 BROTLI_INTERNAL void BrotliStateCleanup(BrotliState* s); |
| 229 void* opaque); | 230 BROTLI_INTERNAL void BrotliStateMetablockBegin(BrotliState* s); |
| 230 void BrotliStateCleanup(BrotliState* s); | 231 BROTLI_INTERNAL void BrotliStateCleanupAfterMetablock(BrotliState* s); |
| 231 void BrotliStateMetablockBegin(BrotliState* s); | 232 BROTLI_INTERNAL void BrotliHuffmanTreeGroupInit(BrotliState* s, |
| 232 void BrotliStateCleanupAfterMetablock(BrotliState* s); | 233 HuffmanTreeGroup* group, uint32_t alphabet_size, uint32_t ntrees); |
| 233 void BrotliHuffmanTreeGroupInit(BrotliState* s, HuffmanTreeGroup* group, | 234 BROTLI_INTERNAL void BrotliHuffmanTreeGroupRelease(BrotliState* s, |
| 234 uint32_t alphabet_size, uint32_t ntrees); | 235 HuffmanTreeGroup* group); |
| 235 void BrotliHuffmanTreeGroupRelease(BrotliState* s, HuffmanTreeGroup* group); | |
| 236 | |
| 237 /* Returns 1, if s is in a state where we have not read any input bytes yet, | |
| 238 and 0 otherwise */ | |
| 239 int BrotliStateIsStreamStart(const BrotliState* s); | |
| 240 | |
| 241 /* Returns 1, if s is in a state where we reached the end of the input and | |
| 242 produced all of the output, and 0 otherwise. */ | |
| 243 int BrotliStateIsStreamEnd(const BrotliState* s); | |
| 244 | 236 |
| 245 #if defined(__cplusplus) || defined(c_plusplus) | 237 #if defined(__cplusplus) || defined(c_plusplus) |
| 246 } /* extern "C" */ | 238 } /* extern "C" */ |
| 247 #endif | 239 #endif |
| 248 | 240 |
| 249 #endif /* BROTLI_DEC_STATE_H_ */ | 241 #endif /* BROTLI_DEC_STATE_H_ */ |
| OLD | NEW |