From: Anton Mitrofanov Date: Thu, 15 Dec 2011 21:48:07 +0000 (+0400) Subject: Fix PCM cost overflow X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=4c08e42504af81cdbe5789a309e868ca8eda2c1f;p=x264.git Fix PCM cost overflow --- diff --git a/encoder/analyse.c b/encoder/analyse.c index 83d8b5d4..7045d093 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -433,8 +433,10 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int qp ) a->i_satd_i4x4 = a->i_satd_chroma = COST_MAX; - /* non-RD PCM decision is inaccurate (as is psy-rd), so don't do it */ - a->i_satd_pcm = !h->mb.i_psy_rd && a->i_mbrd ? ((uint64_t)X264_PCM_COST*a->i_lambda2 + 128) >> 8 : COST_MAX; + /* non-RD PCM decision is inaccurate (as is psy-rd), so don't do it. + * PCM cost can overflow with high lambda2, so cap it at COST_MAX. */ + uint64_t pcm_cost = ((uint64_t)X264_PCM_COST*a->i_lambda2 + 128) >> 8; + a->i_satd_pcm = !h->mb.i_psy_rd && a->i_mbrd && pcm_cost < COST_MAX ? pcm_cost : COST_MAX; a->b_fast_intra = 0; a->b_avoid_topright = 0;