Of all these VLCs here, only VLC.table was really used after init, so use the ff_vlc_init_tables API to get rid of them.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -106,7 +106,7 @@ typedef struct IMCContext { · 105 unmodified lines | |||
| 106 | AVCodecContext *avctx; | 106 | AVCodecContext *avctx; |
| 107 | } IMCContext; | 107 | } IMCContext; |
| 108 | 108 | ||
| 109 | static VLC huffman_vlc[4][4]; | 109 | static const VLCElem *huffman_vlc[4][4]; |
| 110 | 110 | ||
| 111 | #define IMC_VLC_BITS 9 | 111 | #define IMC_VLC_BITS 9 |
| 112 | #define VLC_TABLES_SIZE 9512 | 112 | #define VLC_TABLES_SIZE 9512 |
| @@ -171,16 +171,15 @@ static av_cold void iac_generate_tabs(IMCContext *q, int sampling_rate) · 58 unmodified lines | |||
| 171 | 171 | ||
| 172 | static av_cold void imc_init_static(void) | 172 | static av_cold void imc_init_static(void) |
| 173 | { | 173 | { |
| 174 | VLCInitState state = VLC_INIT_STATE(vlc_tables); | ||
| 174 | /* initialize the VLC tables */ | 175 | /* initialize the VLC tables */ |
| 175 | for (int i = 0, offset = 0; i < 4 ; i++) { | 176 | for (int i = 0; i < 4 ; i++) { |
| 176 | for (int j = 0; j < 4; j++) { | 177 | for (int j = 0; j < 4; j++) { |
| 177 | huffman_vlc[i][j].table = &vlc_tables[offset]; | 178 | huffman_vlc[i][j] = |
| 178 | huffman_vlc[i][j].table_allocated = VLC_TABLES_SIZE - offset; | 179 | ff_vlc_init_tables_from_lengths(&state, IMC_VLC_BITS, imc_huffman_sizes[i], |
| 179 | ff_vlc_init_from_lengths(&huffman_vlc[i][j], IMC_VLC_BITS, imc_huffman_sizes[i], | 180 | imc_huffman_lens[i][j], 1, |
| 180 | imc_huffman_lens[i][j], 1, | 181 | imc_huffman_syms[i][j], 1, 1, |
| 181 | imc_huffman_syms[i][j], 1, 1, | 182 | 0, 0); |
| 182 | 0, VLC_INIT_STATIC_OVERLONG, NULL); | ||
| 183 | offset += huffman_vlc[i][j].table_size; | ||
| 184 | } | 183 | } |
| 185 | } | 184 | } |
| 186 | } | 185 | } |
| @@ -311,16 +310,11 @@ static void imc_read_level_coeffs(IMCContext *q, int stream_format_code, · 124 unmodified lines | |||
| 311 | int *levlCoeffs) | 310 | int *levlCoeffs) |
| 312 | { | 311 | { |
| 313 | int i; | 312 | int i; |
| 314 | VLC *hufftab[4]; | ||
| 315 | int start = 0; | 313 | int start = 0; |
| 316 | const uint8_t *cb_sel; | 314 | const uint8_t *cb_sel; |
| 317 | int s; | 315 | int s = stream_format_code >> 1; |
| 316 | const VLCElem * const *const hufftab = huffman_vlc[s]; | ||
| 318 | 317 | ||
| 319 | s = stream_format_code >> 1; | ||
| 320 | hufftab[0] = &huffman_vlc[s][0]; | ||
| 321 | hufftab[1] = &huffman_vlc[s][1]; | ||
| 322 | hufftab[2] = &huffman_vlc[s][2]; | ||
| 323 | hufftab[3] = &huffman_vlc[s][3]; | ||
| 324 | cb_sel = imc_cb_select[s]; | 318 | cb_sel = imc_cb_select[s]; |
| 325 | 319 | ||
| 326 | if (stream_format_code & 4) | 320 | if (stream_format_code & 4) |
| @@ -328,7 +322,7 @@ static void imc_read_level_coeffs(IMCContext *q, int stream_format_code, · 1 unmodified line | |||
| 328 | if (start) | 322 | if (start) |
| 329 | levlCoeffs[0] = get_bits(&q->gb, 7); | 323 | levlCoeffs[0] = get_bits(&q->gb, 7); |
| 330 | for (i = start; i < BANDS; i++) { | 324 | for (i = start; i < BANDS; i++) { |
| 331 | levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]]->table, | 325 | levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]], |
| 332 | IMC_VLC_BITS, 2); | 326 | IMC_VLC_BITS, 2); |
| 333 | if (levlCoeffs[i] == 17) | 327 | if (levlCoeffs[i] == 17) |
| 334 | levlCoeffs[i] += get_bits(&q->gb, 4); | 328 | levlCoeffs[i] += get_bits(&q->gb, 4); |