Don't directly use best quality for a special case
Don't directly use active_best_quality for these special cases:
- If we are encoding a single frame (image encoding), OR
- If we are encoding consecutive keyframes.
Before this fix, in these special cases, encoding wasn't able to achieve
bitrates lower than that achieved by active_best_quality.
Change-Id: I09b144fe91ca3582a8deb16ac95ce57d243c06e4
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 74bd4a3..eca6911 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -1168,7 +1168,8 @@
if (oxcf->rc_mode == AOM_Q ||
(frame_is_intra_only(cm) && !rc->this_key_frame_forced &&
- cpi->twopass.kf_zeromotion_pct >= STATIC_KF_GROUP_THRESH)) {
+ cpi->twopass.kf_zeromotion_pct >= STATIC_KF_GROUP_THRESH &&
+ rc->frames_to_key > 1)) {
q = active_best_quality;
// Special case code to try and match quality with forced key frames.
} else if (frame_is_intra_only(cm) && rc->this_key_frame_forced) {
diff --git a/test/horz_superres_test.cc b/test/horz_superres_test.cc
index 14483ef..f2c2115 100644
--- a/test/horz_superres_test.cc
+++ b/test/horz_superres_test.cc
@@ -45,7 +45,7 @@
{ "park_joy_90p_10_444.y4m", AOM_IMG_FMT_I44416, AOM_BITS_10, 1, 5, 0, 28.0 },
{ "screendata.y4m", AOM_IMG_FMT_I420, AOM_BITS_8, 0, 4, 1, 20.0 },
// Image coding (single frame).
- { "niklas_1280_720_30.y4m", AOM_IMG_FMT_I420, AOM_BITS_8, 0, 1, 0, 39.0 },
+ { "niklas_1280_720_30.y4m", AOM_IMG_FMT_I420, AOM_BITS_8, 0, 1, 0, 32.0 },
};
// Modes with extra params have their own tests.