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