shithub: dav1d

Download patch

ref: afac3d3f8ede5646256b6e374b69839aca0fb485
parent: a6853a944892d370b3969e97fdcdacd5a3718034
author: Derek Buitenhuis <derek.buitenhuis@gmail.com>
date: Sat Sep 22 10:43:31 EDT 2018

API: Run dav1d_init under pthread_once

This makes the function thread safe, to call, for example,
from multiple transient dependecies or threads.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>

--- a/src/lib.c
+++ b/src/lib.c
@@ -45,10 +45,16 @@
 #include "src/thread_task.h"
 #include "src/wedge.h"
 
-void dav1d_init(void) {
+static void init_internal(void) {
     av1_init_wedge_masks();
     av1_init_interintra_masks();
     av1_init_qm_tables();
+}
+
+static pthread_once_t initted = PTHREAD_ONCE_INIT;
+
+void dav1d_init(void) {
+    pthread_once(&initted, init_internal);
 }
 
 const char *dav1d_version(void) {