aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/4xm.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-30 18:04:51 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-05-02 03:52:06 +0200
commit2648df16c6549b5c9c83d312a9011f32afe75353 (patch)
tree7880fb831cdb7fefc310045ff07ddfce3090604e /libavcodec/4xm.c
parentc13b3fdb1965300f6311c0cf646f85ad1e6c1375 (diff)
downloadffmpeg-2648df16c6549b5c9c83d312a9011f32afe75353.tar.gz
avcodec/4xm: Make decoder init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/4xm.c')
-rw-r--r--libavcodec/4xm.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index e628edde43..cb315cd7e4 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -31,6 +31,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
+#include "libavutil/thread.h"
#include "avcodec.h"
#include "blockdsp.h"
#include "bswapdsp.h"
@@ -246,7 +247,7 @@ static void idct(int16_t block[64])
}
}
-static av_cold void init_vlcs(FourXContext *f)
+static av_cold void init_vlcs(void)
{
static VLC_TYPE table[2][4][32][2];
int i, j;
@@ -988,6 +989,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
static av_cold int decode_init(AVCodecContext *avctx)
{
+ static AVOnce init_static_once = AV_ONCE_INIT;
FourXContext * const f = avctx->priv_data;
int ret;
@@ -1015,13 +1017,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_blockdsp_init(&f->bdsp, avctx);
ff_bswapdsp_init(&f->bbdsp);
f->avctx = avctx;
- init_vlcs(f);
if (f->version > 2)
avctx->pix_fmt = AV_PIX_FMT_RGB565;
else
avctx->pix_fmt = AV_PIX_FMT_BGR555;
+ ff_thread_once(&init_static_once, init_vlcs);
+
return 0;
}
@@ -1035,4 +1038,5 @@ const AVCodec ff_fourxm_decoder = {
.close = decode_end,
.decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};