[x265] [PATCH] asm: avx2 assembly code for 8bpp transpose32x32 module

murugan at multicorewareinc.com murugan at multicorewareinc.com
Thu Oct 9 11:13:18 CEST 2014


# HG changeset patch
# User Murugan Vairavel <murugan at multicorewareinc.com>
# Date 1412838641 -19800
#      Thu Oct 09 12:40:41 2014 +0530
# Node ID 1588689ff25cf63159a8a5ff032b350f80156b15
# Parent  96609efaa87744168c613122d716c21d07b49af5
asm: avx2 assembly code for 8bpp transpose32x32 module

diff -r 96609efaa877 -r 1588689ff25c source/common/x86/asm-primitives.cpp
--- a/source/common/x86/asm-primitives.cpp	Wed Oct 08 18:52:12 2014 +0530
+++ b/source/common/x86/asm-primitives.cpp	Thu Oct 09 12:40:41 2014 +0530
@@ -1792,6 +1792,7 @@
         p.idct[IDCT_8x8] = x265_idct8_avx2;
         p.idct[IDCT_16x16] = x265_idct16_avx2;
         p.idct[IDCT_32x32] = x265_idct32_avx2;
+        p.transpose[BLOCK_32x32] = x265_transpose32_avx2;
 #endif
     }
 #endif // if HIGH_BIT_DEPTH
diff -r 96609efaa877 -r 1588689ff25c source/common/x86/pixel-util.h
--- a/source/common/x86/pixel-util.h	Wed Oct 08 18:52:12 2014 +0530
+++ b/source/common/x86/pixel-util.h	Thu Oct 09 12:40:41 2014 +0530
@@ -44,6 +44,8 @@
 void x265_transpose32_sse2(pixel *dest, pixel *src, intptr_t stride);
 void x265_transpose64_sse2(pixel *dest, pixel *src, intptr_t stride);
 
+void x265_transpose32_avx2(pixel *dest, pixel *src, intptr_t stride);
+
 uint32_t x265_quant_sse4(int32_t *coef, int32_t *quantCoeff, int32_t *deltaU, int16_t *qCoef, int qBits, int add, int numCoeff);
 uint32_t x265_quant_avx2(int32_t *coef, int32_t *quantCoeff, int32_t *deltaU, int16_t *qCoef, int qBits, int add, int numCoeff);
 uint32_t x265_nquant_sse4(int32_t *coef, int32_t *quantCoeff, int16_t *qCoef, int qBits, int add, int numCoeff);
diff -r 96609efaa877 -r 1588689ff25c source/common/x86/pixel-util8.asm
--- a/source/common/x86/pixel-util8.asm	Wed Oct 08 18:52:12 2014 +0530
+++ b/source/common/x86/pixel-util8.asm	Thu Oct 09 12:40:41 2014 +0530
@@ -1670,8 +1670,8 @@
 ;-----------------------------------------------------------------
 ; void transpose_32x32(pixel *dst, pixel *src, intptr_t stride)
 ;-----------------------------------------------------------------
+%if HIGH_BIT_DEPTH
 INIT_XMM sse2
-%if HIGH_BIT_DEPTH
 cglobal transpose32, 3, 7, 4, dest, src, stride
     add    r2,    r2
     mov    r3,    r0
@@ -1739,7 +1739,9 @@
     lea    r0,    [r6 + 24 * 64 + 48]
     mov    r3,    r0
     call   transpose8_internal
+    RET
 %else
+INIT_XMM sse2
 cglobal transpose32, 3, 7, 8, dest, src, stride
     mov    r3,    r0
     mov    r4,    r1
@@ -1758,8 +1760,193 @@
     lea    r0,    [r3 + 16 * 32 + 16]
     mov    r5,    r0
     call   transpose16_internal
