From: Anton Mitrofanov Date: Sun, 8 Jun 2014 18:19:46 +0000 (+0400) Subject: Remove meaningless use of abs() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f112c0e1cae71eb5b98b4f86f635f235cc7b81cb;p=libx264 Remove meaningless use of abs() --- diff --git a/common/common.h b/common/common.h index e6a6fd00..76ae8a3c 100644 --- a/common/common.h +++ b/common/common.h @@ -316,8 +316,8 @@ static ALWAYS_INLINE int x264_predictor_difference( int16_t (*mvc)[2], intptr_t static ALWAYS_INLINE uint16_t x264_cabac_mvd_sum( uint8_t *mvdleft, uint8_t *mvdtop ) { - int amvd0 = abs(mvdleft[0]) + abs(mvdtop[0]); - int amvd1 = abs(mvdleft[1]) + abs(mvdtop[1]); + int amvd0 = mvdleft[0] + mvdtop[0]; + int amvd1 = mvdleft[1] + mvdtop[1]; amvd0 = (amvd0 > 2) + (amvd0 > 32); amvd1 = (amvd1 > 2) + (amvd1 > 32); return amvd0 + (amvd1<<8); diff --git a/common/pixel.c b/common/pixel.c index 5ef5f306..a06f5dbe 100644 --- a/common/pixel.c +++ b/common/pixel.c @@ -197,7 +197,7 @@ PIXEL_VAR_C( x264_pixel_var_8x8, 8, 8 ) #define PIXEL_VAR2_C( name, w, h, shift ) \ static int name( pixel *pix1, intptr_t i_stride1, pixel *pix2, intptr_t i_stride2, int *ssd ) \ { \ - uint32_t var = 0, sum = 0, sqr = 0; \ + int var = 0, sum = 0, sqr = 0; \ for( int y = 0; y < h; y++ ) \ { \ for( int x = 0; x < w; x++ ) \ @@ -209,8 +209,7 @@ static int name( pixel *pix1, intptr_t i_stride1, pixel *pix2, intptr_t i_stride pix1 += i_stride1; \ pix2 += i_stride2; \ } \ - sum = abs(sum); \ - var = sqr - ((uint64_t)sum * sum >> shift); \ + var = sqr - ((int64_t)sum * sum >> shift); \ *ssd = sqr; \ return var; \ }