summaryrefslogtreecommitdiff
path: root/libavcodec/on2avc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-10-18 07:20:43 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-10-21 07:47:55 +0200
commit26cc9db744be8d5057a28c81cebb670197ac5692 (patch)
tree8f55c4dd9fd7d3f086f947b90325ff73f0393359 /libavcodec/on2avc.c
parentfba8890628ece8a4c7ca479ea86d4ec309557384 (diff)
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 <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/on2avc.c')
-rw-r--r--libavcodec/on2avc.c21
1 files changed, 6 insertions, 15 deletions
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;
}
}