diff mbox series

[FFmpeg-devel,181/191] avcodec/h261: Make ff_h261_common_init() thread-safe

Message ID 20201123193739.1249300-19-andreas.rheinhardt@gmail.com
State Superseded
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. 23, 2020, 7:37 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/h261.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h261.c b/libavcodec/h261.c
index 47bad4e57f..9c848eb7e8 100644
--- a/libavcodec/h261.c
+++ b/libavcodec/h261.c
@@ -25,6 +25,8 @@ 
  * H.261 codec
  */
 
+#include "libavutil/thread.h"
+
 #include "avcodec.h"
 #include "h261.h"
 
@@ -80,13 +82,13 @@  void ff_h261_loop_filter(MpegEncContext *s)
     h261_loop_filter(dest_cr, uvlinesize);
 }
 
-av_cold void ff_h261_common_init(void)
+static av_cold void h261_common_init(void)
 {
-    static int done = 0;
-
-    if (done)
-        return;
-
     ff_rl_init(&ff_h261_rl_tcoeff, ff_h261_rl_table_store);
-    done = 1;
+}
+
+av_cold void ff_h261_common_init(void)
+{
+    static AVOnce init_static_once = AV_ONCE_INIT;
+    ff_thread_once(&init_static_once, h261_common_init);
 }