diff mbox series

[FFmpeg-devel,v2,130/162] avcodec/intrax8: Make ff_intrax8_common_init() thread-safe

Message ID 20201120073327.820745-31-andreas.rheinhardt@gmail.com
State Accepted
Commit b1af617f519cf7bbae1379473c76cff2b0e55659
Headers show
Series VLC, esp. init_vlc patches | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 20, 2020, 7:32 a.m. UTC
In particular, don't reinitialize VLCs every time an IntraX8Context is
initialized.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/intrax8.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index b62bff3b48..0bd0db29c4 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -22,6 +22,7 @@ 
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "idctdsp.h"
@@ -696,6 +697,8 @@  av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
                                    int block_last_index[12],
                                    int mb_width, int mb_height)
 {
+    static AVOnce init_static_once = AV_ONCE_INIT;
+
     w->avctx = avctx;
     w->idsp = *idsp;
     w->mb_width  = mb_width;
@@ -723,7 +726,7 @@  av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
     ff_intrax8dsp_init(&w->dsp);
     ff_blockdsp_init(&w->bdsp, avctx);
 
-    x8_vlc_init();
+    ff_thread_once(&init_static_once, x8_vlc_init);
 
     return 0;
 }