Mercurial > libavcodec.hg
comparison mpegaudiodec.c @ 7452:2240c6340eac libavcodec
Use static vlc structure to decode layer 3 huffman tables.
Patch by Art Clarke aclarke vlideshow com
author | benoit |
---|---|
date | Thu, 31 Jul 2008 12:09:11 +0000 |
parents | 0a8486c08024 |
children | 73b10d25cb8d |
comparison
equal
deleted
inserted
replaced
7451:85ab7655ad4d | 7452:2240c6340eac |
---|---|
82 static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g); | 82 static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g); |
83 static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g); | 83 static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g); |
84 | 84 |
85 /* vlc structure for decoding layer 3 huffman tables */ | 85 /* vlc structure for decoding layer 3 huffman tables */ |
86 static VLC huff_vlc[16]; | 86 static VLC huff_vlc[16]; |
87 static VLC_TYPE huff_vlc_tables[ | |
88 0+128+128+128+130+128+154+166+ | |
89 142+204+190+170+542+460+662+414 | |
90 ][2]; | |
91 static const int huff_vlc_tables_sizes[16] = { | |
92 0, 128, 128, 128, 130, 128, 154, 166, | |
93 142, 204, 190, 170, 542, 460, 662, 414 | |
94 }; | |
87 static VLC huff_quad_vlc[2]; | 95 static VLC huff_quad_vlc[2]; |
96 static VLC_TYPE huff_quad_vlc_tables[128+16][2]; | |
97 static const int huff_quad_vlc_tables_sizes[2] = { | |
98 128, 16 | |
99 }; | |
88 /* computed from band_size_long */ | 100 /* computed from band_size_long */ |
89 static uint16_t band_index_long[9][23]; | 101 static uint16_t band_index_long[9][23]; |
90 /* XXX: free when all decoders are closed */ | 102 /* XXX: free when all decoders are closed */ |
91 #define TABLE_4_3_SIZE (8191 + 16)*4 | 103 #define TABLE_4_3_SIZE (8191 + 16)*4 |
92 static int8_t table_4_3_exp[TABLE_4_3_SIZE]; | 104 static int8_t table_4_3_exp[TABLE_4_3_SIZE]; |
322 s->compute_antialias= compute_antialias_integer; | 334 s->compute_antialias= compute_antialias_integer; |
323 else | 335 else |
324 s->compute_antialias= compute_antialias_float; | 336 s->compute_antialias= compute_antialias_float; |
325 | 337 |
326 if (!init && !avctx->parse_only) { | 338 if (!init && !avctx->parse_only) { |
339 int offset; | |
340 | |
327 /* scale factors table for layer 1/2 */ | 341 /* scale factors table for layer 1/2 */ |
328 for(i=0;i<64;i++) { | 342 for(i=0;i<64;i++) { |
329 int shift, mod; | 343 int shift, mod; |
330 /* 1.0 (i = 3) is normalized to 2 ^ FRAC_BITS */ | 344 /* 1.0 (i = 3) is normalized to 2 ^ FRAC_BITS */ |
331 shift = (i / 3); | 345 shift = (i / 3); |
349 } | 363 } |
350 | 364 |
351 ff_mpa_synth_init(window); | 365 ff_mpa_synth_init(window); |
352 | 366 |
353 /* huffman decode tables */ | 367 /* huffman decode tables */ |
368 offset = 0; | |
354 for(i=1;i<16;i++) { | 369 for(i=1;i<16;i++) { |
355 const HuffTable *h = &mpa_huff_tables[i]; | 370 const HuffTable *h = &mpa_huff_tables[i]; |
356 int xsize, x, y; | 371 int xsize, x, y; |
357 unsigned int n; | 372 unsigned int n; |
358 uint8_t tmp_bits [512]; | 373 uint8_t tmp_bits [512]; |
371 tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++]; | 386 tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++]; |
372 } | 387 } |
373 } | 388 } |
374 | 389 |
375 /* XXX: fail test */ | 390 /* XXX: fail test */ |
391 huff_vlc[i].table = huff_vlc_tables+offset; | |
392 huff_vlc[i].table_allocated = huff_vlc_tables_sizes[i]; | |
376 init_vlc(&huff_vlc[i], 7, 512, | 393 init_vlc(&huff_vlc[i], 7, 512, |
377 tmp_bits, 1, 1, tmp_codes, 2, 2, 1); | 394 tmp_bits, 1, 1, tmp_codes, 2, 2, |
378 } | 395 INIT_VLC_USE_NEW_STATIC); |
396 offset += huff_vlc_tables_sizes[i]; | |
397 } | |
398 assert(offset == sizeof(huff_vlc_tables)/(sizeof(VLC_TYPE)*2)); | |
399 | |
400 offset = 0; | |
379 for(i=0;i<2;i++) { | 401 for(i=0;i<2;i++) { |
402 huff_quad_vlc[i].table = huff_quad_vlc_tables+offset; | |
403 huff_quad_vlc[i].table_allocated = huff_quad_vlc_tables_sizes[i]; | |
380 init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16, | 404 init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16, |
381 mpa_quad_bits[i], 1, 1, mpa_quad_codes[i], 1, 1, 1); | 405 mpa_quad_bits[i], 1, 1, mpa_quad_codes[i], 1, 1, |
382 } | 406 INIT_VLC_USE_NEW_STATIC); |
407 offset += huff_quad_vlc_tables_sizes[i]; | |
408 } | |
409 assert(offset == sizeof(huff_quad_vlc_tables)/(sizeof(VLC_TYPE)*2)); | |
383 | 410 |
384 for(i=0;i<9;i++) { | 411 for(i=0;i<9;i++) { |
385 k = 0; | 412 k = 0; |
386 for(j=0;j<22;j++) { | 413 for(j=0;j<22;j++) { |
387 band_index_long[i][j] = k; | 414 band_index_long[i][j] = k; |