small fixes

git-svn-id: svn://kolibrios.org@6863 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2017-02-14 08:45:25 +00:00
parent 568fb16110
commit 0c0f92cb4e

View File

@ -287,7 +287,7 @@ if FASTEST eq 1
@@: @@:
else else
cmp dword[level],Z_DEFAULT_COMPRESSION cmp dword[level],Z_DEFAULT_COMPRESSION
jne @f ;if (..==0) jne @f ;if (..==..)
mov dword[level],6 mov dword[level],6
@@: @@:
end if end if
@ -296,7 +296,6 @@ end if
jge @f ;if (..<0) ;suppress zlib wrapper jge @f ;if (..<0) ;suppress zlib wrapper
mov dword[wrap],0 mov dword[wrap],0
neg dword[windowBits] neg dword[windowBits]
inc dword[windowBits]
jmp .end1 jmp .end1
@@: @@:
if GZIP eq 1 if GZIP eq 1
@ -411,7 +410,6 @@ end if
jmp .end_f jmp .end_f
@@: @@:
mov eax,[edi+deflate_state.lit_bufsize] mov eax,[edi+deflate_state.lit_bufsize]
shr eax,1 ;/=sizeof(uint_16)
add eax,[overlay] add eax,[overlay]
mov [edi+deflate_state.d_buf],eax mov [edi+deflate_state.d_buf],eax
mov eax,[edi+deflate_state.lit_bufsize] mov eax,[edi+deflate_state.lit_bufsize]
@ -428,7 +426,6 @@ end if
stdcall deflateReset, ebx stdcall deflateReset, ebx
.end_f: .end_f:
zlib_debug 'deflateInit2_ strategy = %d',[strategy]
ret ret
endp endp
@ -628,7 +625,6 @@ endp
align 4 align 4
proc deflateReset uses ebx, strm:dword proc deflateReset uses ebx, strm:dword
mov ebx,[strm] mov ebx,[strm]
zlib_debug 'deflateReset'
stdcall deflateResetKeep, ebx stdcall deflateResetKeep, ebx
cmp eax,Z_OK cmp eax,Z_OK
jne @f ;if (..==Z_OK) jne @f ;if (..==Z_OK)
@ -765,7 +761,7 @@ if FASTEST eq 1
@@: @@:
else else
cmp dword[level],Z_DEFAULT_COMPRESSION cmp dword[level],Z_DEFAULT_COMPRESSION
jne @f ;if (..==0) jne @f ;if (..==..)
mov dword[level],6 mov dword[level],6
@@: @@:
end if end if
@ -857,63 +853,124 @@ endp
; upper bound of about 14% expansion does not seem onerous for output buffer ; upper bound of about 14% expansion does not seem onerous for output buffer
; allocation. ; allocation.
;uLong (strm, sourceLen) ;uLong (z_streamp strm, uLong sourceLen)
; z_streamp strm
; uLong sourceLen
align 4 align 4
proc deflateBound, strm:dword, sourceLen:dword proc deflateBound uses ebx edi, strm:dword, sourceLen:dword
; deflate_state *s; locals
; uLong complen, wraplen; complen dd ?
; Bytef *str; wraplen dd ?
zlib_debug 'deflateBound' endl
;edi = s
; conservative upper bound for compressed data ; conservative upper bound for compressed data
; complen = sourceLen + mov ebx,[sourceLen]
; ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; mov eax,ebx
add eax,7
shr eax,3
add eax,ebx
add ebx,63
shr ebx,6
lea eax,[eax+ebx+5]
mov [complen],eax
; if can't get parameters, return conservative bound plus zlib wrapper ; if can't get parameters, return conservative bound plus zlib wrapper
; if (strm == Z_NULL || strm->state == Z_NULL) mov eax,[strm]
; return complen + 6; cmp eax,Z_NULL
je .end0
mov edi,[eax+z_stream.state] ;s = strm.state
cmp edi,Z_NULL
jne @f
.end0: ;if (..==0 || ..==0)
mov eax,[complen]
add eax,6
jmp .end_f
@@:
; compute wrapper length ; compute wrapper length
; s = strm->state; mov ebx,[edi+deflate_state.wrap]
; switch (s->wrap) { cmp ebx,0
; case 0: /* raw deflate */ je .end1
; wraplen = 0; cmp ebx,1
; break; je .end2
; case 1: /* zlib wrapper */ cmp ebx,2
; wraplen = 6 + (s->strstart ? 4 : 0); je .end3
; break; jmp .end4
; case 2: /* gzip wrapper */ .end1: ;raw deflate
; wraplen = 18; mov dword[wraplen],0
; if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ jmp .end5
; if (s->gzhead->extra != Z_NULL) .end2: ;zlib wrapper
; wraplen += 2 + s->gzhead->extra_len; mov eax,[edi+deflate_state.strstart]
; str = s->gzhead->name; neg eax
; if (str != Z_NULL) sbb eax,eax
; do { and eax,4
; wraplen++; add eax,6
; } while (*str++); mov [wraplen],eax
; str = s->gzhead->comment; jmp .end5
; if (str != Z_NULL) .end3: ;gzip wrapper
; do { mov dword[wraplen],18
; wraplen++; cmp dword[edi+deflate_state.gzhead],Z_NULL ;user-supplied gzip header
; } while (*str++); je .end5
; if (s->gzhead->hcrc) mov eax,[edi+deflate_state.gzhead]
; wraplen += 2; cmp dword[eax+gz_header.extra],0
; } je @f
; break; mov eax,[edi+deflate_state.gzhead]
; default: /* for compiler happiness */ mov eax,[eax+gz_header.extra_len]
; wraplen = 6; add dword[wraplen],eax
; } add dword[wraplen],2
@@:
mov eax,[edi+deflate_state.gzhead]
mov eax,[eax+gz_header.name]
cmp eax,0
je @f
.cycle0: ;do
inc dword[wraplen]
movzx ebx,byte[eax]
inc eax
test ebx,ebx
jne .cycle0
@@:
mov eax,[edi+deflate_state.gzhead]
mov eax,[eax+gz_header.comment]
cmp eax,0
je @f
.cycle1: ;do
inc dword[wraplen]
movzx ebx,byte[eax]
inc eax
test ebx,ebx
jne .cycle1
@@:
mov eax,[edi+deflate_state.gzhead]
cmp dword[eax+gz_header.hcrc],0
je .end5
add dword[wraplen],2
jmp .end5
.end4: ;for compiler happiness
mov dword[wraplen],6
.end5:
; if not default parameters, return conservative bound ; if not default parameters, return conservative bound
; if (s->w_bits != 15 || s->hash_bits != 8 + 7) cmp dword[edi+deflate_state.w_bits],15
; return complen + wraplen; jne .end6
cmp dword[edi+deflate_state.hash_bits],8+7
je @f
.end6: ;if (s->w_bits !=.. || s->hash_bits !=..)
mov eax,[complen]
add eax,[wraplen]
jmp .end_f
@@:
; default settings: return tight bound for that case ; default settings: return tight bound for that case
; return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + mov eax,[sourceLen]
; (sourceLen >> 25) + 13 - 6 + wraplen; mov ebx,eax
shr ebx,12
add ebx,eax
mov edi,eax
shr edi,14
add ebx,edi
shr eax,25
add ebx,[wraplen]
lea eax,[eax+ebx+7]
.end_f: .end_f:
ret ret
endp endp
@ -923,11 +980,9 @@ endp
; IN assertion: the stream state is correct and there is enough room in ; IN assertion: the stream state is correct and there is enough room in
; pending_buf. ; pending_buf.
;void (s, b) ;void (deflate_state *s, uInt b)
; deflate_state *s
; uInt b
align 4 align 4
proc putShortMSB uses ebx ecx, s:dword, b:dword proc putShortMSB uses eax ebx ecx, s:dword, b:dword
mov ebx,[s] mov ebx,[s]
mov ecx,[b] mov ecx,[b]
put_byte ebx, ch put_byte ebx, ch
@ -2004,7 +2059,6 @@ else ;FASTEST
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; Optimized version for FASTEST only ; Optimized version for FASTEST only
mov edx,[s] mov edx,[s]
zlib_debug 'longest_match'
; The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. ; The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
; It is easy to get rid of this optimization if necessary. ; It is easy to get rid of this optimization if necessary.
@ -2244,7 +2298,7 @@ end if
mov eax,[edi+deflate_state.lookahead] mov eax,[edi+deflate_state.lookahead]
add eax,[edi+deflate_state.insert] add eax,[edi+deflate_state.insert]
cmp eax,MIN_MATCH cmp eax,MIN_MATCH
jl .end1 ;if (..>=..) jb .end1 ;if (..>=..)
mov esi,[edi+deflate_state.strstart] mov esi,[edi+deflate_state.strstart]
sub esi,[edi+deflate_state.insert] sub esi,[edi+deflate_state.insert]
;esi = str ;esi = str
@ -2414,9 +2468,7 @@ end if
; NOTE: this function should be optimized to avoid extra copying from ; NOTE: this function should be optimized to avoid extra copying from
; window to pending_buf. ; window to pending_buf.
;block_state (s, flush) ;block_state (deflate_state *s, int flush)
; deflate_state *s
; int flush
align 4 align 4
proc deflate_stored uses ebx ecx edi, s:dword, flush:dword proc deflate_stored uses ebx ecx edi, s:dword, flush:dword
; Stored blocks are limited to 0xffff bytes, pending_buf is limited ; Stored blocks are limited to 0xffff bytes, pending_buf is limited