fix calculation 'adler32',

other small fixes

git-svn-id: svn://kolibrios.org@6873 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA
2017-03-04 19:17:49 +00:00
parent 846906fa8c
commit c5ce2bec50
5 changed files with 55 additions and 89 deletions

View File

@@ -149,9 +149,6 @@ f_zbz db ' ZB_line_z',0
f_zb db ' ZB_line',0
f_find_l db 'find_list',0
f_alloc_l db 'alloc_list',0
f_is_l db 'glIsList',0
f_gen_l db 'glGenLists',0
f_end_l db 'glEndList',0
f_fill_tr db 'ZB_fillTriangle...',0
f_fill_tr_nl db ' lines',0
f_fill_tr_nll db ' len',0

View File

@@ -2941,7 +2941,7 @@ align 4
.cycle4:
mov dword[edi+png_struct.zstream.avail_out],16*1024
stdcall [deflate], esi, Z_NO_FLUSH
stdcall [deflate], esi, Z_FINISH ;Z_NO_FLUSH
cmp eax,Z_STREAM_ERROR
je .end1
@@ -2949,13 +2949,14 @@ align 4
sub ecx,[edi+png_struct.zstream.avail_out]
cmp dword[edi+png_struct.zstream.avail_out],0
je .cycle4 ;while (strm.avail_out == 0)
if 0
mov dword[edi+png_struct.zstream.avail_out],16*1024
stdcall [deflate], esi, Z_FINISH
add ecx,16*1024
sub ecx,[edi+png_struct.zstream.avail_out]
cmp eax,Z_STREAM_ERROR
je .end1
end if
stdcall [deflateEnd], esi
if PNG_WRITE_OPTIMIZE_CMF_SUPPORTED eq 1

View File

@@ -9,12 +9,9 @@ NMAX equ 5552
macro DO1 buf,i
{
mov eax,buf
add eax,i
movzx eax,byte[eax]
movzx eax,byte[buf+i]
add [adler],eax
mov eax,[adler]
add [sum2],eax
add edi,[adler]
}
macro DO2 buf,i
{
@@ -113,25 +110,18 @@ end if
}
; =========================================================================
;uLong (adler, buf, len)
; uLong adler
; const Bytef *buf
; uInt len
align 4
proc adler32 uses ebx edx, adler:dword, buf:dword, len:dword
locals
sum2 dd ? ;uLong
endl
;zlib_debug 'adler32 adler = %d',[adler]
;uLong (uLong adler, const Bytef *buf, uInt len)
align 16
proc adler32 uses ebx ecx edx edi, adler:dword, buf:dword, len:dword
; split Adler-32 into component sums
mov eax,[adler]
shr eax,16
mov [sum2],eax
and [adler],0xffff
mov edi,[adler]
shr edi,16
and dword[adler],0xffff
mov ebx,[buf]
mov ecx,[len]
; in case user likes doing a byte at a time, keep it fast
cmp dword[len],1
cmp ecx,1
jne .end0 ;if (..==..)
movzx eax,byte[ebx]
add [adler],eax
@@ -139,12 +129,10 @@ endl
jb @f ;if (..>=..)
sub dword[adler],BASE
@@:
mov eax,[adler]
add [sum2],eax
cmp dword[sum2],BASE
jb @f ;if (..>=..)
sub dword[sum2],BASE
@@:
add edi,[adler]
cmp edi,BASE
jae .combine ;if (..>=..)
sub edi,BASE
jmp .combine
align 4
.end0:
@@ -159,89 +147,82 @@ align 4
@@:
; in case short lengths are provided, keep it somewhat fast
cmp dword[len],16
jge .end1 ;if (..<..)
cmp ecx,16
jae .cycle3 ;if (..<..)
.cycle0:
cmp dword[len],0
jne @f ;while (..)
mov eax,ecx
dec ecx
test eax,eax
je @f ;while (..)
movzx eax,byte[ebx]
inc ebx
add [adler],eax
mov eax,[adler]
add [sum2],eax
dec dword[len]
inc ebx
add edi,[adler]
jmp .cycle0
align 4
@@:
cmp dword[adler],BASE
jl @f ;if (..>=..)
jb @f ;if (..>=..)
sub dword[adler],BASE
@@:
MOD28 dword[sum2] ;only added so many BASE's
MOD28 edi ;only added so many BASE's
jmp .combine
align 4
.end1:
; do length NMAX blocks -- requires just one modulo operation
align 4
.cycle3:
cmp dword[len],NMAX
jl .cycle3end ;while (..>=..)
sub dword[len],NMAX
cmp ecx,NMAX
jb .cycle3end ;while (..>=..)
sub ecx,NMAX
mov edx,NMAX/16 ;NMAX is divisible by 16
.cycle1: ;do
DO16 ebx ;16 sums unrolled
add ebx,16
dec edx
cmp edx,0
jg .cycle1 ;while (..)
jne .cycle1 ;while (..)
MOD [adler]
MOD [sum2]
MOD edi
jmp .cycle3
align 4
.cycle3end:
; do remaining bytes (less than NMAX, still just one modulo)
cmp dword[len],0
jne .end2 ;if (..) ;avoid modulos if none remaining
cmp ecx,0
je .combine ;if (..) ;avoid modulos if none remaining
@@:
cmp dword[len],16
jl .cycle2 ;while (..>=..)
sub dword[len],16
cmp ecx,16
jb .cycle2 ;while (..>=..)
sub ecx,16
DO16 ebx
add ebx,16
jmp @b
align 4
.cycle2:
cmp dword[len],0
jne @f ;while (..)
mov eax,ecx
dec ecx
test eax,eax
je @f ;while (..)
movzx eax,byte[ebx]
inc ebx
add [adler],eax
mov eax,[adler]
add [sum2],eax
dec dword[len]
inc ebx
add edi,[adler]
jmp .cycle2
align 4
@@:
MOD [adler]
MOD [sum2]
.end2:
MOD edi
; return recombined sums
.combine:
mov eax,[sum2]
mov eax,edi
shl eax,16
or eax,[adler]
.end_f:
;zlib_debug ' adler32.ret = %d',eax
ret
endp
; =========================================================================
;uLong (adler1, adler2, len2)
; uLong adler1
; uLong adler2
; z_off64_t len2
;uLong (uLong adler1, uLong adler2, z_off64_t len2)
align 4
proc adler32_combine_, adler1:dword, adler2:dword, len2:dword
locals

