Commit 0df711f2 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Fix and cleanup interpolation filter assignments

BUG=aomedia:490
BUG=aomedia:491
BUG=aomedia:494

Change-Id: I20a375dc6f76a3f3de520e452b3b9b0d4ace0ee0
parent 8f37b162
......@@ -686,7 +686,33 @@ static INLINE int has_subpel_mv_component(const MODE_INFO *const mi,
#endif
}
static INLINE void set_default_interp_filters(
MB_MODE_INFO *const mbmi, InterpFilter frame_interp_filter) {
#if CONFIG_DUAL_FILTER
int dir;
for (dir = 0; dir < 4; ++dir)
mbmi->interp_filter[dir] = frame_interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: frame_interp_filter;
#else
mbmi->interp_filter = frame_interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR
: frame_interp_filter;
#endif // CONFIG_DUAL_FILTER
}
static INLINE int av1_is_interp_needed(const MACROBLOCKD *const xd) {
(void)xd;
#if CONFIG_WARPED_MOTION
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
if (mbmi->motion_mode == WARPED_CAUSAL) return 0;
#endif // CONFIG_WARPED_MOTION
#if CONFIG_GLOBAL_MOTION
if (is_nontrans_global_motion(xd)) return 0;
#endif // CONFIG_GLOBAL_MOTION
return 1;
}
static INLINE int av1_is_interp_search_needed(const MACROBLOCKD *const xd) {
MODE_INFO *const mi = xd->mi[0];
const int is_compound = has_second_ref(&mi->mbmi);
int ref;
......
......@@ -1336,21 +1336,10 @@ static INLINE void read_mb_interp_filter(AV1_COMMON *const cm,
FRAME_CONTEXT *ec_ctx = cm->fc;
#endif
#if CONFIG_GLOBAL_MOTION
if (is_nontrans_global_motion(xd)) {
#if CONFIG_DUAL_FILTER
int dir;
for (dir = 0; dir < 4; ++dir)
mbmi->interp_filter[dir] = cm->interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: cm->interp_filter;
#else
mbmi->interp_filter =
cm->interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR : cm->interp_filter;
#endif // CONFIG_DUAL_FILTER
if (!av1_is_interp_needed(xd)) {
set_default_interp_filters(mbmi, cm->interp_filter);
return;
}
#endif // CONFIG_GLOBAL_MOTION
#if CONFIG_DUAL_FILTER
if (cm->interp_filter != SWITCHABLE) {
......@@ -2190,9 +2179,11 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#if CONFIG_WARPED_MOTION
if (mbmi->motion_mode == WARPED_CAUSAL) {
mbmi->wm_params[0].wmtype = DEFAULT_WMTYPE;
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);
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)) {
assert(0 && "Invalid Warped Model.");
}
}
#endif // CONFIG_WARPED_MOTION
#if CONFIG_SUPERTX
......@@ -2234,26 +2225,9 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
}
#endif // CONFIG_EXT_INTER
#if CONFIG_WARPED_MOTION
if (mbmi->motion_mode != WARPED_CAUSAL) {
#endif // CONFIG_WARPED_MOTION
#if CONFIG_DUAL_FILTER || CONFIG_WARPED_MOTION || CONFIG_GLOBAL_MOTION
read_mb_interp_filter(cm, xd, mbmi, r);
read_mb_interp_filter(cm, xd, mbmi, r);
#endif // CONFIG_DUAL_FILTER || CONFIG_WARPED_MOTION
#if CONFIG_WARPED_MOTION
} else {
#if CONFIG_DUAL_FILTER
int dir;
for (dir = 0; dir < 4; ++dir)
mbmi->interp_filter[dir] = cm->interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: cm->interp_filter;
#else
mbmi->interp_filter =
cm->interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR : cm->interp_filter;
#endif // CONFIG_DUAL_FILTER
}
#endif // CONFIG_WARPED_MOTION
}
static void read_inter_frame_mode_info(AV1Decoder *const pbi,
......
......@@ -1388,9 +1388,19 @@ static void write_mb_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd,
FRAME_CONTEXT *ec_ctx = cm->fc;
#endif
#if CONFIG_GLOBAL_MOTION
if (is_nontrans_global_motion(xd)) return;
#endif // CONFIG_GLOBAL_MOTION
if (!av1_is_interp_needed(xd)) {
#if CONFIG_DUAL_FILTER
for (int i = 0; i < 4; ++i)
assert(mbmi->interp_filter[i] == (cm->interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: cm->interp_filter));
#else
assert(mbmi->interp_filter == (cm->interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: cm->interp_filter));
#endif // CONFIG_DUAL_FILTER
return;
}
if (cm->interp_filter == SWITCHABLE) {
#if CONFIG_DUAL_FILTER
int dir;
......@@ -2090,11 +2100,8 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
}
#endif // CONFIG_EXT_INTER
#if CONFIG_WARPED_MOTION
if (mbmi->motion_mode != WARPED_CAUSAL)
#endif // CONFIG_WARPED_MOTION
#if CONFIG_DUAL_FILTER || CONFIG_WARPED_MOTION || CONFIG_GLOBAL_MOTION
write_mb_interp_filter(cpi, xd, w);
write_mb_interp_filter(cpi, xd, w);
#endif // CONFIG_DUAL_FILTE || CONFIG_WARPED_MOTION
}
......
......@@ -7974,26 +7974,17 @@ int64_t interpolation_filter_search(
if (cm->interp_filter == SWITCHABLE) {
#if !CONFIG_DUAL_FILTER
assign_filter =
predict_interp_filter(cpi, x, bsize, mi_row, mi_col, single_filter);
assign_filter = av1_is_interp_needed(xd)
? predict_interp_filter(cpi, x, bsize, mi_row, mi_col,
single_filter)
: cm->interp_filter;
#endif // !CONFIG_DUAL_FILTER
} else {
assign_filter = cm->interp_filter;
}
#if CONFIG_DUAL_FILTER
mbmi->interp_filter[0] =
assign_filter == SWITCHABLE ? EIGHTTAP_REGULAR : assign_filter;
mbmi->interp_filter[1] =
assign_filter == SWITCHABLE ? EIGHTTAP_REGULAR : assign_filter;
mbmi->interp_filter[2] =
assign_filter == SWITCHABLE ? EIGHTTAP_REGULAR : assign_filter;
mbmi->interp_filter[3] =
assign_filter == SWITCHABLE ? EIGHTTAP_REGULAR : assign_filter;
#else
mbmi->interp_filter =
assign_filter == SWITCHABLE ? EIGHTTAP_REGULAR : assign_filter;
#endif // CONFIG_DUAL_FILTER
set_default_interp_filters(mbmi, assign_filter);
*switchable_rate = av1_get_switchable_rate(cpi, xd);
av1_build_inter_predictors_sb(xd, mi_row, mi_col, orig_dst, bsize);
model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate, &tmp_dist,
......@@ -8002,7 +7993,7 @@ int64_t interpolation_filter_search(
if (assign_filter == SWITCHABLE) {
// do interp_filter search
if (av1_is_interp_needed(xd)) {
if (av1_is_interp_needed(xd) && av1_is_interp_search_needed(xd)) {
#if CONFIG_DUAL_FILTER
const int filter_set_size = DUAL_FILTER_SET_SIZE;
#else
......@@ -10175,16 +10166,9 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
#endif // CONFIG_FILTER_INTRA
// Evaluate all sub-pel filters irrespective of whether we can use
// them for this frame.
#if CONFIG_DUAL_FILTER
for (i = 0; i < 4; ++i) {
mbmi->interp_filter[i] = cm->interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: cm->interp_filter;
}
#else
mbmi->interp_filter =
cm->interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR : cm->interp_filter;
#endif // CONFIG_DUAL_FILTER
set_default_interp_filters(mbmi, cm->interp_filter);
mbmi->mv[0].as_int = mbmi->mv[1].as_int = 0;
mbmi->motion_mode = SIMPLE_TRANSLATION;
......@@ -11532,9 +11516,13 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
}
#endif
if (cm->interp_filter != BILINEAR) {
set_default_interp_filters(mbmi, cm->interp_filter);
if (cm->interp_filter != SWITCHABLE) {
best_filter = cm->interp_filter;
} else {
best_filter = EIGHTTAP_REGULAR;
if (cm->interp_filter == SWITCHABLE &&
if (av1_is_interp_needed(xd) && av1_is_interp_search_needed(xd) &&
x->source_variance >= cpi->sf.disable_filter_search_var_thresh) {
int rs;
int best_rs = INT_MAX;
......@@ -11557,21 +11545,13 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
}
}
}
// Set the appropriate filter
if (cm->interp_filter == SWITCHABLE) {
// Set the appropriate filter
#if CONFIG_DUAL_FILTER
for (i = 0; i < 4; ++i) mbmi->interp_filter[i] = best_filter;
for (i = 0; i < 4; ++i) mbmi->interp_filter[i] = best_filter;
#else
mbmi->interp_filter = best_filter;
mbmi->interp_filter = best_filter;
#endif // CONFIG_DUAL_FILTER
rate2 += av1_get_switchable_rate(cpi, xd);
} else {
#if CONFIG_DUAL_FILTER
for (i = 0; i < 4; ++i) mbmi->interp_filter[i] = cm->interp_filter;
#else
mbmi->interp_filter = cm->interp_filter;
#endif // CONFIG_DUAL_FILTER
}
rate2 += av1_get_switchable_rate(cpi, xd);
if (cm->reference_mode == REFERENCE_MODE_SELECT)
rate2 += av1_cost_bit(comp_mode_p, comp_pred);
......
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