ref: bd5f384bef041f536ced51fe08d0620528ef061b
parent: cf561bad1d027da0b28b4cd75036942e97d4fef7
author: Paul Wilkins <paulwilkins@google.com>
date: Wed Jan 18 06:10:51 EST 2012
Possible divide by 0 error. Put traps to prevent two possible divide by 0 errors. Change-Id: Ia415b945244253dcdd12f54f1f157f9ca8c94d6b
--- a/vp8/encoder/mbgraph.c
+++ b/vp8/encoder/mbgraph.c
@@ -478,15 +478,19 @@
if ( 1 )
{
// Note % of blocks that are marked as static
- cpi->static_mb_pct =
- (ncnt[1] * 100) / cm->MBs;
+ if ( cm->MBs )
+ cpi->static_mb_pct = (ncnt[1] * 100) / cm->MBs;
+ // This error case should not be reachable as this function should
+ // never be called with the common data structure unititialized.
+ else
+ cpi->static_mb_pct = 0;
+
vp8_enable_segmentation((VP8_PTR) cpi);
}
else
{
cpi->static_mb_pct = 0;
-
vp8_disable_segmentation((VP8_PTR) cpi);
}
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -4554,6 +4554,9 @@
int high_err_target = cpi->ambient_err;
int low_err_target = ((cpi->ambient_err * 3) >> 2);
+ // Prevent possible divide by zero error below for perfect KF
+ kf_err += (!kf_err);
+
// The key frame is not good enough
if ( (kf_err > high_err_target) &&
(cpi->projected_frame_size <= frame_over_shoot_limit) )
--
⑨