View File

@@ -341,6 +341,7 @@ end if
mov edi,eax ;edi = s
mov [ebx+z_stream.state],edi
mov [edi+deflate_state.strm],ebx
mov dword[edi+deflate_state.status],INIT_STATE ;to pass state test in deflateReset()
mov eax,[wrap]
mov [edi+deflate_state.wrap],eax
@@ -1009,7 +1010,7 @@ proc flush_pending uses eax ebx ecx edx, strm:dword
mov ecx,[edx+deflate_state.pending]
mov eax,[ebx+z_stream.avail_out]
cmp ecx,eax
jle @f ;if (..>..)
jbe @f ;if (..>..)
mov ecx,eax
@@:
test ecx,ecx
@@ -1220,7 +1221,7 @@ end if
bswap ecx
put_dword edi, ecx
@@:
xor eax,eax ;stdcall calc_crc32, 0, Z_NULL, 0
stdcall adler32, 0,0,0
mov [ebx+z_stream.adler],eax
.end2:
if GZIP eq 1
@@ -1772,7 +1773,7 @@ proc read_buf uses ebx ecx, strm:dword, buf:dword, size:dword
mov eax,[ebx+z_stream.avail_in]
cmp eax,[size]
jle @f ;if (..>..)
jbe @f ;if (..>..)
mov eax,[size]
@@:
cmp eax,0

View File

@@ -170,15 +170,7 @@ test_code:
mov [eax+z_stream.next_out],m1 ;<3B><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><><E1A6A0><EFBFBD>
mov dword[eax+z_stream.avail_out],1024 ;ࠧ<><E0A0A7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><><E1A6A0><EFBFBD> (<28><><EFBFBD><EFBFBD><E1A8AC> 16 <20><>)
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>塞 crc <20><><EFBFBD><><E1A6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
stdcall [calc_crc32], 0,m0,ecx
mov edx,eax
;call print_z_struct
stdcall [deflate], my_strm, Z_FINISH ;Z_NO_FLUSH
;call print_z_struct
stdcall [deflate], my_strm, Z_FINISH
;ࠧ<><E0A0A7><EFBFBD><><E1A6A0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1024-[my_strm.avail_out]
mov ecx,1024
@@ -188,12 +180,6 @@ test_code:
;assert(ret != Z_STREAM_ERROR)
;while (strm.avail_out == 0)
;<3B><EFBFBD><E2A0A2> crc <20><><><E1A6A0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov ecx,[m1size]
sub ecx,4
add ecx,m1
mov [ecx],edx
;<3B><>ନ஢<E0ACA8><E0AEA2><EFBFBD><EFBFBD><><E2A5AA><EFBFBD> <20><><EFBFBD> <20>⮡ࠦ<E2AEA1><E0A0A6><EFBFBD><EFBFBD><><E1A6A0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;<3B> 16-<2D><><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><EFBFBD> ⮫쪮 <20><><EFBFBD> <20><EFBFBD><E0A8AC><EFBFBD>
mov ebx,[m1size]
@@ -229,7 +215,7 @@ align 4
add eax,2
stdcall [deflate_unpack],eax,m2size
mov [m2],eax ;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E1AFA0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov ecx,[m0size] ;;; ???
;;; mov ecx,[m0size] ;;; ???
mov [m2size],ecx
ret