OLD | NEW |
(Empty) | |
| 1 ; |
| 2 ; jcclrmmx.asm - colorspace conversion (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 ; [TAB8] |
| 18 |
| 19 %include "jcolsamp.inc" |
| 20 |
| 21 ; -------------------------------------------------------------------------- |
| 22 SECTION SEG_TEXT |
| 23 BITS 32 |
| 24 ; |
| 25 ; Convert some rows of samples to the output colorspace. |
| 26 ; |
| 27 ; GLOBAL(void) |
| 28 ; jsimd_rgb_ycc_convert_mmx (JDIMENSION img_width, |
| 29 ; JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 30 ; JDIMENSION output_row, int num_rows); |
| 31 ; |
| 32 |
| 33 %define img_width(b) (b)+8 ; JDIMENSION img_width |
| 34 %define input_buf(b) (b)+12 ; JSAMPARRAY input_buf |
| 35 %define output_buf(b) (b)+16 ; JSAMPIMAGE output_buf |
| 36 %define output_row(b) (b)+20 ; JDIMENSION output_row |
| 37 %define num_rows(b) (b)+24 ; int num_rows |
| 38 |
| 39 %define original_ebp ebp+0 |
| 40 %define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] |
| 41 %define WK_NUM 8 |
| 42 %define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr |
| 43 |
| 44 align 16 |
| 45 global EXTN(jsimd_rgb_ycc_convert_mmx) |
| 46 |
| 47 EXTN(jsimd_rgb_ycc_convert_mmx): |
| 48 push ebp |
| 49 mov eax,esp ; eax = original ebp |
| 50 sub esp, byte 4 |
| 51 and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits |
| 52 mov [esp],eax |
| 53 mov ebp,esp ; ebp = aligned ebp |
| 54 lea esp, [wk(0)] |
| 55 pushpic eax ; make a room for GOT address |
| 56 push ebx |
| 57 ; push ecx ; need not be preserved |
| 58 ; push edx ; need not be preserved |
| 59 push esi |
| 60 push edi |
| 61 |
| 62 get_GOT ebx ; get GOT address |
| 63 movpic POINTER [gotptr], ebx ; save GOT address |
| 64 |
| 65 mov ecx, JDIMENSION [img_width(eax)] ; num_cols |
| 66 test ecx,ecx |
| 67 jz near .return |
| 68 |
| 69 push ecx |
| 70 |
| 71 mov esi, JSAMPIMAGE [output_buf(eax)] |
| 72 mov ecx, JDIMENSION [output_row(eax)] |
| 73 mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY] |
| 74 mov ebx, JSAMPARRAY [esi+1*SIZEOF_JSAMPARRAY] |
| 75 mov edx, JSAMPARRAY [esi+2*SIZEOF_JSAMPARRAY] |
| 76 lea edi, [edi+ecx*SIZEOF_JSAMPROW] |
| 77 lea ebx, [ebx+ecx*SIZEOF_JSAMPROW] |
| 78 lea edx, [edx+ecx*SIZEOF_JSAMPROW] |
| 79 |
| 80 pop ecx |
| 81 |
| 82 mov esi, JSAMPARRAY [input_buf(eax)] |
| 83 mov eax, INT [num_rows(eax)] |
| 84 test eax,eax |
| 85 jle near .return |
| 86 alignx 16,7 |
| 87 .rowloop: |
| 88 pushpic eax |
| 89 push edx |
| 90 push ebx |
| 91 push edi |
| 92 push esi |
| 93 push ecx ; col |
| 94 |
| 95 mov esi, JSAMPROW [esi] ; inptr |
| 96 mov edi, JSAMPROW [edi] ; outptr0 |
| 97 mov ebx, JSAMPROW [ebx] ; outptr1 |
| 98 mov edx, JSAMPROW [edx] ; outptr2 |
| 99 movpic eax, POINTER [gotptr] ; load GOT address (eax) |
| 100 |
| 101 cmp ecx, byte SIZEOF_MMWORD |
| 102 jae short .columnloop |
| 103 alignx 16,7 |
| 104 |
| 105 %if RGB_PIXELSIZE == 3 ; --------------- |
| 106 |
| 107 .column_ld1: |
| 108 push eax |
| 109 push edx |
| 110 lea ecx,[ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE |
| 111 test cl, SIZEOF_BYTE |
| 112 jz short .column_ld2 |
| 113 sub ecx, byte SIZEOF_BYTE |
| 114 xor eax,eax |
| 115 mov al, BYTE [esi+ecx] |
| 116 .column_ld2: |
| 117 test cl, SIZEOF_WORD |
| 118 jz short .column_ld4 |
| 119 sub ecx, byte SIZEOF_WORD |
| 120 xor edx,edx |
| 121 mov dx, WORD [esi+ecx] |
| 122 shl eax, WORD_BIT |
| 123 or eax,edx |
| 124 .column_ld4: |
| 125 movd mmA,eax |
| 126 pop edx |
| 127 pop eax |
| 128 test cl, SIZEOF_DWORD |
| 129 jz short .column_ld8 |
| 130 sub ecx, byte SIZEOF_DWORD |
| 131 movd mmG, DWORD [esi+ecx] |
| 132 psllq mmA, DWORD_BIT |
| 133 por mmA,mmG |
| 134 .column_ld8: |
| 135 test cl, SIZEOF_MMWORD |
| 136 jz short .column_ld16 |
| 137 movq mmG,mmA |
| 138 movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] |
| 139 mov ecx, SIZEOF_MMWORD |
| 140 jmp short .rgb_ycc_cnv |
| 141 .column_ld16: |
| 142 test cl, 2*SIZEOF_MMWORD |
| 143 mov ecx, SIZEOF_MMWORD |
| 144 jz short .rgb_ycc_cnv |
| 145 movq mmF,mmA |
| 146 movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] |
| 147 movq mmG, MMWORD [esi+1*SIZEOF_MMWORD] |
| 148 jmp short .rgb_ycc_cnv |
| 149 alignx 16,7 |
| 150 |
| 151 .columnloop: |
| 152 movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] |
| 153 movq mmG, MMWORD [esi+1*SIZEOF_MMWORD] |
| 154 movq mmF, MMWORD [esi+2*SIZEOF_MMWORD] |
| 155 |
| 156 .rgb_ycc_cnv: |
| 157 ; mmA=(00 10 20 01 11 21 02 12) |
| 158 ; mmG=(22 03 13 23 04 14 24 05) |
| 159 ; mmF=(15 25 06 16 26 07 17 27) |
| 160 |
| 161 movq mmD,mmA |
| 162 psllq mmA,4*BYTE_BIT ; mmA=(-- -- -- -- 00 10 20 01) |
| 163 psrlq mmD,4*BYTE_BIT ; mmD=(11 21 02 12 -- -- -- --) |
| 164 |
| 165 punpckhbw mmA,mmG ; mmA=(00 04 10 14 20 24 01 05) |
| 166 psllq mmG,4*BYTE_BIT ; mmG=(-- -- -- -- 22 03 13 23) |
| 167 |
| 168 punpcklbw mmD,mmF ; mmD=(11 15 21 25 02 06 12 16) |
| 169 punpckhbw mmG,mmF ; mmG=(22 26 03 07 13 17 23 27) |
| 170 |
| 171 movq mmE,mmA |
| 172 psllq mmA,4*BYTE_BIT ; mmA=(-- -- -- -- 00 04 10 14) |
| 173 psrlq mmE,4*BYTE_BIT ; mmE=(20 24 01 05 -- -- -- --) |
| 174 |
| 175 punpckhbw mmA,mmD ; mmA=(00 02 04 06 10 12 14 16) |
| 176 psllq mmD,4*BYTE_BIT ; mmD=(-- -- -- -- 11 15 21 25) |
| 177 |
| 178 punpcklbw mmE,mmG ; mmE=(20 22 24 26 01 03 05 07) |
| 179 punpckhbw mmD,mmG ; mmD=(11 13 15 17 21 23 25 27) |
| 180 |
| 181 pxor mmH,mmH |
| 182 |
| 183 movq mmC,mmA |
| 184 punpcklbw mmA,mmH ; mmA=(00 02 04 06) |
| 185 punpckhbw mmC,mmH ; mmC=(10 12 14 16) |
| 186 |
| 187 movq mmB,mmE |
| 188 punpcklbw mmE,mmH ; mmE=(20 22 24 26) |
| 189 punpckhbw mmB,mmH ; mmB=(01 03 05 07) |
| 190 |
| 191 movq mmF,mmD |
| 192 punpcklbw mmD,mmH ; mmD=(11 13 15 17) |
| 193 punpckhbw mmF,mmH ; mmF=(21 23 25 27) |
| 194 |
| 195 %else ; RGB_PIXELSIZE == 4 ; ----------- |
| 196 |
| 197 .column_ld1: |
| 198 test cl, SIZEOF_MMWORD/8 |
| 199 jz short .column_ld2 |
| 200 sub ecx, byte SIZEOF_MMWORD/8 |
| 201 movd mmA, DWORD [esi+ecx*RGB_PIXELSIZE] |
| 202 .column_ld2: |
| 203 test cl, SIZEOF_MMWORD/4 |
| 204 jz short .column_ld4 |
| 205 sub ecx, byte SIZEOF_MMWORD/4 |
| 206 movq mmF,mmA |
| 207 movq mmA, MMWORD [esi+ecx*RGB_PIXELSIZE] |
| 208 .column_ld4: |
| 209 test cl, SIZEOF_MMWORD/2 |
| 210 mov ecx, SIZEOF_MMWORD |
| 211 jz short .rgb_ycc_cnv |
| 212 movq mmD,mmA |
| 213 movq mmC,mmF |
| 214 movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] |
| 215 movq mmF, MMWORD [esi+1*SIZEOF_MMWORD] |
| 216 jmp short .rgb_ycc_cnv |
| 217 alignx 16,7 |
| 218 |
| 219 .columnloop: |
| 220 movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] |
| 221 movq mmF, MMWORD [esi+1*SIZEOF_MMWORD] |
| 222 movq mmD, MMWORD [esi+2*SIZEOF_MMWORD] |
| 223 movq mmC, MMWORD [esi+3*SIZEOF_MMWORD] |
| 224 |
| 225 .rgb_ycc_cnv: |
| 226 ; mmA=(00 10 20 30 01 11 21 31) |
| 227 ; mmF=(02 12 22 32 03 13 23 33) |
| 228 ; mmD=(04 14 24 34 05 15 25 35) |
| 229 ; mmC=(06 16 26 36 07 17 27 37) |
| 230 |
| 231 movq mmB,mmA |
| 232 punpcklbw mmA,mmF ; mmA=(00 02 10 12 20 22 30 32) |
| 233 punpckhbw mmB,mmF ; mmB=(01 03 11 13 21 23 31 33) |
| 234 |
| 235 movq mmG,mmD |
| 236 punpcklbw mmD,mmC ; mmD=(04 06 14 16 24 26 34 36) |
| 237 punpckhbw mmG,mmC ; mmG=(05 07 15 17 25 27 35 37) |
| 238 |
| 239 movq mmE,mmA |
| 240 punpcklwd mmA,mmD ; mmA=(00 02 04 06 10 12 14 16) |
| 241 punpckhwd mmE,mmD ; mmE=(20 22 24 26 30 32 34 36) |
| 242 |
| 243 movq mmH,mmB |
| 244 punpcklwd mmB,mmG ; mmB=(01 03 05 07 11 13 15 17) |
| 245 punpckhwd mmH,mmG ; mmH=(21 23 25 27 31 33 35 37) |
| 246 |
| 247 pxor mmF,mmF |
| 248 |
| 249 movq mmC,mmA |
| 250 punpcklbw mmA,mmF ; mmA=(00 02 04 06) |
| 251 punpckhbw mmC,mmF ; mmC=(10 12 14 16) |
| 252 |
| 253 movq mmD,mmB |
| 254 punpcklbw mmB,mmF ; mmB=(01 03 05 07) |
| 255 punpckhbw mmD,mmF ; mmD=(11 13 15 17) |
| 256 |
| 257 movq mmG,mmE |
| 258 punpcklbw mmE,mmF ; mmE=(20 22 24 26) |
| 259 punpckhbw mmG,mmF ; mmG=(30 32 34 36) |
| 260 |
| 261 punpcklbw mmF,mmH |
| 262 punpckhbw mmH,mmH |
| 263 psrlw mmF,BYTE_BIT ; mmF=(21 23 25 27) |
| 264 psrlw mmH,BYTE_BIT ; mmH=(31 33 35 37) |
| 265 |
| 266 %endif ; RGB_PIXELSIZE ; --------------- |
| 267 |
| 268 ; mm0=(R0 R2 R4 R6)=RE, mm2=(G0 G2 G4 G6)=GE, mm4=(B0 B2 B4 B6)=BE |
| 269 ; mm1=(R1 R3 R5 R7)=RO, mm3=(G1 G3 G5 G7)=GO, mm5=(B1 B3 B5 B7)=BO |
| 270 |
| 271 ; (Original) |
| 272 ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B |
| 273 ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE |
| 274 ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE |
| 275 ; |
| 276 ; (This implementation) |
| 277 ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G |
| 278 ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE |
| 279 ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE |
| 280 |
| 281 movq MMWORD [wk(0)], mm0 ; wk(0)=RE |
| 282 movq MMWORD [wk(1)], mm1 ; wk(1)=RO |
| 283 movq MMWORD [wk(2)], mm4 ; wk(2)=BE |
| 284 movq MMWORD [wk(3)], mm5 ; wk(3)=BO |
| 285 |
| 286 movq mm6,mm1 |
| 287 punpcklwd mm1,mm3 |
| 288 punpckhwd mm6,mm3 |
| 289 movq mm7,mm1 |
| 290 movq mm4,mm6 |
| 291 pmaddwd mm1,[GOTOFF(eax,PW_F0299_F0337)] ; mm1=ROL*FIX(0.299)+GOL*FIX(
0.337) |
| 292 pmaddwd mm6,[GOTOFF(eax,PW_F0299_F0337)] ; mm6=ROH*FIX(0.299)+GOH*FIX(
0.337) |
| 293 pmaddwd mm7,[GOTOFF(eax,PW_MF016_MF033)] ; mm7=ROL*-FIX(0.168)+GOL*-FI
X(0.331) |
| 294 pmaddwd mm4,[GOTOFF(eax,PW_MF016_MF033)] ; mm4=ROH*-FIX(0.168)+GOH*-FI
X(0.331) |
| 295 |
| 296 movq MMWORD [wk(4)], mm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337) |
| 297 movq MMWORD [wk(5)], mm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337) |
| 298 |
| 299 pxor mm1,mm1 |
| 300 pxor mm6,mm6 |
| 301 punpcklwd mm1,mm5 ; mm1=BOL |
| 302 punpckhwd mm6,mm5 ; mm6=BOH |
| 303 psrld mm1,1 ; mm1=BOL*FIX(0.500) |
| 304 psrld mm6,1 ; mm6=BOH*FIX(0.500) |
| 305 |
| 306 movq mm5,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm5=[PD_ONEHALFM1_CJ] |
| 307 |
| 308 paddd mm7,mm1 |
| 309 paddd mm4,mm6 |
| 310 paddd mm7,mm5 |
| 311 paddd mm4,mm5 |
| 312 psrld mm7,SCALEBITS ; mm7=CbOL |
| 313 psrld mm4,SCALEBITS ; mm4=CbOH |
| 314 packssdw mm7,mm4 ; mm7=CbO |
| 315 |
| 316 movq mm1, MMWORD [wk(2)] ; mm1=BE |
| 317 |
| 318 movq mm6,mm0 |
| 319 punpcklwd mm0,mm2 |
| 320 punpckhwd mm6,mm2 |
| 321 movq mm5,mm0 |
| 322 movq mm4,mm6 |
| 323 pmaddwd mm0,[GOTOFF(eax,PW_F0299_F0337)] ; mm0=REL*FIX(0.299)+GEL*FIX(
0.337) |
| 324 pmaddwd mm6,[GOTOFF(eax,PW_F0299_F0337)] ; mm6=REH*FIX(0.299)+GEH*FIX(
0.337) |
| 325 pmaddwd mm5,[GOTOFF(eax,PW_MF016_MF033)] ; mm5=REL*-FIX(0.168)+GEL*-FI
X(0.331) |
| 326 pmaddwd mm4,[GOTOFF(eax,PW_MF016_MF033)] ; mm4=REH*-FIX(0.168)+GEH*-FI
X(0.331) |
| 327 |
| 328 movq MMWORD [wk(6)], mm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337) |
| 329 movq MMWORD [wk(7)], mm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337) |
| 330 |
| 331 pxor mm0,mm0 |
| 332 pxor mm6,mm6 |
| 333 punpcklwd mm0,mm1 ; mm0=BEL |
| 334 punpckhwd mm6,mm1 ; mm6=BEH |
| 335 psrld mm0,1 ; mm0=BEL*FIX(0.500) |
| 336 psrld mm6,1 ; mm6=BEH*FIX(0.500) |
| 337 |
| 338 movq mm1,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ] |
| 339 |
| 340 paddd mm5,mm0 |
| 341 paddd mm4,mm6 |
| 342 paddd mm5,mm1 |
| 343 paddd mm4,mm1 |
| 344 psrld mm5,SCALEBITS ; mm5=CbEL |
| 345 psrld mm4,SCALEBITS ; mm4=CbEH |
| 346 packssdw mm5,mm4 ; mm5=CbE |
| 347 |
| 348 psllw mm7,BYTE_BIT |
| 349 por mm5,mm7 ; mm5=Cb |
| 350 movq MMWORD [ebx], mm5 ; Save Cb |
| 351 |
| 352 movq mm0, MMWORD [wk(3)] ; mm0=BO |
| 353 movq mm6, MMWORD [wk(2)] ; mm6=BE |
| 354 movq mm1, MMWORD [wk(1)] ; mm1=RO |
| 355 |
| 356 movq mm4,mm0 |
| 357 punpcklwd mm0,mm3 |
| 358 punpckhwd mm4,mm3 |
| 359 movq mm7,mm0 |
| 360 movq mm5,mm4 |
| 361 pmaddwd mm0,[GOTOFF(eax,PW_F0114_F0250)] ; mm0=BOL*FIX(0.114)+GOL*FIX(
0.250) |
| 362 pmaddwd mm4,[GOTOFF(eax,PW_F0114_F0250)] ; mm4=BOH*FIX(0.114)+GOH*FIX(
0.250) |
| 363 pmaddwd mm7,[GOTOFF(eax,PW_MF008_MF041)] ; mm7=BOL*-FIX(0.081)+GOL*-FI
X(0.418) |
| 364 pmaddwd mm5,[GOTOFF(eax,PW_MF008_MF041)] ; mm5=BOH*-FIX(0.081)+GOH*-FI
X(0.418) |
| 365 |
| 366 movq mm3,[GOTOFF(eax,PD_ONEHALF)] ; mm3=[PD_ONEHALF] |
| 367 |
| 368 paddd mm0, MMWORD [wk(4)] |
| 369 paddd mm4, MMWORD [wk(5)] |
| 370 paddd mm0,mm3 |
| 371 paddd mm4,mm3 |
| 372 psrld mm0,SCALEBITS ; mm0=YOL |
| 373 psrld mm4,SCALEBITS ; mm4=YOH |
| 374 packssdw mm0,mm4 ; mm0=YO |
| 375 |
| 376 pxor mm3,mm3 |
| 377 pxor mm4,mm4 |
| 378 punpcklwd mm3,mm1 ; mm3=ROL |
| 379 punpckhwd mm4,mm1 ; mm4=ROH |
| 380 psrld mm3,1 ; mm3=ROL*FIX(0.500) |
| 381 psrld mm4,1 ; mm4=ROH*FIX(0.500) |
| 382 |
| 383 movq mm1,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ] |
| 384 |
| 385 paddd mm7,mm3 |
| 386 paddd mm5,mm4 |
| 387 paddd mm7,mm1 |
| 388 paddd mm5,mm1 |
| 389 psrld mm7,SCALEBITS ; mm7=CrOL |
| 390 psrld mm5,SCALEBITS ; mm5=CrOH |
| 391 packssdw mm7,mm5 ; mm7=CrO |
| 392 |
| 393 movq mm3, MMWORD [wk(0)] ; mm3=RE |
| 394 |
| 395 movq mm4,mm6 |
| 396 punpcklwd mm6,mm2 |
| 397 punpckhwd mm4,mm2 |
| 398 movq mm1,mm6 |
| 399 movq mm5,mm4 |
| 400 pmaddwd mm6,[GOTOFF(eax,PW_F0114_F0250)] ; mm6=BEL*FIX(0.114)+GEL*FIX(
0.250) |
| 401 pmaddwd mm4,[GOTOFF(eax,PW_F0114_F0250)] ; mm4=BEH*FIX(0.114)+GEH*FIX(
0.250) |
| 402 pmaddwd mm1,[GOTOFF(eax,PW_MF008_MF041)] ; mm1=BEL*-FIX(0.081)+GEL*-FI
X(0.418) |
| 403 pmaddwd mm5,[GOTOFF(eax,PW_MF008_MF041)] ; mm5=BEH*-FIX(0.081)+GEH*-FI
X(0.418) |
| 404 |
| 405 movq mm2,[GOTOFF(eax,PD_ONEHALF)] ; mm2=[PD_ONEHALF] |
| 406 |
| 407 paddd mm6, MMWORD [wk(6)] |
| 408 paddd mm4, MMWORD [wk(7)] |
| 409 paddd mm6,mm2 |
| 410 paddd mm4,mm2 |
| 411 psrld mm6,SCALEBITS ; mm6=YEL |
| 412 psrld mm4,SCALEBITS ; mm4=YEH |
| 413 packssdw mm6,mm4 ; mm6=YE |
| 414 |
| 415 psllw mm0,BYTE_BIT |
| 416 por mm6,mm0 ; mm6=Y |
| 417 movq MMWORD [edi], mm6 ; Save Y |
| 418 |
| 419 pxor mm2,mm2 |
| 420 pxor mm4,mm4 |
| 421 punpcklwd mm2,mm3 ; mm2=REL |
| 422 punpckhwd mm4,mm3 ; mm4=REH |
| 423 psrld mm2,1 ; mm2=REL*FIX(0.500) |
| 424 psrld mm4,1 ; mm4=REH*FIX(0.500) |
| 425 |
| 426 movq mm0,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm0=[PD_ONEHALFM1_CJ] |
| 427 |
| 428 paddd mm1,mm2 |
| 429 paddd mm5,mm4 |
| 430 paddd mm1,mm0 |
| 431 paddd mm5,mm0 |
| 432 psrld mm1,SCALEBITS ; mm1=CrEL |
| 433 psrld mm5,SCALEBITS ; mm5=CrEH |
| 434 packssdw mm1,mm5 ; mm1=CrE |
| 435 |
| 436 psllw mm7,BYTE_BIT |
| 437 por mm1,mm7 ; mm1=Cr |
| 438 movq MMWORD [edx], mm1 ; Save Cr |
| 439 |
| 440 sub ecx, byte SIZEOF_MMWORD |
| 441 add esi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; inptr |
| 442 add edi, byte SIZEOF_MMWORD ; outptr0 |
| 443 add ebx, byte SIZEOF_MMWORD ; outptr1 |
| 444 add edx, byte SIZEOF_MMWORD ; outptr2 |
| 445 cmp ecx, byte SIZEOF_MMWORD |
| 446 jae near .columnloop |
| 447 test ecx,ecx |
| 448 jnz near .column_ld1 |
| 449 |
| 450 pop ecx ; col |
| 451 pop esi |
| 452 pop edi |
| 453 pop ebx |
| 454 pop edx |
| 455 poppic eax |
| 456 |
| 457 add esi, byte SIZEOF_JSAMPROW ; input_buf |
| 458 add edi, byte SIZEOF_JSAMPROW |
| 459 add ebx, byte SIZEOF_JSAMPROW |
| 460 add edx, byte SIZEOF_JSAMPROW |
| 461 dec eax ; num_rows |
| 462 jg near .rowloop |
| 463 |
| 464 emms ; empty MMX state |
| 465 |
| 466 .return: |
| 467 pop edi |
| 468 pop esi |
| 469 ; pop edx ; need not be preserved |
| 470 ; pop ecx ; need not be preserved |
| 471 pop ebx |
| 472 mov esp,ebp ; esp <- aligned ebp |
| 473 pop esp ; esp <- original ebp |
| 474 pop ebp |
| 475 ret |
| 476 |
| 477 ; For some reason, the OS X linker does not honor the request to align the |
| 478 ; segment unless we do this. |
| 479 align 16 |
OLD | NEW |