MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / smacker_decode_header_tree

Function smacker_decode_header_tree

libavcodec/smacker.c:172–273  ·  view source on GitHub ↗

* Store large tree as FFmpeg's vlc codes */

Source from the content-addressed store, hash-verified

170 * Store large tree as FFmpeg's vlc codes
171 */
172static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size)
173{
174 int res;
175 HuffContext huff;
176 HuffContext tmp1, tmp2;
177 VLC vlc[2];
178 int escapes[3];
179 DBCtx ctx;
180
181 if(size >= UINT_MAX>>4){ // (((size + 3) >> 2) + 3) << 2 must not overflow
182 av_log(smk->avctx, AV_LOG_ERROR, "size too large\n");
183 return -1;
184 }
185
186 tmp1.length = 256;
187 tmp1.maxlength = 0;
188 tmp1.current = 0;
189 tmp1.bits = av_mallocz(256 * 4);
190 tmp1.lengths = av_mallocz(256 * sizeof(int));
191 tmp1.values = av_mallocz(256 * sizeof(int));
192
193 tmp2.length = 256;
194 tmp2.maxlength = 0;
195 tmp2.current = 0;
196 tmp2.bits = av_mallocz(256 * 4);
197 tmp2.lengths = av_mallocz(256 * sizeof(int));
198 tmp2.values = av_mallocz(256 * sizeof(int));
199
200 memset(&vlc[0], 0, sizeof(VLC));
201 memset(&vlc[1], 0, sizeof(VLC));
202
203 if(get_bits1(gb)) {
204 smacker_decode_tree(gb, &tmp1, 0, 0);
205 skip_bits1(gb);
206 res = init_vlc(&vlc[0], SMKTREE_BITS, tmp1.length,
207 tmp1.lengths, sizeof(int), sizeof(int),
208 tmp1.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
209 if(res < 0) {
210 av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
211 return -1;
212 }
213 } else {
214 av_log(smk->avctx, AV_LOG_ERROR, "Skipping low bytes tree\n");
215 }
216 if(get_bits1(gb)){
217 smacker_decode_tree(gb, &tmp2, 0, 0);
218 skip_bits1(gb);
219 res = init_vlc(&vlc[1], SMKTREE_BITS, tmp2.length,
220 tmp2.lengths, sizeof(int), sizeof(int),
221 tmp2.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
222 if(res < 0) {
223 av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
224 return -1;
225 }
226 } else {
227 av_log(smk->avctx, AV_LOG_ERROR, "Skipping high bytes tree\n");
228 }
229

Callers 1

decode_header_treesFunction · 0.85

Calls 9

av_logFunction · 0.85
av_malloczFunction · 0.85
get_bits1Function · 0.85
smacker_decode_treeFunction · 0.85
skip_bits1Function · 0.85
get_bitsFunction · 0.85
smacker_decode_bigtreeFunction · 0.85
free_vlcFunction · 0.85
av_freeFunction · 0.85

Tested by

no test coverage detected