]> granicus.if.org Git - libvpx/commitdiff
Fix rate control bug with recode all.
authorPaul Wilkins <paulwilkins@google.com>
Thu, 6 Sep 2018 14:56:01 +0000 (15:56 +0100)
committerJingning Han <jingning@google.com>
Sat, 8 Sep 2018 02:45:08 +0000 (02:45 +0000)
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

vp9/encoder/vp9_encoder.c

index 1fd4a036a5647ce428b985355524dcb471979834..ed84674438ef758ffc4f5f3c6252212096665eab 100644 (file)
@@ -4342,8 +4342,9 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size,
           // 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 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size,
 #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) {