rtc: Adjust logic in force_large_partition_blocks
For speed 9: add content metrics to logic for
increasing the partition thresholds. Avoid the increase
for superblocks that have high sad.
bdrate avg increase of ~1% on rtc_set, with some
clips ~4% and ~2 gain.
Small speed slowdown expected, ~2%.
Change-Id: I2486e1c893fd20f95e517845ec01daefcd88e5e3
diff --git a/av1/encoder/var_based_part.c b/av1/encoder/var_based_part.c
index a42be45..0f78d7e 100644
--- a/av1/encoder/var_based_part.c
+++ b/av1/encoder/var_based_part.c
@@ -341,7 +341,7 @@
static AOM_INLINE void set_vbp_thresholds(AV1_COMP *cpi, int64_t thresholds[],
int q, int content_lowsumdiff,
- int segment_id) {
+ int source_sad, int segment_id) {
AV1_COMMON *const cm = &cpi->common;
const int is_key_frame = frame_is_intra_only(cm);
const int threshold_multiplier = is_key_frame ? 120 : 1;
@@ -440,14 +440,21 @@
thresholds[1] <<= 2;
thresholds[2] <<= 5;
thresholds[3] = INT32_MAX;
- } else if (cm->width * cm->height > 640 * 480 && segment_id == 0) {
+ // Condition the increase of partition thresholds on the segment
+ // and the content. Avoid the increase for superblocks which have
+ // high source sad, unless the whole frame has very high motion
+ // (i.e, cpi->rc.avg_source_sad is very large, in which case all blocks
+ // have high source sad).
+ } else if (cm->width * cm->height > 640 * 480 && segment_id == 0 &&
+ (source_sad != kHighSad || cpi->rc.avg_source_sad > 50000)) {
thresholds[0] = (3 * thresholds[0]) >> 1;
thresholds[3] = INT32_MAX;
- if (current_qindex >= QINDEX_LARGE_BLOCK_THR) {
+ if (current_qindex > QINDEX_LARGE_BLOCK_THR) {
thresholds[1] <<= 1;
thresholds[2] <<= 1;
}
- } else if (current_qindex > QINDEX_LARGE_BLOCK_THR && segment_id == 0) {
+ } else if (current_qindex > QINDEX_LARGE_BLOCK_THR && segment_id == 0 &&
+ (source_sad != kHighSad || cpi->rc.avg_source_sad > 50000)) {
thresholds[1] <<= 2;
thresholds[2] <<= 5;
thresholds[3] = INT32_MAX;
@@ -621,7 +628,8 @@
if (sf->part_sf.partition_search_type != VAR_BASED_PARTITION) {
return;
} else {
- set_vbp_thresholds(cpi, cpi->vbp_info.thresholds, q, content_lowsumdiff, 0);
+ set_vbp_thresholds(cpi, cpi->vbp_info.thresholds, q, content_lowsumdiff, 0,
+ 0);
// The threshold below is not changed locally.
cpi->vbp_info.threshold_minmax = 15 + (q >> 3);
}
@@ -900,10 +908,12 @@
cyclic_refresh_segment_id_boosted(segment_id) &&
cpi->sf.rt_sf.use_nonrd_pick_mode) {
int q = av1_get_qindex(&cm->seg, segment_id, cm->quant_params.base_qindex);
- set_vbp_thresholds(cpi, thresholds, q, x->content_state_sb.low_sumdiff, 1);
+ set_vbp_thresholds(cpi, thresholds, q, x->content_state_sb.low_sumdiff,
+ x->content_state_sb.source_sad, 1);
} else {
set_vbp_thresholds(cpi, thresholds, cm->quant_params.base_qindex,
- x->content_state_sb.low_sumdiff, 0);
+ x->content_state_sb.low_sumdiff,
+ x->content_state_sb.source_sad, 0);
}
// For non keyframes, disable 4x4 average for low resolution when speed = 8