From 26cc9db744be8d5057a28c81cebb670197ac5692 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Oct 2020 07:20:43 +0200 Subject: avcodec/on2avc: Unify initializing quad and pair VLCs Up until now, quad VLCs are initialized with codes of type uint32_t, pair VLCs with codes of type uint16_t. There were two separate loops in the decoder's init function for each type of VLC. This commit unifies this: The type of the codes are now passed in as void * and the actual size of the codes is obtained from a table. This approach also allows to use the smallest type for each VLC code table: some quad tables actually fitted in uint16_t. This allows to remove about 7KB from the binary. Signed-off-by: Andreas Rheinhardt --- libavcodec/on2avc.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'libavcodec/on2avc.c') diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c index 00e5bf5397..e54c23cb1c 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -961,21 +961,12 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx) ff_on2avc_scale_diff_codes, 4, 4, 0)) { goto vlc_fail; } - for (i = 1; i < 9; i++) { - int idx = i - 1; - if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_quad_cb_elems[idx], - ff_on2avc_quad_cb_bits[idx], 1, 1, - ff_on2avc_quad_cb_codes[idx], 4, 4, - ff_on2avc_quad_cb_syms[idx], 2, 2, 0)) { - goto vlc_fail; - } - } - for (i = 9; i < 16; i++) { - int idx = i - 9; - if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_pair_cb_elems[idx], - ff_on2avc_pair_cb_bits[idx], 1, 1, - ff_on2avc_pair_cb_codes[idx], 2, 2, - ff_on2avc_pair_cb_syms[idx], 2, 2, 0)) { + for (i = 1; i < 16; i++) { + int idx = i - 1, codes_size = ff_on2avc_cb_codes_sizes[idx]; + if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_cb_elems[idx], + ff_on2avc_cb_bits[idx], 1, 1, + ff_on2avc_cb_codes[idx], codes_size, codes_size, + ff_on2avc_cb_syms[idx], 2, 2, 0)) { goto vlc_fail; } } -- cgit v1.2.3