[FFmpeg-cvslog] avcodec/bitstream: Consistently treat symbol as VLC_TYPE

Andreas Rheinhardt git at videolan.org
Tue Oct 27 12:04:38 EET 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Mon Oct 26 00:05:26 2020 +0100| [df6ec7f83b4fb65d760259e01182dc28b6cf3f2f] | committer: Andreas Rheinhardt

avcodec/bitstream: Consistently treat symbol as VLC_TYPE

If a static VLC table gets initialized a second time (or concurrently by
two threads) and if said VLC table uses symbols that have the sign bit
of VLC_TYPE (a typedef for int16_t) set, initializing the VLC fails. The
reason is that the type of the symbol in the temporary array is an
uint16_t and so comparing it to the symbol read from the VLC table will
fail, because only the lower 16bits coincide. Said failure triggers an
assert.

Reviewed-by: Lynne <dev at lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=df6ec7f83b4fb65d760259e01182dc28b6cf3f2f
---

 libavcodec/bitstream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index 77c2b9ce05..2685ff2968 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -129,7 +129,7 @@ static int alloc_table(VLC *vlc, int size, int use_static)
 
 typedef struct VLCcode {
     uint8_t bits;
-    uint16_t symbol;
+    VLC_TYPE symbol;
     /** codeword, with the first bit-to-be-read in the msb
      * (even if intended for a little-endian bitstream reader) */
     uint32_t code;



More information about the ffmpeg-cvslog mailing list