]> granicus.if.org Git - libvpx/commitdiff
Add mutex initialization in encoder
authorYaowu Xu <yaowu@google.com>
Tue, 3 Feb 2015 17:52:21 +0000 (09:52 -0800)
committerYaowu Xu <yaowu@google.com>
Tue, 3 Feb 2015 17:53:08 +0000 (09:53 -0800)
This resolves the encoder crashes on windows.

Change-Id: I159d79014cf9279751e403936ce1f84482ae82da

vp9/vp9_cx_iface.c

index 312e3f1a6926878a919328520e1f152dab2f2cf5..251d2400ba7fe483bc28c16a2472b2df4cffa870 100644 (file)
@@ -743,6 +743,12 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx,
     if (priv->buffer_pool == NULL)
       return VPX_CODEC_MEM_ERROR;
 
+#if CONFIG_MULTITHREAD
+    if (pthread_mutex_init(&priv->buffer_pool->pool_mutex, NULL)) {
+      return VPX_CODEC_MEM_ERROR;
+    }
+#endif
+
     if (ctx->config.enc) {
       // Update the reference to the config structure to an internal copy.
       priv->cfg = *ctx->config.enc;
@@ -774,6 +780,9 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx,
 static vpx_codec_err_t encoder_destroy(vpx_codec_alg_priv_t *ctx) {
   free(ctx->cx_data);
   vp9_remove_compressor(ctx->cpi);
+#if CONFIG_MULTITHREAD
+  pthread_mutex_destroy(&ctx->buffer_pool->pool_mutex);
+#endif
   vpx_free(ctx->buffer_pool);
   vpx_free(ctx);
   return VPX_CODEC_OK;