[x265] [PATCH] asm: avx2 code for sad[64x64] (13997 -> 5214) for 10 bpp

sumalatha at multicorewareinc.com sumalatha at multicorewareinc.com
Thu May 14 08:08:54 CEST 2015


# HG changeset patch
# User Sumalatha Polureddy
# Date 1431583728 -19800
#      Thu May 14 11:38:48 2015 +0530
# Node ID 6bbf3f9021c47d37dec2a0208c606e96d3fd549e
# Parent  8f66730a49c9c679f81cf54dd52a94e40e51b86c
asm: avx2 code for sad[64x64] (13997 -> 5214) for 10 bpp

sse2
sad[64x64]  2.31x    13997.47        32364.27

avx2
sad[64x64]  6.68x    5214.84         34847.11

diff -r 8f66730a49c9 -r 6bbf3f9021c4 source/common/x86/asm-primitives.cpp
--- a/source/common/x86/asm-primitives.cpp	Thu May 14 11:07:36 2015 +0530
+++ b/source/common/x86/asm-primitives.cpp	Thu May 14 11:38:48 2015 +0530
@@ -1287,6 +1287,7 @@
         p.pu[LUMA_64x16].sad = x265_pixel_sad_64x16_avx2;
         p.pu[LUMA_64x32].sad = x265_pixel_sad_64x32_avx2;
         p.pu[LUMA_64x48].sad = x265_pixel_sad_64x48_avx2;
+        p.pu[LUMA_64x64].sad = x265_pixel_sad_64x64_avx2;
 
         p.pu[LUMA_16x4].convert_p2s = x265_filterPixelToShort_16x4_avx2;
         p.pu[LUMA_16x8].convert_p2s = x265_filterPixelToShort_16x8_avx2;
diff -r 8f66730a49c9 -r 6bbf3f9021c4 source/common/x86/sad16-a.asm
--- a/source/common/x86/sad16-a.asm	Thu May 14 11:07:36 2015 +0530
+++ b/source/common/x86/sad16-a.asm	Thu May 14 11:38:48 2015 +0530
@@ -929,6 +929,67 @@
     movd    eax, xm0
     RET
 
+INIT_YMM avx2
+cglobal pixel_sad_64x64, 4, 5, 8
+    pxor    m0, m0
+    pxor    m5, m5
+    pxor    m6, m6
+    pxor    m7, m7
+    mov     r4d, 64 / 2
+    add     r3d, r3d
+    add     r1d, r1d
+.loop:
+    movu    m1, [r2 + 0]
+    movu    m2, [r2 + 32]
+    movu    m3, [r2 + 64]
+    movu    m4, [r2 + 96]
+    psubw   m1, [r0 + 0]
+    psubw   m2, [r0 + 32]
+    psubw   m3, [r0 + 64]
+    psubw   m4, [r0 + 96]
+    pabsw   m1, m1
+    pabsw   m2, m2
+    pabsw   m3, m3
+    pabsw   m4, m4
+    paddw   m0, m1
+    paddw   m5, m2
+    paddw   m6, m3
+    paddw   m7, m4
+
+    movu    m1, [r2 + r3]
+    movu    m2, [r2 + r3 + 32]
+    movu    m3, [r2 + r3 + 64]
+    movu    m4, [r2 + r3 + 96]
+    psubw   m1, [r0 + r1]
+    psubw   m2, [r0 + r1 + 32]
+    psubw   m3, [r0 + r1 + 64]
+    psubw   m4, [r0 + r1 + 96]
+    pabsw   m1, m1
+    pabsw   m2, m2
+    pabsw   m3, m3
+    pabsw   m4, m4
+    paddw   m0, m1
+    paddw   m5, m2
+    paddw   m6, m3
+    paddw   m7, m4
+
+    lea     r0, [r0 + 2 * r1]
+    lea     r2, [r2 + 2 * r3]
+
+    dec    r4d
+    jg     .loop
+
+    HADDUWD m0, m1
+    HADDUWD m5, m1
+    HADDUWD m6, m1
+    HADDUWD m7, m1
+    paddd   m0, m5
+    paddd   m0, m6
+    paddd   m0, m7
+    HADDD   m0, m1    
+    movd    eax, xm0
+    RET
+
 ;------------------------------------------------------------------
 ; int pixel_sad_32xN( uint16_t *, intptr_t, uint16_t *, intptr_t )
 ;------------------------------------------------------------------


More information about the x265-devel mailing list