diff options
author | Debargha Mukherjee <debargha@google.com> | 2019-12-02 14:49:50 -0800 |
---|---|---|
committer | Debargha Mukherjee <debargha@google.com> | 2019-12-02 14:49:50 -0800 |
commit | 5eeabfffcb9eb03d8f52693f6201380ec7110818 (patch) | |
tree | 6849a50500a88b643a2044760148e1398159d7f9 | |
parent | 2ba45e82912cadbf8a0931ea2e819772e7cb4730 (diff) | |
download | libvpx-5eeabfffcb9eb03d8f52693f6201380ec7110818.tar.gz |
Avoid dividing by 0 in vp8 gf_group bits compute
BUG=webm:1653
Change-Id: Ic59fe5e573f08dbca678d3927d4a750ae75f903c
-rw-r--r-- | vp8/encoder/firstpass.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c index 72c9642fe..981c0fde3 100644 --- a/vp8/encoder/firstpass.c +++ b/vp8/encoder/firstpass.c @@ -2072,9 +2072,10 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) { * 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; |