[FFmpeg-devel] [PATCH 163/217] avcodec/4xm: Make decoder init-threadsafe
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Wed Dec 2 06:21:50 EET 2020
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
libavcodec/4xm.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 336c651d31..00a8e0b1f3 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -30,6 +30,7 @@
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/thread.h"
#include "avcodec.h"
#include "blockdsp.h"
#include "bswapdsp.h"
@@ -245,7 +246,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;
@@ -987,6 +988,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;
@@ -1014,13 +1016,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;
}
@@ -1034,4 +1037,5 @@ AVCodec ff_fourxm_decoder = {
.close = decode_end,
.decode = 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