diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-06-13 23:02:57 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-06-17 16:47:29 +0200 |
commit | 2d764069be3b4092dc986467660607d922023332 (patch) | |
tree | 1504ef9e286b8df559635e97d31ebe767a9e6426 /libavcodec/vlc.h | |
parent | 97141ffeec803c448d81ee4a53cfa2355f79f7ec (diff) | |
download | ffmpeg-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/vlc.h')
-rw-r--r-- | libavcodec/vlc.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libavcodec/vlc.h b/libavcodec/vlc.h index 6879c3ca6a..e63c484755 100644 --- a/libavcodec/vlc.h +++ b/libavcodec/vlc.h @@ -21,11 +21,16 @@ #include <stdint.h> -#define VLC_TYPE int16_t +// When changing this, be sure to also update tableprint_vlc.h accordingly. +typedef int16_t VLCBaseType; + +typedef struct VLCElem { + VLCBaseType sym, len; +} VLCElem; typedef struct VLC { int bits; - VLC_TYPE (*table)[2]; ///< code, bits + VLCElem *table; int table_size, table_allocated; } VLC; @@ -98,7 +103,7 @@ void ff_free_vlc(VLC *vlc); #define INIT_CUSTOM_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, \ h, i, j, flags, static_size) \ do { \ - static VLC_TYPE table[static_size][2]; \ + static VLCElem table[static_size]; \ (vlc)->table = table; \ (vlc)->table_allocated = static_size; \ ff_init_vlc_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \ @@ -127,7 +132,7 @@ void ff_free_vlc(VLC *vlc); symbols, symbols_wrap, symbols_size, \ offset, flags, static_size) \ do { \ - static VLC_TYPE table[static_size][2]; \ + static VLCElem table[static_size]; \ (vlc)->table = table; \ (vlc)->table_allocated = static_size; \ ff_init_vlc_from_lengths(vlc, bits, nb_codes, lens, len_wrap, \ |