[x265] [PATCH] asm: avx2 code for sad[16x8] for 10 bpp (398 -> 254)

sumalatha at multicorewareinc.com sumalatha at multicorewareinc.com
Tue Apr 28 14:12:30 CEST 2015


# HG changeset patch
# User Sumalatha Polureddy
# Date 1430221592 -19800
#      Tue Apr 28 17:16:32 2015 +0530
# Node ID aa40df631138c3534b34efc4239a6a0180d5d3bf
# Parent  13290abce29209be5206cce66e436c8ff3682540
asm: avx2 code for sad[16x8] for 10 bpp (398 -> 254)

sse2
sad[ 16x8]  3.30x    398.28          1313.01
avx2
sad[ 16x8]  5.48x    254.91          1398.03

diff -r 13290abce292 -r aa40df631138 source/common/x86/asm-primitives.cpp
--- a/source/common/x86/asm-primitives.cpp	Mon Apr 27 14:15:28 2015 -0500
+++ b/source/common/x86/asm-primitives.cpp	Tue Apr 28 17:16:32 2015 +0530
@@ -1239,6 +1239,8 @@
         p.chroma[X265_CSP_I422].cu[BLOCK_422_16x32].sub_ps = x265_pixel_sub_ps_16x32_avx2;
         p.chroma[X265_CSP_I422].cu[BLOCK_422_32x64].sub_ps = x265_pixel_sub_ps_32x64_avx2;
 
+        p.pu[LUMA_16x8].sad = x265_pixel_sad_16x8_avx2;
+
         p.pu[LUMA_16x4].convert_p2s = x265_filterPixelToShort_16x4_avx2;
         p.pu[LUMA_16x8].convert_p2s = x265_filterPixelToShort_16x8_avx2;
         p.pu[LUMA_16x12].convert_p2s = x265_filterPixelToShort_16x12_avx2;
diff -r 13290abce292 -r aa40df631138 source/common/x86/sad16-a.asm
--- a/source/common/x86/sad16-a.asm	Mon Apr 27 14:15:28 2015 -0500
+++ b/source/common/x86/sad16-a.asm	Tue Apr 28 17:16:32 2015 +0530
@@ -717,6 +717,57 @@
     movd     eax, xm0
     RET
 
+INIT_YMM avx2
+cglobal pixel_sad_16x8, 4,7,7
+    xorps           m0, m0
+    xorps           m6, m6
+    movu            m5, [pw_1]
+    mov             r4d, 8/4
+    add             r1d, r1d
+    add             r3d, r3d
+    lea             r5, [r1 * 3]
+    lea             r6, [r3 * 3]
+.loop
+    movu            m1, [r0]               ; row 0 of pix0
+    movu            m2, [r2]               ; row 0 of pix1
+    movu            m3, [r0 + r1]          ; row 1 of pix0
+    movu            m4, [r2 + r3]          ; row 1 of pix1
+    psubw           m1, m2
+    pabsw           m1, m1
+    pmaddwd         m1, m5
+    psubw           m3, m4
+    pabsw           m3, m3
+    pmaddwd         m3, m5
+    paddd           m0, m1
+    paddd           m6, m3
+
+    movu            m1, [r0 + 2 * r1]      ; row 2 of pix0
+    movu            m2, [r2 + 2 * r3]      ; row 2 of pix1
+    movu            m3, [r0 + r5]          ; row 3 of pix0
+    movu            m4, [r2 + r6]          ; row 3 of pix1
+    psubw           m1, m2
+    pabsw           m1, m1
+    pmaddwd         m1, m5
+    psubw           m3, m4
+    pabsw           m3, m3
+    pmaddwd         m3, m5
+    paddd           m0, m1
+    paddd           m6, m3
+    lea     r2,     [r2 + 4 * r3]
+    lea     r0,     [r0 + 4 * r1]
+
+    dec             r4d
+    jnz             .loop
+
+    paddd           m0, m6
+    vextracti128    xm1, m0, 1
+    paddd           xm0, xm1
+    movhlps         xm1, xm0
+    paddd           xm0, xm1
+    pshufd          xm1, xm0, 1
+    paddd           xm0, xm1
+    movd            eax, xm0
+    RET
 ;-----------------------------------------------------------------------------
 ; void pixel_sad_xN_WxH( uint16_t *fenc, uint16_t *pix0, uint16_t *pix1,
 ;                        uint16_t *pix2, intptr_t i_stride, int scores[3] )


More information about the x265-devel mailing list