diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-04-09 20:45:14 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-04-13 08:26:37 +0200 |
commit | c1f124f3f03c4a3fe1252e77938172d85151bf3e (patch) | |
tree | 015b67511891fb3d34c33db2f616efbc517b525c /libavcodec/hq_hqa.c | |
parent | 9c0d6145c9e066b7286712a292c74a0b75d69be5 (diff) | |
download | ffmpeg-c1f124f3f03c4a3fe1252e77938172d85151bf3e.tar.gz |
avcodec/hq_hqa: Use ff_vlc_init_from_lengths()
This allows to avoid the codes table; furthermore, given
that the runs fit into seven bits and level into nine,
one can put them into one int16_t and use as symbols table
in ff_vlc_init_from_lengths().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/hq_hqa.c')
-rw-r--r-- | libavcodec/hq_hqa.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index f07a11b71a..c849b52073 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -376,24 +376,22 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic, static av_cold void hq_init_static(void) { - VLC_INIT_STATIC_TABLE(hq_ac_rvlc, 9, NUM_HQ_AC_ENTRIES, - hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 0); + VLC_INIT_STATIC_TABLE_FROM_LENGTHS(hq_ac_rvlc, 9, NUM_HQ_AC_ENTRIES, + hq_ac_lens, 1, hq_ac_sym, 2, 2, 0, 0); for (size_t i = 0; i < FF_ARRAY_ELEMS(hq_ac_rvlc); ++i) { int len = hq_ac_rvlc[i].len; - int sym = hq_ac_rvlc[i].sym, level = sym; - int run; + int sym = (int16_t)hq_ac_rvlc[i].sym, level = sym; + + // The invalid code has been remapped to HQ_AC_INVALID_RUN, + // so the VLC is complete. + av_assert1(len != 0); if (len > 0) { - level = hq_ac_syms[sym]; - run = hq_ac_skips[sym] + 1; - } else if (len < 0) { // More bits needed - run = 0; - } else { // Invalid code - run = HQ_AC_INVALID_RUN; + level = sym >> 7; + hq_ac_rvlc[i].run = sym & 0x7F; } hq_ac_rvlc[i].len8 = len; - hq_ac_rvlc[i].run = run; hq_ac_rvlc[i].level = level; } |