summaryrefslogtreecommitdiff
path: root/libavcodec/huffyuvdec.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-06-13 23:02:57 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-06-17 16:47:29 +0200
commit2d764069be3b4092dc986467660607d922023332 (patch)
tree1504ef9e286b8df559635e97d31ebe767a9e6426 /libavcodec/huffyuvdec.c
parent97141ffeec803c448d81ee4a53cfa2355f79f7ec (diff)
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 <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/huffyuvdec.c')
-rw-r--r--libavcodec/huffyuvdec.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 07fa11e37a..acc4aafdc2 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -566,24 +566,24 @@ static av_cold int decode_init(AVCodecContext *avctx)
/** Subset of GET_VLC for use in hand-roller VLC code */
#define VLC_INTERN(dst, table, gb, name, bits, max_depth) \
- code = table[index][0]; \
- n = table[index][1]; \
+ code = table[index].sym; \
+ n = table[index].len; \
if (max_depth > 1 && n < 0) { \
LAST_SKIP_BITS(name, gb, bits); \
UPDATE_CACHE(name, gb); \
\
nb_bits = -n; \
index = SHOW_UBITS(name, gb, nb_bits) + code; \
- code = table[index][0]; \
- n = table[index][1]; \
+ code = table[index].sym; \
+ n = table[index].len; \
if (max_depth > 2 && n < 0) { \
LAST_SKIP_BITS(name, gb, nb_bits); \
UPDATE_CACHE(name, gb); \
\
nb_bits = -n; \
index = SHOW_UBITS(name, gb, nb_bits) + code; \
- code = table[index][0]; \
- n = table[index][1]; \
+ code = table[index].sym; \
+ n = table[index].len; \
} \
} \
dst = code; \
@@ -594,7 +594,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
bits, max_depth, OP) \
do { \
unsigned int index = SHOW_UBITS(name, gb, bits); \
- int code, n = dtable[index][1]; \
+ int code, n = dtable[index].len; \
\
if (n<=0) { \
int nb_bits; \
@@ -604,7 +604,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
index = SHOW_UBITS(name, gb, bits); \
VLC_INTERN(dst1, table2, gb, name, bits, max_depth); \
} else { \
- code = dtable[index][0]; \
+ code = dtable[index].sym; \
OP(dst0, dst1, code); \
LAST_SKIP_BITS(name, gb, n); \
} \
@@ -752,10 +752,10 @@ static av_always_inline void decode_bgr_1(HYuvContext *s, int count,
UPDATE_CACHE(re, &s->gb);
index = SHOW_UBITS(re, &s->gb, VLC_BITS);
- n = s->vlc[4].table[index][1];
+ n = s->vlc[4].table[index].len;
if (n>0) {
- code = s->vlc[4].table[index][0];
+ code = s->vlc[4].table[index].sym;
*(uint32_t *) &s->temp[0][4 * i] = s->pix_bgr_map[code];
LAST_SKIP_BITS(re, &s->gb, n);
} else {