forked from KolibriOS/kolibrios
libimg:
1. tiff (baseline) support 2. pnm (portable anymap) bilevel, grayscale (8bpp), pixmap (24bpp) support 3. xcf: optional layer merging/blending with sse (default is mmx) 4'. new formatting for my old code. more readable for now git-svn-id: svn://kolibrios.org@2388 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
997d83d275
commit
0808796ed5
@ -40,6 +40,8 @@ include 'z80/z80.asm'
|
||||
include 'ico_cur/ico_cur.asm'
|
||||
include 'pcx/pcx.asm'
|
||||
include 'xcf/xcf.asm'
|
||||
include 'tiff/tiff.asm'
|
||||
include 'pnm/pnm.asm'
|
||||
|
||||
;;================================================================================================;;
|
||||
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
|
||||
@ -1999,6 +2001,8 @@ img._.formats_table:
|
||||
.tga dd img.is.tga, img.decode.tga, img.encode.tga
|
||||
.pcx dd img.is.pcx, img.decode.pcx, img.encode.pcx
|
||||
.xcf dd img.is.xcf, img.decode.xcf, img.encode.xcf
|
||||
.tiff dd img.is.tiff, img.decode.tiff, img.encode.tiff
|
||||
.pnm dd img.is.pnm, img.decode.pnm, img.encode.pnm
|
||||
.z80 dd img.is.z80, img.decode.z80, img.encode.z80 ;this must be the last entry as there are no
|
||||
;signatures in z80 screens at all
|
||||
dd 0
|
||||
|
@ -46,6 +46,7 @@ Image.bpp32 = 3
|
||||
Image.bpp15 = 4
|
||||
Image.bpp16 = 5
|
||||
Image.bpp1 = 6
|
||||
Image.bpp4 = 7
|
||||
|
||||
; bits in Image.Flags
|
||||
Image.IsAnimated = 1
|
||||
|
@ -1,5 +1,5 @@
|
||||
;;================================================================================================;;
|
||||
;;//// pcx.asm //// (c) dunkaist, 2010 ///////////////////////////////////////////////////////////;;
|
||||
;;//// pcx.asm //// (c) dunkaist, 2010,2012 //////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
@ -17,7 +17,7 @@
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'pcx.inc'
|
||||
include 'pcx.inc'
|
||||
;include '../../../../system/board/trunk/debug.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
@ -31,37 +31,37 @@ proc img.is.pcx _data, _length ;////////////////////////////////////////////////
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
push ecx edi
|
||||
xor eax, eax
|
||||
push ecx edi
|
||||
xor eax, eax
|
||||
|
||||
mov edi, [_data]
|
||||
mov edi, [_data]
|
||||
|
||||
cmp [edi+pcx_header.magic_number], 10
|
||||
jne .is_not_pcx
|
||||
cmp [edi+pcx_header.version], 5
|
||||
jne .is_not_pcx
|
||||
cmp [edi+pcx_header.encoding], 1
|
||||
jne .is_not_pcx
|
||||
cmp [edi+pcx_header.reserved], 0
|
||||
jne .is_not_pcx
|
||||
cmp [edi + pcx_header.magic_number], 10
|
||||
jne .is_not_pcx
|
||||
cmp [edi + pcx_header.version], 5
|
||||
jne .is_not_pcx
|
||||
cmp [edi + pcx_header.encoding], 1
|
||||
jne .is_not_pcx
|
||||
cmp [edi + pcx_header.reserved], 0
|
||||
jne .is_not_pcx
|
||||
|
||||
add edi, pcx_header.filler
|
||||
xor al, al
|
||||
mov ecx, 58
|
||||
cld
|
||||
repe scasb
|
||||
test ecx, ecx
|
||||
jnz .is_not_pcx
|
||||
add edi, pcx_header.filler
|
||||
xor al, al
|
||||
mov ecx, 58
|
||||
cld
|
||||
repe scasb
|
||||
test ecx, ecx
|
||||
jnz .is_not_pcx
|
||||
|
||||
.is_pcx:
|
||||
inc eax
|
||||
|
||||
.is_not_pcx:
|
||||
pop edi ecx
|
||||
ret
|
||||
.is_pcx:
|
||||
inc eax
|
||||
|
||||
.is_not_pcx:
|
||||
pop edi ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.pcx _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -73,220 +73,218 @@ proc img.decode.pcx _data, _length, _options ;//////////////////////////////////
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
nplanes rd 1
|
||||
xsize rw 1
|
||||
ysize rw 1
|
||||
bpl rw 1
|
||||
total_bpl rd 1
|
||||
line_begin rd 1
|
||||
retvalue rd 1 ; 0 (error) or pointer to image
|
||||
nplanes rd 1
|
||||
xsize rw 1
|
||||
ysize rw 1
|
||||
bpl rw 1
|
||||
total_bpl rd 1
|
||||
line_begin rd 1
|
||||
retvalue rd 1 ; 0 (error) or pointer to image
|
||||
endl
|
||||
|
||||
pusha
|
||||
pusha
|
||||
|
||||
mov esi, [_data]
|
||||
movzx eax, byte[esi+pcx_header.nplanes]
|
||||
mov [nplanes], eax
|
||||
mov bx, word[esi+pcx_header.bpl]
|
||||
mov [bpl], bx
|
||||
mul bx
|
||||
shl eax, 16
|
||||
mov ax, dx
|
||||
ror eax, 16
|
||||
mov [total_bpl], eax
|
||||
mov esi, [_data]
|
||||
movzx eax, byte[esi + pcx_header.nplanes]
|
||||
mov [nplanes], eax
|
||||
mov bx, word[esi + pcx_header.bpl]
|
||||
mov [bpl], bx
|
||||
mul bx
|
||||
shl eax, 16
|
||||
mov ax, dx
|
||||
ror eax, 16
|
||||
mov [total_bpl], eax
|
||||
|
||||
movzx eax, word[esi+pcx_header.xmax]
|
||||
inc ax
|
||||
sub ax, word[esi+pcx_header.xmin]
|
||||
mov [xsize], ax
|
||||
movzx eax, word[esi + pcx_header.xmax]
|
||||
inc ax
|
||||
sub ax, word[esi + pcx_header.xmin]
|
||||
mov [xsize], ax
|
||||
|
||||
movzx ebx, word[esi+pcx_header.ymax]
|
||||
inc bx
|
||||
sub bx, word[esi+pcx_header.ymin]
|
||||
mov [ysize], bx
|
||||
movzx ebx, word[esi + pcx_header.ymax]
|
||||
inc bx
|
||||
sub bx, word[esi + pcx_header.ymin]
|
||||
mov [ysize], bx
|
||||
|
||||
|
||||
cmp [esi+pcx_header.bpp], 1
|
||||
jz .monochrome
|
||||
cmp byte[esi+pcx_header.nplanes], 3
|
||||
jnz .indexed
|
||||
cmp [esi + pcx_header.bpp], 1
|
||||
jz .monochrome
|
||||
cmp byte[esi + pcx_header.nplanes], 3
|
||||
jnz .indexed
|
||||
|
||||
|
||||
._24bit:
|
||||
|
||||
stdcall img.create, eax, ebx, Image.bpp24
|
||||
mov [retvalue], eax
|
||||
test eax, eax
|
||||
jz .quit
|
||||
stdcall img.create, eax, ebx, Image.bpp24
|
||||
mov [retvalue], eax
|
||||
test eax, eax
|
||||
jz .quit
|
||||
|
||||
movzx ebx, [xsize]
|
||||
movzx ecx, [ysize]
|
||||
mov edx, [eax+Image.Data]
|
||||
movzx ebx, [xsize]
|
||||
movzx ecx, [ysize]
|
||||
mov edx, [eax+Image.Data]
|
||||
|
||||
rol ebx, 16
|
||||
or ebx, ecx
|
||||
xor ebx, [edx]
|
||||
mov [eax+Image.Checksum], ebx
|
||||
rol ebx, 16
|
||||
or ebx, ecx
|
||||
xor ebx, [edx]
|
||||
mov [eax + Image.Checksum], ebx
|
||||
|
||||
|
||||
mov esi, [_data]
|
||||
add esi, 128
|
||||
; mov edi, [retvalue]
|
||||
mov edi, [eax+Image.Data]
|
||||
add edi, 2
|
||||
mov [line_begin], edi
|
||||
mov ebx, [total_bpl]
|
||||
mov esi, [_data]
|
||||
add esi, 128
|
||||
; mov edi, [retvalue]
|
||||
mov edi, [eax + Image.Data]
|
||||
add edi, 2
|
||||
mov [line_begin], edi
|
||||
mov ebx, [total_bpl]
|
||||
|
||||
._24bit.begin:
|
||||
mov ax, word[bpl]
|
||||
mov ax, word[bpl]
|
||||
._24bit.decode:
|
||||
call get_byte
|
||||
call pcx._.get_byte
|
||||
._24bit.write_sequence:
|
||||
mov [edi], dl
|
||||
dec ax
|
||||
add edi, [nplanes]
|
||||
dec dh
|
||||
jnz ._24bit.write_sequence
|
||||
mov [edi], dl
|
||||
dec ax
|
||||
add edi, [nplanes]
|
||||
dec dh
|
||||
jnz ._24bit.write_sequence
|
||||
|
||||
test ax, ax
|
||||
jz ._24bit.end_color_line
|
||||
jmp ._24bit.decode
|
||||
test ax, ax
|
||||
jz ._24bit.end_color_line
|
||||
jmp ._24bit.decode
|
||||
|
||||
._24bit.end_color_line:
|
||||
test ebx, ebx
|
||||
jz ._24bit.end_full_line
|
||||
dec [line_begin]
|
||||
mov edi, [line_begin]
|
||||
jmp ._24bit.begin
|
||||
._24bit.end_color_line:
|
||||
test ebx, ebx
|
||||
jz ._24bit.end_full_line
|
||||
dec [line_begin]
|
||||
mov edi, [line_begin]
|
||||
jmp ._24bit.begin
|
||||
|
||||
._24bit.end_full_line:
|
||||
dec word[ysize]
|
||||
jz .quit
|
||||
mov ebx, [total_bpl]
|
||||
add edi, 2
|
||||
mov [line_begin], edi
|
||||
jmp ._24bit.begin
|
||||
dec word[ysize]
|
||||
jz .quit
|
||||
mov ebx, [total_bpl]
|
||||
add edi, 2
|
||||
mov [line_begin], edi
|
||||
jmp ._24bit.begin
|
||||
|
||||
|
||||
.indexed:
|
||||
|
||||
stdcall img.create, eax, ebx, Image.bpp8
|
||||
mov [retvalue], eax
|
||||
test eax, eax
|
||||
jz .quit
|
||||
stdcall img.create, eax, ebx, Image.bpp8
|
||||
mov [retvalue], eax
|
||||
test eax, eax
|
||||
jz .quit
|
||||
|
||||
movzx ebx, [xsize]
|
||||
movzx ecx, [ysize]
|
||||
mov edx, [eax+Image.Data]
|
||||
movzx ebx, [xsize]
|
||||
movzx ecx, [ysize]
|
||||
mov edx, [eax + Image.Data]
|
||||
|
||||
rol ebx, 16
|
||||
or ebx, ecx
|
||||
xor ebx, [edx]
|
||||
mov [eax+Image.Checksum], ebx
|
||||
rol ebx, 16
|
||||
or ebx, ecx
|
||||
xor ebx, [edx]
|
||||
mov [eax + Image.Checksum], ebx
|
||||
|
||||
mov esi, [_data]
|
||||
add esi, [_length]
|
||||
sub esi, 768
|
||||
mov edi, [eax+Image.Palette]
|
||||
mov cx, 256
|
||||
@@:
|
||||
mov ebx, [esi]
|
||||
bswap ebx
|
||||
shr ebx, 8
|
||||
mov [edi], ebx
|
||||
add edi, 4
|
||||
add esi, 3
|
||||
dec cx
|
||||
jnz @b
|
||||
mov esi, [_data]
|
||||
add esi, [_length]
|
||||
sub esi, 768
|
||||
mov edi, [eax + Image.Palette]
|
||||
mov cx, 256
|
||||
@@:
|
||||
mov ebx, [esi]
|
||||
bswap ebx
|
||||
shr ebx, 8
|
||||
mov [edi], ebx
|
||||
add edi, 4
|
||||
add esi, 3
|
||||
dec cx
|
||||
jnz @b
|
||||
|
||||
mov esi, [_data]
|
||||
add esi, 128
|
||||
; mov edi, [retvalue]
|
||||
mov edi, [eax+Image.Data]
|
||||
mov esi, [_data]
|
||||
add esi, 128
|
||||
; mov edi, [retvalue]
|
||||
mov edi, [eax + Image.Data]
|
||||
|
||||
.indexed.begin:
|
||||
mov ax, word[bpl]
|
||||
mov ax, word[bpl]
|
||||
.indexed.decode:
|
||||
call get_byte
|
||||
call pcx._.get_byte
|
||||
.indexed.write_sequence:
|
||||
mov [edi], dl
|
||||
inc edi
|
||||
dec ax
|
||||
dec dh
|
||||
jnz .indexed.write_sequence
|
||||
mov [edi], dl
|
||||
inc edi
|
||||
dec ax
|
||||
dec dh
|
||||
jnz .indexed.write_sequence
|
||||
|
||||
test ax, ax
|
||||
jz .indexed.end_line
|
||||
jmp .indexed.decode
|
||||
test ax, ax
|
||||
jz .indexed.end_line
|
||||
jmp .indexed.decode
|
||||
|
||||
.indexed.end_line:
|
||||
dec word[ysize]
|
||||
jz .quit
|
||||
jmp .indexed.begin
|
||||
dec word[ysize]
|
||||
jz .quit
|
||||
jmp .indexed.begin
|
||||
|
||||
|
||||
.monochrome:
|
||||
|
||||
stdcall img.create, eax, ebx, Image.bpp1
|
||||
mov [retvalue], eax
|
||||
test eax, eax
|
||||
jz .quit
|
||||
stdcall img.create, eax, ebx, Image.bpp1
|
||||
mov [retvalue], eax
|
||||
test eax, eax
|
||||
jz .quit
|
||||
|
||||
movzx ebx, [xsize]
|
||||
movzx ecx, [ysize]
|
||||
mov edx, [eax+Image.Data]
|
||||
movzx ebx, [xsize]
|
||||
movzx ecx, [ysize]
|
||||
mov edx, [eax + Image.Data]
|
||||
|
||||
rol ebx, 16
|
||||
or ebx, ecx
|
||||
xor ebx, [edx]
|
||||
mov [eax+Image.Checksum], ebx
|
||||
rol ebx, 16
|
||||
or ebx, ecx
|
||||
xor ebx, [edx]
|
||||
mov [eax + Image.Checksum], ebx
|
||||
|
||||
mov edi, [eax+Image.Palette]
|
||||
mov [edi], dword 0x00000000
|
||||
mov [edi+4], dword 0x00ffffff
|
||||
mov edi, [eax + Image.Palette]
|
||||
mov [edi], dword 0x00000000
|
||||
mov [edi + 4], dword 0x00ffffff
|
||||
|
||||
mov esi, [_data]
|
||||
add esi, 128
|
||||
; mov edi, [retvalue]
|
||||
mov edi, [eax+Image.Data]
|
||||
mov esi, [_data]
|
||||
add esi, 128
|
||||
; mov edi, [retvalue]
|
||||
mov edi, [eax + Image.Data]
|
||||
|
||||
|
||||
.monochrome.begin:
|
||||
mov ebx, [total_bpl]
|
||||
mov ax, [xsize]
|
||||
mov ebx, [total_bpl]
|
||||
mov ax, [xsize]
|
||||
|
||||
.monochrome.decode:
|
||||
call get_byte
|
||||
call pcx._.get_byte
|
||||
.monochrome.write_sequence:
|
||||
mov [edi], dl
|
||||
inc edi
|
||||
cmp ax, 8
|
||||
jng .monochrome.is_last_byte_in_line
|
||||
sub ax, 8
|
||||
dec dh
|
||||
jnz .monochrome.write_sequence
|
||||
jmp .monochrome.decode
|
||||
mov [edi], dl
|
||||
inc edi
|
||||
cmp ax, 8
|
||||
jng .monochrome.is_last_byte_in_line
|
||||
sub ax, 8
|
||||
dec dh
|
||||
jnz .monochrome.write_sequence
|
||||
jmp .monochrome.decode
|
||||
|
||||
.monochrome.is_last_byte_in_line:
|
||||
test ebx, ebx
|
||||
jng @f
|
||||
call get_byte
|
||||
jmp .monochrome.is_last_byte_in_line
|
||||
@@:
|
||||
dec word[ysize]
|
||||
jnz .monochrome.begin
|
||||
jmp .quit
|
||||
test ebx, ebx
|
||||
jng @f
|
||||
call pcx._.get_byte
|
||||
jmp .monochrome.is_last_byte_in_line
|
||||
@@:
|
||||
dec word[ysize]
|
||||
jnz .monochrome.begin
|
||||
jmp .quit
|
||||
|
||||
|
||||
.quit:
|
||||
popa
|
||||
mov eax, [retvalue]
|
||||
ret
|
||||
|
||||
popa
|
||||
mov eax, [retvalue]
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.pcx _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -297,8 +295,8 @@ proc img.encode.pcx _img, _p_length, _options ;/////////////////////////////////
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
@ -309,25 +307,26 @@ endp
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
proc get_byte
|
||||
proc pcx._.get_byte
|
||||
|
||||
mov dh, byte[esi]
|
||||
inc esi
|
||||
cmp dh, 0xC0
|
||||
jnb .cycle1
|
||||
mov dl, dh
|
||||
mov dh, 1
|
||||
jmp .exit1
|
||||
mov dh, byte[esi]
|
||||
inc esi
|
||||
cmp dh, 0xC0
|
||||
jnb .cycle1
|
||||
mov dl, dh
|
||||
mov dh, 1
|
||||
jmp .exit1
|
||||
.cycle1:
|
||||
and dh, 0x3F
|
||||
mov dl, byte[esi]
|
||||
inc esi
|
||||
and dh, 0x3F
|
||||
mov dl, byte[esi]
|
||||
inc esi
|
||||
.exit1:
|
||||
movzx ecx, dh
|
||||
sub ebx, ecx
|
||||
|
||||
ret
|
||||
movzx ecx, dh
|
||||
sub ebx, ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
@ -335,5 +334,3 @@ endp
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
;
|
@ -1,5 +1,5 @@
|
||||
;;================================================================================================;;
|
||||
;;//// pcx.inc //// (c) dunkaist, 2010 ///////////////////////////////////////////////////////////;;
|
||||
;;//// pcx.inc //// (c) dunkaist, 2010,2012 //////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
@ -17,21 +17,21 @@
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct pcx_header
|
||||
magic_number rb 1
|
||||
version rb 1
|
||||
encoding rb 1
|
||||
bpp rb 1
|
||||
xmin rw 1
|
||||
ymin rw 1
|
||||
xmax rw 1
|
||||
ymax rw 1
|
||||
hres rw 1
|
||||
vres rw 1
|
||||
colormap rb 48
|
||||
reserved rb 1
|
||||
nplanes rb 1
|
||||
bpl rw 1
|
||||
palette_info rw 1
|
||||
filler rb 58
|
||||
ends
|
||||
struct pcx_header
|
||||
magic_number rb 1
|
||||
version rb 1
|
||||
encoding rb 1
|
||||
bpp rb 1
|
||||
xmin rw 1
|
||||
ymin rw 1
|
||||
xmax rw 1
|
||||
ymax rw 1
|
||||
hres rw 1
|
||||
vres rw 1
|
||||
colormap rb 48
|
||||
reserved rb 1
|
||||
nplanes rb 1
|
||||
bpl rw 1
|
||||
palette_info rw 1
|
||||
filler rb 58
|
||||
ends
|
||||
|
54
programs/develop/libraries/libs-dev/libimg/pnm/pbm.asm
Normal file
54
programs/develop/libraries/libs-dev/libimg/pnm/pbm.asm
Normal file
@ -0,0 +1,54 @@
|
||||
.pbm:
|
||||
stdcall img.create, [width], [height], Image.bpp1
|
||||
test eax, eax
|
||||
jz .quit
|
||||
mov [retvalue], eax
|
||||
mov ebx, eax
|
||||
|
||||
mov edi, [ebx+Image.Palette]
|
||||
mov [edi], dword 0x00ffffff
|
||||
mov [edi + 4], dword 0x00000000
|
||||
|
||||
cmp [data_type], PNM_ASCII
|
||||
je .pbm.ascii
|
||||
|
||||
.pbm.raw:
|
||||
mov ecx, [ebx+Image.Width]
|
||||
add ecx, 7
|
||||
shr ecx, 3
|
||||
imul ecx, [ebx+Image.Height]
|
||||
mov edi, [ebx+Image.Data]
|
||||
rep movsb
|
||||
jmp .quit
|
||||
|
||||
.pbm.ascii:
|
||||
mov edi, [ebx+Image.Data]
|
||||
.pbm.next_line:
|
||||
mov edx, [width]
|
||||
mov ecx, 7
|
||||
xor eax, eax
|
||||
.pbm.next_char:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna .pbm.next_char
|
||||
.pbm.get_number:
|
||||
cmp al, '1'
|
||||
sete bl
|
||||
shl bl, cl
|
||||
or ah, bl
|
||||
dec ecx
|
||||
jns @f
|
||||
shr eax, 8
|
||||
stosb
|
||||
mov ecx, 7
|
||||
@@:
|
||||
dec edx
|
||||
jnz .pbm.next_char
|
||||
test byte[width], 0x07
|
||||
jz @f
|
||||
shr eax, 8
|
||||
stosb
|
||||
@@:
|
||||
dec [height]
|
||||
jnz .pbm.next_line
|
||||
jmp .quit
|
72
programs/develop/libraries/libs-dev/libimg/pnm/pgm.asm
Normal file
72
programs/develop/libraries/libs-dev/libimg/pnm/pgm.asm
Normal file
@ -0,0 +1,72 @@
|
||||
.pgm:
|
||||
stdcall img.create, [width], [height], Image.bpp8
|
||||
test eax, eax
|
||||
jz .quit
|
||||
mov [retvalue], eax
|
||||
mov ebx, eax
|
||||
|
||||
mov edi, [ebx+Image.Palette]
|
||||
mov eax, 0xff000000
|
||||
@@:
|
||||
stosd
|
||||
add eax, 0x00010101
|
||||
jnc @b
|
||||
|
||||
mov edi, [ebx+Image.Data]
|
||||
mov ecx, [ebx+Image.Width]
|
||||
imul ecx, [ebx+Image.Height]
|
||||
|
||||
cmp [data_type], PNM_ASCII
|
||||
je .pgm.ascii
|
||||
|
||||
.pgm.raw:
|
||||
cmp [maxval], 0xff
|
||||
jne .pgm.raw.scale
|
||||
rep movsb
|
||||
jmp .quit
|
||||
|
||||
.pgm.raw.scale:
|
||||
mov edx, [maxval]
|
||||
mov eax, 0
|
||||
@@:
|
||||
lodsb
|
||||
mov ebx, eax
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
stosb
|
||||
dec ecx
|
||||
jnz @b
|
||||
jmp .quit
|
||||
|
||||
.pgm.ascii:
|
||||
xor eax, eax
|
||||
cmp [maxval], 0xff
|
||||
jne .pgm.ascii.scale
|
||||
.pgm.ascii.next_char:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna .pgm.ascii.next_char
|
||||
call pnm._.get_number
|
||||
mov eax, ebx
|
||||
stosb
|
||||
dec ecx
|
||||
jnz .pgm.ascii.next_char
|
||||
jmp .quit
|
||||
|
||||
.pgm.ascii.scale:
|
||||
mov edx, [maxval]
|
||||
.pgm.ascii.scale.next_char:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna .pgm.ascii.scale.next_char
|
||||
call pnm._.get_number
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
stosb
|
||||
dec ecx
|
||||
jnz .pgm.ascii.scale.next_char
|
||||
jmp .quit
|
||||
|
230
programs/develop/libraries/libs-dev/libimg/pnm/pnm.asm
Normal file
230
programs/develop/libraries/libs-dev/libimg/pnm/pnm.asm
Normal file
@ -0,0 +1,230 @@
|
||||
;;================================================================================================;;
|
||||
;;//// pnm.asm //// (c) dunkaist, 2012 ///////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||
;; of the License, or (at your option) any later version. ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
|
||||
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||
;; Lesser General Public License for more details. ;;
|
||||
;; ;;
|
||||
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'pnm.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.is.pnm _data, _length ;//////////////////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in pnm format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
xor eax, eax
|
||||
|
||||
mov ecx, [_data]
|
||||
mov cx, word[ecx]
|
||||
xchg cl, ch
|
||||
cmp cx, '1P'
|
||||
jb .is_not_pnm
|
||||
cmp cx, '6P'
|
||||
ja .is_not_pnm
|
||||
|
||||
.is_pnm:
|
||||
inc eax
|
||||
.is_not_pnm:
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.pnm _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in pnm format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
width rd 1
|
||||
height rd 1
|
||||
pnm_type rd 1
|
||||
data_type rd 1 ; raw or ascii
|
||||
maxval rd 1
|
||||
retvalue rd 1
|
||||
endl
|
||||
|
||||
pusha
|
||||
|
||||
mov esi, [_data]
|
||||
lodsw
|
||||
cmp ax, 'P1'
|
||||
jne @f
|
||||
mov [pnm_type], PNM_PBM
|
||||
mov [data_type], PNM_ASCII
|
||||
jmp .parse_header
|
||||
@@:
|
||||
cmp ax, 'P2'
|
||||
jne @f
|
||||
mov [pnm_type], PNM_PGM
|
||||
mov [data_type], PNM_ASCII
|
||||
jmp .parse_header
|
||||
@@:
|
||||
cmp ax, 'P3'
|
||||
jne @f
|
||||
mov [pnm_type], PNM_PPM
|
||||
mov [data_type], PNM_ASCII
|
||||
jmp .parse_header
|
||||
@@:
|
||||
cmp ax, 'P4'
|
||||
jne @f
|
||||
mov [pnm_type], PNM_PBM
|
||||
mov [data_type], PNM_RAW
|
||||
jmp .parse_header
|
||||
@@:
|
||||
cmp ax, 'P5'
|
||||
jne @f
|
||||
mov [pnm_type], PNM_PGM
|
||||
mov [data_type], PNM_RAW
|
||||
jmp .parse_header
|
||||
@@:
|
||||
cmp ax, 'P6'
|
||||
jne @f
|
||||
mov [pnm_type], PNM_PPM
|
||||
mov [data_type], PNM_RAW
|
||||
jmp .parse_header
|
||||
@@:
|
||||
|
||||
.parse_header:
|
||||
xor eax, eax
|
||||
mov [width], eax
|
||||
mov [height], eax
|
||||
mov [maxval], eax
|
||||
|
||||
.next_char:
|
||||
lodsb
|
||||
cmp al, '#'
|
||||
jb .next_char
|
||||
ja .read_number
|
||||
.comment:
|
||||
mov edi, esi
|
||||
mov al, 0x0A
|
||||
mov ecx, edi
|
||||
sub ecx, [_data]
|
||||
neg ecx
|
||||
add ecx, [_length]
|
||||
repne scasb
|
||||
mov esi, edi
|
||||
jmp .next_char
|
||||
|
||||
.read_number:
|
||||
sub eax, 0x30
|
||||
mov ebx, eax
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, '0'
|
||||
jb .number_done
|
||||
sub eax, 0x30
|
||||
imul ebx, 10
|
||||
add ebx, eax
|
||||
jmp @b
|
||||
|
||||
.number_done:
|
||||
cmp [width], 0
|
||||
jne @f
|
||||
mov [width], ebx
|
||||
jmp .next_char
|
||||
@@:
|
||||
cmp [height], 0
|
||||
jne @f
|
||||
mov [height], ebx
|
||||
cmp [pnm_type], PNM_PBM
|
||||
je .header_parsed
|
||||
jmp .next_char
|
||||
@@:
|
||||
mov [maxval], ebx
|
||||
|
||||
.header_parsed:
|
||||
|
||||
mov eax, [pnm_type]
|
||||
cmp eax, PNM_PBM
|
||||
je .pbm
|
||||
cmp eax, PNM_PGM
|
||||
je .pgm
|
||||
cmp eax, PNM_PPM
|
||||
je .ppm
|
||||
jmp .quit
|
||||
|
||||
|
||||
include 'pbm.asm'
|
||||
include 'pgm.asm'
|
||||
include 'ppm.asm'
|
||||
|
||||
.quit:
|
||||
popa
|
||||
mov eax, [retvalue]
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.pnm _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in pnm format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
proc pnm._.get_number
|
||||
sub eax, '0'
|
||||
mov ebx, eax
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, '0'
|
||||
jb .quit
|
||||
sub eax, '0'
|
||||
lea eax, [ebx*8 + eax]
|
||||
lea ebx, [ebx*2 + eax]
|
||||
; imul ebx, 10
|
||||
; add ebx, eax
|
||||
jmp @b
|
||||
.quit:
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
26
programs/develop/libraries/libs-dev/libimg/pnm/pnm.inc
Normal file
26
programs/develop/libraries/libs-dev/libimg/pnm/pnm.inc
Normal file
@ -0,0 +1,26 @@
|
||||
;;================================================================================================;;
|
||||
;;//// pnm.inc //// (c) dunkaist, 2012 ///////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||
;; of the License, or (at your option) any later version. ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
|
||||
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||
;; Lesser General Public License for more details. ;;
|
||||
;; ;;
|
||||
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
PNM_RAW = 0
|
||||
PNM_ASCII = 1
|
||||
|
||||
PNM_PBM = 0
|
||||
PNM_PGM = 1
|
||||
PNM_PPM = 2
|
||||
|
117
programs/develop/libraries/libs-dev/libimg/pnm/ppm.asm
Normal file
117
programs/develop/libraries/libs-dev/libimg/pnm/ppm.asm
Normal file
@ -0,0 +1,117 @@
|
||||
.ppm:
|
||||
stdcall img.create, [width], [height], Image.bpp24
|
||||
test eax, eax
|
||||
jz .quit
|
||||
mov [retvalue], eax
|
||||
mov ebx, eax
|
||||
|
||||
mov edi, [ebx + Image.Data]
|
||||
mov ecx, [ebx + Image.Width]
|
||||
imul ecx, [ebx + Image.Height]
|
||||
|
||||
cmp [data_type], PNM_ASCII
|
||||
je .ppm.ascii
|
||||
|
||||
.ppm.raw:
|
||||
cmp [maxval], 0xff
|
||||
jne .ppm.raw.scale
|
||||
@@:
|
||||
lodsw
|
||||
xchg al, ah
|
||||
movsb
|
||||
stosw
|
||||
dec ecx
|
||||
jnz @b
|
||||
jmp .quit
|
||||
.ppm.raw.scale:
|
||||
mov edx, [maxval]
|
||||
xor eax, eax
|
||||
@@:
|
||||
lodsb
|
||||
mov ebx, eax
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
stosb
|
||||
lodsb
|
||||
mov ebx, eax
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
stosb
|
||||
lodsb
|
||||
mov ebx, eax
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
stosb
|
||||
dec ecx
|
||||
jnz @b
|
||||
jmp .quit
|
||||
|
||||
.ppm.ascii:
|
||||
xor eax, eax
|
||||
cmp [maxval], 0xff
|
||||
jne .ppm.ascii.scale
|
||||
.ppm.ascii.next_char:
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov [edi + 2], bl
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov [edi + 1], bl
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov [edi + 0], bl
|
||||
add edi, 3
|
||||
dec ecx
|
||||
jnz .ppm.ascii.next_char
|
||||
jmp .quit
|
||||
|
||||
.ppm.ascii.scale:
|
||||
mov edx, [maxval]
|
||||
.ppm.ascii.scale.next_char:
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
mov [edi + 2], al
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
mov [edi + 1], al
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
mov [edi + 0], al
|
||||
add edi, 3
|
||||
dec ecx
|
||||
jnz .ppm.ascii.next_char
|
||||
jmp .quit
|
||||
|
430
programs/develop/libraries/libs-dev/libimg/tiff/huffman.asm
Normal file
430
programs/develop/libraries/libs-dev/libimg/tiff/huffman.asm
Normal file
@ -0,0 +1,430 @@
|
||||
tiff._.huffman_tree_white.begin:
|
||||
dd 0x00000000, .0
|
||||
.1 dd 0x00000000, .10
|
||||
.11 dd 0x00000000, .110
|
||||
.111 dd 0x00000000, .1110
|
||||
.1111 dd 0x80000000 + 7
|
||||
.1110 dd 0x80000000 + 6
|
||||
.110 dd 0x00000000, .1100
|
||||
.1101 dd 0x00000000, .11010
|
||||
.11011 dd 0x80000000 + 64
|
||||
.11010 dd 0x00000000, .110100
|
||||
.110101 dd 0x80000000 + 15
|
||||
.110100 dd 0x80000000 + 14
|
||||
.1100 dd 0x80000000 + 5
|
||||
.10 dd 0x00000000, .100
|
||||
.101 dd 0x00000000, .1010
|
||||
.1011 dd 0x80000000 + 4
|
||||
.1010 dd 0x00000000, .10100
|
||||
.10101 dd 0x00000000, .101010
|
||||
.101011 dd 0x80000000 + 17
|
||||
.101010 dd 0x80000000 + 16
|
||||
.10100 dd 0x80000000 + 9
|
||||
.100 dd 0x00000000, .1000
|
||||
.1001 dd 0x00000000, .10010
|
||||
.10011 dd 0x80000000 + 8
|
||||
.10010 dd 0x80000000 + 128
|
||||
.1000 dd 0x80000000 + 3
|
||||
.0 dd 0x00000000, .00
|
||||
.01 dd 0x00000000, .010
|
||||
.011 dd 0x00000000, .0110
|
||||
.0111 dd 0x80000000 + 2
|
||||
.0110 dd 0x00000000, .01100
|
||||
.01101 dd 0x00000000, .011010
|
||||
.011011 dd 0x00000000, .0110110
|
||||
.0110111 dd 0x80000000 + 256
|
||||
.0110110 dd 0x00000000, .01101100
|
||||
.01101101 dd 0x00000000, .011011010
|
||||
.011011011 dd 0x80000000 + 1408
|
||||
.011011010 dd 0x80000000 + 1344
|
||||
.01101100 dd 0x00000000, .011011000
|
||||
.011011001 dd 0x80000000 + 1280
|
||||
.011011000 dd 0x80000000 + 1216
|
||||
.011010 dd 0x00000000, .0110100
|
||||
.0110101 dd 0x00000000, .01101010
|
||||
.01101011 dd 0x00000000, .011010110
|
||||
.011010111 dd 0x80000000 + 1152
|
||||
.011010110 dd 0x80000000 + 1088
|
||||
.01101010 dd 0x00000000, .011010100
|
||||
.011010101 dd 0x80000000 + 1024
|
||||
.011010100 dd 0x80000000 + 960
|
||||
.0110100 dd 0x00000000, .01101000
|
||||
.01101001 dd 0x00000000, .011010010
|
||||
.011010011 dd 0x80000000 + 896
|
||||
.011010010 dd 0x80000000 + 832
|
||||
.01101000 dd 0x80000000 + 576
|
||||
.01100 dd 0x00000000, .011000
|
||||
.011001 dd 0x00000000, .0110010
|
||||
.0110011 dd 0x00000000, .01100110
|
||||
.01100111 dd 0x80000000 + 640
|
||||
.01100110 dd 0x00000000, .011001100
|
||||
.011001101 dd 0x80000000 + 768
|
||||
.011001100 dd 0x80000000 + 704
|
||||
.0110010 dd 0x00000000, .01100100
|
||||
.01100101 dd 0x80000000 + 512
|
||||
.01100100 dd 0x80000000 + 448
|
||||
.011000 dd 0x80000000 + 1664
|
||||
.010 dd 0x00000000, .0100
|
||||
.0101 dd 0x00000000, .01010
|
||||
.01011 dd 0x00000000, .010110
|
||||
.010111 dd 0x80000000 + 192
|
||||
.010110 dd 0x00000000, .0101100
|
||||
.0101101 dd 0x00000000, .01011010
|
||||
.01011011 dd 0x80000000 + 58
|
||||
.01011010 dd 0x80000000 + 57
|
||||
.0101100 dd 0x00000000, .01011000
|
||||
.01011001 dd 0x80000000 + 56
|
||||
.01011000 dd 0x80000000 + 55
|
||||
.01010 dd 0x00000000, .010100
|
||||
.010101 dd 0x00000000, .0101010
|
||||
.0101011 dd 0x80000000 + 25
|
||||
.0101010 dd 0x00000000, .01010100
|
||||
.01010101 dd 0x80000000 + 52
|
||||
.01010100 dd 0x80000000 + 51
|
||||
.010100 dd 0x00000000, .0101000
|
||||
.0101001 dd 0x00000000, .01010010
|
||||
.01010011 dd 0x80000000 + 50
|
||||
.01010010 dd 0x80000000 + 49
|
||||
.0101000 dd 0x80000000 + 24
|
||||
.0100 dd 0x00000000, .01000
|
||||
.01001 dd 0x00000000, .010010
|
||||
.010011 dd 0x00000000, .0100110
|
||||
.0100111 dd 0x80000000 + 18
|
||||
.0100110 dd 0x00000000, .01001100
|
||||
.01001101 dd 0x00000000, .010011010
|
||||
.010011011 dd 0x80000000 + 1728
|
||||
.010011010 dd 0x80000000 + 1600
|
||||
.01001100 dd 0x00000000, .010011000
|
||||
.010011001 dd 0x80000000 + 1536
|
||||
.010011000 dd 0x80000000 + 1472
|
||||
.010010 dd 0x00000000, .0100100
|
||||
.0100101 dd 0x00000000, .01001010
|
||||
.01001011 dd 0x80000000 + 60
|
||||
.01001010 dd 0x80000000 + 59
|
||||
.0100100 dd 0x80000000 + 27
|
||||
.01000 dd 0x80000000 + 11
|
||||
.00 dd 0x00000000, .000
|
||||
.001 dd 0x00000000, .0010
|
||||
.0011 dd 0x00000000, .00110
|
||||
.00111 dd 0x80000000 + 10
|
||||
.00110 dd 0x00000000, .001100
|
||||
.001101 dd 0x00000000, .0011010
|
||||
.0011011 dd 0x00000000, .00110110
|
||||
.00110111 dd 0x80000000 + 384
|
||||
.00110110 dd 0x80000000 + 320
|
||||
.0011010 dd 0x00000000, .00110100
|
||||
.00110101 dd 0x80000000 + 0
|
||||
.00110100 dd 0x80000000 + 63
|
||||
.001100 dd 0x00000000, .0011000
|
||||
.0011001 dd 0x00000000, .00110010
|
||||
.00110011 dd 0x80000000 + 62
|
||||
.00110010 dd 0x80000000 + 61
|
||||
.0011000 dd 0x80000000 + 28
|
||||
.0010 dd 0x00000000, .00100
|
||||
.00101 dd 0x00000000, .001010
|
||||
.001011 dd 0x00000000, .0010110
|
||||
.0010111 dd 0x80000000 + 21
|
||||
.0010110 dd 0x00000000, .00101100
|
||||
.00101101 dd 0x80000000 + 44
|
||||
.00101100 dd 0x80000000 + 43
|
||||
.001010 dd 0x00000000, .0010100
|
||||
.0010101 dd 0x00000000, .00101010
|
||||
.00101011 dd 0x80000000 + 42
|
||||
.00101010 dd 0x80000000 + 41
|
||||
.0010100 dd 0x00000000, .00101000
|
||||
.00101001 dd 0x80000000 + 40
|
||||
.00101000 dd 0x80000000 + 39
|
||||
.00100 dd 0x00000000, .001000
|
||||
.001001 dd 0x00000000, .0010010
|
||||
.0010011 dd 0x80000000 + 26
|
||||
.0010010 dd 0x00000000, .00100100
|
||||
.00100101 dd 0x80000000 + 54
|
||||
.00100100 dd 0x80000000 + 53
|
||||
.001000 dd 0x80000000 + 12
|
||||
.000 dd 0x00000000, .0000
|
||||
.0001 dd 0x00000000, .00010
|
||||
.00011 dd 0x00000000, .000110
|
||||
.000111 dd 0x80000000 + 1
|
||||
.000110 dd 0x00000000, .0001100
|
||||
.0001101 dd 0x00000000, .00011010
|
||||
.00011011 dd 0x80000000 + 32
|
||||
.00011010 dd 0x80000000 + 31
|
||||
.0001100 dd 0x80000000 + 19
|
||||
.00010 dd 0x00000000, .000100
|
||||
.000101 dd 0x00000000, .0001010
|
||||
.0001011 dd 0x00000000, .00010110
|
||||
.00010111 dd 0x80000000 + 38
|
||||
.00010110 dd 0x80000000 + 37
|
||||
.0001010 dd 0x00000000, .00010100
|
||||
.00010101 dd 0x80000000 + 36
|
||||
.00010100 dd 0x80000000 + 35
|
||||
.000100 dd 0x00000000, .0001000
|
||||
.0001001 dd 0x00000000, .00010010
|
||||
.00010011 dd 0x80000000 + 34
|
||||
.00010010 dd 0x80000000 + 33
|
||||
.0001000 dd 0x80000000 + 20
|
||||
.0000 dd 0x00000000, .00000
|
||||
.00001 dd 0x00000000, .000010
|
||||
.000011 dd 0x80000000 + 13
|
||||
.000010 dd 0x00000000, .0000100
|
||||
.0000101 dd 0x00000000, .00001010
|
||||
.00001011 dd 0x80000000 + 48
|
||||
.00001010 dd 0x80000000 + 47
|
||||
.0000100 dd 0x80000000 + 23
|
||||
.00000 dd 0x00000000, .000000
|
||||
.000001 dd 0x00000000, .0000010
|
||||
.0000011 dd 0x80000000 + 22
|
||||
.0000010 dd 0x00000000, .00000100
|
||||
.00000101 dd 0x80000000 + 46
|
||||
.00000100 dd 0x80000000 + 45
|
||||
.000000 dd 0x00000000, .0000000
|
||||
.0000001 dd 0x00000000, .00000010
|
||||
.00000011 dd 0x80000000 + 30
|
||||
.00000010 dd 0x80000000 + 29
|
||||
.0000000 dd 0x00000000, .00000000
|
||||
.00000001 dd 0x00000000, .000000010
|
||||
.000000011 dd 0x00000000, .0000000110
|
||||
.0000000111 dd 0x00000000, .00000001110
|
||||
.00000001111 dd 0x00000000, .000000011110
|
||||
.000000011111 dd 0x80000000 + 2560
|
||||
.000000011110 dd 0x80000000 + 2496
|
||||
.00000001110 dd 0x00000000, .000000011100
|
||||
.000000011101 dd 0x80000000 + 2432
|
||||
.000000011100 dd 0x80000000 + 2368
|
||||
.0000000110 dd 0x00000000, .00000001100
|
||||
.00000001101 dd 0x80000000 + 1920
|
||||
.00000001100 dd 0x80000000 + 1856
|
||||
.000000010 dd 0x00000000, .0000000100
|
||||
.0000000101 dd 0x00000000, .00000001010
|
||||
.00000001011 dd 0x00000000, .000000010110
|
||||
.000000010111 dd 0x80000000 + 2304
|
||||
.000000010110 dd 0x80000000 + 2240
|
||||
.00000001010 dd 0x00000000, .000000010100
|
||||
.000000010101 dd 0x80000000 + 2176
|
||||
.000000010100 dd 0x80000000 + 2112
|
||||
.0000000100 dd 0x00000000, .00000001000
|
||||
.00000001001 dd 0x00000000, .000000010010
|
||||
.000000010011 dd 0x80000000 + 2048
|
||||
.000000010010 dd 0x80000000 + 1984
|
||||
.00000001000 dd 0x80000000 + 1792
|
||||
.00000000 dd 0x00000010, .000000000
|
||||
.000000000 dd 0x00000010, .0000000000
|
||||
.0000000000 dd 0x00000010, .00000000000
|
||||
.00000000000 dd 0x00000011, .000000000001
|
||||
.000000000001 dd 0x80000000 + 0xffff
|
||||
tiff._.huffman_tree_white.end:
|
||||
|
||||
tiff._.huffman_tree_black.begin:
|
||||
dd 0x00000000, .0
|
||||
.1 dd 0x00000000, .10
|
||||
.11 dd 0x80000000 + 2
|
||||
.10 dd 0x80000000 + 3
|
||||
.0 dd 0x00000000, .00
|
||||
.01 dd 0x00000000, .010
|
||||
.011 dd 0x80000000 + 4
|
||||
.010 dd 0x80000000 + 1
|
||||
.00 dd 0x00000000, .000
|
||||
.001 dd 0x00000000, .0010
|
||||
.0011 dd 0x80000000 + 5
|
||||
.0010 dd 0x80000000 + 6
|
||||
.000 dd 0x00000000, .0000
|
||||
.0001 dd 0x00000000, .00010
|
||||
.00011 dd 0x80000000 + 7
|
||||
.00010 dd 0x00000000, .000100
|
||||
.000101 dd 0x80000000 + 8
|
||||
.000100 dd 0x80000000 + 9
|
||||
.0000 dd 0x00000000, .00000
|
||||
.00001 dd 0x00000000, .000010
|
||||
.000011 dd 0x00000000, .0000110
|
||||
.0000111 dd 0x80000000 + 12
|
||||
.0000110 dd 0x00000000, .00001100
|
||||
.00001101 dd 0x00000000, .000011010
|
||||
.000011011 dd 0x00000000, .0000110110
|
||||
.0000110111 dd 0x80000000 + 0
|
||||
.0000110110 dd 0x00000000, .00001101100
|
||||
.00001101101 dd 0x00000000, .000011011010
|
||||
.000011011011 dd 0x80000000 + 43
|
||||
.000011011010 dd 0x80000000 + 42
|
||||
.00001101100 dd 0x80000000 + 21
|
||||
.000011010 dd 0x00000000, .0000110100
|
||||
.0000110101 dd 0x00000000, .00001101010
|
||||
.00001101011 dd 0x00000000, .000011010110
|
||||
.000011010111 dd 0x80000000 + 39
|
||||
.000011010110 dd 0x80000000 + 38
|
||||
.00001101010 dd 0x00000000, .000011010100
|
||||
.000011010101 dd 0x80000000 + 37
|
||||
.000011010100 dd 0x80000000 + 36
|
||||
.0000110100 dd 0x00000000, .00001101000
|
||||
.00001101001 dd 0x00000000, .000011010010
|
||||
.000011010011 dd 0x80000000 + 35
|
||||
.000011010010 dd 0x80000000 + 34
|
||||
.00001101000 dd 0x80000000 + 20
|
||||
.00001100 dd 0x00000000, .000011000
|
||||
.000011001 dd 0x00000000, .0000110010
|
||||
.0000110011 dd 0x00000000, .00001100110
|
||||
.00001100111 dd 0x80000000 + 19
|
||||
.00001100110 dd 0x00000000, .000011001100
|
||||
.000011001101 dd 0x80000000 + 29
|
||||
.000011001100 dd 0x80000000 + 28
|
||||
.0000110010 dd 0x00000000, .00001100100
|
||||
.00001100101 dd 0x00000000, .000011001010
|
||||
.000011001011 dd 0x80000000 + 27
|
||||
.000011001010 dd 0x80000000 + 26
|
||||
.00001100100 dd 0x00000000, .000011001000
|
||||
.000011001001 dd 0x80000000 + 192
|
||||
.000011001000 dd 0x80000000 + 128
|
||||
.000011000 dd 0x80000000 + 15
|
||||
.000010 dd 0x00000000, .0000100
|
||||
.0000101 dd 0x80000000 + 11
|
||||
.0000100 dd 0x80000000 + 10
|
||||
.00000 dd 0x00000000, .000000
|
||||
.000001 dd 0x00000000, .0000010
|
||||
.0000011 dd 0x00000000, .00000110
|
||||
.00000111 dd 0x80000000 + 14
|
||||
.00000110 dd 0x00000000, .000001100
|
||||
.000001101 dd 0x00000000, .0000011010
|
||||
.0000011011 dd 0x00000000, .00000110110
|
||||
.00000110111 dd 0x80000000 + 22
|
||||
.00000110110 dd 0x00000000, .000001101100
|
||||
.000001101101 dd 0x80000000 + 41
|
||||
.000001101100 dd 0x80000000 + 40
|
||||
.0000011010 dd 0x00000000, .00000110100
|
||||
.00000110101 dd 0x00000000, .000001101010
|
||||
.000001101011 dd 0x80000000 + 33
|
||||
.000001101010 dd 0x80000000 + 32
|
||||
.00000110100 dd 0x00000000, .000001101000
|
||||
.000001101001 dd 0x80000000 + 31
|
||||
.000001101000 dd 0x80000000 + 30
|
||||
.000001100 dd 0x00000000, .0000011000
|
||||
.0000011001 dd 0x00000000, .00000110010
|
||||
.00000110011 dd 0x00000000, .000001100110
|
||||
.000001100111 dd 0x80000000 + 63
|
||||
.000001100110 dd 0x80000000 + 62
|
||||
.00000110010 dd 0x00000000, .000001100100
|
||||
.000001100101 dd 0x80000000 + 49
|
||||
.000001100100 dd 0x80000000 + 48
|
||||
.0000011000 dd 0x80000000 + 17
|
||||
.0000010 dd 0x00000000, .00000100
|
||||
.00000101 dd 0x00000000, .000001010
|
||||
.000001011 dd 0x00000000, .0000010110
|
||||
.0000010111 dd 0x80000000 + 16
|
||||
.0000010110 dd 0x00000000, .00000101100
|
||||
.00000101101 dd 0x00000000, .000001011010
|
||||
.000001011011 dd 0x80000000 + 256
|
||||
.000001011010 dd 0x80000000 + 61
|
||||
.00000101100 dd 0x00000000, .000001011000
|
||||
.000001011001 dd 0x80000000 + 58
|
||||
.000001011000 dd 0x80000000 + 57
|
||||
.000001010 dd 0x00000000, .0000010100
|
||||
.0000010101 dd 0x00000000, .00000101010
|
||||
.00000101011 dd 0x00000000, .000001010110
|
||||
.000001010111 dd 0x80000000 + 47
|
||||
.000001010110 dd 0x80000000 + 46
|
||||
.00000101010 dd 0x00000000, .000001010100
|
||||
.000001010101 dd 0x80000000 + 45
|
||||
.000001010100 dd 0x80000000 + 44
|
||||
.0000010100 dd 0x00000000, .00000101000
|
||||
.00000101001 dd 0x00000000, .000001010010
|
||||
.000001010011 dd 0x80000000 + 51
|
||||
.000001010010 dd 0x80000000 + 50
|
||||
.00000101000 dd 0x80000000 + 23
|
||||
.00000100 dd 0x80000000 + 13
|
||||
.000000 dd 0x00000000, .0000000
|
||||
.0000001 dd 0x00000000, .00000010
|
||||
.00000011 dd 0x00000000, .000000110
|
||||
.000000111 dd 0x00000000, .0000001110
|
||||
.0000001111 dd 0x80000000 + 64
|
||||
.0000001110 dd 0x00000000, .00000011100
|
||||
.00000011101 dd 0x00000000, .000000111010
|
||||
.000000111011 dd 0x00000000, .0000001110110
|
||||
.0000001110111 dd 0x80000000 + 1216
|
||||
.0000001110110 dd 0x80000000 + 1152
|
||||
.000000111010 dd 0x00000000, .0000001110100
|
||||
.0000001110101 dd 0x80000000 + 1088
|
||||
.0000001110100 dd 0x80000000 + 1024
|
||||
.00000011100 dd 0x00000000, .000000111000
|
||||
.000000111001 dd 0x00000000, .0000001110010
|
||||
.0000001110011 dd 0x80000000 + 960
|
||||
.0000001110010 dd 0x80000000 + 896
|
||||
.000000111000 dd 0x80000000 + 54
|
||||
.000000110 dd 0x00000000, .0000001100
|
||||
.0000001101 dd 0x00000000, .00000011010
|
||||
.00000011011 dd 0x00000000, .000000110110
|
||||
.000000110111 dd 0x80000000 + 53
|
||||
.000000110110 dd 0x00000000, .0000001101100
|
||||
.0000001101101 dd 0x80000000 + 576
|
||||
.0000001101100 dd 0x80000000 + 512
|
||||
.00000011010 dd 0x00000000, .000000110100
|
||||
.000000110101 dd 0x80000000 + 448
|
||||
.000000110100 dd 0x80000000 + 384
|
||||
.0000001100 dd 0x00000000, .00000011000
|
||||
.00000011001 dd 0x00000000, .000000110010
|
||||
.000000110011 dd 0x80000000 + 320
|
||||
.000000110010 dd 0x00000000, .0000001100100
|
||||
.0000001100101 dd 0x80000000 + 1728
|
||||
.0000001100100 dd 0x80000000 + 1664
|
||||
.00000011000 dd 0x80000000 + 25
|
||||
.00000010 dd 0x00000000, .000000100
|
||||
.000000101 dd 0x00000000, .0000001010
|
||||
.0000001011 dd 0x00000000, .00000010110
|
||||
.00000010111 dd 0x80000000 + 24
|
||||
.00000010110 dd 0x00000000, .000000101100
|
||||
.000000101101 dd 0x00000000, .0000001011010
|
||||
.0000001011011 dd 0x80000000 + 1600
|
||||
.0000001011010 dd 0x80000000 + 1536
|
||||
.000000101100 dd 0x80000000 + 60
|
||||
.0000001010 dd 0x00000000, .00000010100
|
||||
.00000010101 dd 0x00000000, .000000101010
|
||||
.000000101011 dd 0x80000000 + 59
|
||||
.000000101010 dd 0x00000000, .0000001010100
|
||||
.0000001010101 dd 0x80000000 + 1472
|
||||
.0000001010100 dd 0x80000000 + 1408
|
||||
.00000010100 dd 0x00000000, .000000101000
|
||||
.000000101001 dd 0x00000000, .0000001010010
|
||||
.0000001010011 dd 0x80000000 + 1344
|
||||
.0000001010010 dd 0x80000000 + 1280
|
||||
.000000101000 dd 0x80000000 + 56
|
||||
.000000100 dd 0x00000000, .0000001000
|
||||
.0000001001 dd 0x00000000, .00000010010
|
||||
.00000010011 dd 0x00000000, .000000100110
|
||||
.000000100111 dd 0x80000000 + 55
|
||||
.000000100110 dd 0x00000000, .0000001001100
|
||||
.0000001001101 dd 0x80000000 + 832
|
||||
.0000001001100 dd 0x80000000 + 768
|
||||
.00000010010 dd 0x00000000, .000000100100
|
||||
.000000100101 dd 0x00000000, .0000001001010
|
||||
.0000001001011 dd 0x80000000 + 704
|
||||
.0000001001010 dd 0x80000000 + 640
|
||||
.000000100100 dd 0x80000000 + 52
|
||||
.0000001000 dd 0x80000000 + 18
|
||||
.0000000 dd 0x00000000, .00000000
|
||||
.00000001 dd 0x00000000, .000000010
|
||||
.000000011 dd 0x00000000, .0000000110
|
||||
.0000000111 dd 0x00000000, .00000001110
|
||||
.00000001111 dd 0x00000000, .000000011110
|
||||
.000000011111 dd 0x80000000 + 2560
|
||||
.000000011110 dd 0x80000000 + 2496
|
||||
.00000001110 dd 0x00000000, .000000011100
|
||||
.000000011101 dd 0x80000000 + 2432
|
||||
.000000011100 dd 0x80000000 + 2368
|
||||
.0000000110 dd 0x00000000, .00000001100
|
||||
.00000001101 dd 0x80000000 + 1920
|
||||
.00000001100 dd 0x80000000 + 1856
|
||||
.000000010 dd 0x00000000, .0000000100
|
||||
.0000000101 dd 0x00000000, .00000001010
|
||||
.00000001011 dd 0x00000000, .000000010110
|
||||
.000000010111 dd 0x80000000 + 2304
|
||||
.000000010110 dd 0x80000000 + 2240
|
||||
.00000001010 dd 0x00000000, .000000010100
|
||||
.000000010101 dd 0x80000000 + 2176
|
||||
.000000010100 dd 0x80000000 + 2112
|
||||
.0000000100 dd 0x00000000, .00000001000
|
||||
.00000001001 dd 0x00000000, .000000010010
|
||||
.000000010011 dd 0x80000000 + 2048
|
||||
.000000010010 dd 0x80000000 + 1984
|
||||
.00000001000 dd 0x80000000 + 1792
|
||||
.00000000 dd 0x00000010, .000000000
|
||||
.000000000 dd 0x00000010, .0000000000
|
||||
.0000000000 dd 0x00000010, .00000000000
|
||||
.00000000000 dd 0x80000000 + 0xffff
|
||||
tiff._.huffman_tree_black.end:
|
853
programs/develop/libraries/libs-dev/libimg/tiff/tiff.asm
Normal file
853
programs/develop/libraries/libs-dev/libimg/tiff/tiff.asm
Normal file
@ -0,0 +1,853 @@
|
||||
;;================================================================================================;;
|
||||
;;//// tiff.asm //// (c) dunkaist, 2011-2012 /////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||
;; of the License, or (at your option) any later version. ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
|
||||
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||
;; Lesser General Public License for more details. ;;
|
||||
;; ;;
|
||||
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'tiff.inc'
|
||||
;include '../../../../../system/board/trunk/debug.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.is.tiff _data, _length ;/////////////////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in tiff format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
push esi
|
||||
|
||||
mov esi, [_data]
|
||||
lodsw
|
||||
cmp ax, word 'II'
|
||||
je .little_endian
|
||||
cmp ax, word 'MM'
|
||||
je .big_endian
|
||||
jmp .is_not_tiff
|
||||
|
||||
.little_endian:
|
||||
lodsw
|
||||
cmp ax, 0x002A
|
||||
je .is_tiff
|
||||
jmp .is_not_tiff
|
||||
|
||||
.big_endian:
|
||||
lodsw
|
||||
cmp ax, 0x2A00
|
||||
je .is_tiff
|
||||
|
||||
.is_not_tiff:
|
||||
pop esi
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.is_tiff:
|
||||
pop esi
|
||||
xor eax, eax
|
||||
inc eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.tiff _data, _length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in tiff format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
_endianness rd 1 ; 0 stands for LE, otherwise BE
|
||||
retvalue rd 1 ; 0 (error) or pointer to image
|
||||
endl
|
||||
|
||||
push ebx edx esi edi
|
||||
|
||||
mov esi, [_data]
|
||||
lodsw
|
||||
mov [_endianness], 0
|
||||
cmp ax, word 'II'
|
||||
seta byte[_endianness]
|
||||
|
||||
lodsw_
|
||||
lodsd_
|
||||
@@:
|
||||
stdcall tiff._.parse_IFD, [_data], eax, [_endianness]
|
||||
mov ebx, eax
|
||||
mov [retvalue], eax
|
||||
lodsd_
|
||||
test eax, eax
|
||||
; jnz @b
|
||||
|
||||
|
||||
.quit:
|
||||
mov eax, [retvalue]
|
||||
pop edi esi edx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.tiff _img, _p_length, _options ;//////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in tiff format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
proc tiff._.parse_IFD _data, _IFD, _endianness
|
||||
locals
|
||||
extended rd 1
|
||||
retvalue rd 1
|
||||
decompress rd 1
|
||||
endl
|
||||
push ebx edx edi
|
||||
mov [retvalue], 0
|
||||
|
||||
invoke mem.alloc, sizeof.tiff_extra
|
||||
test eax, eax
|
||||
jz .quit
|
||||
mov [extended], eax
|
||||
mov ebx, eax
|
||||
mov edi, eax
|
||||
mov ecx, sizeof.tiff_extra/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
|
||||
mov esi, [_IFD]
|
||||
add esi, [_data]
|
||||
lodsw_
|
||||
movzx ecx, ax
|
||||
@@:
|
||||
push ecx
|
||||
stdcall tiff._.parse_IFDE, [_data], [_endianness]
|
||||
pop ecx
|
||||
dec ecx
|
||||
jnz @b
|
||||
|
||||
call tiff._.define_image_type
|
||||
|
||||
stdcall img.create, [ebx + tiff_extra.image_width], [ebx + tiff_extra.image_height], eax
|
||||
test eax, eax
|
||||
jz .quit
|
||||
mov [retvalue], eax
|
||||
mov edx, eax
|
||||
mov [edx + Image.Extended], ebx
|
||||
|
||||
cmp [ebx+tiff_extra.compression], TIFF.COMPRESSION.UNCOMPRESSED
|
||||
jne @f
|
||||
mov [decompress], tiff._.decompress.uncompressed
|
||||
jmp .decompressor_defined
|
||||
@@:
|
||||
cmp [ebx + tiff_extra.compression], TIFF.COMPRESSION.PACKBITS
|
||||
jne @f
|
||||
mov [decompress], tiff._.decompress.packbits
|
||||
jmp .decompressor_defined
|
||||
@@:
|
||||
mov [decompress], tiff._.decompress.ccitt1d
|
||||
jmp .decompressor_defined
|
||||
jmp .quit
|
||||
.decompressor_defined:
|
||||
|
||||
push esi ; fixme!!
|
||||
|
||||
mov ecx, [edx + Image.Type]
|
||||
dec ecx
|
||||
jz .bpp8
|
||||
dec ecx
|
||||
jz .bpp24
|
||||
dec ecx
|
||||
jz .bpp32
|
||||
dec ecx
|
||||
dec ecx ; tiff doesn't handle 15bpp images
|
||||
jz .bpp16
|
||||
dec ecx
|
||||
jz .bpp1
|
||||
dec ecx
|
||||
jz .bpp4
|
||||
;error report!!
|
||||
|
||||
.bpp1:
|
||||
.bpp1.palette:
|
||||
mov edi, [edx+Image.Palette]
|
||||
cmp [ebx + tiff_extra.photometric], TIFF.PHOTOMETRIC.BLACK_IS_ZERO
|
||||
jne .bpp1.white_is_zero
|
||||
.bpp1.black_is_zero:
|
||||
mov [edi], dword 0x00000000
|
||||
mov [edi + 4], dword 0x00ffffff
|
||||
jmp .common
|
||||
.bpp1.white_is_zero:
|
||||
mov [edi], dword 0x00ffffff
|
||||
mov [edi + 4], dword 0x00000000
|
||||
jmp .common
|
||||
|
||||
.bpp4:
|
||||
jmp .common
|
||||
|
||||
.bpp8:
|
||||
cmp [ebx + tiff_extra.palette], 0
|
||||
je .bpp8.grayscale
|
||||
|
||||
mov esi, [ebx + tiff_extra.palette]
|
||||
mov ah, 2
|
||||
.bpp8.channel:
|
||||
mov edi, eax
|
||||
and edi, 0x0000ff00
|
||||
shr edi, 8
|
||||
add edi, [edx + Image.Palette]
|
||||
mov ecx, 256
|
||||
@@:
|
||||
lodsb
|
||||
stosb
|
||||
lodsb
|
||||
add edi, 3
|
||||
dec ecx
|
||||
jnz @b
|
||||
dec ah
|
||||
jns .bpp8.channel
|
||||
jmp .common
|
||||
.bpp8.grayscale:
|
||||
mov edi, [edx + Image.Palette]
|
||||
mov eax, 0xff000000
|
||||
@@:
|
||||
stosd
|
||||
add eax, 0x00010101
|
||||
jnc @b
|
||||
jmp .common
|
||||
|
||||
.bpp16:
|
||||
jmp .common
|
||||
|
||||
.bpp24:
|
||||
jmp .common
|
||||
|
||||
.bpp32:
|
||||
jmp .common
|
||||
|
||||
|
||||
.common:
|
||||
mov edi, [edx+Image.Data]
|
||||
mov esi, [ebx+tiff_extra.strip_offsets]
|
||||
mov edx, [ebx+tiff_extra.strip_byte_counts]
|
||||
|
||||
|
||||
cmp [ebx + tiff_extra.strip_offsets_length], TIFF.IFDE_TYPE_LENGTH.SHORT
|
||||
jne .l_x
|
||||
cmp [ebx + tiff_extra.strip_byte_counts_length], TIFF.IFDE_TYPE_LENGTH.SHORT
|
||||
jne .s_l
|
||||
jmp .s_s
|
||||
.l_x: cmp [ebx + tiff_extra.strip_byte_counts_length], TIFF.IFDE_TYPE_LENGTH.SHORT
|
||||
jne .l_l
|
||||
jmp .l_s
|
||||
|
||||
.s_s:
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
push esi
|
||||
mov esi, eax
|
||||
add esi, [_data]
|
||||
xor ecx, ecx
|
||||
mov cx, word[edx]
|
||||
test [_endianness], 1
|
||||
jz @f
|
||||
xchg cl, ch
|
||||
@@:
|
||||
add edx, 2
|
||||
stdcall [decompress], [retvalue]
|
||||
pop esi
|
||||
dec [ebx + tiff_extra.offsets_number]
|
||||
jnz .s_s
|
||||
jmp .decoded
|
||||
|
||||
.s_l:
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
push esi
|
||||
mov esi, eax
|
||||
add esi, [_data]
|
||||
mov ecx, [edx]
|
||||
test [_endianness], 1
|
||||
jz @f
|
||||
bswap ecx
|
||||
@@:
|
||||
add edx, 4
|
||||
stdcall [decompress], [retvalue]
|
||||
pop esi
|
||||
dec [ebx + tiff_extra.offsets_number]
|
||||
jnz .s_l
|
||||
jmp .decoded
|
||||
|
||||
.l_s:
|
||||
lodsd_
|
||||
push esi
|
||||
mov esi, eax
|
||||
add esi, [_data]
|
||||
xor ecx, ecx
|
||||
mov cx, word[edx]
|
||||
test [_endianness], 1
|
||||
jz @f
|
||||
xchg cl, ch
|
||||
@@:
|
||||
add edx, 2
|
||||
stdcall [decompress], [retvalue]
|
||||
pop esi
|
||||
dec [ebx + tiff_extra.offsets_number]
|
||||
jnz .l_s
|
||||
jmp .decoded
|
||||
|
||||
.l_l:
|
||||
lodsd_
|
||||
push esi
|
||||
mov esi, eax
|
||||
add esi, [_data]
|
||||
mov ecx, [edx]
|
||||
test [_endianness], 1
|
||||
jz @f
|
||||
bswap ecx
|
||||
@@:
|
||||
add edx, 4
|
||||
stdcall [decompress], [retvalue]
|
||||
pop esi
|
||||
dec [ebx + tiff_extra.offsets_number]
|
||||
jnz .l_l
|
||||
jmp .decoded
|
||||
|
||||
|
||||
.decoded:
|
||||
cmp [ebx + tiff_extra.samples_per_pixel], 3
|
||||
jne .pop_quit
|
||||
mov eax, [retvalue]
|
||||
mov esi, [eax + Image.Data]
|
||||
mov edi, [eax + Image.Data]
|
||||
mov ecx, [eax + Image.Width]
|
||||
imul ecx, [eax + Image.Height]
|
||||
@@:
|
||||
lodsw
|
||||
movsb
|
||||
mov byte[esi - 1], al
|
||||
add edi, 2
|
||||
dec ecx
|
||||
jnz @b
|
||||
|
||||
|
||||
.pop_quit:
|
||||
pop esi
|
||||
.quit:
|
||||
pop edi edx ebx
|
||||
mov eax, [retvalue]
|
||||
ret
|
||||
endp
|
||||
|
||||
proc tiff._.parse_IFDE _data, _endianness
|
||||
|
||||
push ebx edx edi
|
||||
|
||||
lodsw_
|
||||
mov edx, tiff.IFDE_tag_table.begin
|
||||
mov ecx, (tiff.IFDE_tag_table.end-tiff.IFDE_tag_table.begin)/8
|
||||
.tag:
|
||||
cmp ax, word[edx]
|
||||
jne @f
|
||||
lodsw_
|
||||
jmp dword[edx + 4]
|
||||
@@:
|
||||
add edx, 8
|
||||
dec ecx
|
||||
jnz .tag
|
||||
.tag_default: ; unknown/unsupported/uninteresting/unimportant
|
||||
lodsw
|
||||
lodsd
|
||||
lodsd
|
||||
jmp .quit ; just skip it
|
||||
|
||||
.tag_100:
|
||||
cmp ax, TIFF.IFDE_TYPE.SHORT
|
||||
jne @f
|
||||
lodsd
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
mov [ebx + tiff_extra.image_width], eax
|
||||
lodsw
|
||||
jmp .quit
|
||||
@@:
|
||||
cmp ax, TIFF.IFDE_TYPE.LONG
|
||||
jne @f
|
||||
lodsd
|
||||
lodsd_
|
||||
mov [ebx + tiff_extra.image_width], eax
|
||||
jmp .quit
|
||||
@@:
|
||||
jmp .quit
|
||||
|
||||
.tag_101:
|
||||
cmp ax, TIFF.IFDE_TYPE.SHORT
|
||||
jne @f
|
||||
lodsd
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
mov [ebx + tiff_extra.image_height], eax
|
||||
lodsw
|
||||
jmp .quit
|
||||
@@:
|
||||
cmp ax, TIFF.IFDE_TYPE.LONG
|
||||
jne @f
|
||||
lodsd
|
||||
lodsd_
|
||||
mov [ebx + tiff_extra.image_height], eax
|
||||
jmp .quit
|
||||
@@:
|
||||
jmp .quit
|
||||
|
||||
.tag_102:
|
||||
lodsd_
|
||||
imul eax, TIFF.IFDE_TYPE_LENGTH.SHORT
|
||||
cmp eax, 4
|
||||
ja @f
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
mov [ebx + tiff_extra.bits_per_sample], eax
|
||||
lodsw
|
||||
jmp .quit
|
||||
@@:
|
||||
lodsd_
|
||||
add eax, [_data]
|
||||
push esi
|
||||
mov esi, eax
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
pop esi
|
||||
mov [ebx + tiff_extra.bits_per_sample], eax
|
||||
jmp .quit
|
||||
|
||||
.tag_103:
|
||||
cmp ax, TIFF.IFDE_TYPE.SHORT
|
||||
jne @f
|
||||
lodsd
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
mov [ebx + tiff_extra.compression], eax
|
||||
lodsw
|
||||
jmp .quit
|
||||
@@:
|
||||
jmp .quit
|
||||
|
||||
.tag_106:
|
||||
cmp ax, TIFF.IFDE_TYPE.SHORT
|
||||
jne @f
|
||||
lodsd
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
mov [ebx + tiff_extra.photometric], eax
|
||||
lodsw
|
||||
jmp .quit
|
||||
@@:
|
||||
|
||||
jmp .quit
|
||||
|
||||
.tag_111:
|
||||
cmp ax, TIFF.IFDE_TYPE.SHORT
|
||||
jne @f
|
||||
mov [ebx + tiff_extra.strip_offsets_length], TIFF.IFDE_TYPE_LENGTH.SHORT
|
||||
jmp .tag_111.common
|
||||
@@:
|
||||
mov [ebx + tiff_extra.strip_offsets_length], TIFF.IFDE_TYPE_LENGTH.LONG
|
||||
.tag_111.common:
|
||||
lodsd_
|
||||
mov [ebx + tiff_extra.offsets_number], eax
|
||||
imul eax, [ebx+tiff_extra.strip_offsets_length]
|
||||
cmp eax, 4
|
||||
ja @f
|
||||
mov [ebx + tiff_extra.strip_offsets], esi
|
||||
lodsd
|
||||
jmp .quit
|
||||
@@:
|
||||
lodsd_
|
||||
add eax, [_data]
|
||||
mov [ebx + tiff_extra.strip_offsets], eax
|
||||
jmp .quit
|
||||
|
||||
.tag_115:
|
||||
lodsd_
|
||||
imul eax, TIFF.IFDE_TYPE_LENGTH.SHORT
|
||||
cmp eax, 4
|
||||
ja @f
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
mov [ebx + tiff_extra.samples_per_pixel], eax
|
||||
lodsw
|
||||
jmp .quit
|
||||
@@:
|
||||
lodsd_
|
||||
add eax, [_data]
|
||||
movzx eax, word[eax]
|
||||
jmp .quit
|
||||
|
||||
.tag_116:
|
||||
cmp ax, TIFF.IFDE_TYPE.SHORT
|
||||
jne @f
|
||||
lodsd
|
||||
xor eax, eax
|
||||
lodsw_
|
||||
mov [ebx + tiff_extra.rows_per_strip], eax
|
||||
lodsw
|
||||
jmp .quit
|
||||
@@:
|
||||
lodsd
|
||||
lodsd_
|
||||
mov [ebx + tiff_extra.rows_per_strip], eax
|
||||
jmp .quit
|
||||
|
||||
.tag_117:
|
||||
cmp ax, TIFF.IFDE_TYPE.SHORT
|
||||
jne @f
|
||||
mov [ebx + tiff_extra.strip_byte_counts_length], TIFF.IFDE_TYPE_LENGTH.SHORT
|
||||
jmp .tag_117.common
|
||||
@@:
|
||||
mov [ebx + tiff_extra.strip_byte_counts_length], TIFF.IFDE_TYPE_LENGTH.LONG
|
||||
.tag_117.common:
|
||||
lodsd_
|
||||
imul eax, [ebx + tiff_extra.strip_byte_counts_length]
|
||||
cmp eax, 4
|
||||
ja @f
|
||||
mov [ebx + tiff_extra.strip_byte_counts], esi
|
||||
lodsd
|
||||
jmp .quit
|
||||
@@:
|
||||
lodsd_
|
||||
add eax, [_data]
|
||||
mov [ebx + tiff_extra.strip_byte_counts], eax
|
||||
jmp .quit
|
||||
|
||||
.tag_140:
|
||||
lodsd
|
||||
lodsd_
|
||||
add eax, [_data]
|
||||
mov [ebx + tiff_extra.palette], eax
|
||||
jmp .quit
|
||||
|
||||
.quit:
|
||||
pop edi edx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc tiff._.define_image_type
|
||||
|
||||
xor eax, eax
|
||||
|
||||
cmp [ebx + tiff_extra.bits_per_sample], 1
|
||||
jg .not_bilevel
|
||||
mov eax, Image.bpp1
|
||||
jmp .quit
|
||||
.not_bilevel:
|
||||
cmp [ebx + tiff_extra.palette], 0
|
||||
je .without_palette
|
||||
cmp [ebx + tiff_extra.bits_per_sample], 4
|
||||
jne @f
|
||||
mov eax, Image.bpp4
|
||||
jmp .quit
|
||||
@@:
|
||||
cmp [ebx + tiff_extra.bits_per_sample], 8
|
||||
jne @f
|
||||
mov eax, Image.bpp8
|
||||
jmp .quit
|
||||
@@:
|
||||
jmp .quit
|
||||
.without_palette:
|
||||
cmp [ebx + tiff_extra.samples_per_pixel], 1
|
||||
jg .not_grayscale
|
||||
cmp [ebx + tiff_extra.bits_per_sample], 4
|
||||
jne @f
|
||||
mov eax, Image.bpp4
|
||||
jmp .quit
|
||||
@@:
|
||||
cmp [ebx + tiff_extra.bits_per_sample], 8
|
||||
jne @f
|
||||
mov eax, Image.bpp8
|
||||
jmp .quit
|
||||
.not_grayscale:
|
||||
cmp [ebx + tiff_extra.samples_per_pixel], 3
|
||||
jne @f
|
||||
mov eax, Image.bpp24
|
||||
jmp .quit
|
||||
@@:
|
||||
jmp .quit
|
||||
.quit:
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc tiff._.decompress.uncompressed _image
|
||||
|
||||
rep movsb
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc tiff._.decompress.packbits _image
|
||||
|
||||
push ebx ecx edx esi
|
||||
|
||||
mov edx, ecx
|
||||
|
||||
.decode:
|
||||
lodsb
|
||||
dec edx
|
||||
cmp al, 0xff
|
||||
jbe .different
|
||||
cmp al, 0x80
|
||||
jne .identical
|
||||
test edx, edx
|
||||
jz .quit
|
||||
jmp .decode
|
||||
|
||||
.identical:
|
||||
neg al
|
||||
inc al
|
||||
movzx ecx, al
|
||||
dec edx
|
||||
lodsb
|
||||
rep stosb
|
||||
test edx, edx
|
||||
jnz .decode
|
||||
jmp .quit
|
||||
|
||||
.different:
|
||||
movzx ecx, al
|
||||
inc ecx
|
||||
sub edx, ecx
|
||||
rep movsb
|
||||
test edx, edx
|
||||
jnz .decode
|
||||
|
||||
.quit:
|
||||
pop esi edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc tiff._.decompress.ccitt1d _image
|
||||
locals
|
||||
current_tree rd 1
|
||||
old_tree rd 1
|
||||
width rd 1
|
||||
height rd 1
|
||||
width_left rd 1
|
||||
is_makeup rd 1
|
||||
endl
|
||||
push ebx ecx edx esi
|
||||
mov [is_makeup], 0
|
||||
|
||||
mov ebx, [_image]
|
||||
push [ebx + Image.Height]
|
||||
pop [height]
|
||||
push [ebx + Image.Width]
|
||||
pop [width]
|
||||
|
||||
mov edx, esi
|
||||
.next_scanline:
|
||||
push [width]
|
||||
pop [width_left]
|
||||
dec [height]
|
||||
js .error
|
||||
mov [current_tree], tiff._.huffman_tree_white.begin
|
||||
mov [old_tree], tiff._.huffman_tree_black.begin
|
||||
mov ebx, 0
|
||||
mov ecx, 8
|
||||
.next_run:
|
||||
mov esi, [current_tree]
|
||||
.branch:
|
||||
lodsd
|
||||
btr eax, 31
|
||||
jnc .not_a_leaf
|
||||
cmp eax, 63
|
||||
seta byte[is_makeup]
|
||||
ja @f
|
||||
push [current_tree]
|
||||
push [old_tree]
|
||||
pop [current_tree]
|
||||
pop [old_tree]
|
||||
@@:
|
||||
stdcall tiff._.write_run, [width_left], [current_tree]
|
||||
mov [width_left], eax
|
||||
test byte[is_makeup], 0x01
|
||||
jnz .next_run
|
||||
test eax, eax
|
||||
jnz .next_run
|
||||
jmp .next_scanline
|
||||
.not_a_leaf:
|
||||
test bh, bh
|
||||
jnz @f
|
||||
mov bl, byte[edx]
|
||||
inc edx
|
||||
mov bh, 8
|
||||
@@:
|
||||
test al, 0x02
|
||||
jz .not_a_corner
|
||||
dec bh
|
||||
sal bl, 1
|
||||
lahf
|
||||
and ah, 0x03
|
||||
cmp al, ah
|
||||
jne .error
|
||||
mov esi, [esi]
|
||||
jmp .branch
|
||||
.not_a_corner:
|
||||
lodsd
|
||||
dec bh
|
||||
sal bl, 1
|
||||
jc .branch
|
||||
mov esi, eax
|
||||
jmp .branch
|
||||
.error:
|
||||
.quit:
|
||||
pop esi edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc tiff._.write_run _width_left, _current_tree
|
||||
|
||||
push ebx
|
||||
|
||||
test eax, eax
|
||||
jz .done
|
||||
sub [_width_left], eax
|
||||
js .error
|
||||
cmp esi, tiff._.huffman_tree_black.begin
|
||||
seta bh
|
||||
|
||||
cmp ecx, eax
|
||||
ja .one_byte
|
||||
.many_bytes:
|
||||
mov bl, [edi]
|
||||
@@:
|
||||
shl bl, 1
|
||||
or bl, bh
|
||||
dec eax
|
||||
dec ecx
|
||||
jnz @b
|
||||
mov [edi], bl
|
||||
inc edi
|
||||
mov ecx, eax
|
||||
and eax, 0x07
|
||||
shr ecx, 3
|
||||
|
||||
push eax
|
||||
xor eax, eax
|
||||
test bh, bh
|
||||
jz @f
|
||||
dec al
|
||||
@@:
|
||||
rep stosb
|
||||
pop eax
|
||||
|
||||
mov ecx, 8
|
||||
test eax, eax
|
||||
jz .done
|
||||
|
||||
.one_byte:
|
||||
mov bl, [edi]
|
||||
@@:
|
||||
shl bl, 1
|
||||
or bl, bh
|
||||
dec ecx
|
||||
dec eax
|
||||
jnz @b
|
||||
mov byte[edi], bl
|
||||
|
||||
cmp [_width_left], 0
|
||||
jne .done
|
||||
mov bl, [edi]
|
||||
shl bl, cl
|
||||
mov byte[edi], bl
|
||||
inc edi
|
||||
.done:
|
||||
mov eax, [_width_left]
|
||||
jmp .quit
|
||||
.error:
|
||||
.quit:
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc tiff._.get_word _endianness
|
||||
|
||||
lodsw
|
||||
test [_endianness], 1
|
||||
jnz @f
|
||||
ret
|
||||
@@:
|
||||
xchg al, ah
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc tiff._.get_dword _endianness
|
||||
|
||||
lodsd
|
||||
test [_endianness], 1
|
||||
jnz @f
|
||||
ret
|
||||
@@:
|
||||
bswap eax
|
||||
ret
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
tiff.IFDE_tag_table.begin:
|
||||
.tag_100: dd 0x0100, tiff._.parse_IFDE.tag_100 ; image width
|
||||
.tag_101: dd 0x0101, tiff._.parse_IFDE.tag_101 ; image height (this is called 'length' in spec)
|
||||
.tag_102: dd 0x0102, tiff._.parse_IFDE.tag_102 ; bits per sample
|
||||
.tag_103: dd 0x0103, tiff._.parse_IFDE.tag_103 ; compression
|
||||
.tag_106: dd 0x0106, tiff._.parse_IFDE.tag_106 ; photometric interpretation
|
||||
.tag_111: dd 0x0111, tiff._.parse_IFDE.tag_111 ; strip offsets
|
||||
.tag_115: dd 0x0115, tiff._.parse_IFDE.tag_115 ; samples per pixel
|
||||
.tag_116: dd 0x0116, tiff._.parse_IFDE.tag_116 ; rows per strip
|
||||
.tag_117: dd 0x0117, tiff._.parse_IFDE.tag_117 ; strip byte counts
|
||||
.tag_140: dd 0x0140, tiff._.parse_IFDE.tag_140 ; color map
|
||||
tiff.IFDE_tag_table.end:
|
||||
|
||||
include 'huffman.asm' ; huffman trees for ccitt1d compression method
|
97
programs/develop/libraries/libs-dev/libimg/tiff/tiff.inc
Normal file
97
programs/develop/libraries/libs-dev/libimg/tiff/tiff.inc
Normal file
@ -0,0 +1,97 @@
|
||||
;;================================================================================================;;
|
||||
;;//// tiff.inc //// (c) dunkaist, 2011-2012 /////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
|
||||
;; of the License, or (at your option) any later version. ;;
|
||||
;; ;;
|
||||
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
|
||||
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||
;; Lesser General Public License for more details. ;;
|
||||
;; ;;
|
||||
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
|
||||
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct tiff_header
|
||||
magic_1 rw 1
|
||||
magic_2 rw 1
|
||||
first_IFD rd 1
|
||||
ends
|
||||
|
||||
struct tiff_extra
|
||||
image_width rd 1 ; SHORT or LONG
|
||||
image_height rd 1 ; SHORT or LONG
|
||||
bits_per_sample rd 1 ; SHORT
|
||||
samples_per_pixel rd 1 ; SHORT
|
||||
compression rd 1 ; SHORT
|
||||
photometric rd 1 ; SHORT
|
||||
offsets_number rd 1
|
||||
strip_offsets rd 1 ; SHORT or LONG
|
||||
strip_offsets_length rd 1
|
||||
rows_per_strip rd 1 ; SHORT or LONG
|
||||
strip_byte_counts rd 1 ; LONG or SHORT
|
||||
strip_byte_counts_length rd 1
|
||||
palette rd 1 ; SHORT
|
||||
palette_size rd 1 ; in colors, not samples
|
||||
ends
|
||||
|
||||
|
||||
TIFF.IFDE_TYPE.BYTE = 1
|
||||
TIFF.IFDE_TYPE.ASCII = 2
|
||||
TIFF.IFDE_TYPE.SHORT = 3
|
||||
TIFF.IFDE_TYPE.LONG = 4
|
||||
TIFF.IFDE_TYPE.RATIONAL = 5
|
||||
TIFF.IFDE_TYPE.SBYTE = 6
|
||||
TIFF.IFDE_TYPE.UNDEFINED = 7
|
||||
TIFF.IFDE_TYPE.SSHORT = 8
|
||||
TIFF.IFDE_TYPE.SLONG = 9
|
||||
TIFF.IFDE_TYPE.SRATIONAL = 10
|
||||
TIFF.IFDE_TYPE.FLOAT = 11
|
||||
TIFF.IFDE_TYPE.DOUBLE = 12
|
||||
|
||||
TIFF.IFDE_TYPE_LENGTH.BYTE = 1
|
||||
TIFF.IFDE_TYPE_LENGTH.ASCII = 1
|
||||
TIFF.IFDE_TYPE_LENGTH.SHORT = 2
|
||||
TIFF.IFDE_TYPE_LENGTH.LONG = 4
|
||||
TIFF.IFDE_TYPE_LENGTH.RATIONAL = 8
|
||||
TIFF.IFDE_TYPE_LENGTH.SBYTE = 1
|
||||
TIFF.IFDE_TYPE_LENGTH.UNDEFINED = 1
|
||||
TIFF.IFDE_TYPE_LENGTH.SSHORT = 2
|
||||
TIFF.IFDE_TYPE_LENGTH.SLONG = 4
|
||||
TIFF.IFDE_TYPE_LENGTH.SRATIONAL = 8
|
||||
TIFF.IFDE_TYPE_LENGTH.FLOAT = 4
|
||||
TIFF.IFDE_TYPE_LENGTH.DOUBLE = 8
|
||||
|
||||
TIFF.COMPRESSION.UNCOMPRESSED = 1
|
||||
TIFF.COMPRESSION.CCITT1D = 2
|
||||
TIFF.COMPRESSION.GROUP3FAX = 3
|
||||
TIFF.COMPRESSION.GROUP4FAX = 4
|
||||
TIFF.COMPRESSION.LZW = 5
|
||||
TIFF.COMPRESSION.JPEG = 6
|
||||
TIFF.COMPRESSION.PACKBITS = 32773
|
||||
|
||||
TIFF.PHOTOMETRIC.WHITE_IS_ZERO = 0
|
||||
TIFF.PHOTOMETRIC.BLACK_IS_ZERO = 1
|
||||
TIFF.PHOTOMETRIC.RGB = 2
|
||||
TIFF.PHOTOMETRIC.RGB_PALETTE = 3
|
||||
TIFF.PHOTOMETRIC.MASK = 4
|
||||
TIFF.PHOTOMETRIC.CMYK = 5
|
||||
TIFF.PHOTOMETRIC.YCbCr = 6
|
||||
TIFF.PHOTOMETRIC.CIELAB = 8
|
||||
|
||||
|
||||
macro lodsw_
|
||||
{
|
||||
stdcall tiff._.get_word, [_endianness]
|
||||
}
|
||||
|
||||
macro lodsd_
|
||||
{
|
||||
stdcall tiff._.get_dword, [_endianness]
|
||||
}
|
||||
|
821
programs/develop/libraries/libs-dev/libimg/xcf/composite_mmx.asm
Normal file
821
programs/develop/libraries/libs-dev/libimg/xcf/composite_mmx.asm
Normal file
@ -0,0 +1,821 @@
|
||||
proc xcf._.blend_rgb
|
||||
|
||||
xchg al, bh
|
||||
mov ah, bh
|
||||
neg ax
|
||||
add ax, 0xffff
|
||||
mul ah
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
xchg ah, bh
|
||||
|
||||
mov al, 0xff
|
||||
cmp ah, bh
|
||||
je @f
|
||||
not al
|
||||
div bh
|
||||
@@:
|
||||
|
||||
mov ah, al
|
||||
|
||||
movd mm1, eax
|
||||
punpcklbw mm1, mm1
|
||||
punpcklbw mm1, mm0
|
||||
|
||||
movq mm7, mm1
|
||||
psrlw mm7, 7
|
||||
paddw mm1, mm7
|
||||
|
||||
psubw mm3, mm2
|
||||
pmullw mm3, mm1
|
||||
psllw mm2, 8
|
||||
paddw mm3, mm2
|
||||
pinsrw mm3, ebx, 3
|
||||
psrlw mm3, 8
|
||||
packuswb mm3, mm0
|
||||
movd eax, mm3
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.blend_gray
|
||||
|
||||
xchg al, bh
|
||||
mov ah, bh
|
||||
neg ax
|
||||
add ax, 0xffff
|
||||
mul ah
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
xchg ah, bh
|
||||
|
||||
mov al, 0xff
|
||||
cmp ah, bh
|
||||
je @f
|
||||
not al
|
||||
div bh
|
||||
@@:
|
||||
|
||||
mov ah, al
|
||||
|
||||
movd mm1, eax
|
||||
punpcklbw mm1, mm1
|
||||
punpcklbw mm1, mm0
|
||||
|
||||
movq mm7, mm1
|
||||
psrlw mm7, 7
|
||||
paddw mm1, mm7
|
||||
|
||||
psubw mm3, mm2
|
||||
pmullw mm3, mm1
|
||||
psllw mm2, 8
|
||||
paddw mm3, mm2
|
||||
pinsrw mm3, ebx, 1
|
||||
psrlw mm3, 8
|
||||
packuswb mm3, mm0
|
||||
movd eax, mm3
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.merge_32 _copy_width, _copy_height, _img_total_bpl, _bottom_total_bpl
|
||||
.rgb_line:
|
||||
mov ecx, [_copy_width]
|
||||
.rgb_pixel:
|
||||
mov ebx, [edi]
|
||||
lodsd
|
||||
|
||||
movd mm2, ebx
|
||||
movd mm3, eax
|
||||
shr eax, 24
|
||||
shr ebx, 16
|
||||
cmp al, bh
|
||||
jna @f
|
||||
mov al, bh
|
||||
@@:
|
||||
pxor mm0, mm0
|
||||
call edx
|
||||
call xcf._.blend_rgb
|
||||
stosd
|
||||
dec ecx
|
||||
jnz .rgb_pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .rgb_line
|
||||
emms
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.merge_8a _copy_width, _copy_height, _img_total_bpl, _bottom_total_bpl
|
||||
.gray_line:
|
||||
mov ecx, [_copy_width]
|
||||
.gray_pixel:
|
||||
mov bx, word[edi]
|
||||
lodsw
|
||||
movd mm2, ebx
|
||||
movd mm3, eax
|
||||
shr eax, 8
|
||||
cmp al, bh
|
||||
jna @f
|
||||
mov al, bh
|
||||
@@:
|
||||
pxor mm0, mm0
|
||||
call edx
|
||||
call xcf._.blend_gray
|
||||
stosw
|
||||
dec ecx
|
||||
jnz .gray_pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .gray_line
|
||||
emms
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_00 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
|
||||
.line:
|
||||
mov ecx, [_copy_width]
|
||||
.pixel:
|
||||
mov ebx, [edi]
|
||||
lodsd
|
||||
movd mm2, ebx
|
||||
movd mm3, eax
|
||||
|
||||
shr eax, 24
|
||||
shr ebx, 16
|
||||
|
||||
xchg al, bh
|
||||
mov ah, bh
|
||||
neg ax
|
||||
add ax, 0xffff
|
||||
mul ah
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
xchg ah, bh
|
||||
|
||||
mov al, 0xff
|
||||
cmp ah, bh
|
||||
je @f
|
||||
not al
|
||||
div bh
|
||||
@@:
|
||||
|
||||
mov ah, al
|
||||
|
||||
movd mm1, eax
|
||||
pxor mm0, mm0
|
||||
punpcklbw mm1, mm1
|
||||
punpcklbw mm1, mm0
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
psubsw mm3, mm2
|
||||
pmullw mm3, mm1
|
||||
psllw mm2, 8
|
||||
paddw mm3, mm2
|
||||
pinsrw mm3, ebx, 3
|
||||
psrlw mm3, 8
|
||||
packuswb mm3, mm0
|
||||
movd eax, mm3
|
||||
stosd
|
||||
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_gray_00 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
|
||||
.line:
|
||||
mov ecx, [_copy_width]
|
||||
.pixel:
|
||||
mov bx, [edi]
|
||||
lodsw
|
||||
movd mm2, ebx
|
||||
movd mm3, eax
|
||||
|
||||
shr eax, 8
|
||||
|
||||
xchg al, bh
|
||||
mov ah, bh
|
||||
neg ax
|
||||
add ax, 0xffff
|
||||
mul ah
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
xchg ah, bh
|
||||
|
||||
mov al, 0xff
|
||||
cmp ah, bh
|
||||
je @f
|
||||
not al
|
||||
div bh
|
||||
@@:
|
||||
|
||||
mov ah, al
|
||||
|
||||
movd mm1, eax
|
||||
pxor mm0, mm0
|
||||
punpcklbw mm1, mm1
|
||||
punpcklbw mm1, mm0
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
psubw mm3, mm2
|
||||
pmullw mm3, mm1
|
||||
psllw mm2, 8
|
||||
paddw mm3, mm2
|
||||
pinsrw mm3, ebx, 1
|
||||
psrlw mm3, 8
|
||||
packuswb mm3, mm0
|
||||
movd eax, mm3
|
||||
stosw
|
||||
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_indexed_00 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
|
||||
.line:
|
||||
mov ecx, [_copy_width]
|
||||
.pixel:
|
||||
mov bx, [edi]
|
||||
lodsw
|
||||
|
||||
or ah, 0x7f
|
||||
test ah, 0x80
|
||||
jnz @f
|
||||
mov ax, bx
|
||||
@@:
|
||||
stosw
|
||||
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_01 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
pushad
|
||||
|
||||
pxor mm4, mm4
|
||||
movd mm4, [xcf._.random_b]
|
||||
movd mm1, [xcf._.random_a]
|
||||
movd mm2, [xcf._.random_c]
|
||||
|
||||
.line:
|
||||
mov ecx, [_copy_width]
|
||||
.pixel:
|
||||
mov ebx, [edi]
|
||||
lodsd
|
||||
|
||||
movq mm0, mm4
|
||||
pmuludq mm0, mm1
|
||||
paddq mm0, mm2
|
||||
movd edx, mm0
|
||||
movd mm4, edx
|
||||
pxor mm0, mm0
|
||||
|
||||
rol eax, 8
|
||||
test al, al
|
||||
jz @f
|
||||
shr edx, 17
|
||||
cmp dl, al
|
||||
ja @f
|
||||
ror eax, 8
|
||||
or eax, 0xff000000
|
||||
jmp .done
|
||||
@@:
|
||||
mov eax, ebx
|
||||
.done:
|
||||
stosd
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
|
||||
.quit:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_gray_01 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
pushad
|
||||
|
||||
pxor mm4, mm4
|
||||
movd mm4, [xcf._.random_b]
|
||||
movd mm1, [xcf._.random_a]
|
||||
movd mm2, [xcf._.random_c]
|
||||
|
||||
.line:
|
||||
mov ecx, [_copy_width]
|
||||
.pixel:
|
||||
mov ebx, [edi]
|
||||
lodsw
|
||||
|
||||
movq mm0, mm4
|
||||
pmuludq mm0, mm1
|
||||
paddq mm0, mm2
|
||||
movd edx, mm0
|
||||
movd mm4, edx
|
||||
pxor mm0, mm0
|
||||
|
||||
test ah, ah
|
||||
jz @f
|
||||
shr edx, 17
|
||||
cmp dl, ah
|
||||
ja @f
|
||||
or ax, 0xff00
|
||||
jmp .done
|
||||
@@:
|
||||
mov eax, ebx
|
||||
.done:
|
||||
stosw
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
|
||||
.quit:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_03 ; Multiply
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
pmullw mm3, mm2
|
||||
psrlw mm3, 8
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_04 ; Screen
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
movq mm5, [xcf._.mmx_00ff]
|
||||
movq mm4, mm5
|
||||
psubw mm4, mm2
|
||||
psubw mm3, mm5
|
||||
pmullw mm3, mm4
|
||||
psrlw mm3, 8
|
||||
paddw mm3, mm5
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_05 ; Overlay
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
movq mm4, [xcf._.mmx_00ff]
|
||||
psubw mm4, mm2
|
||||
pmullw mm3, mm4
|
||||
psrlw mm3, 7
|
||||
paddw mm3, mm2
|
||||
pmullw mm3, mm2
|
||||
psrlw mm3, 8
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_06 ; Difference
|
||||
|
||||
movq mm4, mm3
|
||||
pminub mm4, mm2
|
||||
pmaxub mm3, mm2
|
||||
psubusb mm3, mm4
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_07 ; Addition
|
||||
|
||||
paddusb mm3, mm2
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_08 ; Subtract
|
||||
|
||||
movq mm4, mm2
|
||||
psubusb mm4, mm3
|
||||
movq mm3, mm4
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_09 ; Darken Only
|
||||
|
||||
pminub mm3, mm2
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_10 ; Lighten Only
|
||||
|
||||
pmaxub mm3, mm2
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_11 ; Hue (H of HSV)
|
||||
push eax ebx ecx edx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
call xcf._.rgb2hsv
|
||||
xchg eax, ebx
|
||||
call xcf._.rgb2hsv
|
||||
xchg eax, ebx
|
||||
|
||||
test ah, ah
|
||||
jnz @f
|
||||
ror eax, 8
|
||||
ror ebx, 8
|
||||
mov ah, bh
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
@@:
|
||||
mov ax, bx
|
||||
|
||||
call xcf._.hsv2rgb
|
||||
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
.quit:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_12 ; Saturation (S of HSV)
|
||||
push eax ebx ecx edx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
call xcf._.rgb2hsv
|
||||
xchg eax, ebx
|
||||
call xcf._.rgb2hsv
|
||||
xchg eax, ebx
|
||||
|
||||
ror eax, 8
|
||||
ror ebx, 8
|
||||
mov ah, bh
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
mov al, bl
|
||||
|
||||
call xcf._.hsv2rgb
|
||||
|
||||
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
.quit:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_13 ; Color (H and S of HSL)
|
||||
push eax ebx ecx edx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
call xcf._.rgb2hsl
|
||||
xchg eax, ebx
|
||||
call xcf._.rgb2hsl
|
||||
xchg eax, ebx
|
||||
|
||||
mov al, bl
|
||||
|
||||
call xcf._.hsl2rgb
|
||||
|
||||
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
.quit:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_14 ; Value (V of HSV)
|
||||
push eax ebx ecx edx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
call xcf._.rgb2hsv
|
||||
xchg eax, ebx
|
||||
call xcf._.rgb2hsv
|
||||
xchg eax, ebx
|
||||
|
||||
ror eax, 8
|
||||
ror ebx, 8
|
||||
mov ax, bx
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
call xcf._.hsv2rgb
|
||||
|
||||
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
.quit:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_15 ; Divide
|
||||
push eax ebx ecx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
xchg eax, ebx
|
||||
|
||||
mov ecx, 3
|
||||
|
||||
.color:
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
shl ax, 8
|
||||
test bl, bl
|
||||
jz .clamp1
|
||||
cmp ah, bl
|
||||
jae .clamp2
|
||||
div bl
|
||||
jmp .done
|
||||
.clamp1:
|
||||
mov al, 0xff
|
||||
test ah, ah
|
||||
jnz @f
|
||||
not al
|
||||
@@:
|
||||
jmp .done
|
||||
.clamp2:
|
||||
mov al, 0xff
|
||||
jmp .done
|
||||
.done:
|
||||
mov ah, al
|
||||
loop .color
|
||||
|
||||
ror eax, 8
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_16 ; Dodge
|
||||
push eax ebx ecx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
xchg eax, ebx
|
||||
|
||||
mov ecx, 3
|
||||
|
||||
.color:
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
shl ax, 8
|
||||
neg bl
|
||||
add bl, 0xff
|
||||
test bl, bl
|
||||
jz .clamp1
|
||||
cmp ah, bl
|
||||
jae .clamp2
|
||||
div bl
|
||||
jmp .done
|
||||
.clamp1:
|
||||
mov al, 0xff
|
||||
test ah, ah
|
||||
jnz @f
|
||||
not al
|
||||
@@:
|
||||
jmp .done
|
||||
.clamp2:
|
||||
mov al, 0xff
|
||||
jmp .done
|
||||
.done:
|
||||
mov ah, al
|
||||
loop .color
|
||||
|
||||
ror eax, 8
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_17 ; Burn
|
||||
push eax ebx ecx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
xchg eax, ebx
|
||||
|
||||
mov ecx, 3
|
||||
|
||||
.color:
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
shl ax, 8
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
test bl, bl
|
||||
jz .clamp1
|
||||
cmp ah, bl
|
||||
jae .clamp2
|
||||
div bl
|
||||
jmp .done
|
||||
.clamp1:
|
||||
mov al, 0xff
|
||||
test ah, ah
|
||||
jnz @f
|
||||
not al
|
||||
@@:
|
||||
jmp .done
|
||||
.clamp2:
|
||||
mov al, 0xff
|
||||
jmp .done
|
||||
.done:
|
||||
mov ah, al
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
loop .color
|
||||
|
||||
ror eax, 8
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_18 ; Hard Light
|
||||
push eax ebx ecx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
mov ecx, 3
|
||||
|
||||
.color:
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
cmp al, 127
|
||||
jna .part1
|
||||
mov ah, 0xff
|
||||
sub ah, bl
|
||||
neg al
|
||||
add al, 0xff
|
||||
mul ah
|
||||
shl ax, 1
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
jmp .done
|
||||
.part1:
|
||||
mul bl
|
||||
shl ax, 1
|
||||
.done:
|
||||
loop .color
|
||||
|
||||
ror eax, 8
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_20 ; Grain Extract
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
movq mm4, mm2
|
||||
psubw mm3, [xcf._.mmx_0080]
|
||||
psubw mm4, mm3
|
||||
movq mm3, mm4
|
||||
packuswb mm3, mm0
|
||||
punpcklbw mm3, mm0
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc xcf._.composite_rgb_21 ; Grain Merge
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
paddw mm3, mm2
|
||||
psubusw mm3, [xcf._.mmx_0080]
|
||||
packuswb mm3, mm0
|
||||
punpcklbw mm3, mm0
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
; starting numbers for pseudo-random number generator
|
||||
xcf._.random_a dd 1103515245
|
||||
xcf._.random_b dd 777
|
||||
xcf._.random_c dd 12345
|
||||
|
||||
xcf._.mmx_0080 dq 0x0080008000800080
|
||||
xcf._.mmx_00ff dq 0x00ff00ff00ff00ff
|
||||
xcf._.mmx_0100 dq 0x0100010001000100
|
@ -1,828 +0,0 @@
|
||||
proc blend_rgb
|
||||
|
||||
xchg al, bh
|
||||
mov ah, bh
|
||||
neg ax
|
||||
add ax, 0xffff
|
||||
mul ah
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
xchg ah, bh
|
||||
|
||||
mov al, 0xff
|
||||
cmp ah, bh
|
||||
je @f
|
||||
not al
|
||||
div bh
|
||||
@@:
|
||||
|
||||
mov ah, al
|
||||
movd mm1, eax
|
||||
; pxor mm0, mm0 ; already xor'ed in composite function
|
||||
punpcklbw mm1, mm1
|
||||
punpcklbw mm1, mm0
|
||||
; punpcklbw mm3, mm0
|
||||
|
||||
movq mm7, mm1
|
||||
psrlw mm7, 7
|
||||
paddw mm1, mm7
|
||||
|
||||
psubw mm3, mm2
|
||||
pmullw mm3, mm1
|
||||
psllw mm2, 8
|
||||
paddw mm3, mm2
|
||||
pinsrw mm3, ebx, 3
|
||||
psrlw mm3, 8
|
||||
packuswb mm3, mm0
|
||||
movd eax, mm3
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc blend_gray
|
||||
|
||||
xchg al, bh
|
||||
mov ah, bh
|
||||
neg ax
|
||||
add ax, 0xffff
|
||||
mul ah
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
xchg ah, bh
|
||||
|
||||
mov al, 0xff
|
||||
cmp ah, bh
|
||||
je @f
|
||||
not al
|
||||
div bh
|
||||
@@:
|
||||
|
||||
mov ah, al
|
||||
movd mm1, eax
|
||||
; pxor mm0, mm0 ; already xor'ed in composite function
|
||||
punpcklbw mm1, mm1
|
||||
punpcklbw mm1, mm0
|
||||
; punpcklbw mm3, mm0
|
||||
|
||||
movq mm7, mm1
|
||||
psrlw mm7, 7
|
||||
paddw mm1, mm7
|
||||
|
||||
psubw mm3, mm2
|
||||
pmullw mm3, mm1
|
||||
psllw mm2, 8
|
||||
paddw mm3, mm2
|
||||
pinsrw mm3, ebx, 1
|
||||
psrlw mm3, 8
|
||||
packuswb mm3, mm0
|
||||
movd eax, mm3
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc merge_32 _copy_width, _copy_height, _img_total_bpl, _bottom_total_bpl
|
||||
.rgb_line:
|
||||
mov ecx, [_copy_width]
|
||||
.rgb_pixel:
|
||||
mov ebx, [edi]
|
||||
lodsd
|
||||
|
||||
movd mm2, ebx
|
||||
movd mm3, eax
|
||||
shr eax, 24
|
||||
shr ebx, 16
|
||||
cmp al, bh
|
||||
jna @f
|
||||
mov al, bh
|
||||
@@: pxor mm0, mm0
|
||||
call edx
|
||||
call blend_rgb
|
||||
stosd
|
||||
dec ecx
|
||||
jnz .rgb_pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .rgb_line
|
||||
emms
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc merge_8a _copy_width, _copy_height, _img_total_bpl, _bottom_total_bpl
|
||||
.gray_line:
|
||||
mov ecx, [_copy_width]
|
||||
.gray_pixel:
|
||||
mov bx, word[edi]
|
||||
lodsw
|
||||
movd mm2, ebx
|
||||
movd mm3, eax
|
||||
shr eax, 8
|
||||
cmp al, bh
|
||||
jna @f
|
||||
mov al, bh
|
||||
@@: pxor mm0, mm0
|
||||
call edx
|
||||
call blend_gray
|
||||
stosw
|
||||
dec ecx
|
||||
jnz .gray_pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .gray_line
|
||||
emms
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_00 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
|
||||
.line: mov ecx, [_copy_width]
|
||||
.pixel: mov ebx, [edi]
|
||||
lodsd
|
||||
movd mm2, ebx
|
||||
movd mm3, eax
|
||||
|
||||
shr eax, 24
|
||||
shr ebx, 16
|
||||
|
||||
xchg al, bh
|
||||
mov ah, bh
|
||||
neg ax
|
||||
add ax, 0xffff
|
||||
mul ah
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
xchg ah, bh
|
||||
|
||||
mov al, 0xff
|
||||
cmp ah, bh
|
||||
je @f
|
||||
not al
|
||||
div bh
|
||||
@@:
|
||||
|
||||
mov ah, al
|
||||
movd mm1, eax
|
||||
pxor mm0, mm0
|
||||
punpcklbw mm1, mm1
|
||||
punpcklbw mm1, mm0
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
psubsw mm3, mm2
|
||||
pmullw mm3, mm1
|
||||
psllw mm2, 8
|
||||
paddw mm3, mm2
|
||||
pinsrw mm3, ebx, 3
|
||||
psrlw mm3, 8
|
||||
packuswb mm3, mm0
|
||||
movd eax, mm3
|
||||
stosd
|
||||
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_gray_00 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
|
||||
.line: mov ecx, [_copy_width]
|
||||
.pixel: mov bx, [edi]
|
||||
lodsw
|
||||
movd mm2, ebx
|
||||
movd mm3, eax
|
||||
|
||||
shr eax, 8
|
||||
|
||||
xchg al, bh
|
||||
mov ah, bh
|
||||
neg ax
|
||||
add ax, 0xffff
|
||||
mul ah
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
xchg ah, bh
|
||||
|
||||
mov al, 0xff
|
||||
cmp ah, bh
|
||||
je @f
|
||||
not al
|
||||
div bh
|
||||
@@:
|
||||
|
||||
mov ah, al
|
||||
movd mm1, eax
|
||||
pxor mm0, mm0
|
||||
punpcklbw mm1, mm1
|
||||
punpcklbw mm1, mm0
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
psubw mm3, mm2
|
||||
pmullw mm3, mm1
|
||||
psllw mm2, 8
|
||||
paddw mm3, mm2
|
||||
pinsrw mm3, ebx, 1
|
||||
psrlw mm3, 8
|
||||
packuswb mm3, mm0
|
||||
movd eax, mm3
|
||||
stosw
|
||||
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_indexed_00 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
|
||||
.line: mov ecx, [_copy_width]
|
||||
.pixel: mov bx, [edi]
|
||||
lodsw
|
||||
|
||||
or ah, 0x7f
|
||||
test ah, 0x80
|
||||
jnz @f
|
||||
mov ax, bx
|
||||
@@: stosw
|
||||
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_01 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
pushad
|
||||
|
||||
pxor mm4, mm4
|
||||
movd mm4, [random_b]
|
||||
movd mm1, [random_a]
|
||||
movd mm2, [random_c]
|
||||
|
||||
.line: mov ecx, [_copy_width]
|
||||
.pixel: mov ebx, [edi]
|
||||
lodsd
|
||||
|
||||
movq mm0, mm4
|
||||
pmuludq mm0, mm1
|
||||
paddq mm0, mm2
|
||||
movd edx, mm0
|
||||
movd mm4, edx
|
||||
pxor mm0, mm0
|
||||
|
||||
rol eax, 8
|
||||
test al, al
|
||||
jz @f
|
||||
shr edx, 17
|
||||
cmp dl, al
|
||||
ja @f
|
||||
ror eax, 8
|
||||
or eax, 0xff000000
|
||||
jmp .done
|
||||
@@: mov eax, ebx
|
||||
.done: stosd
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
|
||||
.quit: popad
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_gray_01 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
pushad
|
||||
|
||||
pxor mm4, mm4
|
||||
movd mm4, [random_b]
|
||||
movd mm1, [random_a]
|
||||
movd mm2, [random_c]
|
||||
|
||||
.line: mov ecx, [_copy_width]
|
||||
.pixel: mov ebx, [edi]
|
||||
lodsw
|
||||
|
||||
movq mm0, mm4
|
||||
pmuludq mm0, mm1
|
||||
paddq mm0, mm2
|
||||
movd edx, mm0
|
||||
movd mm4, edx
|
||||
pxor mm0, mm0
|
||||
|
||||
test ah, ah
|
||||
jz @f
|
||||
shr edx, 17
|
||||
cmp dl, ah
|
||||
ja @f
|
||||
or ax, 0xff00
|
||||
jmp .done
|
||||
@@: mov eax, ebx
|
||||
.done: stosw
|
||||
dec ecx
|
||||
jnz .pixel
|
||||
add esi, [_img_total_bpl]
|
||||
add edi, [_bottom_total_bpl]
|
||||
dec [_copy_height]
|
||||
jnz .line
|
||||
|
||||
.quit: popad
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;proc composite_indexed_01 _copy_width, _copy_height, _bottom_total_bpl, _img_total_bpl
|
||||
; pushad
|
||||
;
|
||||
; pxor mm4, mm4
|
||||
; movd mm4, [random_b]
|
||||
; movd mm1, [random_a]
|
||||
; movd mm2, [random_c]
|
||||
;
|
||||
;.line: mov ecx, [_copy_width]
|
||||
;.pixel: mov ebx, [edi]
|
||||
; lodsw
|
||||
;
|
||||
; movq mm0, mm4
|
||||
; pmuludq mm0, mm1
|
||||
; paddq mm0, mm2
|
||||
; movd edx, mm0
|
||||
; movd mm4, edx
|
||||
; pxor mm0, mm0
|
||||
;
|
||||
; test ah, ah
|
||||
; jz @f
|
||||
; shr edx, 17
|
||||
; cmp dl, ah
|
||||
; ja @f
|
||||
; or ax, 0xff00
|
||||
; jmp .done
|
||||
;@@: mov eax, ebx
|
||||
;.done: stosw
|
||||
; dec ecx
|
||||
; jnz .pixel
|
||||
; add esi, [_img_total_bpl]
|
||||
; add edi, [_bottom_total_bpl]
|
||||
; dec [_copy_height]
|
||||
; jnz .line
|
||||
;
|
||||
;.quit: popad
|
||||
; ret
|
||||
;endp
|
||||
|
||||
|
||||
proc composite_rgb_03 ; Multiply
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
pmullw mm3, mm2
|
||||
psrlw mm3, 8
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_04 ; Screen
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
movq mm4, [mmx_00ff]
|
||||
movq mm5, mm4
|
||||
psubw mm4, mm2
|
||||
psubw mm5, mm3
|
||||
pmullw mm4, mm5
|
||||
psrlw mm4, 8
|
||||
movq mm3, [mmx_00ff]
|
||||
psubw mm3, mm4
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_05 ; Overlay
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
movq mm4, [mmx_00ff]
|
||||
psubw mm4, mm2
|
||||
pmullw mm3, mm4
|
||||
psrlw mm3, 7
|
||||
paddw mm3, mm2
|
||||
pmullw mm3, mm2
|
||||
psrlw mm3, 8
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_06 ; Difference
|
||||
|
||||
movq mm4, mm3
|
||||
pminub mm4, mm2
|
||||
pmaxub mm3, mm2
|
||||
psubusb mm3, mm4
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_07 ; Addition
|
||||
|
||||
paddusb mm3, mm2
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_08 ; Subtract
|
||||
|
||||
movq mm4, mm2
|
||||
psubusb mm4, mm3
|
||||
movq mm3, mm4
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_09 ; Darken Only
|
||||
|
||||
pminub mm3, mm2
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_10 ; Lighten Only
|
||||
|
||||
pmaxub mm3, mm2
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_11 ; Hue (H of HSV)
|
||||
push eax ebx ecx edx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
call pixel_rgb2hsv
|
||||
xchg eax, ebx
|
||||
call pixel_rgb2hsv
|
||||
xchg eax, ebx
|
||||
|
||||
test ah, ah
|
||||
jnz @f
|
||||
ror eax, 8
|
||||
ror ebx, 8
|
||||
mov ah, bh
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
@@:
|
||||
mov ax, bx
|
||||
|
||||
call pixel_hsv2rgb
|
||||
|
||||
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
.quit:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_12 ; Saturation (S of HSV)
|
||||
push eax ebx ecx edx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
call pixel_rgb2hsv
|
||||
xchg eax, ebx
|
||||
call pixel_rgb2hsv
|
||||
xchg eax, ebx
|
||||
|
||||
ror eax, 8
|
||||
ror ebx, 8
|
||||
mov ah, bh
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
mov al, bl
|
||||
|
||||
call pixel_hsv2rgb
|
||||
|
||||
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
.quit:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_13 ; Color (H and S of HSL)
|
||||
push eax ebx ecx edx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
call pixel_rgb2hsl
|
||||
xchg eax, ebx
|
||||
call pixel_rgb2hsl
|
||||
xchg eax, ebx
|
||||
|
||||
mov al, bl
|
||||
|
||||
call pixel_hsl2rgb
|
||||
|
||||
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
.quit:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_14 ; Value (V of HSV)
|
||||
push eax ebx ecx edx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
call pixel_rgb2hsv
|
||||
xchg eax, ebx
|
||||
call pixel_rgb2hsv
|
||||
xchg eax, ebx
|
||||
|
||||
ror eax, 8
|
||||
ror ebx, 8
|
||||
mov ax, bx
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
call pixel_hsv2rgb
|
||||
|
||||
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
.quit:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_15 ; Divide
|
||||
push eax ebx ecx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
xchg eax, ebx
|
||||
|
||||
mov ecx, 3
|
||||
|
||||
.color: rol eax, 8
|
||||
rol ebx, 8
|
||||
shl ax, 8
|
||||
test bl, bl
|
||||
jz .clamp1
|
||||
cmp ah, bl
|
||||
jae .clamp2
|
||||
div bl
|
||||
jmp .done
|
||||
.clamp1:mov al, 0xff
|
||||
test ah, ah
|
||||
jnz @f
|
||||
not al
|
||||
@@: jmp .done
|
||||
.clamp2:mov al, 0xff
|
||||
jmp .done
|
||||
.done: mov ah, al
|
||||
loop .color
|
||||
|
||||
ror eax, 8
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_16 ; Dodge
|
||||
push eax ebx ecx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
xchg eax, ebx
|
||||
|
||||
mov ecx, 3
|
||||
|
||||
.color: rol eax, 8
|
||||
rol ebx, 8
|
||||
shl ax, 8
|
||||
neg bl
|
||||
add bl, 0xff
|
||||
test bl, bl
|
||||
jz .clamp1
|
||||
cmp ah, bl
|
||||
jae .clamp2
|
||||
div bl
|
||||
jmp .done
|
||||
.clamp1:mov al, 0xff
|
||||
test ah, ah
|
||||
jnz @f
|
||||
not al
|
||||
@@: jmp .done
|
||||
.clamp2:mov al, 0xff
|
||||
jmp .done
|
||||
.done: mov ah, al
|
||||
loop .color
|
||||
|
||||
ror eax, 8
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_17 ; Burn
|
||||
push eax ebx ecx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
xchg eax, ebx
|
||||
|
||||
mov ecx, 3
|
||||
|
||||
.color: rol eax, 8
|
||||
rol ebx, 8
|
||||
shl ax, 8
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
test bl, bl
|
||||
jz .clamp1
|
||||
cmp ah, bl
|
||||
jae .clamp2
|
||||
div bl
|
||||
jmp .done
|
||||
.clamp1:mov al, 0xff
|
||||
test ah, ah
|
||||
jnz @f
|
||||
not al
|
||||
@@: jmp .done
|
||||
.clamp2:mov al, 0xff
|
||||
jmp .done
|
||||
.done: mov ah, al
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
loop .color
|
||||
|
||||
ror eax, 8
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_18 ; Hard Light
|
||||
push eax ebx ecx
|
||||
|
||||
movd eax, mm3
|
||||
movd ebx, mm2
|
||||
|
||||
rol eax, 8
|
||||
rol ebx, 8
|
||||
|
||||
mov ecx, 3
|
||||
|
||||
.color: rol eax, 8
|
||||
rol ebx, 8
|
||||
cmp al, 127
|
||||
jna .part1
|
||||
mov ah, 0xff
|
||||
sub ah, bl
|
||||
neg al
|
||||
add al, 0xff
|
||||
mul ah
|
||||
shl ax, 1
|
||||
neg ah
|
||||
add ah, 0xff
|
||||
jmp .done
|
||||
.part1:
|
||||
mul bl
|
||||
shl ax, 1
|
||||
.done: loop .color
|
||||
|
||||
ror eax, 8
|
||||
movd mm3, eax
|
||||
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_20 ; Grain Extract
|
||||
|
||||
movq mm4, [mmx_0080]
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
movq mm5, mm2
|
||||
psubw mm3, mm4
|
||||
psubsw mm5, mm3
|
||||
packuswb mm5, mm0
|
||||
punpcklbw mm5, mm0
|
||||
movq mm3, mm5
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc composite_rgb_21 ; Grain Merge
|
||||
|
||||
movq mm4, [mmx_0080]
|
||||
punpcklbw mm2, mm0
|
||||
punpcklbw mm3, mm0
|
||||
movq mm5, mm2
|
||||
psubw mm5, mm4
|
||||
paddsw mm3, mm5
|
||||
packuswb mm3, mm0
|
||||
punpcklbw mm3, mm0
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
mmx_0080 dq 0x0080008000800080
|
||||
mmx_00ff dq 0x00ff00ff00ff00ff
|
||||
mmx_0100 dq 0x0100010001000100
|
1315
programs/develop/libraries/libs-dev/libimg/xcf/composite_sse.asm
Normal file
1315
programs/develop/libraries/libs-dev/libimg/xcf/composite_sse.asm
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
;;================================================================================================;;
|
||||
;;//// xcf.inc //// (c) dunkaist, 2011 ///////////////////////////////////////////////////////////;;
|
||||
;;//// xcf.inc //// (c) dunkaist, 2011-2012 //////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; This file is part of Common development libraries (Libs-Dev). ;;
|
||||
@ -17,26 +17,26 @@
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct xcf_header
|
||||
magic_string rb 9
|
||||
version rd 1
|
||||
reserved rb 1
|
||||
width rd 1
|
||||
height rd 1
|
||||
base_type rd 1
|
||||
XCF_BASETYPE_RGB = 0
|
||||
XCF_BASETYPE_GRAY = 1
|
||||
XCF_BASETYPE_INDEXED = 2
|
||||
|
||||
struct xcf_header
|
||||
magic_string rb 9
|
||||
version rd 1
|
||||
reserved rb 1
|
||||
width rd 1
|
||||
height rd 1
|
||||
base_type rd 1
|
||||
ends
|
||||
|
||||
XCF_BASETYPE_RGB equ 0
|
||||
XCF_BASETYPE_GRAY equ 1
|
||||
XCF_BASETYPE_INDEXED equ 2
|
||||
|
||||
struct xcf_ext
|
||||
visible rd 1
|
||||
layer_mode rd 1
|
||||
offset_x rd 1
|
||||
offset_y rd 1
|
||||
opacity rd 1
|
||||
apply_mask rd 1
|
||||
type rd 1
|
||||
planes rd 1
|
||||
ends
|
||||
struct xcf_ext
|
||||
visible rd 1
|
||||
layer_mode rd 1
|
||||
offset_x rd 1
|
||||
offset_y rd 1
|
||||
opacity rd 1
|
||||
apply_mask rd 1
|
||||
type rd 1
|
||||
planes rd 1
|
||||
ends
|
||||
|
Loading…
Reference in New Issue
Block a user