shithub: libvpx

Download patch

ref: b32ba09d3568492229da222740c0e18afc3f0094
parent: 1c69be6e757d856298a427414b7e98d402557dd9
parent: cd6093081495b89d6c55b84ff3ef02fee19f85fc
author: James Zern <jzern@google.com>
date: Thu Dec 18 13:48:30 EST 2014

Merge "make vp9 encoder static initializers thread safe"

--- a/vp9/common/vp9_rtcd.c
+++ b/vp9/common/vp9_rtcd.c
@@ -16,5 +16,7 @@
 
 void vp9_rtcd() {
     vpx_scale_rtcd();
+    // TODO(JBB): Remove this once, by insuring that both the encoder and
+    // decoder setup functions are protected by once();
     once(setup_rtcd_internal);
 }
--- a/vp9/decoder/vp9_decoder.c
+++ b/vp9/decoder/vp9_decoder.c
@@ -15,6 +15,7 @@
 #include "./vpx_scale_rtcd.h"
 
 #include "vpx_mem/vpx_mem.h"
+#include "vpx_ports/vpx_once.h"
 #include "vpx_ports/vpx_timer.h"
 #include "vpx_scale/vpx_scale.h"
 
@@ -34,7 +35,7 @@
 #include "vp9/decoder/vp9_dthread.h"
 
 static void initialize_dec() {
-  static int init_done = 0;
+  static volatile int init_done = 0;
 
   if (!init_done) {
     vp9_rtcd();
@@ -85,7 +86,7 @@
                   sizeof(*cm->frame_contexts)));
 
   pbi->need_resync = 1;
-  initialize_dec();
+  once(initialize_dec);
 
   // Initialize the references to not point to any frame buffers.
   vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -182,7 +182,7 @@
 }
 
 void vp9_initialize_enc() {
-  static int init_done = 0;
+  static volatile int init_done = 0;
 
   if (!init_done) {
     vp9_rtcd();
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -13,6 +13,7 @@
 
 #include "./vpx_config.h"
 #include "vpx/vpx_codec.h"
+#include "vpx_ports/vpx_once.h"
 #include "vpx/internal/vpx_codec_internal.h"
 #include "./vpx_version.h"
 #include "vp9/encoder/vp9_encoder.h"
@@ -729,7 +730,7 @@
     }
 
     priv->extra_cfg = default_extra_cfg;
-    vp9_initialize_enc();
+    once(vp9_initialize_enc);
 
     res = validate_config(priv, &priv->cfg, &priv->extra_cfg);