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