Skip alike starting MVs at speed 1
Combined the MV checking conditions, and refactored the code. Chose a
conservative mv_diff threshold for speed 1.
Borg test results(speed 1, 150 frames):
avg_psnr: ovr_psnr: ssim: avg speedups over whole set:
lowres: -0.000 -0.005 0.067 1.0%
midres: 0.008 0.006 0.095 2.0%
ugc360p: 0.024 0.036 0.089 2.3%
STATS_CHANGED
Change-Id: I1c6a3c900a07f6aea402d62f3be32dc2be5e9a53
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 8cb1972..84d97bf 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -375,6 +375,7 @@
sf->lpf_sf.dual_sgr_penalty_level = 1;
sf->lpf_sf.enable_sgr_ep_pruning = 1;
+ // TODO(any, yunqing): move this feature to speed 0.
sf->tpl_sf.skip_alike_starting_mv = 1;
}
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 11aa2da..c5f490e 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -175,34 +175,17 @@
return bestsme;
}
-static int is_duplicate_mv(int_mv candidate_mv, int_mv *center_mvs,
- int center_mvs_count, int skip_alike_starting_mv) {
- int_mv candidate_mv_full; /* full-pixel value */
- static int mv_shift_lookup[3] = { 0, 3, 3 };
- int shift = mv_shift_lookup[skip_alike_starting_mv];
+static int is_alike_mv(int_mv candidate_mv, int_mv *center_mvs,
+ int center_mvs_count, int skip_alike_starting_mv) {
+ // MV difference threshold is in 1/8 precision.
+ const int mv_diff_thr[3] = { 1, (8 << 3), (16 << 3) };
+ int thr = mv_diff_thr[skip_alike_starting_mv];
int i;
- candidate_mv_full.as_mv.col = (candidate_mv.as_mv.col >> shift);
- candidate_mv_full.as_mv.row = (candidate_mv.as_mv.row >> shift);
-
for (i = 0; i < center_mvs_count; i++) {
- int_mv center_mv_full;
- center_mv_full.as_mv.col = (center_mvs[i].as_mv.col >> shift);
- center_mv_full.as_mv.row = (center_mvs[i].as_mv.row >> shift);
-
- if (candidate_mv_full.as_int == center_mv_full.as_int) {
+ if (abs(center_mvs[i].as_mv.col - candidate_mv.as_mv.col) < thr &&
+ abs(center_mvs[i].as_mv.row - candidate_mv.as_mv.row) < thr)
return 1;
- }
-
- // TODO(yunqing): will combine this part with the above checking.
- if (skip_alike_starting_mv == 2) {
- const int mv_diff_thr = 16;
- if (abs(center_mv_full.as_mv.col - candidate_mv_full.as_mv.col) <
- mv_diff_thr &&
- abs(center_mv_full.as_mv.row - candidate_mv_full.as_mv.row) <
- mv_diff_thr)
- return 1;
- }
}
return 0;
@@ -335,8 +318,8 @@
if (xd->up_available) {
TplDepStats *ref_tpl_stats = &tpl_frame->tpl_stats_ptr[av1_tpl_ptr_pos(
cpi, mi_row - mi_height, mi_col, tpl_frame->stride)];
- if (!is_duplicate_mv(ref_tpl_stats->mv[rf_idx], center_mvs, refmv_count,
- cpi->sf.tpl_sf.skip_alike_starting_mv)) {
+ if (!is_alike_mv(ref_tpl_stats->mv[rf_idx], center_mvs, refmv_count,
+ cpi->sf.tpl_sf.skip_alike_starting_mv)) {
center_mvs[refmv_count].as_int = ref_tpl_stats->mv[rf_idx].as_int;
++refmv_count;
}
@@ -345,8 +328,8 @@
if (xd->left_available) {
TplDepStats *ref_tpl_stats = &tpl_frame->tpl_stats_ptr[av1_tpl_ptr_pos(
cpi, mi_row, mi_col - mi_width, tpl_frame->stride)];
- if (!is_duplicate_mv(ref_tpl_stats->mv[rf_idx], center_mvs, refmv_count,
- cpi->sf.tpl_sf.skip_alike_starting_mv)) {
+ if (!is_alike_mv(ref_tpl_stats->mv[rf_idx], center_mvs, refmv_count,
+ cpi->sf.tpl_sf.skip_alike_starting_mv)) {
center_mvs[refmv_count].as_int = ref_tpl_stats->mv[rf_idx].as_int;
++refmv_count;
}
@@ -355,8 +338,8 @@
if (xd->up_available && mi_col + mi_width < xd->tile.mi_col_end) {
TplDepStats *ref_tpl_stats = &tpl_frame->tpl_stats_ptr[av1_tpl_ptr_pos(
cpi, mi_row - mi_height, mi_col + mi_width, tpl_frame->stride)];
- if (!is_duplicate_mv(ref_tpl_stats->mv[rf_idx], center_mvs, refmv_count,
- cpi->sf.tpl_sf.skip_alike_starting_mv)) {
+ if (!is_alike_mv(ref_tpl_stats->mv[rf_idx], center_mvs, refmv_count,
+ cpi->sf.tpl_sf.skip_alike_starting_mv)) {
center_mvs[refmv_count].as_int = ref_tpl_stats->mv[rf_idx].as_int;
++refmv_count;
}