[x265] [PATCH 3 of 3] asm: code for input pixel upShift/downShift

murugan at multicorewareinc.com murugan at multicorewareinc.com
Fri Mar 21 06:35:31 CET 2014


# HG changeset patch
# User Murugan Vairavel <murugan at multicorewareinc.com>
# Date 1395379456 -19800
#      Fri Mar 21 10:54:16 2014 +0530
# Node ID 29728f7728591116192575d411ef2db2dff49c18
# Parent  435e50b2b92c83e10fdb2bd86bc8e8df91b7338b
asm: code for input pixel upShift/downShift

diff -r 435e50b2b92c -r 29728f772859 source/common/x86/asm-primitives.cpp
--- a/source/common/x86/asm-primitives.cpp	Fri Mar 21 10:49:47 2014 +0530
+++ b/source/common/x86/asm-primitives.cpp	Fri Mar 21 10:54:16 2014 +0530
@@ -1071,6 +1071,7 @@
         p.intra_pred[BLOCK_8x8][1] = x265_intra_pred_dc8_sse4;
         p.intra_pred[BLOCK_16x16][1] = x265_intra_pred_dc16_sse4;
         p.intra_pred[BLOCK_32x32][1] = x265_intra_pred_dc32_sse4;
+        p.planecopy_cp = x265_upShift_8_sse4;
 
         INTRA_ANG_SSE4_COMMON(sse4);
         INTRA_ANG_SSE4_HIGH(sse4);
@@ -1169,6 +1170,7 @@
         p.idct[IDCT_4x4] = x265_idct4_sse2;
         p.idct[IDST_4x4] = x265_idst4_sse2;
         p.count_nonzero = x265_count_nonzero_sse2;
