[x264-devel] ppc: Use xxpermdi to halve the computation in sad_x4_8x8

Luca Barbato git at videolan.org
Tue Mar 12 19:31:54 CET 2019


x264 | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sun Aug 19 17:27:53 2018 +0200| [28fb2661161c12ee20c29d9bb2a75509a5af5327] | committer: Anton Mitrofanov

ppc: Use xxpermdi to halve the computation in sad_x4_8x8

About 20% faster.

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

 common/ppc/pixel.c | 47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/common/ppc/pixel.c b/common/ppc/pixel.c
index 5bb2bec6..66d7e045 100644
--- a/common/ppc/pixel.c
+++ b/common/ppc/pixel.c
@@ -1061,56 +1061,57 @@ static void pixel_sad_x4_8x8_altivec( uint8_t *fenc,
 
     for( int y = 0; y < 4; y++ )
     {
-        pix0v = vec_vsx_ld(0, pix0);
+        vec_u8_t pix0vH = vec_vsx_ld( 0, pix0 );
         pix0 += i_stride;
 
-        pix1v = vec_vsx_ld(0, pix1);
+        vec_u8_t pix1vH = vec_vsx_ld( 0, pix1 );
         pix1 += i_stride;
 
-        fencv = vec_vsx_ld(0, fenc);
+        vec_u8_t fencvH = vec_vsx_ld( 0, fenc );
         fenc += FENC_STRIDE;
 
-        pix2v = vec_vsx_ld(0, pix2);
+        vec_u8_t pix2vH = vec_vsx_ld( 0, pix2 );
         pix2 += i_stride;
 
-        pix3v = vec_vsx_ld(0, pix3);
+        vec_u8_t pix3vH = vec_vsx_ld( 0, pix3 );
         pix3 += i_stride;
 
-        sum0v = (vec_s32_t) vec_sum4s( vec_absd( fencv, pix0v ), (vec_u32_t) sum0v );
-        sum1v = (vec_s32_t) vec_sum4s( vec_absd( fencv, pix1v ), (vec_u32_t) sum1v );
-        sum2v = (vec_s32_t) vec_sum4s( vec_absd( fencv, pix2v ), (vec_u32_t) sum2v );
-        sum3v = (vec_s32_t) vec_sum4s( vec_absd( fencv, pix3v ), (vec_u32_t) sum3v );
-
-        pix0v = vec_vsx_ld(0, pix0);
+        vec_u8_t pix0vL = vec_vsx_ld( 0, pix0 );
         pix0 += i_stride;
 
-        pix1v = vec_vsx_ld(0, pix1);
+        vec_u8_t pix1vL = vec_vsx_ld( 0, pix1 );
         pix1 += i_stride;
 
-        fencv = vec_vsx_ld(0, fenc);
+        vec_u8_t fencvL = vec_vsx_ld( 0, fenc );
         fenc += FENC_STRIDE;
 
-        pix2v = vec_vsx_ld(0, pix2);
+        vec_u8_t pix2vL = vec_vsx_ld( 0, pix2 );
         pix2 += i_stride;
 
-        pix3v = vec_vsx_ld(0, pix3);
+        vec_u8_t pix3vL = vec_vsx_ld( 0, pix3 );
         pix3 += i_stride;
 
+        fencv = xxpermdi( fencvH, fencvL, 0 );
+        pix0v = xxpermdi( pix0vH, pix0vL, 0 );
+        pix1v = xxpermdi( pix1vH, pix1vL, 0 );
+        pix2v = xxpermdi( pix2vH, pix2vL, 0 );
+        pix3v = xxpermdi( pix3vH, pix3vL, 0 );
+
         sum0v = (vec_s32_t) vec_sum4s( vec_absd( fencv, pix0v ), (vec_u32_t) sum0v );
         sum1v = (vec_s32_t) vec_sum4s( vec_absd( fencv, pix1v ), (vec_u32_t) sum1v );
         sum2v = (vec_s32_t) vec_sum4s( vec_absd( fencv, pix2v ), (vec_u32_t) sum2v );
         sum3v = (vec_s32_t) vec_sum4s( vec_absd( fencv, pix3v ), (vec_u32_t) sum3v );
     }
 
-    sum0v = vec_sum2s( sum0v, zero_s32v );
-    sum1v = vec_sum2s( sum1v, zero_s32v );
-    sum2v = vec_sum2s( sum2v, zero_s32v );
-    sum3v = vec_sum2s( sum3v, zero_s32v );
+    sum0v = vec_sums( sum0v, zero_s32v );
+    sum1v = vec_sums( sum1v, zero_s32v );
+    sum2v = vec_sums( sum2v, zero_s32v );
+    sum3v = vec_sums( sum3v, zero_s32v );
 
-    sum0v = vec_splat( sum0v, 1 );
-    sum1v = vec_splat( sum1v, 1 );
-    sum2v = vec_splat( sum2v, 1 );
-    sum3v = vec_splat( sum3v, 1 );
+    sum0v = vec_splat( sum0v, 3 );
+    sum1v = vec_splat( sum1v, 3 );
+    sum2v = vec_splat( sum2v, 3 );
+    sum3v = vec_splat( sum3v, 3 );
 
     vec_ste( sum0v, 0, &sum0);
     vec_ste( sum1v, 0, &sum1);



More information about the x264-devel mailing list