summaryrefslogtreecommitdiff
path: root/libavcodec/get_bits.h
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/get_bits.h
parent97141ffeec803c448d81ee4a53cfa2355f79f7ec (diff)
downloadffmpeg-2d764069be3b4092dc986467660607d922023332.tar.gz
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/get_bits.h')
-rw-r--r--libavcodec/get_bits.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index d4e9276da1..16f8af5107 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -710,8 +710,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s)
unsigned int index; \
\
index = SHOW_UBITS(name, gb, bits); \
- 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); \
@@ -720,8 +720,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s)
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); \
@@ -729,8 +729,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s)
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; \
} \
} \
SKIP_BITS(name, gb, n); \
@@ -775,15 +775,15 @@ static inline const uint8_t *align_get_bits(GetBitContext *s)
/* Return the LUT element for the given bitstream configuration. */
static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits,
- VLC_TYPE (*table)[2])
+ const VLCElem *table)
{
unsigned idx;
*nb_bits = -*n;
idx = show_bits(s, *nb_bits) + code;
- *n = table[idx][1];
+ *n = table[idx].len;
- return table[idx][0];
+ return table[idx].sym;
}
/**
@@ -795,14 +795,14 @@ static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits,
* = (max_vlc_length + bits - 1) / bits
* @returns the code parsed or -1 if no vlc matches
*/
-static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
+static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table,
int bits, int max_depth)
{
#if CACHED_BITSTREAM_READER
int nb_bits;
unsigned idx = show_bits(s, bits);
- int code = table[idx][0];
- int n = table[idx][1];
+ int code = table[idx].sym;
+ int n = table[idx].len;
if (max_depth > 1 && n < 0) {
skip_remaining(s, bits);