|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; jccolext.asm - colorspace conversion (MMX)
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB</ossman@cendio.se>
|
|
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 "jcolsamp.inc"
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; --------------------------------------------------------------------------
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; Convert some rows of samples to the output colorspace.
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; GLOBAL(void)
|
|
shun-iwasawa |
82a8f5 |
; jsimd_rgb_ycc_convert_mmx(JDIMENSION img_width, JSAMPARRAY input_buf,
|
|
shun-iwasawa |
82a8f5 |
; JSAMPIMAGE output_buf, JDIMENSION output_row,
|
|
shun-iwasawa |
82a8f5 |
; int num_rows);
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
%define img_width(b) (b) + 8 ; JDIMENSION img_width
|
|
shun-iwasawa |
82a8f5 |
%define input_buf(b) (b) + 12 ; JSAMPARRAY input_buf
|
|
shun-iwasawa |
82a8f5 |
%define output_buf(b) (b) + 16 ; JSAMPIMAGE output_buf
|
|
shun-iwasawa |
82a8f5 |
%define output_row(b) (b) + 20 ; JDIMENSION output_row
|
|
shun-iwasawa |
82a8f5 |
%define num_rows(b) (b) + 24 ; int num_rows
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
%define original_ebp ebp + 0
|
|
shun-iwasawa |
82a8f5 |
%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
; mmword wk[WK_NUM]
|
|
shun-iwasawa |
82a8f5 |
%define WK_NUM 8
|
|
shun-iwasawa |
82a8f5 |
%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
align 32
|
|
shun-iwasawa |
82a8f5 |
GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_mmx)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
EXTN(jsimd_rgb_ycc_convert_mmx):
|
|
shun-iwasawa |
82a8f5 |
push ebp
|
|
shun-iwasawa |
82a8f5 |
mov eax, esp ; eax = original ebp
|
|
shun-iwasawa |
82a8f5 |
sub esp, byte 4
|
|
shun-iwasawa |
82a8f5 |
and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
|
|
shun-iwasawa |
82a8f5 |
mov [esp], eax
|
|
shun-iwasawa |
82a8f5 |
mov ebp, esp ; ebp = aligned ebp
|
|
shun-iwasawa |
82a8f5 |
lea esp, [wk(0)]
|
|
shun-iwasawa |
82a8f5 |
pushpic eax ; make a room for GOT address
|
|
shun-iwasawa |
82a8f5 |
push ebx
|
|
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 |
get_GOT ebx ; get GOT address
|
|
shun-iwasawa |
82a8f5 |
movpic POINTER [gotptr], ebx ; save GOT address
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov ecx, JDIMENSION [img_width(eax)] ; num_cols
|
|
shun-iwasawa |
82a8f5 |
test ecx, ecx
|
|
shun-iwasawa |
82a8f5 |
jz near .return
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
push ecx
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPIMAGE [output_buf(eax)]
|
|
shun-iwasawa |
82a8f5 |
mov ecx, JDIMENSION [output_row(eax)]
|
|
shun-iwasawa |
82a8f5 |
mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY]
|
|
shun-iwasawa |
82a8f5 |
mov ebx, JSAMPARRAY [esi+1*SIZEOF_JSAMPARRAY]
|
|
shun-iwasawa |
82a8f5 |
mov edx, JSAMPARRAY [esi+2*SIZEOF_JSAMPARRAY]
|
|
shun-iwasawa |
82a8f5 |
lea edi, [edi+ecx*SIZEOF_JSAMPROW]
|
|
shun-iwasawa |
82a8f5 |
lea ebx, [ebx+ecx*SIZEOF_JSAMPROW]
|
|
shun-iwasawa |
82a8f5 |
lea edx, [edx+ecx*SIZEOF_JSAMPROW]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pop ecx
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPARRAY [input_buf(eax)]
|
|
shun-iwasawa |
82a8f5 |
mov eax, INT [num_rows(eax)]
|
|
shun-iwasawa |
82a8f5 |
test eax, eax
|
|
shun-iwasawa |
82a8f5 |
jle near .return
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
.rowloop:
|
|
shun-iwasawa |
82a8f5 |
pushpic eax
|
|
shun-iwasawa |
82a8f5 |
push edx
|
|
shun-iwasawa |
82a8f5 |
push ebx
|
|
shun-iwasawa |
82a8f5 |
push edi
|
|
shun-iwasawa |
82a8f5 |
push esi
|
|
shun-iwasawa |
82a8f5 |
push ecx ; col
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
mov esi, JSAMPROW [esi] ; inptr
|
|
shun-iwasawa |
82a8f5 |
mov edi, JSAMPROW [edi] ; outptr0
|
|
shun-iwasawa |
82a8f5 |
mov ebx, JSAMPROW [ebx] ; outptr1
|
|
shun-iwasawa |
82a8f5 |
mov edx, JSAMPROW [edx] ; outptr2
|
|
shun-iwasawa |
82a8f5 |
movpic eax, POINTER [gotptr] ; load GOT address (eax)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, byte SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
jae short .columnloop
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
%if RGB_PIXELSIZE == 3 ; ---------------
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.column_ld1:
|
|
shun-iwasawa |
82a8f5 |
push eax
|
|
shun-iwasawa |
82a8f5 |
push edx
|
|
shun-iwasawa |
82a8f5 |
lea ecx, [ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE
|
|
shun-iwasawa |
82a8f5 |
test cl, SIZEOF_BYTE
|
|
shun-iwasawa |
82a8f5 |
jz short .column_ld2
|
|
shun-iwasawa |
82a8f5 |
sub ecx, byte SIZEOF_BYTE
|
|
shun-iwasawa |
82a8f5 |
xor eax, eax
|
|
shun-iwasawa |
82a8f5 |
mov al, byte [esi+ecx]
|
|
shun-iwasawa |
82a8f5 |
.column_ld2:
|
|
shun-iwasawa |
82a8f5 |
test cl, SIZEOF_WORD
|
|
shun-iwasawa |
82a8f5 |
jz short .column_ld4
|
|
shun-iwasawa |
82a8f5 |
sub ecx, byte SIZEOF_WORD
|
|
shun-iwasawa |
82a8f5 |
xor edx, edx
|
|
shun-iwasawa |
82a8f5 |
mov dx, word [esi+ecx]
|
|
shun-iwasawa |
82a8f5 |
shl eax, WORD_BIT
|
|
shun-iwasawa |
82a8f5 |
or eax, edx
|
|
shun-iwasawa |
82a8f5 |
.column_ld4:
|
|
shun-iwasawa |
82a8f5 |
movd mmA, eax
|
|
shun-iwasawa |
82a8f5 |
pop edx
|
|
shun-iwasawa |
82a8f5 |
pop eax
|
|
shun-iwasawa |
82a8f5 |
test cl, SIZEOF_DWORD
|
|
shun-iwasawa |
82a8f5 |
jz short .column_ld8
|
|
shun-iwasawa |
82a8f5 |
sub ecx, byte SIZEOF_DWORD
|
|
shun-iwasawa |
82a8f5 |
movd mmG, dword [esi+ecx]
|
|
shun-iwasawa |
82a8f5 |
psllq mmA, DWORD_BIT
|
|
shun-iwasawa |
82a8f5 |
por mmA, mmG
|
|
shun-iwasawa |
82a8f5 |
.column_ld8:
|
|
shun-iwasawa |
82a8f5 |
test cl, SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
jz short .column_ld16
|
|
shun-iwasawa |
82a8f5 |
movq mmG, mmA
|
|
shun-iwasawa |
82a8f5 |
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
jmp short .rgb_ycc_cnv
|
|
shun-iwasawa |
82a8f5 |
.column_ld16:
|
|
shun-iwasawa |
82a8f5 |
test cl, 2*SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
jz short .rgb_ycc_cnv
|
|
shun-iwasawa |
82a8f5 |
movq mmF, mmA
|
|
shun-iwasawa |
82a8f5 |
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
jmp short .rgb_ycc_cnv
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop:
|
|
shun-iwasawa |
82a8f5 |
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
movq mmF, MMWORD [esi+2*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.rgb_ycc_cnv:
|
|
shun-iwasawa |
82a8f5 |
; mmA=(00 10 20 01 11 21 02 12)
|
|
shun-iwasawa |
82a8f5 |
; mmG=(22 03 13 23 04 14 24 05)
|
|
shun-iwasawa |
82a8f5 |
; mmF=(15 25 06 16 26 07 17 27)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmD, mmA
|
|
shun-iwasawa |
82a8f5 |
psllq mmA, 4*BYTE_BIT ; mmA=(-- -- -- -- 00 10 20 01)
|
|
shun-iwasawa |
82a8f5 |
psrlq mmD, 4*BYTE_BIT ; mmD=(11 21 02 12 -- -- -- --)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmA, mmG ; mmA=(00 04 10 14 20 24 01 05)
|
|
shun-iwasawa |
82a8f5 |
psllq mmG, 4*BYTE_BIT ; mmG=(-- -- -- -- 22 03 13 23)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmD, mmF ; mmD=(11 15 21 25 02 06 12 16)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmG, mmF ; mmG=(22 26 03 07 13 17 23 27)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmE, mmA
|
|
shun-iwasawa |
82a8f5 |
psllq mmA, 4*BYTE_BIT ; mmA=(-- -- -- -- 00 04 10 14)
|
|
shun-iwasawa |
82a8f5 |
psrlq mmE, 4*BYTE_BIT ; mmE=(20 24 01 05 -- -- -- --)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmA, mmD ; mmA=(00 02 04 06 10 12 14 16)
|
|
shun-iwasawa |
82a8f5 |
psllq mmD, 4*BYTE_BIT ; mmD=(-- -- -- -- 11 15 21 25)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmE, mmG ; mmE=(20 22 24 26 01 03 05 07)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmD, mmG ; mmD=(11 13 15 17 21 23 25 27)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pxor mmH, mmH
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmC, mmA
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmA, mmH ; mmA=(00 02 04 06)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmC, mmH ; mmC=(10 12 14 16)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmB, mmE
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmE, mmH ; mmE=(20 22 24 26)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmB, mmH ; mmB=(01 03 05 07)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmF, mmD
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmD, mmH ; mmD=(11 13 15 17)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmF, mmH ; mmF=(21 23 25 27)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
%else ; RGB_PIXELSIZE == 4 ; -----------
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.column_ld1:
|
|
shun-iwasawa |
82a8f5 |
test cl, SIZEOF_MMWORD/8
|
|
shun-iwasawa |
82a8f5 |
jz short .column_ld2
|
|
shun-iwasawa |
82a8f5 |
sub ecx, byte SIZEOF_MMWORD/8
|
|
shun-iwasawa |
82a8f5 |
movd mmA, dword [esi+ecx*RGB_PIXELSIZE]
|
|
shun-iwasawa |
82a8f5 |
.column_ld2:
|
|
shun-iwasawa |
82a8f5 |
test cl, SIZEOF_MMWORD/4
|
|
shun-iwasawa |
82a8f5 |
jz short .column_ld4
|
|
shun-iwasawa |
82a8f5 |
sub ecx, byte SIZEOF_MMWORD/4
|
|
shun-iwasawa |
82a8f5 |
movq mmF, mmA
|
|
shun-iwasawa |
82a8f5 |
movq mmA, MMWORD [esi+ecx*RGB_PIXELSIZE]
|
|
shun-iwasawa |
82a8f5 |
.column_ld4:
|
|
shun-iwasawa |
82a8f5 |
test cl, SIZEOF_MMWORD/2
|
|
shun-iwasawa |
82a8f5 |
mov ecx, SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
jz short .rgb_ycc_cnv
|
|
shun-iwasawa |
82a8f5 |
movq mmD, mmA
|
|
shun-iwasawa |
82a8f5 |
movq mmC, mmF
|
|
shun-iwasawa |
82a8f5 |
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
jmp short .rgb_ycc_cnv
|
|
shun-iwasawa |
82a8f5 |
alignx 16, 7
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.columnloop:
|
|
shun-iwasawa |
82a8f5 |
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
movq mmD, MMWORD [esi+2*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
movq mmC, MMWORD [esi+3*SIZEOF_MMWORD]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.rgb_ycc_cnv:
|
|
shun-iwasawa |
82a8f5 |
; mmA=(00 10 20 30 01 11 21 31)
|
|
shun-iwasawa |
82a8f5 |
; mmF=(02 12 22 32 03 13 23 33)
|
|
shun-iwasawa |
82a8f5 |
; mmD=(04 14 24 34 05 15 25 35)
|
|
shun-iwasawa |
82a8f5 |
; mmC=(06 16 26 36 07 17 27 37)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmB, mmA
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmA, mmF ; mmA=(00 02 10 12 20 22 30 32)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmB, mmF ; mmB=(01 03 11 13 21 23 31 33)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmG, mmD
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmD, mmC ; mmD=(04 06 14 16 24 26 34 36)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmG, mmC ; mmG=(05 07 15 17 25 27 35 37)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmE, mmA
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mmA, mmD ; mmA=(00 02 04 06 10 12 14 16)
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mmE, mmD ; mmE=(20 22 24 26 30 32 34 36)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmH, mmB
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mmB, mmG ; mmB=(01 03 05 07 11 13 15 17)
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mmH, mmG ; mmH=(21 23 25 27 31 33 35 37)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pxor mmF, mmF
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmC, mmA
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmA, mmF ; mmA=(00 02 04 06)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmC, mmF ; mmC=(10 12 14 16)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmD, mmB
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmB, mmF ; mmB=(01 03 05 07)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmD, mmF ; mmD=(11 13 15 17)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mmG, mmE
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmE, mmF ; mmE=(20 22 24 26)
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmG, mmF ; mmG=(30 32 34 36)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
punpcklbw mmF, mmH
|
|
shun-iwasawa |
82a8f5 |
punpckhbw mmH, mmH
|
|
shun-iwasawa |
82a8f5 |
psrlw mmF, BYTE_BIT ; mmF=(21 23 25 27)
|
|
shun-iwasawa |
82a8f5 |
psrlw mmH, BYTE_BIT ; mmH=(31 33 35 37)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
%endif ; RGB_PIXELSIZE ; ---------------
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; mm0=(R0 R2 R4 R6)=RE, mm2=(G0 G2 G4 G6)=GE, mm4=(B0 B2 B4 B6)=BE
|
|
shun-iwasawa |
82a8f5 |
; mm1=(R1 R3 R5 R7)=RO, mm3=(G1 G3 G5 G7)=GO, mm5=(B1 B3 B5 B7)=BO
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
; (Original)
|
|
shun-iwasawa |
82a8f5 |
; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
|
|
shun-iwasawa |
82a8f5 |
; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
|
|
shun-iwasawa |
82a8f5 |
; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
|
|
shun-iwasawa |
82a8f5 |
;
|
|
shun-iwasawa |
82a8f5 |
; (This implementation)
|
|
shun-iwasawa |
82a8f5 |
; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
|
|
shun-iwasawa |
82a8f5 |
; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
|
|
shun-iwasawa |
82a8f5 |
; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [wk(0)], mm0 ; wk(0)=RE
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [wk(1)], mm1 ; wk(1)=RO
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [wk(2)], mm4 ; wk(2)=BE
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [wk(3)], mm5 ; wk(3)=BO
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm6, mm1
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mm1, mm3
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mm6, mm3
|
|
shun-iwasawa |
82a8f5 |
movq mm7, mm1
|
|
shun-iwasawa |
82a8f5 |
movq mm4, mm6
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm1, [GOTOFF(eax,PW_F0299_F0337)] ; mm1=ROL*FIX(0.299)+GOL*FIX(0.337)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm6, [GOTOFF(eax,PW_F0299_F0337)] ; mm6=ROH*FIX(0.299)+GOH*FIX(0.337)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm7, [GOTOFF(eax,PW_MF016_MF033)] ; mm7=ROL*-FIX(0.168)+GOL*-FIX(0.331)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm4, [GOTOFF(eax,PW_MF016_MF033)] ; mm4=ROH*-FIX(0.168)+GOH*-FIX(0.331)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [wk(4)], mm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337)
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [wk(5)], mm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pxor mm1, mm1
|
|
shun-iwasawa |
82a8f5 |
pxor mm6, mm6
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mm1, mm5 ; mm1=BOL
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mm6, mm5 ; mm6=BOH
|
|
shun-iwasawa |
82a8f5 |
psrld mm1, 1 ; mm1=BOL*FIX(0.500)
|
|
shun-iwasawa |
82a8f5 |
psrld mm6, 1 ; mm6=BOH*FIX(0.500)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm5, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm5=[PD_ONEHALFM1_CJ]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
paddd mm7, mm1
|
|
shun-iwasawa |
82a8f5 |
paddd mm4, mm6
|
|
shun-iwasawa |
82a8f5 |
paddd mm7, mm5
|
|
shun-iwasawa |
82a8f5 |
paddd mm4, mm5
|
|
shun-iwasawa |
82a8f5 |
psrld mm7, SCALEBITS ; mm7=CbOL
|
|
shun-iwasawa |
82a8f5 |
psrld mm4, SCALEBITS ; mm4=CbOH
|
|
shun-iwasawa |
82a8f5 |
packssdw mm7, mm4 ; mm7=CbO
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm1, MMWORD [wk(2)] ; mm1=BE
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm6, mm0
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mm0, mm2
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mm6, mm2
|
|
shun-iwasawa |
82a8f5 |
movq mm5, mm0
|
|
shun-iwasawa |
82a8f5 |
movq mm4, mm6
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm0, [GOTOFF(eax,PW_F0299_F0337)] ; mm0=REL*FIX(0.299)+GEL*FIX(0.337)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm6, [GOTOFF(eax,PW_F0299_F0337)] ; mm6=REH*FIX(0.299)+GEH*FIX(0.337)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm5, [GOTOFF(eax,PW_MF016_MF033)] ; mm5=REL*-FIX(0.168)+GEL*-FIX(0.331)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm4, [GOTOFF(eax,PW_MF016_MF033)] ; mm4=REH*-FIX(0.168)+GEH*-FIX(0.331)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [wk(6)], mm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337)
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [wk(7)], mm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pxor mm0, mm0
|
|
shun-iwasawa |
82a8f5 |
pxor mm6, mm6
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mm0, mm1 ; mm0=BEL
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mm6, mm1 ; mm6=BEH
|
|
shun-iwasawa |
82a8f5 |
psrld mm0, 1 ; mm0=BEL*FIX(0.500)
|
|
shun-iwasawa |
82a8f5 |
psrld mm6, 1 ; mm6=BEH*FIX(0.500)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm1, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
paddd mm5, mm0
|
|
shun-iwasawa |
82a8f5 |
paddd mm4, mm6
|
|
shun-iwasawa |
82a8f5 |
paddd mm5, mm1
|
|
shun-iwasawa |
82a8f5 |
paddd mm4, mm1
|
|
shun-iwasawa |
82a8f5 |
psrld mm5, SCALEBITS ; mm5=CbEL
|
|
shun-iwasawa |
82a8f5 |
psrld mm4, SCALEBITS ; mm4=CbEH
|
|
shun-iwasawa |
82a8f5 |
packssdw mm5, mm4 ; mm5=CbE
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
psllw mm7, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
por mm5, mm7 ; mm5=Cb
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [ebx], mm5 ; Save Cb
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm0, MMWORD [wk(3)] ; mm0=BO
|
|
shun-iwasawa |
82a8f5 |
movq mm6, MMWORD [wk(2)] ; mm6=BE
|
|
shun-iwasawa |
82a8f5 |
movq mm1, MMWORD [wk(1)] ; mm1=RO
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm4, mm0
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mm0, mm3
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mm4, mm3
|
|
shun-iwasawa |
82a8f5 |
movq mm7, mm0
|
|
shun-iwasawa |
82a8f5 |
movq mm5, mm4
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm0, [GOTOFF(eax,PW_F0114_F0250)] ; mm0=BOL*FIX(0.114)+GOL*FIX(0.250)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm4, [GOTOFF(eax,PW_F0114_F0250)] ; mm4=BOH*FIX(0.114)+GOH*FIX(0.250)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm7, [GOTOFF(eax,PW_MF008_MF041)] ; mm7=BOL*-FIX(0.081)+GOL*-FIX(0.418)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm5, [GOTOFF(eax,PW_MF008_MF041)] ; mm5=BOH*-FIX(0.081)+GOH*-FIX(0.418)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm3, [GOTOFF(eax,PD_ONEHALF)] ; mm3=[PD_ONEHALF]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
paddd mm0, MMWORD [wk(4)]
|
|
shun-iwasawa |
82a8f5 |
paddd mm4, MMWORD [wk(5)]
|
|
shun-iwasawa |
82a8f5 |
paddd mm0, mm3
|
|
shun-iwasawa |
82a8f5 |
paddd mm4, mm3
|
|
shun-iwasawa |
82a8f5 |
psrld mm0, SCALEBITS ; mm0=YOL
|
|
shun-iwasawa |
82a8f5 |
psrld mm4, SCALEBITS ; mm4=YOH
|
|
shun-iwasawa |
82a8f5 |
packssdw mm0, mm4 ; mm0=YO
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pxor mm3, mm3
|
|
shun-iwasawa |
82a8f5 |
pxor mm4, mm4
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mm3, mm1 ; mm3=ROL
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mm4, mm1 ; mm4=ROH
|
|
shun-iwasawa |
82a8f5 |
psrld mm3, 1 ; mm3=ROL*FIX(0.500)
|
|
shun-iwasawa |
82a8f5 |
psrld mm4, 1 ; mm4=ROH*FIX(0.500)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm1, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
paddd mm7, mm3
|
|
shun-iwasawa |
82a8f5 |
paddd mm5, mm4
|
|
shun-iwasawa |
82a8f5 |
paddd mm7, mm1
|
|
shun-iwasawa |
82a8f5 |
paddd mm5, mm1
|
|
shun-iwasawa |
82a8f5 |
psrld mm7, SCALEBITS ; mm7=CrOL
|
|
shun-iwasawa |
82a8f5 |
psrld mm5, SCALEBITS ; mm5=CrOH
|
|
shun-iwasawa |
82a8f5 |
packssdw mm7, mm5 ; mm7=CrO
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm3, MMWORD [wk(0)] ; mm3=RE
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm4, mm6
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mm6, mm2
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mm4, mm2
|
|
shun-iwasawa |
82a8f5 |
movq mm1, mm6
|
|
shun-iwasawa |
82a8f5 |
movq mm5, mm4
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm6, [GOTOFF(eax,PW_F0114_F0250)] ; mm6=BEL*FIX(0.114)+GEL*FIX(0.250)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm4, [GOTOFF(eax,PW_F0114_F0250)] ; mm4=BEH*FIX(0.114)+GEH*FIX(0.250)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm1, [GOTOFF(eax,PW_MF008_MF041)] ; mm1=BEL*-FIX(0.081)+GEL*-FIX(0.418)
|
|
shun-iwasawa |
82a8f5 |
pmaddwd mm5, [GOTOFF(eax,PW_MF008_MF041)] ; mm5=BEH*-FIX(0.081)+GEH*-FIX(0.418)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm2, [GOTOFF(eax,PD_ONEHALF)] ; mm2=[PD_ONEHALF]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
paddd mm6, MMWORD [wk(6)]
|
|
shun-iwasawa |
82a8f5 |
paddd mm4, MMWORD [wk(7)]
|
|
shun-iwasawa |
82a8f5 |
paddd mm6, mm2
|
|
shun-iwasawa |
82a8f5 |
paddd mm4, mm2
|
|
shun-iwasawa |
82a8f5 |
psrld mm6, SCALEBITS ; mm6=YEL
|
|
shun-iwasawa |
82a8f5 |
psrld mm4, SCALEBITS ; mm4=YEH
|
|
shun-iwasawa |
82a8f5 |
packssdw mm6, mm4 ; mm6=YE
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
psllw mm0, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
por mm6, mm0 ; mm6=Y
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [edi], mm6 ; Save Y
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pxor mm2, mm2
|
|
shun-iwasawa |
82a8f5 |
pxor mm4, mm4
|
|
shun-iwasawa |
82a8f5 |
punpcklwd mm2, mm3 ; mm2=REL
|
|
shun-iwasawa |
82a8f5 |
punpckhwd mm4, mm3 ; mm4=REH
|
|
shun-iwasawa |
82a8f5 |
psrld mm2, 1 ; mm2=REL*FIX(0.500)
|
|
shun-iwasawa |
82a8f5 |
psrld mm4, 1 ; mm4=REH*FIX(0.500)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
movq mm0, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm0=[PD_ONEHALFM1_CJ]
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
paddd mm1, mm2
|
|
shun-iwasawa |
82a8f5 |
paddd mm5, mm4
|
|
shun-iwasawa |
82a8f5 |
paddd mm1, mm0
|
|
shun-iwasawa |
82a8f5 |
paddd mm5, mm0
|
|
shun-iwasawa |
82a8f5 |
psrld mm1, SCALEBITS ; mm1=CrEL
|
|
shun-iwasawa |
82a8f5 |
psrld mm5, SCALEBITS ; mm5=CrEH
|
|
shun-iwasawa |
82a8f5 |
packssdw mm1, mm5 ; mm1=CrE
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
psllw mm7, BYTE_BIT
|
|
shun-iwasawa |
82a8f5 |
por mm1, mm7 ; mm1=Cr
|
|
shun-iwasawa |
82a8f5 |
movq MMWORD [edx], mm1 ; Save Cr
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
sub ecx, byte SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
add esi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; inptr
|
|
shun-iwasawa |
82a8f5 |
add edi, byte SIZEOF_MMWORD ; outptr0
|
|
shun-iwasawa |
82a8f5 |
add ebx, byte SIZEOF_MMWORD ; outptr1
|
|
shun-iwasawa |
82a8f5 |
add edx, byte SIZEOF_MMWORD ; outptr2
|
|
shun-iwasawa |
82a8f5 |
cmp ecx, byte SIZEOF_MMWORD
|
|
shun-iwasawa |
82a8f5 |
jae near .columnloop
|
|
shun-iwasawa |
82a8f5 |
test ecx, ecx
|
|
shun-iwasawa |
82a8f5 |
jnz near .column_ld1
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
pop ecx ; col
|
|
shun-iwasawa |
82a8f5 |
pop esi
|
|
shun-iwasawa |
82a8f5 |
pop edi
|
|
shun-iwasawa |
82a8f5 |
pop ebx
|
|
shun-iwasawa |
82a8f5 |
pop edx
|
|
shun-iwasawa |
82a8f5 |
poppic eax
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add esi, byte SIZEOF_JSAMPROW ; input_buf
|
|
shun-iwasawa |
82a8f5 |
add edi, byte SIZEOF_JSAMPROW
|
|
shun-iwasawa |
82a8f5 |
add ebx, byte SIZEOF_JSAMPROW
|
|
shun-iwasawa |
82a8f5 |
add edx, byte SIZEOF_JSAMPROW
|
|
shun-iwasawa |
82a8f5 |
dec eax ; num_rows
|
|
shun-iwasawa |
82a8f5 |
jg near .rowloop
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
emms ; empty MMX state
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
.return:
|
|
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
|
|
shun-iwasawa |
82a8f5 |
mov esp, ebp ; esp <- aligned ebp
|
|
shun-iwasawa |
82a8f5 |
pop esp ; esp <- original ebp
|
|
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
|