]> granicus.if.org Git - libx264/commitdiff
Fix integer overflow in 2-pass VBV
authorFiona Glaser <fiona@x264.com>
Sat, 19 Sep 2009 16:50:59 +0000 (09:50 -0700)
committerFiona Glaser <fiona@x264.com>
Mon, 21 Sep 2009 06:01:00 +0000 (23:01 -0700)
Bug caused slight undersizing in 2-pass mode in some cases.

encoder/ratecontrol.c

index c6b9f6d2281ed61671be555d892f5acdeaf4dba3..72d3c37219f2ebf7082ed0592745d8db06f4e861 100644 (file)
@@ -1936,7 +1936,7 @@ static int vbv_pass2( x264_t *h )
             adj_max = fix_underflow(h, t0, t1, 1.001, qscale_min, qscale_max);
 
         expected_bits = count_expected_bits(h);
-    } while((expected_bits < .995*all_available_bits) && ((int)(expected_bits+.5) > (int)(prev_bits+.5)) );
+    } while((expected_bits < .995*all_available_bits) && ((int64_t)(expected_bits+.5) > (int64_t)(prev_bits+.5)) );
 
     if (!adj_max)
         x264_log( h, X264_LOG_WARNING, "vbv-maxrate issue, qpmax or vbv-maxrate too low\n");