Commit 19e7aa82 authored by Yue Chen's avatar Yue Chen Committed by Debargha Mukherjee

Remove interp filter for non-translation global mv

BDRATE results:
lowres: -0.880% (up from -0.844%)

Change-Id: I017c0beddcc687148fed33c1e9963e05f1eaf6ea
parent ad67d795
...@@ -1100,6 +1100,46 @@ static INLINE void av1_get_block_dimensions(BLOCK_SIZE bsize, int plane, ...@@ -1100,6 +1100,46 @@ static INLINE void av1_get_block_dimensions(BLOCK_SIZE bsize, int plane,
if (cols_within_bounds) *cols_within_bounds = block_cols >> pd->subsampling_x; if (cols_within_bounds) *cols_within_bounds = block_cols >> pd->subsampling_x;
} }
#if CONFIG_GLOBAL_MOTION
static INLINE int is_nontrans_global_motion(const MACROBLOCKD *xd) {
const MODE_INFO *mi = xd->mi[0];
const MB_MODE_INFO *const mbmi = &mi->mbmi;
int ref;
#if CONFIG_CB4X4
const int unify_bsize = 1;
#else
const int unify_bsize = 0;
#endif
// First check if all modes are ZEROMV
if (mbmi->sb_type >= BLOCK_8X8 || unify_bsize) {
#if CONFIG_EXT_INTER
if (mbmi->mode != ZEROMV && mbmi->mode != ZERO_ZEROMV) return 0;
#else
if (mbmi->mode != ZEROMV) return 0;
#endif // CONFIG_EXT_INTER
} else {
#if CONFIG_EXT_INTER
if (mi->bmi[0].as_mode != ZEROMV || mi->bmi[1].as_mode != ZEROMV ||
mi->bmi[2].as_mode != ZEROMV || mi->bmi[3].as_mode != ZEROMV ||
mi->bmi[0].as_mode != ZERO_ZEROMV ||
mi->bmi[1].as_mode != ZERO_ZEROMV ||
mi->bmi[2].as_mode != ZERO_ZEROMV || mi->bmi[3].as_mode != ZERO_ZEROMV)
return 0;
#else
if (mi->bmi[0].as_mode != ZEROMV || mi->bmi[1].as_mode != ZEROMV ||
mi->bmi[2].as_mode != ZEROMV || mi->bmi[3].as_mode != ZEROMV)
return 0;
#endif // CONFIG_EXT_INTER
}
// Now check if all global motion is non translational
for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) {
if (xd->global_motion[mbmi->ref_frame[ref]].wmtype <= TRANSLATION) return 0;
}
return 1;
}
#endif // CONFIG_GLOBAL_MOTION
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
......
...@@ -1458,6 +1458,7 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, ...@@ -1458,6 +1458,7 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
MB_MODE_INFO *mbmi; MB_MODE_INFO *mbmi;
mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis); mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
#if CONFIG_DELTA_Q #if CONFIG_DELTA_Q
if (cm->delta_q_present_flag) { if (cm->delta_q_present_flag) {
int i; int i;
......
...@@ -1115,11 +1115,29 @@ static INLINE void read_mb_interp_filter(AV1_COMMON *const cm, ...@@ -1115,11 +1115,29 @@ static INLINE void read_mb_interp_filter(AV1_COMMON *const cm,
FRAME_CONTEXT *ec_ctx = cm->fc; FRAME_CONTEXT *ec_ctx = cm->fc;
#endif #endif
#if CONFIG_GLOBAL_MOTION
if (is_nontrans_global_motion(xd)) {
#if CONFIG_DUAL_FILTER
mbmi->interp_filter[0] =
cm->interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR : cm->interp_filter;
mbmi->interp_filter[1] =
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
return;
}
#endif // CONFIG_GLOBAL_MOTION
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
int dir;
if (cm->interp_filter != SWITCHABLE) { if (cm->interp_filter != SWITCHABLE) {
int dir;
for (dir = 0; dir < 4; ++dir) mbmi->interp_filter[dir] = cm->interp_filter; for (dir = 0; dir < 4; ++dir) mbmi->interp_filter[dir] = cm->interp_filter;
} else { } else {
int dir;
for (dir = 0; dir < 2; ++dir) { for (dir = 0; dir < 2; ++dir) {
const int ctx = av1_get_pred_context_switchable_interp(xd, dir); const int ctx = av1_get_pred_context_switchable_interp(xd, dir);
mbmi->interp_filter[dir] = EIGHTTAP_REGULAR; mbmi->interp_filter[dir] = EIGHTTAP_REGULAR;
...@@ -1708,7 +1726,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, ...@@ -1708,7 +1726,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
} }
#endif #endif
#if !CONFIG_DUAL_FILTER && !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 #endif // !CONFIG_DUAL_FILTER && !CONFIG_WARPED_MOTION
...@@ -1951,7 +1969,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, ...@@ -1951,7 +1969,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#if CONFIG_WARPED_MOTION #if CONFIG_WARPED_MOTION
if (mbmi->motion_mode != WARPED_CAUSAL) { if (mbmi->motion_mode != WARPED_CAUSAL) {
#endif // CONFIG_WARPED_MOTION #endif // CONFIG_WARPED_MOTION
#if CONFIG_DUAL_FILTER || 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 #endif // CONFIG_DUAL_FILTER || CONFIG_WARPED_MOTION
#if CONFIG_WARPED_MOTION #if CONFIG_WARPED_MOTION
......
...@@ -1148,6 +1148,9 @@ static void write_mb_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd, ...@@ -1148,6 +1148,9 @@ static void write_mb_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd,
FRAME_CONTEXT *ec_ctx = cm->fc; FRAME_CONTEXT *ec_ctx = cm->fc;
#endif #endif
#if CONFIG_GLOBAL_MOTION
if (is_nontrans_global_motion(xd)) return;
#endif // CONFIG_GLOBAL_MOTION
if (cm->interp_filter == SWITCHABLE) { if (cm->interp_filter == SWITCHABLE) {
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
int dir; int dir;
...@@ -1518,7 +1521,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi, ...@@ -1518,7 +1521,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
} }
} }
#if !CONFIG_DUAL_FILTER && !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_FILTER && !CONFIG_WARPED_MOTION #endif // !CONFIG_DUAL_FILTER && !CONFIG_WARPED_MOTION
...@@ -1715,7 +1718,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi, ...@@ -1715,7 +1718,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
#if CONFIG_WARPED_MOTION #if CONFIG_WARPED_MOTION
if (mbmi->motion_mode != WARPED_CAUSAL) if (mbmi->motion_mode != WARPED_CAUSAL)
#endif // CONFIG_WARPED_MOTION #endif // CONFIG_WARPED_MOTION
#if CONFIG_DUAL_FILTER || 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 #endif // CONFIG_DUAL_FILTE || CONFIG_WARPED_MOTION
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "av1/encoder/corner_detect.h" #include "av1/encoder/corner_detect.h"
// Fast_9 wrapper // Fast_9 wrapper
#define FAST_BARRIER 20 #define FAST_BARRIER 18
int fast_corner_detect(unsigned char *buf, int width, int height, int stride, int fast_corner_detect(unsigned char *buf, int width, int height, int stride,
int *points, int max_points) { int *points, int max_points) {
int num_points; int num_points;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define SEARCH_SZ 9 #define SEARCH_SZ 9
#define SEARCH_SZ_BY2 ((SEARCH_SZ - 1) / 2) #define SEARCH_SZ_BY2 ((SEARCH_SZ - 1) / 2)
#define THRESHOLD_NCC 0.80 #define THRESHOLD_NCC 0.75
static double compute_variance(unsigned char *im, int stride, int x, int y, static double compute_variance(unsigned char *im, int stride, int x, int y,
double *mean) { double *mean) {
......
...@@ -1200,7 +1200,10 @@ static void update_state(const AV1_COMP *const cpi, ThreadData *td, ...@@ -1200,7 +1200,10 @@ static void update_state(const AV1_COMP *const cpi, ThreadData *td,
#if CONFIG_WARPED_MOTION #if CONFIG_WARPED_MOTION
&& mbmi->motion_mode != WARPED_CAUSAL && mbmi->motion_mode != WARPED_CAUSAL
#endif // CONFIG_WARPED_MOTION #endif // CONFIG_WARPED_MOTION
) { #if CONFIG_GLOBAL_MOTION
&& !is_nontrans_global_motion(xd)
#endif // CONFIG_GLOBAL_MOTION
) {
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
update_filter_type_count(td->counts, xd, mbmi); update_filter_type_count(td->counts, xd, mbmi);
#else #else
...@@ -1377,6 +1380,9 @@ static void update_state_supertx(const AV1_COMP *const cpi, ThreadData *td, ...@@ -1377,6 +1380,9 @@ static void update_state_supertx(const AV1_COMP *const cpi, ThreadData *td,
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
&& av1_is_interp_needed(xd) && av1_is_interp_needed(xd)
#endif #endif
#if CONFIG_GLOBAL_MOTION
&& !is_nontrans_global_motion(xd)
#endif // CONFIG_GLOBAL_MOTION
) { ) {
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
update_filter_type_count(td->counts, xd, mbmi); update_filter_type_count(td->counts, xd, mbmi);
......
...@@ -8893,6 +8893,7 @@ static int64_t handle_inter_mode( ...@@ -8893,6 +8893,7 @@ static int64_t handle_inter_mode(
if (!is_comp_pred && mbmi->motion_mode == SIMPLE_TRANSLATION) if (!is_comp_pred && mbmi->motion_mode == SIMPLE_TRANSLATION)
single_skippable[this_mode][refs[0]] = rd_stats->skip; single_skippable[this_mode][refs[0]] = rd_stats->skip;
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION #endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if CONFIG_GLOBAL_MOTION #if CONFIG_GLOBAL_MOTION
if (this_mode == ZEROMV if (this_mode == ZEROMV
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
...@@ -8902,6 +8903,21 @@ static int64_t handle_inter_mode( ...@@ -8902,6 +8903,21 @@ static int64_t handle_inter_mode(
rd_stats->rate += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[0]); rd_stats->rate += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[0]);
if (is_comp_pred) if (is_comp_pred)
rd_stats->rate += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[1]); rd_stats->rate += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[1]);
if (is_nontrans_global_motion(xd)) {
rd_stats->rate -= rs;
#if CONFIG_DUAL_FILTER
mbmi->interp_filter[0] = cm->interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: cm->interp_filter;
mbmi->interp_filter[1] = 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_GLOBAL_MOTION #endif // CONFIG_GLOBAL_MOTION
...@@ -11046,6 +11062,30 @@ PALETTE_EXIT: ...@@ -11046,6 +11062,30 @@ PALETTE_EXIT:
*mbmi = best_mbmode; *mbmi = best_mbmode;
x->skip |= best_skip2; x->skip |= best_skip2;
// Note: this section is needed since the mode may have been forced to
// ZEROMV by the all-zero mode handling of ref-mv.
#if CONFIG_GLOBAL_MOTION
if (mbmi->mode == ZEROMV
#if CONFIG_EXT_INTER
|| mbmi->mode == ZERO_ZEROMV
#endif // CONFIG_EXT_INTER
) {
if (is_nontrans_global_motion(xd)) {
#if CONFIG_DUAL_FILTER
mbmi->interp_filter[0] = cm->interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: cm->interp_filter;
mbmi->interp_filter[1] = 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_GLOBAL_MOTION
#if CONFIG_REF_MV #if CONFIG_REF_MV
for (i = 0; i < 1 + has_second_ref(mbmi); ++i) { for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
if (mbmi->mode != NEWMV) if (mbmi->mode != NEWMV)
...@@ -11978,6 +12018,29 @@ void av1_rd_pick_inter_mode_sub8x8(const struct AV1_COMP *cpi, ...@@ -11978,6 +12018,29 @@ void av1_rd_pick_inter_mode_sub8x8(const struct AV1_COMP *cpi,
mbmi->mv[1].as_int = xd->mi[0]->bmi[3].as_mv[1].as_int; mbmi->mv[1].as_int = xd->mi[0]->bmi[3].as_mv[1].as_int;
} }
// Note: this section is needed since the mode may have been forced to ZEROMV
#if CONFIG_GLOBAL_MOTION
if (mbmi->mode == ZEROMV
#if CONFIG_EXT_INTER
|| mbmi->mode == ZERO_ZEROMV
#endif // CONFIG_EXT_INTER
) {
if (is_nontrans_global_motion(xd)) {
#if CONFIG_DUAL_FILTER
mbmi->interp_filter[0] = cm->interp_filter == SWITCHABLE
? EIGHTTAP_REGULAR
: cm->interp_filter;
mbmi->interp_filter[1] = 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_GLOBAL_MOTION
for (i = 0; i < REFERENCE_MODES; ++i) { for (i = 0; i < REFERENCE_MODES; ++i) {
if (best_pred_rd[i] == INT64_MAX) if (best_pred_rd[i] == INT64_MAX)
best_pred_diff[i] = INT_MIN; best_pred_diff[i] = INT_MIN;
......
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