media/libjpeg/simd/jdsammmx.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 ; jdsammmx.asm - upsampling (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 "jsimdext.inc"
michael@0 20
michael@0 21 ; --------------------------------------------------------------------------
michael@0 22 SECTION SEG_CONST
michael@0 23
michael@0 24 alignz 16
michael@0 25 global EXTN(jconst_fancy_upsample_mmx)
michael@0 26
michael@0 27 EXTN(jconst_fancy_upsample_mmx):
michael@0 28
michael@0 29 PW_ONE times 4 dw 1
michael@0 30 PW_TWO times 4 dw 2
michael@0 31 PW_THREE times 4 dw 3
michael@0 32 PW_SEVEN times 4 dw 7
michael@0 33 PW_EIGHT times 4 dw 8
michael@0 34
michael@0 35 alignz 16
michael@0 36
michael@0 37 ; --------------------------------------------------------------------------
michael@0 38 SECTION SEG_TEXT
michael@0 39 BITS 32
michael@0 40 ;
michael@0 41 ; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
michael@0 42 ;
michael@0 43 ; The upsampling algorithm is linear interpolation between pixel centers,
michael@0 44 ; also known as a "triangle filter". This is a good compromise between
michael@0 45 ; speed and visual quality. The centers of the output pixels are 1/4 and 3/4
michael@0 46 ; of the way between input pixel centers.
michael@0 47 ;
michael@0 48 ; GLOBAL(void)
michael@0 49 ; jsimd_h2v1_fancy_upsample_mmx (int max_v_samp_factor,
michael@0 50 ; JDIMENSION downsampled_width,
michael@0 51 ; JSAMPARRAY input_data,
michael@0 52 ; JSAMPARRAY * output_data_ptr);
michael@0 53 ;
michael@0 54
michael@0 55 %define max_v_samp(b) (b)+8 ; int max_v_samp_factor
michael@0 56 %define downsamp_width(b) (b)+12 ; JDIMENSION downsampled_width
michael@0 57 %define input_data(b) (b)+16 ; JSAMPARRAY input_data
michael@0 58 %define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr
michael@0 59
michael@0 60 align 16
michael@0 61 global EXTN(jsimd_h2v1_fancy_upsample_mmx)
michael@0 62
michael@0 63 EXTN(jsimd_h2v1_fancy_upsample_mmx):
michael@0 64 push ebp
michael@0 65 mov ebp,esp
michael@0 66 pushpic ebx
michael@0 67 ; push ecx ; need not be preserved
michael@0 68 ; push edx ; need not be preserved
michael@0 69 push esi
michael@0 70 push edi
michael@0 71
michael@0 72 get_GOT ebx ; get GOT address
michael@0 73
michael@0 74 mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
michael@0 75 test eax,eax
michael@0 76 jz near .return
michael@0 77
michael@0 78 mov ecx, INT [max_v_samp(ebp)] ; rowctr
michael@0 79 test ecx,ecx
michael@0 80 jz near .return
michael@0 81
michael@0 82 mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
michael@0 83 mov edi, POINTER [output_data_ptr(ebp)]
michael@0 84 mov edi, JSAMPARRAY [edi] ; output_data
michael@0 85 alignx 16,7
michael@0 86 .rowloop:
michael@0 87 push eax ; colctr
michael@0 88 push edi
michael@0 89 push esi
michael@0 90
michael@0 91 mov esi, JSAMPROW [esi] ; inptr
michael@0 92 mov edi, JSAMPROW [edi] ; outptr
michael@0 93
michael@0 94 test eax, SIZEOF_MMWORD-1
michael@0 95 jz short .skip
michael@0 96 mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE]
michael@0 97 mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
michael@0 98 .skip:
michael@0 99 pxor mm0,mm0 ; mm0=(all 0's)
michael@0 100 pcmpeqb mm7,mm7
michael@0 101 psrlq mm7,(SIZEOF_MMWORD-1)*BYTE_BIT
michael@0 102 pand mm7, MMWORD [esi+0*SIZEOF_MMWORD]
michael@0 103
michael@0 104 add eax, byte SIZEOF_MMWORD-1
michael@0 105 and eax, byte -SIZEOF_MMWORD
michael@0 106 cmp eax, byte SIZEOF_MMWORD
michael@0 107 ja short .columnloop
michael@0 108 alignx 16,7
michael@0 109
michael@0 110 .columnloop_last:
michael@0 111 pcmpeqb mm6,mm6
michael@0 112 psllq mm6,(SIZEOF_MMWORD-1)*BYTE_BIT
michael@0 113 pand mm6, MMWORD [esi+0*SIZEOF_MMWORD]
michael@0 114 jmp short .upsample
michael@0 115 alignx 16,7
michael@0 116
michael@0 117 .columnloop:
michael@0 118 movq mm6, MMWORD [esi+1*SIZEOF_MMWORD]
michael@0 119 psllq mm6,(SIZEOF_MMWORD-1)*BYTE_BIT
michael@0 120
michael@0 121 .upsample:
michael@0 122 movq mm1, MMWORD [esi+0*SIZEOF_MMWORD]
michael@0 123 movq mm2,mm1
michael@0 124 movq mm3,mm1 ; mm1=( 0 1 2 3 4 5 6 7)
michael@0 125 psllq mm2,BYTE_BIT ; mm2=( - 0 1 2 3 4 5 6)
michael@0 126 psrlq mm3,BYTE_BIT ; mm3=( 1 2 3 4 5 6 7 -)
michael@0 127
michael@0 128 por mm2,mm7 ; mm2=(-1 0 1 2 3 4 5 6)
michael@0 129 por mm3,mm6 ; mm3=( 1 2 3 4 5 6 7 8)
michael@0 130
michael@0 131 movq mm7,mm1
michael@0 132 psrlq mm7,(SIZEOF_MMWORD-1)*BYTE_BIT ; mm7=( 7 - - - - - - -)
michael@0 133
michael@0 134 movq mm4,mm1
michael@0 135 punpcklbw mm1,mm0 ; mm1=( 0 1 2 3)
michael@0 136 punpckhbw mm4,mm0 ; mm4=( 4 5 6 7)
michael@0 137 movq mm5,mm2
michael@0 138 punpcklbw mm2,mm0 ; mm2=(-1 0 1 2)
michael@0 139 punpckhbw mm5,mm0 ; mm5=( 3 4 5 6)
michael@0 140 movq mm6,mm3
michael@0 141 punpcklbw mm3,mm0 ; mm3=( 1 2 3 4)
michael@0 142 punpckhbw mm6,mm0 ; mm6=( 5 6 7 8)
michael@0 143
michael@0 144 pmullw mm1,[GOTOFF(ebx,PW_THREE)]
michael@0 145 pmullw mm4,[GOTOFF(ebx,PW_THREE)]
michael@0 146 paddw mm2,[GOTOFF(ebx,PW_ONE)]
michael@0 147 paddw mm5,[GOTOFF(ebx,PW_ONE)]
michael@0 148 paddw mm3,[GOTOFF(ebx,PW_TWO)]
michael@0 149 paddw mm6,[GOTOFF(ebx,PW_TWO)]
michael@0 150
michael@0 151 paddw mm2,mm1
michael@0 152 paddw mm5,mm4
michael@0 153 psrlw mm2,2 ; mm2=OutLE=( 0 2 4 6)
michael@0 154 psrlw mm5,2 ; mm5=OutHE=( 8 10 12 14)
michael@0 155 paddw mm3,mm1
michael@0 156 paddw mm6,mm4
michael@0 157 psrlw mm3,2 ; mm3=OutLO=( 1 3 5 7)
michael@0 158 psrlw mm6,2 ; mm6=OutHO=( 9 11 13 15)
michael@0 159
michael@0 160 psllw mm3,BYTE_BIT
michael@0 161 psllw mm6,BYTE_BIT
michael@0 162 por mm2,mm3 ; mm2=OutL=( 0 1 2 3 4 5 6 7)
michael@0 163 por mm5,mm6 ; mm5=OutH=( 8 9 10 11 12 13 14 15)
michael@0 164
michael@0 165 movq MMWORD [edi+0*SIZEOF_MMWORD], mm2
michael@0 166 movq MMWORD [edi+1*SIZEOF_MMWORD], mm5
michael@0 167
michael@0 168 sub eax, byte SIZEOF_MMWORD
michael@0 169 add esi, byte 1*SIZEOF_MMWORD ; inptr
michael@0 170 add edi, byte 2*SIZEOF_MMWORD ; outptr
michael@0 171 cmp eax, byte SIZEOF_MMWORD
michael@0 172 ja near .columnloop
michael@0 173 test eax,eax
michael@0 174 jnz near .columnloop_last
michael@0 175
michael@0 176 pop esi
michael@0 177 pop edi
michael@0 178 pop eax
michael@0 179
michael@0 180 add esi, byte SIZEOF_JSAMPROW ; input_data
michael@0 181 add edi, byte SIZEOF_JSAMPROW ; output_data
michael@0 182 dec ecx ; rowctr
michael@0 183 jg near .rowloop
michael@0 184
michael@0 185 emms ; empty MMX state
michael@0 186
michael@0 187 .return:
michael@0 188 pop edi
michael@0 189 pop esi
michael@0 190 ; pop edx ; need not be preserved
michael@0 191 ; pop ecx ; need not be preserved
michael@0 192 poppic ebx
michael@0 193 pop ebp
michael@0 194 ret
michael@0 195
michael@0 196 ; --------------------------------------------------------------------------
michael@0 197 ;
michael@0 198 ; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
michael@0 199 ; Again a triangle filter; see comments for h2v1 case, above.
michael@0 200 ;
michael@0 201 ; GLOBAL(void)
michael@0 202 ; jsimd_h2v2_fancy_upsample_mmx (int max_v_samp_factor,
michael@0 203 ; JDIMENSION downsampled_width,
michael@0 204 ; JSAMPARRAY input_data,
michael@0 205 ; JSAMPARRAY * output_data_ptr);
michael@0 206 ;
michael@0 207
michael@0 208 %define max_v_samp(b) (b)+8 ; int max_v_samp_factor
michael@0 209 %define downsamp_width(b) (b)+12 ; JDIMENSION downsampled_width
michael@0 210 %define input_data(b) (b)+16 ; JSAMPARRAY input_data
michael@0 211 %define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr
michael@0 212
michael@0 213 %define original_ebp ebp+0
michael@0 214 %define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM]
michael@0 215 %define WK_NUM 4
michael@0 216 %define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr
michael@0 217
michael@0 218 align 16
michael@0 219 global EXTN(jsimd_h2v2_fancy_upsample_mmx)
michael@0 220
michael@0 221 EXTN(jsimd_h2v2_fancy_upsample_mmx):
michael@0 222 push ebp
michael@0 223 mov eax,esp ; eax = original ebp
michael@0 224 sub esp, byte 4
michael@0 225 and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
michael@0 226 mov [esp],eax
michael@0 227 mov ebp,esp ; ebp = aligned ebp
michael@0 228 lea esp, [wk(0)]
michael@0 229 pushpic eax ; make a room for GOT address
michael@0 230 push ebx
michael@0 231 ; push ecx ; need not be preserved
michael@0 232 ; push edx ; need not be preserved
michael@0 233 push esi
michael@0 234 push edi
michael@0 235
michael@0 236 get_GOT ebx ; get GOT address
michael@0 237 movpic POINTER [gotptr], ebx ; save GOT address
michael@0 238
michael@0 239 mov edx,eax ; edx = original ebp
michael@0 240 mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
michael@0 241 test eax,eax
michael@0 242 jz near .return
michael@0 243
michael@0 244 mov ecx, INT [max_v_samp(edx)] ; rowctr
michael@0 245 test ecx,ecx
michael@0 246 jz near .return
michael@0 247
michael@0 248 mov esi, JSAMPARRAY [input_data(edx)] ; input_data
michael@0 249 mov edi, POINTER [output_data_ptr(edx)]
michael@0 250 mov edi, JSAMPARRAY [edi] ; output_data
michael@0 251 alignx 16,7
michael@0 252 .rowloop:
michael@0 253 push eax ; colctr
michael@0 254 push ecx
michael@0 255 push edi
michael@0 256 push esi
michael@0 257
michael@0 258 mov ecx, JSAMPROW [esi-1*SIZEOF_JSAMPROW] ; inptr1(above)
michael@0 259 mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
michael@0 260 mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1(below)
michael@0 261 mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
michael@0 262 mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
michael@0 263
michael@0 264 test eax, SIZEOF_MMWORD-1
michael@0 265 jz short .skip
michael@0 266 push edx
michael@0 267 mov dl, JSAMPLE [ecx+(eax-1)*SIZEOF_JSAMPLE]
michael@0 268 mov JSAMPLE [ecx+eax*SIZEOF_JSAMPLE], dl
michael@0 269 mov dl, JSAMPLE [ebx+(eax-1)*SIZEOF_JSAMPLE]
michael@0 270 mov JSAMPLE [ebx+eax*SIZEOF_JSAMPLE], dl
michael@0 271 mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE]
michael@0 272 mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
michael@0 273 pop edx
michael@0 274 .skip:
michael@0 275 ; -- process the first column block
michael@0 276
michael@0 277 movq mm0, MMWORD [ebx+0*SIZEOF_MMWORD] ; mm0=row[ 0][0]
michael@0 278 movq mm1, MMWORD [ecx+0*SIZEOF_MMWORD] ; mm1=row[-1][0]
michael@0 279 movq mm2, MMWORD [esi+0*SIZEOF_MMWORD] ; mm2=row[+1][0]
michael@0 280
michael@0 281 pushpic ebx
michael@0 282 movpic ebx, POINTER [gotptr] ; load GOT address
michael@0 283
michael@0 284 pxor mm3,mm3 ; mm3=(all 0's)
michael@0 285 movq mm4,mm0
michael@0 286 punpcklbw mm0,mm3 ; mm0=row[ 0][0]( 0 1 2 3)
michael@0 287 punpckhbw mm4,mm3 ; mm4=row[ 0][0]( 4 5 6 7)
michael@0 288 movq mm5,mm1
michael@0 289 punpcklbw mm1,mm3 ; mm1=row[-1][0]( 0 1 2 3)
michael@0 290 punpckhbw mm5,mm3 ; mm5=row[-1][0]( 4 5 6 7)
michael@0 291 movq mm6,mm2
michael@0 292 punpcklbw mm2,mm3 ; mm2=row[+1][0]( 0 1 2 3)
michael@0 293 punpckhbw mm6,mm3 ; mm6=row[+1][0]( 4 5 6 7)
michael@0 294
michael@0 295 pmullw mm0,[GOTOFF(ebx,PW_THREE)]
michael@0 296 pmullw mm4,[GOTOFF(ebx,PW_THREE)]
michael@0 297
michael@0 298 pcmpeqb mm7,mm7
michael@0 299 psrlq mm7,(SIZEOF_MMWORD-2)*BYTE_BIT
michael@0 300
michael@0 301 paddw mm1,mm0 ; mm1=Int0L=( 0 1 2 3)
michael@0 302 paddw mm5,mm4 ; mm5=Int0H=( 4 5 6 7)
michael@0 303 paddw mm2,mm0 ; mm2=Int1L=( 0 1 2 3)
michael@0 304 paddw mm6,mm4 ; mm6=Int1H=( 4 5 6 7)
michael@0 305
michael@0 306 movq MMWORD [edx+0*SIZEOF_MMWORD], mm1 ; temporarily save
michael@0 307 movq MMWORD [edx+1*SIZEOF_MMWORD], mm5 ; the intermediate data
michael@0 308 movq MMWORD [edi+0*SIZEOF_MMWORD], mm2
michael@0 309 movq MMWORD [edi+1*SIZEOF_MMWORD], mm6
michael@0 310
michael@0 311 pand mm1,mm7 ; mm1=( 0 - - -)
michael@0 312 pand mm2,mm7 ; mm2=( 0 - - -)
michael@0 313
michael@0 314 movq MMWORD [wk(0)], mm1
michael@0 315 movq MMWORD [wk(1)], mm2
michael@0 316
michael@0 317 poppic ebx
michael@0 318
michael@0 319 add eax, byte SIZEOF_MMWORD-1
michael@0 320 and eax, byte -SIZEOF_MMWORD
michael@0 321 cmp eax, byte SIZEOF_MMWORD
michael@0 322 ja short .columnloop
michael@0 323 alignx 16,7
michael@0 324
michael@0 325 .columnloop_last:
michael@0 326 ; -- process the last column block
michael@0 327
michael@0 328 pushpic ebx
michael@0 329 movpic ebx, POINTER [gotptr] ; load GOT address
michael@0 330
michael@0 331 pcmpeqb mm1,mm1
michael@0 332 psllq mm1,(SIZEOF_MMWORD-2)*BYTE_BIT
michael@0 333 movq mm2,mm1
michael@0 334
michael@0 335 pand mm1, MMWORD [edx+1*SIZEOF_MMWORD] ; mm1=( - - - 7)
michael@0 336 pand mm2, MMWORD [edi+1*SIZEOF_MMWORD] ; mm2=( - - - 7)
michael@0 337
michael@0 338 movq MMWORD [wk(2)], mm1
michael@0 339 movq MMWORD [wk(3)], mm2
michael@0 340
michael@0 341 jmp short .upsample
michael@0 342 alignx 16,7
michael@0 343
michael@0 344 .columnloop:
michael@0 345 ; -- process the next column block
michael@0 346
michael@0 347 movq mm0, MMWORD [ebx+1*SIZEOF_MMWORD] ; mm0=row[ 0][1]
michael@0 348 movq mm1, MMWORD [ecx+1*SIZEOF_MMWORD] ; mm1=row[-1][1]
michael@0 349 movq mm2, MMWORD [esi+1*SIZEOF_MMWORD] ; mm2=row[+1][1]
michael@0 350
michael@0 351 pushpic ebx
michael@0 352 movpic ebx, POINTER [gotptr] ; load GOT address
michael@0 353
michael@0 354 pxor mm3,mm3 ; mm3=(all 0's)
michael@0 355 movq mm4,mm0
michael@0 356 punpcklbw mm0,mm3 ; mm0=row[ 0][1]( 0 1 2 3)
michael@0 357 punpckhbw mm4,mm3 ; mm4=row[ 0][1]( 4 5 6 7)
michael@0 358 movq mm5,mm1
michael@0 359 punpcklbw mm1,mm3 ; mm1=row[-1][1]( 0 1 2 3)
michael@0 360 punpckhbw mm5,mm3 ; mm5=row[-1][1]( 4 5 6 7)
michael@0 361 movq mm6,mm2
michael@0 362 punpcklbw mm2,mm3 ; mm2=row[+1][1]( 0 1 2 3)
michael@0 363 punpckhbw mm6,mm3 ; mm6=row[+1][1]( 4 5 6 7)
michael@0 364
michael@0 365 pmullw mm0,[GOTOFF(ebx,PW_THREE)]
michael@0 366 pmullw mm4,[GOTOFF(ebx,PW_THREE)]
michael@0 367
michael@0 368 paddw mm1,mm0 ; mm1=Int0L=( 0 1 2 3)
michael@0 369 paddw mm5,mm4 ; mm5=Int0H=( 4 5 6 7)
michael@0 370 paddw mm2,mm0 ; mm2=Int1L=( 0 1 2 3)
michael@0 371 paddw mm6,mm4 ; mm6=Int1H=( 4 5 6 7)
michael@0 372
michael@0 373 movq MMWORD [edx+2*SIZEOF_MMWORD], mm1 ; temporarily save
michael@0 374 movq MMWORD [edx+3*SIZEOF_MMWORD], mm5 ; the intermediate data
michael@0 375 movq MMWORD [edi+2*SIZEOF_MMWORD], mm2
michael@0 376 movq MMWORD [edi+3*SIZEOF_MMWORD], mm6
michael@0 377
michael@0 378 psllq mm1,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm1=( - - - 0)
michael@0 379 psllq mm2,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm2=( - - - 0)
michael@0 380
michael@0 381 movq MMWORD [wk(2)], mm1
michael@0 382 movq MMWORD [wk(3)], mm2
michael@0 383
michael@0 384 .upsample:
michael@0 385 ; -- process the upper row
michael@0 386
michael@0 387 movq mm7, MMWORD [edx+0*SIZEOF_MMWORD] ; mm7=Int0L=( 0 1 2 3)
michael@0 388 movq mm3, MMWORD [edx+1*SIZEOF_MMWORD] ; mm3=Int0H=( 4 5 6 7)
michael@0 389
michael@0 390 movq mm0,mm7
michael@0 391 movq mm4,mm3
michael@0 392 psrlq mm0,2*BYTE_BIT ; mm0=( 1 2 3 -)
michael@0 393 psllq mm4,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm4=( - - - 4)
michael@0 394 movq mm5,mm7
michael@0 395 movq mm6,mm3
michael@0 396 psrlq mm5,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm5=( 3 - - -)
michael@0 397 psllq mm6,2*BYTE_BIT ; mm6=( - 4 5 6)
michael@0 398
michael@0 399 por mm0,mm4 ; mm0=( 1 2 3 4)
michael@0 400 por mm5,mm6 ; mm5=( 3 4 5 6)
michael@0 401
michael@0 402 movq mm1,mm7
michael@0 403 movq mm2,mm3
michael@0 404 psllq mm1,2*BYTE_BIT ; mm1=( - 0 1 2)
michael@0 405 psrlq mm2,2*BYTE_BIT ; mm2=( 5 6 7 -)
michael@0 406 movq mm4,mm3
michael@0 407 psrlq mm4,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm4=( 7 - - -)
michael@0 408
michael@0 409 por mm1, MMWORD [wk(0)] ; mm1=(-1 0 1 2)
michael@0 410 por mm2, MMWORD [wk(2)] ; mm2=( 5 6 7 8)
michael@0 411
michael@0 412 movq MMWORD [wk(0)], mm4
michael@0 413
michael@0 414 pmullw mm7,[GOTOFF(ebx,PW_THREE)]
michael@0 415 pmullw mm3,[GOTOFF(ebx,PW_THREE)]
michael@0 416 paddw mm1,[GOTOFF(ebx,PW_EIGHT)]
michael@0 417 paddw mm5,[GOTOFF(ebx,PW_EIGHT)]
michael@0 418 paddw mm0,[GOTOFF(ebx,PW_SEVEN)]
michael@0 419 paddw mm2,[GOTOFF(ebx,PW_SEVEN)]
michael@0 420
michael@0 421 paddw mm1,mm7
michael@0 422 paddw mm5,mm3
michael@0 423 psrlw mm1,4 ; mm1=Out0LE=( 0 2 4 6)
michael@0 424 psrlw mm5,4 ; mm5=Out0HE=( 8 10 12 14)
michael@0 425 paddw mm0,mm7
michael@0 426 paddw mm2,mm3
michael@0 427 psrlw mm0,4 ; mm0=Out0LO=( 1 3 5 7)
michael@0 428 psrlw mm2,4 ; mm2=Out0HO=( 9 11 13 15)
michael@0 429
michael@0 430 psllw mm0,BYTE_BIT
michael@0 431 psllw mm2,BYTE_BIT
michael@0 432 por mm1,mm0 ; mm1=Out0L=( 0 1 2 3 4 5 6 7)
michael@0 433 por mm5,mm2 ; mm5=Out0H=( 8 9 10 11 12 13 14 15)
michael@0 434
michael@0 435 movq MMWORD [edx+0*SIZEOF_MMWORD], mm1
michael@0 436 movq MMWORD [edx+1*SIZEOF_MMWORD], mm5
michael@0 437
michael@0 438 ; -- process the lower row
michael@0 439
michael@0 440 movq mm6, MMWORD [edi+0*SIZEOF_MMWORD] ; mm6=Int1L=( 0 1 2 3)
michael@0 441 movq mm4, MMWORD [edi+1*SIZEOF_MMWORD] ; mm4=Int1H=( 4 5 6 7)
michael@0 442
michael@0 443 movq mm7,mm6
michael@0 444 movq mm3,mm4
michael@0 445 psrlq mm7,2*BYTE_BIT ; mm7=( 1 2 3 -)
michael@0 446 psllq mm3,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm3=( - - - 4)
michael@0 447 movq mm0,mm6
michael@0 448 movq mm2,mm4
michael@0 449 psrlq mm0,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm0=( 3 - - -)
michael@0 450 psllq mm2,2*BYTE_BIT ; mm2=( - 4 5 6)
michael@0 451
michael@0 452 por mm7,mm3 ; mm7=( 1 2 3 4)
michael@0 453 por mm0,mm2 ; mm0=( 3 4 5 6)
michael@0 454
michael@0 455 movq mm1,mm6
michael@0 456 movq mm5,mm4
michael@0 457 psllq mm1,2*BYTE_BIT ; mm1=( - 0 1 2)
michael@0 458 psrlq mm5,2*BYTE_BIT ; mm5=( 5 6 7 -)
michael@0 459 movq mm3,mm4
michael@0 460 psrlq mm3,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm3=( 7 - - -)
michael@0 461
michael@0 462 por mm1, MMWORD [wk(1)] ; mm1=(-1 0 1 2)
michael@0 463 por mm5, MMWORD [wk(3)] ; mm5=( 5 6 7 8)
michael@0 464
michael@0 465 movq MMWORD [wk(1)], mm3
michael@0 466
michael@0 467 pmullw mm6,[GOTOFF(ebx,PW_THREE)]
michael@0 468 pmullw mm4,[GOTOFF(ebx,PW_THREE)]
michael@0 469 paddw mm1,[GOTOFF(ebx,PW_EIGHT)]
michael@0 470 paddw mm0,[GOTOFF(ebx,PW_EIGHT)]
michael@0 471 paddw mm7,[GOTOFF(ebx,PW_SEVEN)]
michael@0 472 paddw mm5,[GOTOFF(ebx,PW_SEVEN)]
michael@0 473
michael@0 474 paddw mm1,mm6
michael@0 475 paddw mm0,mm4
michael@0 476 psrlw mm1,4 ; mm1=Out1LE=( 0 2 4 6)
michael@0 477 psrlw mm0,4 ; mm0=Out1HE=( 8 10 12 14)
michael@0 478 paddw mm7,mm6
michael@0 479 paddw mm5,mm4
michael@0 480 psrlw mm7,4 ; mm7=Out1LO=( 1 3 5 7)
michael@0 481 psrlw mm5,4 ; mm5=Out1HO=( 9 11 13 15)
michael@0 482
michael@0 483 psllw mm7,BYTE_BIT
michael@0 484 psllw mm5,BYTE_BIT
michael@0 485 por mm1,mm7 ; mm1=Out1L=( 0 1 2 3 4 5 6 7)
michael@0 486 por mm0,mm5 ; mm0=Out1H=( 8 9 10 11 12 13 14 15)
michael@0 487
michael@0 488 movq MMWORD [edi+0*SIZEOF_MMWORD], mm1
michael@0 489 movq MMWORD [edi+1*SIZEOF_MMWORD], mm0
michael@0 490
michael@0 491 poppic ebx
michael@0 492
michael@0 493 sub eax, byte SIZEOF_MMWORD
michael@0 494 add ecx, byte 1*SIZEOF_MMWORD ; inptr1(above)
michael@0 495 add ebx, byte 1*SIZEOF_MMWORD ; inptr0
michael@0 496 add esi, byte 1*SIZEOF_MMWORD ; inptr1(below)
michael@0 497 add edx, byte 2*SIZEOF_MMWORD ; outptr0
michael@0 498 add edi, byte 2*SIZEOF_MMWORD ; outptr1
michael@0 499 cmp eax, byte SIZEOF_MMWORD
michael@0 500 ja near .columnloop
michael@0 501 test eax,eax
michael@0 502 jnz near .columnloop_last
michael@0 503
michael@0 504 pop esi
michael@0 505 pop edi
michael@0 506 pop ecx
michael@0 507 pop eax
michael@0 508
michael@0 509 add esi, byte 1*SIZEOF_JSAMPROW ; input_data
michael@0 510 add edi, byte 2*SIZEOF_JSAMPROW ; output_data
michael@0 511 sub ecx, byte 2 ; rowctr
michael@0 512 jg near .rowloop
michael@0 513
michael@0 514 emms ; empty MMX state
michael@0 515
michael@0 516 .return:
michael@0 517 pop edi
michael@0 518 pop esi
michael@0 519 ; pop edx ; need not be preserved
michael@0 520 ; pop ecx ; need not be preserved
michael@0 521 pop ebx
michael@0 522 mov esp,ebp ; esp <- aligned ebp
michael@0 523 pop esp ; esp <- original ebp
michael@0 524 pop ebp
michael@0 525 ret
michael@0 526
michael@0 527 ; --------------------------------------------------------------------------
michael@0 528 ;
michael@0 529 ; Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
michael@0 530 ; It's still a box filter.
michael@0 531 ;
michael@0 532 ; GLOBAL(void)
michael@0 533 ; jsimd_h2v1_upsample_mmx (int max_v_samp_factor,
michael@0 534 ; JDIMENSION output_width,
michael@0 535 ; JSAMPARRAY input_data,
michael@0 536 ; JSAMPARRAY * output_data_ptr);
michael@0 537 ;
michael@0 538
michael@0 539 %define max_v_samp(b) (b)+8 ; int max_v_samp_factor
michael@0 540 %define output_width(b) (b)+12 ; JDIMENSION output_width
michael@0 541 %define input_data(b) (b)+16 ; JSAMPARRAY input_data
michael@0 542 %define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr
michael@0 543
michael@0 544 align 16
michael@0 545 global EXTN(jsimd_h2v1_upsample_mmx)
michael@0 546
michael@0 547 EXTN(jsimd_h2v1_upsample_mmx):
michael@0 548 push ebp
michael@0 549 mov ebp,esp
michael@0 550 ; push ebx ; unused
michael@0 551 ; push ecx ; need not be preserved
michael@0 552 ; push edx ; need not be preserved
michael@0 553 push esi
michael@0 554 push edi
michael@0 555
michael@0 556 mov edx, JDIMENSION [output_width(ebp)]
michael@0 557 add edx, byte (2*SIZEOF_MMWORD)-1
michael@0 558 and edx, byte -(2*SIZEOF_MMWORD)
michael@0 559 jz short .return
michael@0 560
michael@0 561 mov ecx, INT [max_v_samp(ebp)] ; rowctr
michael@0 562 test ecx,ecx
michael@0 563 jz short .return
michael@0 564
michael@0 565 mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
michael@0 566 mov edi, POINTER [output_data_ptr(ebp)]
michael@0 567 mov edi, JSAMPARRAY [edi] ; output_data
michael@0 568 alignx 16,7
michael@0 569 .rowloop:
michael@0 570 push edi
michael@0 571 push esi
michael@0 572
michael@0 573 mov esi, JSAMPROW [esi] ; inptr
michael@0 574 mov edi, JSAMPROW [edi] ; outptr
michael@0 575 mov eax,edx ; colctr
michael@0 576 alignx 16,7
michael@0 577 .columnloop:
michael@0 578
michael@0 579 movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
michael@0 580
michael@0 581 movq mm1,mm0
michael@0 582 punpcklbw mm0,mm0
michael@0 583 punpckhbw mm1,mm1
michael@0 584
michael@0 585 movq MMWORD [edi+0*SIZEOF_MMWORD], mm0
michael@0 586 movq MMWORD [edi+1*SIZEOF_MMWORD], mm1
michael@0 587
michael@0 588 sub eax, byte 2*SIZEOF_MMWORD
michael@0 589 jz short .nextrow
michael@0 590
michael@0 591 movq mm2, MMWORD [esi+1*SIZEOF_MMWORD]
michael@0 592
michael@0 593 movq mm3,mm2
michael@0 594 punpcklbw mm2,mm2
michael@0 595 punpckhbw mm3,mm3
michael@0 596
michael@0 597 movq MMWORD [edi+2*SIZEOF_MMWORD], mm2
michael@0 598 movq MMWORD [edi+3*SIZEOF_MMWORD], mm3
michael@0 599
michael@0 600 sub eax, byte 2*SIZEOF_MMWORD
michael@0 601 jz short .nextrow
michael@0 602
michael@0 603 add esi, byte 2*SIZEOF_MMWORD ; inptr
michael@0 604 add edi, byte 4*SIZEOF_MMWORD ; outptr
michael@0 605 jmp short .columnloop
michael@0 606 alignx 16,7
michael@0 607
michael@0 608 .nextrow:
michael@0 609 pop esi
michael@0 610 pop edi
michael@0 611
michael@0 612 add esi, byte SIZEOF_JSAMPROW ; input_data
michael@0 613 add edi, byte SIZEOF_JSAMPROW ; output_data
michael@0 614 dec ecx ; rowctr
michael@0 615 jg short .rowloop
michael@0 616
michael@0 617 emms ; empty MMX state
michael@0 618
michael@0 619 .return:
michael@0 620 pop edi
michael@0 621 pop esi
michael@0 622 ; pop edx ; need not be preserved
michael@0 623 ; pop ecx ; need not be preserved
michael@0 624 ; pop ebx ; unused
michael@0 625 pop ebp
michael@0 626 ret
michael@0 627
michael@0 628 ; --------------------------------------------------------------------------
michael@0 629 ;
michael@0 630 ; Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
michael@0 631 ; It's still a box filter.
michael@0 632 ;
michael@0 633 ; GLOBAL(void)
michael@0 634 ; jsimd_h2v2_upsample_mmx (int max_v_samp_factor,
michael@0 635 ; JDIMENSION output_width,
michael@0 636 ; JSAMPARRAY input_data,
michael@0 637 ; JSAMPARRAY * output_data_ptr);
michael@0 638 ;
michael@0 639
michael@0 640 %define max_v_samp(b) (b)+8 ; int max_v_samp_factor
michael@0 641 %define output_width(b) (b)+12 ; JDIMENSION output_width
michael@0 642 %define input_data(b) (b)+16 ; JSAMPARRAY input_data
michael@0 643 %define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr
michael@0 644
michael@0 645 align 16
michael@0 646 global EXTN(jsimd_h2v2_upsample_mmx)
michael@0 647
michael@0 648 EXTN(jsimd_h2v2_upsample_mmx):
michael@0 649 push ebp
michael@0 650 mov ebp,esp
michael@0 651 push ebx
michael@0 652 ; push ecx ; need not be preserved
michael@0 653 ; push edx ; need not be preserved
michael@0 654 push esi
michael@0 655 push edi
michael@0 656
michael@0 657 mov edx, JDIMENSION [output_width(ebp)]
michael@0 658 add edx, byte (2*SIZEOF_MMWORD)-1
michael@0 659 and edx, byte -(2*SIZEOF_MMWORD)
michael@0 660 jz near .return
michael@0 661
michael@0 662 mov ecx, INT [max_v_samp(ebp)] ; rowctr
michael@0 663 test ecx,ecx
michael@0 664 jz short .return
michael@0 665
michael@0 666 mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
michael@0 667 mov edi, POINTER [output_data_ptr(ebp)]
michael@0 668 mov edi, JSAMPARRAY [edi] ; output_data
michael@0 669 alignx 16,7
michael@0 670 .rowloop:
michael@0 671 push edi
michael@0 672 push esi
michael@0 673
michael@0 674 mov esi, JSAMPROW [esi] ; inptr
michael@0 675 mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
michael@0 676 mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
michael@0 677 mov eax,edx ; colctr
michael@0 678 alignx 16,7
michael@0 679 .columnloop:
michael@0 680
michael@0 681 movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
michael@0 682
michael@0 683 movq mm1,mm0
michael@0 684 punpcklbw mm0,mm0
michael@0 685 punpckhbw mm1,mm1
michael@0 686
michael@0 687 movq MMWORD [ebx+0*SIZEOF_MMWORD], mm0
michael@0 688 movq MMWORD [ebx+1*SIZEOF_MMWORD], mm1
michael@0 689 movq MMWORD [edi+0*SIZEOF_MMWORD], mm0
michael@0 690 movq MMWORD [edi+1*SIZEOF_MMWORD], mm1
michael@0 691
michael@0 692 sub eax, byte 2*SIZEOF_MMWORD
michael@0 693 jz short .nextrow
michael@0 694
michael@0 695 movq mm2, MMWORD [esi+1*SIZEOF_MMWORD]
michael@0 696
michael@0 697 movq mm3,mm2
michael@0 698 punpcklbw mm2,mm2
michael@0 699 punpckhbw mm3,mm3
michael@0 700
michael@0 701 movq MMWORD [ebx+2*SIZEOF_MMWORD], mm2
michael@0 702 movq MMWORD [ebx+3*SIZEOF_MMWORD], mm3
michael@0 703 movq MMWORD [edi+2*SIZEOF_MMWORD], mm2
michael@0 704 movq MMWORD [edi+3*SIZEOF_MMWORD], mm3
michael@0 705
michael@0 706 sub eax, byte 2*SIZEOF_MMWORD
michael@0 707 jz short .nextrow
michael@0 708
michael@0 709 add esi, byte 2*SIZEOF_MMWORD ; inptr
michael@0 710 add ebx, byte 4*SIZEOF_MMWORD ; outptr0
michael@0 711 add edi, byte 4*SIZEOF_MMWORD ; outptr1
michael@0 712 jmp short .columnloop
michael@0 713 alignx 16,7
michael@0 714
michael@0 715 .nextrow:
michael@0 716 pop esi
michael@0 717 pop edi
michael@0 718
michael@0 719 add esi, byte 1*SIZEOF_JSAMPROW ; input_data
michael@0 720 add edi, byte 2*SIZEOF_JSAMPROW ; output_data
michael@0 721 sub ecx, byte 2 ; rowctr
michael@0 722 jg short .rowloop
michael@0 723
michael@0 724 emms ; empty MMX state
michael@0 725
michael@0 726 .return:
michael@0 727 pop edi
michael@0 728 pop esi
michael@0 729 ; pop edx ; need not be preserved
michael@0 730 ; pop ecx ; need not be preserved
michael@0 731 pop ebx
michael@0 732 pop ebp
michael@0 733 ret
michael@0 734
michael@0 735 ; For some reason, the OS X linker does not honor the request to align the
michael@0 736 ; segment unless we do this.
michael@0 737 align 16

mercurial