]> granicus.if.org Git - libvpx/commitdiff
Merge "Fix race condition in wiener_var_rd_mult"
authorAngie Chiang <angiebird@google.com>
Mon, 18 Mar 2019 19:39:04 +0000 (19:39 +0000)
committerGerrit Code Review <noreply-gerritcodereview@google.com>
Mon, 18 Mar 2019 19:39:04 +0000 (19:39 +0000)
1  2 
vp9/encoder/vp9_encodeframe.c

index 17d57f9afeb3760a724249c10e3525db6f24d698,047b06b532aa969e7d47e9486f7ffe8989c71e0d..d0ebbae8d297fe5b5baafe1f7da004aebcf1197a
@@@ -3595,9 -3595,15 +3595,15 @@@ static int wiener_var_rdmult(VP9_COMP *
      for (col = mb_col_start; col < mb_col_end; ++col)
        wiener_variance += cpi->mb_wiener_variance[row * cm->mb_cols + col];
  
+ #if CONFIG_MULTITHREAD
+   pthread_mutex_lock(&cpi->kmeans_mutex);
+ #endif  // CONFIG_MULTITHREAD
    kmeans_data = &cpi->kmeans_data_arr[cpi->kmeans_data_size++];
 -  kmeans_data->value = log(1 + wiener_variance);
 +  kmeans_data->value = log(1.0 + wiener_variance) / log(2.0);
    kmeans_data->pos = mi_row * cpi->kmeans_data_stride + mi_col;
+ #if CONFIG_MULTITHREAD
+   pthread_mutex_unlock(&cpi->kmeans_mutex);
+ #endif  // CONFIG_MULTITHREAD
    if (wiener_variance)
      wiener_variance /=
          (mb_row_end - mb_row_start) * (mb_col_end - mb_col_start);