1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libjpeg/simd/jdsamss2-64.asm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,671 @@ 1.4 +; 1.5 +; jdsamss2-64.asm - upsampling (64-bit 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 + 1.25 +; -------------------------------------------------------------------------- 1.26 + SECTION SEG_CONST 1.27 + 1.28 + alignz 16 1.29 + global EXTN(jconst_fancy_upsample_sse2) 1.30 + 1.31 +EXTN(jconst_fancy_upsample_sse2): 1.32 + 1.33 +PW_ONE times 8 dw 1 1.34 +PW_TWO times 8 dw 2 1.35 +PW_THREE times 8 dw 3 1.36 +PW_SEVEN times 8 dw 7 1.37 +PW_EIGHT times 8 dw 8 1.38 + 1.39 + alignz 16 1.40 + 1.41 +; -------------------------------------------------------------------------- 1.42 + SECTION SEG_TEXT 1.43 + BITS 64 1.44 +; 1.45 +; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. 1.46 +; 1.47 +; The upsampling algorithm is linear interpolation between pixel centers, 1.48 +; also known as a "triangle filter". This is a good compromise between 1.49 +; speed and visual quality. The centers of the output pixels are 1/4 and 3/4 1.50 +; of the way between input pixel centers. 1.51 +; 1.52 +; GLOBAL(void) 1.53 +; jsimd_h2v1_fancy_upsample_sse2 (int max_v_samp_factor, 1.54 +; JDIMENSION downsampled_width, 1.55 +; JSAMPARRAY input_data, 1.56 +; JSAMPARRAY * output_data_ptr); 1.57 +; 1.58 + 1.59 +; r10 = int max_v_samp_factor 1.60 +; r11 = JDIMENSION downsampled_width 1.61 +; r12 = JSAMPARRAY input_data 1.62 +; r13 = JSAMPARRAY * output_data_ptr 1.63 + 1.64 + align 16 1.65 + global EXTN(jsimd_h2v1_fancy_upsample_sse2) 1.66 + 1.67 +EXTN(jsimd_h2v1_fancy_upsample_sse2): 1.68 + push rbp 1.69 + mov rax,rsp 1.70 + mov rbp,rsp 1.71 + collect_args 1.72 + 1.73 + mov rax, r11 ; colctr 1.74 + test rax,rax 1.75 + jz near .return 1.76 + 1.77 + mov rcx, r10 ; rowctr 1.78 + test rcx,rcx 1.79 + jz near .return 1.80 + 1.81 + mov rsi, r12 ; input_data 1.82 + mov rdi, r13 1.83 + mov rdi, JSAMPARRAY [rdi] ; output_data 1.84 +.rowloop: 1.85 + push rax ; colctr 1.86 + push rdi 1.87 + push rsi 1.88 + 1.89 + mov rsi, JSAMPROW [rsi] ; inptr 1.90 + mov rdi, JSAMPROW [rdi] ; outptr 1.91 + 1.92 + test rax, SIZEOF_XMMWORD-1 1.93 + jz short .skip 1.94 + mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE] 1.95 + mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample 1.96 +.skip: 1.97 + pxor xmm0,xmm0 ; xmm0=(all 0's) 1.98 + pcmpeqb xmm7,xmm7 1.99 + psrldq xmm7,(SIZEOF_XMMWORD-1) 1.100 + pand xmm7, XMMWORD [rsi+0*SIZEOF_XMMWORD] 1.101 + 1.102 + add rax, byte SIZEOF_XMMWORD-1 1.103 + and rax, byte -SIZEOF_XMMWORD 1.104 + cmp rax, byte SIZEOF_XMMWORD 1.105 + ja short .columnloop 1.106 + 1.107 +.columnloop_last: 1.108 + pcmpeqb xmm6,xmm6 1.109 + pslldq xmm6,(SIZEOF_XMMWORD-1) 1.110 + pand xmm6, XMMWORD [rsi+0*SIZEOF_XMMWORD] 1.111 + jmp short .upsample 1.112 + 1.113 +.columnloop: 1.114 + movdqa xmm6, XMMWORD [rsi+1*SIZEOF_XMMWORD] 1.115 + pslldq xmm6,(SIZEOF_XMMWORD-1) 1.116 + 1.117 +.upsample: 1.118 + movdqa xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD] 1.119 + movdqa xmm2,xmm1 1.120 + movdqa xmm3,xmm1 ; xmm1=( 0 1 2 ... 13 14 15) 1.121 + pslldq xmm2,1 ; xmm2=(-- 0 1 ... 12 13 14) 1.122 + psrldq xmm3,1 ; xmm3=( 1 2 3 ... 14 15 --) 1.123 + 1.124 + por xmm2,xmm7 ; xmm2=(-1 0 1 ... 12 13 14) 1.125 + por xmm3,xmm6 ; xmm3=( 1 2 3 ... 14 15 16) 1.126 + 1.127 + movdqa xmm7,xmm1 1.128 + psrldq xmm7,(SIZEOF_XMMWORD-1) ; xmm7=(15 -- -- ... -- -- --) 1.129 + 1.130 + movdqa xmm4,xmm1 1.131 + punpcklbw xmm1,xmm0 ; xmm1=( 0 1 2 3 4 5 6 7) 1.132 + punpckhbw xmm4,xmm0 ; xmm4=( 8 9 10 11 12 13 14 15) 1.133 + movdqa xmm5,xmm2 1.134 + punpcklbw xmm2,xmm0 ; xmm2=(-1 0 1 2 3 4 5 6) 1.135 + punpckhbw xmm5,xmm0 ; xmm5=( 7 8 9 10 11 12 13 14) 1.136 + movdqa xmm6,xmm3 1.137 + punpcklbw xmm3,xmm0 ; xmm3=( 1 2 3 4 5 6 7 8) 1.138 + punpckhbw xmm6,xmm0 ; xmm6=( 9 10 11 12 13 14 15 16) 1.139 + 1.140 + pmullw xmm1,[rel PW_THREE] 1.141 + pmullw xmm4,[rel PW_THREE] 1.142 + paddw xmm2,[rel PW_ONE] 1.143 + paddw xmm5,[rel PW_ONE] 1.144 + paddw xmm3,[rel PW_TWO] 1.145 + paddw xmm6,[rel PW_TWO] 1.146 + 1.147 + paddw xmm2,xmm1 1.148 + paddw xmm5,xmm4 1.149 + psrlw xmm2,2 ; xmm2=OutLE=( 0 2 4 6 8 10 12 14) 1.150 + psrlw xmm5,2 ; xmm5=OutHE=(16 18 20 22 24 26 28 30) 1.151 + paddw xmm3,xmm1 1.152 + paddw xmm6,xmm4 1.153 + psrlw xmm3,2 ; xmm3=OutLO=( 1 3 5 7 9 11 13 15) 1.154 + psrlw xmm6,2 ; xmm6=OutHO=(17 19 21 23 25 27 29 31) 1.155 + 1.156 + psllw xmm3,BYTE_BIT 1.157 + psllw xmm6,BYTE_BIT 1.158 + por xmm2,xmm3 ; xmm2=OutL=( 0 1 2 ... 13 14 15) 1.159 + por xmm5,xmm6 ; xmm5=OutH=(16 17 18 ... 29 30 31) 1.160 + 1.161 + movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm2 1.162 + movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm5 1.163 + 1.164 + sub rax, byte SIZEOF_XMMWORD 1.165 + add rsi, byte 1*SIZEOF_XMMWORD ; inptr 1.166 + add rdi, byte 2*SIZEOF_XMMWORD ; outptr 1.167 + cmp rax, byte SIZEOF_XMMWORD 1.168 + ja near .columnloop 1.169 + test eax,eax 1.170 + jnz near .columnloop_last 1.171 + 1.172 + pop rsi 1.173 + pop rdi 1.174 + pop rax 1.175 + 1.176 + add rsi, byte SIZEOF_JSAMPROW ; input_data 1.177 + add rdi, byte SIZEOF_JSAMPROW ; output_data 1.178 + dec rcx ; rowctr 1.179 + jg near .rowloop 1.180 + 1.181 +.return: 1.182 + uncollect_args 1.183 + pop rbp 1.184 + ret 1.185 + 1.186 +; -------------------------------------------------------------------------- 1.187 +; 1.188 +; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. 1.189 +; Again a triangle filter; see comments for h2v1 case, above. 1.190 +; 1.191 +; GLOBAL(void) 1.192 +; jsimd_h2v2_fancy_upsample_sse2 (int max_v_samp_factor, 1.193 +; JDIMENSION downsampled_width, 1.194 +; JSAMPARRAY input_data, 1.195 +; JSAMPARRAY * output_data_ptr); 1.196 +; 1.197 + 1.198 +; r10 = int max_v_samp_factor 1.199 +; r11 = JDIMENSION downsampled_width 1.200 +; r12 = JSAMPARRAY input_data 1.201 +; r13 = JSAMPARRAY * output_data_ptr 1.202 + 1.203 +%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] 1.204 +%define WK_NUM 4 1.205 + 1.206 + align 16 1.207 + global EXTN(jsimd_h2v2_fancy_upsample_sse2) 1.208 + 1.209 +EXTN(jsimd_h2v2_fancy_upsample_sse2): 1.210 + push rbp 1.211 + mov rax,rsp ; rax = original rbp 1.212 + sub rsp, byte 4 1.213 + and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits 1.214 + mov [rsp],rax 1.215 + mov rbp,rsp ; rbp = aligned rbp 1.216 + lea rsp, [wk(0)] 1.217 + collect_args 1.218 + push rbx 1.219 + 1.220 + mov rax, r11 ; colctr 1.221 + test rax,rax 1.222 + jz near .return 1.223 + 1.224 + mov rcx, r10 ; rowctr 1.225 + test rcx,rcx 1.226 + jz near .return 1.227 + 1.228 + mov rsi, r12 ; input_data 1.229 + mov rdi, r13 1.230 + mov rdi, JSAMPARRAY [rdi] ; output_data 1.231 +.rowloop: 1.232 + push rax ; colctr 1.233 + push rcx 1.234 + push rdi 1.235 + push rsi 1.236 + 1.237 + mov rcx, JSAMPROW [rsi-1*SIZEOF_JSAMPROW] ; inptr1(above) 1.238 + mov rbx, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; inptr0 1.239 + mov rsi, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; inptr1(below) 1.240 + mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0 1.241 + mov rdi, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1 1.242 + 1.243 + test rax, SIZEOF_XMMWORD-1 1.244 + jz short .skip 1.245 + push rdx 1.246 + mov dl, JSAMPLE [rcx+(rax-1)*SIZEOF_JSAMPLE] 1.247 + mov JSAMPLE [rcx+rax*SIZEOF_JSAMPLE], dl 1.248 + mov dl, JSAMPLE [rbx+(rax-1)*SIZEOF_JSAMPLE] 1.249 + mov JSAMPLE [rbx+rax*SIZEOF_JSAMPLE], dl 1.250 + mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE] 1.251 + mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample 1.252 + pop rdx 1.253 +.skip: 1.254 + ; -- process the first column block 1.255 + 1.256 + movdqa xmm0, XMMWORD [rbx+0*SIZEOF_XMMWORD] ; xmm0=row[ 0][0] 1.257 + movdqa xmm1, XMMWORD [rcx+0*SIZEOF_XMMWORD] ; xmm1=row[-1][0] 1.258 + movdqa xmm2, XMMWORD [rsi+0*SIZEOF_XMMWORD] ; xmm2=row[+1][0] 1.259 + 1.260 + pxor xmm3,xmm3 ; xmm3=(all 0's) 1.261 + movdqa xmm4,xmm0 1.262 + punpcklbw xmm0,xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7) 1.263 + punpckhbw xmm4,xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15) 1.264 + movdqa xmm5,xmm1 1.265 + punpcklbw xmm1,xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7) 1.266 + punpckhbw xmm5,xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15) 1.267 + movdqa xmm6,xmm2 1.268 + punpcklbw xmm2,xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7) 1.269 + punpckhbw xmm6,xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15) 1.270 + 1.271 + pmullw xmm0,[rel PW_THREE] 1.272 + pmullw xmm4,[rel PW_THREE] 1.273 + 1.274 + pcmpeqb xmm7,xmm7 1.275 + psrldq xmm7,(SIZEOF_XMMWORD-2) 1.276 + 1.277 + paddw xmm1,xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7) 1.278 + paddw xmm5,xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15) 1.279 + paddw xmm2,xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7) 1.280 + paddw xmm6,xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15) 1.281 + 1.282 + movdqa XMMWORD [rdx+0*SIZEOF_XMMWORD], xmm1 ; temporarily save 1.283 + movdqa XMMWORD [rdx+1*SIZEOF_XMMWORD], xmm5 ; the intermediate data 1.284 + movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm2 1.285 + movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm6 1.286 + 1.287 + pand xmm1,xmm7 ; xmm1=( 0 -- -- -- -- -- -- --) 1.288 + pand xmm2,xmm7 ; xmm2=( 0 -- -- -- -- -- -- --) 1.289 + 1.290 + movdqa XMMWORD [wk(0)], xmm1 1.291 + movdqa XMMWORD [wk(1)], xmm2 1.292 + 1.293 + add rax, byte SIZEOF_XMMWORD-1 1.294 + and rax, byte -SIZEOF_XMMWORD 1.295 + cmp rax, byte SIZEOF_XMMWORD 1.296 + ja short .columnloop 1.297 + 1.298 +.columnloop_last: 1.299 + ; -- process the last column block 1.300 + 1.301 + pcmpeqb xmm1,xmm1 1.302 + pslldq xmm1,(SIZEOF_XMMWORD-2) 1.303 + movdqa xmm2,xmm1 1.304 + 1.305 + pand xmm1, XMMWORD [rdx+1*SIZEOF_XMMWORD] 1.306 + pand xmm2, XMMWORD [rdi+1*SIZEOF_XMMWORD] 1.307 + 1.308 + movdqa XMMWORD [wk(2)], xmm1 ; xmm1=(-- -- -- -- -- -- -- 15) 1.309 + movdqa XMMWORD [wk(3)], xmm2 ; xmm2=(-- -- -- -- -- -- -- 15) 1.310 + 1.311 + jmp near .upsample 1.312 + 1.313 +.columnloop: 1.314 + ; -- process the next column block 1.315 + 1.316 + movdqa xmm0, XMMWORD [rbx+1*SIZEOF_XMMWORD] ; xmm0=row[ 0][1] 1.317 + movdqa xmm1, XMMWORD [rcx+1*SIZEOF_XMMWORD] ; xmm1=row[-1][1] 1.318 + movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] ; xmm2=row[+1][1] 1.319 + 1.320 + pxor xmm3,xmm3 ; xmm3=(all 0's) 1.321 + movdqa xmm4,xmm0 1.322 + punpcklbw xmm0,xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7) 1.323 + punpckhbw xmm4,xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15) 1.324 + movdqa xmm5,xmm1 1.325 + punpcklbw xmm1,xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7) 1.326 + punpckhbw xmm5,xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15) 1.327 + movdqa xmm6,xmm2 1.328 + punpcklbw xmm2,xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7) 1.329 + punpckhbw xmm6,xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15) 1.330 + 1.331 + pmullw xmm0,[rel PW_THREE] 1.332 + pmullw xmm4,[rel PW_THREE] 1.333 + 1.334 + paddw xmm1,xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7) 1.335 + paddw xmm5,xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15) 1.336 + paddw xmm2,xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7) 1.337 + paddw xmm6,xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15) 1.338 + 1.339 + movdqa XMMWORD [rdx+2*SIZEOF_XMMWORD], xmm1 ; temporarily save 1.340 + movdqa XMMWORD [rdx+3*SIZEOF_XMMWORD], xmm5 ; the intermediate data 1.341 + movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 1.342 + movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm6 1.343 + 1.344 + pslldq xmm1,(SIZEOF_XMMWORD-2) ; xmm1=(-- -- -- -- -- -- -- 0) 1.345 + pslldq xmm2,(SIZEOF_XMMWORD-2) ; xmm2=(-- -- -- -- -- -- -- 0) 1.346 + 1.347 + movdqa XMMWORD [wk(2)], xmm1 1.348 + movdqa XMMWORD [wk(3)], xmm2 1.349 + 1.350 +.upsample: 1.351 + ; -- process the upper row 1.352 + 1.353 + movdqa xmm7, XMMWORD [rdx+0*SIZEOF_XMMWORD] 1.354 + movdqa xmm3, XMMWORD [rdx+1*SIZEOF_XMMWORD] 1.355 + 1.356 + movdqa xmm0,xmm7 ; xmm7=Int0L=( 0 1 2 3 4 5 6 7) 1.357 + movdqa xmm4,xmm3 ; xmm3=Int0H=( 8 9 10 11 12 13 14 15) 1.358 + psrldq xmm0,2 ; xmm0=( 1 2 3 4 5 6 7 --) 1.359 + pslldq xmm4,(SIZEOF_XMMWORD-2) ; xmm4=(-- -- -- -- -- -- -- 8) 1.360 + movdqa xmm5,xmm7 1.361 + movdqa xmm6,xmm3 1.362 + psrldq xmm5,(SIZEOF_XMMWORD-2) ; xmm5=( 7 -- -- -- -- -- -- --) 1.363 + pslldq xmm6,2 ; xmm6=(-- 8 9 10 11 12 13 14) 1.364 + 1.365 + por xmm0,xmm4 ; xmm0=( 1 2 3 4 5 6 7 8) 1.366 + por xmm5,xmm6 ; xmm5=( 7 8 9 10 11 12 13 14) 1.367 + 1.368 + movdqa xmm1,xmm7 1.369 + movdqa xmm2,xmm3 1.370 + pslldq xmm1,2 ; xmm1=(-- 0 1 2 3 4 5 6) 1.371 + psrldq xmm2,2 ; xmm2=( 9 10 11 12 13 14 15 --) 1.372 + movdqa xmm4,xmm3 1.373 + psrldq xmm4,(SIZEOF_XMMWORD-2) ; xmm4=(15 -- -- -- -- -- -- --) 1.374 + 1.375 + por xmm1, XMMWORD [wk(0)] ; xmm1=(-1 0 1 2 3 4 5 6) 1.376 + por xmm2, XMMWORD [wk(2)] ; xmm2=( 9 10 11 12 13 14 15 16) 1.377 + 1.378 + movdqa XMMWORD [wk(0)], xmm4 1.379 + 1.380 + pmullw xmm7,[rel PW_THREE] 1.381 + pmullw xmm3,[rel PW_THREE] 1.382 + paddw xmm1,[rel PW_EIGHT] 1.383 + paddw xmm5,[rel PW_EIGHT] 1.384 + paddw xmm0,[rel PW_SEVEN] 1.385 + paddw xmm2,[rel PW_SEVEN] 1.386 + 1.387 + paddw xmm1,xmm7 1.388 + paddw xmm5,xmm3 1.389 + psrlw xmm1,4 ; xmm1=Out0LE=( 0 2 4 6 8 10 12 14) 1.390 + psrlw xmm5,4 ; xmm5=Out0HE=(16 18 20 22 24 26 28 30) 1.391 + paddw xmm0,xmm7 1.392 + paddw xmm2,xmm3 1.393 + psrlw xmm0,4 ; xmm0=Out0LO=( 1 3 5 7 9 11 13 15) 1.394 + psrlw xmm2,4 ; xmm2=Out0HO=(17 19 21 23 25 27 29 31) 1.395 + 1.396 + psllw xmm0,BYTE_BIT 1.397 + psllw xmm2,BYTE_BIT 1.398 + por xmm1,xmm0 ; xmm1=Out0L=( 0 1 2 ... 13 14 15) 1.399 + por xmm5,xmm2 ; xmm5=Out0H=(16 17 18 ... 29 30 31) 1.400 + 1.401 + movdqa XMMWORD [rdx+0*SIZEOF_XMMWORD], xmm1 1.402 + movdqa XMMWORD [rdx+1*SIZEOF_XMMWORD], xmm5 1.403 + 1.404 + ; -- process the lower row 1.405 + 1.406 + movdqa xmm6, XMMWORD [rdi+0*SIZEOF_XMMWORD] 1.407 + movdqa xmm4, XMMWORD [rdi+1*SIZEOF_XMMWORD] 1.408 + 1.409 + movdqa xmm7,xmm6 ; xmm6=Int1L=( 0 1 2 3 4 5 6 7) 1.410 + movdqa xmm3,xmm4 ; xmm4=Int1H=( 8 9 10 11 12 13 14 15) 1.411 + psrldq xmm7,2 ; xmm7=( 1 2 3 4 5 6 7 --) 1.412 + pslldq xmm3,(SIZEOF_XMMWORD-2) ; xmm3=(-- -- -- -- -- -- -- 8) 1.413 + movdqa xmm0,xmm6 1.414 + movdqa xmm2,xmm4 1.415 + psrldq xmm0,(SIZEOF_XMMWORD-2) ; xmm0=( 7 -- -- -- -- -- -- --) 1.416 + pslldq xmm2,2 ; xmm2=(-- 8 9 10 11 12 13 14) 1.417 + 1.418 + por xmm7,xmm3 ; xmm7=( 1 2 3 4 5 6 7 8) 1.419 + por xmm0,xmm2 ; xmm0=( 7 8 9 10 11 12 13 14) 1.420 + 1.421 + movdqa xmm1,xmm6 1.422 + movdqa xmm5,xmm4 1.423 + pslldq xmm1,2 ; xmm1=(-- 0 1 2 3 4 5 6) 1.424 + psrldq xmm5,2 ; xmm5=( 9 10 11 12 13 14 15 --) 1.425 + movdqa xmm3,xmm4 1.426 + psrldq xmm3,(SIZEOF_XMMWORD-2) ; xmm3=(15 -- -- -- -- -- -- --) 1.427 + 1.428 + por xmm1, XMMWORD [wk(1)] ; xmm1=(-1 0 1 2 3 4 5 6) 1.429 + por xmm5, XMMWORD [wk(3)] ; xmm5=( 9 10 11 12 13 14 15 16) 1.430 + 1.431 + movdqa XMMWORD [wk(1)], xmm3 1.432 + 1.433 + pmullw xmm6,[rel PW_THREE] 1.434 + pmullw xmm4,[rel PW_THREE] 1.435 + paddw xmm1,[rel PW_EIGHT] 1.436 + paddw xmm0,[rel PW_EIGHT] 1.437 + paddw xmm7,[rel PW_SEVEN] 1.438 + paddw xmm5,[rel PW_SEVEN] 1.439 + 1.440 + paddw xmm1,xmm6 1.441 + paddw xmm0,xmm4 1.442 + psrlw xmm1,4 ; xmm1=Out1LE=( 0 2 4 6 8 10 12 14) 1.443 + psrlw xmm0,4 ; xmm0=Out1HE=(16 18 20 22 24 26 28 30) 1.444 + paddw xmm7,xmm6 1.445 + paddw xmm5,xmm4 1.446 + psrlw xmm7,4 ; xmm7=Out1LO=( 1 3 5 7 9 11 13 15) 1.447 + psrlw xmm5,4 ; xmm5=Out1HO=(17 19 21 23 25 27 29 31) 1.448 + 1.449 + psllw xmm7,BYTE_BIT 1.450 + psllw xmm5,BYTE_BIT 1.451 + por xmm1,xmm7 ; xmm1=Out1L=( 0 1 2 ... 13 14 15) 1.452 + por xmm0,xmm5 ; xmm0=Out1H=(16 17 18 ... 29 30 31) 1.453 + 1.454 + movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm1 1.455 + movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm0 1.456 + 1.457 + sub rax, byte SIZEOF_XMMWORD 1.458 + add rcx, byte 1*SIZEOF_XMMWORD ; inptr1(above) 1.459 + add rbx, byte 1*SIZEOF_XMMWORD ; inptr0 1.460 + add rsi, byte 1*SIZEOF_XMMWORD ; inptr1(below) 1.461 + add rdx, byte 2*SIZEOF_XMMWORD ; outptr0 1.462 + add rdi, byte 2*SIZEOF_XMMWORD ; outptr1 1.463 + cmp rax, byte SIZEOF_XMMWORD 1.464 + ja near .columnloop 1.465 + test rax,rax 1.466 + jnz near .columnloop_last 1.467 + 1.468 + pop rsi 1.469 + pop rdi 1.470 + pop rcx 1.471 + pop rax 1.472 + 1.473 + add rsi, byte 1*SIZEOF_JSAMPROW ; input_data 1.474 + add rdi, byte 2*SIZEOF_JSAMPROW ; output_data 1.475 + sub rcx, byte 2 ; rowctr 1.476 + jg near .rowloop 1.477 + 1.478 +.return: 1.479 + pop rbx 1.480 + uncollect_args 1.481 + mov rsp,rbp ; rsp <- aligned rbp 1.482 + pop rsp ; rsp <- original rbp 1.483 + pop rbp 1.484 + ret 1.485 + 1.486 +; -------------------------------------------------------------------------- 1.487 +; 1.488 +; Fast processing for the common case of 2:1 horizontal and 1:1 vertical. 1.489 +; It's still a box filter. 1.490 +; 1.491 +; GLOBAL(void) 1.492 +; jsimd_h2v1_upsample_sse2 (int max_v_samp_factor, 1.493 +; JDIMENSION output_width, 1.494 +; JSAMPARRAY input_data, 1.495 +; JSAMPARRAY * output_data_ptr); 1.496 +; 1.497 + 1.498 +; r10 = int max_v_samp_factor 1.499 +; r11 = JDIMENSION output_width 1.500 +; r12 = JSAMPARRAY input_data 1.501 +; r13 = JSAMPARRAY * output_data_ptr 1.502 + 1.503 + align 16 1.504 + global EXTN(jsimd_h2v1_upsample_sse2) 1.505 + 1.506 +EXTN(jsimd_h2v1_upsample_sse2): 1.507 + push rbp 1.508 + mov rax,rsp 1.509 + mov rbp,rsp 1.510 + collect_args 1.511 + 1.512 + mov rdx, r11 1.513 + add rdx, byte (2*SIZEOF_XMMWORD)-1 1.514 + and rdx, byte -(2*SIZEOF_XMMWORD) 1.515 + jz near .return 1.516 + 1.517 + mov rcx, r10 ; rowctr 1.518 + test rcx,rcx 1.519 + jz short .return 1.520 + 1.521 + mov rsi, r12 ; input_data 1.522 + mov rdi, r13 1.523 + mov rdi, JSAMPARRAY [rdi] ; output_data 1.524 +.rowloop: 1.525 + push rdi 1.526 + push rsi 1.527 + 1.528 + mov rsi, JSAMPROW [rsi] ; inptr 1.529 + mov rdi, JSAMPROW [rdi] ; outptr 1.530 + mov rax,rdx ; colctr 1.531 +.columnloop: 1.532 + 1.533 + movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD] 1.534 + 1.535 + movdqa xmm1,xmm0 1.536 + punpcklbw xmm0,xmm0 1.537 + punpckhbw xmm1,xmm1 1.538 + 1.539 + movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0 1.540 + movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1 1.541 + 1.542 + sub rax, byte 2*SIZEOF_XMMWORD 1.543 + jz short .nextrow 1.544 + 1.545 + movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] 1.546 + 1.547 + movdqa xmm3,xmm2 1.548 + punpcklbw xmm2,xmm2 1.549 + punpckhbw xmm3,xmm3 1.550 + 1.551 + movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 1.552 + movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm3 1.553 + 1.554 + sub rax, byte 2*SIZEOF_XMMWORD 1.555 + jz short .nextrow 1.556 + 1.557 + add rsi, byte 2*SIZEOF_XMMWORD ; inptr 1.558 + add rdi, byte 4*SIZEOF_XMMWORD ; outptr 1.559 + jmp short .columnloop 1.560 + 1.561 +.nextrow: 1.562 + pop rsi 1.563 + pop rdi 1.564 + 1.565 + add rsi, byte SIZEOF_JSAMPROW ; input_data 1.566 + add rdi, byte SIZEOF_JSAMPROW ; output_data 1.567 + dec rcx ; rowctr 1.568 + jg short .rowloop 1.569 + 1.570 +.return: 1.571 + uncollect_args 1.572 + pop rbp 1.573 + ret 1.574 + 1.575 +; -------------------------------------------------------------------------- 1.576 +; 1.577 +; Fast processing for the common case of 2:1 horizontal and 2:1 vertical. 1.578 +; It's still a box filter. 1.579 +; 1.580 +; GLOBAL(void) 1.581 +; jsimd_h2v2_upsample_sse2 (nt max_v_samp_factor, 1.582 +; JDIMENSION output_width, 1.583 +; JSAMPARRAY input_data, 1.584 +; JSAMPARRAY * output_data_ptr); 1.585 +; 1.586 + 1.587 +; r10 = int max_v_samp_factor 1.588 +; r11 = JDIMENSION output_width 1.589 +; r12 = JSAMPARRAY input_data 1.590 +; r13 = JSAMPARRAY * output_data_ptr 1.591 + 1.592 + align 16 1.593 + global EXTN(jsimd_h2v2_upsample_sse2) 1.594 + 1.595 +EXTN(jsimd_h2v2_upsample_sse2): 1.596 + push rbp 1.597 + mov rax,rsp 1.598 + mov rbp,rsp 1.599 + collect_args 1.600 + push rbx 1.601 + 1.602 + mov rdx, r11 1.603 + add rdx, byte (2*SIZEOF_XMMWORD)-1 1.604 + and rdx, byte -(2*SIZEOF_XMMWORD) 1.605 + jz near .return 1.606 + 1.607 + mov rcx, r10 ; rowctr 1.608 + test rcx,rcx 1.609 + jz near .return 1.610 + 1.611 + mov rsi, r12 ; input_data 1.612 + mov rdi, r13 1.613 + mov rdi, JSAMPARRAY [rdi] ; output_data 1.614 +.rowloop: 1.615 + push rdi 1.616 + push rsi 1.617 + 1.618 + mov rsi, JSAMPROW [rsi] ; inptr 1.619 + mov rbx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0 1.620 + mov rdi, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1 1.621 + mov rax,rdx ; colctr 1.622 +.columnloop: 1.623 + 1.624 + movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD] 1.625 + 1.626 + movdqa xmm1,xmm0 1.627 + punpcklbw xmm0,xmm0 1.628 + punpckhbw xmm1,xmm1 1.629 + 1.630 + movdqa XMMWORD [rbx+0*SIZEOF_XMMWORD], xmm0 1.631 + movdqa XMMWORD [rbx+1*SIZEOF_XMMWORD], xmm1 1.632 + movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0 1.633 + movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1 1.634 + 1.635 + sub rax, byte 2*SIZEOF_XMMWORD 1.636 + jz short .nextrow 1.637 + 1.638 + movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] 1.639 + 1.640 + movdqa xmm3,xmm2 1.641 + punpcklbw xmm2,xmm2 1.642 + punpckhbw xmm3,xmm3 1.643 + 1.644 + movdqa XMMWORD [rbx+2*SIZEOF_XMMWORD], xmm2 1.645 + movdqa XMMWORD [rbx+3*SIZEOF_XMMWORD], xmm3 1.646 + movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 1.647 + movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm3 1.648 + 1.649 + sub rax, byte 2*SIZEOF_XMMWORD 1.650 + jz short .nextrow 1.651 + 1.652 + add rsi, byte 2*SIZEOF_XMMWORD ; inptr 1.653 + add rbx, byte 4*SIZEOF_XMMWORD ; outptr0 1.654 + add rdi, byte 4*SIZEOF_XMMWORD ; outptr1 1.655 + jmp short .columnloop 1.656 + 1.657 +.nextrow: 1.658 + pop rsi 1.659 + pop rdi 1.660 + 1.661 + add rsi, byte 1*SIZEOF_JSAMPROW ; input_data 1.662 + add rdi, byte 2*SIZEOF_JSAMPROW ; output_data 1.663 + sub rcx, byte 2 ; rowctr 1.664 + jg near .rowloop 1.665 + 1.666 +.return: 1.667 + pop rbx 1.668 + uncollect_args 1.669 + pop rbp 1.670 + ret 1.671 + 1.672 +; For some reason, the OS X linker does not honor the request to align the 1.673 +; segment unless we do this. 1.674 + align 16