diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-02-11 19:27:55 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-02-18 20:17:18 +0100 |
commit | f32685594737339bd8600302cf2fc726c5b8b7b6 (patch) | |
tree | 3822e6c14fe443bc3dfb21979e86020072617632 /libavcodec/ituh263dec.c | |
parent | 6b3957354759386ce9c93f1b3154691d99cb3437 (diff) |
avcodec/ituh263dec: Make initializing VLCs thread-safe
This automatically makes the FLV, H.263, H.263+, Intel H.263,
MPEG-4, RealVideo 1.0 and RealVideo 2.0 decoders init-threadsafe.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/ituh263dec.c')
-rw-r--r-- | libavcodec/ituh263dec.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 77ca0d7e40..96a343c39f 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -34,6 +34,7 @@ #include "libavutil/internal.h" #include "libavutil/mathematics.h" #include "libavutil/mem_internal.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "mpegvideo.h" #include "h263.h" @@ -103,12 +104,8 @@ static VLC cbpc_b_vlc; /* init vlcs */ -/* XXX: find a better solution to handle static init */ -av_cold void ff_h263_decode_init_vlc(void) +static av_cold void h263_decode_init_vlc(void) { - static volatile int done = 0; - - if (!done) { INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9, ff_h263_intra_MCBPC_bits, 1, 1, ff_h263_intra_MCBPC_code, 1, 1, 72); @@ -130,8 +127,12 @@ av_cold void ff_h263_decode_init_vlc(void) INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4, &ff_cbpc_b_tab[0][1], 2, 1, &ff_cbpc_b_tab[0][0], 2, 1, 8); - done = 1; - } +} + +av_cold void ff_h263_decode_init_vlc(void) +{ + static AVOnce init_static_once = AV_ONCE_INIT; + ff_thread_once(&init_static_once, h263_decode_init_vlc); } int ff_h263_decode_mba(MpegEncContext *s) |