Cleanup variables in cpi
num_winner_motion_modes, max_comp_type_rd_threshold_mul and
max_comp_type_rd_threshold_div are removed from cpi and added
as local variables in functions : av1_rd_pick_inter_mode_sb and
av1_compound_type_rd.
Change-Id: I90610266a5592839e3718cc9e35c5108284c8856
diff --git a/av1/encoder/compound_type.c b/av1/encoder/compound_type.c
index 1469a10..a7e9efc 100644
--- a/av1/encoder/compound_type.c
+++ b/av1/encoder/compound_type.c
@@ -1187,6 +1187,11 @@
return rd;
}
+// scaling values to be used for gating wedge/compound segment based on best
+// approximate rd
+static int comp_type_rd_threshold_mul[3] = { 1, 11, 12 };
+static int comp_type_rd_threshold_div[3] = { 3, 16, 16 };
+
int av1_compound_type_rd(const AV1_COMP *const cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, int_mv *cur_mv, int mode_search_mask,
int masked_compound_used, const BUFFER_SET *orig_dst,
@@ -1436,10 +1441,18 @@
// Handle masked compound types
update_mbmi_for_compound_type(mbmi, cur_type);
rs2 = masked_type_cost[cur_type];
+ // Factors to control gating of compound type selection based on best
+ // approximate rd so far
+ const int max_comp_type_rd_threshold_mul =
+ comp_type_rd_threshold_mul[cpi->sf.inter_sf
+ .prune_comp_type_by_comp_avg];
+ const int max_comp_type_rd_threshold_div =
+ comp_type_rd_threshold_div[cpi->sf.inter_sf
+ .prune_comp_type_by_comp_avg];
// Evaluate COMPOUND_WEDGE / COMPOUND_DIFFWTD if approximated cost is
// within threshold
- int64_t approx_rd = ((*rd / cpi->max_comp_type_rd_threshold_div) *
- cpi->max_comp_type_rd_threshold_mul);
+ int64_t approx_rd = ((*rd / max_comp_type_rd_threshold_div) *
+ max_comp_type_rd_threshold_mul);
if (approx_rd < ref_best_rd) {
const int64_t tmp_rd_thresh = AOMMIN(*rd, rd_thresh);
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index ff45616..2c51e37 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -1029,11 +1029,6 @@
// Mark which ref frames can be skipped for encoding current frame druing RDO.
int prune_ref_frame_mask;
- // Factors to control gating of compound type selection based on best
- // approximate rd so far
- int max_comp_type_rd_threshold_mul;
- int max_comp_type_rd_threshold_div;
-
// Threshold of transform domain distortion
// Index 0: Default mode evaluation, Winner mode processing is not applicable
// (Eg : IntraBc).
@@ -1127,10 +1122,6 @@
int8_t nearest_past_ref;
int8_t nearest_future_ref;
- // Indicates the number of simple translation winner modes for exhaustive
- // motion mode evaluation
- int num_winner_motion_modes;
-
// TODO(sdeng): consider merge the following arrays.
double *tpl_rdmult_scaling_factors;
double *tpl_sb_rdmult_scaling_factors;
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 217bde2..ec10fd7 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -4167,6 +4167,9 @@
}
}
+// Indicates number of winner simple translation modes to be used
+static unsigned int num_winner_motion_modes[3] = { 0, 10, 3 };
+
void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
MACROBLOCK *x, RD_STATS *rd_cost,
const BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
@@ -4204,7 +4207,12 @@
NULL,
{ { { 0 }, { { 0 } }, { 0 }, 0, 0, 0, 0 } },
0 };
- const int max_winner_motion_mode_cand = cpi->num_winner_motion_modes;
+ // Indicates the appropriate number of simple translation winner modes for
+ // exhaustive motion mode evaluation
+ const int max_winner_motion_mode_cand =
+ num_winner_motion_modes[cpi->sf.winner_mode_sf
+ .motion_mode_for_winner_cand];
+ assert(max_winner_motion_mode_cand <= MAX_WINNER_MOTION_MODES);
motion_mode_candidate motion_mode_cand;
motion_mode_best_st_candidate best_motion_mode_cands;
// Initializing the number of motion mode candidates to zero.
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index b1707fa..a268182 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -63,9 +63,6 @@
{ 1, 2, 0 },
{ 2, 2, 0 } };
-// Indicates number of winner simple translation modes to be used
-static unsigned int num_winner_motion_modes[3] = { 0, 10, 3 };
-
// Threshold values to be used for disabling coeff RD-optimization
// based on block MSE
// TODO(any): Experiment the threshold logic based on variance metric
@@ -103,11 +100,6 @@
{ 1, 1, 1 },
{ 1, 2, 1 } };
-// scaling values to be used for gating wedge/compound segment based on best
-// approximate rd
-static int comp_type_rd_threshold_mul[3] = { 1, 11, 12 };
-static int comp_type_rd_threshold_div[3] = { 3, 16, 16 };
-
// Intra only frames, golden frames (except alt ref overlays) and
// alt ref frames tend to be coded at a higher than ambient quality
static int frame_is_boosted(const AV1_COMP *cpi) {
@@ -1230,10 +1222,6 @@
cpi->find_fractional_mv_step = av1_return_max_sub_pixel_mv;
else if (cpi->oxcf.motion_vector_unit_test == 2)
cpi->find_fractional_mv_step = av1_return_min_sub_pixel_mv;
- cpi->max_comp_type_rd_threshold_mul =
- comp_type_rd_threshold_mul[sf->inter_sf.prune_comp_type_by_comp_avg];
- cpi->max_comp_type_rd_threshold_div =
- comp_type_rd_threshold_div[sf->inter_sf.prune_comp_type_by_comp_avg];
// assert ensures that tx_domain_dist_level is accessed correctly
assert(cpi->sf.rd_sf.tx_domain_dist_thres_level >= 0 &&
@@ -1248,12 +1236,6 @@
tx_domain_dist_types[cpi->sf.rd_sf.tx_domain_dist_level],
sizeof(cpi->use_transform_domain_distortion));
- // Update the number of winner motion modes to be used appropriately
- cpi->num_winner_motion_modes =
- num_winner_motion_modes[cpi->sf.winner_mode_sf
- .motion_mode_for_winner_cand];
- assert(cpi->num_winner_motion_modes <= MAX_WINNER_MOTION_MODES);
-
// assert ensures that coeff_opt_dist_thresholds is accessed correctly
assert(cpi->sf.rd_sf.perform_coeff_opt >= 0 &&
cpi->sf.rd_sf.perform_coeff_opt < 5);