shithub: dav1d

Download patch

ref: d2d79ed7f0b319b2e9c2e495d5b4dff9bd94ec8a
parent: c6788ed5ee9401962b820be30e1b91d47a923daa
author: Henrik Gramner <[email protected]>
date: Tue Oct 2 16:14:43 EDT 2018

Remove dav1d_init()

Perform the library initialization as part of dav1d_open() instead.

--- a/include/dav1d/dav1d.h
+++ b/include/dav1d/dav1d.h
@@ -40,11 +40,6 @@
     int n_tile_threads;
 } Dav1dSettings;
 
-/*
- * Init the library.
- */
-DAV1D_API void dav1d_init(void);
-
 /**
  * Get library version.
  */
--- a/src/lib.c
+++ b/src/lib.c
@@ -50,12 +50,6 @@
     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) {
     return DAV1D_VERSION;
 }
@@ -68,6 +62,9 @@
 int dav1d_open(Dav1dContext **const c_out,
                const Dav1dSettings *const s)
 {
+    static pthread_once_t initted = PTHREAD_ONCE_INIT;
+    pthread_once(&initted, init_internal);
+
     validate_input_or_ret(c_out != NULL, -EINVAL);
     validate_input_or_ret(s != NULL, -EINVAL);
     validate_input_or_ret(s->n_tile_threads >= 1 &&
--- a/src/qm.c
+++ b/src/qm.c
@@ -3105,7 +3105,7 @@
 }
 
 void av1_init_qm_tables(void) {
-    // This function is guaranteed to be called only once by dav1d_init
+    // This function is guaranteed to be called only once
 
     for (int i = 0; i < 15; i++)
         for (int j = 0; j < 2; j++) {
--- a/src/wedge.c
+++ b/src/wedge.c
@@ -223,7 +223,7 @@
 }
 
 void av1_init_wedge_masks(void) {
-    // This function is guaranteed to be called only once by dav1d_init
+    // This function is guaranteed to be called only once
 
     enum WedgeMasterLineType {
         WEDGE_MASTER_LINE_ODD,
@@ -322,7 +322,7 @@
 }
 
 void av1_init_interintra_masks(void) {
-    // This function is guaranteed to be called only once by dav1d_init
+    // This function is guaranteed to be called only once
 
     memset(ii_dc_mask, 32, 32 * 32);
 #define set(a) a[II_VERT_PRED - 1], a[II_HOR_PRED - 1], a[II_SMOOTH_PRED - 1]
--- a/tools/dav1d.c
+++ b/tools/dav1d.c
@@ -78,7 +78,6 @@
         return -1;
     }
 
-    dav1d_init();
     init_demuxers();
     init_muxers();
     parse(argc, argv, &cli_settings, &lib_settings);