Fix comp interinter and interintra mode cost in EXT_INTER + REF_MV
Performance gain using baseline with ref_mv on is improved from
1.781% to 1.846%
Change-Id: I5a4bfdfcde25fa5c81e6999e20033ee4af993185
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 29da9e4..08e4969 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -9332,19 +9332,31 @@
}
#if CONFIG_REF_MV
- // TODO(jingning): This needs some refactoring to improve code quality
- // and reduce redundant steps.
+// TODO(jingning): This needs some refactoring to improve code quality
+// and reduce redundant steps.
+#if CONFIG_EXT_INTER
+ if (((mbmi->mode == NEARMV || mbmi->mode == NEAR_NEARMV) &&
+ mbmi_ext->ref_mv_count[ref_frame_type] > 2) ||
+ ((mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV) &&
+ mbmi_ext->ref_mv_count[ref_frame_type] > 1)) {
+#else
if ((mbmi->mode == NEARMV &&
mbmi_ext->ref_mv_count[ref_frame_type] > 2) ||
(mbmi->mode == NEWMV && mbmi_ext->ref_mv_count[ref_frame_type] > 1)) {
+#endif // CONFIG_EXT_INTER
int_mv backup_mv = frame_mv[NEARMV][ref_frame];
MB_MODE_INFO backup_mbmi = *mbmi;
int backup_skip = x->skip;
int64_t tmp_ref_rd = this_rd;
int ref_idx;
- // TODO(jingning): This should be deprecated shortly.
+// TODO(jingning): This should be deprecated shortly.
+#if CONFIG_EXT_INTER
+ int idx_offset =
+ (mbmi->mode == NEARMV || mbmi->mode == NEAR_NEARMV) ? 1 : 0;
+#else
int idx_offset = (mbmi->mode == NEARMV) ? 1 : 0;
+#endif
int ref_set =
AOMMIN(2, mbmi_ext->ref_mv_count[ref_frame_type] - 1 - idx_offset);
@@ -9383,6 +9395,10 @@
int ref;
int_mv cur_mv;
RD_STATS tmp_rd_stats, tmp_rd_stats_y, tmp_rd_stats_uv;
+#if CONFIG_EXT_INTER
+ int tmp_compmode_interintra_cost = 0;
+ int tmp_compmode_interinter_cost = 0;
+#endif // CONFIG_EXT_INTER
av1_invalid_rd_stats(&tmp_rd_stats);
@@ -9413,8 +9429,6 @@
{ { 0 } } };
int dummy_single_newmvs_rate[2][TOTAL_REFS_PER_FRAME] = { { 0 },
{ 0 } };
- int dummy_compmode_interintra_cost = 0;
- int dummy_compmode_interinter_cost = 0;
#else
int_mv dummy_single_newmv[TOTAL_REFS_PER_FRAME] = { { 0 } };
#endif
@@ -9429,8 +9443,8 @@
#endif // CONFIG_MOTION_VAR
#if CONFIG_EXT_INTER
dummy_single_newmvs, dummy_single_newmvs_rate,
- &dummy_compmode_interintra_cost,
- &dummy_compmode_interinter_cost, NULL,
+ &tmp_compmode_interintra_cost, &tmp_compmode_interinter_cost,
+ NULL,
#else
dummy_single_newmv,
#endif
@@ -9498,6 +9512,10 @@
memcpy(x->blk_skip_drl[i], x->blk_skip[i],
sizeof(uint8_t) * ctx->num_4x4_blk);
#endif
+#if CONFIG_EXT_INTER
+ compmode_interintra_cost = tmp_compmode_interintra_cost;
+ compmode_interinter_cost = tmp_compmode_interinter_cost;
+#endif
} else {
*mbmi = backup_mbmi;
x->skip = backup_skip;