- int nums = hf->size;
- int16_t sym[32];
- for (int j = 0; j < nums; j++)
- sym[j] = sign_extend(j, hf->value_bits);
-
- ff_init_vlc_sparse(&s->sf_vlc[1][i], 9, hf->size, hf->bits, 1, 1,
- hf->codes, 2, 2, sym, sizeof(*sym), sizeof(*sym), 0);
+ /* The symbols are signed integers in the range -16..15;
+ * the values in the source table are offset by 16 to make
+ * them fit into an uint8_t; the -16 reverses this shift. */
+ ret = ff_init_vlc_from_lengths(&s->sf_vlc[1][i], ATRAC9_SF_VLC_BITS,
+ hf->size, &tab[0][1], 2,
+ &tab[0][0], 2, 1, -16, 0, avctx);
+ if (ret < 0)
+ return ret;
+ tab += hf->size;