diff mbox series

[FFmpeg-devel,091/134] avcodec/indeo3: Make decoder init-threadsafe

Message ID 20201130005454.110441-19-andreas.rheinhardt@gmail.com
State Accepted
Commit 8d87e1ef6c8ea9b63f9251e1e72503a915af47a2
Headers show
Series [FFmpeg-devel,01/45] avcodec/a64multienc: Fix memleak upon init failure
Related show

Checks

Context Check Description
andriy/x86 warning Failed to apply patch

Commit Message

Andreas Rheinhardt Nov. 30, 2020, 12:54 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/indeo3.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index 75113a7541..cf2cb9134f 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -31,6 +31,7 @@ 
 
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "copy_block.h"
 #include "bytestream.h"
@@ -1049,12 +1050,13 @@  static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst,
 
 static av_cold int decode_init(AVCodecContext *avctx)
 {
+    static AVOnce init_static_once = AV_ONCE_INIT;
     Indeo3DecodeContext *ctx = avctx->priv_data;
 
     ctx->avctx     = avctx;
     avctx->pix_fmt = AV_PIX_FMT_YUV410P;
 
-    build_requant_tab();
+    ff_thread_once(&init_static_once, build_requant_tab);
 
     ff_hpeldsp_init(&ctx->hdsp, avctx->flags);
 
@@ -1141,5 +1143,5 @@  AVCodec ff_indeo3_decoder = {
     .close          = decode_close,
     .decode         = decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };