[FFmpeg-devel] [PATCH 3/3 v3] h264: Run VLC init under pthread_once

Hendrik Leppkes h.leppkes at gmail.com
Wed Oct 7 22:46:50 CEST 2015


On Wed, Oct 7, 2015 at 10:18 PM, Michael Niedermayer
<michael at niedermayer.cc> wrote:
> On Wed, Oct 07, 2015 at 12:28:51PM -0400, Derek Buitenhuis wrote:
>> This makes the h.264 decoder threadsafe to initialize.
>
> can you explain why it is not threadsafe currently ?
> (assuming "done = 1" would be moved to the end of
> ff_h264_decode_init_vlc())
>

Validating that a complex init function doesn't produce intermittently
incoherent states on all platforms (were reads/writes are not
necessarily atomic) is no easy feat. Global init should be protected
and only run once to avoid any and all unforseen issues.
Right now its protected by the lock in avcodec - but if we want to get
rid of that to avoid contention issues, we need new protection.

- Hendrik


More information about the ffmpeg-devel mailing list