rtc-screen: Improve conditions for better motion search
For screen: increased motion search was set based
on high_num_blocks_motion. This CL changes that and
sets it based on source sad metrics, and updated/added
new metrics in the scene detection.
This makes the increased motion search
setting more aggressive but also more targeted.
Stats for speed 10 screen:
avg_psnr/ovr_psnr/ssim, IC speedup
-2.7/-3.7/-4.1, -1.2%
youtube clip has gains: -9/-12/-11, but 7% IC slowdown
Change-Id: I984d35b09b4a251aa19790eb1b3c621ee0ab9db5
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 33b6b6d..315bae6 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -2761,7 +2761,8 @@
return;
}
rc->high_source_sad = 0;
- rc->high_num_blocks_with_motion = 0;
+ rc->percent_blocks_with_motion = 0;
+ rc->max_block_source_sad = 0;
rc->prev_avg_source_sad = rc->avg_source_sad;
if (src_width == last_src_width && src_height == last_src_height) {
const int num_mi_cols = cm->mi_params.mi_cols;
@@ -2815,6 +2816,8 @@
avg_sad += tmp_sad;
num_samples++;
if (tmp_sad == 0) num_zero_temp_sad++;
+ if (tmp_sad > rc->max_block_source_sad)
+ rc->max_block_source_sad = tmp_sad;
src_y += 64;
last_src_y += 64;
@@ -2840,9 +2843,9 @@
rc->high_source_sad = 0;
rc->avg_source_sad = (3 * rc->avg_source_sad + avg_sad) >> 2;
rc->frame_source_sad = avg_sad;
-
- if (num_zero_temp_sad < (3 * num_samples >> 2))
- rc->high_num_blocks_with_motion = 1;
+ if (num_samples > 0)
+ rc->percent_blocks_with_motion =
+ ((num_samples - num_zero_temp_sad) * 100) / num_samples;
}
cpi->svc.high_source_sad_superframe = rc->high_source_sad;
}
diff --git a/av1/encoder/ratectrl.h b/av1/encoder/ratectrl.h
index 6a678b7..df177b9 100644
--- a/av1/encoder/ratectrl.h
+++ b/av1/encoder/ratectrl.h
@@ -238,7 +238,10 @@
int cnt_zeromv;
// signals if number of blocks with motion is high
- int high_num_blocks_with_motion;
+ int percent_blocks_with_motion;
+
+ // Maximum value of source sad across all blocks of frame.
+ uint64_t max_block_source_sad;
// For dynamic resize, 1 pass cbr.
RESIZE_STATE resize_state;
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index ab3ef83..8c545ff 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -1449,7 +1449,9 @@
sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC_H_V;
}
}
- if (cpi->rc.high_num_blocks_with_motion && speed >= 6) {
+ if (cpi->rc.max_block_source_sad > 20000 &&
+ cpi->rc.frame_source_sad > 100 &&
+ cpi->rc.percent_blocks_with_motion > 1 && speed >= 6) {
sf->mv_sf.search_method = NSTEP;
sf->rt_sf.fullpel_search_step_param = 2;
}