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

Side by Side Diff: simd/jimmxint.asm

Issue 1953443002: Update to libjpeg_turbo 1.4.90 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: Created 4 years, 7 months 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
« no previous file with comments | « simd/jimmxfst.asm ('k') | simd/jimmxred.asm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 ;
2 ; jimmxint.asm - accurate integer IDCT (MMX)
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 ; This file contains a slow-but-accurate integer implementation of the
18 ; inverse DCT (Discrete Cosine Transform). The following code is based
19 ; directly on the IJG's original jidctint.c; see the jidctint.c for
20 ; more details.
21 ;
22 ; [TAB8]
23
24 %include "jsimdext.inc"
25 %include "jdct.inc"
26
27 ; --------------------------------------------------------------------------
28
29 %define CONST_BITS 13
30 %define PASS1_BITS 2
31
32 %define DESCALE_P1 (CONST_BITS-PASS1_BITS)
33 %define DESCALE_P2 (CONST_BITS+PASS1_BITS+3)
34
35 %if CONST_BITS == 13
36 F_0_298 equ 2446 ; FIX(0.298631336)
37 F_0_390 equ 3196 ; FIX(0.390180644)
38 F_0_541 equ 4433 ; FIX(0.541196100)
39 F_0_765 equ 6270 ; FIX(0.765366865)
40 F_0_899 equ 7373 ; FIX(0.899976223)
41 F_1_175 equ 9633 ; FIX(1.175875602)
42 F_1_501 equ 12299 ; FIX(1.501321110)
43 F_1_847 equ 15137 ; FIX(1.847759065)
44 F_1_961 equ 16069 ; FIX(1.961570560)
45 F_2_053 equ 16819 ; FIX(2.053119869)
46 F_2_562 equ 20995 ; FIX(2.562915447)
47 F_3_072 equ 25172 ; FIX(3.072711026)
48 %else
49 ; NASM cannot do compile-time arithmetic on floating-point constants.
50 %define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n))
51 F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336)
52 F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644)
53 F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100)
54 F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865)
55 F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223)
56 F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602)
57 F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110)
58 F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065)
59 F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560)
60 F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869)
61 F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447)
62 F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026)
63 %endif
64
65 ; --------------------------------------------------------------------------
66 SECTION SEG_CONST
67
68 alignz 16
69 global EXTN(jconst_idct_islow_mmx) PRIVATE
70
71 EXTN(jconst_idct_islow_mmx):
72
73 PW_F130_F054 times 2 dw (F_0_541+F_0_765), F_0_541
74 PW_F054_MF130 times 2 dw F_0_541, (F_0_541-F_1_847)
75 PW_MF078_F117 times 2 dw (F_1_175-F_1_961), F_1_175
76 PW_F117_F078 times 2 dw F_1_175, (F_1_175-F_0_390)
77 PW_MF060_MF089 times 2 dw (F_0_298-F_0_899),-F_0_899
78 PW_MF089_F060 times 2 dw -F_0_899, (F_1_501-F_0_899)
79 PW_MF050_MF256 times 2 dw (F_2_053-F_2_562),-F_2_562
80 PW_MF256_F050 times 2 dw -F_2_562, (F_3_072-F_2_562)
81 PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1-1)
82 PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2-1)
83 PB_CENTERJSAMP times 8 db CENTERJSAMPLE
84
85 alignz 16
86
87 ; --------------------------------------------------------------------------
88 SECTION SEG_TEXT
89 BITS 32
90 ;
91 ; Perform dequantization and inverse DCT on one block of coefficients.
92 ;
93 ; GLOBAL(void)
94 ; jsimd_idct_islow_mmx (void * dct_table, JCOEFPTR coef_block,
95 ; JSAMPARRAY output_buf, JDIMENSION output_col)
96 ;
97
98 %define dct_table(b) (b)+8 ; jpeg_component_info * compptr
99 %define coef_block(b) (b)+12 ; JCOEFPTR coef_block
100 %define output_buf(b) (b)+16 ; JSAMPARRAY output_buf
101 %define output_col(b) (b)+20 ; JDIMENSION output_col
102
103 %define original_ebp ebp+0
104 %define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM]
105 %define WK_NUM 12
106 %define workspace wk(0)-DCTSIZE2*SIZEOF_JCOEF
107 ; JCOEF workspace[DCTSIZE2]
108
109 align 16
110 global EXTN(jsimd_idct_islow_mmx) PRIVATE
111
112 EXTN(jsimd_idct_islow_mmx):
113 push ebp
114 mov eax,esp ; eax = original ebp
115 sub esp, byte 4
116 and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
117 mov [esp],eax
118 mov ebp,esp ; ebp = aligned ebp
119 lea esp, [workspace]
120 push ebx
121 ; push ecx ; need not be preserved
122 ; push edx ; need not be preserved
123 push esi
124 push edi
125
126 get_GOT ebx ; get GOT address
127
128 ; ---- Pass 1: process columns from input, store into work array.
129
130 ; mov eax, [original_ebp]
131 mov edx, POINTER [dct_table(eax)] ; quantptr
132 mov esi, JCOEFPTR [coef_block(eax)] ; inptr
133 lea edi, [workspace] ; JCOEF * wsptr
134 mov ecx, DCTSIZE/4 ; ctr
135 alignx 16,7
136 .columnloop:
137 %ifndef NO_ZERO_COLUMN_TEST_ISLOW_MMX
138 mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
139 or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
140 jnz short .columnDCT
141
142 movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
143 movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
144 por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
145 por mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
146 por mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
147 por mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
148 por mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
149 por mm1,mm0
150 packsswb mm1,mm1
151 movd eax,mm1
152 test eax,eax
153 jnz short .columnDCT
154
155 ; -- AC terms all zero
156
157 movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
158 pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
159
160 psllw mm0,PASS1_BITS
161
162 movq mm2,mm0 ; mm0=in0=(00 01 02 03)
163 punpcklwd mm0,mm0 ; mm0=(00 00 01 01)
164 punpckhwd mm2,mm2 ; mm2=(02 02 03 03)
165
166 movq mm1,mm0
167 punpckldq mm0,mm0 ; mm0=(00 00 00 00)
168 punpckhdq mm1,mm1 ; mm1=(01 01 01 01)
169 movq mm3,mm2
170 punpckldq mm2,mm2 ; mm2=(02 02 02 02)
171 punpckhdq mm3,mm3 ; mm3=(03 03 03 03)
172
173 movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
174 movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0
175 movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1
176 movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm1
177 movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
178 movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2
179 movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
180 movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3
181 jmp near .nextcolumn
182 alignx 16,7
183 %endif
184 .columnDCT:
185
186 ; -- Even part
187
188 movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
189 movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
190 pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
191 pmullw mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
192 movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
193 movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
194 pmullw mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
195 pmullw mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
196
197 ; (Original)
198 ; z1 = (z2 + z3) * 0.541196100;
199 ; tmp2 = z1 + z3 * -1.847759065;
200 ; tmp3 = z1 + z2 * 0.765366865;
201 ;
202 ; (This implementation)
203 ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
204 ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
205
206 movq mm4,mm1 ; mm1=in2=z2
207 movq mm5,mm1
208 punpcklwd mm4,mm3 ; mm3=in6=z3
209 punpckhwd mm5,mm3
210 movq mm1,mm4
211 movq mm3,mm5
212 pmaddwd mm4,[GOTOFF(ebx,PW_F130_F054)] ; mm4=tmp3L
213 pmaddwd mm5,[GOTOFF(ebx,PW_F130_F054)] ; mm5=tmp3H
214 pmaddwd mm1,[GOTOFF(ebx,PW_F054_MF130)] ; mm1=tmp2L
215 pmaddwd mm3,[GOTOFF(ebx,PW_F054_MF130)] ; mm3=tmp2H
216
217 movq mm6,mm0
218 paddw mm0,mm2 ; mm0=in0+in4
219 psubw mm6,mm2 ; mm6=in0-in4
220
221 pxor mm7,mm7
222 pxor mm2,mm2
223 punpcklwd mm7,mm0 ; mm7=tmp0L
224 punpckhwd mm2,mm0 ; mm2=tmp0H
225 psrad mm7,(16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS
226 psrad mm2,(16-CONST_BITS) ; psrad mm2,16 & pslld mm2,CONST_BITS
227
228 movq mm0,mm7
229 paddd mm7,mm4 ; mm7=tmp10L
230 psubd mm0,mm4 ; mm0=tmp13L
231 movq mm4,mm2
232 paddd mm2,mm5 ; mm2=tmp10H
233 psubd mm4,mm5 ; mm4=tmp13H
234
235 movq MMWORD [wk(0)], mm7 ; wk(0)=tmp10L
236 movq MMWORD [wk(1)], mm2 ; wk(1)=tmp10H
237 movq MMWORD [wk(2)], mm0 ; wk(2)=tmp13L
238 movq MMWORD [wk(3)], mm4 ; wk(3)=tmp13H
239
240 pxor mm5,mm5
241 pxor mm7,mm7
242 punpcklwd mm5,mm6 ; mm5=tmp1L
243 punpckhwd mm7,mm6 ; mm7=tmp1H
244 psrad mm5,(16-CONST_BITS) ; psrad mm5,16 & pslld mm5,CONST_BITS
245 psrad mm7,(16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS
246
247 movq mm2,mm5
248 paddd mm5,mm1 ; mm5=tmp11L
249 psubd mm2,mm1 ; mm2=tmp12L
250 movq mm0,mm7
251 paddd mm7,mm3 ; mm7=tmp11H
252 psubd mm0,mm3 ; mm0=tmp12H
253
254 movq MMWORD [wk(4)], mm5 ; wk(4)=tmp11L
255 movq MMWORD [wk(5)], mm7 ; wk(5)=tmp11H
256 movq MMWORD [wk(6)], mm2 ; wk(6)=tmp12L
257 movq MMWORD [wk(7)], mm0 ; wk(7)=tmp12H
258
259 ; -- Odd part
260
261 movq mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
262 movq mm6, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
263 pmullw mm4, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
264 pmullw mm6, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
265 movq mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
266 movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
267 pmullw mm1, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
268 pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
269
270 movq mm5,mm6
271 movq mm7,mm4
272 paddw mm5,mm3 ; mm5=z3
273 paddw mm7,mm1 ; mm7=z4
274
275 ; (Original)
276 ; z5 = (z3 + z4) * 1.175875602;
277 ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
278 ; z3 += z5; z4 += z5;
279 ;
280 ; (This implementation)
281 ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
282 ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
283
284 movq mm2,mm5
285 movq mm0,mm5
286 punpcklwd mm2,mm7
287 punpckhwd mm0,mm7
288 movq mm5,mm2
289 movq mm7,mm0
290 pmaddwd mm2,[GOTOFF(ebx,PW_MF078_F117)] ; mm2=z3L
291 pmaddwd mm0,[GOTOFF(ebx,PW_MF078_F117)] ; mm0=z3H
292 pmaddwd mm5,[GOTOFF(ebx,PW_F117_F078)] ; mm5=z4L
293 pmaddwd mm7,[GOTOFF(ebx,PW_F117_F078)] ; mm7=z4H
294
295 movq MMWORD [wk(10)], mm2 ; wk(10)=z3L
296 movq MMWORD [wk(11)], mm0 ; wk(11)=z3H
297
298 ; (Original)
299 ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
300 ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
301 ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
302 ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
303 ; tmp0 += z1 + z3; tmp1 += z2 + z4;
304 ; tmp2 += z2 + z3; tmp3 += z1 + z4;
305 ;
306 ; (This implementation)
307 ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
308 ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
309 ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
310 ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
311 ; tmp0 += z3; tmp1 += z4;
312 ; tmp2 += z3; tmp3 += z4;
313
314 movq mm2,mm3
315 movq mm0,mm3
316 punpcklwd mm2,mm4
317 punpckhwd mm0,mm4
318 movq mm3,mm2
319 movq mm4,mm0
320 pmaddwd mm2,[GOTOFF(ebx,PW_MF060_MF089)] ; mm2=tmp0L
321 pmaddwd mm0,[GOTOFF(ebx,PW_MF060_MF089)] ; mm0=tmp0H
322 pmaddwd mm3,[GOTOFF(ebx,PW_MF089_F060)] ; mm3=tmp3L
323 pmaddwd mm4,[GOTOFF(ebx,PW_MF089_F060)] ; mm4=tmp3H
324
325 paddd mm2, MMWORD [wk(10)] ; mm2=tmp0L
326 paddd mm0, MMWORD [wk(11)] ; mm0=tmp0H
327 paddd mm3,mm5 ; mm3=tmp3L
328 paddd mm4,mm7 ; mm4=tmp3H
329
330 movq MMWORD [wk(8)], mm2 ; wk(8)=tmp0L
331 movq MMWORD [wk(9)], mm0 ; wk(9)=tmp0H
332
333 movq mm2,mm1
334 movq mm0,mm1
335 punpcklwd mm2,mm6
336 punpckhwd mm0,mm6
337 movq mm1,mm2
338 movq mm6,mm0
339 pmaddwd mm2,[GOTOFF(ebx,PW_MF050_MF256)] ; mm2=tmp1L
340 pmaddwd mm0,[GOTOFF(ebx,PW_MF050_MF256)] ; mm0=tmp1H
341 pmaddwd mm1,[GOTOFF(ebx,PW_MF256_F050)] ; mm1=tmp2L
342 pmaddwd mm6,[GOTOFF(ebx,PW_MF256_F050)] ; mm6=tmp2H
343
344 paddd mm2,mm5 ; mm2=tmp1L
345 paddd mm0,mm7 ; mm0=tmp1H
346 paddd mm1, MMWORD [wk(10)] ; mm1=tmp2L
347 paddd mm6, MMWORD [wk(11)] ; mm6=tmp2H
348
349 movq MMWORD [wk(10)], mm2 ; wk(10)=tmp1L
350 movq MMWORD [wk(11)], mm0 ; wk(11)=tmp1H
351
352 ; -- Final output stage
353
354 movq mm5, MMWORD [wk(0)] ; mm5=tmp10L
355 movq mm7, MMWORD [wk(1)] ; mm7=tmp10H
356
357 movq mm2,mm5
358 movq mm0,mm7
359 paddd mm5,mm3 ; mm5=data0L
360 paddd mm7,mm4 ; mm7=data0H
361 psubd mm2,mm3 ; mm2=data7L
362 psubd mm0,mm4 ; mm0=data7H
363
364 movq mm3,[GOTOFF(ebx,PD_DESCALE_P1)] ; mm3=[PD_DESCALE_P1]
365
366 paddd mm5,mm3
367 paddd mm7,mm3
368 psrad mm5,DESCALE_P1
369 psrad mm7,DESCALE_P1
370 paddd mm2,mm3
371 paddd mm0,mm3
372 psrad mm2,DESCALE_P1
373 psrad mm0,DESCALE_P1
374
375 packssdw mm5,mm7 ; mm5=data0=(00 01 02 03)
376 packssdw mm2,mm0 ; mm2=data7=(70 71 72 73)
377
378 movq mm4, MMWORD [wk(4)] ; mm4=tmp11L
379 movq mm3, MMWORD [wk(5)] ; mm3=tmp11H
380
381 movq mm7,mm4
382 movq mm0,mm3
383 paddd mm4,mm1 ; mm4=data1L
384 paddd mm3,mm6 ; mm3=data1H
385 psubd mm7,mm1 ; mm7=data6L
386 psubd mm0,mm6 ; mm0=data6H
387
388 movq mm1,[GOTOFF(ebx,PD_DESCALE_P1)] ; mm1=[PD_DESCALE_P1]
389
390 paddd mm4,mm1
391 paddd mm3,mm1
392 psrad mm4,DESCALE_P1
393 psrad mm3,DESCALE_P1
394 paddd mm7,mm1
395 paddd mm0,mm1
396 psrad mm7,DESCALE_P1
397 psrad mm0,DESCALE_P1
398
399 packssdw mm4,mm3 ; mm4=data1=(10 11 12 13)
400 packssdw mm7,mm0 ; mm7=data6=(60 61 62 63)
401
402 movq mm6,mm5 ; transpose coefficients(phase 1)
403 punpcklwd mm5,mm4 ; mm5=(00 10 01 11)
404 punpckhwd mm6,mm4 ; mm6=(02 12 03 13)
405 movq mm1,mm7 ; transpose coefficients(phase 1)
406 punpcklwd mm7,mm2 ; mm7=(60 70 61 71)
407 punpckhwd mm1,mm2 ; mm1=(62 72 63 73)
408
409 movq mm3, MMWORD [wk(6)] ; mm3=tmp12L
410 movq mm0, MMWORD [wk(7)] ; mm0=tmp12H
411 movq mm4, MMWORD [wk(10)] ; mm4=tmp1L
412 movq mm2, MMWORD [wk(11)] ; mm2=tmp1H
413
414 movq MMWORD [wk(0)], mm5 ; wk(0)=(00 10 01 11)
415 movq MMWORD [wk(1)], mm6 ; wk(1)=(02 12 03 13)
416 movq MMWORD [wk(4)], mm7 ; wk(4)=(60 70 61 71)
417 movq MMWORD [wk(5)], mm1 ; wk(5)=(62 72 63 73)
418
419 movq mm5,mm3
420 movq mm6,mm0
421 paddd mm3,mm4 ; mm3=data2L
422 paddd mm0,mm2 ; mm0=data2H
423 psubd mm5,mm4 ; mm5=data5L
424 psubd mm6,mm2 ; mm6=data5H
425
426 movq mm7,[GOTOFF(ebx,PD_DESCALE_P1)] ; mm7=[PD_DESCALE_P1]
427
428 paddd mm3,mm7
429 paddd mm0,mm7
430 psrad mm3,DESCALE_P1
431 psrad mm0,DESCALE_P1
432 paddd mm5,mm7
433 paddd mm6,mm7
434 psrad mm5,DESCALE_P1
435 psrad mm6,DESCALE_P1
436
437 packssdw mm3,mm0 ; mm3=data2=(20 21 22 23)
438 packssdw mm5,mm6 ; mm5=data5=(50 51 52 53)
439
440 movq mm1, MMWORD [wk(2)] ; mm1=tmp13L
441 movq mm4, MMWORD [wk(3)] ; mm4=tmp13H
442 movq mm2, MMWORD [wk(8)] ; mm2=tmp0L
443 movq mm7, MMWORD [wk(9)] ; mm7=tmp0H
444
445 movq mm0,mm1
446 movq mm6,mm4
447 paddd mm1,mm2 ; mm1=data3L
448 paddd mm4,mm7 ; mm4=data3H
449 psubd mm0,mm2 ; mm0=data4L
450 psubd mm6,mm7 ; mm6=data4H
451
452 movq mm2,[GOTOFF(ebx,PD_DESCALE_P1)] ; mm2=[PD_DESCALE_P1]
453
454 paddd mm1,mm2
455 paddd mm4,mm2
456 psrad mm1,DESCALE_P1
457 psrad mm4,DESCALE_P1
458 paddd mm0,mm2
459 paddd mm6,mm2
460 psrad mm0,DESCALE_P1
461 psrad mm6,DESCALE_P1
462
463 packssdw mm1,mm4 ; mm1=data3=(30 31 32 33)
464 packssdw mm0,mm6 ; mm0=data4=(40 41 42 43)
465
466 movq mm7, MMWORD [wk(0)] ; mm7=(00 10 01 11)
467 movq mm2, MMWORD [wk(1)] ; mm2=(02 12 03 13)
468
469 movq mm4,mm3 ; transpose coefficients(phase 1)
470 punpcklwd mm3,mm1 ; mm3=(20 30 21 31)
471 punpckhwd mm4,mm1 ; mm4=(22 32 23 33)
472 movq mm6,mm0 ; transpose coefficients(phase 1)
473 punpcklwd mm0,mm5 ; mm0=(40 50 41 51)
474 punpckhwd mm6,mm5 ; mm6=(42 52 43 53)
475
476 movq mm1,mm7 ; transpose coefficients(phase 2)
477 punpckldq mm7,mm3 ; mm7=(00 10 20 30)
478 punpckhdq mm1,mm3 ; mm1=(01 11 21 31)
479 movq mm5,mm2 ; transpose coefficients(phase 2)
480 punpckldq mm2,mm4 ; mm2=(02 12 22 32)
481 punpckhdq mm5,mm4 ; mm5=(03 13 23 33)
482
483 movq mm3, MMWORD [wk(4)] ; mm3=(60 70 61 71)
484 movq mm4, MMWORD [wk(5)] ; mm4=(62 72 63 73)
485
486 movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm7
487 movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1
488 movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
489 movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm5
490
491 movq mm7,mm0 ; transpose coefficients(phase 2)
492 punpckldq mm0,mm3 ; mm0=(40 50 60 70)
493 punpckhdq mm7,mm3 ; mm7=(41 51 61 71)
494 movq mm1,mm6 ; transpose coefficients(phase 2)
495 punpckldq mm6,mm4 ; mm6=(42 52 62 72)
496 punpckhdq mm1,mm4 ; mm1=(43 53 63 73)
497
498 movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0
499 movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm7
500 movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm6
501 movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm1
502
503 .nextcolumn:
504 add esi, byte 4*SIZEOF_JCOEF ; coef_block
505 add edx, byte 4*SIZEOF_ISLOW_MULT_TYPE ; quantptr
506 add edi, byte 4*DCTSIZE*SIZEOF_JCOEF ; wsptr
507 dec ecx ; ctr
508 jnz near .columnloop
509
510 ; ---- Pass 2: process rows from work array, store into output array.
511
512 mov eax, [original_ebp]
513 lea esi, [workspace] ; JCOEF * wsptr
514 mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
515 mov eax, JDIMENSION [output_col(eax)]
516 mov ecx, DCTSIZE/4 ; ctr
517 alignx 16,7
518 .rowloop:
519
520 ; -- Even part
521
522 movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
523 movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
524 movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
525 movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
526
527 ; (Original)
528 ; z1 = (z2 + z3) * 0.541196100;
529 ; tmp2 = z1 + z3 * -1.847759065;
530 ; tmp3 = z1 + z2 * 0.765366865;
531 ;
532 ; (This implementation)
533 ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
534 ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
535
536 movq mm4,mm1 ; mm1=in2=z2
537 movq mm5,mm1
538 punpcklwd mm4,mm3 ; mm3=in6=z3
539 punpckhwd mm5,mm3
540 movq mm1,mm4
541 movq mm3,mm5
542 pmaddwd mm4,[GOTOFF(ebx,PW_F130_F054)] ; mm4=tmp3L
543 pmaddwd mm5,[GOTOFF(ebx,PW_F130_F054)] ; mm5=tmp3H
544 pmaddwd mm1,[GOTOFF(ebx,PW_F054_MF130)] ; mm1=tmp2L
545 pmaddwd mm3,[GOTOFF(ebx,PW_F054_MF130)] ; mm3=tmp2H
546
547 movq mm6,mm0
548 paddw mm0,mm2 ; mm0=in0+in4
549 psubw mm6,mm2 ; mm6=in0-in4
550
551 pxor mm7,mm7
552 pxor mm2,mm2
553 punpcklwd mm7,mm0 ; mm7=tmp0L
554 punpckhwd mm2,mm0 ; mm2=tmp0H
555 psrad mm7,(16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS
556 psrad mm2,(16-CONST_BITS) ; psrad mm2,16 & pslld mm2,CONST_BITS
557
558 movq mm0,mm7
559 paddd mm7,mm4 ; mm7=tmp10L
560 psubd mm0,mm4 ; mm0=tmp13L
561 movq mm4,mm2
562 paddd mm2,mm5 ; mm2=tmp10H
563 psubd mm4,mm5 ; mm4=tmp13H
564
565 movq MMWORD [wk(0)], mm7 ; wk(0)=tmp10L
566 movq MMWORD [wk(1)], mm2 ; wk(1)=tmp10H
567 movq MMWORD [wk(2)], mm0 ; wk(2)=tmp13L
568 movq MMWORD [wk(3)], mm4 ; wk(3)=tmp13H
569
570 pxor mm5,mm5
571 pxor mm7,mm7
572 punpcklwd mm5,mm6 ; mm5=tmp1L
573 punpckhwd mm7,mm6 ; mm7=tmp1H
574 psrad mm5,(16-CONST_BITS) ; psrad mm5,16 & pslld mm5,CONST_BITS
575 psrad mm7,(16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS
576
577 movq mm2,mm5
578 paddd mm5,mm1 ; mm5=tmp11L
579 psubd mm2,mm1 ; mm2=tmp12L
580 movq mm0,mm7
581 paddd mm7,mm3 ; mm7=tmp11H
582 psubd mm0,mm3 ; mm0=tmp12H
583
584 movq MMWORD [wk(4)], mm5 ; wk(4)=tmp11L
585 movq MMWORD [wk(5)], mm7 ; wk(5)=tmp11H
586 movq MMWORD [wk(6)], mm2 ; wk(6)=tmp12L
587 movq MMWORD [wk(7)], mm0 ; wk(7)=tmp12H
588
589 ; -- Odd part
590
591 movq mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
592 movq mm6, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
593 movq mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
594 movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
595
596 movq mm5,mm6
597 movq mm7,mm4
598 paddw mm5,mm3 ; mm5=z3
599 paddw mm7,mm1 ; mm7=z4
600
601 ; (Original)
602 ; z5 = (z3 + z4) * 1.175875602;
603 ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
604 ; z3 += z5; z4 += z5;
605 ;
606 ; (This implementation)
607 ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
608 ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
609
610 movq mm2,mm5
611 movq mm0,mm5
612 punpcklwd mm2,mm7
613 punpckhwd mm0,mm7
614 movq mm5,mm2
615 movq mm7,mm0
616 pmaddwd mm2,[GOTOFF(ebx,PW_MF078_F117)] ; mm2=z3L
617 pmaddwd mm0,[GOTOFF(ebx,PW_MF078_F117)] ; mm0=z3H
618 pmaddwd mm5,[GOTOFF(ebx,PW_F117_F078)] ; mm5=z4L
619 pmaddwd mm7,[GOTOFF(ebx,PW_F117_F078)] ; mm7=z4H
620
621 movq MMWORD [wk(10)], mm2 ; wk(10)=z3L
622 movq MMWORD [wk(11)], mm0 ; wk(11)=z3H
623
624 ; (Original)
625 ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
626 ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
627 ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
628 ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
629 ; tmp0 += z1 + z3; tmp1 += z2 + z4;
630 ; tmp2 += z2 + z3; tmp3 += z1 + z4;
631 ;
632 ; (This implementation)
633 ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
634 ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
635 ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
636 ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
637 ; tmp0 += z3; tmp1 += z4;
638 ; tmp2 += z3; tmp3 += z4;
639
640 movq mm2,mm3
641 movq mm0,mm3
642 punpcklwd mm2,mm4
643 punpckhwd mm0,mm4
644 movq mm3,mm2
645 movq mm4,mm0
646 pmaddwd mm2,[GOTOFF(ebx,PW_MF060_MF089)] ; mm2=tmp0L
647 pmaddwd mm0,[GOTOFF(ebx,PW_MF060_MF089)] ; mm0=tmp0H
648 pmaddwd mm3,[GOTOFF(ebx,PW_MF089_F060)] ; mm3=tmp3L
649 pmaddwd mm4,[GOTOFF(ebx,PW_MF089_F060)] ; mm4=tmp3H
650
651 paddd mm2, MMWORD [wk(10)] ; mm2=tmp0L
652 paddd mm0, MMWORD [wk(11)] ; mm0=tmp0H
653 paddd mm3,mm5 ; mm3=tmp3L
654 paddd mm4,mm7 ; mm4=tmp3H
655
656 movq MMWORD [wk(8)], mm2 ; wk(8)=tmp0L
657 movq MMWORD [wk(9)], mm0 ; wk(9)=tmp0H
658
659 movq mm2,mm1
660 movq mm0,mm1
661 punpcklwd mm2,mm6
662 punpckhwd mm0,mm6
663 movq mm1,mm2
664 movq mm6,mm0
665 pmaddwd mm2,[GOTOFF(ebx,PW_MF050_MF256)] ; mm2=tmp1L
666 pmaddwd mm0,[GOTOFF(ebx,PW_MF050_MF256)] ; mm0=tmp1H
667 pmaddwd mm1,[GOTOFF(ebx,PW_MF256_F050)] ; mm1=tmp2L
668 pmaddwd mm6,[GOTOFF(ebx,PW_MF256_F050)] ; mm6=tmp2H
669
670 paddd mm2,mm5 ; mm2=tmp1L
671 paddd mm0,mm7 ; mm0=tmp1H
672 paddd mm1, MMWORD [wk(10)] ; mm1=tmp2L
673 paddd mm6, MMWORD [wk(11)] ; mm6=tmp2H
674
675 movq MMWORD [wk(10)], mm2 ; wk(10)=tmp1L
676 movq MMWORD [wk(11)], mm0 ; wk(11)=tmp1H
677
678 ; -- Final output stage
679
680 movq mm5, MMWORD [wk(0)] ; mm5=tmp10L
681 movq mm7, MMWORD [wk(1)] ; mm7=tmp10H
682
683 movq mm2,mm5
684 movq mm0,mm7
685 paddd mm5,mm3 ; mm5=data0L
686 paddd mm7,mm4 ; mm7=data0H
687 psubd mm2,mm3 ; mm2=data7L
688 psubd mm0,mm4 ; mm0=data7H
689
690 movq mm3,[GOTOFF(ebx,PD_DESCALE_P2)] ; mm3=[PD_DESCALE_P2]
691
692 paddd mm5,mm3
693 paddd mm7,mm3
694 psrad mm5,DESCALE_P2
695 psrad mm7,DESCALE_P2
696 paddd mm2,mm3
697 paddd mm0,mm3
698 psrad mm2,DESCALE_P2
699 psrad mm0,DESCALE_P2
700
701 packssdw mm5,mm7 ; mm5=data0=(00 10 20 30)
702 packssdw mm2,mm0 ; mm2=data7=(07 17 27 37)
703
704 movq mm4, MMWORD [wk(4)] ; mm4=tmp11L
705 movq mm3, MMWORD [wk(5)] ; mm3=tmp11H
706
707 movq mm7,mm4
708 movq mm0,mm3
709 paddd mm4,mm1 ; mm4=data1L
710 paddd mm3,mm6 ; mm3=data1H
711 psubd mm7,mm1 ; mm7=data6L
712 psubd mm0,mm6 ; mm0=data6H
713
714 movq mm1,[GOTOFF(ebx,PD_DESCALE_P2)] ; mm1=[PD_DESCALE_P2]
715
716 paddd mm4,mm1
717 paddd mm3,mm1
718 psrad mm4,DESCALE_P2
719 psrad mm3,DESCALE_P2
720 paddd mm7,mm1
721 paddd mm0,mm1
722 psrad mm7,DESCALE_P2
723 psrad mm0,DESCALE_P2
724
725 packssdw mm4,mm3 ; mm4=data1=(01 11 21 31)
726 packssdw mm7,mm0 ; mm7=data6=(06 16 26 36)
727
728 packsswb mm5,mm7 ; mm5=(00 10 20 30 06 16 26 36)
729 packsswb mm4,mm2 ; mm4=(01 11 21 31 07 17 27 37)
730
731 movq mm6, MMWORD [wk(6)] ; mm6=tmp12L
732 movq mm1, MMWORD [wk(7)] ; mm1=tmp12H
733 movq mm3, MMWORD [wk(10)] ; mm3=tmp1L
734 movq mm0, MMWORD [wk(11)] ; mm0=tmp1H
735
736 movq MMWORD [wk(0)], mm5 ; wk(0)=(00 10 20 30 06 16 26 36)
737 movq MMWORD [wk(1)], mm4 ; wk(1)=(01 11 21 31 07 17 27 37)
738
739 movq mm7,mm6
740 movq mm2,mm1
741 paddd mm6,mm3 ; mm6=data2L
742 paddd mm1,mm0 ; mm1=data2H
743 psubd mm7,mm3 ; mm7=data5L
744 psubd mm2,mm0 ; mm2=data5H
745
746 movq mm5,[GOTOFF(ebx,PD_DESCALE_P2)] ; mm5=[PD_DESCALE_P2]
747
748 paddd mm6,mm5
749 paddd mm1,mm5
750 psrad mm6,DESCALE_P2
751 psrad mm1,DESCALE_P2
752 paddd mm7,mm5
753 paddd mm2,mm5
754 psrad mm7,DESCALE_P2
755 psrad mm2,DESCALE_P2
756
757 packssdw mm6,mm1 ; mm6=data2=(02 12 22 32)
758 packssdw mm7,mm2 ; mm7=data5=(05 15 25 35)
759
760 movq mm4, MMWORD [wk(2)] ; mm4=tmp13L
761 movq mm3, MMWORD [wk(3)] ; mm3=tmp13H
762 movq mm0, MMWORD [wk(8)] ; mm0=tmp0L
763 movq mm5, MMWORD [wk(9)] ; mm5=tmp0H
764
765 movq mm1,mm4
766 movq mm2,mm3
767 paddd mm4,mm0 ; mm4=data3L
768 paddd mm3,mm5 ; mm3=data3H
769 psubd mm1,mm0 ; mm1=data4L
770 psubd mm2,mm5 ; mm2=data4H
771
772 movq mm0,[GOTOFF(ebx,PD_DESCALE_P2)] ; mm0=[PD_DESCALE_P2]
773
774 paddd mm4,mm0
775 paddd mm3,mm0
776 psrad mm4,DESCALE_P2
777 psrad mm3,DESCALE_P2
778 paddd mm1,mm0
779 paddd mm2,mm0
780 psrad mm1,DESCALE_P2
781 psrad mm2,DESCALE_P2
782
783 movq mm5,[GOTOFF(ebx,PB_CENTERJSAMP)] ; mm5=[PB_CENTERJSAMP]
784
785 packssdw mm4,mm3 ; mm4=data3=(03 13 23 33)
786 packssdw mm1,mm2 ; mm1=data4=(04 14 24 34)
787
788 movq mm0, MMWORD [wk(0)] ; mm0=(00 10 20 30 06 16 26 36)
789 movq mm3, MMWORD [wk(1)] ; mm3=(01 11 21 31 07 17 27 37)
790
791 packsswb mm6,mm1 ; mm6=(02 12 22 32 04 14 24 34)
792 packsswb mm4,mm7 ; mm4=(03 13 23 33 05 15 25 35)
793
794 paddb mm0,mm5
795 paddb mm3,mm5
796 paddb mm6,mm5
797 paddb mm4,mm5
798
799 movq mm2,mm0 ; transpose coefficients(phase 1)
800 punpcklbw mm0,mm3 ; mm0=(00 01 10 11 20 21 30 31)
801 punpckhbw mm2,mm3 ; mm2=(06 07 16 17 26 27 36 37)
802 movq mm1,mm6 ; transpose coefficients(phase 1)
803 punpcklbw mm6,mm4 ; mm6=(02 03 12 13 22 23 32 33)
804 punpckhbw mm1,mm4 ; mm1=(04 05 14 15 24 25 34 35)
805
806 movq mm7,mm0 ; transpose coefficients(phase 2)
807 punpcklwd mm0,mm6 ; mm0=(00 01 02 03 10 11 12 13)
808 punpckhwd mm7,mm6 ; mm7=(20 21 22 23 30 31 32 33)
809 movq mm5,mm1 ; transpose coefficients(phase 2)
810 punpcklwd mm1,mm2 ; mm1=(04 05 06 07 14 15 16 17)
811 punpckhwd mm5,mm2 ; mm5=(24 25 26 27 34 35 36 37)
812
813 movq mm3,mm0 ; transpose coefficients(phase 3)
814 punpckldq mm0,mm1 ; mm0=(00 01 02 03 04 05 06 07)
815 punpckhdq mm3,mm1 ; mm3=(10 11 12 13 14 15 16 17)
816 movq mm4,mm7 ; transpose coefficients(phase 3)
817 punpckldq mm7,mm5 ; mm7=(20 21 22 23 24 25 26 27)
818 punpckhdq mm4,mm5 ; mm4=(30 31 32 33 34 35 36 37)
819
820 pushpic ebx ; save GOT address
821
822 mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
823 mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
824 movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm0
825 movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm3
826 mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
827 mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
828 movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm7
829 movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4
830
831 poppic ebx ; restore GOT address
832
833 add esi, byte 4*SIZEOF_JCOEF ; wsptr
834 add edi, byte 4*SIZEOF_JSAMPROW
835 dec ecx ; ctr
836 jnz near .rowloop
837
838 emms ; empty MMX state
839
840 pop edi
841 pop esi
842 ; pop edx ; need not be preserved
843 ; pop ecx ; need not be preserved
844 pop ebx
845 mov esp,ebp ; esp <- aligned ebp
846 pop esp ; esp <- original ebp
847 pop ebp
848 ret
849
850 ; For some reason, the OS X linker does not honor the request to align the
851 ; segment unless we do this.
852 align 16
OLDNEW
« no previous file with comments | « simd/jimmxfst.asm ('k') | simd/jimmxred.asm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698