summaryrefslogtreecommitdiff
path: root/vp8/encoder
diff options
context:
space:
mode:
authorPaul Wilkins <paulwilkins@google.com>2012-01-18 11:10:51 +0000
committerPaul Wilkins <paulwilkins@google.com>2012-01-18 11:10:51 +0000
commitbd5f384bef041f536ced51fe08d0620528ef061b (patch)
treeaf7e747bf76108edb8f1f84bfda8d6440e770402 /vp8/encoder
parentcf561bad1d027da0b28b4cd75036942e97d4fef7 (diff)
downloadlibvpx-bd5f384bef041f536ced51fe08d0620528ef061b.tar
libvpx-bd5f384bef041f536ced51fe08d0620528ef061b.tar.gz
libvpx-bd5f384bef041f536ced51fe08d0620528ef061b.tar.bz2
libvpx-bd5f384bef041f536ced51fe08d0620528ef061b.zip
Possible divide by 0 error.
Put traps to prevent two possible divide by 0 errors. Change-Id: Ia415b945244253dcdd12f54f1f157f9ca8c94d6b
Diffstat (limited to 'vp8/encoder')
-rw-r--r--vp8/encoder/mbgraph.c10
-rw-r--r--vp8/encoder/onyx_if.c3
2 files changed, 10 insertions, 3 deletions
diff --git a/vp8/encoder/mbgraph.c b/vp8/encoder/mbgraph.c
index 4f9ba125b..79b7fd595 100644
--- a/vp8/encoder/mbgraph.c
+++ b/vp8/encoder/mbgraph.c
@@ -478,15 +478,19 @@ void separate_arf_mbs
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);
}
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 25b56691d..6715ac2f6 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -4554,6 +4554,9 @@ static void encode_frame_to_data_rate
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) )