michael@0: ; michael@0: ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: ; michael@0: ; Use of this source code is governed by a BSD-style license michael@0: ; that can be found in the LICENSE file in the root of the source michael@0: ; tree. An additional intellectual property rights grant can be found michael@0: ; in the file PATENTS. All contributing project authors may michael@0: ; be found in the AUTHORS file in the root of the source tree. michael@0: ; michael@0: michael@0: michael@0: %include "vpx_ports/x86_abi_support.asm" michael@0: michael@0: global sym(vp9_sad16x16_mmx) PRIVATE michael@0: global sym(vp9_sad8x16_mmx) PRIVATE michael@0: global sym(vp9_sad8x8_mmx) PRIVATE michael@0: global sym(vp9_sad4x4_mmx) PRIVATE michael@0: global sym(vp9_sad16x8_mmx) PRIVATE michael@0: michael@0: ;unsigned int vp9_sad16x16_mmx( michael@0: ; unsigned char *src_ptr, michael@0: ; int src_stride, michael@0: ; unsigned char *ref_ptr, michael@0: ; int ref_stride) michael@0: sym(vp9_sad16x16_mmx): michael@0: push rbp michael@0: mov rbp, rsp michael@0: SHADOW_ARGS_TO_STACK 4 michael@0: push rsi michael@0: push rdi michael@0: ; end prolog michael@0: michael@0: mov rsi, arg(0) ;src_ptr michael@0: mov rdi, arg(2) ;ref_ptr michael@0: michael@0: movsxd rax, dword ptr arg(1) ;src_stride michael@0: movsxd rdx, dword ptr arg(3) ;ref_stride michael@0: michael@0: lea rcx, [rsi+rax*8] michael@0: michael@0: lea rcx, [rcx+rax*8] michael@0: pxor mm7, mm7 michael@0: michael@0: pxor mm6, mm6 michael@0: michael@0: .x16x16sad_mmx_loop: michael@0: michael@0: movq mm0, QWORD PTR [rsi] michael@0: movq mm2, QWORD PTR [rsi+8] michael@0: michael@0: movq mm1, QWORD PTR [rdi] michael@0: movq mm3, QWORD PTR [rdi+8] michael@0: michael@0: movq mm4, mm0 michael@0: movq mm5, mm2 michael@0: michael@0: psubusb mm0, mm1 michael@0: psubusb mm1, mm4 michael@0: michael@0: psubusb mm2, mm3 michael@0: psubusb mm3, mm5 michael@0: michael@0: por mm0, mm1 michael@0: por mm2, mm3 michael@0: michael@0: movq mm1, mm0 michael@0: movq mm3, mm2 michael@0: michael@0: punpcklbw mm0, mm6 michael@0: punpcklbw mm2, mm6 michael@0: michael@0: punpckhbw mm1, mm6 michael@0: punpckhbw mm3, mm6 michael@0: michael@0: paddw mm0, mm2 michael@0: paddw mm1, mm3 michael@0: michael@0: michael@0: lea rsi, [rsi+rax] michael@0: add rdi, rdx michael@0: michael@0: paddw mm7, mm0 michael@0: paddw mm7, mm1 michael@0: michael@0: cmp rsi, rcx michael@0: jne .x16x16sad_mmx_loop michael@0: michael@0: michael@0: movq mm0, mm7 michael@0: michael@0: punpcklwd mm0, mm6 michael@0: punpckhwd mm7, mm6 michael@0: michael@0: paddw mm0, mm7 michael@0: movq mm7, mm0 michael@0: michael@0: michael@0: psrlq mm0, 32 michael@0: paddw mm7, mm0 michael@0: michael@0: movq rax, mm7 michael@0: michael@0: pop rdi michael@0: pop rsi michael@0: mov rsp, rbp michael@0: ; begin epilog michael@0: UNSHADOW_ARGS michael@0: pop rbp michael@0: ret michael@0: michael@0: michael@0: ;unsigned int vp9_sad8x16_mmx( michael@0: ; unsigned char *src_ptr, michael@0: ; int src_stride, michael@0: ; unsigned char *ref_ptr, michael@0: ; int ref_stride) michael@0: sym(vp9_sad8x16_mmx): michael@0: push rbp michael@0: mov rbp, rsp michael@0: SHADOW_ARGS_TO_STACK 4 michael@0: push rsi michael@0: push rdi michael@0: ; end prolog michael@0: michael@0: mov rsi, arg(0) ;src_ptr michael@0: mov rdi, arg(2) ;ref_ptr michael@0: michael@0: movsxd rax, dword ptr arg(1) ;src_stride michael@0: movsxd rdx, dword ptr arg(3) ;ref_stride michael@0: michael@0: lea rcx, [rsi+rax*8] michael@0: michael@0: lea rcx, [rcx+rax*8] michael@0: pxor mm7, mm7 michael@0: michael@0: pxor mm6, mm6 michael@0: michael@0: .x8x16sad_mmx_loop: michael@0: michael@0: movq mm0, QWORD PTR [rsi] michael@0: movq mm1, QWORD PTR [rdi] michael@0: michael@0: movq mm2, mm0 michael@0: psubusb mm0, mm1 michael@0: michael@0: psubusb mm1, mm2 michael@0: por mm0, mm1 michael@0: michael@0: movq mm2, mm0 michael@0: punpcklbw mm0, mm6 michael@0: michael@0: punpckhbw mm2, mm6 michael@0: lea rsi, [rsi+rax] michael@0: michael@0: add rdi, rdx michael@0: paddw mm7, mm0 michael@0: michael@0: paddw mm7, mm2 michael@0: cmp rsi, rcx michael@0: michael@0: jne .x8x16sad_mmx_loop michael@0: michael@0: movq mm0, mm7 michael@0: punpcklwd mm0, mm6 michael@0: michael@0: punpckhwd mm7, mm6 michael@0: paddw mm0, mm7 michael@0: michael@0: movq mm7, mm0 michael@0: psrlq mm0, 32 michael@0: michael@0: paddw mm7, mm0 michael@0: movq rax, mm7 michael@0: michael@0: pop rdi michael@0: pop rsi michael@0: mov rsp, rbp michael@0: ; begin epilog michael@0: UNSHADOW_ARGS michael@0: pop rbp michael@0: ret michael@0: michael@0: michael@0: ;unsigned int vp9_sad8x8_mmx( michael@0: ; unsigned char *src_ptr, michael@0: ; int src_stride, michael@0: ; unsigned char *ref_ptr, michael@0: ; int ref_stride) michael@0: sym(vp9_sad8x8_mmx): michael@0: push rbp michael@0: mov rbp, rsp michael@0: SHADOW_ARGS_TO_STACK 4 michael@0: push rsi michael@0: push rdi michael@0: ; end prolog michael@0: michael@0: mov rsi, arg(0) ;src_ptr michael@0: mov rdi, arg(2) ;ref_ptr michael@0: michael@0: movsxd rax, dword ptr arg(1) ;src_stride michael@0: movsxd rdx, dword ptr arg(3) ;ref_stride michael@0: michael@0: lea rcx, [rsi+rax*8] michael@0: pxor mm7, mm7 michael@0: michael@0: pxor mm6, mm6 michael@0: michael@0: .x8x8sad_mmx_loop: michael@0: michael@0: movq mm0, QWORD PTR [rsi] michael@0: movq mm1, QWORD PTR [rdi] michael@0: michael@0: movq mm2, mm0 michael@0: psubusb mm0, mm1 michael@0: michael@0: psubusb mm1, mm2 michael@0: por mm0, mm1 michael@0: michael@0: movq mm2, mm0 michael@0: punpcklbw mm0, mm6 michael@0: michael@0: punpckhbw mm2, mm6 michael@0: paddw mm0, mm2 michael@0: michael@0: lea rsi, [rsi+rax] michael@0: add rdi, rdx michael@0: michael@0: paddw mm7, mm0 michael@0: cmp rsi, rcx michael@0: michael@0: jne .x8x8sad_mmx_loop michael@0: michael@0: movq mm0, mm7 michael@0: punpcklwd mm0, mm6 michael@0: michael@0: punpckhwd mm7, mm6 michael@0: paddw mm0, mm7 michael@0: michael@0: movq mm7, mm0 michael@0: psrlq mm0, 32 michael@0: michael@0: paddw mm7, mm0 michael@0: movq rax, mm7 michael@0: michael@0: pop rdi michael@0: pop rsi michael@0: mov rsp, rbp michael@0: ; begin epilog michael@0: UNSHADOW_ARGS michael@0: pop rbp michael@0: ret michael@0: michael@0: michael@0: ;unsigned int vp9_sad4x4_mmx( michael@0: ; unsigned char *src_ptr, michael@0: ; int src_stride, michael@0: ; unsigned char *ref_ptr, michael@0: ; int ref_stride) michael@0: sym(vp9_sad4x4_mmx): michael@0: push rbp michael@0: mov rbp, rsp michael@0: SHADOW_ARGS_TO_STACK 4 michael@0: push rsi michael@0: push rdi michael@0: ; end prolog michael@0: michael@0: mov rsi, arg(0) ;src_ptr michael@0: mov rdi, arg(2) ;ref_ptr michael@0: michael@0: movsxd rax, dword ptr arg(1) ;src_stride michael@0: movsxd rdx, dword ptr arg(3) ;ref_stride michael@0: michael@0: movd mm0, DWORD PTR [rsi] michael@0: movd mm1, DWORD PTR [rdi] michael@0: michael@0: movd mm2, DWORD PTR [rsi+rax] michael@0: movd mm3, DWORD PTR [rdi+rdx] michael@0: michael@0: punpcklbw mm0, mm2 michael@0: punpcklbw mm1, mm3 michael@0: michael@0: movq mm2, mm0 michael@0: psubusb mm0, mm1 michael@0: michael@0: psubusb mm1, mm2 michael@0: por mm0, mm1 michael@0: michael@0: movq mm2, mm0 michael@0: pxor mm3, mm3 michael@0: michael@0: punpcklbw mm0, mm3 michael@0: punpckhbw mm2, mm3 michael@0: michael@0: paddw mm0, mm2 michael@0: michael@0: lea rsi, [rsi+rax*2] michael@0: lea rdi, [rdi+rdx*2] michael@0: michael@0: movd mm4, DWORD PTR [rsi] michael@0: movd mm5, DWORD PTR [rdi] michael@0: michael@0: movd mm6, DWORD PTR [rsi+rax] michael@0: movd mm7, DWORD PTR [rdi+rdx] michael@0: michael@0: punpcklbw mm4, mm6 michael@0: punpcklbw mm5, mm7 michael@0: michael@0: movq mm6, mm4 michael@0: psubusb mm4, mm5 michael@0: michael@0: psubusb mm5, mm6 michael@0: por mm4, mm5 michael@0: michael@0: movq mm5, mm4 michael@0: punpcklbw mm4, mm3 michael@0: michael@0: punpckhbw mm5, mm3 michael@0: paddw mm4, mm5 michael@0: michael@0: paddw mm0, mm4 michael@0: movq mm1, mm0 michael@0: michael@0: punpcklwd mm0, mm3 michael@0: punpckhwd mm1, mm3 michael@0: michael@0: paddw mm0, mm1 michael@0: movq mm1, mm0 michael@0: michael@0: psrlq mm0, 32 michael@0: paddw mm0, mm1 michael@0: michael@0: movq rax, mm0 michael@0: michael@0: pop rdi michael@0: pop rsi michael@0: mov rsp, rbp michael@0: ; begin epilog michael@0: UNSHADOW_ARGS michael@0: pop rbp michael@0: ret michael@0: michael@0: michael@0: ;unsigned int vp9_sad16x8_mmx( michael@0: ; unsigned char *src_ptr, michael@0: ; int src_stride, michael@0: ; unsigned char *ref_ptr, michael@0: ; int ref_stride) michael@0: sym(vp9_sad16x8_mmx): michael@0: push rbp michael@0: mov rbp, rsp michael@0: SHADOW_ARGS_TO_STACK 4 michael@0: push rsi michael@0: push rdi michael@0: ; end prolog michael@0: michael@0: mov rsi, arg(0) ;src_ptr michael@0: mov rdi, arg(2) ;ref_ptr michael@0: michael@0: movsxd rax, dword ptr arg(1) ;src_stride michael@0: movsxd rdx, dword ptr arg(3) ;ref_stride michael@0: michael@0: lea rcx, [rsi+rax*8] michael@0: pxor mm7, mm7 michael@0: michael@0: pxor mm6, mm6 michael@0: michael@0: .x16x8sad_mmx_loop: michael@0: michael@0: movq mm0, [rsi] michael@0: movq mm1, [rdi] michael@0: michael@0: movq mm2, [rsi+8] michael@0: movq mm3, [rdi+8] michael@0: michael@0: movq mm4, mm0 michael@0: movq mm5, mm2 michael@0: michael@0: psubusb mm0, mm1 michael@0: psubusb mm1, mm4 michael@0: michael@0: psubusb mm2, mm3 michael@0: psubusb mm3, mm5 michael@0: michael@0: por mm0, mm1 michael@0: por mm2, mm3 michael@0: michael@0: movq mm1, mm0 michael@0: movq mm3, mm2 michael@0: michael@0: punpcklbw mm0, mm6 michael@0: punpckhbw mm1, mm6 michael@0: michael@0: punpcklbw mm2, mm6 michael@0: punpckhbw mm3, mm6 michael@0: michael@0: michael@0: paddw mm0, mm2 michael@0: paddw mm1, mm3 michael@0: michael@0: paddw mm0, mm1 michael@0: lea rsi, [rsi+rax] michael@0: michael@0: add rdi, rdx michael@0: paddw mm7, mm0 michael@0: michael@0: cmp rsi, rcx michael@0: jne .x16x8sad_mmx_loop michael@0: michael@0: movq mm0, mm7 michael@0: punpcklwd mm0, mm6 michael@0: michael@0: punpckhwd mm7, mm6 michael@0: paddw mm0, mm7 michael@0: michael@0: movq mm7, mm0 michael@0: psrlq mm0, 32 michael@0: michael@0: paddw mm7, mm0 michael@0: movq rax, mm7 michael@0: michael@0: pop rdi michael@0: pop rsi michael@0: mov rsp, rbp michael@0: ; begin epilog michael@0: UNSHADOW_ARGS michael@0: pop rbp michael@0: ret