Adjust kf_boost based on tpl stats
Small to medium improvements depending on sequence
and length of sequence.
BDRATE (end_usage=q, cpu_used=0):
AWCY Objective-1 Fast: -0.40%
lowres (33 frames): -0.089%
midres (33 frames): -0.025%
lowres (50 frames): -0.265%
midres (50 frames): -0.006%
lowres (65 frames): +0.012%
midres (65 frames): -0.075%
lowres (80 frames): -0.060%
midres (80 frames): -0.062%
STATS_CHANGED
Change-Id: Ie49ca00b356404795304540ed15ee3a3c239805a
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index e60be29..73f3138 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3587,6 +3587,14 @@
return boost;
}
+static int get_kf_boost_from_r0(double r0, int frames_to_key) {
+ double factor = sqrt((double)frames_to_key);
+ factor = AOMMIN(factor, 10.0);
+ factor = AOMMAX(factor, 4.0);
+ int boost = (int)rint((75.0 + 14.0 * factor) / r0);
+ return boost;
+}
+
static void process_tpl_stats_frame(AV1_COMP *cpi) {
const GF_GROUP *const gf_group = &cpi->gf_group;
AV1_COMMON *const cm = &cpi->common;
@@ -3623,8 +3631,14 @@
cpi->rd.arf_r0 = cpi->rd.r0;
const int gfu_boost = get_gfu_boost_from_r0(cpi->rd.arf_r0);
// printf("old boost %d new boost %d\n", cpi->rc.gfu_boost,
- // gfu_boost);
+ // gfu_boost);
cpi->rc.gfu_boost = (cpi->rc.gfu_boost + gfu_boost) / 2;
+ } else if (frame_is_intra_only(cm)) {
+ const int kf_boost =
+ get_kf_boost_from_r0(cpi->rd.r0, cpi->rc.frames_to_key);
+ // printf("old kf boost %d new kf boost %d [%d]\n", cpi->rc.kf_boost,
+ // kf_boost, cpi->rc.frames_to_key);
+ cpi->rc.kf_boost = (cpi->rc.kf_boost + kf_boost) / 2;
}
cpi->rd.mc_count_base =
(double)mc_count_base / (cm->mi_rows * cm->mi_cols);