aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/qdm2.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-15 22:09:31 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-08 17:51:46 +0100
commit5f2b30ba06310b90a178ca46dfb51db277431532 (patch)
tree993e0686e454845c1d5c5da6f340b0c765382dfb /libavcodec/qdm2.c
parent03112cdcd110a94aff4ddee8b2fddde0f7a36690 (diff)
downloadffmpeg-5f2b30ba06310b90a178ca46dfb51db277431532.tar.gz
avcodec/qdm2: Make decoder init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/qdm2.c')
-rw-r--r--libavcodec/qdm2.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index 118e2eac1f..fbc4c0cfdd 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"
@@ -1596,19 +1597,12 @@ static void qdm2_synthesis_filter(QDM2Context *q, int index)
* Init static data (does not depend on specific file)
*/
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;
}
/**
@@ -1616,12 +1610,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:
@@ -1767,6 +1760,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;
}
@@ -1883,4 +1878,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,
};