1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libjpeg/simd/jiss2flt.asm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,498 @@ 1.4 +; 1.5 +; jiss2flt.asm - floating-point IDCT (SSE & SSE2) 1.6 +; 1.7 +; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB 1.8 +; 1.9 +; Based on 1.10 +; x86 SIMD extension for IJG JPEG library 1.11 +; Copyright (C) 1999-2006, MIYASAKA Masaru. 1.12 +; For conditions of distribution and use, see copyright notice in jsimdext.inc 1.13 +; 1.14 +; This file should be assembled with NASM (Netwide Assembler), 1.15 +; can *not* be assembled with Microsoft's MASM or any compatible 1.16 +; assembler (including Borland's Turbo Assembler). 1.17 +; NASM is available from http://nasm.sourceforge.net/ or 1.18 +; http://sourceforge.net/project/showfiles.php?group_id=6208 1.19 +; 1.20 +; This file contains a floating-point implementation of the inverse DCT 1.21 +; (Discrete Cosine Transform). The following code is based directly on 1.22 +; the IJG's original jidctflt.c; see the jidctflt.c for more details. 1.23 +; 1.24 +; [TAB8] 1.25 + 1.26 +%include "jsimdext.inc" 1.27 +%include "jdct.inc" 1.28 + 1.29 +; -------------------------------------------------------------------------- 1.30 + 1.31 +%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5) 1.32 + shufps %1,%2,0x44 1.33 +%endmacro 1.34 + 1.35 +%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7) 1.36 + shufps %1,%2,0xEE 1.37 +%endmacro 1.38 + 1.39 +; -------------------------------------------------------------------------- 1.40 + SECTION SEG_CONST 1.41 + 1.42 + alignz 16 1.43 + global EXTN(jconst_idct_float_sse2) 1.44 + 1.45 +EXTN(jconst_idct_float_sse2): 1.46 + 1.47 +PD_1_414 times 4 dd 1.414213562373095048801689 1.48 +PD_1_847 times 4 dd 1.847759065022573512256366 1.49 +PD_1_082 times 4 dd 1.082392200292393968799446 1.50 +PD_M2_613 times 4 dd -2.613125929752753055713286 1.51 +PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3) 1.52 +PB_CENTERJSAMP times 16 db CENTERJSAMPLE 1.53 + 1.54 + alignz 16 1.55 + 1.56 +; -------------------------------------------------------------------------- 1.57 + SECTION SEG_TEXT 1.58 + BITS 32 1.59 +; 1.60 +; Perform dequantization and inverse DCT on one block of coefficients. 1.61 +; 1.62 +; GLOBAL(void) 1.63 +; jsimd_idct_float_sse2 (void * dct_table, JCOEFPTR coef_block, 1.64 +; JSAMPARRAY output_buf, JDIMENSION output_col) 1.65 +; 1.66 + 1.67 +%define dct_table(b) (b)+8 ; void * dct_table 1.68 +%define coef_block(b) (b)+12 ; JCOEFPTR coef_block 1.69 +%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf 1.70 +%define output_col(b) (b)+20 ; JDIMENSION output_col 1.71 + 1.72 +%define original_ebp ebp+0 1.73 +%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] 1.74 +%define WK_NUM 2 1.75 +%define workspace wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT 1.76 + ; FAST_FLOAT workspace[DCTSIZE2] 1.77 + 1.78 + align 16 1.79 + global EXTN(jsimd_idct_float_sse2) 1.80 + 1.81 +EXTN(jsimd_idct_float_sse2): 1.82 + push ebp 1.83 + mov eax,esp ; eax = original ebp 1.84 + sub esp, byte 4 1.85 + and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits 1.86 + mov [esp],eax 1.87 + mov ebp,esp ; ebp = aligned ebp 1.88 + lea esp, [workspace] 1.89 + push ebx 1.90 +; push ecx ; need not be preserved 1.91 +; push edx ; need not be preserved 1.92 + push esi 1.93 + push edi 1.94 + 1.95 + get_GOT ebx ; get GOT address 1.96 + 1.97 + ; ---- Pass 1: process columns from input, store into work array. 1.98 + 1.99 +; mov eax, [original_ebp] 1.100 + mov edx, POINTER [dct_table(eax)] ; quantptr 1.101 + mov esi, JCOEFPTR [coef_block(eax)] ; inptr 1.102 + lea edi, [workspace] ; FAST_FLOAT * wsptr 1.103 + mov ecx, DCTSIZE/4 ; ctr 1.104 + alignx 16,7 1.105 +.columnloop: 1.106 +%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE 1.107 + mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] 1.108 + or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] 1.109 + jnz near .columnDCT 1.110 + 1.111 + movq xmm1, XMM_MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] 1.112 + movq xmm2, XMM_MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] 1.113 + movq xmm3, XMM_MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] 1.114 + movq xmm4, XMM_MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] 1.115 + movq xmm5, XMM_MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] 1.116 + movq xmm6, XMM_MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] 1.117 + movq xmm7, XMM_MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] 1.118 + por xmm1,xmm2 1.119 + por xmm3,xmm4 1.120 + por xmm5,xmm6 1.121 + por xmm1,xmm3 1.122 + por xmm5,xmm7 1.123 + por xmm1,xmm5 1.124 + packsswb xmm1,xmm1 1.125 + movd eax,xmm1 1.126 + test eax,eax 1.127 + jnz short .columnDCT 1.128 + 1.129 + ; -- AC terms all zero 1.130 + 1.131 + movq xmm0, XMM_MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] 1.132 + 1.133 + punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) 1.134 + psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03) 1.135 + cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03) 1.136 + 1.137 + mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.138 + 1.139 + movaps xmm1,xmm0 1.140 + movaps xmm2,xmm0 1.141 + movaps xmm3,xmm0 1.142 + 1.143 + shufps xmm0,xmm0,0x00 ; xmm0=(00 00 00 00) 1.144 + shufps xmm1,xmm1,0x55 ; xmm1=(01 01 01 01) 1.145 + shufps xmm2,xmm2,0xAA ; xmm2=(02 02 02 02) 1.146 + shufps xmm3,xmm3,0xFF ; xmm3=(03 03 03 03) 1.147 + 1.148 + movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0 1.149 + movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm0 1.150 + movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm1 1.151 + movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm1 1.152 + movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm2 1.153 + movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm2 1.154 + movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3 1.155 + movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3 1.156 + jmp near .nextcolumn 1.157 + alignx 16,7 1.158 +%endif 1.159 +.columnDCT: 1.160 + 1.161 + ; -- Even part 1.162 + 1.163 + movq xmm0, XMM_MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] 1.164 + movq xmm1, XMM_MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] 1.165 + movq xmm2, XMM_MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] 1.166 + movq xmm3, XMM_MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] 1.167 + 1.168 + punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) 1.169 + punpcklwd xmm1,xmm1 ; xmm1=(20 20 21 21 22 22 23 23) 1.170 + psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03) 1.171 + psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in2=(20 21 22 23) 1.172 + cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03) 1.173 + cvtdq2ps xmm1,xmm1 ; xmm1=in2=(20 21 22 23) 1.174 + 1.175 + punpcklwd xmm2,xmm2 ; xmm2=(40 40 41 41 42 42 43 43) 1.176 + punpcklwd xmm3,xmm3 ; xmm3=(60 60 61 61 62 62 63 63) 1.177 + psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in4=(40 41 42 43) 1.178 + psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in6=(60 61 62 63) 1.179 + cvtdq2ps xmm2,xmm2 ; xmm2=in4=(40 41 42 43) 1.180 + cvtdq2ps xmm3,xmm3 ; xmm3=in6=(60 61 62 63) 1.181 + 1.182 + mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.183 + mulps xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.184 + mulps xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.185 + mulps xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.186 + 1.187 + movaps xmm4,xmm0 1.188 + movaps xmm5,xmm1 1.189 + subps xmm0,xmm2 ; xmm0=tmp11 1.190 + subps xmm1,xmm3 1.191 + addps xmm4,xmm2 ; xmm4=tmp10 1.192 + addps xmm5,xmm3 ; xmm5=tmp13 1.193 + 1.194 + mulps xmm1,[GOTOFF(ebx,PD_1_414)] 1.195 + subps xmm1,xmm5 ; xmm1=tmp12 1.196 + 1.197 + movaps xmm6,xmm4 1.198 + movaps xmm7,xmm0 1.199 + subps xmm4,xmm5 ; xmm4=tmp3 1.200 + subps xmm0,xmm1 ; xmm0=tmp2 1.201 + addps xmm6,xmm5 ; xmm6=tmp0 1.202 + addps xmm7,xmm1 ; xmm7=tmp1 1.203 + 1.204 + movaps XMMWORD [wk(1)], xmm4 ; tmp3 1.205 + movaps XMMWORD [wk(0)], xmm0 ; tmp2 1.206 + 1.207 + ; -- Odd part 1.208 + 1.209 + movq xmm2, XMM_MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] 1.210 + movq xmm3, XMM_MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] 1.211 + movq xmm5, XMM_MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] 1.212 + movq xmm1, XMM_MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] 1.213 + 1.214 + punpcklwd xmm2,xmm2 ; xmm2=(10 10 11 11 12 12 13 13) 1.215 + punpcklwd xmm3,xmm3 ; xmm3=(30 30 31 31 32 32 33 33) 1.216 + psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in1=(10 11 12 13) 1.217 + psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in3=(30 31 32 33) 1.218 + cvtdq2ps xmm2,xmm2 ; xmm2=in1=(10 11 12 13) 1.219 + cvtdq2ps xmm3,xmm3 ; xmm3=in3=(30 31 32 33) 1.220 + 1.221 + punpcklwd xmm5,xmm5 ; xmm5=(50 50 51 51 52 52 53 53) 1.222 + punpcklwd xmm1,xmm1 ; xmm1=(70 70 71 71 72 72 73 73) 1.223 + psrad xmm5,(DWORD_BIT-WORD_BIT) ; xmm5=in5=(50 51 52 53) 1.224 + psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in7=(70 71 72 73) 1.225 + cvtdq2ps xmm5,xmm5 ; xmm5=in5=(50 51 52 53) 1.226 + cvtdq2ps xmm1,xmm1 ; xmm1=in7=(70 71 72 73) 1.227 + 1.228 + mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.229 + mulps xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.230 + mulps xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.231 + mulps xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)] 1.232 + 1.233 + movaps xmm4,xmm2 1.234 + movaps xmm0,xmm5 1.235 + addps xmm2,xmm1 ; xmm2=z11 1.236 + addps xmm5,xmm3 ; xmm5=z13 1.237 + subps xmm4,xmm1 ; xmm4=z12 1.238 + subps xmm0,xmm3 ; xmm0=z10 1.239 + 1.240 + movaps xmm1,xmm2 1.241 + subps xmm2,xmm5 1.242 + addps xmm1,xmm5 ; xmm1=tmp7 1.243 + 1.244 + mulps xmm2,[GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11 1.245 + 1.246 + movaps xmm3,xmm0 1.247 + addps xmm0,xmm4 1.248 + mulps xmm0,[GOTOFF(ebx,PD_1_847)] ; xmm0=z5 1.249 + mulps xmm3,[GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930) 1.250 + mulps xmm4,[GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200) 1.251 + addps xmm3,xmm0 ; xmm3=tmp12 1.252 + subps xmm4,xmm0 ; xmm4=tmp10 1.253 + 1.254 + ; -- Final output stage 1.255 + 1.256 + subps xmm3,xmm1 ; xmm3=tmp6 1.257 + movaps xmm5,xmm6 1.258 + movaps xmm0,xmm7 1.259 + addps xmm6,xmm1 ; xmm6=data0=(00 01 02 03) 1.260 + addps xmm7,xmm3 ; xmm7=data1=(10 11 12 13) 1.261 + subps xmm5,xmm1 ; xmm5=data7=(70 71 72 73) 1.262 + subps xmm0,xmm3 ; xmm0=data6=(60 61 62 63) 1.263 + subps xmm2,xmm3 ; xmm2=tmp5 1.264 + 1.265 + movaps xmm1,xmm6 ; transpose coefficients(phase 1) 1.266 + unpcklps xmm6,xmm7 ; xmm6=(00 10 01 11) 1.267 + unpckhps xmm1,xmm7 ; xmm1=(02 12 03 13) 1.268 + movaps xmm3,xmm0 ; transpose coefficients(phase 1) 1.269 + unpcklps xmm0,xmm5 ; xmm0=(60 70 61 71) 1.270 + unpckhps xmm3,xmm5 ; xmm3=(62 72 63 73) 1.271 + 1.272 + movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2 1.273 + movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3 1.274 + 1.275 + movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71) 1.276 + movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73) 1.277 + 1.278 + addps xmm4,xmm2 ; xmm4=tmp4 1.279 + movaps xmm0,xmm7 1.280 + movaps xmm3,xmm5 1.281 + addps xmm7,xmm2 ; xmm7=data2=(20 21 22 23) 1.282 + addps xmm5,xmm4 ; xmm5=data4=(40 41 42 43) 1.283 + subps xmm0,xmm2 ; xmm0=data5=(50 51 52 53) 1.284 + subps xmm3,xmm4 ; xmm3=data3=(30 31 32 33) 1.285 + 1.286 + movaps xmm2,xmm7 ; transpose coefficients(phase 1) 1.287 + unpcklps xmm7,xmm3 ; xmm7=(20 30 21 31) 1.288 + unpckhps xmm2,xmm3 ; xmm2=(22 32 23 33) 1.289 + movaps xmm4,xmm5 ; transpose coefficients(phase 1) 1.290 + unpcklps xmm5,xmm0 ; xmm5=(40 50 41 51) 1.291 + unpckhps xmm4,xmm0 ; xmm4=(42 52 43 53) 1.292 + 1.293 + movaps xmm3,xmm6 ; transpose coefficients(phase 2) 1.294 + unpcklps2 xmm6,xmm7 ; xmm6=(00 10 20 30) 1.295 + unpckhps2 xmm3,xmm7 ; xmm3=(01 11 21 31) 1.296 + movaps xmm0,xmm1 ; transpose coefficients(phase 2) 1.297 + unpcklps2 xmm1,xmm2 ; xmm1=(02 12 22 32) 1.298 + unpckhps2 xmm0,xmm2 ; xmm0=(03 13 23 33) 1.299 + 1.300 + movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71) 1.301 + movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73) 1.302 + 1.303 + movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm6 1.304 + movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm3 1.305 + movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm1 1.306 + movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0 1.307 + 1.308 + movaps xmm6,xmm5 ; transpose coefficients(phase 2) 1.309 + unpcklps2 xmm5,xmm7 ; xmm5=(40 50 60 70) 1.310 + unpckhps2 xmm6,xmm7 ; xmm6=(41 51 61 71) 1.311 + movaps xmm3,xmm4 ; transpose coefficients(phase 2) 1.312 + unpcklps2 xmm4,xmm2 ; xmm4=(42 52 62 72) 1.313 + unpckhps2 xmm3,xmm2 ; xmm3=(43 53 63 73) 1.314 + 1.315 + movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5 1.316 + movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6 1.317 + movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm4 1.318 + movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3 1.319 + 1.320 +.nextcolumn: 1.321 + add esi, byte 4*SIZEOF_JCOEF ; coef_block 1.322 + add edx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr 1.323 + add edi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr 1.324 + dec ecx ; ctr 1.325 + jnz near .columnloop 1.326 + 1.327 + ; -- Prefetch the next coefficient block 1.328 + 1.329 + prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32] 1.330 + prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32] 1.331 + prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32] 1.332 + prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32] 1.333 + 1.334 + ; ---- Pass 2: process rows from work array, store into output array. 1.335 + 1.336 + mov eax, [original_ebp] 1.337 + lea esi, [workspace] ; FAST_FLOAT * wsptr 1.338 + mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) 1.339 + mov eax, JDIMENSION [output_col(eax)] 1.340 + mov ecx, DCTSIZE/4 ; ctr 1.341 + alignx 16,7 1.342 +.rowloop: 1.343 + 1.344 + ; -- Even part 1.345 + 1.346 + movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)] 1.347 + movaps xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)] 1.348 + movaps xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)] 1.349 + movaps xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)] 1.350 + 1.351 + movaps xmm4,xmm0 1.352 + movaps xmm5,xmm1 1.353 + subps xmm0,xmm2 ; xmm0=tmp11 1.354 + subps xmm1,xmm3 1.355 + addps xmm4,xmm2 ; xmm4=tmp10 1.356 + addps xmm5,xmm3 ; xmm5=tmp13 1.357 + 1.358 + mulps xmm1,[GOTOFF(ebx,PD_1_414)] 1.359 + subps xmm1,xmm5 ; xmm1=tmp12 1.360 + 1.361 + movaps xmm6,xmm4 1.362 + movaps xmm7,xmm0 1.363 + subps xmm4,xmm5 ; xmm4=tmp3 1.364 + subps xmm0,xmm1 ; xmm0=tmp2 1.365 + addps xmm6,xmm5 ; xmm6=tmp0 1.366 + addps xmm7,xmm1 ; xmm7=tmp1 1.367 + 1.368 + movaps XMMWORD [wk(1)], xmm4 ; tmp3 1.369 + movaps XMMWORD [wk(0)], xmm0 ; tmp2 1.370 + 1.371 + ; -- Odd part 1.372 + 1.373 + movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)] 1.374 + movaps xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)] 1.375 + movaps xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)] 1.376 + movaps xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)] 1.377 + 1.378 + movaps xmm4,xmm2 1.379 + movaps xmm0,xmm5 1.380 + addps xmm2,xmm1 ; xmm2=z11 1.381 + addps xmm5,xmm3 ; xmm5=z13 1.382 + subps xmm4,xmm1 ; xmm4=z12 1.383 + subps xmm0,xmm3 ; xmm0=z10 1.384 + 1.385 + movaps xmm1,xmm2 1.386 + subps xmm2,xmm5 1.387 + addps xmm1,xmm5 ; xmm1=tmp7 1.388 + 1.389 + mulps xmm2,[GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11 1.390 + 1.391 + movaps xmm3,xmm0 1.392 + addps xmm0,xmm4 1.393 + mulps xmm0,[GOTOFF(ebx,PD_1_847)] ; xmm0=z5 1.394 + mulps xmm3,[GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930) 1.395 + mulps xmm4,[GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200) 1.396 + addps xmm3,xmm0 ; xmm3=tmp12 1.397 + subps xmm4,xmm0 ; xmm4=tmp10 1.398 + 1.399 + ; -- Final output stage 1.400 + 1.401 + subps xmm3,xmm1 ; xmm3=tmp6 1.402 + movaps xmm5,xmm6 1.403 + movaps xmm0,xmm7 1.404 + addps xmm6,xmm1 ; xmm6=data0=(00 10 20 30) 1.405 + addps xmm7,xmm3 ; xmm7=data1=(01 11 21 31) 1.406 + subps xmm5,xmm1 ; xmm5=data7=(07 17 27 37) 1.407 + subps xmm0,xmm3 ; xmm0=data6=(06 16 26 36) 1.408 + subps xmm2,xmm3 ; xmm2=tmp5 1.409 + 1.410 + movaps xmm1,[GOTOFF(ebx,PD_RNDINT_MAGIC)] ; xmm1=[PD_RNDINT_MAGIC] 1.411 + pcmpeqd xmm3,xmm3 1.412 + psrld xmm3,WORD_BIT ; xmm3={0xFFFF 0x0000 0xFFFF 0x0000 ..} 1.413 + 1.414 + addps xmm6,xmm1 ; xmm6=roundint(data0/8)=(00 ** 10 ** 20 ** 30 **) 1.415 + addps xmm7,xmm1 ; xmm7=roundint(data1/8)=(01 ** 11 ** 21 ** 31 **) 1.416 + addps xmm0,xmm1 ; xmm0=roundint(data6/8)=(06 ** 16 ** 26 ** 36 **) 1.417 + addps xmm5,xmm1 ; xmm5=roundint(data7/8)=(07 ** 17 ** 27 ** 37 **) 1.418 + 1.419 + pand xmm6,xmm3 ; xmm6=(00 -- 10 -- 20 -- 30 --) 1.420 + pslld xmm7,WORD_BIT ; xmm7=(-- 01 -- 11 -- 21 -- 31) 1.421 + pand xmm0,xmm3 ; xmm0=(06 -- 16 -- 26 -- 36 --) 1.422 + pslld xmm5,WORD_BIT ; xmm5=(-- 07 -- 17 -- 27 -- 37) 1.423 + por xmm6,xmm7 ; xmm6=(00 01 10 11 20 21 30 31) 1.424 + por xmm0,xmm5 ; xmm0=(06 07 16 17 26 27 36 37) 1.425 + 1.426 + movaps xmm1, XMMWORD [wk(0)] ; xmm1=tmp2 1.427 + movaps xmm3, XMMWORD [wk(1)] ; xmm3=tmp3 1.428 + 1.429 + addps xmm4,xmm2 ; xmm4=tmp4 1.430 + movaps xmm7,xmm1 1.431 + movaps xmm5,xmm3 1.432 + addps xmm1,xmm2 ; xmm1=data2=(02 12 22 32) 1.433 + addps xmm3,xmm4 ; xmm3=data4=(04 14 24 34) 1.434 + subps xmm7,xmm2 ; xmm7=data5=(05 15 25 35) 1.435 + subps xmm5,xmm4 ; xmm5=data3=(03 13 23 33) 1.436 + 1.437 + movaps xmm2,[GOTOFF(ebx,PD_RNDINT_MAGIC)] ; xmm2=[PD_RNDINT_MAGIC] 1.438 + pcmpeqd xmm4,xmm4 1.439 + psrld xmm4,WORD_BIT ; xmm4={0xFFFF 0x0000 0xFFFF 0x0000 ..} 1.440 + 1.441 + addps xmm3,xmm2 ; xmm3=roundint(data4/8)=(04 ** 14 ** 24 ** 34 **) 1.442 + addps xmm7,xmm2 ; xmm7=roundint(data5/8)=(05 ** 15 ** 25 ** 35 **) 1.443 + addps xmm1,xmm2 ; xmm1=roundint(data2/8)=(02 ** 12 ** 22 ** 32 **) 1.444 + addps xmm5,xmm2 ; xmm5=roundint(data3/8)=(03 ** 13 ** 23 ** 33 **) 1.445 + 1.446 + pand xmm3,xmm4 ; xmm3=(04 -- 14 -- 24 -- 34 --) 1.447 + pslld xmm7,WORD_BIT ; xmm7=(-- 05 -- 15 -- 25 -- 35) 1.448 + pand xmm1,xmm4 ; xmm1=(02 -- 12 -- 22 -- 32 --) 1.449 + pslld xmm5,WORD_BIT ; xmm5=(-- 03 -- 13 -- 23 -- 33) 1.450 + por xmm3,xmm7 ; xmm3=(04 05 14 15 24 25 34 35) 1.451 + por xmm1,xmm5 ; xmm1=(02 03 12 13 22 23 32 33) 1.452 + 1.453 + movdqa xmm2,[GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm2=[PB_CENTERJSAMP] 1.454 + 1.455 + packsswb xmm6,xmm3 ; xmm6=(00 01 10 11 20 21 30 31 04 05 14 15 24 25 34 35) 1.456 + packsswb xmm1,xmm0 ; xmm1=(02 03 12 13 22 23 32 33 06 07 16 17 26 27 36 37) 1.457 + paddb xmm6,xmm2 1.458 + paddb xmm1,xmm2 1.459 + 1.460 + movdqa xmm4,xmm6 ; transpose coefficients(phase 2) 1.461 + punpcklwd xmm6,xmm1 ; xmm6=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) 1.462 + punpckhwd xmm4,xmm1 ; xmm4=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) 1.463 + 1.464 + movdqa xmm7,xmm6 ; transpose coefficients(phase 3) 1.465 + punpckldq xmm6,xmm4 ; xmm6=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) 1.466 + punpckhdq xmm7,xmm4 ; xmm7=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) 1.467 + 1.468 + pshufd xmm5,xmm6,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) 1.469 + pshufd xmm3,xmm7,0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) 1.470 + 1.471 + pushpic ebx ; save GOT address 1.472 + 1.473 + mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] 1.474 + mov ebx, JSAMPROW [edi+2*SIZEOF_JSAMPROW] 1.475 + movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6 1.476 + movq XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE], xmm7 1.477 + mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] 1.478 + mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW] 1.479 + movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm5 1.480 + movq XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE], xmm3 1.481 + 1.482 + poppic ebx ; restore GOT address 1.483 + 1.484 + add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr 1.485 + add edi, byte 4*SIZEOF_JSAMPROW 1.486 + dec ecx ; ctr 1.487 + jnz near .rowloop 1.488 + 1.489 + pop edi 1.490 + pop esi 1.491 +; pop edx ; need not be preserved 1.492 +; pop ecx ; need not be preserved 1.493 + pop ebx 1.494 + mov esp,ebp ; esp <- aligned ebp 1.495 + pop esp ; esp <- original ebp 1.496 + pop ebp 1.497 + ret 1.498 + 1.499 +; For some reason, the OS X linker does not honor the request to align the 1.500 +; segment unless we do this. 1.501 + align 16