shithub: libvpx

Download patch

ref: 5eeabfffcb9eb03d8f52693f6201380ec7110818
parent: 2ba45e82912cadbf8a0931ea2e819772e7cb4730
author: Debargha Mukherjee <debargha@google.com>
date: Mon Dec 2 09:49:50 EST 2019

Avoid dividing by 0 in vp8 gf_group bits compute

BUG=webm:1653

Change-Id: Ic59fe5e573f08dbca678d3927d4a750ae75f903c

--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -2072,9 +2072,10 @@
      * score, otherwise it may be worse off than an "un-boosted" frame
      */
     else {
+      // Avoid division by 0 by clamping cpi->twopass.kf_group_error_left to 1
       int alt_gf_bits =
           (int)((double)cpi->twopass.kf_group_bits * mod_frame_err /
-                DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left));
+                (double)VPXMAX(cpi->twopass.kf_group_error_left, 1));
 
       if (alt_gf_bits > gf_bits) {
         gf_bits = alt_gf_bits;