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