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
45#define ASV1_LEVEL_VLC_BITS 445#define ASV1_LEVEL_VLC_BITS 4
46#define ASV2_LEVEL_VLC_BITS 1046#define ASV2_LEVEL_VLC_BITS 10
47 47
48static VLC ccp_vlc;48static VLCElem ccp_vlc[32];
49static VLC level_vlc;49static VLCElem level_vlc[16];
50static VLC dc_ccp_vlc;50static VLCElem dc_ccp_vlc[16];
51static VLC ac_ccp_vlc;51static VLCElem ac_ccp_vlc[64];
52static VLC asv2_level_vlc;52static VLCElem asv2_level_vlc[1024];
53 53
54typedef struct ASVDecContext {54typedef struct ASVDecContext {
55 ASVCommonContext c;55 ASVCommonContext c;
@@ -67,26 +67,26 @@ typedef struct ASVDecContext { · 11 unmodified lines
67 67
68static av_cold void init_vlcs(void)68static av_cold void init_vlcs(void)
69{69{
70 VLC_INIT_STATIC(&ccp_vlc, CCP_VLC_BITS, 17,70 VLC_INIT_STATIC_TABLE(ccp_vlc, CCP_VLC_BITS, 17,
71 &ff_asv_ccp_tab[0][1], 2, 1,71 &ff_asv_ccp_tab[0][1], 2, 1,
72 &ff_asv_ccp_tab[0][0], 2, 1, 32);72 &ff_asv_ccp_tab[0][0], 2, 1, 0);
73 VLC_INIT_LE_STATIC(&dc_ccp_vlc, DC_CCP_VLC_BITS, 8,73 VLC_INIT_STATIC_TABLE(dc_ccp_vlc, DC_CCP_VLC_BITS, 8,
74 &ff_asv_dc_ccp_tab[0][1], 2, 1,74 &ff_asv_dc_ccp_tab[0][1], 2, 1,
75 &ff_asv_dc_ccp_tab[0][0], 2, 1, 16);75 &ff_asv_dc_ccp_tab[0][0], 2, 1, VLC_INIT_LE);
76 VLC_INIT_LE_STATIC(&ac_ccp_vlc, AC_CCP_VLC_BITS, 16,76 VLC_INIT_STATIC_TABLE(ac_ccp_vlc, AC_CCP_VLC_BITS, 16,
77 &ff_asv_ac_ccp_tab[0][1], 2, 1,77 &ff_asv_ac_ccp_tab[0][1], 2, 1,
78 &ff_asv_ac_ccp_tab[0][0], 2, 1, 64);78 &ff_asv_ac_ccp_tab[0][0], 2, 1, VLC_INIT_LE);
79 VLC_INIT_STATIC(&level_vlc, ASV1_LEVEL_VLC_BITS, 7,79 VLC_INIT_STATIC_TABLE(level_vlc, ASV1_LEVEL_VLC_BITS, 7,
80 &ff_asv_level_tab[0][1], 2, 1,80 &ff_asv_level_tab[0][1], 2, 1,
81 &ff_asv_level_tab[0][0], 2, 1, 16);81 &ff_asv_level_tab[0][0], 2, 1, 0);
82 VLC_INIT_LE_STATIC(&asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63,82 VLC_INIT_STATIC_TABLE(asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63,
83 &ff_asv2_level_tab[0][1], 4, 2,83 &ff_asv2_level_tab[0][1], 4, 2,
84 &ff_asv2_level_tab[0][0], 4, 2, 1024);84 &ff_asv2_level_tab[0][0], 4, 2, VLC_INIT_LE);
85}85}
86 86
87static inline int asv1_get_level(GetBitContext *gb)87static inline int asv1_get_level(GetBitContext *gb)
88{88{
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);
90 90
91 if (code == 3)91 if (code == 3)
92 return get_sbits(gb, 8);92 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
115 115
116static inline int asv2_get_level(GetBitContext *gb)116static inline int asv2_get_level(GetBitContext *gb)
117{117{
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);
119 119
120 if (code == 31)120 if (code == 31)
121 return (int8_t) get_bits_le(gb, 8);121 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
130 block[0] = 8 * get_bits(&a->gb, 8);130 block[0] = 8 * get_bits(&a->gb, 8);
131 131
132 for (i = 0; i < 11; i++) {132 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);
134 134
135 if (ccp) {135 if (ccp) {
136 if (ccp == 16)136 if (ccp == 16)
@@ -162,7 +162,7 @@ static inline int asv2_decode_block(ASVDecContext *a, int16_t block[64]) · 25 unmodified lines
162 162
163 block[0] = 8 * get_bits_le(&a->gb, 8);163 block[0] = 8 * get_bits_le(&a->gb, 8);
164 164
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);
166 if (ccp) {166 if (ccp) {
167 if (ccp & 4)167 if (ccp & 4)
168 block[a->permutated_scantable[1]] = (asv2_get_level(&a->gb) * a->intra_matrix[1]) >> 4;168 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
173 }173 }
174 174
175 for (i = 1; i < count + 1; i++) {175 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);
177 177
178 if (ccp) {178 if (ccp) {
179 if (ccp & 8)179 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