Commit bd5f384b authored by Paul Wilkins's avatar Paul Wilkins
Browse files

Possible divide by 0 error.

Put traps to prevent two possible divide by 0 errors.

Change-Id: Ia415b945244253dcdd12f54f1f157f9ca8c94d6b
Showing with 10 additions and 3 deletions
...@@ -478,15 +478,19 @@ void separate_arf_mbs ...@@ -478,15 +478,19 @@ void separate_arf_mbs
if ( 1 ) if ( 1 )
{ {
// Note % of blocks that are marked as static // Note % of blocks that are marked as static
cpi->static_mb_pct = if ( cm->MBs )
(ncnt[1] * 100) / 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); vp8_enable_segmentation((VP8_PTR) cpi);
} }
else else
{ {
cpi->static_mb_pct = 0; cpi->static_mb_pct = 0;
vp8_disable_segmentation((VP8_PTR) cpi); vp8_disable_segmentation((VP8_PTR) cpi);
} }
......
...@@ -4554,6 +4554,9 @@ static void encode_frame_to_data_rate ...@@ -4554,6 +4554,9 @@ static void encode_frame_to_data_rate
int high_err_target = cpi->ambient_err; int high_err_target = cpi->ambient_err;
int low_err_target = ((cpi->ambient_err * 3) >> 2); 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 // The key frame is not good enough
if ( (kf_err > high_err_target) && if ( (kf_err > high_err_target) &&
(cpi->projected_frame_size <= frame_over_shoot_limit) ) (cpi->projected_frame_size <= frame_over_shoot_limit) )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment