]> git.sesse.net Git - x264/commitdiff
Hack around a potential failure point in VBV
authorFiona Glaser <fiona@x264.com>
Wed, 28 Jan 2009 07:27:56 +0000 (23:27 -0800)
committerFiona Glaser <fiona@x264.com>
Wed, 28 Jan 2009 07:27:56 +0000 (23:27 -0800)
pred_b_from_p can become absurdly large in static scenes, leading to rare collapses of quality with VBV+B-frames+threads.
This isn't a final fix, but should resolve the problem in most cases in the meantime.

encoder/ratecontrol.c

index 96b67de660121205f23b4e8e2d30a05143bb8c6a..c0a4bd769d6a21d5aa4d3e9568c35aac621f477d 100644 (file)
@@ -1147,6 +1147,10 @@ void x264_ratecontrol_end( x264_t *h, int bits )
             {
                 update_predictor( rc->pred_b_from_p, qp2qscale(rc->qpa_rc),
                                   h->fref1[h->i_ref1-1]->i_satd, rc->bframe_bits / rc->bframes );
+                /* In some cases, such as completely blank scenes, pred_b_from_p can go nuts */
+                /* Hackily cap the predictor coeff in case this happens. */
+                /* FIXME FIXME FIXME */
+                rc->pred_b_from_p->coeff = X264_MIN( rc->pred_b_from_p->coeff, 10. );
                 rc->bframe_bits = 0;
             }
         }