[FFmpeg-devel] [PATCH 001/114] avcodec/bitstream: Add second function to create VLCs

Derek Buitenhuis derek.buitenhuis at gmail.com
Thu Nov 12 23:25:49 EET 2020


On 12/11/2020 20:51, Andreas Rheinhardt wrote:
> The ff_init_vlc_... functions are inherently thread-safe: Everything is
> modified only once and directly set to its final value; so it's no
> problem if two threads are initializing the same static VLC at the same
> time.



Hmm, indeed. At the very least it is doing repeated work and allocations on every init
that needn't happen. Wrapping in ff_thread_once is still preferable IMO...

Unrelatedly: It looks like buf may not be freed when ff_init_vlc_from_lengths is called
with INIT_VLC_USE_NEW_STATIC with more than LOCALBUF_ELEMS (which while currently
set to something higher than the max used, could accidentally be called with more than
1500 in the future.) There should be fixed, or maybe be an assert added so that nobody
ends up doing that in the first place by accident.

- Derek


More information about the ffmpeg-devel mailing list