[x264-devel] Remove meaningless use of abs()

Anton Mitrofanov git at videolan.org
Sun Jul 20 11:58:30 CEST 2014


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Sun Jun  8 22:19:46 2014 +0400| [f112c0e1cae71eb5b98b4f86f635f235cc7b81cb] | committer: Fiona Glaser

Remove meaningless use of abs()

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=f112c0e1cae71eb5b98b4f86f635f235cc7b81cb
---

 common/common.h |    4 ++--
 common/pixel.c  |    5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/common/common.h b/common/common.h
index e6a6fd0..76ae8a3 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 5ef5f30..a06f5db 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; \
 }



More information about the x264-devel mailing list