Remove ext-warped-motion part2
Part2 of ext-warped-motion experiment was removed.
Change-Id: I1b7aebad1fd7cb60d92c3ce959d5101228addae2
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 3756f44..c7713d8 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -7644,39 +7644,6 @@
}
#endif
-#if CONFIG_EXT_WARPED_MOTION
-static int handle_zero_mv(const AV1_COMMON *const cm, MACROBLOCK *const x,
- BLOCK_SIZE bsize, int mi_col, int mi_row) {
- MACROBLOCKD *xd = &x->e_mbd;
- MODE_INFO *mi = xd->mi[0];
- MB_MODE_INFO *mbmi = &mi->mbmi;
- int skip = 0;
-
- // Handle the special case of 0 MV.
- if (mbmi->ref_frame[0] > INTRA_FRAME && mbmi->ref_frame[1] <= INTRA_FRAME) {
- int8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
- int16_t mode_ctx = x->mbmi_ext->mode_context[ref_frame_type];
- if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) {
- int_mv zeromv;
- const MV_REFERENCE_FRAME ref = mbmi->ref_frame[0];
- zeromv.as_int = gm_get_motion_vector(&cm->global_motion[ref],
- cm->allow_high_precision_mv, bsize,
- mi_col, mi_row
-#if CONFIG_AMVR
- ,
- cm->cur_frame_force_integer_mv
-#endif
- )
- .as_int;
- if (mbmi->mv[0].as_int == zeromv.as_int && mbmi->mode != GLOBALMV) {
- skip = 1;
- }
- }
- }
- return skip;
-}
-#endif // CONFIG_EXT_WARPED_MOTION
-
// TODO(afergs): Refactor the MBMI references in here - there's four
// TODO(afergs): Refactor optional args - add them to a struct or remove
static int64_t motion_mode_rd(
@@ -7713,9 +7680,8 @@
#if CONFIG_EXT_WARPED_MOTION
int pts0[SAMPLES_ARRAY_SIZE], pts_inref0[SAMPLES_ARRAY_SIZE];
- int pts_mv0[SAMPLES_ARRAY_SIZE], pts_wm[SAMPLES_ARRAY_SIZE];
+ int pts_mv0[SAMPLES_ARRAY_SIZE];
int total_samples;
- int best_cand = -1;
#else
int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
#endif // CONFIG_EXT_WARPED_MOTION
@@ -7726,22 +7692,8 @@
aom_clear_system_state();
#if CONFIG_EXT_WARPED_MOTION
mbmi->num_proj_ref[0] =
- findSamples(cm, xd, mi_row, mi_col, pts0, pts_inref0, pts_mv0, pts_wm);
+ findSamples(cm, xd, mi_row, mi_col, pts0, pts_inref0, pts_mv0);
total_samples = mbmi->num_proj_ref[0];
-
- // Find a warped neighbor.
- int cand;
- int best_weight = 0;
-
- // if (this_mode == NEARESTMV)
- for (cand = 0; cand < mbmi->num_proj_ref[0]; cand++) {
- if (pts_wm[cand * 2 + 1] > best_weight) {
- best_weight = pts_wm[cand * 2 + 1];
- best_cand = cand;
- }
- }
- mbmi->wm_ctx = best_cand;
- best_bmc_mbmi->wm_ctx = mbmi->wm_ctx;
#else
mbmi->num_proj_ref[0] = findSamples(cm, xd, mi_row, mi_col, pts, pts_inref);
#endif // CONFIG_EXT_WARPED_MOTION
@@ -7800,97 +7752,77 @@
av1_unswitchable_filter(cm->interp_filter));
#if CONFIG_EXT_WARPED_MOTION
- if (this_mode == NEARESTMV && best_cand != -1) {
- MODE_INFO *best_mi = xd->mi[pts_wm[2 * best_cand]];
- assert(best_mi->mbmi.motion_mode == WARPED_CAUSAL);
- mbmi->wm_params[0] = best_mi->mbmi.wm_params[0];
-
- // Handle the special case of 0 MV.
- if (handle_zero_mv(cm, x, bsize, mi_col, mi_row)) continue;
-
- av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, NULL, bsize);
- model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate,
- &tmp_dist, skip_txfm_sb, skip_sse_sb);
- } else {
- memcpy(pts, pts0, total_samples * 2 * sizeof(*pts0));
- memcpy(pts_inref, pts_inref0, total_samples * 2 * sizeof(*pts_inref0));
- // Rank the samples by motion vector difference
- if (mbmi->num_proj_ref[0] > 1) {
- mbmi->num_proj_ref[0] = sortSamples(pts_mv0, &mbmi->mv[0].as_mv, pts,
- pts_inref, mbmi->num_proj_ref[0]);
- best_bmc_mbmi->num_proj_ref[0] = mbmi->num_proj_ref[0];
- }
+ memcpy(pts, pts0, total_samples * 2 * sizeof(*pts0));
+ memcpy(pts_inref, pts_inref0, total_samples * 2 * sizeof(*pts_inref0));
+ // Rank the samples by motion vector difference
+ if (mbmi->num_proj_ref[0] > 1) {
+ mbmi->num_proj_ref[0] = sortSamples(pts_mv0, &mbmi->mv[0].as_mv, pts,
+ pts_inref, mbmi->num_proj_ref[0]);
+ best_bmc_mbmi->num_proj_ref[0] = mbmi->num_proj_ref[0];
+ }
#endif // CONFIG_EXT_WARPED_MOTION
- if (!find_projection(mbmi->num_proj_ref[0], pts, pts_inref, bsize,
- mbmi->mv[0].as_mv.row, mbmi->mv[0].as_mv.col,
- &mbmi->wm_params[0], mi_row, mi_col)) {
- // Refine MV for NEWMV mode
- if (!is_comp_pred && have_newmv_in_inter_mode(this_mode)) {
- int tmp_rate_mv = 0;
- const int_mv mv0 = mbmi->mv[0];
- const WarpedMotionParams wm_params0 = mbmi->wm_params[0];
+ if (!find_projection(mbmi->num_proj_ref[0], pts, pts_inref, bsize,
+ mbmi->mv[0].as_mv.row, mbmi->mv[0].as_mv.col,
+ &mbmi->wm_params[0], mi_row, mi_col)) {
+ // Refine MV for NEWMV mode
+ if (!is_comp_pred && have_newmv_in_inter_mode(this_mode)) {
+ int tmp_rate_mv = 0;
+ const int_mv mv0 = mbmi->mv[0];
+ const WarpedMotionParams wm_params0 = mbmi->wm_params[0];
#if CONFIG_EXT_WARPED_MOTION
- int num_proj_ref0 = mbmi->num_proj_ref[0];
+ int num_proj_ref0 = mbmi->num_proj_ref[0];
- // Refine MV in a small range.
- av1_refine_warped_mv(cpi, x, bsize, mi_row, mi_col, pts0,
- pts_inref0, pts_mv0, total_samples);
+ // Refine MV in a small range.
+ av1_refine_warped_mv(cpi, x, bsize, mi_row, mi_col, pts0, pts_inref0,
+ pts_mv0, total_samples);
#else
// Refine MV in a small range.
av1_refine_warped_mv(cpi, x, bsize, mi_row, mi_col, pts, pts_inref);
#endif // CONFIG_EXT_WARPED_MOTION
- // Keep the refined MV and WM parameters.
- if (mv0.as_int != mbmi->mv[0].as_int) {
- const int ref = refs[0];
- const MV ref_mv = x->mbmi_ext->ref_mvs[ref][0].as_mv;
+ // Keep the refined MV and WM parameters.
+ if (mv0.as_int != mbmi->mv[0].as_int) {
+ const int ref = refs[0];
+ const MV ref_mv = x->mbmi_ext->ref_mvs[ref][0].as_mv;
- tmp_rate_mv =
- av1_mv_bit_cost(&mbmi->mv[0].as_mv, &ref_mv, x->nmvjointcost,
- x->mvcost, MV_COST_WEIGHT);
+ tmp_rate_mv =
+ av1_mv_bit_cost(&mbmi->mv[0].as_mv, &ref_mv, x->nmvjointcost,
+ x->mvcost, MV_COST_WEIGHT);
- if (cpi->sf.adaptive_motion_search)
- x->pred_mv[ref] = mbmi->mv[0].as_mv;
+ if (cpi->sf.adaptive_motion_search)
+ x->pred_mv[ref] = mbmi->mv[0].as_mv;
- single_newmv[ref] = mbmi->mv[0];
+ single_newmv[ref] = mbmi->mv[0];
- if (discount_newmv_test(cpi, this_mode, mbmi->mv[0], mode_mv,
- refs[0])) {
- tmp_rate_mv = AOMMAX((tmp_rate_mv / NEW_MV_DISCOUNT_FACTOR), 1);
- }
-#if CONFIG_EXT_WARPED_MOTION
- best_bmc_mbmi->num_proj_ref[0] = mbmi->num_proj_ref[0];
-#endif // CONFIG_EXT_WARPED_MOTION
- tmp_rate2 = rate2_bmc_nocoeff - rate_mv_bmc + tmp_rate_mv;
-#if CONFIG_DUAL_FILTER
- mbmi->interp_filters =
- condition_interp_filters_on_mv(mbmi->interp_filters, xd);
-#endif // CONFIG_DUAL_FILTER
- } else {
- // Restore the old MV and WM parameters.
- mbmi->mv[0] = mv0;
- mbmi->wm_params[0] = wm_params0;
-#if CONFIG_EXT_WARPED_MOTION
- mbmi->num_proj_ref[0] = num_proj_ref0;
-#endif // CONFIG_EXT_WARPED_MOTION
+ if (discount_newmv_test(cpi, this_mode, mbmi->mv[0], mode_mv,
+ refs[0])) {
+ tmp_rate_mv = AOMMAX((tmp_rate_mv / NEW_MV_DISCOUNT_FACTOR), 1);
}
+#if CONFIG_EXT_WARPED_MOTION
+ best_bmc_mbmi->num_proj_ref[0] = mbmi->num_proj_ref[0];
+#endif // CONFIG_EXT_WARPED_MOTION
+ tmp_rate2 = rate2_bmc_nocoeff - rate_mv_bmc + tmp_rate_mv;
+#if CONFIG_DUAL_FILTER
+ mbmi->interp_filters =
+ condition_interp_filters_on_mv(mbmi->interp_filters, xd);
+#endif // CONFIG_DUAL_FILTER
+ } else {
+ // Restore the old MV and WM parameters.
+ mbmi->mv[0] = mv0;
+ mbmi->wm_params[0] = wm_params0;
+#if CONFIG_EXT_WARPED_MOTION
+ mbmi->num_proj_ref[0] = num_proj_ref0;
+#endif // CONFIG_EXT_WARPED_MOTION
}
-
-#if CONFIG_EXT_WARPED_MOTION
- // Handle the special case of 0 MV.
- if (handle_zero_mv(cm, x, bsize, mi_col, mi_row)) continue;
-#endif // CONFIG_EXT_WARPED_MOTION
-
- av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, NULL, bsize);
- model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate,
- &tmp_dist, skip_txfm_sb, skip_sse_sb);
- } else {
- continue;
}
-#if CONFIG_EXT_WARPED_MOTION
+
+ av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, NULL, bsize);
+ model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate,
+ &tmp_dist, skip_txfm_sb, skip_sse_sb);
+ } else {
+ continue;
}
-#endif // CONFIG_EXT_WARPED_MOTION
}
x->skip = 0;
@@ -7900,17 +7832,7 @@
rd_stats->rate = tmp_rate2;
if (last_motion_mode_allowed > SIMPLE_TRANSLATION) {
if (last_motion_mode_allowed == WARPED_CAUSAL) {
-#if CONFIG_EXT_WARPED_MOTION
- int wm_ctx = 0;
- if (mbmi->wm_ctx != -1) {
- wm_ctx = 1;
- if (mbmi->mode == NEARESTMV) wm_ctx = 2;
- }
-
- rd_stats->rate += x->motion_mode_cost[wm_ctx][bsize][mbmi->motion_mode];
-#else
rd_stats->rate += x->motion_mode_cost[bsize][mbmi->motion_mode];
-#endif // CONFIG_EXT_WARPED_MOTION
} else {
rd_stats->rate += x->motion_mode_cost1[bsize][mbmi->motion_mode];
}
@@ -10738,11 +10660,7 @@
// Therefore, sometimes, NEWMV is chosen instead of NEARESTMV, NEARMV, and
// GLOBALMV. Here, checks are added for those cases, and the mode decisions
// are corrected.
- if ((best_mbmode.mode == NEWMV || best_mbmode.mode == NEW_NEWMV)
-#if CONFIG_EXT_WARPED_MOTION
- && best_mbmode.motion_mode != WARPED_CAUSAL
-#endif // CONFIG_EXT_WARPED_MOTION
- ) {
+ if (best_mbmode.mode == NEWMV || best_mbmode.mode == NEW_NEWMV) {
const MV_REFERENCE_FRAME refs[2] = { best_mbmode.ref_frame[0],
best_mbmode.ref_frame[1] };
int comp_pred_mode = refs[1] > INTRA_FRAME;
@@ -10842,9 +10760,6 @@
if (best_mbmode.ref_frame[0] > INTRA_FRAME &&
best_mbmode.ref_frame[1] <= INTRA_FRAME
-#if CONFIG_EXT_WARPED_MOTION
- && best_mbmode.motion_mode != WARPED_CAUSAL
-#endif // CONFIG_EXT_WARPED_MOTION
#if CONFIG_EXT_SKIP
&& !best_mbmode.skip_mode
#endif // CONFIG_EXT_SKIP
@@ -11009,9 +10924,9 @@
if (is_motion_variation_allowed_bsize(bsize) && !has_second_ref(mbmi)) {
int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
#if CONFIG_EXT_WARPED_MOTION
- int pts_mv[SAMPLES_ARRAY_SIZE], pts_wm[SAMPLES_ARRAY_SIZE];
+ int pts_mv[SAMPLES_ARRAY_SIZE];
mbmi->num_proj_ref[0] =
- findSamples(cm, xd, mi_row, mi_col, pts, pts_inref, pts_mv, pts_wm);
+ findSamples(cm, xd, mi_row, mi_col, pts, pts_inref, pts_mv);
// Rank the samples by motion vector difference
if (mbmi->num_proj_ref[0] > 1)
mbmi->num_proj_ref[0] = sortSamples(pts_mv, &mbmi->mv[0].as_mv, pts,