- for (i = 0; i < 16; i++) {
- /* DC histograms */
- if (init_vlc(&s->dc_vlc[i], 11, 32,
- &s->huffman_table[i][0][1], 8, 4,
- &s->huffman_table[i][0][0], 8, 4, 0) < 0)
- goto vlc_fail;
-
- /* group 1 AC histograms */
- if (init_vlc(&s->ac_vlc_1[i], 11, 32,
- &s->huffman_table[i + 16][0][1], 8, 4,
- &s->huffman_table[i + 16][0][0], 8, 4, 0) < 0)
- goto vlc_fail;
-
- /* group 2 AC histograms */
- if (init_vlc(&s->ac_vlc_2[i], 11, 32,
- &s->huffman_table[i + 16 * 2][0][1], 8, 4,
- &s->huffman_table[i + 16 * 2][0][0], 8, 4, 0) < 0)
- goto vlc_fail;
-
- /* group 3 AC histograms */
- if (init_vlc(&s->ac_vlc_3[i], 11, 32,
- &s->huffman_table[i + 16 * 3][0][1], 8, 4,
- &s->huffman_table[i + 16 * 3][0][0], 8, 4, 0) < 0)
- goto vlc_fail;
-
- /* group 4 AC histograms */
- if (init_vlc(&s->ac_vlc_4[i], 11, 32,
- &s->huffman_table[i + 16 * 4][0][1], 8, 4,
- &s->huffman_table[i + 16 * 4][0][0], 8, 4, 0) < 0)
- goto vlc_fail;
+ for (i = 0; i < FF_ARRAY_ELEMS(s->coeff_vlc); i++) {
+ const HuffTable *tab = &s->huffman_table[i];
+
+ ret = ff_init_vlc_from_lengths(&s->coeff_vlc[i], 11, tab->nb_entries,
+ &tab->entries[0].len, sizeof(*tab->entries),
+ &tab->entries[0].sym, sizeof(*tab->entries), 1,
+ 0, 0, avctx);
+ if (ret < 0)
+ return ret;