@@ -349,4 +349,5 @@ AVCodec ff_eamad_decoder = {
.close = decode_end,
.decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};
@@ -189,4 +189,5 @@ AVCodec ff_eatqi_decoder = {
.close = tqi_decode_end,
.decode = tqi_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};
@@ -258,4 +258,5 @@ AVCodec ff_mdec_decoder = {
.close = decode_end,
.decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};
@@ -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"
@@ -134,13 +135,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);
@@ -168,7 +164,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);
}
/**
This automatically makes the eamad, eatqi and mdec init-threadsafe. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavcodec/eamad.c | 1 + libavcodec/eatqi.c | 1 + libavcodec/mdec.c | 1 + libavcodec/mpeg12.c | 15 ++++++++------- 4 files changed, 11 insertions(+), 7 deletions(-)