diff --git a/encoder/rdo.c b/encoder/rdo.c index 93170437a045fb7d1d16a6e494b3c6b6d15cd98c..fa7649e24f5d3ae4214f55251908cb0ff2e69fa2 100644 --- a/encoder/rdo.c +++ b/encoder/rdo.c @@ -141,7 +141,8 @@ static inline int ssd_plane( x264_t *h, int size, int p, int x, int y ) int dc = h->pixf.sad[size]( fdec, FDEC_STRIDE, (pixel*)x264_zero, 0 ) >> 1; satd = abs(h->pixf.satd[size]( fdec, FDEC_STRIDE, (pixel*)x264_zero, 0 ) - dc - cached_satd( h, size, x, y )); } - satd = (satd * h->mb.i_psy_rd * h->mb.i_psy_rd_lambda + 128) >> 8; + int64_t tmp = ((int64_t)satd * h->mb.i_psy_rd * h->mb.i_psy_rd_lambda + 128) >> 8; + satd = X264_MIN( tmp, COST_MAX ); } return h->pixf.ssd[size](fenc, FENC_STRIDE, fdec, FDEC_STRIDE) + satd; }