1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libjpeg/simd/jcqnts2f-64.asm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,158 @@ 1.4 +; 1.5 +; jcqnts2f-64.asm - sample data conversion and quantization (64-bit SSE & SSE2) 1.6 +; 1.7 +; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB 1.8 +; Copyright 2009 D. R. Commander 1.9 +; 1.10 +; Based on 1.11 +; x86 SIMD extension for IJG JPEG library 1.12 +; Copyright (C) 1999-2006, MIYASAKA Masaru. 1.13 +; For conditions of distribution and use, see copyright notice in jsimdext.inc 1.14 +; 1.15 +; This file should be assembled with NASM (Netwide Assembler), 1.16 +; can *not* be assembled with Microsoft's MASM or any compatible 1.17 +; assembler (including Borland's Turbo Assembler). 1.18 +; NASM is available from http://nasm.sourceforge.net/ or 1.19 +; http://sourceforge.net/project/showfiles.php?group_id=6208 1.20 +; 1.21 +; [TAB8] 1.22 + 1.23 +%include "jsimdext.inc" 1.24 +%include "jdct.inc" 1.25 + 1.26 +; -------------------------------------------------------------------------- 1.27 + SECTION SEG_TEXT 1.28 + BITS 64 1.29 +; 1.30 +; Load data into workspace, applying unsigned->signed conversion 1.31 +; 1.32 +; GLOBAL(void) 1.33 +; jsimd_convsamp_float_sse2 (JSAMPARRAY sample_data, JDIMENSION start_col, 1.34 +; FAST_FLOAT * workspace); 1.35 +; 1.36 + 1.37 +; r10 = JSAMPARRAY sample_data 1.38 +; r11 = JDIMENSION start_col 1.39 +; r12 = FAST_FLOAT * workspace 1.40 + 1.41 + align 16 1.42 + global EXTN(jsimd_convsamp_float_sse2) 1.43 + 1.44 +EXTN(jsimd_convsamp_float_sse2): 1.45 + push rbp 1.46 + mov rax,rsp 1.47 + mov rbp,rsp 1.48 + collect_args 1.49 + push rbx 1.50 + 1.51 + pcmpeqw xmm7,xmm7 1.52 + psllw xmm7,7 1.53 + packsswb xmm7,xmm7 ; xmm7 = PB_CENTERJSAMPLE (0x808080..) 1.54 + 1.55 + mov rsi, r10 1.56 + mov rax, r11 1.57 + mov rdi, r12 1.58 + mov rcx, DCTSIZE/2 1.59 +.convloop: 1.60 + mov rbx, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) 1.61 + mov rdx, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) 1.62 + 1.63 + movq xmm0, XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE] 1.64 + movq xmm1, XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE] 1.65 + 1.66 + psubb xmm0,xmm7 ; xmm0=(01234567) 1.67 + psubb xmm1,xmm7 ; xmm1=(89ABCDEF) 1.68 + 1.69 + punpcklbw xmm0,xmm0 ; xmm0=(*0*1*2*3*4*5*6*7) 1.70 + punpcklbw xmm1,xmm1 ; xmm1=(*8*9*A*B*C*D*E*F) 1.71 + 1.72 + punpcklwd xmm2,xmm0 ; xmm2=(***0***1***2***3) 1.73 + punpckhwd xmm0,xmm0 ; xmm0=(***4***5***6***7) 1.74 + punpcklwd xmm3,xmm1 ; xmm3=(***8***9***A***B) 1.75 + punpckhwd xmm1,xmm1 ; xmm1=(***C***D***E***F) 1.76 + 1.77 + psrad xmm2,(DWORD_BIT-BYTE_BIT) ; xmm2=(0123) 1.78 + psrad xmm0,(DWORD_BIT-BYTE_BIT) ; xmm0=(4567) 1.79 + cvtdq2ps xmm2,xmm2 ; xmm2=(0123) 1.80 + cvtdq2ps xmm0,xmm0 ; xmm0=(4567) 1.81 + psrad xmm3,(DWORD_BIT-BYTE_BIT) ; xmm3=(89AB) 1.82 + psrad xmm1,(DWORD_BIT-BYTE_BIT) ; xmm1=(CDEF) 1.83 + cvtdq2ps xmm3,xmm3 ; xmm3=(89AB) 1.84 + cvtdq2ps xmm1,xmm1 ; xmm1=(CDEF) 1.85 + 1.86 + movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm2 1.87 + movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm0 1.88 + movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm3 1.89 + movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm1 1.90 + 1.91 + add rsi, byte 2*SIZEOF_JSAMPROW 1.92 + add rdi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT 1.93 + dec rcx 1.94 + jnz short .convloop 1.95 + 1.96 + pop rbx 1.97 + uncollect_args 1.98 + pop rbp 1.99 + ret 1.100 + 1.101 + 1.102 +; -------------------------------------------------------------------------- 1.103 +; 1.104 +; Quantize/descale the coefficients, and store into coef_block 1.105 +; 1.106 +; GLOBAL(void) 1.107 +; jsimd_quantize_float_sse2 (JCOEFPTR coef_block, FAST_FLOAT * divisors, 1.108 +; FAST_FLOAT * workspace); 1.109 +; 1.110 + 1.111 +; r10 = JCOEFPTR coef_block 1.112 +; r11 = FAST_FLOAT * divisors 1.113 +; r12 = FAST_FLOAT * workspace 1.114 + 1.115 + align 16 1.116 + global EXTN(jsimd_quantize_float_sse2) 1.117 + 1.118 +EXTN(jsimd_quantize_float_sse2): 1.119 + push rbp 1.120 + mov rax,rsp 1.121 + mov rbp,rsp 1.122 + collect_args 1.123 + 1.124 + mov rsi, r12 1.125 + mov rdx, r11 1.126 + mov rdi, r10 1.127 + mov rax, DCTSIZE2/16 1.128 +.quantloop: 1.129 + movaps xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_FAST_FLOAT)] 1.130 + movaps xmm1, XMMWORD [XMMBLOCK(0,1,rsi,SIZEOF_FAST_FLOAT)] 1.131 + mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)] 1.132 + mulps xmm1, XMMWORD [XMMBLOCK(0,1,rdx,SIZEOF_FAST_FLOAT)] 1.133 + movaps xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_FAST_FLOAT)] 1.134 + movaps xmm3, XMMWORD [XMMBLOCK(1,1,rsi,SIZEOF_FAST_FLOAT)] 1.135 + mulps xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)] 1.136 + mulps xmm3, XMMWORD [XMMBLOCK(1,1,rdx,SIZEOF_FAST_FLOAT)] 1.137 + 1.138 + cvtps2dq xmm0,xmm0 1.139 + cvtps2dq xmm1,xmm1 1.140 + cvtps2dq xmm2,xmm2 1.141 + cvtps2dq xmm3,xmm3 1.142 + 1.143 + packssdw xmm0,xmm1 1.144 + packssdw xmm2,xmm3 1.145 + 1.146 + movdqa XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_JCOEF)], xmm0 1.147 + movdqa XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_JCOEF)], xmm2 1.148 + 1.149 + add rsi, byte 16*SIZEOF_FAST_FLOAT 1.150 + add rdx, byte 16*SIZEOF_FAST_FLOAT 1.151 + add rdi, byte 16*SIZEOF_JCOEF 1.152 + dec rax 1.153 + jnz short .quantloop 1.154 + 1.155 + uncollect_args 1.156 + pop rbp 1.157 + ret 1.158 + 1.159 +; For some reason, the OS X linker does not honor the request to align the 1.160 +; segment unless we do this. 1.161 + align 16