Commit d326f763 authored by Yue Chen's avatar Yue Chen

Remove and refactor code in rdopt.c

Change-Id: Ie35949c803a39717162d2a304d58f68dbcfc1f45
parent f0305584
......@@ -6907,6 +6907,7 @@ static int64_t handle_inter_mode(
uint8_t *tmp_buf;
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
MOTION_MODE motion_mode;
int allow_motvar =
#if CONFIG_EXT_INTER
!is_comp_interintra_pred &&
......@@ -6918,7 +6919,7 @@ static int64_t handle_inter_mode(
uint8_t best_blk_skip[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE * 4];
#endif // CONFIG_VAR_TX
int64_t best_rd = INT64_MAX;
MB_MODE_INFO best_mbmi;
MB_MODE_INFO base_mbmi, best_mbmi;
#if CONFIG_EXT_INTER
int rate2_bmc_nocoeff;
int rate_mv_bmc;
......@@ -7685,37 +7686,25 @@ static int64_t handle_inter_mode(
if (cm->interp_filter == SWITCHABLE) rd_stats->rate += rs;
#if CONFIG_MOTION_VAR
rate2_nocoeff = rd_stats->rate;
base_mbmi = *mbmi;
#endif // CONFIG_MOTION_VAR
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
best_rd = INT64_MAX;
for (mbmi->motion_mode = SIMPLE_TRANSLATION;
mbmi->motion_mode < (allow_motvar ? MOTION_MODES : 1);
mbmi->motion_mode++) {
int64_t tmp_rd = INT64_MAX;
for (motion_mode = SIMPLE_TRANSLATION;
motion_mode < (allow_motvar ? MOTION_MODES : 1); motion_mode++) {
int64_t tmp_rd = INT64_MAX, tmp_dist;
int tmp_rate;
#if CONFIG_EXT_INTER
int tmp_rate2 = mbmi->motion_mode != SIMPLE_TRANSLATION ? rate2_bmc_nocoeff
: rate2_nocoeff;
int tmp_rate2 =
motion_mode != SIMPLE_TRANSLATION ? rate2_bmc_nocoeff : rate2_nocoeff;
#else
int tmp_rate2 = rate2_nocoeff;
#endif // CONFIG_EXT_INTER
#if CONFIG_EXT_INTERP
#if CONFIG_DUAL_FILTER
InterpFilter obmc_interp_filter[2][2] = {
{ mbmi->interp_filter[0], mbmi->interp_filter[1] }, // obmc == 0
{ mbmi->interp_filter[0], mbmi->interp_filter[1] } // obmc == 1
};
#else
InterpFilter obmc_interp_filter[2] = {
mbmi->interp_filter, // obmc == 0
mbmi->interp_filter // obmc == 1
};
#endif // CONFIG_DUAL_FILTER
#endif // CONFIG_EXT_INTERP
*mbmi = base_mbmi;
mbmi->motion_mode = motion_mode;
#if CONFIG_MOTION_VAR
int tmp_rate;
int64_t tmp_dist;
if (mbmi->motion_mode == OBMC_CAUSAL) {
#if CONFIG_EXT_INTER
*mbmi = best_bmc_mbmi;
......@@ -7742,12 +7731,11 @@ static int64_t handle_inter_mode(
#if CONFIG_EXT_INTERP
#if CONFIG_DUAL_FILTER
if (!has_subpel_mv_component(xd->mi[0], xd, 0))
obmc_interp_filter[1][0] = mbmi->interp_filter[0] = EIGHTTAP_REGULAR;
mbmi->interp_filter[0] = EIGHTTAP_REGULAR;
if (!has_subpel_mv_component(xd->mi[0], xd, 1))
obmc_interp_filter[1][1] = mbmi->interp_filter[1] = EIGHTTAP_REGULAR;
mbmi->interp_filter[1] = EIGHTTAP_REGULAR;
#else
if (!av1_is_interp_needed(xd))
obmc_interp_filter[1] = mbmi->interp_filter = EIGHTTAP_REGULAR;
if (!av1_is_interp_needed(xd)) mbmi->interp_filter = EIGHTTAP_REGULAR;
#endif // CONFIG_DUAL_FILTER
// This is not quite correct with CONFIG_DUAL_FILTER when a filter
// is needed in only one direction
......@@ -7909,14 +7897,6 @@ static int64_t handle_inter_mode(
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
tmp_rd = RDCOST(x->rdmult, x->rddiv, rd_stats->rate, rd_stats->dist);
if (mbmi->motion_mode == SIMPLE_TRANSLATION || (tmp_rd < best_rd)) {
#if CONFIG_EXT_INTERP
#if CONFIG_DUAL_FILTER
mbmi->interp_filter[0] = obmc_interp_filter[mbmi->motion_mode][0];
mbmi->interp_filter[1] = obmc_interp_filter[mbmi->motion_mode][1];
#else
mbmi->interp_filter = obmc_interp_filter[mbmi->motion_mode];
#endif // CONFIG_DUAL_FILTER
#endif // CONFIG_EXT_INTERP
best_mbmi = *mbmi;
best_rd = tmp_rd;
best_rd_stats = *rd_stats;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment