Debian Codegraph @

c/dec/state.c

raw symbols SCIP
1 /* Copyright 2015 Google Inc. All Rights Reserved.
2
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 */
6
7 #include "state.h"cxx . . $ `<file>/c/dec/state.h`/
8
9 #include "../common/dictionary.h"cxx . . $ `<file>/c/common/dictionary.h`/
10 #include "../common/platform.h"cxx . . $ `<file>/c/common/platform.h`/
11 #include "huffman.h"cxx . . $ `<file>/c/dec/huffman.h`/
12
13 #if defined(__cplusplus) || defined(c_plusplus)
14 extern "C" {
15 #endif
16
17 #ifdef BROTLI_REPORTING
18 /* When BROTLI_REPORTING is defined extra reporting module have to be linked. */
19 void BrotliDecoderOnStart(const BrotliDecoderState* s);
20 void BrotliDecoderOnFinish(const BrotliDecoderState* s);
21 #define BROTLI_DECODER_ON_START(s) BrotliDecoderOnStart(s);
22 #define BROTLI_DECODER_ON_FINISH(s) BrotliDecoderOnFinish(s);
23 #else
24 #if !defined(BROTLI_DECODER_ON_START)
25 #define BROTLI_DECODER_ON_STARTcxx . . $ `c/dec/state.c:25:9`!(s) (void)(s);
26 #endif
27 #if !defined(BROTLI_DECODER_ON_FINISH)
28 #define BROTLI_DECODER_ON_FINISHcxx . . $ `c/dec/state.c:28:9`!(s) (void)(s);
29 #endif
30 #endif
31
32 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! BrotliDecoderStateInitcxx . . $ BrotliDecoderStateInit(6711db6abf207b4c).(BrotliDecoderStatecxx . . $ `c/dec/state.h:368:9`!* s,
33 brotli_alloc_funccxx . . $ brotli_alloc_func# alloc_func, brotli_free_funccxx . . $ brotli_free_func# free_func, void* opaque) {
34 BROTLI_DECODER_ON_STARTcxx . . $ `c/dec/state.c:25:9`!(s);
35 if (!alloc_func) {
36 s->alloc_funccxx . . $ BrotliDecoderStateStruct#alloc_func. = BrotliDefaultAllocFunccxx . . $ BrotliDefaultAllocFunc(417ab160f6baadc6).;
37 s->free_funccxx . . $ BrotliDecoderStateStruct#free_func. = BrotliDefaultFreeFunccxx . . $ BrotliDefaultFreeFunc(6c58c5e2437d25a2).;
38 s->memory_manager_opaquecxx . . $ BrotliDecoderStateStruct#memory_manager_opaque. = 0;
39 } else {
40 s->alloc_funccxx . . $ BrotliDecoderStateStruct#alloc_func. = alloc_func;
41 s->free_funccxx . . $ BrotliDecoderStateStruct#free_func. = free_func;
42 s->memory_manager_opaquecxx . . $ BrotliDecoderStateStruct#memory_manager_opaque. = opaque;
43 }
44
45 s->error_codecxx . . $ BrotliDecoderStateStruct#error_code. = 0; /* BROTLI_DECODER_NO_ERROR */
46
47 BrotliInitBitReadercxx . . $ BrotliInitBitReader(165eb0102fa4fad4).(&s->brcxx . . $ BrotliDecoderStateStruct#br.);
48 s->statecxx . . $ BrotliDecoderStateStruct#state. = BROTLI_STATE_UNINITEDcxx . . $ BROTLI_STATE_UNINITED.;
49 s->large_windowcxx . . $ BrotliDecoderStateStruct#large_window. = 0;
50 s->substate_metablock_headercxx . . $ BrotliDecoderStateStruct#substate_metablock_header. = BROTLI_STATE_METABLOCK_HEADER_NONEcxx . . $ BROTLI_STATE_METABLOCK_HEADER_NONE.;
51 s->substate_uncompressedcxx . . $ BrotliDecoderStateStruct#substate_uncompressed. = BROTLI_STATE_UNCOMPRESSED_NONEcxx . . $ BROTLI_STATE_UNCOMPRESSED_NONE.;
52 s->substate_decode_uint8cxx . . $ BrotliDecoderStateStruct#substate_decode_uint8. = BROTLI_STATE_DECODE_UINT8_NONEcxx . . $ BROTLI_STATE_DECODE_UINT8_NONE.;
53 s->substate_read_block_lengthcxx . . $ BrotliDecoderStateStruct#substate_read_block_length. = BROTLI_STATE_READ_BLOCK_LENGTH_NONEcxx . . $ BROTLI_STATE_READ_BLOCK_LENGTH_NONE.;
54
55 s->buffer_lengthcxx . . $ BrotliDecoderStateStruct#buffer_length. = 0;
56 s->loop_countercxx . . $ BrotliDecoderStateStruct#loop_counter. = 0;
57 s->poscxx . . $ BrotliDecoderStateStruct#pos. = 0;
58 s->rb_roundtripscxx . . $ BrotliDecoderStateStruct#rb_roundtrips. = 0;
59 s->partial_pos_outcxx . . $ BrotliDecoderStateStruct#partial_pos_out. = 0;
60 s->used_inputcxx . . $ BrotliDecoderStateStruct#used_input. = 0;
61
62 s->block_type_treescxx . . $ BrotliDecoderStateStruct#block_type_trees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
63 s->block_len_treescxx . . $ BrotliDecoderStateStruct#block_len_trees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
64 s->ringbuffercxx . . $ BrotliDecoderStateStruct#ringbuffer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
65 s->ringbuffer_sizecxx . . $ BrotliDecoderStateStruct#ringbuffer_size. = 0;
66 s->new_ringbuffer_sizecxx . . $ BrotliDecoderStateStruct#new_ringbuffer_size. = 0;
67 s->ringbuffer_maskcxx . . $ BrotliDecoderStateStruct#ringbuffer_mask. = 0;
68
69 s->context_mapcxx . . $ BrotliDecoderStateStruct#context_map. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
70 s->context_modescxx . . $ BrotliDecoderStateStruct#context_modes. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
71 s->dist_context_mapcxx . . $ BrotliDecoderStateStruct#dist_context_map. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
72 s->context_map_slicecxx . . $ BrotliDecoderStateStruct#context_map_slice. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
73 s->dist_context_map_slicecxx . . $ BrotliDecoderStateStruct#dist_context_map_slice. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
74
75 s->literal_hgroupcxx . . $ BrotliDecoderStateStruct#literal_hgroup..codescxx . . $ $anonymous_type_421782d160a65272_1#codes. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
76 s->literal_hgroupcxx . . $ BrotliDecoderStateStruct#literal_hgroup..htreescxx . . $ $anonymous_type_421782d160a65272_1#htrees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
77 s->insert_copy_hgroupcxx . . $ BrotliDecoderStateStruct#insert_copy_hgroup..codescxx . . $ $anonymous_type_421782d160a65272_1#codes. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
78 s->insert_copy_hgroupcxx . . $ BrotliDecoderStateStruct#insert_copy_hgroup..htreescxx . . $ $anonymous_type_421782d160a65272_1#htrees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
79 s->distance_hgroupcxx . . $ BrotliDecoderStateStruct#distance_hgroup..codescxx . . $ $anonymous_type_421782d160a65272_1#codes. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
80 s->distance_hgroupcxx . . $ BrotliDecoderStateStruct#distance_hgroup..htreescxx . . $ $anonymous_type_421782d160a65272_1#htrees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
81
82 s->is_last_metablockcxx . . $ BrotliDecoderStateStruct#is_last_metablock. = 0;
83 s->is_uncompressedcxx . . $ BrotliDecoderStateStruct#is_uncompressed. = 0;
84 s->is_metadatacxx . . $ BrotliDecoderStateStruct#is_metadata. = 0;
85 s->should_wrap_ringbuffercxx . . $ BrotliDecoderStateStruct#should_wrap_ringbuffer. = 0;
86 s->canny_ringbuffer_allocationcxx . . $ BrotliDecoderStateStruct#canny_ringbuffer_allocation. = 1;
87
88 s->window_bitscxx . . $ BrotliDecoderStateStruct#window_bits. = 0;
89 s->max_distancecxx . . $ BrotliDecoderStateStruct#max_distance. = 0;
90 s->dist_rbcxx . . $ BrotliDecoderStateStruct#dist_rb.[0] = 16;
91 s->dist_rbcxx . . $ BrotliDecoderStateStruct#dist_rb.[1] = 15;
92 s->dist_rbcxx . . $ BrotliDecoderStateStruct#dist_rb.[2] = 11;
93 s->dist_rbcxx . . $ BrotliDecoderStateStruct#dist_rb.[3] = 4;
94 s->dist_rb_idxcxx . . $ BrotliDecoderStateStruct#dist_rb_idx. = 0;
95 s->block_type_treescxx . . $ BrotliDecoderStateStruct#block_type_trees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
96 s->block_len_treescxx . . $ BrotliDecoderStateStruct#block_len_trees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
97
98 s->mtf_upper_boundcxx . . $ BrotliDecoderStateStruct#mtf_upper_bound. = 63;
99
100 s->compound_dictionarycxx . . $ BrotliDecoderStateStruct#compound_dictionary. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
101 s->dictionarycxx . . $ BrotliDecoderStateStruct#dictionary. =
102 BrotliSharedDictionaryCreateInstancecxx . . $ BrotliSharedDictionaryCreateInstance(b1eb22dafc661833).(alloc_func, free_func, opaque);
103 if (!s->dictionarycxx . . $ BrotliDecoderStateStruct#dictionary.) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!;
104
105 s->metadata_start_funccxx . . $ BrotliDecoderStateStruct#metadata_start_func. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
106 s->metadata_chunk_funccxx . . $ BrotliDecoderStateStruct#metadata_chunk_func. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
107 s->metadata_callback_opaquecxx . . $ BrotliDecoderStateStruct#metadata_callback_opaque. = 0;
108
109 return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!;
110 }
111
112 void BrotliDecoderStateMetablockBegincxx . . $ BrotliDecoderStateMetablockBegin(bb1fb99afd41e748).(BrotliDecoderStatecxx . . $ `c/dec/state.h:368:9`!* s) {
113 s->meta_block_remaining_lencxx . . $ BrotliDecoderStateStruct#meta_block_remaining_len. = 0;
114 s->block_lengthcxx . . $ BrotliDecoderStateStruct#block_length.[0] = BROTLI_BLOCK_SIZE_CAPcxx . . $ `c/dec/state.h:390:9`!;
115 s->block_lengthcxx . . $ BrotliDecoderStateStruct#block_length.[1] = BROTLI_BLOCK_SIZE_CAPcxx . . $ `c/dec/state.h:390:9`!;
116 s->block_lengthcxx . . $ BrotliDecoderStateStruct#block_length.[2] = BROTLI_BLOCK_SIZE_CAPcxx . . $ `c/dec/state.h:390:9`!;
117 s->num_block_typescxx . . $ BrotliDecoderStateStruct#num_block_types.[0] = 1;
118 s->num_block_typescxx . . $ BrotliDecoderStateStruct#num_block_types.[1] = 1;
119 s->num_block_typescxx . . $ BrotliDecoderStateStruct#num_block_types.[2] = 1;
120 s->block_type_rbcxx . . $ BrotliDecoderStateStruct#block_type_rb.[0] = 1;
121 s->block_type_rbcxx . . $ BrotliDecoderStateStruct#block_type_rb.[1] = 0;
122 s->block_type_rbcxx . . $ BrotliDecoderStateStruct#block_type_rb.[2] = 1;
123 s->block_type_rbcxx . . $ BrotliDecoderStateStruct#block_type_rb.[3] = 0;
124 s->block_type_rbcxx . . $ BrotliDecoderStateStruct#block_type_rb.[4] = 1;
125 s->block_type_rbcxx . . $ BrotliDecoderStateStruct#block_type_rb.[5] = 0;
126 s->context_mapcxx . . $ BrotliDecoderStateStruct#context_map. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
127 s->context_modescxx . . $ BrotliDecoderStateStruct#context_modes. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
128 s->dist_context_mapcxx . . $ BrotliDecoderStateStruct#dist_context_map. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
129 s->context_map_slicecxx . . $ BrotliDecoderStateStruct#context_map_slice. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
130 s->literal_htreecxx . . $ BrotliDecoderStateStruct#literal_htree. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
131 s->dist_context_map_slicecxx . . $ BrotliDecoderStateStruct#dist_context_map_slice. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
132 s->dist_htree_indexcxx . . $ BrotliDecoderStateStruct#dist_htree_index. = 0;
133 s->context_lookupcxx . . $ BrotliDecoderStateStruct#context_lookup. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
134 s->literal_hgroupcxx . . $ BrotliDecoderStateStruct#literal_hgroup..codescxx . . $ $anonymous_type_421782d160a65272_1#codes. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
135 s->literal_hgroupcxx . . $ BrotliDecoderStateStruct#literal_hgroup..htreescxx . . $ $anonymous_type_421782d160a65272_1#htrees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
136 s->insert_copy_hgroupcxx . . $ BrotliDecoderStateStruct#insert_copy_hgroup..codescxx . . $ $anonymous_type_421782d160a65272_1#codes. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
137 s->insert_copy_hgroupcxx . . $ BrotliDecoderStateStruct#insert_copy_hgroup..htreescxx . . $ $anonymous_type_421782d160a65272_1#htrees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
138 s->distance_hgroupcxx . . $ BrotliDecoderStateStruct#distance_hgroup..codescxx . . $ $anonymous_type_421782d160a65272_1#codes. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
139 s->distance_hgroupcxx . . $ BrotliDecoderStateStruct#distance_hgroup..htreescxx . . $ $anonymous_type_421782d160a65272_1#htrees. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
140 }
141
142 void BrotliDecoderStateCleanupAfterMetablockcxx . . $ BrotliDecoderStateCleanupAfterMetablock(bb1fb99afd41e748).(BrotliDecoderStatecxx . . $ `c/dec/state.h:368:9`!* s) {
143 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->context_modes);
144 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->context_map);
145 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->dist_context_map);
146 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->literal_hgroup.htrees);
147 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->insert_copy_hgroup.htrees);
148 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->distance_hgroup.htrees);
149 }
150
151 void BrotliDecoderStateCleanupcxx . . $ BrotliDecoderStateCleanup(bb1fb99afd41e748).(BrotliDecoderStatecxx . . $ `c/dec/state.h:368:9`!* s) {
152 BrotliDecoderStateCleanupAfterMetablockcxx . . $ BrotliDecoderStateCleanupAfterMetablock(bb1fb99afd41e748).(s);
153
154 BROTLI_DECODER_ON_FINISHcxx . . $ `c/dec/state.c:28:9`!(s);
155
156 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->compound_dictionary);
157 BrotliSharedDictionaryDestroyInstancecxx . . $ BrotliSharedDictionaryDestroyInstance(9313191f525150ef).(s->dictionarycxx . . $ BrotliDecoderStateStruct#dictionary.);
158 s->dictionarycxx . . $ BrotliDecoderStateStruct#dictionary. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
159 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->ringbuffer);
160 BROTLI_DECODER_FREEcxx . . $ `c/dec/state.h:383:9`!(s, s->block_type_trees);
161 }
162
163 BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! BrotliDecoderHuffmanTreeGroupInitcxx . . $ BrotliDecoderHuffmanTreeGroupInit(20e2164bba7db65f).(BrotliDecoderStatecxx . . $ `c/dec/state.h:368:9`!* s,
164 HuffmanTreeGroupcxx . . $ HuffmanTreeGroup#* group, brotli_reg_tcxx . . $ `c/common/platform.h:237:9`! alphabet_size_max,
165 brotli_reg_tcxx . . $ `c/common/platform.h:237:9`! alphabet_size_limit, brotli_reg_tcxx . . $ `c/common/platform.h:237:9`! ntrees) {
166 /* 376 = 256 (1-st level table) + 4 + 7 + 15 + 31 + 63 (2-nd level mix-tables)
167 This number is discovered "unlimited" "enough" calculator; it is actually
168 a wee bigger than required in several cases (especially for alphabets with
169 less than 16 symbols). */
170 const size_t max_table_size = alphabet_size_limit + 376;
171 const size_t code_size = sizeof(HuffmanCodecxx . . $ HuffmanCode#) * ntrees * max_table_size;
172 const size_t htree_size = sizeof(HuffmanCodecxx . . $ HuffmanCode#*) * ntrees;
173 /* Pointer alignment is, hopefully, wider than sizeof(HuffmanCode). */
174 HuffmanCodecxx . . $ HuffmanCode#** p = (HuffmanCodecxx . . $ HuffmanCode#**)BROTLI_DECODER_ALLOCcxx . . $ `c/dec/state.h:381:9`!(s,
175 code_size + htree_size);
176 group->alphabet_size_maxcxx . . $ $anonymous_type_421782d160a65272_1#alphabet_size_max. = (uint16_tcxx . . $ uint16_t#)alphabet_size_max;
177 group->alphabet_size_limitcxx . . $ $anonymous_type_421782d160a65272_1#alphabet_size_limit. = (uint16_tcxx . . $ uint16_t#)alphabet_size_limit;
178 group->num_htreescxx . . $ $anonymous_type_421782d160a65272_1#num_htrees. = (uint16_tcxx . . $ uint16_t#)ntrees;
179 group->htreescxx . . $ $anonymous_type_421782d160a65272_1#htrees. = p;
180 group->codescxx . . $ $anonymous_type_421782d160a65272_1#codes. = p ? (HuffmanCodecxx . . $ HuffmanCode#*)(&p[ntrees]) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
181 return !!p;
182 }
183
184 #if defined(__cplusplus) || defined(c_plusplus)
185 } /* extern "C" */
186 #endif