media/libjpeg/simd/jisseflt.asm

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libjpeg/simd/jisseflt.asm	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,572 @@
     1.4 +;
     1.5 +; jisseflt.asm - floating-point IDCT (SSE & MMX)
     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_sse)
    1.44 +
    1.45 +EXTN(jconst_idct_float_sse):
    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_0_125	times 4 dd  0.125	; 1/8
    1.52 +PB_CENTERJSAMP	times 8 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_sse (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_sse)
    1.80 +
    1.81 +EXTN(jsimd_idct_float_sse):
    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	mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
   1.112 +	movq	mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
   1.113 +	por	mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
   1.114 +	por	mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
   1.115 +	por	mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
   1.116 +	por	mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
   1.117 +	por	mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
   1.118 +	por	mm1,mm0
   1.119 +	packsswb mm1,mm1
   1.120 +	movd	eax,mm1
   1.121 +	test	eax,eax
   1.122 +	jnz	short .columnDCT
   1.123 +
   1.124 +	; -- AC terms all zero
   1.125 +
   1.126 +	movq      mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
   1.127 +
   1.128 +	punpckhwd mm1,mm0			; mm1=(** 02 ** 03)
   1.129 +	punpcklwd mm0,mm0			; mm0=(00 00 01 01)
   1.130 +	psrad     mm1,(DWORD_BIT-WORD_BIT)	; mm1=in0H=(02 03)
   1.131 +	psrad     mm0,(DWORD_BIT-WORD_BIT)	; mm0=in0L=(00 01)
   1.132 +	cvtpi2ps  xmm3,mm1			; xmm3=(02 03 ** **)
   1.133 +	cvtpi2ps  xmm0,mm0			; xmm0=(00 01 ** **)
   1.134 +	movlhps   xmm0,xmm3			; xmm0=in0=(00 01 02 03)
   1.135 +
   1.136 +	mulps	xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.137 +
   1.138 +	movaps	xmm1,xmm0
   1.139 +	movaps	xmm2,xmm0
   1.140 +	movaps	xmm3,xmm0
   1.141 +
   1.142 +	shufps	xmm0,xmm0,0x00			; xmm0=(00 00 00 00)
   1.143 +	shufps	xmm1,xmm1,0x55			; xmm1=(01 01 01 01)
   1.144 +	shufps	xmm2,xmm2,0xAA			; xmm2=(02 02 02 02)
   1.145 +	shufps	xmm3,xmm3,0xFF			; xmm3=(03 03 03 03)
   1.146 +
   1.147 +	movaps	XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0
   1.148 +	movaps	XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm0
   1.149 +	movaps	XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm1
   1.150 +	movaps	XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm1
   1.151 +	movaps	XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm2
   1.152 +	movaps	XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm2
   1.153 +	movaps	XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3
   1.154 +	movaps	XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
   1.155 +	jmp	near .nextcolumn
   1.156 +	alignx	16,7
   1.157 +%endif
   1.158 +.columnDCT:
   1.159 +
   1.160 +	; -- Even part
   1.161 +
   1.162 +	movq      mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
   1.163 +	movq      mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
   1.164 +	movq      mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
   1.165 +	movq      mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
   1.166 +
   1.167 +	punpckhwd mm4,mm0			; mm4=(** 02 ** 03)
   1.168 +	punpcklwd mm0,mm0			; mm0=(00 00 01 01)
   1.169 +	punpckhwd mm5,mm1			; mm5=(** 22 ** 23)
   1.170 +	punpcklwd mm1,mm1			; mm1=(20 20 21 21)
   1.171 +
   1.172 +	psrad     mm4,(DWORD_BIT-WORD_BIT)	; mm4=in0H=(02 03)
   1.173 +	psrad     mm0,(DWORD_BIT-WORD_BIT)	; mm0=in0L=(00 01)
   1.174 +	cvtpi2ps  xmm4,mm4			; xmm4=(02 03 ** **)
   1.175 +	cvtpi2ps  xmm0,mm0			; xmm0=(00 01 ** **)
   1.176 +	psrad     mm5,(DWORD_BIT-WORD_BIT)	; mm5=in2H=(22 23)
   1.177 +	psrad     mm1,(DWORD_BIT-WORD_BIT)	; mm1=in2L=(20 21)
   1.178 +	cvtpi2ps  xmm5,mm5			; xmm5=(22 23 ** **)
   1.179 +	cvtpi2ps  xmm1,mm1			; xmm1=(20 21 ** **)
   1.180 +
   1.181 +	punpckhwd mm6,mm2			; mm6=(** 42 ** 43)
   1.182 +	punpcklwd mm2,mm2			; mm2=(40 40 41 41)
   1.183 +	punpckhwd mm7,mm3			; mm7=(** 62 ** 63)
   1.184 +	punpcklwd mm3,mm3			; mm3=(60 60 61 61)
   1.185 +
   1.186 +	psrad     mm6,(DWORD_BIT-WORD_BIT)	; mm6=in4H=(42 43)
   1.187 +	psrad     mm2,(DWORD_BIT-WORD_BIT)	; mm2=in4L=(40 41)
   1.188 +	cvtpi2ps  xmm6,mm6			; xmm6=(42 43 ** **)
   1.189 +	cvtpi2ps  xmm2,mm2			; xmm2=(40 41 ** **)
   1.190 +	psrad     mm7,(DWORD_BIT-WORD_BIT)	; mm7=in6H=(62 63)
   1.191 +	psrad     mm3,(DWORD_BIT-WORD_BIT)	; mm3=in6L=(60 61)
   1.192 +	cvtpi2ps  xmm7,mm7			; xmm7=(62 63 ** **)
   1.193 +	cvtpi2ps  xmm3,mm3			; xmm3=(60 61 ** **)
   1.194 +
   1.195 +	movlhps   xmm0,xmm4			; xmm0=in0=(00 01 02 03)
   1.196 +	movlhps   xmm1,xmm5			; xmm1=in2=(20 21 22 23)
   1.197 +	mulps     xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.198 +	mulps     xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.199 +
   1.200 +	movlhps   xmm2,xmm6			; xmm2=in4=(40 41 42 43)
   1.201 +	movlhps   xmm3,xmm7			; xmm3=in6=(60 61 62 63)
   1.202 +	mulps     xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.203 +	mulps     xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.204 +
   1.205 +	movaps	xmm4,xmm0
   1.206 +	movaps	xmm5,xmm1
   1.207 +	subps	xmm0,xmm2		; xmm0=tmp11
   1.208 +	subps	xmm1,xmm3
   1.209 +	addps	xmm4,xmm2		; xmm4=tmp10
   1.210 +	addps	xmm5,xmm3		; xmm5=tmp13
   1.211 +
   1.212 +	mulps	xmm1,[GOTOFF(ebx,PD_1_414)]
   1.213 +	subps	xmm1,xmm5		; xmm1=tmp12
   1.214 +
   1.215 +	movaps	xmm6,xmm4
   1.216 +	movaps	xmm7,xmm0
   1.217 +	subps	xmm4,xmm5		; xmm4=tmp3
   1.218 +	subps	xmm0,xmm1		; xmm0=tmp2
   1.219 +	addps	xmm6,xmm5		; xmm6=tmp0
   1.220 +	addps	xmm7,xmm1		; xmm7=tmp1
   1.221 +
   1.222 +	movaps	XMMWORD [wk(1)], xmm4	; tmp3
   1.223 +	movaps	XMMWORD [wk(0)], xmm0	; tmp2
   1.224 +
   1.225 +	; -- Odd part
   1.226 +
   1.227 +	movq      mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
   1.228 +	movq      mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
   1.229 +	movq      mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
   1.230 +	movq      mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
   1.231 +
   1.232 +	punpckhwd mm6,mm4			; mm6=(** 12 ** 13)
   1.233 +	punpcklwd mm4,mm4			; mm4=(10 10 11 11)
   1.234 +	punpckhwd mm2,mm0			; mm2=(** 32 ** 33)
   1.235 +	punpcklwd mm0,mm0			; mm0=(30 30 31 31)
   1.236 +
   1.237 +	psrad     mm6,(DWORD_BIT-WORD_BIT)	; mm6=in1H=(12 13)
   1.238 +	psrad     mm4,(DWORD_BIT-WORD_BIT)	; mm4=in1L=(10 11)
   1.239 +	cvtpi2ps  xmm4,mm6			; xmm4=(12 13 ** **)
   1.240 +	cvtpi2ps  xmm2,mm4			; xmm2=(10 11 ** **)
   1.241 +	psrad     mm2,(DWORD_BIT-WORD_BIT)	; mm2=in3H=(32 33)
   1.242 +	psrad     mm0,(DWORD_BIT-WORD_BIT)	; mm0=in3L=(30 31)
   1.243 +	cvtpi2ps  xmm0,mm2			; xmm0=(32 33 ** **)
   1.244 +	cvtpi2ps  xmm3,mm0			; xmm3=(30 31 ** **)
   1.245 +
   1.246 +	punpckhwd mm7,mm5			; mm7=(** 52 ** 53)
   1.247 +	punpcklwd mm5,mm5			; mm5=(50 50 51 51)
   1.248 +	punpckhwd mm3,mm1			; mm3=(** 72 ** 73)
   1.249 +	punpcklwd mm1,mm1			; mm1=(70 70 71 71)
   1.250 +
   1.251 +	movlhps   xmm2,xmm4			; xmm2=in1=(10 11 12 13)
   1.252 +	movlhps   xmm3,xmm0			; xmm3=in3=(30 31 32 33)
   1.253 +
   1.254 +	psrad     mm7,(DWORD_BIT-WORD_BIT)	; mm7=in5H=(52 53)
   1.255 +	psrad     mm5,(DWORD_BIT-WORD_BIT)	; mm5=in5L=(50 51)
   1.256 +	cvtpi2ps  xmm4,mm7			; xmm4=(52 53 ** **)
   1.257 +	cvtpi2ps  xmm5,mm5			; xmm5=(50 51 ** **)
   1.258 +	psrad     mm3,(DWORD_BIT-WORD_BIT)	; mm3=in7H=(72 73)
   1.259 +	psrad     mm1,(DWORD_BIT-WORD_BIT)	; mm1=in7L=(70 71)
   1.260 +	cvtpi2ps  xmm0,mm3			; xmm0=(72 73 ** **)
   1.261 +	cvtpi2ps  xmm1,mm1			; xmm1=(70 71 ** **)
   1.262 +
   1.263 +	mulps     xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.264 +	mulps     xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.265 +
   1.266 +	movlhps   xmm5,xmm4			; xmm5=in5=(50 51 52 53)
   1.267 +	movlhps   xmm1,xmm0			; xmm1=in7=(70 71 72 73)
   1.268 +	mulps     xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.269 +	mulps     xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
   1.270 +
   1.271 +	movaps	xmm4,xmm2
   1.272 +	movaps	xmm0,xmm5
   1.273 +	addps	xmm2,xmm1		; xmm2=z11
   1.274 +	addps	xmm5,xmm3		; xmm5=z13
   1.275 +	subps	xmm4,xmm1		; xmm4=z12
   1.276 +	subps	xmm0,xmm3		; xmm0=z10
   1.277 +
   1.278 +	movaps	xmm1,xmm2
   1.279 +	subps	xmm2,xmm5
   1.280 +	addps	xmm1,xmm5		; xmm1=tmp7
   1.281 +
   1.282 +	mulps	xmm2,[GOTOFF(ebx,PD_1_414)]	; xmm2=tmp11
   1.283 +
   1.284 +	movaps	xmm3,xmm0
   1.285 +	addps	xmm0,xmm4
   1.286 +	mulps	xmm0,[GOTOFF(ebx,PD_1_847)]	; xmm0=z5
   1.287 +	mulps	xmm3,[GOTOFF(ebx,PD_M2_613)]	; xmm3=(z10 * -2.613125930)
   1.288 +	mulps	xmm4,[GOTOFF(ebx,PD_1_082)]	; xmm4=(z12 * 1.082392200)
   1.289 +	addps	xmm3,xmm0		; xmm3=tmp12
   1.290 +	subps	xmm4,xmm0		; xmm4=tmp10
   1.291 +
   1.292 +	; -- Final output stage
   1.293 +
   1.294 +	subps	xmm3,xmm1		; xmm3=tmp6
   1.295 +	movaps	xmm5,xmm6
   1.296 +	movaps	xmm0,xmm7
   1.297 +	addps	xmm6,xmm1		; xmm6=data0=(00 01 02 03)
   1.298 +	addps	xmm7,xmm3		; xmm7=data1=(10 11 12 13)
   1.299 +	subps	xmm5,xmm1		; xmm5=data7=(70 71 72 73)
   1.300 +	subps	xmm0,xmm3		; xmm0=data6=(60 61 62 63)
   1.301 +	subps	xmm2,xmm3		; xmm2=tmp5
   1.302 +
   1.303 +	movaps    xmm1,xmm6		; transpose coefficients(phase 1)
   1.304 +	unpcklps  xmm6,xmm7		; xmm6=(00 10 01 11)
   1.305 +	unpckhps  xmm1,xmm7		; xmm1=(02 12 03 13)
   1.306 +	movaps    xmm3,xmm0		; transpose coefficients(phase 1)
   1.307 +	unpcklps  xmm0,xmm5		; xmm0=(60 70 61 71)
   1.308 +	unpckhps  xmm3,xmm5		; xmm3=(62 72 63 73)
   1.309 +
   1.310 +	movaps	xmm7, XMMWORD [wk(0)]	; xmm7=tmp2
   1.311 +	movaps	xmm5, XMMWORD [wk(1)]	; xmm5=tmp3
   1.312 +
   1.313 +	movaps	XMMWORD [wk(0)], xmm0	; wk(0)=(60 70 61 71)
   1.314 +	movaps	XMMWORD [wk(1)], xmm3	; wk(1)=(62 72 63 73)
   1.315 +
   1.316 +	addps	xmm4,xmm2		; xmm4=tmp4
   1.317 +	movaps	xmm0,xmm7
   1.318 +	movaps	xmm3,xmm5
   1.319 +	addps	xmm7,xmm2		; xmm7=data2=(20 21 22 23)
   1.320 +	addps	xmm5,xmm4		; xmm5=data4=(40 41 42 43)
   1.321 +	subps	xmm0,xmm2		; xmm0=data5=(50 51 52 53)
   1.322 +	subps	xmm3,xmm4		; xmm3=data3=(30 31 32 33)
   1.323 +
   1.324 +	movaps    xmm2,xmm7		; transpose coefficients(phase 1)
   1.325 +	unpcklps  xmm7,xmm3		; xmm7=(20 30 21 31)
   1.326 +	unpckhps  xmm2,xmm3		; xmm2=(22 32 23 33)
   1.327 +	movaps    xmm4,xmm5		; transpose coefficients(phase 1)
   1.328 +	unpcklps  xmm5,xmm0		; xmm5=(40 50 41 51)
   1.329 +	unpckhps  xmm4,xmm0		; xmm4=(42 52 43 53)
   1.330 +
   1.331 +	movaps    xmm3,xmm6		; transpose coefficients(phase 2)
   1.332 +	unpcklps2 xmm6,xmm7		; xmm6=(00 10 20 30)
   1.333 +	unpckhps2 xmm3,xmm7		; xmm3=(01 11 21 31)
   1.334 +	movaps    xmm0,xmm1		; transpose coefficients(phase 2)
   1.335 +	unpcklps2 xmm1,xmm2		; xmm1=(02 12 22 32)
   1.336 +	unpckhps2 xmm0,xmm2		; xmm0=(03 13 23 33)
   1.337 +
   1.338 +	movaps	xmm7, XMMWORD [wk(0)]	; xmm7=(60 70 61 71)
   1.339 +	movaps	xmm2, XMMWORD [wk(1)]	; xmm2=(62 72 63 73)
   1.340 +
   1.341 +	movaps	XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm6
   1.342 +	movaps	XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm3
   1.343 +	movaps	XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm1
   1.344 +	movaps	XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0
   1.345 +
   1.346 +	movaps    xmm6,xmm5		; transpose coefficients(phase 2)
   1.347 +	unpcklps2 xmm5,xmm7		; xmm5=(40 50 60 70)
   1.348 +	unpckhps2 xmm6,xmm7		; xmm6=(41 51 61 71)
   1.349 +	movaps    xmm3,xmm4		; transpose coefficients(phase 2)
   1.350 +	unpcklps2 xmm4,xmm2		; xmm4=(42 52 62 72)
   1.351 +	unpckhps2 xmm3,xmm2		; xmm3=(43 53 63 73)
   1.352 +
   1.353 +	movaps	XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5
   1.354 +	movaps	XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
   1.355 +	movaps	XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm4
   1.356 +	movaps	XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
   1.357 +
   1.358 +.nextcolumn:
   1.359 +	add	esi, byte 4*SIZEOF_JCOEF		; coef_block
   1.360 +	add	edx, byte 4*SIZEOF_FLOAT_MULT_TYPE	; quantptr
   1.361 +	add	edi,      4*DCTSIZE*SIZEOF_FAST_FLOAT	; wsptr
   1.362 +	dec	ecx					; ctr
   1.363 +	jnz	near .columnloop
   1.364 +
   1.365 +	; -- Prefetch the next coefficient block
   1.366 +
   1.367 +	prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
   1.368 +	prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
   1.369 +	prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
   1.370 +	prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
   1.371 +
   1.372 +	; ---- Pass 2: process rows from work array, store into output array.
   1.373 +
   1.374 +	mov	eax, [original_ebp]
   1.375 +	lea	esi, [workspace]			; FAST_FLOAT * wsptr
   1.376 +	mov	edi, JSAMPARRAY [output_buf(eax)]	; (JSAMPROW *)
   1.377 +	mov	eax, JDIMENSION [output_col(eax)]
   1.378 +	mov	ecx, DCTSIZE/4				; ctr
   1.379 +	alignx	16,7
   1.380 +.rowloop:
   1.381 +
   1.382 +	; -- Even part
   1.383 +
   1.384 +	movaps	xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
   1.385 +	movaps	xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)]
   1.386 +	movaps	xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)]
   1.387 +	movaps	xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)]
   1.388 +
   1.389 +	movaps	xmm4,xmm0
   1.390 +	movaps	xmm5,xmm1
   1.391 +	subps	xmm0,xmm2		; xmm0=tmp11
   1.392 +	subps	xmm1,xmm3
   1.393 +	addps	xmm4,xmm2		; xmm4=tmp10
   1.394 +	addps	xmm5,xmm3		; xmm5=tmp13
   1.395 +
   1.396 +	mulps	xmm1,[GOTOFF(ebx,PD_1_414)]
   1.397 +	subps	xmm1,xmm5		; xmm1=tmp12
   1.398 +
   1.399 +	movaps	xmm6,xmm4
   1.400 +	movaps	xmm7,xmm0
   1.401 +	subps	xmm4,xmm5		; xmm4=tmp3
   1.402 +	subps	xmm0,xmm1		; xmm0=tmp2
   1.403 +	addps	xmm6,xmm5		; xmm6=tmp0
   1.404 +	addps	xmm7,xmm1		; xmm7=tmp1
   1.405 +
   1.406 +	movaps	XMMWORD [wk(1)], xmm4	; tmp3
   1.407 +	movaps	XMMWORD [wk(0)], xmm0	; tmp2
   1.408 +
   1.409 +	; -- Odd part
   1.410 +
   1.411 +	movaps	xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
   1.412 +	movaps	xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)]
   1.413 +	movaps	xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)]
   1.414 +	movaps	xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)]
   1.415 +
   1.416 +	movaps	xmm4,xmm2
   1.417 +	movaps	xmm0,xmm5
   1.418 +	addps	xmm2,xmm1		; xmm2=z11
   1.419 +	addps	xmm5,xmm3		; xmm5=z13
   1.420 +	subps	xmm4,xmm1		; xmm4=z12
   1.421 +	subps	xmm0,xmm3		; xmm0=z10
   1.422 +
   1.423 +	movaps	xmm1,xmm2
   1.424 +	subps	xmm2,xmm5
   1.425 +	addps	xmm1,xmm5		; xmm1=tmp7
   1.426 +
   1.427 +	mulps	xmm2,[GOTOFF(ebx,PD_1_414)]	; xmm2=tmp11
   1.428 +
   1.429 +	movaps	xmm3,xmm0
   1.430 +	addps	xmm0,xmm4
   1.431 +	mulps	xmm0,[GOTOFF(ebx,PD_1_847)]	; xmm0=z5
   1.432 +	mulps	xmm3,[GOTOFF(ebx,PD_M2_613)]	; xmm3=(z10 * -2.613125930)
   1.433 +	mulps	xmm4,[GOTOFF(ebx,PD_1_082)]	; xmm4=(z12 * 1.082392200)
   1.434 +	addps	xmm3,xmm0		; xmm3=tmp12
   1.435 +	subps	xmm4,xmm0		; xmm4=tmp10
   1.436 +
   1.437 +	; -- Final output stage
   1.438 +
   1.439 +	subps	xmm3,xmm1		; xmm3=tmp6
   1.440 +	movaps	xmm5,xmm6
   1.441 +	movaps	xmm0,xmm7
   1.442 +	addps	xmm6,xmm1		; xmm6=data0=(00 10 20 30)
   1.443 +	addps	xmm7,xmm3		; xmm7=data1=(01 11 21 31)
   1.444 +	subps	xmm5,xmm1		; xmm5=data7=(07 17 27 37)
   1.445 +	subps	xmm0,xmm3		; xmm0=data6=(06 16 26 36)
   1.446 +	subps	xmm2,xmm3		; xmm2=tmp5
   1.447 +
   1.448 +	movaps	xmm1,[GOTOFF(ebx,PD_0_125)]	; xmm1=[PD_0_125]
   1.449 +
   1.450 +	mulps	xmm6,xmm1		; descale(1/8)
   1.451 +	mulps	xmm7,xmm1		; descale(1/8)
   1.452 +	mulps	xmm5,xmm1		; descale(1/8)
   1.453 +	mulps	xmm0,xmm1		; descale(1/8)
   1.454 +
   1.455 +	movhlps   xmm3,xmm6
   1.456 +	movhlps   xmm1,xmm7
   1.457 +	cvtps2pi  mm0,xmm6		; round to int32, mm0=data0L=(00 10)
   1.458 +	cvtps2pi  mm1,xmm7		; round to int32, mm1=data1L=(01 11)
   1.459 +	cvtps2pi  mm2,xmm3		; round to int32, mm2=data0H=(20 30)
   1.460 +	cvtps2pi  mm3,xmm1		; round to int32, mm3=data1H=(21 31)
   1.461 +	packssdw  mm0,mm2		; mm0=data0=(00 10 20 30)
   1.462 +	packssdw  mm1,mm3		; mm1=data1=(01 11 21 31)
   1.463 +
   1.464 +	movhlps   xmm6,xmm5
   1.465 +	movhlps   xmm7,xmm0
   1.466 +	cvtps2pi  mm4,xmm5		; round to int32, mm4=data7L=(07 17)
   1.467 +	cvtps2pi  mm5,xmm0		; round to int32, mm5=data6L=(06 16)
   1.468 +	cvtps2pi  mm6,xmm6		; round to int32, mm6=data7H=(27 37)
   1.469 +	cvtps2pi  mm7,xmm7		; round to int32, mm7=data6H=(26 36)
   1.470 +	packssdw  mm4,mm6		; mm4=data7=(07 17 27 37)
   1.471 +	packssdw  mm5,mm7		; mm5=data6=(06 16 26 36)
   1.472 +
   1.473 +	packsswb  mm0,mm5		; mm0=(00 10 20 30 06 16 26 36)
   1.474 +	packsswb  mm1,mm4		; mm1=(01 11 21 31 07 17 27 37)
   1.475 +
   1.476 +	movaps	xmm3, XMMWORD [wk(0)]	; xmm3=tmp2
   1.477 +	movaps	xmm1, XMMWORD [wk(1)]	; xmm1=tmp3
   1.478 +
   1.479 +	movaps	xmm6,[GOTOFF(ebx,PD_0_125)]	; xmm6=[PD_0_125]
   1.480 +
   1.481 +	addps	xmm4,xmm2		; xmm4=tmp4
   1.482 +	movaps	xmm5,xmm3
   1.483 +	movaps	xmm0,xmm1
   1.484 +	addps	xmm3,xmm2		; xmm3=data2=(02 12 22 32)
   1.485 +	addps	xmm1,xmm4		; xmm1=data4=(04 14 24 34)
   1.486 +	subps	xmm5,xmm2		; xmm5=data5=(05 15 25 35)
   1.487 +	subps	xmm0,xmm4		; xmm0=data3=(03 13 23 33)
   1.488 +
   1.489 +	mulps	xmm3,xmm6		; descale(1/8)
   1.490 +	mulps	xmm1,xmm6		; descale(1/8)
   1.491 +	mulps	xmm5,xmm6		; descale(1/8)
   1.492 +	mulps	xmm0,xmm6		; descale(1/8)
   1.493 +
   1.494 +	movhlps   xmm7,xmm3
   1.495 +	movhlps   xmm2,xmm1
   1.496 +	cvtps2pi  mm2,xmm3		; round to int32, mm2=data2L=(02 12)
   1.497 +	cvtps2pi  mm3,xmm1		; round to int32, mm3=data4L=(04 14)
   1.498 +	cvtps2pi  mm6,xmm7		; round to int32, mm6=data2H=(22 32)
   1.499 +	cvtps2pi  mm7,xmm2		; round to int32, mm7=data4H=(24 34)
   1.500 +	packssdw  mm2,mm6		; mm2=data2=(02 12 22 32)
   1.501 +	packssdw  mm3,mm7		; mm3=data4=(04 14 24 34)
   1.502 +
   1.503 +	movhlps   xmm4,xmm5
   1.504 +	movhlps   xmm6,xmm0
   1.505 +	cvtps2pi  mm5,xmm5		; round to int32, mm5=data5L=(05 15)
   1.506 +	cvtps2pi  mm4,xmm0		; round to int32, mm4=data3L=(03 13)
   1.507 +	cvtps2pi  mm6,xmm4		; round to int32, mm6=data5H=(25 35)
   1.508 +	cvtps2pi  mm7,xmm6		; round to int32, mm7=data3H=(23 33)
   1.509 +	packssdw  mm5,mm6		; mm5=data5=(05 15 25 35)
   1.510 +	packssdw  mm4,mm7		; mm4=data3=(03 13 23 33)
   1.511 +
   1.512 +	movq      mm6,[GOTOFF(ebx,PB_CENTERJSAMP)]	; mm6=[PB_CENTERJSAMP]
   1.513 +
   1.514 +	packsswb  mm2,mm3		; mm2=(02 12 22 32 04 14 24 34)
   1.515 +	packsswb  mm4,mm5		; mm4=(03 13 23 33 05 15 25 35)
   1.516 +
   1.517 +	paddb     mm0,mm6
   1.518 +	paddb     mm1,mm6
   1.519 +	paddb     mm2,mm6
   1.520 +	paddb     mm4,mm6
   1.521 +
   1.522 +	movq      mm7,mm0		; transpose coefficients(phase 1)
   1.523 +	punpcklbw mm0,mm1		; mm0=(00 01 10 11 20 21 30 31)
   1.524 +	punpckhbw mm7,mm1		; mm7=(06 07 16 17 26 27 36 37)
   1.525 +	movq      mm3,mm2		; transpose coefficients(phase 1)
   1.526 +	punpcklbw mm2,mm4		; mm2=(02 03 12 13 22 23 32 33)
   1.527 +	punpckhbw mm3,mm4		; mm3=(04 05 14 15 24 25 34 35)
   1.528 +
   1.529 +	movq      mm5,mm0		; transpose coefficients(phase 2)
   1.530 +	punpcklwd mm0,mm2		; mm0=(00 01 02 03 10 11 12 13)
   1.531 +	punpckhwd mm5,mm2		; mm5=(20 21 22 23 30 31 32 33)
   1.532 +	movq      mm6,mm3		; transpose coefficients(phase 2)
   1.533 +	punpcklwd mm3,mm7		; mm3=(04 05 06 07 14 15 16 17)
   1.534 +	punpckhwd mm6,mm7		; mm6=(24 25 26 27 34 35 36 37)
   1.535 +
   1.536 +	movq      mm1,mm0		; transpose coefficients(phase 3)
   1.537 +	punpckldq mm0,mm3		; mm0=(00 01 02 03 04 05 06 07)
   1.538 +	punpckhdq mm1,mm3		; mm1=(10 11 12 13 14 15 16 17)
   1.539 +	movq      mm4,mm5		; transpose coefficients(phase 3)
   1.540 +	punpckldq mm5,mm6		; mm5=(20 21 22 23 24 25 26 27)
   1.541 +	punpckhdq mm4,mm6		; mm4=(30 31 32 33 34 35 36 37)
   1.542 +
   1.543 +	pushpic	ebx			; save GOT address
   1.544 +
   1.545 +	mov	edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
   1.546 +	mov	ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
   1.547 +	movq	MMWORD [edx+eax*SIZEOF_JSAMPLE], mm0
   1.548 +	movq	MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm1
   1.549 +	mov	edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
   1.550 +	mov	ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
   1.551 +	movq	MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5
   1.552 +	movq	MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4
   1.553 +
   1.554 +	poppic	ebx			; restore GOT address
   1.555 +
   1.556 +	add	esi, byte 4*SIZEOF_FAST_FLOAT	; wsptr
   1.557 +	add	edi, byte 4*SIZEOF_JSAMPROW
   1.558 +	dec	ecx				; ctr
   1.559 +	jnz	near .rowloop
   1.560 +
   1.561 +	emms		; empty MMX state
   1.562 +
   1.563 +	pop	edi
   1.564 +	pop	esi
   1.565 +;	pop	edx		; need not be preserved
   1.566 +;	pop	ecx		; need not be preserved
   1.567 +	pop	ebx
   1.568 +	mov	esp,ebp		; esp <- aligned ebp
   1.569 +	pop	esp		; esp <- original ebp
   1.570 +	pop	ebp
   1.571 +	ret
   1.572 +
   1.573 +; For some reason, the OS X linker does not honor the request to align the
   1.574 +; segment unless we do this.
   1.575 +	align	16

mercurial