From c778f2266dcea9c462006a63a43598ec655060d6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 17 Nov 2020 18:44:18 +0100 Subject: avcodec/mpegaudiodec: Make decoders init-threadsafe Simple now that ff_mpadsp_init() and ff_mpa_synth_init_* are thread-safe. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'libavcodec/mpegaudiodec_template.c') diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index b03f7cfc33..1faaa0ae52 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -30,6 +30,7 @@ #include "libavutil/crc.h" #include "libavutil/float_dsp.h" #include "libavutil/libm.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "get_bits.h" #include "internal.h" @@ -405,14 +406,9 @@ static av_cold void decode_init_static(void) static av_cold int decode_init(AVCodecContext * avctx) { - static int initialized_tables = 0; + static AVOnce init_static_once = AV_ONCE_INIT; MPADecodeContext *s = avctx->priv_data; - if (!initialized_tables) { - decode_init_static(); - initialized_tables = 1; - } - s->avctx = avctx; #if USE_FLOATS @@ -438,6 +434,8 @@ static av_cold int decode_init(AVCodecContext * avctx) if (avctx->codec_id == AV_CODEC_ID_MP3ADU) s->adu_mode = 1; + ff_thread_once(&init_static_once, decode_init_static); + return 0; } -- cgit v1.2.3