+    RET
+%if ARCH_X86_64 == 1
+INIT_YMM avx2
+cglobal transpose32, 3, 5, 16
+    lea          r3, [r2 * 3]
+    mov          r4d, 2
+
+.loop:
+    movu         m0, [r1]
+    movu         m1, [r1 + r2]
+    movu         m2, [r1 + 2 * r2]
+    movu         m3, [r1 + r3]
+    lea          r1, [r1 + 4 * r2]
+
+    movu         m4, [r1]
+    movu         m5, [r1 + r2]
+    movu         m6, [r1 + 2 * r2]
+    movu         m7, [r1 + r3]
+
+    punpcklbw    m8, m0, m1                 ;[1 - 8 ; 17 - 24][1 2]
+    punpckhbw    m0, m1                     ;[9 - 16; 25 - 32][1 2]
+
+    punpcklbw    m1, m2, m3                 ;[1 - 8 ; 17 - 24][3 4]
+    punpckhbw    m2, m3                     ;[9 - 16; 25 - 32][3 4]
+
+    punpcklbw    m3, m4, m5                 ;[1 - 8 ; 17 - 24][5 6]
+    punpckhbw    m4, m5                     ;[9 - 16; 25 - 32][5 6]
+
+    punpcklbw    m5, m6, m7                 ;[1 - 8 ; 17 - 24][7 8]
+    punpckhbw    m6, m7                     ;[9 - 16; 25 - 32][7 8]
+
+    punpcklwd    m7, m8, m1                 ;[1 - 4 ; 17 - 20][1 2 3 4]
+    punpckhwd    m8, m1                     ;[5 - 8 ; 20 - 24][1 2 3 4]
+
+    punpcklwd    m1, m3, m5                 ;[1 - 4 ; 17 - 20][5 6 7 8]
+    punpckhwd    m3, m5                     ;[5 - 8 ; 20 - 24][5 6 7 8]
+
+    punpcklwd    m5, m0, m2                 ;[9 - 12; 25 - 28][1 2 3 4]
+    punpckhwd    m0, m2                     ;[12- 15; 29 - 32][1 2 3 4]
+
+    punpcklwd    m2, m4, m6                 ;[9 - 12; 25 - 28][5 6 7 8]
+    punpckhwd    m4, m6                     ;[12- 15; 29 - 32][5 6 7 8]
+
+    punpckldq    m6, m7, m1                 ;[1 - 2 ; 17 - 18][1 2 3 4 5 6 7 8]
+    punpckhdq    m7, m1                     ;[3 - 4 ; 19 - 20][1 2 3 4 5 6 7 8]
+
+    punpckldq    m1, m8, m3                 ;[5 - 6 ; 21 - 22][1 2 3 4 5 6 7 8]
+    punpckhdq    m8, m3                     ;[7 - 8 ; 23 - 24][1 2 3 4 5 6 7 8]
+
+    punpckldq    m3, m5, m2                 ;[9 - 10; 25 - 26][1 2 3 4 5 6 7 8]
+    punpckhdq    m5, m2                     ;[11- 12; 27 - 28][1 2 3 4 5 6 7 8]
+
+    punpckldq    m2, m0, m4                 ;[13- 14; 29 - 30][1 2 3 4 5 6 7 8]
+    punpckhdq    m0, m4                     ;[15- 16; 31 - 32][1 2 3 4 5 6 7 8]
+
+    movq         [r0 + 0  * 32], xm6
+    movhps       [r0 + 1  * 32], xm6
+    vextracti128 xm4, m6, 1
+    movq         [r0 + 16 * 32], xm4
+    movhps       [r0 + 17 * 32], xm4
+
+    lea          r1,  [r1 + 4 * r2]
+    movu         m9,  [r1]
+    movu         m10, [r1 + r2]
+    movu         m11, [r1 + 2 * r2]
+    movu         m12, [r1 + r3]
+    lea          r1,  [r1 + 4 * r2]
+
+    movu         m13, [r1]
+    movu         m14, [r1 + r2]
+    movu         m15, [r1 + 2 * r2]
+    movu         m6,  [r1 + r3]
+
+    punpcklbw    m4, m9, m10                ;[1 - 8 ; 17 - 24][9 10]
+    punpckhbw    m9, m10                    ;[9 - 16; 25 - 32][9 10]
+
+    punpcklbw    m10, m11, m12              ;[1 - 8 ; 17 - 24][11 12]
+    punpckhbw    m11, m12                   ;[9 - 16; 25 - 32][11 12]
+
+    punpcklbw    m12, m13, m14              ;[1 - 8 ; 17 - 24][13 14]
+    punpckhbw    m13, m14                   ;[9 - 16; 25 - 32][13 14]
+
+    punpcklbw    m14, m15, m6               ;[1 - 8 ; 17 - 24][15 16]
+    punpckhbw    m15, m6                    ;[9 - 16; 25 - 32][15 16]
+
+    punpcklwd    m6, m4, m10                ;[1 - 4 ; 17 - 20][9 10 11 12]
+    punpckhwd    m4, m10                    ;[5 - 8 ; 20 - 24][9 10 11 12]
+
+    punpcklwd    m10, m12, m14              ;[1 - 4 ; 17 - 20][13 14 15 16]
+    punpckhwd    m12, m14                   ;[5 - 8 ; 20 - 24][13 14 15 16]
+
+    punpcklwd    m14, m9, m11               ;[9 - 12; 25 - 28][9 10 11 12]
+    punpckhwd    m9, m11                    ;[13- 16; 29 - 32][9 10 11 12]
+
+    punpcklwd    m11, m13, m15              ;[9 - 12; 25 - 28][13 14 15 16]
+    punpckhwd    m13, m15                   ;[13- 16; 29 - 32][13 14 15 16]
+
+    punpckldq    m15, m6, m10               ;[1 - 2 ; 17 - 18][9 10 11 12 13 14 15 16]
+    punpckhdq    m6, m10                    ;[3 - 4 ; 19 - 20][9 10 11 12 13 14 15 16]
+
+    punpckldq    m10, m4, m12               ;[5 - 6 ; 21 - 22][9 10 11 12 13 14 15 16]
+    punpckhdq    m4, m12                    ;[7 - 8 ; 23 - 24][9 10 11 12 13 14 15 16]
+
+    punpckldq    m12, m14, m11              ;[9 - 10; 25 - 26][9 10 11 12 13 14 15 16]
+    punpckhdq    m14, m11                   ;[11- 12; 27 - 28][9 10 11 12 13 14 15 16]
+
+    punpckldq    m11, m9, m13               ;[13- 14; 29 - 30][9 10 11 12 13 14 15 16]
+    punpckhdq    m9, m13                    ;[15- 16; 31 - 32][9 10 11 12 13 14 15 16]
+
+
+    punpcklqdq   m13, m7, m6                ;[3 ; 19][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+    punpckhqdq   m7, m6                     ;[4 ; 20][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+
+    punpcklqdq   m6, m1, m10                ;[5 ; 21][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+    punpckhqdq   m1, m10                    ;[6 ; 22][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+
+    punpcklqdq   m10, m8, m4                ;[7 ; 23][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+    punpckhqdq   m8, m4                     ;[8 ; 24][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+
+    punpcklqdq   m4, m3, m12                ;[9 ; 25][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+    punpckhqdq   m3, m12                    ;[10; 26][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+
+    punpcklqdq   m12, m5, m14               ;[11; 27][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+    punpckhqdq   m5, m14                    ;[12; 28][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+
+    punpcklqdq   m14, m2, m11               ;[13; 29][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+    punpckhqdq   m2, m11                    ;[14; 30][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+
+    punpcklqdq   m11, m0, m9                ;[15; 31][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+    punpckhqdq   m0, m9                     ;[16; 32][1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
+
+    movq         [r0 + 0  * 32 + 8], xm15
+    movhps       [r0 + 1  * 32 + 8], xm15
+    vextracti128 xm9, m15, 1
+    movq         [r0 + 16 * 32 + 8], xm9
+    movhps       [r0 + 17 * 32 + 8], xm9
+
+    movu         [r0 + 2  * 32], xm13
+    vextracti128 xm9, m13, 1
+    movu         [r0 + 18 * 32], xm9
+
+    movu         [r0 + 3  * 32], xm7
+    vextracti128 [r0 + 19 * 32], m7, 1
+
+    movu         [r0 + 4  * 32], xm6
+    vextracti128 [r0 + 20 * 32], m6, 1
+
+    movu         [r0 + 5  * 32], xm1
+    vextracti128 [r0 + 21 * 32], m1, 1
+
+    movu         [r0 + 6  * 32], xm10
+    vextracti128 [r0 + 22 * 32], m10, 1
+
+    movu         [r0 + 7  * 32], xm8
+    vextracti128 [r0 + 23 * 32], m8, 1
+
+    movu         [r0 + 8  * 32], xm4
+    vextracti128 [r0 + 24 * 32], m4, 1
+
+    movu         [r0 + 9  * 32], xm3
+    vextracti128 [r0 + 25 * 32], m3, 1
+
+    movu         [r0 + 10 * 32], xm12
+    vextracti128 [r0 + 26 * 32], m12, 1
+
+    movu         [r0 + 11 * 32], xm5
+    vextracti128 [r0 + 27 * 32], m5, 1
+
+    movu         [r0 + 12 * 32], xm14
+    vextracti128 [r0 + 28 * 32], m14, 1
+
+    movu         [r0 + 13 * 32], xm2
+    vextracti128 [r0 + 29 * 32], m2, 1
+
+    movu         [r0 + 14 * 32], xm11
+    vextracti128 [r0 + 30 * 32], m11, 1
+
+    movu         [r0 + 15 * 32], xm0
+    vextracti128 [r0 + 31 * 32], m0, 1
+
+    add          r0, 16
+    lea          r1,  [r1 + 4 * r2]
+    dec          r4d
+    jnz          .loop
+    RET
 %endif
-    RET
+%endif
 
 ;-----------------------------------------------------------------
 ; void transpose_64x64(pixel *dst, pixel *src, intptr_t stride)


More information about the x265-devel mailing list