ref: bb58dfade710c94fc78b50a50f76925863873f38
parent: 2d65fc2ce68a1d82680bfc4de4148f5684e02109
author: Paul Wilkins <paulwilkins@google.com>
date: Thu Sep 6 11:56:01 EDT 2018
Fix rate control bug with recode all. This patch fixes a rate control bug that can manifest if the recode loop is activated for all frame types. Specifically things go wrong when the recode loop is used on an overlay frame that has a rate target of 0 bits. The patch prevents adjustment of the active worst quality and repeat recode loops for overlay frames. The bug showed up during artificial experiments on re-distribution of bits in ARF groups but does not activate in any current encode profile, as even best best quality does not currently allow recodes for all frames. Change-Id: I80872093d9ebd3350106230c42c3928e56ecb754
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -4342,8 +4342,9 @@
// Special case if the projected size is > the max allowed.
if ((q == q_high) &&
((rc->projected_frame_size >= rc->max_frame_bandwidth) ||
- (rc->projected_frame_size >=
- big_rate_miss_high_threshold(cpi)))) {
+ (!rc->is_src_frame_alt_ref &&
+ (rc->projected_frame_size >=
+ big_rate_miss_high_threshold(cpi))))) {
int max_rate = VPXMAX(1, VPXMIN(rc->max_frame_bandwidth,
big_rate_miss_high_threshold(cpi)));
double q_val_high;
@@ -4448,7 +4449,7 @@
#endif
// Have we been forced to adapt Q outside the expected range by an extreme
// rate miss. If so adjust the active maxQ for the subsequent frames.
- if (q > cpi->twopass.active_worst_quality) {
+ if (!rc->is_src_frame_alt_ref && (q > cpi->twopass.active_worst_quality)) {
cpi->twopass.active_worst_quality = q;
} else if (oxcf->vbr_corpus_complexity && q == q_low &&
rc->projected_frame_size < rc->this_frame_target) {