media/libjpeg/simd/jdmrgmmx.asm

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 ;
michael@0 2 ; jdmrgmmx.asm - merged upsampling/color 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 ; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
michael@0 24 ;
michael@0 25 ; GLOBAL(void)
michael@0 26 ; jsimd_h2v1_merged_upsample_mmx (JDIMENSION output_width,
michael@0 27 ; JSAMPIMAGE input_buf,
michael@0 28 ; JDIMENSION in_row_group_ctr,
michael@0 29 ; JSAMPARRAY output_buf);
michael@0 30 ;
michael@0 31
michael@0 32 %define output_width(b) (b)+8 ; JDIMENSION output_width
michael@0 33 %define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf
michael@0 34 %define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr
michael@0 35 %define output_buf(b) (b)+20 ; JSAMPARRAY output_buf
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 3
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_h2v1_merged_upsample_mmx)
michael@0 44
michael@0 45 EXTN(jsimd_h2v1_merged_upsample_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 [output_width(eax)] ; col
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 edi, JSAMPIMAGE [input_buf(eax)]
michael@0 70 mov ecx, JDIMENSION [in_row_group_ctr(eax)]
michael@0 71 mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
michael@0 72 mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
michael@0 73 mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
michael@0 74 mov edi, JSAMPARRAY [output_buf(eax)]
michael@0 75 mov esi, JSAMPROW [esi+ecx*SIZEOF_JSAMPROW] ; inptr0
michael@0 76 mov ebx, JSAMPROW [ebx+ecx*SIZEOF_JSAMPROW] ; inptr1
michael@0 77 mov edx, JSAMPROW [edx+ecx*SIZEOF_JSAMPROW] ; inptr2
michael@0 78 mov edi, JSAMPROW [edi] ; outptr
michael@0 79
michael@0 80 pop ecx ; col
michael@0 81
michael@0 82 alignx 16,7
michael@0 83 .columnloop:
michael@0 84 movpic eax, POINTER [gotptr] ; load GOT address (eax)
michael@0 85
michael@0 86 movq mm6, MMWORD [ebx] ; mm6=Cb(01234567)
michael@0 87 movq mm7, MMWORD [edx] ; mm7=Cr(01234567)
michael@0 88
michael@0 89 pxor mm1,mm1 ; mm1=(all 0's)
michael@0 90 pcmpeqw mm3,mm3
michael@0 91 psllw mm3,7 ; mm3={0xFF80 0xFF80 0xFF80 0xFF80}
michael@0 92
michael@0 93 movq mm4,mm6
michael@0 94 punpckhbw mm6,mm1 ; mm6=Cb(4567)=CbH
michael@0 95 punpcklbw mm4,mm1 ; mm4=Cb(0123)=CbL
michael@0 96 movq mm0,mm7
michael@0 97 punpckhbw mm7,mm1 ; mm7=Cr(4567)=CrH
michael@0 98 punpcklbw mm0,mm1 ; mm0=Cr(0123)=CrL
michael@0 99
michael@0 100 paddw mm6,mm3
michael@0 101 paddw mm4,mm3
michael@0 102 paddw mm7,mm3
michael@0 103 paddw mm0,mm3
michael@0 104
michael@0 105 ; (Original)
michael@0 106 ; R = Y + 1.40200 * Cr
michael@0 107 ; G = Y - 0.34414 * Cb - 0.71414 * Cr
michael@0 108 ; B = Y + 1.77200 * Cb
michael@0 109 ;
michael@0 110 ; (This implementation)
michael@0 111 ; R = Y + 0.40200 * Cr + Cr
michael@0 112 ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
michael@0 113 ; B = Y - 0.22800 * Cb + Cb + Cb
michael@0 114
michael@0 115 movq mm5,mm6 ; mm5=CbH
michael@0 116 movq mm2,mm4 ; mm2=CbL
michael@0 117 paddw mm6,mm6 ; mm6=2*CbH
michael@0 118 paddw mm4,mm4 ; mm4=2*CbL
michael@0 119 movq mm1,mm7 ; mm1=CrH
michael@0 120 movq mm3,mm0 ; mm3=CrL
michael@0 121 paddw mm7,mm7 ; mm7=2*CrH
michael@0 122 paddw mm0,mm0 ; mm0=2*CrL
michael@0 123
michael@0 124 pmulhw mm6,[GOTOFF(eax,PW_MF0228)] ; mm6=(2*CbH * -FIX(0.22800))
michael@0 125 pmulhw mm4,[GOTOFF(eax,PW_MF0228)] ; mm4=(2*CbL * -FIX(0.22800))
michael@0 126 pmulhw mm7,[GOTOFF(eax,PW_F0402)] ; mm7=(2*CrH * FIX(0.40200))
michael@0 127 pmulhw mm0,[GOTOFF(eax,PW_F0402)] ; mm0=(2*CrL * FIX(0.40200))
michael@0 128
michael@0 129 paddw mm6,[GOTOFF(eax,PW_ONE)]
michael@0 130 paddw mm4,[GOTOFF(eax,PW_ONE)]
michael@0 131 psraw mm6,1 ; mm6=(CbH * -FIX(0.22800))
michael@0 132 psraw mm4,1 ; mm4=(CbL * -FIX(0.22800))
michael@0 133 paddw mm7,[GOTOFF(eax,PW_ONE)]
michael@0 134 paddw mm0,[GOTOFF(eax,PW_ONE)]
michael@0 135 psraw mm7,1 ; mm7=(CrH * FIX(0.40200))
michael@0 136 psraw mm0,1 ; mm0=(CrL * FIX(0.40200))
michael@0 137
michael@0 138 paddw mm6,mm5
michael@0 139 paddw mm4,mm2
michael@0 140 paddw mm6,mm5 ; mm6=(CbH * FIX(1.77200))=(B-Y)H
michael@0 141 paddw mm4,mm2 ; mm4=(CbL * FIX(1.77200))=(B-Y)L
michael@0 142 paddw mm7,mm1 ; mm7=(CrH * FIX(1.40200))=(R-Y)H
michael@0 143 paddw mm0,mm3 ; mm0=(CrL * FIX(1.40200))=(R-Y)L
michael@0 144
michael@0 145 movq MMWORD [wk(0)], mm6 ; wk(0)=(B-Y)H
michael@0 146 movq MMWORD [wk(1)], mm7 ; wk(1)=(R-Y)H
michael@0 147
michael@0 148 movq mm6,mm5
michael@0 149 movq mm7,mm2
michael@0 150 punpcklwd mm5,mm1
michael@0 151 punpckhwd mm6,mm1
michael@0 152 pmaddwd mm5,[GOTOFF(eax,PW_MF0344_F0285)]
michael@0 153 pmaddwd mm6,[GOTOFF(eax,PW_MF0344_F0285)]
michael@0 154 punpcklwd mm2,mm3
michael@0 155 punpckhwd mm7,mm3
michael@0 156 pmaddwd mm2,[GOTOFF(eax,PW_MF0344_F0285)]
michael@0 157 pmaddwd mm7,[GOTOFF(eax,PW_MF0344_F0285)]
michael@0 158
michael@0 159 paddd mm5,[GOTOFF(eax,PD_ONEHALF)]
michael@0 160 paddd mm6,[GOTOFF(eax,PD_ONEHALF)]
michael@0 161 psrad mm5,SCALEBITS
michael@0 162 psrad mm6,SCALEBITS
michael@0 163 paddd mm2,[GOTOFF(eax,PD_ONEHALF)]
michael@0 164 paddd mm7,[GOTOFF(eax,PD_ONEHALF)]
michael@0 165 psrad mm2,SCALEBITS
michael@0 166 psrad mm7,SCALEBITS
michael@0 167
michael@0 168 packssdw mm5,mm6 ; mm5=CbH*-FIX(0.344)+CrH*FIX(0.285)
michael@0 169 packssdw mm2,mm7 ; mm2=CbL*-FIX(0.344)+CrL*FIX(0.285)
michael@0 170 psubw mm5,mm1 ; mm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H
michael@0 171 psubw mm2,mm3 ; mm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L
michael@0 172
michael@0 173 movq MMWORD [wk(2)], mm5 ; wk(2)=(G-Y)H
michael@0 174
michael@0 175 mov al,2 ; Yctr
michael@0 176 jmp short .Yloop_1st
michael@0 177 alignx 16,7
michael@0 178
michael@0 179 .Yloop_2nd:
michael@0 180 movq mm0, MMWORD [wk(1)] ; mm0=(R-Y)H
michael@0 181 movq mm2, MMWORD [wk(2)] ; mm2=(G-Y)H
michael@0 182 movq mm4, MMWORD [wk(0)] ; mm4=(B-Y)H
michael@0 183 alignx 16,7
michael@0 184
michael@0 185 .Yloop_1st:
michael@0 186 movq mm7, MMWORD [esi] ; mm7=Y(01234567)
michael@0 187
michael@0 188 pcmpeqw mm6,mm6
michael@0 189 psrlw mm6,BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..}
michael@0 190 pand mm6,mm7 ; mm6=Y(0246)=YE
michael@0 191 psrlw mm7,BYTE_BIT ; mm7=Y(1357)=YO
michael@0 192
michael@0 193 movq mm1,mm0 ; mm1=mm0=(R-Y)(L/H)
michael@0 194 movq mm3,mm2 ; mm3=mm2=(G-Y)(L/H)
michael@0 195 movq mm5,mm4 ; mm5=mm4=(B-Y)(L/H)
michael@0 196
michael@0 197 paddw mm0,mm6 ; mm0=((R-Y)+YE)=RE=(R0 R2 R4 R6)
michael@0 198 paddw mm1,mm7 ; mm1=((R-Y)+YO)=RO=(R1 R3 R5 R7)
michael@0 199 packuswb mm0,mm0 ; mm0=(R0 R2 R4 R6 ** ** ** **)
michael@0 200 packuswb mm1,mm1 ; mm1=(R1 R3 R5 R7 ** ** ** **)
michael@0 201
michael@0 202 paddw mm2,mm6 ; mm2=((G-Y)+YE)=GE=(G0 G2 G4 G6)
michael@0 203 paddw mm3,mm7 ; mm3=((G-Y)+YO)=GO=(G1 G3 G5 G7)
michael@0 204 packuswb mm2,mm2 ; mm2=(G0 G2 G4 G6 ** ** ** **)
michael@0 205 packuswb mm3,mm3 ; mm3=(G1 G3 G5 G7 ** ** ** **)
michael@0 206
michael@0 207 paddw mm4,mm6 ; mm4=((B-Y)+YE)=BE=(B0 B2 B4 B6)
michael@0 208 paddw mm5,mm7 ; mm5=((B-Y)+YO)=BO=(B1 B3 B5 B7)
michael@0 209 packuswb mm4,mm4 ; mm4=(B0 B2 B4 B6 ** ** ** **)
michael@0 210 packuswb mm5,mm5 ; mm5=(B1 B3 B5 B7 ** ** ** **)
michael@0 211
michael@0 212 %if RGB_PIXELSIZE == 3 ; ---------------
michael@0 213
michael@0 214 ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **)
michael@0 215 ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **)
michael@0 216 ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **)
michael@0 217 ; mmG=(** ** ** ** ** ** ** **), mmH=(** ** ** ** ** ** ** **)
michael@0 218
michael@0 219 punpcklbw mmA,mmC ; mmA=(00 10 02 12 04 14 06 16)
michael@0 220 punpcklbw mmE,mmB ; mmE=(20 01 22 03 24 05 26 07)
michael@0 221 punpcklbw mmD,mmF ; mmD=(11 21 13 23 15 25 17 27)
michael@0 222
michael@0 223 movq mmG,mmA
michael@0 224 movq mmH,mmA
michael@0 225 punpcklwd mmA,mmE ; mmA=(00 10 20 01 02 12 22 03)
michael@0 226 punpckhwd mmG,mmE ; mmG=(04 14 24 05 06 16 26 07)
michael@0 227
michael@0 228 psrlq mmH,2*BYTE_BIT ; mmH=(02 12 04 14 06 16 -- --)
michael@0 229 psrlq mmE,2*BYTE_BIT ; mmE=(22 03 24 05 26 07 -- --)
michael@0 230
michael@0 231 movq mmC,mmD
michael@0 232 movq mmB,mmD
michael@0 233 punpcklwd mmD,mmH ; mmD=(11 21 02 12 13 23 04 14)
michael@0 234 punpckhwd mmC,mmH ; mmC=(15 25 06 16 17 27 -- --)
michael@0 235
michael@0 236 psrlq mmB,2*BYTE_BIT ; mmB=(13 23 15 25 17 27 -- --)
michael@0 237
michael@0 238 movq mmF,mmE
michael@0 239 punpcklwd mmE,mmB ; mmE=(22 03 13 23 24 05 15 25)
michael@0 240 punpckhwd mmF,mmB ; mmF=(26 07 17 27 -- -- -- --)
michael@0 241
michael@0 242 punpckldq mmA,mmD ; mmA=(00 10 20 01 11 21 02 12)
michael@0 243 punpckldq mmE,mmG ; mmE=(22 03 13 23 04 14 24 05)
michael@0 244 punpckldq mmC,mmF ; mmC=(15 25 06 16 26 07 17 27)
michael@0 245
michael@0 246 cmp ecx, byte SIZEOF_MMWORD
michael@0 247 jb short .column_st16
michael@0 248
michael@0 249 movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
michael@0 250 movq MMWORD [edi+1*SIZEOF_MMWORD], mmE
michael@0 251 movq MMWORD [edi+2*SIZEOF_MMWORD], mmC
michael@0 252
michael@0 253 sub ecx, byte SIZEOF_MMWORD
michael@0 254 jz near .endcolumn
michael@0 255
michael@0 256 add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
michael@0 257 add esi, byte SIZEOF_MMWORD ; inptr0
michael@0 258 dec al ; Yctr
michael@0 259 jnz near .Yloop_2nd
michael@0 260
michael@0 261 add ebx, byte SIZEOF_MMWORD ; inptr1
michael@0 262 add edx, byte SIZEOF_MMWORD ; inptr2
michael@0 263 jmp near .columnloop
michael@0 264 alignx 16,7
michael@0 265
michael@0 266 .column_st16:
michael@0 267 lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
michael@0 268 cmp ecx, byte 2*SIZEOF_MMWORD
michael@0 269 jb short .column_st8
michael@0 270 movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
michael@0 271 movq MMWORD [edi+1*SIZEOF_MMWORD], mmE
michael@0 272 movq mmA,mmC
michael@0 273 sub ecx, byte 2*SIZEOF_MMWORD
michael@0 274 add edi, byte 2*SIZEOF_MMWORD
michael@0 275 jmp short .column_st4
michael@0 276 .column_st8:
michael@0 277 cmp ecx, byte SIZEOF_MMWORD
michael@0 278 jb short .column_st4
michael@0 279 movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
michael@0 280 movq mmA,mmE
michael@0 281 sub ecx, byte SIZEOF_MMWORD
michael@0 282 add edi, byte SIZEOF_MMWORD
michael@0 283 .column_st4:
michael@0 284 movd eax,mmA
michael@0 285 cmp ecx, byte SIZEOF_DWORD
michael@0 286 jb short .column_st2
michael@0 287 mov DWORD [edi+0*SIZEOF_DWORD], eax
michael@0 288 psrlq mmA,DWORD_BIT
michael@0 289 movd eax,mmA
michael@0 290 sub ecx, byte SIZEOF_DWORD
michael@0 291 add edi, byte SIZEOF_DWORD
michael@0 292 .column_st2:
michael@0 293 cmp ecx, byte SIZEOF_WORD
michael@0 294 jb short .column_st1
michael@0 295 mov WORD [edi+0*SIZEOF_WORD], ax
michael@0 296 shr eax,WORD_BIT
michael@0 297 sub ecx, byte SIZEOF_WORD
michael@0 298 add edi, byte SIZEOF_WORD
michael@0 299 .column_st1:
michael@0 300 cmp ecx, byte SIZEOF_BYTE
michael@0 301 jb short .endcolumn
michael@0 302 mov BYTE [edi+0*SIZEOF_BYTE], al
michael@0 303
michael@0 304 %else ; RGB_PIXELSIZE == 4 ; -----------
michael@0 305
michael@0 306 %ifdef RGBX_FILLER_0XFF
michael@0 307 pcmpeqb mm6,mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **)
michael@0 308 pcmpeqb mm7,mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **)
michael@0 309 %else
michael@0 310 pxor mm6,mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **)
michael@0 311 pxor mm7,mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **)
michael@0 312 %endif
michael@0 313 ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **)
michael@0 314 ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **)
michael@0 315 ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **)
michael@0 316 ; mmG=(30 32 34 36 ** ** ** **), mmH=(31 33 35 37 ** ** ** **)
michael@0 317
michael@0 318 punpcklbw mmA,mmC ; mmA=(00 10 02 12 04 14 06 16)
michael@0 319 punpcklbw mmE,mmG ; mmE=(20 30 22 32 24 34 26 36)
michael@0 320 punpcklbw mmB,mmD ; mmB=(01 11 03 13 05 15 07 17)
michael@0 321 punpcklbw mmF,mmH ; mmF=(21 31 23 33 25 35 27 37)
michael@0 322
michael@0 323 movq mmC,mmA
michael@0 324 punpcklwd mmA,mmE ; mmA=(00 10 20 30 02 12 22 32)
michael@0 325 punpckhwd mmC,mmE ; mmC=(04 14 24 34 06 16 26 36)
michael@0 326 movq mmG,mmB
michael@0 327 punpcklwd mmB,mmF ; mmB=(01 11 21 31 03 13 23 33)
michael@0 328 punpckhwd mmG,mmF ; mmG=(05 15 25 35 07 17 27 37)
michael@0 329
michael@0 330 movq mmD,mmA
michael@0 331 punpckldq mmA,mmB ; mmA=(00 10 20 30 01 11 21 31)
michael@0 332 punpckhdq mmD,mmB ; mmD=(02 12 22 32 03 13 23 33)
michael@0 333 movq mmH,mmC
michael@0 334 punpckldq mmC,mmG ; mmC=(04 14 24 34 05 15 25 35)
michael@0 335 punpckhdq mmH,mmG ; mmH=(06 16 26 36 07 17 27 37)
michael@0 336
michael@0 337 cmp ecx, byte SIZEOF_MMWORD
michael@0 338 jb short .column_st16
michael@0 339
michael@0 340 movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
michael@0 341 movq MMWORD [edi+1*SIZEOF_MMWORD], mmD
michael@0 342 movq MMWORD [edi+2*SIZEOF_MMWORD], mmC
michael@0 343 movq MMWORD [edi+3*SIZEOF_MMWORD], mmH
michael@0 344
michael@0 345 sub ecx, byte SIZEOF_MMWORD
michael@0 346 jz short .endcolumn
michael@0 347
michael@0 348 add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
michael@0 349 add esi, byte SIZEOF_MMWORD ; inptr0
michael@0 350 dec al ; Yctr
michael@0 351 jnz near .Yloop_2nd
michael@0 352
michael@0 353 add ebx, byte SIZEOF_MMWORD ; inptr1
michael@0 354 add edx, byte SIZEOF_MMWORD ; inptr2
michael@0 355 jmp near .columnloop
michael@0 356 alignx 16,7
michael@0 357
michael@0 358 .column_st16:
michael@0 359 cmp ecx, byte SIZEOF_MMWORD/2
michael@0 360 jb short .column_st8
michael@0 361 movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
michael@0 362 movq MMWORD [edi+1*SIZEOF_MMWORD], mmD
michael@0 363 movq mmA,mmC
michael@0 364 movq mmD,mmH
michael@0 365 sub ecx, byte SIZEOF_MMWORD/2
michael@0 366 add edi, byte 2*SIZEOF_MMWORD
michael@0 367 .column_st8:
michael@0 368 cmp ecx, byte SIZEOF_MMWORD/4
michael@0 369 jb short .column_st4
michael@0 370 movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
michael@0 371 movq mmA,mmD
michael@0 372 sub ecx, byte SIZEOF_MMWORD/4
michael@0 373 add edi, byte 1*SIZEOF_MMWORD
michael@0 374 .column_st4:
michael@0 375 cmp ecx, byte SIZEOF_MMWORD/8
michael@0 376 jb short .endcolumn
michael@0 377 movd DWORD [edi+0*SIZEOF_DWORD], mmA
michael@0 378
michael@0 379 %endif ; RGB_PIXELSIZE ; ---------------
michael@0 380
michael@0 381 .endcolumn:
michael@0 382 emms ; empty MMX state
michael@0 383
michael@0 384 .return:
michael@0 385 pop edi
michael@0 386 pop esi
michael@0 387 ; pop edx ; need not be preserved
michael@0 388 ; pop ecx ; need not be preserved
michael@0 389 pop ebx
michael@0 390 mov esp,ebp ; esp <- aligned ebp
michael@0 391 pop esp ; esp <- original ebp
michael@0 392 pop ebp
michael@0 393 ret
michael@0 394
michael@0 395 ; --------------------------------------------------------------------------
michael@0 396 ;
michael@0 397 ; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
michael@0 398 ;
michael@0 399 ; GLOBAL(void)
michael@0 400 ; jsimd_h2v2_merged_upsample_mmx (JDIMENSION output_width,
michael@0 401 ; JSAMPIMAGE input_buf,
michael@0 402 ; JDIMENSION in_row_group_ctr,
michael@0 403 ; JSAMPARRAY output_buf);
michael@0 404 ;
michael@0 405
michael@0 406 %define output_width(b) (b)+8 ; JDIMENSION output_width
michael@0 407 %define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf
michael@0 408 %define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr
michael@0 409 %define output_buf(b) (b)+20 ; JSAMPARRAY output_buf
michael@0 410
michael@0 411 align 16
michael@0 412 global EXTN(jsimd_h2v2_merged_upsample_mmx)
michael@0 413
michael@0 414 EXTN(jsimd_h2v2_merged_upsample_mmx):
michael@0 415 push ebp
michael@0 416 mov ebp,esp
michael@0 417 push ebx
michael@0 418 ; push ecx ; need not be preserved
michael@0 419 ; push edx ; need not be preserved
michael@0 420 push esi
michael@0 421 push edi
michael@0 422
michael@0 423 mov eax, JDIMENSION [output_width(ebp)]
michael@0 424
michael@0 425 mov edi, JSAMPIMAGE [input_buf(ebp)]
michael@0 426 mov ecx, JDIMENSION [in_row_group_ctr(ebp)]
michael@0 427 mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
michael@0 428 mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
michael@0 429 mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
michael@0 430 mov edi, JSAMPARRAY [output_buf(ebp)]
michael@0 431 lea esi, [esi+ecx*SIZEOF_JSAMPROW]
michael@0 432
michael@0 433 push edx ; inptr2
michael@0 434 push ebx ; inptr1
michael@0 435 push esi ; inptr00
michael@0 436 mov ebx,esp
michael@0 437
michael@0 438 push edi ; output_buf (outptr0)
michael@0 439 push ecx ; in_row_group_ctr
michael@0 440 push ebx ; input_buf
michael@0 441 push eax ; output_width
michael@0 442
michael@0 443 call near EXTN(jsimd_h2v1_merged_upsample_mmx)
michael@0 444
michael@0 445 add esi, byte SIZEOF_JSAMPROW ; inptr01
michael@0 446 add edi, byte SIZEOF_JSAMPROW ; outptr1
michael@0 447 mov POINTER [ebx+0*SIZEOF_POINTER], esi
michael@0 448 mov POINTER [ebx-1*SIZEOF_POINTER], edi
michael@0 449
michael@0 450 call near EXTN(jsimd_h2v1_merged_upsample_mmx)
michael@0 451
michael@0 452 add esp, byte 7*SIZEOF_DWORD
michael@0 453
michael@0 454 pop edi
michael@0 455 pop esi
michael@0 456 ; pop edx ; need not be preserved
michael@0 457 ; pop ecx ; need not be preserved
michael@0 458 pop ebx
michael@0 459 pop ebp
michael@0 460 ret
michael@0 461
michael@0 462 ; For some reason, the OS X linker does not honor the request to align the
michael@0 463 ; segment unless we do this.
michael@0 464 align 16

mercurial