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_zb db ' ZB_line',0
f_find_l db 'find_list',0 f_find_l db 'find_list',0
f_alloc_l db 'alloc_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 db 'ZB_fillTriangle...',0
f_fill_tr_nl db ' lines',0 f_fill_tr_nl db ' lines',0
f_fill_tr_nll db ' len',0 f_fill_tr_nll db ' len',0

View File

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

View File

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

View File

@ -341,6 +341,7 @@ end if
mov edi,eax ;edi = s mov edi,eax ;edi = s
mov [ebx+z_stream.state],edi mov [ebx+z_stream.state],edi
mov [edi+deflate_state.strm],ebx mov [edi+deflate_state.strm],ebx
mov dword[edi+deflate_state.status],INIT_STATE ;to pass state test in deflateReset()
mov eax,[wrap] mov eax,[wrap]
mov [edi+deflate_state.wrap],eax 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 ecx,[edx+deflate_state.pending]
mov eax,[ebx+z_stream.avail_out] mov eax,[ebx+z_stream.avail_out]
cmp ecx,eax cmp ecx,eax
jle @f ;if (..>..) jbe @f ;if (..>..)
mov ecx,eax mov ecx,eax
@@: @@:
test ecx,ecx test ecx,ecx
@ -1220,7 +1221,7 @@ end if
bswap ecx bswap ecx
put_dword edi, 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 mov [ebx+z_stream.adler],eax
.end2: .end2:
if GZIP eq 1 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] mov eax,[ebx+z_stream.avail_in]
cmp eax,[size] cmp eax,[size]
jle @f ;if (..>..) jbe @f ;if (..>..)
mov eax,[size] mov eax,[size]
@@: @@:
cmp eax,0 cmp eax,0

View File

@ -170,15 +170,7 @@ test_code:
mov [eax+z_stream.next_out],m1 ;ãáâ ­ ¢«¨¢ ¥¬ ¡ãä¥à ¤«ï ᦠâ¨ï mov [eax+z_stream.next_out],m1 ;ãáâ ­ ¢«¨¢ ¥¬ ¡ãä¥à ¤«ï ᦠâ¨ï
mov dword[eax+z_stream.avail_out],1024 ;à §¬¥à ¡ãä¥à  ¤«ï ᦠâ¨ï (¬ ªá¨¬ã¬ 16 Š¡) mov dword[eax+z_stream.avail_out],1024 ;à §¬¥à ¡ãä¥à  ¤«ï ᦠâ¨ï (¬ ªá¨¬ã¬ 16 Š¡)
;¢ëç¨á«ï¥¬ crc ¤«ï ᦨ¬ ¥¬ë¦ ¤ ­­ëå stdcall [deflate], my_strm, Z_FINISH
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
;à §¬¥à ᦠâëå ¤ ­­ëå: 1024-[my_strm.avail_out] ;à §¬¥à ᦠâëå ¤ ­­ëå: 1024-[my_strm.avail_out]
mov ecx,1024 mov ecx,1024
@ -188,12 +180,6 @@ test_code:
;assert(ret != Z_STREAM_ERROR) ;assert(ret != Z_STREAM_ERROR)
;while (strm.avail_out == 0) ;while (strm.avail_out == 0)
;áâ ¢¨¬ crc ­  ᦠâë¥ ¤ ­­ë¥
mov ecx,[m1size]
sub ecx,4
add ecx,m1
mov [ecx],edx
;ä®à¬¨à®¢ ­¨¥ ⥪áâ  ¤«ï ®â®¡à ¦¥­¨ï ᦠâëå ¤ ­­ëå ;ä®à¬¨à®¢ ­¨¥ ⥪áâ  ¤«ï ®â®¡à ¦¥­¨ï ᦠâëå ¤ ­­ëå
;¢ 16-à¨ç­®¬ ¢¨¤¥, ­ã¦­® ⮫쪮 ¤«ï ¯à¨¬¥à  ;¢ 16-à¨ç­®¬ ¢¨¤¥, ­ã¦­® ⮫쪮 ¤«ï ¯à¨¬¥à 
mov ebx,[m1size] mov ebx,[m1size]
@ -229,7 +215,7 @@ align 4
add eax,2 add eax,2
stdcall [deflate_unpack],eax,m2size stdcall [deflate_unpack],eax,m2size
mov [m2],eax ;§ ¯¨áì ­®¢ëå à á¯ ª®¢ ­­ëå ¤ ­­ëå mov [m2],eax ;§ ¯¨áì ­®¢ëå à á¯ ª®¢ ­­ëå ¤ ­­ëå
mov ecx,[m0size] ;;; ??? ;;; mov ecx,[m0size] ;;; ???
mov [m2size],ecx mov [m2size],ecx
ret ret