+        p.planecopy_sp = x265_downShift_10_sse2;
     }
     if (cpuMask & X265_CPU_SSSE3)
     {
diff -r 435e50b2b92c -r 29728f772859 source/common/x86/pixel-a.asm
--- a/source/common/x86/pixel-a.asm	Fri Mar 21 10:49:47 2014 +0530
+++ b/source/common/x86/pixel-a.asm	Fri Mar 21 10:54:16 2014 +0530
@@ -6356,3 +6356,189 @@
     RET
 %endif ; HIGH_BIT_DEPTH
 
+; Input 10bpp, Output 8bpp, width is multiple of 16
+;------------------------------------------------------------------------------------------------------------------------
+;void planecopy_sp(uint16_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height, int shift, uint16_t mask)
+;------------------------------------------------------------------------------------------------------------------------
+INIT_XMM sse2
+cglobal downShift_10, 7,7,3
+    movd        m0, r6d        ; m0 = shift
+    add         r1, r1
+    dec         r5d
+.loopH:
+    xor         r6, r6
+.loopW:
+    movu        m1, [r0 + r6 * 2]
+    movu        m2, [r0 + r6 * 2 + 16]
+    psrlw       m1, m0
+    psrlw       m2, m0
+    packuswb    m1, m2
+    movu        [r2 + r6], m1
+
+    add         r6, 16
+    cmp         r6d, r4d
+    jl          .loopW
+
+    ; move to next row
+    lea         r0, [r0 + r1]
+    lea         r2, [r2 + r3]
+    dec         r5d
+    jnz         .loopH
+
+;processing last row of every frame [To handle width which not a multiple of 16]
+
+.loop16:
+    movu        m1, [r0]
+    movu        m2, [r0 + 16]
+    psrlw       m1, m0
+    psrlw       m2, m0
+    packuswb    m1, m2
+    movu        [r2], m1
+
+    add         r0, 2 * mmsize
+    add         r2, mmsize
+    sub         r4d, 16
+    jz          .end
+    cmp         r4d, 15
+    jg          .loop16
+
+    cmp         r4d, 8
+    jl          .process4
+    movu        m1, [r0]
+    psrlw       m1, m0
+    packuswb    m1, m1
+    movh        [r2], m1
+
+    add         r0, mmsize
+    add         r2, 8
+    sub         r4d, 8
+    jz          .end
+
+.process4:
+    cmp         r4d, 4
+    jl          .process2
+    movh        m1,[r0]
+    psrlw       m1, m0
+    packuswb    m1, m1
+    movd        [r2], m1
+
+    add         r0, 8
+    add         r2, 4
+    sub         r4d, 4
+    jz          .end
+
+.process2:
+    cmp         r4d, 2
+    jl          .process1
+    movd        m1, [r0]
+    psrlw       m1, m0
+    packuswb    m1, m1
+    movd        r6, m1
+    mov         [r2], r6w
+
+    add         r0, 4
+    add         r2, 2
+    sub         r4d, 2
+    jz          .end
+
+.process1:
+    movd        m1, [r0]
+    psrlw       m1, m0
+    packuswb    m1, m1
+    movd        r6, m1
+    mov         [r2], r6b
+.end:
+    RET
+
+; Input 8bpp, Output 16bpp, width is multiple of 16
+;-----------------------------------------------------------------------------------------------------
+;void planecopy_cp(uint8_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height)
+;-----------------------------------------------------------------------------------------------------
+INIT_XMM sse4
+cglobal upShift_8, 6,7,2
+
+    add         r3, r3
+    dec         r5d
+
+.loopH:
+    xor         r6, r6
+.loopW:
+    pmovzxbw    m0,[r0 + r6]
+    pmovzxbw    m1,[r0 + r6 + 8]
+    psllw       m0, 2
+    psllw       m1, 2
+    movu        [r2 + r6 * 2], m0
+    movu        [r2 + r6 * 2 + 16], m1
+
+    add         r6, 16
+    cmp         r6d, r4d
+    jl          .loopW
+
+    ; move to next row
+    lea         r0, [r0 + r1]
+    lea         r2, [r2 + r3]
+    dec         r5d
+    jnz         .loopH
+
+;processing last row of every frame [To handle width which not a multiple of 16]
+
+.loop16:
+    pmovzxbw    m0,[r0]
+    pmovzxbw    m1,[r0 + 8]
+    psllw       m0, 2
+    psllw       m1, 2
+    movu        [r2], m0
+    movu        [r2 + 16], m1
+
+    add         r0, mmsize
+    add         r2, 2 * mmsize
+    sub         r4d, 16
+    jz          .end
+    cmp         r4d, 15
+    jg          .loop16
+
+    cmp         r4d, 8
+    jl          .process4
+    pmovzxbw    m0,[r0]
+    psllw       m0, 2
+    movu        [r2], m0
+
+    add         r0, 8
+    add         r2, mmsize
+    sub         r4d, 8
+    jz          .end
+
+.process4:
+    cmp         r4d, 4
+    jl          .process2
+    movd        m0,[r0]
+    pmovzxbw    m0,m0
+    psllw       m0, 2
+    movh        [r2], m0
+
+    add         r0, 4
+    add         r2, 8
+    sub         r4d, 4
+    jz          .end
+
+.process2:
+    cmp         r4d, 2
+    jl          .process1
+    movzx       r6d, byte [r0]
+    shl         r6d, 2
+    mov         [r2], r6w
+    movzx       r6d, byte [r0 + 1]
+    shl         r6d, 2
+    mov         [r2 + 2], r6w
+
+    add         r0, 2
+    add         r2, 4
+    sub         r4d, 2
+    jz          .end
+
+.process1:
+    movzx       r6d, byte [r0]
+    shl         r6d, 2
+    mov         [r2], r6w
+.end:
+    RET
diff -r 435e50b2b92c -r 29728f772859 source/common/x86/pixel.h
--- a/source/common/x86/pixel.h	Fri Mar 21 10:49:47 2014 +0530
+++ b/source/common/x86/pixel.h	Fri Mar 21 10:54:16 2014 +0530
@@ -200,6 +200,9 @@
 ADDAVG(addAvg_64x48)
 ADDAVG(addAvg_64x64)
 
+void x265_downShift_10_sse2(uint16_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height, int shift, uint16_t mask);
+void x265_upShift_8_sse4(uint8_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height);
+
 #undef DECL_PIXELS
 #undef DECL_HEVC_SSD
 #undef DECL_X1


More information about the x265-devel mailing list