From: Paul Wilkins Date: Mon, 3 Sep 2018 15:48:02 +0000 (+0100) Subject: Fix short first kf bug. X-Git-Tag: v1.8.0~356^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f46c31844b9162557e12de73352075f6b8d9379;p=libvpx Fix short first kf bug. This change is in response to quality issue in b/112953058 The quality regression observed is a result of a bug that manifested because of a very short key frame group at the start of a chunk. The group was so short that it was less than the minimum allowed length of an ARF group, so the initial group was coded as a GF only group. However, group length was not set correctly and the result was a frame coded with a target of 0 bits. This causes two problems: Firstly one very poor frame that caused the issue to be raised. Secondly that one frame obviously overshoots its 0 target very heavily and this has the effect moving the needle significantly in terms of the adaptive rate control (specifically the estimate of bits per macro block used to estimate the active Q range). Consequently there is undershoot for most of the rest of the chunk and the overall rate ends up much lower than the target (14Mb/s vs a target of 22Mb/s). (The sharp drop in the overall rate is also noted in the issue. BUG=b/112953058 Change-Id: Ide9cce57acd3dee0f9496b752902e7b4735f2c7f --- diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 38e1d37cc..70953be9b 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -3002,11 +3002,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { rc->gfu_boost = VPXMIN((int)rc->gfu_boost, i * 200); #endif - rc->baseline_gf_interval = - ((twopass->kf_zeromotion_pct >= STATIC_KF_GROUP_THRESH) && - (i >= rc->frames_to_key)) - ? i - : (i - (is_key_frame || rc->source_alt_ref_pending)); + rc->baseline_gf_interval = i - rc->source_alt_ref_pending; // TODO(zoeliu): Turn on the option to disable extra ALTREFs for still GF // groups.