From 03094a5533fee1435f9c9cfd1e6e812f17fdbf1f Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Tue, 26 Nov 2013 09:56:14 -0800 Subject: [PATCH] Fix unit test failures Change-Id: Ibc61ef81fafeb20df6df6e5496b6c01760f3dc84 --- vp9/encoder/vp9_firstpass.c | 8 +++++--- vp9/encoder/vp9_ratectrl.c | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index df2841020..924f9f324 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -336,9 +336,11 @@ static int frame_max_bits(VP9_COMP *cpi) { const double max_bits = (1.0 * cpi->twopass.bits_left / (cpi->twopass.total_stats.count - cpi->common.current_video_frame)) * (cpi->oxcf.two_pass_vbrmax_section / 100.0); - - // Trap case where we are out of bits. - return MAX((int)max_bits, 0); + if (max_bits < 0) + return 0; + if (max_bits >= INT_MAX) + return INT_MAX; + return (int)max_bits; } void vp9_init_first_pass(VP9_COMP *cpi) { diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 6e4c56c1a..062de78f3 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -244,7 +244,7 @@ static void calc_iframe_target_size(VP9_COMP *cpi) { cpi->rc.this_frame_target = target; // Target rate per SB64 (including partial SB64s. - cpi->rc.sb64_target_rate = (cpi->rc.this_frame_target * 64 * 64) / + cpi->rc.sb64_target_rate = ((int64_t)cpi->rc.this_frame_target * 64 * 64) / (cpi->common.width * cpi->common.height); } @@ -274,7 +274,7 @@ static void calc_pframe_target_size(VP9_COMP *cpi) { } // Target rate per SB64 (including partial SB64s. - cpi->rc.sb64_target_rate = (cpi->rc.this_frame_target * 64 * 64) / + cpi->rc.sb64_target_rate = ((int64_t)cpi->rc.this_frame_target * 64 * 64) / (cpi->common.width * cpi->common.height); -- 2.40.0