shithub: libvpx

Download patch

ref: 63c5bf2b9cc024bf324ef9b149d4cc5876e7d329
parent: 004b9d83e37d355f590a6976a27b7b845d19a869
author: Yunqing Wang <[email protected]>
date: Wed Apr 15 06:49:07 EDT 2015

Fix Tsan errors

This patch fixed 2 reported Tsan errors while running VP9 real-time
encoder.

Change-Id: Ib0278fe802852862c3ce87c4a500e544d7089f67

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -458,8 +458,7 @@
   return 0;
 }
 
-
-void vp9_set_vbp_thresholds(VP9_COMP *cpi, int64_t thresholds[], int q) {
+void vp9_set_vbp_thresholds(VP9_COMP *cpi, int q) {
   SPEED_FEATURES *const sf = &cpi->sf;
   if (sf->partition_search_type != VAR_BASED_PARTITION &&
       sf->partition_search_type != REFERENCE_PARTITION) {
@@ -480,19 +479,19 @@
     // Array index: 0 - threshold_64x64; 1 - threshold_32x32;
     // 2 - threshold_16x16; 3 - vbp_threshold_8x8;
     if (is_key_frame) {
-      thresholds[0] = threshold_base;
-      thresholds[1] = threshold_base >> 2;
-      thresholds[2] = threshold_base >> 2;
-      thresholds[3] = threshold_base << 2;
+      cpi->vbp_thresholds[0] = threshold_base;
+      cpi->vbp_thresholds[1] = threshold_base >> 2;
+      cpi->vbp_thresholds[2] = threshold_base >> 2;
+      cpi->vbp_thresholds[3] = threshold_base << 2;
       cpi->vbp_bsize_min = BLOCK_8X8;
     } else {
-      thresholds[1] = threshold_base;
+      cpi->vbp_thresholds[1] = threshold_base;
       if (cm->width <= 352 && cm->height <= 288) {
-        thresholds[0] = threshold_base >> 2;
-        thresholds[2] = threshold_base << 3;
+        cpi->vbp_thresholds[0] = threshold_base >> 2;
+        cpi->vbp_thresholds[2] = threshold_base << 3;
       } else {
-        thresholds[0] = threshold_base;
-        thresholds[2] = threshold_base << cpi->oxcf.speed;
+        cpi->vbp_thresholds[0] = threshold_base;
+        cpi->vbp_thresholds[2] = threshold_base << cpi->oxcf.speed;
       }
       cpi->vbp_bsize_min = BLOCK_16X16;
     }
@@ -499,6 +498,22 @@
   }
 }
 
+static void modify_vbp_thresholds(VP9_COMP *cpi, int64_t thresholds[], int q) {
+  VP9_COMMON *const cm = &cpi->common;
+  const int64_t threshold_base = (int64_t)(cpi->y_dequant[q][1]);
+
+  // Array index: 0 - threshold_64x64; 1 - threshold_32x32;
+  // 2 - threshold_16x16; 3 - vbp_threshold_8x8;
+  thresholds[1] = threshold_base;
+  if (cm->width <= 352 && cm->height <= 288) {
+    thresholds[0] = threshold_base >> 2;
+    thresholds[2] = threshold_base << 3;
+  } else {
+    thresholds[0] = threshold_base;
+    thresholds[2] = threshold_base << cpi->oxcf.speed;
+  }
+}
+
 static void fill_variance_4x4avg(const uint8_t *s, int sp, const uint8_t *d,
                                  int dp, int x8_idx, int y8_idx, v8x8 *vst,
 #if CONFIG_VP9_HIGHBITDEPTH
@@ -611,7 +626,7 @@
 
     if (cyclic_refresh_segment_id_boosted(segment_id)) {
       int q = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex);
-      vp9_set_vbp_thresholds(cpi, thresholds, q);
+      modify_vbp_thresholds(cpi, thresholds, q);
     }
   }
 
@@ -3853,6 +3868,9 @@
       p[i].eobs = ctx->eobs_pbuf[i][0];
     }
     vp9_zero(x->zcoeff_blk);
+
+    if (cm->frame_type != KEY_FRAME && cpi->rc.frames_since_golden == 0)
+      cpi->ref_frame_flags &= (~VP9_GOLD_FLAG);
 
     if (sf->partition_search_type == SOURCE_VAR_BASED_PARTITION)
       source_var_based_partition_search_method(cpi);
--- a/vp9/encoder/vp9_encodeframe.h
+++ b/vp9/encoder/vp9_encodeframe.h
@@ -40,7 +40,7 @@
 void vp9_encode_tile(struct VP9_COMP *cpi, struct ThreadData *td,
                      int tile_row, int tile_col);
 
-void vp9_set_vbp_thresholds(struct VP9_COMP *cpi, int64_t thresholds[], int q);
+void vp9_set_vbp_thresholds(struct VP9_COMP *cpi, int q);
 
 #ifdef __cplusplus
 }  // extern "C"
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2958,7 +2958,7 @@
   set_size_dependent_vars(cpi, &q, &bottom_index, &top_index);
 
   vp9_set_quantizer(cm, q);
-  vp9_set_vbp_thresholds(cpi, cpi->vbp_thresholds, q);
+  vp9_set_vbp_thresholds(cpi, q);
 
   setup_frame(cpi);
 
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -1125,7 +1125,6 @@
 #endif
 
   if (cpi->rc.frames_since_golden == 0) {
-    cpi->ref_frame_flags &= (~VP9_GOLD_FLAG);
     usable_ref_frame = LAST_FRAME;
   } else {
     usable_ref_frame = GOLDEN_FRAME;