History

avcodec/asvdec: Avoid superfluous VLC structures

Of all these VLCs here, only VLC.table was really used after init, so use the ff_vlc_init_tables API to get rid of them.

Andreas Rheinhardt committed 3 years ago

Commit a99285a1 parent ab8a8241 file · +25 −25Browse files

Unified · Split

libavcodec/asvdec.c+25−25
@@ -45,11 +45,11 @@ · 44 unmodified lines
4545 #define ASV1_LEVEL_VLC_BITS 4
4646 #define ASV2_LEVEL_VLC_BITS 10
4747
48−static VLC ccp_vlc;
49−static VLC level_vlc;
50−static VLC dc_ccp_vlc;
51−static VLC ac_ccp_vlc;
52−static VLC asv2_level_vlc;
48+static VLCElem ccp_vlc[32];
49+static VLCElem level_vlc[16];
50+static VLCElem dc_ccp_vlc[16];
51+static VLCElem ac_ccp_vlc[64];
52+static VLCElem asv2_level_vlc[1024];
5353
5454 typedef struct ASVDecContext {
5555 ASVCommonContext c;
@@ -67,26 +67,26 @@ typedef struct ASVDecContext { · 11 unmodified lines
6767
6868 static av_cold void init_vlcs(void)
6969 {
70− VLC_INIT_STATIC(&ccp_vlc, CCP_VLC_BITS, 17,
71− &ff_asv_ccp_tab[0][1], 2, 1,
72− &ff_asv_ccp_tab[0][0], 2, 1, 32);
73− VLC_INIT_LE_STATIC(&dc_ccp_vlc, DC_CCP_VLC_BITS, 8,
74− &ff_asv_dc_ccp_tab[0][1], 2, 1,
75− &ff_asv_dc_ccp_tab[0][0], 2, 1, 16);
76− VLC_INIT_LE_STATIC(&ac_ccp_vlc, AC_CCP_VLC_BITS, 16,
77− &ff_asv_ac_ccp_tab[0][1], 2, 1,
78− &ff_asv_ac_ccp_tab[0][0], 2, 1, 64);
79− VLC_INIT_STATIC(&level_vlc, ASV1_LEVEL_VLC_BITS, 7,
80− &ff_asv_level_tab[0][1], 2, 1,
81− &ff_asv_level_tab[0][0], 2, 1, 16);
82− VLC_INIT_LE_STATIC(&asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63,
83− &ff_asv2_level_tab[0][1], 4, 2,
84− &ff_asv2_level_tab[0][0], 4, 2, 1024);
70+ VLC_INIT_STATIC_TABLE(ccp_vlc, CCP_VLC_BITS, 17,
71+ &ff_asv_ccp_tab[0][1], 2, 1,
72+ &ff_asv_ccp_tab[0][0], 2, 1, 0);
73+ VLC_INIT_STATIC_TABLE(dc_ccp_vlc, DC_CCP_VLC_BITS, 8,
74+ &ff_asv_dc_ccp_tab[0][1], 2, 1,
75+ &ff_asv_dc_ccp_tab[0][0], 2, 1, VLC_INIT_LE);
76+ VLC_INIT_STATIC_TABLE(ac_ccp_vlc, AC_CCP_VLC_BITS, 16,
77+ &ff_asv_ac_ccp_tab[0][1], 2, 1,
78+ &ff_asv_ac_ccp_tab[0][0], 2, 1, VLC_INIT_LE);
79+ VLC_INIT_STATIC_TABLE(level_vlc, ASV1_LEVEL_VLC_BITS, 7,
80+ &ff_asv_level_tab[0][1], 2, 1,
81+ &ff_asv_level_tab[0][0], 2, 1, 0);
82+ VLC_INIT_STATIC_TABLE(asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63,
83+ &ff_asv2_level_tab[0][1], 4, 2,
84+ &ff_asv2_level_tab[0][0], 4, 2, VLC_INIT_LE);
8585 }
8686
8787 static inline int asv1_get_level(GetBitContext *gb)
8888 {
89− int code = get_vlc2(gb, level_vlc.table, ASV1_LEVEL_VLC_BITS, 1);
89+ int code = get_vlc2(gb, level_vlc, ASV1_LEVEL_VLC_BITS, 1);
9090
9191 if (code == 3)
9292 return get_sbits(gb, 8);
@@ -115,7 +115,7 @@ static inline int asv2_get_vlc2(GetBitContext *gb, const VLCElem *table, int bit · 22 unmodified lines
115115
116116 static inline int asv2_get_level(GetBitContext *gb)
117117 {
118− int code = asv2_get_vlc2(gb, asv2_level_vlc.table, ASV2_LEVEL_VLC_BITS);
118+ int code = asv2_get_vlc2(gb, asv2_level_vlc, ASV2_LEVEL_VLC_BITS);
119119
120120 if (code == 31)
121121 return (int8_t) get_bits_le(gb, 8);
@@ -130,7 +130,7 @@ static inline int asv1_decode_block(ASVDecContext *a, int16_t block[64]) · 8 unmodified lines
130130 block[0] = 8 * get_bits(&a->gb, 8);
131131
132132 for (i = 0; i < 11; i++) {
133− const int ccp = get_vlc2(&a->gb, ccp_vlc.table, CCP_VLC_BITS, 1);
133+ const int ccp = get_vlc2(&a->gb, ccp_vlc, CCP_VLC_BITS, 1);
134134
135135 if (ccp) {
136136 if (ccp == 16)
@@ -162,7 +162,7 @@ static inline int asv2_decode_block(ASVDecContext *a, int16_t block[64]) · 25 unmodified lines
162162
163163 block[0] = 8 * get_bits_le(&a->gb, 8);
164164
165− ccp = asv2_get_vlc2(&a->gb, dc_ccp_vlc.table, DC_CCP_VLC_BITS);
165+ ccp = asv2_get_vlc2(&a->gb, dc_ccp_vlc, DC_CCP_VLC_BITS);
166166 if (ccp) {
167167 if (ccp & 4)
168168 block[a->permutated_scantable[1]] = (asv2_get_level(&a->gb) * a->intra_matrix[1]) >> 4;
@@ -173,7 +173,7 @@ static inline int asv2_decode_block(ASVDecContext *a, int16_t block[64]) · 4 unmodified lines
173173 }
174174
175175 for (i = 1; i < count + 1; i++) {
176− const int ccp = asv2_get_vlc2(&a->gb, ac_ccp_vlc.table, AC_CCP_VLC_BITS);
176+ const int ccp = asv2_get_vlc2(&a->gb, ac_ccp_vlc, AC_CCP_VLC_BITS);
177177
178178 if (ccp) {
179179 if (ccp & 8)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t