diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /contrib/libs/brotli/dec/state.c | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/brotli/dec/state.c')
-rw-r--r-- | contrib/libs/brotli/dec/state.c | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/contrib/libs/brotli/dec/state.c b/contrib/libs/brotli/dec/state.c index e0b37c2dcd..aebdee19c4 100644 --- a/contrib/libs/brotli/dec/state.c +++ b/contrib/libs/brotli/dec/state.c @@ -1,20 +1,20 @@ -/* Copyright 2015 Google Inc. All Rights Reserved. - +/* Copyright 2015 Google Inc. All Rights Reserved. + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ - + #include "./state.h" - + #include <stdlib.h> /* free, malloc */ - + #include <brotli/types.h> -#include "./huffman.h" - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - +#include "./huffman.h" + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + BROTLI_BOOL BrotliDecoderStateInit(BrotliDecoderState* s, brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque) { if (!alloc_func) { @@ -30,101 +30,101 @@ BROTLI_BOOL BrotliDecoderStateInit(BrotliDecoderState* s, s->error_code = 0; /* BROTLI_DECODER_NO_ERROR */ BrotliInitBitReader(&s->br); - s->state = BROTLI_STATE_UNINITED; + s->state = BROTLI_STATE_UNINITED; s->large_window = 0; - s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; - s->substate_tree_group = BROTLI_STATE_TREE_GROUP_NONE; - s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE; - s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_NONE; - s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE; - s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE; + s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE; + s->substate_tree_group = BROTLI_STATE_TREE_GROUP_NONE; + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE; + s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_NONE; + s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE; + s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE; s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE; - + s->buffer_length = 0; s->loop_counter = 0; s->pos = 0; s->rb_roundtrips = 0; s->partial_pos_out = 0; - s->block_type_trees = NULL; - s->block_len_trees = NULL; - s->ringbuffer = NULL; + s->block_type_trees = NULL; + s->block_len_trees = NULL; + s->ringbuffer = NULL; s->ringbuffer_size = 0; s->new_ringbuffer_size = 0; s->ringbuffer_mask = 0; - - s->context_map = NULL; - s->context_modes = NULL; - s->dist_context_map = NULL; - s->context_map_slice = NULL; - s->dist_context_map_slice = NULL; - + + s->context_map = NULL; + s->context_modes = NULL; + s->dist_context_map = NULL; + s->context_map_slice = NULL; + s->dist_context_map_slice = NULL; + s->sub_loop_counter = 0; - s->literal_hgroup.codes = NULL; - s->literal_hgroup.htrees = NULL; - s->insert_copy_hgroup.codes = NULL; - s->insert_copy_hgroup.htrees = NULL; - s->distance_hgroup.codes = NULL; - s->distance_hgroup.htrees = NULL; - + s->literal_hgroup.codes = NULL; + s->literal_hgroup.htrees = NULL; + s->insert_copy_hgroup.codes = NULL; + s->insert_copy_hgroup.htrees = NULL; + s->distance_hgroup.codes = NULL; + s->distance_hgroup.htrees = NULL; + s->is_last_metablock = 0; s->is_uncompressed = 0; s->is_metadata = 0; s->should_wrap_ringbuffer = 0; s->canny_ringbuffer_allocation = 1; - - s->window_bits = 0; - s->max_distance = 0; - s->dist_rb[0] = 16; - s->dist_rb[1] = 15; - s->dist_rb[2] = 11; - s->dist_rb[3] = 4; - s->dist_rb_idx = 0; - s->block_type_trees = NULL; - s->block_len_trees = NULL; - - /* Make small negative indexes addressable. */ - s->symbol_lists = &s->symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1]; - + + s->window_bits = 0; + s->max_distance = 0; + s->dist_rb[0] = 16; + s->dist_rb[1] = 15; + s->dist_rb[2] = 11; + s->dist_rb[3] = 4; + s->dist_rb_idx = 0; + s->block_type_trees = NULL; + s->block_len_trees = NULL; + + /* Make small negative indexes addressable. */ + s->symbol_lists = &s->symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1]; + s->mtf_upper_bound = 63; s->dictionary = BrotliGetDictionary(); s->transforms = BrotliGetTransforms(); return BROTLI_TRUE; -} - +} + void BrotliDecoderStateMetablockBegin(BrotliDecoderState* s) { - s->meta_block_remaining_len = 0; + s->meta_block_remaining_len = 0; s->block_length[0] = 1U << 24; s->block_length[1] = 1U << 24; s->block_length[2] = 1U << 24; - s->num_block_types[0] = 1; - s->num_block_types[1] = 1; - s->num_block_types[2] = 1; - s->block_type_rb[0] = 1; - s->block_type_rb[1] = 0; - s->block_type_rb[2] = 1; - s->block_type_rb[3] = 0; - s->block_type_rb[4] = 1; - s->block_type_rb[5] = 0; - s->context_map = NULL; - s->context_modes = NULL; - s->dist_context_map = NULL; - s->context_map_slice = NULL; - s->literal_htree = NULL; - s->dist_context_map_slice = NULL; - s->dist_htree_index = 0; + s->num_block_types[0] = 1; + s->num_block_types[1] = 1; + s->num_block_types[2] = 1; + s->block_type_rb[0] = 1; + s->block_type_rb[1] = 0; + s->block_type_rb[2] = 1; + s->block_type_rb[3] = 0; + s->block_type_rb[4] = 1; + s->block_type_rb[5] = 0; + s->context_map = NULL; + s->context_modes = NULL; + s->dist_context_map = NULL; + s->context_map_slice = NULL; + s->literal_htree = NULL; + s->dist_context_map_slice = NULL; + s->dist_htree_index = 0; s->context_lookup = NULL; - s->literal_hgroup.codes = NULL; - s->literal_hgroup.htrees = NULL; - s->insert_copy_hgroup.codes = NULL; - s->insert_copy_hgroup.htrees = NULL; - s->distance_hgroup.codes = NULL; - s->distance_hgroup.htrees = NULL; -} - + s->literal_hgroup.codes = NULL; + s->literal_hgroup.htrees = NULL; + s->insert_copy_hgroup.codes = NULL; + s->insert_copy_hgroup.htrees = NULL; + s->distance_hgroup.codes = NULL; + s->distance_hgroup.htrees = NULL; +} + void BrotliDecoderStateCleanupAfterMetablock(BrotliDecoderState* s) { BROTLI_DECODER_FREE(s, s->context_modes); BROTLI_DECODER_FREE(s, s->context_map); @@ -132,15 +132,15 @@ void BrotliDecoderStateCleanupAfterMetablock(BrotliDecoderState* s) { BROTLI_DECODER_FREE(s, s->literal_hgroup.htrees); BROTLI_DECODER_FREE(s, s->insert_copy_hgroup.htrees); BROTLI_DECODER_FREE(s, s->distance_hgroup.htrees); -} - +} + void BrotliDecoderStateCleanup(BrotliDecoderState* s) { BrotliDecoderStateCleanupAfterMetablock(s); - + BROTLI_DECODER_FREE(s, s->ringbuffer); BROTLI_DECODER_FREE(s, s->block_type_trees); -} - +} + BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(BrotliDecoderState* s, HuffmanTreeGroup* group, uint32_t alphabet_size, uint32_t max_symbol, uint32_t ntrees) { @@ -159,6 +159,6 @@ BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(BrotliDecoderState* s, return !!p; } -#if defined(__cplusplus) || defined(c_plusplus) +#if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ -#endif +#endif |