[FFmpeg-devel] [PATCH v2 069/162] avcodec/qdm2: Make decoder init-threadsafe
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Fri Nov 20 09:19:42 EET 2020
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
libavcodec/qdm2.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index f2e78c3fa2..b1465750c2 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -36,6 +36,7 @@
#include <stdio.h>
#include "libavutil/channel_layout.h"
+#include "libavutil/thread.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
@@ -1598,19 +1599,12 @@ static void qdm2_synthesis_filter(QDM2Context *q, int index)
* @param q context
*/
static av_cold void qdm2_init_static_data(void) {
- static int done;
-
- if(done)
- return;
-
qdm2_init_vlc();
softclip_table_init();
rnd_table_init();
init_noise_samples();
ff_mpa_synth_init_float();
-
- done = 1;
}
/**
@@ -1618,12 +1612,11 @@ static av_cold void qdm2_init_static_data(void) {
*/
static av_cold int qdm2_decode_init(AVCodecContext *avctx)
{
+ static AVOnce init_static_once = AV_ONCE_INIT;
QDM2Context *s = avctx->priv_data;
int tmp_val, tmp, size;
GetByteContext gb;
- qdm2_init_static_data();
-
/* extradata parsing
Structure:
@@ -1769,6 +1762,8 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ ff_thread_once(&init_static_once, qdm2_init_static_data);
+
return 0;
}
@@ -1885,4 +1880,5 @@ AVCodec ff_qdm2_decoder = {
.close = qdm2_decode_close,
.decode = qdm2_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};
--
2.25.1
More information about the ffmpeg-devel
mailing list