[x265] [PATCH] weight_pp: avx2 asm code as per new interface

praveen at multicorewareinc.com praveen at multicorewareinc.com
Tue Oct 21 08:14:43 CEST 2014


# HG changeset patch
# User Praveen Tiwari
# Date 1413872031 -19800
# Node ID 6db8760034c7c416452d72103f753ff48e319a81
# Parent  535b9ca17dd3063f5a36c8935b194093eb4267af
weight_pp: avx2 asm code as per new interface

diff -r 535b9ca17dd3 -r 6db8760034c7 source/common/x86/asm-primitives.cpp
--- a/source/common/x86/asm-primitives.cpp	Mon Oct 20 21:51:44 2014 -0500
+++ b/source/common/x86/asm-primitives.cpp	Tue Oct 21 11:43:51 2014 +0530
@@ -1789,6 +1789,8 @@
         p.chroma[X265_CSP_I422].copy_ss[CHROMA422_16x32] = x265_blockcopy_ss_16x32_avx;
         p.chroma[X265_CSP_I422].copy_ss[CHROMA422_16x64] = x265_blockcopy_ss_16x64_avx;
 
+        p.weight_pp = x265_weight_pp_avx2;
+
 #if X86_64
         p.dct[DCT_8x8] = x265_dct8_avx2;
         p.dct[DCT_16x16] = x265_dct16_avx2;
diff -r 535b9ca17dd3 -r 6db8760034c7 source/common/x86/pixel-util.h
--- a/source/common/x86/pixel-util.h	Mon Oct 20 21:51:44 2014 -0500
+++ b/source/common/x86/pixel-util.h	Tue Oct 21 11:43:51 2014 +0530
@@ -58,6 +58,7 @@
 int x265_count_nonzero_ssse3(const int16_t *quantCoeff, int numCoeff);
 
 void x265_weight_pp_sse4(pixel *src, pixel *dst, intptr_t stride, int width, int height, int w0, int round, int shift, int offset);
+void x265_weight_pp_avx2(pixel *src, pixel *dst, intptr_t stride, int width, int height, int w0, int round, int shift, int offset);
 void x265_weight_sp_sse4(int16_t *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset);
 
 void x265_pixel_ssim_4x4x2_core_mmx2(const uint8_t * pix1, intptr_t stride1,
diff -r 535b9ca17dd3 -r 6db8760034c7 source/common/x86/pixel-util8.asm
--- a/source/common/x86/pixel-util8.asm	Mon Oct 20 21:51:44 2014 -0500
+++ b/source/common/x86/pixel-util8.asm	Tue Oct 21 11:43:51 2014 +0530
@@ -1363,6 +1363,57 @@
     jnz         .loopH
     RET
 
+
+INIT_YMM avx2
+cglobal weight_pp, 6, 7, 6
+
+    shl          r5d, 6            ; m0 = [w0<<6]
+    mov          r6d, r6m
+    shl          r6d, 16
+    or           r6d, r5d          ; assuming both (w0<<6) and round are using maximum of 16 bits each.
+    movd         xm0, r6d
+    pshufd       xm0, xm0, 0       ; m0 = [w0<<6, round]
+    vinserti128  m0, m0, xm0, 1    ; document says (pshufd + vinserti128) can be replaced with vpbroadcastd m0, xm0, but having build problem, need to investigate
+
+    movd         xm1, r7m
+    vpbroadcastd m2, r8m
+    mova         m5, [pw_1]
+    sub          r2d, r3d
+    shr          r3d, 4
+
+.loopH:
+    mov          r5d, r3d
+
+.loopW:
+    pmovzxbw    m4, [r0]
+    punpcklwd   m3, m4, m5
+    pmaddwd     m3, m0
+    psrad       m3, xm1
+    paddd       m3, m2
+
+    punpckhwd   m4, m5
+    pmaddwd     m4, m0
+    psrad       m4, xm1
+    paddd       m4, m2
+
+    packssdw    m3, m4
+    vextracti128 xm4, m3, 1
+    packuswb    xm3, xm4
+    movu        [r1], xm3
+
+    add         r0, 16
+    add         r1, 16
+
+    dec         r5d
+    jnz         .loopW
+
+    lea         r0, [r0 + r2]
+    lea         r1, [r1 + r2]
+
+    dec         r4d
+    jnz         .loopH
+    RET
+
 ;-------------------------------------------------------------------------------------------------------------------------------------------------
 ;void weight_sp(int16_t *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset)
 ;-------------------------------------------------------------------------------------------------------------------------------------------------


More information about the x265-devel mailing list