Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/libjpeg_turbo/simd/jdmrgss2.asm

Issue 4134011: Adds libjpeg-turbo to deps... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 ;
2 ; jdmrgss2.asm - merged upsampling/color conversion (SSE2)
3 ;
4 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
5 ;
6 ; Based on
7 ; x86 SIMD extension for IJG JPEG library
8 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
9 ; For conditions of distribution and use, see copyright notice in jsimdext.inc
10 ;
11 ; This file should be assembled with NASM (Netwide Assembler),
12 ; can *not* be assembled with Microsoft's MASM or any compatible
13 ; assembler (including Borland's Turbo Assembler).
14 ; NASM is available from http://nasm.sourceforge.net/ or
15 ; http://sourceforge.net/project/showfiles.php?group_id=6208
16 ;
17 ; [TAB8]
18
19 %include "jcolsamp.inc"
20
21 ; --------------------------------------------------------------------------
22 SECTION SEG_TEXT
23 BITS 32
24 ;
25 ; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
26 ;
27 ; GLOBAL(void)
28 ; jsimd_h2v1_merged_upsample_sse2 (JDIMENSION output_width,
29 ; JSAMPIMAGE input_buf,
30 ; JDIMENSION in_row_group_ctr,
31 ; JSAMPARRAY output_buf);
32 ;
33
34 %define output_width(b) (b)+8 ; JDIMENSION output_width
35 %define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf
36 %define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr
37 %define output_buf(b) (b)+20 ; JSAMPARRAY output_buf
38
39 %define original_ebp ebp+0
40 %define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
41 %define WK_NUM 3
42 %define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr
43
44 align 16
45 global EXTN(jsimd_h2v1_merged_upsample_sse2)
46
47 EXTN(jsimd_h2v1_merged_upsample_sse2):
48 push ebp
49 mov eax,esp ; eax = original ebp
50 sub esp, byte 4
51 and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
52 mov [esp],eax
53 mov ebp,esp ; ebp = aligned ebp
54 lea esp, [wk(0)]
55 pushpic eax ; make a room for GOT address
56 push ebx
57 ; push ecx ; need not be preserved
58 ; push edx ; need not be preserved
59 push esi
60 push edi
61
62 get_GOT ebx ; get GOT address
63 movpic POINTER [gotptr], ebx ; save GOT address
64
65 mov ecx, JDIMENSION [output_width(eax)] ; col
66 test ecx,ecx
67 jz near .return
68
69 push ecx
70
71 mov edi, JSAMPIMAGE [input_buf(eax)]
72 mov ecx, JDIMENSION [in_row_group_ctr(eax)]
73 mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
74 mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
75 mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
76 mov edi, JSAMPARRAY [output_buf(eax)]
77 mov esi, JSAMPROW [esi+ecx*SIZEOF_JSAMPROW] ; inptr0
78 mov ebx, JSAMPROW [ebx+ecx*SIZEOF_JSAMPROW] ; inptr1
79 mov edx, JSAMPROW [edx+ecx*SIZEOF_JSAMPROW] ; inptr2
80 mov edi, JSAMPROW [edi] ; outptr
81
82 pop ecx ; col
83
84 alignx 16,7
85 .columnloop:
86 movpic eax, POINTER [gotptr] ; load GOT address (eax)
87
88 movdqa xmm6, XMMWORD [ebx] ; xmm6=Cb(0123456789ABCDEF)
89 movdqa xmm7, XMMWORD [edx] ; xmm7=Cr(0123456789ABCDEF)
90
91 pxor xmm1,xmm1 ; xmm1=(all 0's)
92 pcmpeqw xmm3,xmm3
93 psllw xmm3,7 ; xmm3={0xFF80 0xFF80 0xFF80 0xFF80 ..}
94
95 movdqa xmm4,xmm6
96 punpckhbw xmm6,xmm1 ; xmm6=Cb(89ABCDEF)=CbH
97 punpcklbw xmm4,xmm1 ; xmm4=Cb(01234567)=CbL
98 movdqa xmm0,xmm7
99 punpckhbw xmm7,xmm1 ; xmm7=Cr(89ABCDEF)=CrH
100 punpcklbw xmm0,xmm1 ; xmm0=Cr(01234567)=CrL
101
102 paddw xmm6,xmm3
103 paddw xmm4,xmm3
104 paddw xmm7,xmm3
105 paddw xmm0,xmm3
106
107 ; (Original)
108 ; R = Y + 1.40200 * Cr
109 ; G = Y - 0.34414 * Cb - 0.71414 * Cr
110 ; B = Y + 1.77200 * Cb
111 ;
112 ; (This implementation)
113 ; R = Y + 0.40200 * Cr + Cr
114 ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
115 ; B = Y - 0.22800 * Cb + Cb + Cb
116
117 movdqa xmm5,xmm6 ; xmm5=CbH
118 movdqa xmm2,xmm4 ; xmm2=CbL
119 paddw xmm6,xmm6 ; xmm6=2*CbH
120 paddw xmm4,xmm4 ; xmm4=2*CbL
121 movdqa xmm1,xmm7 ; xmm1=CrH
122 movdqa xmm3,xmm0 ; xmm3=CrL
123 paddw xmm7,xmm7 ; xmm7=2*CrH
124 paddw xmm0,xmm0 ; xmm0=2*CrL
125
126 pmulhw xmm6,[GOTOFF(eax,PW_MF0228)] ; xmm6=(2*CbH * -FIX(0.22800))
127 pmulhw xmm4,[GOTOFF(eax,PW_MF0228)] ; xmm4=(2*CbL * -FIX(0.22800))
128 pmulhw xmm7,[GOTOFF(eax,PW_F0402)] ; xmm7=(2*CrH * FIX(0.40200))
129 pmulhw xmm0,[GOTOFF(eax,PW_F0402)] ; xmm0=(2*CrL * FIX(0.40200))
130
131 paddw xmm6,[GOTOFF(eax,PW_ONE)]
132 paddw xmm4,[GOTOFF(eax,PW_ONE)]
133 psraw xmm6,1 ; xmm6=(CbH * -FIX(0.22800))
134 psraw xmm4,1 ; xmm4=(CbL * -FIX(0.22800))
135 paddw xmm7,[GOTOFF(eax,PW_ONE)]
136 paddw xmm0,[GOTOFF(eax,PW_ONE)]
137 psraw xmm7,1 ; xmm7=(CrH * FIX(0.40200))
138 psraw xmm0,1 ; xmm0=(CrL * FIX(0.40200))
139
140 paddw xmm6,xmm5
141 paddw xmm4,xmm2
142 paddw xmm6,xmm5 ; xmm6=(CbH * FIX(1.77200))=(B-Y)H
143 paddw xmm4,xmm2 ; xmm4=(CbL * FIX(1.77200))=(B-Y)L
144 paddw xmm7,xmm1 ; xmm7=(CrH * FIX(1.40200))=(R-Y)H
145 paddw xmm0,xmm3 ; xmm0=(CrL * FIX(1.40200))=(R-Y)L
146
147 movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=(B-Y)H
148 movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(R-Y)H
149
150 movdqa xmm6,xmm5
151 movdqa xmm7,xmm2
152 punpcklwd xmm5,xmm1
153 punpckhwd xmm6,xmm1
154 pmaddwd xmm5,[GOTOFF(eax,PW_MF0344_F0285)]
155 pmaddwd xmm6,[GOTOFF(eax,PW_MF0344_F0285)]
156 punpcklwd xmm2,xmm3
157 punpckhwd xmm7,xmm3
158 pmaddwd xmm2,[GOTOFF(eax,PW_MF0344_F0285)]
159 pmaddwd xmm7,[GOTOFF(eax,PW_MF0344_F0285)]
160
161 paddd xmm5,[GOTOFF(eax,PD_ONEHALF)]
162 paddd xmm6,[GOTOFF(eax,PD_ONEHALF)]
163 psrad xmm5,SCALEBITS
164 psrad xmm6,SCALEBITS
165 paddd xmm2,[GOTOFF(eax,PD_ONEHALF)]
166 paddd xmm7,[GOTOFF(eax,PD_ONEHALF)]
167 psrad xmm2,SCALEBITS
168 psrad xmm7,SCALEBITS
169
170 packssdw xmm5,xmm6 ; xmm5=CbH*-FIX(0.344)+CrH*FIX(0.285)
171 packssdw xmm2,xmm7 ; xmm2=CbL*-FIX(0.344)+CrL*FIX(0.285)
172 psubw xmm5,xmm1 ; xmm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H
173 psubw xmm2,xmm3 ; xmm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L
174
175 movdqa XMMWORD [wk(2)], xmm5 ; wk(2)=(G-Y)H
176
177 mov al,2 ; Yctr
178 jmp short .Yloop_1st
179 alignx 16,7
180
181 .Yloop_2nd:
182 movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(R-Y)H
183 movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(G-Y)H
184 movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(B-Y)H
185 alignx 16,7
186
187 .Yloop_1st:
188 movdqa xmm7, XMMWORD [esi] ; xmm7=Y(0123456789ABCDEF)
189
190 pcmpeqw xmm6,xmm6
191 psrlw xmm6,BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
192 pand xmm6,xmm7 ; xmm6=Y(02468ACE)=YE
193 psrlw xmm7,BYTE_BIT ; xmm7=Y(13579BDF)=YO
194
195 movdqa xmm1,xmm0 ; xmm1=xmm0=(R-Y)(L/H)
196 movdqa xmm3,xmm2 ; xmm3=xmm2=(G-Y)(L/H)
197 movdqa xmm5,xmm4 ; xmm5=xmm4=(B-Y)(L/H)
198
199 paddw xmm0,xmm6 ; xmm0=((R-Y)+YE)=RE=R(02468ACE)
200 paddw xmm1,xmm7 ; xmm1=((R-Y)+YO)=RO=R(13579BDF)
201 packuswb xmm0,xmm0 ; xmm0=R(02468ACE********)
202 packuswb xmm1,xmm1 ; xmm1=R(13579BDF********)
203
204 paddw xmm2,xmm6 ; xmm2=((G-Y)+YE)=GE=G(02468ACE)
205 paddw xmm3,xmm7 ; xmm3=((G-Y)+YO)=GO=G(13579BDF)
206 packuswb xmm2,xmm2 ; xmm2=G(02468ACE********)
207 packuswb xmm3,xmm3 ; xmm3=G(13579BDF********)
208
209 paddw xmm4,xmm6 ; xmm4=((B-Y)+YE)=BE=B(02468ACE)
210 paddw xmm5,xmm7 ; xmm5=((B-Y)+YO)=BO=B(13579BDF)
211 packuswb xmm4,xmm4 ; xmm4=B(02468ACE********)
212 packuswb xmm5,xmm5 ; xmm5=B(13579BDF********)
213
214 %if RGB_PIXELSIZE == 3 ; ---------------
215
216 ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
217 ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
218 ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
219 ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **)
220
221 punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1 C 0E 1E)
222 punpcklbw xmmE,xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0 D 2E 0F)
223 punpcklbw xmmD,xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2 D 1F 2F)
224
225 movdqa xmmG,xmmA
226 movdqa xmmH,xmmA
227 punpcklwd xmmA,xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 1 6 26 07)
228 punpckhwd xmmG,xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1 E 2E 0F)
229
230 psrldq xmmH,2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1 E -- --)
231 psrldq xmmE,2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0 F -- --)
232
233 movdqa xmmC,xmmD
234 movdqa xmmB,xmmD
235 punpcklwd xmmD,xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 2 7 08 18)
236 punpckhwd xmmC,xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2 F -- --)
237
238 psrldq xmmB,2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2 F -- --)
239
240 movdqa xmmF,xmmE
241 punpcklwd xmmE,xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 0 9 19 29)
242 punpckhwd xmmF,xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- - - -- --)
243
244 pshufd xmmH,xmmA,0x4E; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 1 2 22 03)
245 movdqa xmmB,xmmE
246 punpckldq xmmA,xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 2 3 04 14)
247 punpckldq xmmE,xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 1 6 26 07)
248 punpckhdq xmmD,xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 0 9 19 29)
249
250 pshufd xmmH,xmmG,0x4E; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1 A 2A 0B)
251 movdqa xmmB,xmmF
252 punpckldq xmmG,xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2 B 0C 1C)
253 punpckldq xmmF,xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1 E 2E 0F)
254 punpckhdq xmmC,xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- - - -- --)
255
256 punpcklqdq xmmA,xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 1 4 24 05)
257 punpcklqdq xmmD,xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 2 9 0A 1A)
258 punpcklqdq xmmF,xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0 F 1F 2F)
259
260 cmp ecx, byte SIZEOF_XMMWORD
261 jb short .column_st32
262
263 test edi, SIZEOF_XMMWORD-1
264 jnz short .out1
265 ; --(aligned)-------------------
266 movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
267 movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
268 movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF
269 add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
270 jmp short .out0
271 .out1: ; --(unaligned)-----------------
272 pcmpeqb xmmH,xmmH ; xmmH=(all 1's)
273 maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA
274 add edi, byte SIZEOF_XMMWORD ; outptr
275 maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [edi], xmmD
276 add edi, byte SIZEOF_XMMWORD ; outptr
277 maskmovdqu xmmF,xmmH ; movntdqu XMMWORD [edi], xmmF
278 add edi, byte SIZEOF_XMMWORD ; outptr
279 .out0:
280 sub ecx, byte SIZEOF_XMMWORD
281 jz near .endcolumn
282
283 add esi, byte SIZEOF_XMMWORD ; inptr0
284 dec al ; Yctr
285 jnz near .Yloop_2nd
286
287 add ebx, byte SIZEOF_XMMWORD ; inptr1
288 add edx, byte SIZEOF_XMMWORD ; inptr2
289 jmp near .columnloop
290 alignx 16,7
291
292 .column_st32:
293 pcmpeqb xmmH,xmmH ; xmmH=(all 1's)
294 lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
295 cmp ecx, byte 2*SIZEOF_XMMWORD
296 jb short .column_st16
297 maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA
298 add edi, byte SIZEOF_XMMWORD ; outptr
299 maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [edi], xmmD
300 add edi, byte SIZEOF_XMMWORD ; outptr
301 movdqa xmmA,xmmF
302 sub ecx, byte 2*SIZEOF_XMMWORD
303 jmp short .column_st15
304 .column_st16:
305 cmp ecx, byte SIZEOF_XMMWORD
306 jb short .column_st15
307 maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA
308 add edi, byte SIZEOF_XMMWORD ; outptr
309 movdqa xmmA,xmmD
310 sub ecx, byte SIZEOF_XMMWORD
311 .column_st15:
312 mov eax,ecx
313 xor ecx, byte 0x0F
314 shl ecx, 2
315 movd xmmB,ecx
316 psrlq xmmH,4
317 pcmpeqb xmmE,xmmE
318 psrlq xmmH,xmmB
319 psrlq xmmE,xmmB
320 punpcklbw xmmE,xmmH
321 ; ----------------
322 mov ecx,edi
323 and ecx, byte SIZEOF_XMMWORD-1
324 jz short .adj0
325 add eax,ecx
326 cmp eax, byte SIZEOF_XMMWORD
327 ja short .adj0
328 and edi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary
329 shl ecx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx
330 movdqa xmmG,xmmA
331 movdqa xmmC,xmmE
332 pslldq xmmA, SIZEOF_XMMWORD/2
333 pslldq xmmE, SIZEOF_XMMWORD/2
334 movd xmmD,ecx
335 sub ecx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT
336 jb short .adj1
337 movd xmmF,ecx
338 psllq xmmA,xmmF
339 psllq xmmE,xmmF
340 jmp short .adj0
341 .adj1: neg ecx
342 movd xmmF,ecx
343 psrlq xmmA,xmmF
344 psrlq xmmE,xmmF
345 psllq xmmG,xmmD
346 psllq xmmC,xmmD
347 por xmmA,xmmG
348 por xmmE,xmmC
349 .adj0: ; ----------------
350 maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA
351
352 %else ; RGB_PIXELSIZE == 4 ; -----------
353
354 %ifdef RGBX_FILLER_0XFF
355 pcmpeqb xmm6,xmm6 ; xmm6=XE=X(02468ACE********)
356 pcmpeqb xmm7,xmm7 ; xmm7=XO=X(13579BDF********)
357 %else
358 pxor xmm6,xmm6 ; xmm6=XE=X(02468ACE********)
359 pxor xmm7,xmm7 ; xmm7=XO=X(13579BDF********)
360 %endif
361 ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
362 ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
363 ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
364 ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **)
365
366 punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1 C 0E 1E)
367 punpcklbw xmmE,xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3 C 2E 3E)
368 punpcklbw xmmB,xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1 D 0F 1F)
369 punpcklbw xmmF,xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3 D 2F 3F)
370
371 movdqa xmmC,xmmA
372 punpcklwd xmmA,xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 1 6 26 36)
373 punpckhwd xmmC,xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1 E 2E 3E)
374 movdqa xmmG,xmmB
375 punpcklwd xmmB,xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 1 7 27 37)
376 punpckhwd xmmG,xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1 F 2F 3F)
377
378 movdqa xmmD,xmmA
379 punpckldq xmmA,xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 1 3 23 33)
380 punpckhdq xmmD,xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 1 7 27 37)
381 movdqa xmmH,xmmC
382 punpckldq xmmC,xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1 B 2B 3B)
383 punpckhdq xmmH,xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1 F 2F 3F)
384
385 cmp ecx, byte SIZEOF_XMMWORD
386 jb short .column_st32
387
388 test edi, SIZEOF_XMMWORD-1
389 jnz short .out1
390 ; --(aligned)-------------------
391 movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
392 movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
393 movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC
394 movntdq XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH
395 add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
396 jmp short .out0
397 .out1: ; --(unaligned)-----------------
398 pcmpeqb xmmE,xmmE ; xmmE=(all 1's)
399 maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA
400 add edi, byte SIZEOF_XMMWORD ; outptr
401 maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [edi], xmmD
402 add edi, byte SIZEOF_XMMWORD ; outptr
403 maskmovdqu xmmC,xmmE ; movntdqu XMMWORD [edi], xmmC
404 add edi, byte SIZEOF_XMMWORD ; outptr
405 maskmovdqu xmmH,xmmE ; movntdqu XMMWORD [edi], xmmH
406 add edi, byte SIZEOF_XMMWORD ; outptr
407 .out0:
408 sub ecx, byte SIZEOF_XMMWORD
409 jz near .endcolumn
410
411 add esi, byte SIZEOF_XMMWORD ; inptr0
412 dec al ; Yctr
413 jnz near .Yloop_2nd
414
415 add ebx, byte SIZEOF_XMMWORD ; inptr1
416 add edx, byte SIZEOF_XMMWORD ; inptr2
417 jmp near .columnloop
418 alignx 16,7
419
420 .column_st32:
421 pcmpeqb xmmE,xmmE ; xmmE=(all 1's)
422 cmp ecx, byte SIZEOF_XMMWORD/2
423 jb short .column_st16
424 maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA
425 add edi, byte SIZEOF_XMMWORD ; outptr
426 maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [edi], xmmD
427 add edi, byte SIZEOF_XMMWORD ; outptr
428 movdqa xmmA,xmmC
429 movdqa xmmD,xmmH
430 sub ecx, byte SIZEOF_XMMWORD/2
431 .column_st16:
432 cmp ecx, byte SIZEOF_XMMWORD/4
433 jb short .column_st15
434 maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA
435 add edi, byte SIZEOF_XMMWORD ; outptr
436 movdqa xmmA,xmmD
437 sub ecx, byte SIZEOF_XMMWORD/4
438 .column_st15:
439 cmp ecx, byte SIZEOF_XMMWORD/16
440 jb short .endcolumn
441 mov eax,ecx
442 xor ecx, byte 0x03
443 inc ecx
444 shl ecx, 4
445 movd xmmF,ecx
446 psrlq xmmE,xmmF
447 punpcklbw xmmE,xmmE
448 ; ----------------
449 mov ecx,edi
450 and ecx, byte SIZEOF_XMMWORD-1
451 jz short .adj0
452 lea eax, [ecx+eax*4] ; RGB_PIXELSIZE
453 cmp eax, byte SIZEOF_XMMWORD
454 ja short .adj0
455 and edi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary
456 shl ecx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx
457 movdqa xmmB,xmmA
458 movdqa xmmG,xmmE
459 pslldq xmmA, SIZEOF_XMMWORD/2
460 pslldq xmmE, SIZEOF_XMMWORD/2
461 movd xmmC,ecx
462 sub ecx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT
463 jb short .adj1
464 movd xmmH,ecx
465 psllq xmmA,xmmH
466 psllq xmmE,xmmH
467 jmp short .adj0
468 .adj1: neg ecx
469 movd xmmH,ecx
470 psrlq xmmA,xmmH
471 psrlq xmmE,xmmH
472 psllq xmmB,xmmC
473 psllq xmmG,xmmC
474 por xmmA,xmmB
475 por xmmE,xmmG
476 .adj0: ; ----------------
477 maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA
478
479 %endif ; RGB_PIXELSIZE ; ---------------
480
481 .endcolumn:
482 sfence ; flush the write buffer
483
484 .return:
485 pop edi
486 pop esi
487 ; pop edx ; need not be preserved
488 ; pop ecx ; need not be preserved
489 pop ebx
490 mov esp,ebp ; esp <- aligned ebp
491 pop esp ; esp <- original ebp
492 pop ebp
493 ret
494
495 ; --------------------------------------------------------------------------
496 ;
497 ; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
498 ;
499 ; GLOBAL(void)
500 ; jsimd_h2v2_merged_upsample_sse2 (JDIMENSION output_width,
501 ; JSAMPIMAGE input_buf,
502 ; JDIMENSION in_row_group_ctr,
503 ; JSAMPARRAY output_buf);
504 ;
505
506 %define output_width(b) (b)+8 ; JDIMENSION output_width
507 %define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf
508 %define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr
509 %define output_buf(b) (b)+20 ; JSAMPARRAY output_buf
510
511 align 16
512 global EXTN(jsimd_h2v2_merged_upsample_sse2)
513
514 EXTN(jsimd_h2v2_merged_upsample_sse2):
515 push ebp
516 mov ebp,esp
517 push ebx
518 ; push ecx ; need not be preserved
519 ; push edx ; need not be preserved
520 push esi
521 push edi
522
523 mov eax, POINTER [output_width(ebp)]
524
525 mov edi, JSAMPIMAGE [input_buf(ebp)]
526 mov ecx, JDIMENSION [in_row_group_ctr(ebp)]
527 mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
528 mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
529 mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
530 mov edi, JSAMPARRAY [output_buf(ebp)]
531 lea esi, [esi+ecx*SIZEOF_JSAMPROW]
532
533 push edx ; inptr2
534 push ebx ; inptr1
535 push esi ; inptr00
536 mov ebx,esp
537
538 push edi ; output_buf (outptr0)
539 push ecx ; in_row_group_ctr
540 push ebx ; input_buf
541 push eax ; output_width
542
543 call near EXTN(jsimd_h2v1_merged_upsample_sse2)
544
545 add esi, byte SIZEOF_JSAMPROW ; inptr01
546 add edi, byte SIZEOF_JSAMPROW ; outptr1
547 mov POINTER [ebx+0*SIZEOF_POINTER], esi
548 mov POINTER [ebx-1*SIZEOF_POINTER], edi
549
550 call near EXTN(jsimd_h2v1_merged_upsample_sse2)
551
552 add esp, byte 7*SIZEOF_DWORD
553
554 pop edi
555 pop esi
556 ; pop edx ; need not be preserved
557 ; pop ecx ; need not be preserved
558 pop ebx
559 pop ebp
560 ret
561
562 ; For some reason, the OS X linker does not honor the request to align the
563 ; segment unless we do this.
564 align 16
OLDNEW
« no previous file with comments | « third_party/libjpeg_turbo/simd/jdmrgmmx.asm ('k') | third_party/libjpeg_turbo/simd/jdmrgss2-64.asm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698