Fix Tsan errors This patch fixed 2 reported Tsan errors while running VP9 real-time encoder. Change-Id: Ib0278fe802852862c3ce87c4a500e544d7089f67
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 367ab3c..e59d2c2 100644 --- 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,25 +479,41 @@ // 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; } } } +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); } } @@ -3854,6 +3869,9 @@ } 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); }
diff --git a/vp9/encoder/vp9_encodeframe.h b/vp9/encoder/vp9_encodeframe.h index 1027130..1acde02 100644 --- 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"
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 82f99b3..59788eb 100644 --- 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);
diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 0ad3249..416f679 100644 --- 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;