|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; jcsample.asm - downsampling (AVX2)
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB</ossman@cendio.se>
|
|
shun-iwasawa |
82a8f5 |
; Copyright (C) 2015, Intel Corporation.
|
|
shun-iwasawa |
82a8f5 |
; Copyright (C) 2016, D. R. Commander.
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; Based on the x86 SIMD extension for IJG JPEG library
|
|
shun-iwasawa |
82a8f5 |
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
|
shun-iwasawa |
82a8f5 |
; For conditions of distribution and use, see copyright notice in jsimdext.inc
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; This file should be assembled with NASM (Netwide Assembler),
|
|
shun-iwasawa |
82a8f5 |
; can *not* be assembled with Microsoft's MASM or any compatible
|
|
shun-iwasawa |
82a8f5 |
; assembler (including Borland's Turbo Assembler).
|
|
shun-iwasawa |
82a8f5 |
; NASM is available from http://nasm.sourceforge.net/ or
|
|
shun-iwasawa |
82a8f5 |
; http://sourceforge.net/project/showfiles.php?group_id=6208
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
%include "jsimdext.inc"
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; --------------------------------------------------------------------------
|
|
shun-iwasawa |
82a8f5 |
SECTION SEG_TEXT
|
|
shun-iwasawa |
82a8f5 |
BITS 32
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; Downsample pixel values of a single component.
|
|
shun-iwasawa |
82a8f5 |
; This version handles the common case of 2:1 horizontal and 1:1 vertical,
|
|
shun-iwasawa |
82a8f5 |
; without smoothing.
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; GLOBAL(void)
|
|
shun-iwasawa |
82a8f5 |
; jsimd_h2v1_downsample_avx2(JDIMENSION image_width, int max_v_samp_factor,
|
|
shun-iwasawa |
82a8f5 |
; JDIMENSION v_samp_factor,
|
|
shun-iwasawa |
82a8f5 |
; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
|
|
shun-iwasawa |
82a8f5 |
; JSAMPARRAY output_data);
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
%define img_width(b) (b) + 8 ; JDIMENSION image_width
|
|
shun-iwasawa |
82a8f5 |
%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
|
|
shun-iwasawa |
82a8f5 |
%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
|
|
shun-iwasawa |
82a8f5 |
%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
|
|
shun-iwasawa |
82a8f5 |
%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
|
|
shun-iwasawa |
82a8f5 |
%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
align 32
|
|
shun-iwasawa |
82a8f5 |
GLOBAL_FUNCTION(jsimd_h2v1_downsample_avx2)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
EXTN(jsimd_h2v1_downsample_avx2):
|
|
shun-iwasawa |
82a8f5 |
push ebp
|
|
shun-iwasawa |
82a8f5 |
mov ebp, esp
|
|
shun-iwasawa |
82a8f5 |
; push ebx ; unused
|
|
shun-iwasawa |
82a8f5 |
; push ecx ; need not be preserved
|
|
shun-iwasawa |
82a8f5 |
; push edx ; need not be preserved
|
|
shun-iwasawa |
82a8f5 |
push esi
|
|
shun-iwasawa |
82a8f5 |
push edi
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov ecx, JDIMENSION [width_blks(ebp)]
|
|
shun-iwasawa |
82a8f5 |
shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
|
|
shun-iwasawa |
82a8f5 |
jz near .return
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov edx, JDIMENSION [img_width(ebp)]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; -- expand_right_edge
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
push ecx
|
|
shun-iwasawa |
82a8f5 |
shl ecx, 1 ; output_cols * 2
|
|
shun-iwasawa |
82a8f5 |
sub ecx, edx
|
|
shun-iwasawa |
82a8f5 |
jle short .expand_end
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov eax, INT [max_v_samp(ebp)]
|
|
shun-iwasawa |
82a8f5 |
test eax, eax
|
|
shun-iwasawa |
82a8f5 |
jle short .expand_end
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
cld
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
.expandloop:
|
|
shun-iwasawa |
82a8f5 |
push eax
|
|
shun-iwasawa |
82a8f5 |
push ecx
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov edi, JSAMPROW [esi]
|
|
shun-iwasawa |
82a8f5 |
add edi, edx
|
|
shun-iwasawa |
82a8f5 |
mov al, JSAMPLE [edi-1]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
rep stosb
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pop ecx
|
|
shun-iwasawa |
82a8f5 |
pop eax
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add esi, byte SIZEOF_JSAMPROW
|
|
shun-iwasawa |
82a8f5 |
dec eax
|
|
shun-iwasawa |
82a8f5 |
jg short .expandloop
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.expand_end:
|
|
shun-iwasawa |
82a8f5 |
pop ecx ; output_cols
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; -- h2v1_downsample
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
|
|
shun-iwasawa |
82a8f5 |
test eax, eax
|
|
shun-iwasawa |
82a8f5 |
jle near .return
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov edx, 0x00010000 ; bias pattern
|
|
shun-iwasawa |
82a8f5 |
vmovd xmm7, edx
|
|
shun-iwasawa |
82a8f5 |
vpshufd xmm7, xmm7, 0x00 ; xmm7={0, 1, 0, 1, 0, 1, 0, 1}
|
|
shun-iwasawa |
82a8f5 |
vperm2i128 ymm7, ymm7, ymm7, 0 ; ymm7={xmm7, xmm7}
|
|
shun-iwasawa |
82a8f5 |
vpcmpeqw ymm6, ymm6, ymm6
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm6, ymm6, BYTE_BIT ; ymm6={0xFF 0x00 0xFF 0x00 ..}
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
|
|
shun-iwasawa |
82a8f5 |
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
.rowloop:
|
|
shun-iwasawa |
82a8f5 |
push ecx
|
|
shun-iwasawa |
82a8f5 |
push edi
|
|
shun-iwasawa |
82a8f5 |
push esi
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPROW [esi] ; inptr
|
|
shun-iwasawa |
82a8f5 |
mov edi, JSAMPROW [edi] ; outptr
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, byte SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jae short .columnloop
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop_r24:
|
|
shun-iwasawa |
82a8f5 |
; ecx can possibly be 8, 16, 24
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, 24
|
|
shun-iwasawa |
82a8f5 |
jne .columnloop_r16
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu xmm1, XMMWORD [esi+1*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jmp short .downsample
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop_r16:
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, 16
|
|
shun-iwasawa |
82a8f5 |
jne .columnloop_r8
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vpxor ymm1, ymm1, ymm1
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jmp short .downsample
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop_r8:
|
|
shun-iwasawa |
82a8f5 |
vmovdqu xmm0, XMMWORD[esi+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vpxor ymm1, ymm1, ymm1
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jmp short .downsample
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop:
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm1, YMMWORD [esi+1*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.downsample:
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm2, ymm0, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
vpand ymm0, ymm0, ymm6
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm3, ymm1, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
vpand ymm1, ymm1, ymm6
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm0, ymm0, ymm2
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm1, ymm1, ymm3
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm0, ymm0, ymm7
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm1, ymm1, ymm7
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm0, ymm0, 1
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm1, ymm1, 1
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
vpackuswb ymm0, ymm0, ymm1
|
|
shun-iwasawa |
82a8f5 |
vpermq ymm0, ymm0, 0xd8
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm0
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
sub ecx, byte SIZEOF_YMMWORD ; outcol
|
|
shun-iwasawa |
82a8f5 |
add esi, byte 2*SIZEOF_YMMWORD ; inptr
|
|
shun-iwasawa |
82a8f5 |
add edi, byte 1*SIZEOF_YMMWORD ; outptr
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, byte SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jae short .columnloop
|
|
shun-iwasawa |
82a8f5 |
test ecx, ecx
|
|
shun-iwasawa |
82a8f5 |
jnz near .columnloop_r24
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pop esi
|
|
shun-iwasawa |
82a8f5 |
pop edi
|
|
shun-iwasawa |
82a8f5 |
pop ecx
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add esi, byte SIZEOF_JSAMPROW ; input_data
|
|
shun-iwasawa |
82a8f5 |
add edi, byte SIZEOF_JSAMPROW ; output_data
|
|
shun-iwasawa |
82a8f5 |
dec eax ; rowctr
|
|
shun-iwasawa |
82a8f5 |
jg near .rowloop
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.return:
|
|
shun-iwasawa |
82a8f5 |
vzeroupper
|
|
shun-iwasawa |
82a8f5 |
pop edi
|
|
shun-iwasawa |
82a8f5 |
pop esi
|
|
shun-iwasawa |
82a8f5 |
; pop edx ; need not be preserved
|
|
shun-iwasawa |
82a8f5 |
; pop ecx ; need not be preserved
|
|
shun-iwasawa |
82a8f5 |
; pop ebx ; unused
|
|
shun-iwasawa |
82a8f5 |
pop ebp
|
|
shun-iwasawa |
82a8f5 |
ret
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; --------------------------------------------------------------------------
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; Downsample pixel values of a single component.
|
|
shun-iwasawa |
82a8f5 |
; This version handles the standard case of 2:1 horizontal and 2:1 vertical,
|
|
shun-iwasawa |
82a8f5 |
; without smoothing.
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; GLOBAL(void)
|
|
shun-iwasawa |
82a8f5 |
; jsimd_h2v2_downsample_avx2(JDIMENSION image_width, int max_v_samp_factor,
|
|
shun-iwasawa |
82a8f5 |
; JDIMENSION v_samp_factor,
|
|
shun-iwasawa |
82a8f5 |
; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
|
|
shun-iwasawa |
82a8f5 |
; JSAMPARRAY output_data);
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
%define img_width(b) (b) + 8 ; JDIMENSION image_width
|
|
shun-iwasawa |
82a8f5 |
%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
|
|
shun-iwasawa |
82a8f5 |
%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
|
|
shun-iwasawa |
82a8f5 |
%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
|
|
shun-iwasawa |
82a8f5 |
%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
|
|
shun-iwasawa |
82a8f5 |
%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
align 32
|
|
shun-iwasawa |
82a8f5 |
GLOBAL_FUNCTION(jsimd_h2v2_downsample_avx2)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
EXTN(jsimd_h2v2_downsample_avx2):
|
|
shun-iwasawa |
82a8f5 |
push ebp
|
|
shun-iwasawa |
82a8f5 |
mov ebp, esp
|
|
shun-iwasawa |
82a8f5 |
; push ebx ; unused
|
|
shun-iwasawa |
82a8f5 |
; push ecx ; need not be preserved
|
|
shun-iwasawa |
82a8f5 |
; push edx ; need not be preserved
|
|
shun-iwasawa |
82a8f5 |
push esi
|
|
shun-iwasawa |
82a8f5 |
push edi
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov ecx, JDIMENSION [width_blks(ebp)]
|
|
shun-iwasawa |
82a8f5 |
shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
|
|
shun-iwasawa |
82a8f5 |
jz near .return
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov edx, JDIMENSION [img_width(ebp)]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; -- expand_right_edge
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
push ecx
|
|
shun-iwasawa |
82a8f5 |
shl ecx, 1 ; output_cols * 2
|
|
shun-iwasawa |
82a8f5 |
sub ecx, edx
|
|
shun-iwasawa |
82a8f5 |
jle short .expand_end
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov eax, INT [max_v_samp(ebp)]
|
|
shun-iwasawa |
82a8f5 |
test eax, eax
|
|
shun-iwasawa |
82a8f5 |
jle short .expand_end
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
cld
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
.expandloop:
|
|
shun-iwasawa |
82a8f5 |
push eax
|
|
shun-iwasawa |
82a8f5 |
push ecx
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov edi, JSAMPROW [esi]
|
|
shun-iwasawa |
82a8f5 |
add edi, edx
|
|
shun-iwasawa |
82a8f5 |
mov al, JSAMPLE [edi-1]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
rep stosb
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pop ecx
|
|
shun-iwasawa |
82a8f5 |
pop eax
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add esi, byte SIZEOF_JSAMPROW
|
|
shun-iwasawa |
82a8f5 |
dec eax
|
|
shun-iwasawa |
82a8f5 |
jg short .expandloop
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.expand_end:
|
|
shun-iwasawa |
82a8f5 |
pop ecx ; output_cols
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; -- h2v2_downsample
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
|
|
shun-iwasawa |
82a8f5 |
test eax, eax
|
|
shun-iwasawa |
82a8f5 |
jle near .return
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov edx, 0x00020001 ; bias pattern
|
|
shun-iwasawa |
82a8f5 |
vmovd xmm7, edx
|
|
shun-iwasawa |
82a8f5 |
vpcmpeqw ymm6, ymm6, ymm6
|
|
shun-iwasawa |
82a8f5 |
vpshufd xmm7, xmm7, 0x00 ; ymm7={1, 2, 1, 2, 1, 2, 1, 2}
|
|
shun-iwasawa |
82a8f5 |
vperm2i128 ymm7, ymm7, ymm7, 0
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm6, ymm6, BYTE_BIT ; ymm6={0xFF 0x00 0xFF 0x00 ..}
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
|
|
shun-iwasawa |
82a8f5 |
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
.rowloop:
|
|
shun-iwasawa |
82a8f5 |
push ecx
|
|
shun-iwasawa |
82a8f5 |
push edi
|
|
shun-iwasawa |
82a8f5 |
push esi
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1
|
|
shun-iwasawa |
82a8f5 |
mov edi, JSAMPROW [edi] ; outptr
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, byte SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jae short .columnloop
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop_r24:
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, 24
|
|
shun-iwasawa |
82a8f5 |
jne .columnloop_r16
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm0, YMMWORD [edx+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm1, YMMWORD [esi+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu xmm2, XMMWORD [edx+1*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu xmm3, XMMWORD [esi+1*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jmp short .downsample
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop_r16:
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, 16
|
|
shun-iwasawa |
82a8f5 |
jne .columnloop_r8
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm0, YMMWORD [edx+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm1, YMMWORD [esi+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vpxor ymm2, ymm2, ymm2
|
|
shun-iwasawa |
82a8f5 |
vpxor ymm3, ymm3, ymm3
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jmp short .downsample
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop_r8:
|
|
shun-iwasawa |
82a8f5 |
vmovdqu xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vpxor ymm2, ymm2, ymm2
|
|
shun-iwasawa |
82a8f5 |
vpxor ymm3, ymm3, ymm3
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jmp short .downsample
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop:
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm0, YMMWORD [edx+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm1, YMMWORD [esi+0*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm2, YMMWORD [edx+1*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
vmovdqu ymm3, YMMWORD [esi+1*SIZEOF_YMMWORD]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.downsample:
|
|
shun-iwasawa |
82a8f5 |
vpand ymm4, ymm0, ymm6
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm0, ymm0, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
vpand ymm5, ymm1, ymm6
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm1, ymm1, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm0, ymm0, ymm4
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm1, ymm1, ymm5
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
vpand ymm4, ymm2, ymm6
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm2, ymm2, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
vpand ymm5, ymm3, ymm6
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm3, ymm3, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm2, ymm2, ymm4
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm3, ymm3, ymm5
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm0, ymm0, ymm1
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm2, ymm2, ymm3
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm0, ymm0, ymm7
|
|
shun-iwasawa |
82a8f5 |
vpaddw ymm2, ymm2, ymm7
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm0, ymm0, 2
|
|
shun-iwasawa |
82a8f5 |
vpsrlw ymm2, ymm2, 2
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
vpackuswb ymm0, ymm0, ymm2
|
|
shun-iwasawa |
82a8f5 |
vpermq ymm0, ymm0, 0xd8
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm0
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
sub ecx, byte SIZEOF_YMMWORD ; outcol
|
|
shun-iwasawa |
82a8f5 |
add edx, byte 2*SIZEOF_YMMWORD ; inptr0
|
|
shun-iwasawa |
82a8f5 |
add esi, byte 2*SIZEOF_YMMWORD ; inptr1
|
|
shun-iwasawa |
82a8f5 |
add edi, byte 1*SIZEOF_YMMWORD ; outptr
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, byte SIZEOF_YMMWORD
|
|
shun-iwasawa |
82a8f5 |
jae near .columnloop
|
|
shun-iwasawa |
82a8f5 |
test ecx, ecx
|
|
shun-iwasawa |
82a8f5 |
jnz near .columnloop_r24
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pop esi
|
|
shun-iwasawa |
82a8f5 |
pop edi
|
|
shun-iwasawa |
82a8f5 |
pop ecx
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add esi, byte 2*SIZEOF_JSAMPROW ; input_data
|
|
shun-iwasawa |
82a8f5 |
add edi, byte 1*SIZEOF_JSAMPROW ; output_data
|
|
shun-iwasawa |
82a8f5 |
dec eax ; rowctr
|
|
shun-iwasawa |
82a8f5 |
jg near .rowloop
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.return:
|
|
shun-iwasawa |
82a8f5 |
vzeroupper
|
|
shun-iwasawa |
82a8f5 |
pop edi
|
|
shun-iwasawa |
82a8f5 |
pop esi
|
|
shun-iwasawa |
82a8f5 |
; pop edx ; need not be preserved
|
|
shun-iwasawa |
82a8f5 |
; pop ecx ; need not be preserved
|
|
shun-iwasawa |
82a8f5 |
; pop ebx ; unused
|
|
shun-iwasawa |
82a8f5 |
pop ebp
|
|
shun-iwasawa |
82a8f5 |
ret
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; For some reason, the OS X linker does not honor the request to align the
|
|
shun-iwasawa |
82a8f5 |
; segment unless we do this.
|
|
shun-iwasawa |
82a8f5 |
align 32
|