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.
Showing the changes to libavcodec/bitstream.c (1 of 1 file). Show all
Unified · Split
| @@ -129,7 +129,7 @@ static int alloc_table(VLC *vlc, int size, int use_static) · 128 unmodified lines | |||
| 129 | 129 | ||
| 130 | typedef struct VLCcode { | 130 | typedef struct VLCcode { |
| 131 | uint8_t bits; | 131 | uint8_t bits; |
| 132 | uint16_t symbol; | 132 | VLC_TYPE symbol; |
| 133 | /** codeword, with the first bit-to-be-read in the msb | 133 | /** codeword, with the first bit-to-be-read in the msb |
| 134 | * (even if intended for a little-endian bitstream reader) */ | 134 | * (even if intended for a little-endian bitstream reader) */ |
| 135 | uint32_t code; | 135 | uint32_t code; |