diff mbox series

[FFmpeg-devel,v2,112/162] avcodec/rv34: Make initializing static VLC tables thread-safe

Message ID 20201120073327.820745-13-andreas.rheinhardt@gmail.com
State Accepted
Commit f697622f687c22392194d6939914c9a6a01ce69e
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
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/rv34.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index e633c348bd..13f9b609e2 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -27,6 +27,7 @@ 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
+#include "libavutil/thread.h"
 
 #include "avcodec.h"
 #include "error_resilience.h"
@@ -1481,6 +1482,7 @@  static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
  */
 av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
 {
+    static AVOnce init_static_once = AV_ONCE_INIT;
     RV34DecContext *r = avctx->priv_data;
     MpegEncContext *s = &r->s;
     int ret;
@@ -1513,8 +1515,7 @@  av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
         return ret;
     }
 
-    if(!intra_vlcs[0].cbppattern[0].bits)
-        rv34_init_tables();
+    ff_thread_once(&init_static_once, rv34_init_tables);
 
     return 0;
 }