diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-11-23 03:10:36 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-12-31 11:46:20 +0100 |
commit | 902e16d18356025506e6a084dcfb3c0eacf634da (patch) | |
tree | 92f6f024c97c93abdc9c7e5a710934fb8b7752bf /libavcodec/mpeg12.c | |
parent | 6e8fcd9c5624c1a89e49803de9e10562ace61b6a (diff) | |
download | ffmpeg-902e16d18356025506e6a084dcfb3c0eacf634da.tar.gz |
avcodec/mpeg12: Make initializing VLCs thread-safe
This automatically makes the eamad, eatqi, ipu and mdec decoders
init-threadsafe; in addition to the actual mpeg[12]video decoders,
of course.
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r-- | libavcodec/mpeg12.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index b4ef41e12d..2aaed89920 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -30,6 +30,7 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/timecode.h" +#include "libavutil/thread.h" #include "internal.h" #include "avcodec.h" @@ -132,13 +133,8 @@ VLC ff_mb_ptype_vlc; VLC ff_mb_btype_vlc; VLC ff_mb_pat_vlc; -av_cold void ff_mpeg12_init_vlcs(void) +static av_cold void mpeg12_init_vlcs(void) { - static int done = 0; - - if (!done) { - done = 1; - INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12, ff_mpeg12_vlc_dc_lum_bits, 1, 1, ff_mpeg12_vlc_dc_lum_code, 2, 2, 512); @@ -164,7 +160,12 @@ av_cold void ff_mpeg12_init_vlcs(void) INIT_2D_VLC_RL(ff_rl_mpeg1, 680, 0); INIT_2D_VLC_RL(ff_rl_mpeg2, 674, 0); - } +} + +av_cold void ff_mpeg12_init_vlcs(void) +{ + static AVOnce init_static_once = AV_ONCE_INIT; + ff_thread_once(&init_static_once, mpeg12_init_vlcs); } /** |