Commit 5f2e8449 authored by Ronald S. Bultje's avatar Ronald S. Bultje Committed by Gerrit Code Review
Browse files

Merge "Port sadNxNx4d functions to x86inc.asm." into experimental

parents aec5bed3 c0ce2ab3
......@@ -496,25 +496,25 @@ prototype void vp9_sad4x4x8 "const uint8_t *src_ptr, int src_stride, const uint
specialize vp9_sad4x4x8 sse4
prototype void vp9_sad64x64x4d "const uint8_t *src_ptr, int src_stride, const uint8_t **ref_ptr, int ref_stride, unsigned int *sad_array"
specialize vp9_sad64x64x4d sse3
specialize vp9_sad64x64x4d sse2
prototype void vp9_sad32x32x4d "const uint8_t *src_ptr, int src_stride, const uint8_t **ref_ptr, int ref_stride, unsigned int *sad_array"
specialize vp9_sad32x32x4d sse3
specialize vp9_sad32x32x4d sse2
prototype void vp9_sad16x16x4d "const uint8_t *src_ptr, int src_stride, const uint8_t **ref_ptr, int ref_stride, unsigned int *sad_array"
specialize vp9_sad16x16x4d sse3
specialize vp9_sad16x16x4d sse2
prototype void vp9_sad16x8x4d "const uint8_t *src_ptr, int src_stride, const uint8_t **ref_ptr, int ref_stride, unsigned int *sad_array"
specialize vp9_sad16x8x4d sse3
specialize vp9_sad16x8x4d sse2
prototype void vp9_sad8x16x4d "const uint8_t *src_ptr, int src_stride, const uint8_t **ref_ptr, int ref_stride, unsigned int *sad_array"
specialize vp9_sad8x16x4d sse3
specialize vp9_sad8x16x4d sse2
prototype void vp9_sad8x8x4d "const uint8_t *src_ptr, int src_stride, const uint8_t **ref_ptr, int ref_stride, unsigned int *sad_array"
specialize vp9_sad8x8x4d sse3
specialize vp9_sad8x8x4d sse2
prototype void vp9_sad4x4x4d "const uint8_t *src_ptr, int src_stride, const uint8_t **ref_ptr, int ref_stride, unsigned int *sad_array"
specialize vp9_sad4x4x4d sse3
specialize vp9_sad4x4x4d sse
#
# Block copy
......
;
; Copyright (c) 2010 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
%include "third_party/x86inc/x86inc.asm"
SECTION .text
; PROCESS_4x2x4 first, off_{first,second}_{src,ref}, advance_at_end
%macro PROCESS_4x2x4 5-6 0
movd m0, [srcq +%2]
%if %1 == 1
movd m6, [ref1q+%3]
movd m4, [ref2q+%3]
movd m7, [ref3q+%3]
movd m5, [ref4q+%3]
punpckldq m0, [srcq +%4]
punpckldq m6, [ref1q+%5]
punpckldq m4, [ref2q+%5]
punpckldq m7, [ref3q+%5]
punpckldq m5, [ref4q+%5]
psadbw m6, m0
psadbw m4, m0
psadbw m7, m0
psadbw m5, m0
punpckldq m6, m4
punpckldq m7, m5
%else
movd m1, [ref1q+%3]
movd m2, [ref2q+%3]
movd m3, [ref3q+%3]
movd m4, [ref4q+%3]
punpckldq m0, [srcq +%4]
punpckldq m1, [ref1q+%5]
punpckldq m2, [ref2q+%5]
punpckldq m3, [ref3q+%5]
punpckldq m4, [ref4q+%5]
psadbw m1, m0
psadbw m2, m0
psadbw m3, m0
psadbw m4, m0
punpckldq m1, m2
punpckldq m3, m4
paddd m6, m1
paddd m7, m3
%endif
%if %6 == 1
lea srcq, [srcq +src_strideq*2]
lea ref1q, [ref1q+ref_strideq*2]
lea ref2q, [ref2q+ref_strideq*2]
lea ref3q, [ref3q+ref_strideq*2]
lea ref4q, [ref4q+ref_strideq*2]
%endif
%endmacro
; PROCESS_8x2x4 first, off_{first,second}_{src,ref}, advance_at_end
%macro PROCESS_8x2x4 5-6 0
movh m0, [srcq +%2]
%if %1 == 1
movh m4, [ref1q+%3]
movh m5, [ref2q+%3]
movh m6, [ref3q+%3]
movh m7, [ref4q+%3]
movhps m0, [srcq +%4]
movhps m4, [ref1q+%5]
movhps m5, [ref2q+%5]
movhps m6, [ref3q+%5]
movhps m7, [ref4q+%5]
psadbw m4, m0
psadbw m5, m0
psadbw m6, m0
psadbw m7, m0
%else
movh m1, [ref1q+%3]
movh m2, [ref2q+%3]
movh m3, [ref3q+%3]
movhps m0, [srcq +%4]
movhps m1, [ref1q+%5]
movhps m2, [ref2q+%5]
movhps m3, [ref3q+%5]
psadbw m1, m0
psadbw m2, m0
psadbw m3, m0
paddd m4, m1
movh m1, [ref4q+%3]
movhps m1, [ref4q+%5]
paddd m5, m2
paddd m6, m3
psadbw m1, m0
paddd m7, m1
%endif
%if %6 == 1
lea srcq, [srcq +src_strideq*2]
lea ref1q, [ref1q+ref_strideq*2]
lea ref2q, [ref2q+ref_strideq*2]
lea ref3q, [ref3q+ref_strideq*2]
lea ref4q, [ref4q+ref_strideq*2]
%endif
%endmacro
; PROCESS_16x2x4 first, off_{first,second}_{src,ref}, advance_at_end
%macro PROCESS_16x2x4 5-6 0
; 1st 16 px
mova m0, [srcq +%2]
%if %1 == 1
movu m4, [ref1q+%3]
movu m5, [ref2q+%3]
movu m6, [ref3q+%3]
movu m7, [ref4q+%3]
psadbw m4, m0
psadbw m5, m0
psadbw m6, m0
psadbw m7, m0
%else
movu m1, [ref1q+%3]
movu m2, [ref2q+%3]
movu m3, [ref3q+%3]
psadbw m1, m0
psadbw m2, m0
psadbw m3, m0
paddd m4, m1
movu m1, [ref4q+%3]
paddd m5, m2
paddd m6, m3
psadbw m1, m0
paddd m7, m1
%endif
; 2nd 16 px
mova m0, [srcq +%4]
movu m1, [ref1q+%5]
movu m2, [ref2q+%5]
movu m3, [ref3q+%5]
psadbw m1, m0
psadbw m2, m0
psadbw m3, m0
paddd m4, m1
movu m1, [ref4q+%5]
paddd m5, m2
paddd m6, m3
%if %6 == 1
lea srcq, [srcq +src_strideq*2]
lea ref1q, [ref1q+ref_strideq*2]
lea ref2q, [ref2q+ref_strideq*2]
lea ref3q, [ref3q+ref_strideq*2]
lea ref4q, [ref4q+ref_strideq*2]
%endif
psadbw m1, m0
paddd m7, m1
%endmacro
; PROCESS_32x2x4 first, off_{first,second}_{src,ref}, advance_at_end
%macro PROCESS_32x2x4 5-6 0
PROCESS_16x2x4 %1, %2, %3, %2 + 16, %3 + 16
PROCESS_16x2x4 0, %4, %5, %4 + 16, %5 + 16, %6
%endmacro
; PROCESS_64x2x4 first, off_{first,second}_{src,ref}, advance_at_end
%macro PROCESS_64x2x4 5-6 0
PROCESS_32x2x4 %1, %2, %3, %2 + 32, %3 + 32
PROCESS_32x2x4 0, %4, %5, %4 + 32, %5 + 32, %6
%endmacro
; void vp9_sadNxNx4d_sse2(uint8_t *src, int src_stride,
; uint8_t *ref[4], int ref_stride,
; unsigned int res[4]);
; where NxN = 64x64, 32x32, 16x16, 16x8, 8x16 or 8x8
%macro SADNXN4D 2
%if UNIX64
cglobal sad%1x%2x4d, 5, 8, 8, src, src_stride, ref1, ref_stride, \
res, ref2, ref3, ref4
%else
cglobal sad%1x%2x4d, 4, 7, 8, src, src_stride, ref1, ref_stride, \
ref2, ref3, ref4
%endif
movsxdifnidn src_strideq, src_strided
movsxdifnidn ref_strideq, ref_strided
mov ref2q, [ref1q+gprsize*1]
mov ref3q, [ref1q+gprsize*2]
mov ref4q, [ref1q+gprsize*3]
mov ref1q, [ref1q+gprsize*0]
PROCESS_%1x2x4 1, 0, 0, src_strideq, ref_strideq, 1
%rep (%2-4)/2
PROCESS_%1x2x4 0, 0, 0, src_strideq, ref_strideq, 1
%endrep
PROCESS_%1x2x4 0, 0, 0, src_strideq, ref_strideq, 0
%if mmsize == 16
pslldq m5, 4
pslldq m7, 4
por m4, m5
por m6, m7
mova m5, m4
mova m7, m6
punpcklqdq m4, m6
punpckhqdq m5, m7
movifnidn r4, r4mp
paddd m4, m5
movu [r4], m4
RET
%else
movifnidn r4, r4mp
movq [r4+0], m6
movq [r4+8], m7
RET
%endif
%endmacro
INIT_XMM sse2
SADNXN4D 64, 64
SADNXN4D 32, 32
SADNXN4D 16, 16
SADNXN4D 16, 8
SADNXN4D 8, 16
SADNXN4D 8, 8
INIT_MMX sse
SADNXN4D 4, 4
......@@ -83,87 +83,6 @@
ret
%endmacro
%macro STACK_FRAME_CREATE_X4 0
%if ABI_IS_32BIT
%define src_ptr rsi
%define src_stride rax
%define r0_ptr rcx
%define r1_ptr rdx
%define r2_ptr rbx
%define r3_ptr rdi
%define ref_stride rbp
%define result_ptr arg(4)
push rbp
mov rbp, rsp
push rsi
push rdi
push rbx
push rbp
mov rdi, arg(2) ; ref_ptr_base
LOAD_X4_ADDRESSES rdi, rcx, rdx, rax, rdi
mov rsi, arg(0) ; src_ptr
movsxd rbx, dword ptr arg(1) ; src_stride
movsxd rbp, dword ptr arg(3) ; ref_stride
xchg rbx, rax
%else
%ifidn __OUTPUT_FORMAT__,x64
SAVE_XMM 7, u
%define src_ptr rcx
%define src_stride rdx
%define r0_ptr rsi
%define r1_ptr r10
%define r2_ptr r11
%define r3_ptr r8
%define ref_stride r9
%define result_ptr [rsp+xmm_stack_space+16+4*8]
push rsi
LOAD_X4_ADDRESSES r8, r0_ptr, r1_ptr, r2_ptr, r3_ptr
%else
%define src_ptr rdi
%define src_stride rsi
%define r0_ptr r9
%define r1_ptr r10
%define r2_ptr r11
%define r3_ptr rdx
%define ref_stride rcx
%define result_ptr r8
LOAD_X4_ADDRESSES rdx, r0_ptr, r1_ptr, r2_ptr, r3_ptr
%endif
%endif
%endmacro
%macro STACK_FRAME_DESTROY_X4 0
%define src_ptr
%define src_stride
%define r0_ptr
%define r1_ptr
%define r2_ptr
%define r3_ptr
%define ref_stride
%define result_ptr
%if ABI_IS_32BIT
pop rbx
pop rdi
pop rsi
pop rbp
%else
%ifidn __OUTPUT_FORMAT__,x64
pop rsi
RESTORE_XMM
%endif
%endif
ret
%endmacro
%macro PROCESS_16X2X3 5
%if %1==0
movdqa xmm0, XMMWORD PTR [%2]
......@@ -250,130 +169,6 @@
paddw mm7, mm3
%endmacro
%macro LOAD_X4_ADDRESSES 5
mov %2, [%1+REG_SZ_BYTES*0]
mov %3, [%1+REG_SZ_BYTES*1]
mov %4, [%1+REG_SZ_BYTES*2]
mov %5, [%1+REG_SZ_BYTES*3]
%endmacro
%macro PROCESS_16X2X4 8-9 0
%if %1==0 || %1==3
movdqa xmm0, XMMWORD PTR [%2+%9]
lddqu xmm4, XMMWORD PTR [%3+%9]
lddqu xmm5, XMMWORD PTR [%4+%9]
lddqu xmm6, XMMWORD PTR [%5+%9]
lddqu xmm7, XMMWORD PTR [%6+%9]
psadbw xmm4, xmm0
psadbw xmm5, xmm0
psadbw xmm6, xmm0
psadbw xmm7, xmm0
%else
movdqa xmm0, XMMWORD PTR [%2+%9]
lddqu xmm1, XMMWORD PTR [%3+%9]
lddqu xmm2, XMMWORD PTR [%4+%9]
lddqu xmm3, XMMWORD PTR [%5+%9]
psadbw xmm1, xmm0
psadbw xmm2, xmm0
psadbw xmm3, xmm0
paddd xmm4, xmm1
lddqu xmm1, XMMWORD PTR [%6+%9]
paddd xmm5, xmm2
paddd xmm6, xmm3
psadbw xmm1, xmm0
paddd xmm7, xmm1
%endif
movdqa xmm0, XMMWORD PTR [%2+%7+%9]
lddqu xmm1, XMMWORD PTR [%3+%8+%9]
lddqu xmm2, XMMWORD PTR [%4+%8+%9]
lddqu xmm3, XMMWORD PTR [%5+%8+%9]
psadbw xmm1, xmm0
psadbw xmm2, xmm0
psadbw xmm3, xmm0
paddd xmm4, xmm1
lddqu xmm1, XMMWORD PTR [%6+%8+%9]
paddd xmm5, xmm2
paddd xmm6, xmm3
%if %1==0 || %1==1
lea %2, [%2+%7*2]
lea %3, [%3+%8*2]
lea %4, [%4+%8*2]
lea %5, [%5+%8*2]
lea %6, [%6+%8*2]
%endif
psadbw xmm1, xmm0
paddd xmm7, xmm1
%endmacro
%macro PROCESS_8X2X4 8
%if %1==0
movq mm0, QWORD PTR [%2]
movq mm4, QWORD PTR [%3]
movq mm5, QWORD PTR [%4]
movq mm6, QWORD PTR [%5]
movq mm7, QWORD PTR [%6]
psadbw mm4, mm0
psadbw mm5, mm0
psadbw mm6, mm0
psadbw mm7, mm0
%else
movq mm0, QWORD PTR [%2]
movq mm1, QWORD PTR [%3]
movq mm2, QWORD PTR [%4]
movq mm3, QWORD PTR [%5]
psadbw mm1, mm0
psadbw mm2, mm0
psadbw mm3, mm0
paddw mm4, mm1
movq mm1, QWORD PTR [%6]
paddw mm5, mm2
paddw mm6, mm3
psadbw mm1, mm0
paddw mm7, mm1
%endif
movq mm0, QWORD PTR [%2+%7]
movq mm1, QWORD PTR [%3+%8]
movq mm2, QWORD PTR [%4+%8]
movq mm3, QWORD PTR [%5+%8]
psadbw mm1, mm0
psadbw mm2, mm0
psadbw mm3, mm0
paddw mm4, mm1
movq mm1, QWORD PTR [%6+%8]
paddw mm5, mm2
paddw mm6, mm3
%if %1==0 || %1==1
lea %2, [%2+%7*2]
lea %3, [%3+%8*2]
lea %4, [%4+%8*2]
lea %5, [%5+%8*2]
lea %6, [%6+%8*2]
%endif
psadbw mm1, mm0
paddw mm7, mm1
%endmacro
;void int vp9_sad16x16x3_sse3(
; unsigned char *src_ptr,
; int src_stride,
......@@ -642,340 +437,3 @@ sym(vp9_copy32xn_sse3):
.copy_is_done:
STACK_FRAME_DESTROY_X3
;void vp9_sad64x64x4d_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr_base,
; int ref_stride,
; int *results)
global sym(vp9_sad64x64x4d_sse3) PRIVATE
sym(vp9_sad64x64x4d_sse3):
STACK_FRAME_CREATE_X4
%macro PROCESS_64X8X4 2-3+
PROCESS_16X2X4 %1, %3
PROCESS_16X2X4 2, %3, 16
PROCESS_16X2X4 2, %3, 32
PROCESS_16X2X4 1, %3, 48
PROCESS_16X2X4 2, %3
PROCESS_16X2X4 2, %3, 16
PROCESS_16X2X4 2, %3, 32
PROCESS_16X2X4 1, %3, 48
PROCESS_16X2X4 2, %3
PROCESS_16X2X4 2, %3, 16
PROCESS_16X2X4 2, %3, 32
PROCESS_16X2X4 1, %3, 48
PROCESS_16X2X4 2, %3
PROCESS_16X2X4 2, %3, 16
PROCESS_16X2X4 2, %3, 32
PROCESS_16X2X4 %2, %3, 48
%endmacro
PROCESS_64X8X4 3, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_64X8X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_64X8X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_64X8X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_64X8X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_64X8X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_64X8X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_64X8X4 2, 2, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
%macro STORE_4D_RESULTS 0
%if ABI_IS_32BIT
pop rbp
%endif
mov rcx, result_ptr
movq xmm0, xmm4
psrldq xmm4, 8
paddd xmm0, xmm4
movd [rcx], xmm0
;-
movq xmm0, xmm5
psrldq xmm5, 8
paddd xmm0, xmm5
movd [rcx+4], xmm0
;-
movq xmm0, xmm6
psrldq xmm6, 8
paddd xmm0, xmm6
movd [rcx+8], xmm0
;-
movq xmm0, xmm7
psrldq xmm7, 8
paddd xmm0, xmm7
movd [rcx+12], xmm0
%endmacro
STORE_4D_RESULTS
STACK_FRAME_DESTROY_X4
;void vp9_sad32x32x4d_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr_base,
; int ref_stride,
; int *results)
global sym(vp9_sad32x32x4d_sse3) PRIVATE
sym(vp9_sad32x32x4d_sse3):
STACK_FRAME_CREATE_X4
%macro PROCESS_32X4X4 2-3+
PROCESS_16X2X4 %1, %3
PROCESS_16X2X4 1, %3, 16
PROCESS_16X2X4 2, %3
PROCESS_16X2X4 %2, %3, 16
%endmacro
PROCESS_32X4X4 3, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_32X4X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_32X4X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_32X4X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_32X4X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_32X4X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_32X4X4 2, 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_32X4X4 2, 2, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
STORE_4D_RESULTS
STACK_FRAME_DESTROY_X4
;void vp9_sad16x16x4d_sse3(
; unsigned char *src_ptr,
; int src_stride,
; unsigned char *ref_ptr_base,
; int ref_stride,
; int *results)
global sym(vp9_sad16x16x4d_sse3) PRIVATE
sym(vp9_sad16x16x4d_sse3):
STACK_FRAME_CREATE_X4
PROCESS_16X2X4 0, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_16X2X4 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_16X2X4 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_16X2X4 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_16X2X4 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_16X2X4 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_16X2X4 1, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride
PROCESS_16X2X4 2, src_ptr, r0_ptr, r1_ptr, r2_ptr, r3_ptr, src_stride, ref_stride