Skip to content

Commit 2d76406

Browse files
committed
avcodec/vlc: Use structure instead of VLC_TYPE array as VLC element
In C, qualifiers for arrays are broken: const VLC_TYPE (*foo)[2] is a pointer to an array of two const VLC_TYPE elements and unfortunately this is not compatible with a pointer to a const array of two VLC_TYPE, because the latter does not exist as array types are never qualified (the qualifier applies to the base type instead). This is the reason why get_vlc2() doesn't accept a const VLC table despite not modifying the table at all, as there is no automatic conversion from VLC_TYPE (*)[2] to const VLC_TYPE (*)[2]. Fix this by using a structure VLCElem for the VLC table. This also has the advantage of making it clear which element is which. Signed-off-by: Andreas Rheinhardt <[email protected]>
1 parent 97141ff commit 2d76406

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+120
-116
lines changed

libavcodec/4xm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static void idct(int16_t block[64])
250250

251251
static av_cold void init_vlcs(void)
252252
{
253-
static VLC_TYPE table[2][4][32][2];
253+
static VLCElem table[2][4][32];
254254
int i, j;
255255

256256
for (i = 0; i < 2; i++) {

libavcodec/aacdec_template.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,8 @@ static void aacdec_init(AACContext *ac);
12211221

12221222
static av_cold void aac_static_table_init(void)
12231223
{
1224-
static VLC_TYPE vlc_buf[304 + 270 + 550 + 300 + 328 +
1225-
294 + 306 + 268 + 510 + 366 + 462][2];
1224+
static VLCElem vlc_buf[304 + 270 + 550 + 300 + 328 +
1225+
294 + 306 + 268 + 510 + 366 + 462];
12261226
for (unsigned i = 0, offset = 0; i < 11; i++) {
12271227
vlc_spectral[i].table = &vlc_buf[offset];
12281228
vlc_spectral[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset;
@@ -1821,7 +1821,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024],
18211821
#if !USE_FIXED
18221822
const float *vq = ff_aac_codebook_vector_vals[cbt_m1];
18231823
#endif /* !USE_FIXED */
1824-
VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table;
1824+
const VLCElem *vlc_tab = vlc_spectral[cbt_m1].table;
18251825
OPEN_READER(re, gb);
18261826

18271827
switch (cbt_m1 >> 1) {

libavcodec/aacps_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSCom
7878
int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \
7979
{ \
8080
int b, num = ps->nr_ ## PAR ## _par; \
81-
VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \
81+
const VLCElem *vlc_table = vlc_ps[table_idx].table; \
8282
if (dt) { \
8383
int e_prev = e ? e - 1 : ps->num_env_old - 1; \
8484
e_prev = FFMAX(e_prev, 0); \

libavcodec/aacsbr_template.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ static int read_sbr_envelope(AACContext *ac, SpectralBandReplication *sbr, GetBi
811811
{
812812
int bits;
813813
int i, j, k;
814-
VLC_TYPE (*t_huff)[2], (*f_huff)[2];
814+
const VLCElem *t_huff, *f_huff;
815815
int t_lav, f_lav;
816816
const int delta = (ch == 1 && sbr->bs_coupling == 1) + 1;
817817
const int odd = sbr->n[1] & 1;
@@ -899,7 +899,7 @@ static int read_sbr_noise(AACContext *ac, SpectralBandReplication *sbr, GetBitCo
899899
SBRData *ch_data, int ch)
900900
{
901901
int i, j;
902-
VLC_TYPE (*t_huff)[2], (*f_huff)[2];
902+
const VLCElem *t_huff, *f_huff;
903903
int t_lav, f_lav;
904904
int delta = (ch == 1 && sbr->bs_coupling == 1) + 1;
905905

libavcodec/asvdec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static inline int asv1_get_level(GetBitContext *gb)
7878
}
7979

8080
// get_vlc2() is big-endian in this file
81-
static inline int asv2_get_vlc2(GetBitContext *gb, VLC_TYPE (*table)[2], int bits)
81+
static inline int asv2_get_vlc2(GetBitContext *gb, const VLCElem *table, int bits)
8282
{
8383
unsigned int index;
8484
int code, n;
@@ -87,8 +87,8 @@ static inline int asv2_get_vlc2(GetBitContext *gb, VLC_TYPE (*table)[2], int bit
8787
UPDATE_CACHE_LE(re, gb);
8888

8989
index = SHOW_UBITS_LE(re, gb, bits);
90-
code = table[index][0];
91-
n = table[index][1];
90+
code = table[index].sym;
91+
n = table[index].len;
9292
LAST_SKIP_BITS(re, gb, n);
9393

9494
CLOSE_READER(re, gb);

libavcodec/atrac3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ typedef struct ATRAC3Context {
122122
} ATRAC3Context;
123123

124124
static DECLARE_ALIGNED(32, float, mdct_window)[MDCT_SIZE];
125-
static VLC_TYPE atrac3_vlc_table[7 * 1 << ATRAC3_VLC_BITS][2];
125+
static VLCElem atrac3_vlc_table[7 * 1 << ATRAC3_VLC_BITS];
126126
static VLC spectral_coeff_tab[7];
127127

128128
/**
@@ -852,7 +852,7 @@ static int atrac3al_decode_frame(AVCodecContext *avctx, AVFrame *frame,
852852

853853
static av_cold void atrac3_init_static_data(void)
854854
{
855-
VLC_TYPE (*table)[2] = atrac3_vlc_table;
855+
VLCElem *table = atrac3_vlc_table;
856856
const uint8_t (*hufftabs)[2] = atrac3_hufftabs;
857857
int i;
858858

libavcodec/atrac3plus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "atrac3plus.h"
3232
#include "atrac3plus_data.h"
3333

34-
static VLC_TYPE tables_data[154276][2];
34+
static VLCElem tables_data[154276];
3535
static VLC wl_vlc_tabs[4];
3636
static VLC sf_vlc_tabs[8];
3737
static VLC ct_vlc_tabs[4];

libavcodec/atrac9dec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ static av_cold void atrac9_init_vlc(VLC *vlc, int nb_bits, int nb_codes,
844844
const uint8_t (**tab)[2],
845845
unsigned *buf_offset, int offset)
846846
{
847-
static VLC_TYPE vlc_buf[24812][2];
847+
static VLCElem vlc_buf[24812];
848848

849849
vlc->table = &vlc_buf[*buf_offset];
850850
vlc->table_allocated = FF_ARRAY_ELEMS(vlc_buf) - *buf_offset;

libavcodec/bink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
13141314
static av_cold void bink_init_vlcs(void)
13151315
{
13161316
for (int i = 0, offset = 0; i < 16; i++) {
1317-
static VLC_TYPE table[976][2];
1317+
static VLCElem table[976];
13181318
const int maxbits = bink_tree_lens[i][15];
13191319
bink_trees[i].table = table + offset;
13201320
bink_trees[i].table_allocated = 1 << maxbits;

libavcodec/cfhddata.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s)
308308
if (ret < 0)
309309
return ret;
310310
for (i = 0; i < s->vlc_9.table_size; i++) {
311-
int code = s->vlc_9.table[i][0];
312-
int len = s->vlc_9.table[i][1];
311+
int code = s->vlc_9.table[i].sym;
312+
int len = s->vlc_9.table[i].len;
313313
int level, run;
314314

315315
if (len < 0) { // more bits needed
@@ -351,8 +351,8 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s)
351351
av_assert0(s->vlc_18.table_size == 4572);
352352

353353
for (i = 0; i < s->vlc_18.table_size; i++) {
354-
int code = s->vlc_18.table[i][0];
355-
int len = s->vlc_18.table[i][1];
354+
int code = s->vlc_18.table[i].sym;
355+
int len = s->vlc_18.table[i].len;
356356
int level, run;
357357

358358
if (len < 0) { // more bits needed

0 commit comments

Comments
 (0)