From 2d764069be3b4092dc986467660607d922023332 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 13 Jun 2022 23:02:57 +0200 Subject: 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 --- libavcodec/asvdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libavcodec/asvdec.c') diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c index 5b2c71be82..57ba4c5b5e 100644 --- a/libavcodec/asvdec.c +++ b/libavcodec/asvdec.c @@ -78,7 +78,7 @@ static inline int asv1_get_level(GetBitContext *gb) } // get_vlc2() is big-endian in this file -static inline int asv2_get_vlc2(GetBitContext *gb, VLC_TYPE (*table)[2], int bits) +static inline int asv2_get_vlc2(GetBitContext *gb, const VLCElem *table, int bits) { unsigned int index; int code, n; @@ -87,8 +87,8 @@ static inline int asv2_get_vlc2(GetBitContext *gb, VLC_TYPE (*table)[2], int bit UPDATE_CACHE_LE(re, gb); index = SHOW_UBITS_LE(re, gb, bits); - code = table[index][0]; - n = table[index][1]; + code = table[index].sym; + n = table[index].len; LAST_SKIP_BITS(re, gb, n); CLOSE_READER(re, gb); -- cgit v1.2.3