1; 2; jdcolext.asm - colorspace conversion (SSE2) 3; 4; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB 5; Copyright (C) 2012, 2016, D. R. Commander. 6; 7; Based on the 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%include "jcolsamp.inc" 18 19; -------------------------------------------------------------------------- 20; 21; Convert some rows of samples to the output colorspace. 22; 23; GLOBAL(void) 24; jsimd_ycc_rgb_convert_sse2(JDIMENSION out_width, JSAMPIMAGE input_buf, 25; JDIMENSION input_row, JSAMPARRAY output_buf, 26; int num_rows) 27; 28 29%define out_width(b) (b) + 8 ; JDIMENSION out_width 30%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf 31%define input_row(b) (b) + 16 ; JDIMENSION input_row 32%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf 33%define num_rows(b) (b) + 24 ; int num_rows 34 35%define original_ebp ebp + 0 36%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD 37 ; xmmword wk[WK_NUM] 38%define WK_NUM 2 39%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr 40 41 align 32 42 GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_sse2) 43 44EXTN(jsimd_ycc_rgb_convert_sse2): 45 push ebp 46 mov eax, esp ; eax = original ebp 47 sub esp, byte 4 48 and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits 49 mov [esp], eax 50 mov ebp, esp ; ebp = aligned ebp 51 lea esp, [wk(0)] 52 pushpic eax ; make a room for GOT address 53 push ebx 54; push ecx ; need not be preserved 55; push edx ; need not be preserved 56 push esi 57 push edi 58 59 get_GOT ebx ; get GOT address 60 movpic POINTER [gotptr], ebx ; save GOT address 61 62 mov ecx, JDIMENSION [out_width(eax)] ; num_cols 63 test ecx, ecx 64 jz near .return 65 66 push ecx 67 68 mov edi, JSAMPIMAGE [input_buf(eax)] 69 mov ecx, JDIMENSION [input_row(eax)] 70 mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY] 71 mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY] 72 mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY] 73 lea esi, [esi+ecx*SIZEOF_JSAMPROW] 74 lea ebx, [ebx+ecx*SIZEOF_JSAMPROW] 75 lea edx, [edx+ecx*SIZEOF_JSAMPROW] 76 77 pop ecx 78 79 mov edi, JSAMPARRAY [output_buf(eax)] 80 mov eax, INT [num_rows(eax)] 81 test eax, eax 82 jle near .return 83 alignx 16, 7 84.rowloop: 85 push eax 86 push edi 87 push edx 88 push ebx 89 push esi 90 push ecx ; col 91 92 mov esi, JSAMPROW [esi] ; inptr0 93 mov ebx, JSAMPROW [ebx] ; inptr1 94 mov edx, JSAMPROW [edx] ; inptr2 95 mov edi, JSAMPROW [edi] ; outptr 96 movpic eax, POINTER [gotptr] ; load GOT address (eax) 97 alignx 16, 7 98.columnloop: 99 100 movdqa xmm5, XMMWORD [ebx] ; xmm5=Cb(0123456789ABCDEF) 101 movdqa xmm1, XMMWORD [edx] ; xmm1=Cr(0123456789ABCDEF) 102 103 pcmpeqw xmm4, xmm4 104 pcmpeqw xmm7, xmm7 105 psrlw xmm4, BYTE_BIT 106 psllw xmm7, 7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..} 107 movdqa xmm0, xmm4 ; xmm0=xmm4={0xFF 0x00 0xFF 0x00 ..} 108 109 pand xmm4, xmm5 ; xmm4=Cb(02468ACE)=CbE 110 psrlw xmm5, BYTE_BIT ; xmm5=Cb(13579BDF)=CbO 111 pand xmm0, xmm1 ; xmm0=Cr(02468ACE)=CrE 112 psrlw xmm1, BYTE_BIT ; xmm1=Cr(13579BDF)=CrO 113 114 paddw xmm4, xmm7 115 paddw xmm5, xmm7 116 paddw xmm0, xmm7 117 paddw xmm1, xmm7 118 119 ; (Original) 120 ; R = Y + 1.40200 * Cr 121 ; G = Y - 0.34414 * Cb - 0.71414 * Cr 122 ; B = Y + 1.77200 * Cb 123 ; 124 ; (This implementation) 125 ; R = Y + 0.40200 * Cr + Cr 126 ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr 127 ; B = Y - 0.22800 * Cb + Cb + Cb 128 129 movdqa xmm2, xmm4 ; xmm2=CbE 130 movdqa xmm3, xmm5 ; xmm3=CbO 131 paddw xmm4, xmm4 ; xmm4=2*CbE 132 paddw xmm5, xmm5 ; xmm5=2*CbO 133 movdqa xmm6, xmm0 ; xmm6=CrE 134 movdqa xmm7, xmm1 ; xmm7=CrO 135 paddw xmm0, xmm0 ; xmm0=2*CrE 136 paddw xmm1, xmm1 ; xmm1=2*CrO 137 138 pmulhw xmm4, [GOTOFF(eax,PW_MF0228)] ; xmm4=(2*CbE * -FIX(0.22800)) 139 pmulhw xmm5, [GOTOFF(eax,PW_MF0228)] ; xmm5=(2*CbO * -FIX(0.22800)) 140 pmulhw xmm0, [GOTOFF(eax,PW_F0402)] ; xmm0=(2*CrE * FIX(0.40200)) 141 pmulhw xmm1, [GOTOFF(eax,PW_F0402)] ; xmm1=(2*CrO * FIX(0.40200)) 142 143 paddw xmm4, [GOTOFF(eax,PW_ONE)] 144 paddw xmm5, [GOTOFF(eax,PW_ONE)] 145 psraw xmm4, 1 ; xmm4=(CbE * -FIX(0.22800)) 146 psraw xmm5, 1 ; xmm5=(CbO * -FIX(0.22800)) 147 paddw xmm0, [GOTOFF(eax,PW_ONE)] 148 paddw xmm1, [GOTOFF(eax,PW_ONE)] 149 psraw xmm0, 1 ; xmm0=(CrE * FIX(0.40200)) 150 psraw xmm1, 1 ; xmm1=(CrO * FIX(0.40200)) 151 152 paddw xmm4, xmm2 153 paddw xmm5, xmm3 154 paddw xmm4, xmm2 ; xmm4=(CbE * FIX(1.77200))=(B-Y)E 155 paddw xmm5, xmm3 ; xmm5=(CbO * FIX(1.77200))=(B-Y)O 156 paddw xmm0, xmm6 ; xmm0=(CrE * FIX(1.40200))=(R-Y)E 157 paddw xmm1, xmm7 ; xmm1=(CrO * FIX(1.40200))=(R-Y)O 158 159 movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=(B-Y)E 160 movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(B-Y)O 161 162 movdqa xmm4, xmm2 163 movdqa xmm5, xmm3 164 punpcklwd xmm2, xmm6 165 punpckhwd xmm4, xmm6 166 pmaddwd xmm2, [GOTOFF(eax,PW_MF0344_F0285)] 167 pmaddwd xmm4, [GOTOFF(eax,PW_MF0344_F0285)] 168 punpcklwd xmm3, xmm7 169 punpckhwd xmm5, xmm7 170 pmaddwd xmm3, [GOTOFF(eax,PW_MF0344_F0285)] 171 pmaddwd xmm5, [GOTOFF(eax,PW_MF0344_F0285)] 172 173 paddd xmm2, [GOTOFF(eax,PD_ONEHALF)] 174 paddd xmm4, [GOTOFF(eax,PD_ONEHALF)] 175 psrad xmm2, SCALEBITS 176 psrad xmm4, SCALEBITS 177 paddd xmm3, [GOTOFF(eax,PD_ONEHALF)] 178 paddd xmm5, [GOTOFF(eax,PD_ONEHALF)] 179 psrad xmm3, SCALEBITS 180 psrad xmm5, SCALEBITS 181 182 packssdw xmm2, xmm4 ; xmm2=CbE*-FIX(0.344)+CrE*FIX(0.285) 183 packssdw xmm3, xmm5 ; xmm3=CbO*-FIX(0.344)+CrO*FIX(0.285) 184 psubw xmm2, xmm6 ; xmm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E 185 psubw xmm3, xmm7 ; xmm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O 186 187 movdqa xmm5, XMMWORD [esi] ; xmm5=Y(0123456789ABCDEF) 188 189 pcmpeqw xmm4, xmm4 190 psrlw xmm4, BYTE_BIT ; xmm4={0xFF 0x00 0xFF 0x00 ..} 191 pand xmm4, xmm5 ; xmm4=Y(02468ACE)=YE 192 psrlw xmm5, BYTE_BIT ; xmm5=Y(13579BDF)=YO 193 194 paddw xmm0, xmm4 ; xmm0=((R-Y)E+YE)=RE=R(02468ACE) 195 paddw xmm1, xmm5 ; xmm1=((R-Y)O+YO)=RO=R(13579BDF) 196 packuswb xmm0, xmm0 ; xmm0=R(02468ACE********) 197 packuswb xmm1, xmm1 ; xmm1=R(13579BDF********) 198 199 paddw xmm2, xmm4 ; xmm2=((G-Y)E+YE)=GE=G(02468ACE) 200 paddw xmm3, xmm5 ; xmm3=((G-Y)O+YO)=GO=G(13579BDF) 201 packuswb xmm2, xmm2 ; xmm2=G(02468ACE********) 202 packuswb xmm3, xmm3 ; xmm3=G(13579BDF********) 203 204 paddw xmm4, XMMWORD [wk(0)] ; xmm4=(YE+(B-Y)E)=BE=B(02468ACE) 205 paddw xmm5, XMMWORD [wk(1)] ; xmm5=(YO+(B-Y)O)=BO=B(13579BDF) 206 packuswb xmm4, xmm4 ; xmm4=B(02468ACE********) 207 packuswb xmm5, xmm5 ; xmm5=B(13579BDF********) 208 209%if RGB_PIXELSIZE == 3 ; --------------- 210 211 ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) 212 ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) 213 ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) 214 ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **) 215 216 punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) 217 punpcklbw xmmE, xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F) 218 punpcklbw xmmD, xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F) 219 220 movdqa xmmG, xmmA 221 movdqa xmmH, xmmA 222 punpcklwd xmmA, xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07) 223 punpckhwd xmmG, xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F) 224 225 psrldq xmmH, 2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --) 226 psrldq xmmE, 2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --) 227 228 movdqa xmmC, xmmD 229 movdqa xmmB, xmmD 230 punpcklwd xmmD, xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18) 231 punpckhwd xmmC, xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --) 232 233 psrldq xmmB, 2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --) 234 235 movdqa xmmF, xmmE 236 punpcklwd xmmE, xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29) 237 punpckhwd xmmF, xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --) 238 239 pshufd xmmH, xmmA, 0x4E ; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03) 240 movdqa xmmB, xmmE 241 punpckldq xmmA, xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14) 242 punpckldq xmmE, xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07) 243 punpckhdq xmmD, xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29) 244 245 pshufd xmmH, xmmG, 0x4E ; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B) 246 movdqa xmmB, xmmF 247 punpckldq xmmG, xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C) 248 punpckldq xmmF, xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F) 249 punpckhdq xmmC, xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --) 250 251 punpcklqdq xmmA, xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05) 252 punpcklqdq xmmD, xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) 253 punpcklqdq xmmF, xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F) 254 255 cmp ecx, byte SIZEOF_XMMWORD 256 jb short .column_st32 257 258 test edi, SIZEOF_XMMWORD-1 259 jnz short .out1 260 ; --(aligned)------------------- 261 movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA 262 movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD 263 movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF 264 jmp short .out0 265.out1: ; --(unaligned)----------------- 266 movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA 267 movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD 268 movdqu XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF 269.out0: 270 add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr 271 sub ecx, byte SIZEOF_XMMWORD 272 jz near .nextrow 273 274 add esi, byte SIZEOF_XMMWORD ; inptr0 275 add ebx, byte SIZEOF_XMMWORD ; inptr1 276 add edx, byte SIZEOF_XMMWORD ; inptr2 277 jmp near .columnloop 278 alignx 16, 7 279 280.column_st32: 281 lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE 282 cmp ecx, byte 2*SIZEOF_XMMWORD 283 jb short .column_st16 284 movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA 285 movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD 286 add edi, byte 2*SIZEOF_XMMWORD ; outptr 287 movdqa xmmA, xmmF 288 sub ecx, byte 2*SIZEOF_XMMWORD 289 jmp short .column_st15 290.column_st16: 291 cmp ecx, byte SIZEOF_XMMWORD 292 jb short .column_st15 293 movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA 294 add edi, byte SIZEOF_XMMWORD ; outptr 295 movdqa xmmA, xmmD 296 sub ecx, byte SIZEOF_XMMWORD 297.column_st15: 298 ; Store the lower 8 bytes of xmmA to the output when it has enough 299 ; space. 300 cmp ecx, byte SIZEOF_MMWORD 301 jb short .column_st7 302 movq XMM_MMWORD [edi], xmmA 303 add edi, byte SIZEOF_MMWORD 304 sub ecx, byte SIZEOF_MMWORD 305 psrldq xmmA, SIZEOF_MMWORD 306.column_st7: 307 ; Store the lower 4 bytes of xmmA to the output when it has enough 308 ; space. 309 cmp ecx, byte SIZEOF_DWORD 310 jb short .column_st3 311 movd XMM_DWORD [edi], xmmA 312 add edi, byte SIZEOF_DWORD 313 sub ecx, byte SIZEOF_DWORD 314 psrldq xmmA, SIZEOF_DWORD 315.column_st3: 316 ; Store the lower 2 bytes of eax to the output when it has enough 317 ; space. 318 movd eax, xmmA 319 cmp ecx, byte SIZEOF_WORD 320 jb short .column_st1 321 mov word [edi], ax 322 add edi, byte SIZEOF_WORD 323 sub ecx, byte SIZEOF_WORD 324 shr eax, 16 325.column_st1: 326 ; Store the lower 1 byte of eax to the output when it has enough 327 ; space. 328 test ecx, ecx 329 jz short .nextrow 330 mov byte [edi], al 331 332%else ; RGB_PIXELSIZE == 4 ; ----------- 333 334%ifdef RGBX_FILLER_0XFF 335 pcmpeqb xmm6, xmm6 ; xmm6=XE=X(02468ACE********) 336 pcmpeqb xmm7, xmm7 ; xmm7=XO=X(13579BDF********) 337%else 338 pxor xmm6, xmm6 ; xmm6=XE=X(02468ACE********) 339 pxor xmm7, xmm7 ; xmm7=XO=X(13579BDF********) 340%endif 341 ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) 342 ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) 343 ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) 344 ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **) 345 346 punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) 347 punpcklbw xmmE, xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E) 348 punpcklbw xmmB, xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F) 349 punpcklbw xmmF, xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F) 350 351 movdqa xmmC, xmmA 352 punpcklwd xmmA, xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36) 353 punpckhwd xmmC, xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E) 354 movdqa xmmG, xmmB 355 punpcklwd xmmB, xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37) 356 punpckhwd xmmG, xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F) 357 358 movdqa xmmD, xmmA 359 punpckldq xmmA, xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33) 360 punpckhdq xmmD, xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) 361 movdqa xmmH, xmmC 362 punpckldq xmmC, xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B) 363 punpckhdq xmmH, xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) 364 365 cmp ecx, byte SIZEOF_XMMWORD 366 jb short .column_st32 367 368 test edi, SIZEOF_XMMWORD-1 369 jnz short .out1 370 ; --(aligned)------------------- 371 movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA 372 movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD 373 movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC 374 movntdq XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH 375 jmp short .out0 376.out1: ; --(unaligned)----------------- 377 movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA 378 movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD 379 movdqu XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC 380 movdqu XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH 381.out0: 382 add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr 383 sub ecx, byte SIZEOF_XMMWORD 384 jz near .nextrow 385 386 add esi, byte SIZEOF_XMMWORD ; inptr0 387 add ebx, byte SIZEOF_XMMWORD ; inptr1 388 add edx, byte SIZEOF_XMMWORD ; inptr2 389 jmp near .columnloop 390 alignx 16, 7 391 392.column_st32: 393 cmp ecx, byte SIZEOF_XMMWORD/2 394 jb short .column_st16 395 movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA 396 movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD 397 add edi, byte 2*SIZEOF_XMMWORD ; outptr 398 movdqa xmmA, xmmC 399 movdqa xmmD, xmmH 400 sub ecx, byte SIZEOF_XMMWORD/2 401.column_st16: 402 cmp ecx, byte SIZEOF_XMMWORD/4 403 jb short .column_st15 404 movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA 405 add edi, byte SIZEOF_XMMWORD ; outptr 406 movdqa xmmA, xmmD 407 sub ecx, byte SIZEOF_XMMWORD/4 408.column_st15: 409 ; Store two pixels (8 bytes) of xmmA to the output when it has enough 410 ; space. 411 cmp ecx, byte SIZEOF_XMMWORD/8 412 jb short .column_st7 413 movq XMM_MMWORD [edi], xmmA 414 add edi, byte SIZEOF_XMMWORD/8*4 415 sub ecx, byte SIZEOF_XMMWORD/8 416 psrldq xmmA, SIZEOF_XMMWORD/8*4 417.column_st7: 418 ; Store one pixel (4 bytes) of xmmA to the output when it has enough 419 ; space. 420 test ecx, ecx 421 jz short .nextrow 422 movd XMM_DWORD [edi], xmmA 423 424%endif ; RGB_PIXELSIZE ; --------------- 425 426 alignx 16, 7 427 428.nextrow: 429 pop ecx 430 pop esi 431 pop ebx 432 pop edx 433 pop edi 434 pop eax 435 436 add esi, byte SIZEOF_JSAMPROW 437 add ebx, byte SIZEOF_JSAMPROW 438 add edx, byte SIZEOF_JSAMPROW 439 add edi, byte SIZEOF_JSAMPROW ; output_buf 440 dec eax ; num_rows 441 jg near .rowloop 442 443 sfence ; flush the write buffer 444 445.return: 446 pop edi 447 pop esi 448; pop edx ; need not be preserved 449; pop ecx ; need not be preserved 450 pop ebx 451 mov esp, ebp ; esp <- aligned ebp 452 pop esp ; esp <- original ebp 453 pop ebp 454 ret 455 456; For some reason, the OS X linker does not honor the request to align the 457; segment unless we do this. 458 align 32 459