rtc: Smooth increase of partition thresholds For speed 9, where force_large_partition_blocks is used: make the increase of partition thresholds increase lineraly across the Q threshold. This is to avoid sudden big change in thresholds when Q changes by +/-1 at thresholds avg. bdrate gain ~0.6 on rtc set, all clips have some small gain. Some speed change is expected depending on the bitrate/content (i.e., depending on whether the typical Q was below/above the threshold). Change-Id: I29c0ecc843e53419f9254c934a84d1021e6a0aa8
diff --git a/av1/encoder/var_based_part.c b/av1/encoder/var_based_part.c index 0f78d7e..106b071 100644 --- a/av1/encoder/var_based_part.c +++ b/av1/encoder/var_based_part.c
@@ -436,6 +436,15 @@ thresholds[2] = (5 * threshold_base) >> 1; } if (cpi->sf.rt_sf.force_large_partition_blocks) { + double weight; + const int win = 20; + if (current_qindex < QINDEX_LARGE_BLOCK_THR - win) + weight = 1.0; + else if (current_qindex > QINDEX_LARGE_BLOCK_THR + win) + weight = 0.0; + else + weight = + 1.0 - (current_qindex - QINDEX_LARGE_BLOCK_THR + win) / (2 * win); if (cm->width * cm->height <= 352 * 288) { thresholds[1] <<= 2; thresholds[2] <<= 5; @@ -450,13 +459,17 @@ thresholds[0] = (3 * thresholds[0]) >> 1; thresholds[3] = INT32_MAX; if (current_qindex > QINDEX_LARGE_BLOCK_THR) { - thresholds[1] <<= 1; - thresholds[2] <<= 1; + thresholds[1] = (int)((1 - weight) * (thresholds[1] << 1) + + weight * thresholds[1]); + thresholds[2] = (int)((1 - weight) * (thresholds[2] << 1) + + weight * thresholds[2]); } } 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[1] = + (int)((1 - weight) * (thresholds[1] << 2) + weight * thresholds[1]); + thresholds[2] = + (int)((1 - weight) * (thresholds[2] << 5) + weight * thresholds[2]); thresholds[3] = INT32_MAX; } }