forked from KolibriOS/kolibrios
small fixes & optimize
git-svn-id: svn://kolibrios.org@6819 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
88ca371b1a
commit
0b7080c6d1
@ -400,8 +400,7 @@ end if
|
|||||||
cmp dword[edi+deflate_state.head],Z_NULL
|
cmp dword[edi+deflate_state.head],Z_NULL
|
||||||
je .end3
|
je .end3
|
||||||
cmp dword[edi+deflate_state.pending_buf],Z_NULL
|
cmp dword[edi+deflate_state.pending_buf],Z_NULL
|
||||||
je .end3
|
jne @f
|
||||||
jmp @f
|
|
||||||
.end3: ;if (..==0 || ..==0 || ..==0 || ..==0)
|
.end3: ;if (..==0 || ..==0 || ..==0 || ..==0)
|
||||||
mov dword[edi+deflate_state.status],FINISH_STATE
|
mov dword[edi+deflate_state.status],FINISH_STATE
|
||||||
ERR_MSG Z_MEM_ERROR
|
ERR_MSG Z_MEM_ERROR
|
||||||
@ -438,9 +437,8 @@ endp
|
|||||||
; const Bytef *dictionary
|
; const Bytef *dictionary
|
||||||
; uInt dictLength
|
; uInt dictLength
|
||||||
align 4
|
align 4
|
||||||
proc deflateSetDictionary uses ebx edi, strm:dword, dictionary:dword, dictLength:dword
|
proc deflateSetDictionary uses ebx ecx edx edi esi, strm:dword, dictionary:dword, dictLength:dword
|
||||||
locals
|
locals
|
||||||
; uInt str, n;
|
|
||||||
wrap dd ? ;int
|
wrap dd ? ;int
|
||||||
avail dd ? ;unsigned
|
avail dd ? ;unsigned
|
||||||
next dd ? ;unsigned char*
|
next dd ? ;unsigned char*
|
||||||
@ -452,8 +450,7 @@ endl
|
|||||||
cmp edi,Z_NULL
|
cmp edi,Z_NULL
|
||||||
je @f
|
je @f
|
||||||
cmp dword[dictionary],Z_NULL
|
cmp dword[dictionary],Z_NULL
|
||||||
je @f ;if (..==0 || ..==0 || ..==0)
|
jne .end0 ;if (..==0 || ..==0 || ..==0)
|
||||||
jmp .end0
|
|
||||||
@@:
|
@@:
|
||||||
mov eax,Z_STREAM_ERROR
|
mov eax,Z_STREAM_ERROR
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
@ -486,40 +483,71 @@ endl
|
|||||||
mov eax,[edi+deflate_state.w_size]
|
mov eax,[edi+deflate_state.w_size]
|
||||||
cmp [dictLength],eax
|
cmp [dictLength],eax
|
||||||
jl .end2 ;if (..>=..)
|
jl .end2 ;if (..>=..)
|
||||||
; if (wrap == 0) { /* already empty otherwise */
|
cmp dword[wrap],0
|
||||||
; CLEAR_HASH(s);
|
jne @f ;if (..==0) ;already empty otherwise
|
||||||
; s->strstart = 0;
|
CLEAR_HASH edi
|
||||||
; s->block_start = 0L;
|
mov dword[edi+deflate_state.strstart],0
|
||||||
; s->insert = 0;
|
mov dword[edi+deflate_state.block_start],0
|
||||||
; }
|
mov dword[edi+deflate_state.insert],0
|
||||||
; dictionary += dictLength - s->w_size; /* use the tail */
|
@@:
|
||||||
|
mov eax,[dictLength]
|
||||||
|
sub eax,[edi+deflate_state.w_size]
|
||||||
|
add [dictionary],eax ;use the tail
|
||||||
mov eax,[edi+deflate_state.w_size]
|
mov eax,[edi+deflate_state.w_size]
|
||||||
mov [dictLength],eax
|
mov [dictLength],eax
|
||||||
.end2:
|
.end2:
|
||||||
|
|
||||||
; insert dictionary into window and hash
|
; insert dictionary into window and hash
|
||||||
; avail = strm->avail_in;
|
mov eax,[ebx+z_stream.avail_in]
|
||||||
; next = strm->next_in;
|
mov [avail],eax
|
||||||
; strm->avail_in = dictLength;
|
mov eax,[ebx+z_stream.next_in]
|
||||||
; strm->next_in = (z_const Bytef *)dictionary;
|
mov [next],eax
|
||||||
; fill_window(s);
|
mov eax,[dictLength]
|
||||||
; while (s->lookahead >= MIN_MATCH) {
|
mov [ebx+z_stream.avail_in],eax
|
||||||
; str = s->strstart;
|
mov eax,[dictionary]
|
||||||
; n = s->lookahead - (MIN_MATCH-1);
|
mov [ebx+z_stream.next_in],eax
|
||||||
; do {
|
stdcall fill_window, edi
|
||||||
; UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
|
.cycle0: ;while (..>=..)
|
||||||
|
mov ecx,[edi+deflate_state.lookahead]
|
||||||
|
cmp ecx,MIN_MATCH
|
||||||
|
jl .cycle0end
|
||||||
|
mov esi,[edi+deflate_state.strstart]
|
||||||
|
;esi = str
|
||||||
|
sub ecx,MIN_MATCH-1
|
||||||
|
.cycle1: ;do
|
||||||
|
mov eax,[edi+deflate_state.window]
|
||||||
|
add eax,esi
|
||||||
|
add eax,MIN_MATCH-1
|
||||||
|
movzx eax,byte[eax]
|
||||||
|
UPDATE_HASH edi, [edi+deflate_state.ins_h], eax
|
||||||
if FASTEST eq 0
|
if FASTEST eq 0
|
||||||
; s->prev[str & s->w_mask] = s->head[s->ins_h];
|
mov edx,[edi+deflate_state.ins_h]
|
||||||
|
shl edx,2
|
||||||
|
add edx,[edi+deflate_state.head]
|
||||||
|
mov edx,[edx] ;edx = s.head[s.ins_h]
|
||||||
|
mov eax,esi
|
||||||
|
and eax,[edi+deflate_state.w_mask]
|
||||||
|
shl eax,2
|
||||||
|
add eax,[edi+deflate_state.prev]
|
||||||
|
mov [eax],edx
|
||||||
end if
|
end if
|
||||||
; s->head[s->ins_h] = (Pos)str;
|
mov edx,[edi+deflate_state.ins_h]
|
||||||
; str++;
|
shl edx,2
|
||||||
; } while (--n);
|
add edx,[edi+deflate_state.head]
|
||||||
; s->strstart = str;
|
mov [edx],esi ;s.head[s.ins_h] = str
|
||||||
; s->lookahead = MIN_MATCH-1;
|
inc esi
|
||||||
; fill_window(s);
|
dec ecx
|
||||||
; }
|
jnz .cycle1 ;while (--..)
|
||||||
; s->strstart += s->lookahead;
|
mov [edi+deflate_state.strstart],esi
|
||||||
; s->block_start = (long)s->strstart;
|
mov [edi+deflate_state.lookahead],MIN_MATCH-1
|
||||||
|
stdcall fill_window, edi
|
||||||
|
jmp .cycle0
|
||||||
|
align 4
|
||||||
|
.cycle0end:
|
||||||
|
mov eax,[edi+deflate_state.strstart]
|
||||||
|
add eax,[edi+deflate_state.lookahead]
|
||||||
|
mov [edi+deflate_state.strstart],eax
|
||||||
|
mov [edi+deflate_state.block_start],eax
|
||||||
mov eax,[edi+deflate_state.lookahead]
|
mov eax,[edi+deflate_state.lookahead]
|
||||||
mov [edi+deflate_state.insert],eax
|
mov [edi+deflate_state.insert],eax
|
||||||
mov dword[edi+deflate_state.lookahead],0
|
mov dword[edi+deflate_state.lookahead],0
|
||||||
@ -552,8 +580,7 @@ proc deflateResetKeep uses ebx edi, strm:dword
|
|||||||
cmp dword[ebx+z_stream.zalloc],0
|
cmp dword[ebx+z_stream.zalloc],0
|
||||||
je @f
|
je @f
|
||||||
cmp dword[ebx+z_stream.zfree],0
|
cmp dword[ebx+z_stream.zfree],0
|
||||||
je @f ;if (..==0 || ..==0 || ..==0 || ..==0)
|
jne .end0 ;if (..==0 || ..==0 || ..==0 || ..==0)
|
||||||
jmp .end0
|
|
||||||
@@:
|
@@:
|
||||||
mov eax,Z_STREAM_ERROR
|
mov eax,Z_STREAM_ERROR
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
@ -570,8 +597,7 @@ proc deflateResetKeep uses ebx edi, strm:dword
|
|||||||
|
|
||||||
cmp dword[edi+deflate_state.wrap],0
|
cmp dword[edi+deflate_state.wrap],0
|
||||||
jge @f ;if (..<0)
|
jge @f ;if (..<0)
|
||||||
neg dword[edi+deflate_state.wrap]
|
neg dword[edi+deflate_state.wrap] ;was made negative by deflate(..., Z_FINISH)
|
||||||
inc dword[edi+deflate_state.wrap] ;was made negative by deflate(..., Z_FINISH)
|
|
||||||
@@:
|
@@:
|
||||||
mov eax,BUSY_STATE
|
mov eax,BUSY_STATE
|
||||||
cmp dword[edi+deflate_state.wrap],0
|
cmp dword[edi+deflate_state.wrap],0
|
||||||
@ -1510,17 +1536,15 @@ end if
|
|||||||
; If avail_out is zero, the application will call deflate again
|
; If avail_out is zero, the application will call deflate again
|
||||||
; to flush the rest.
|
; to flush the rest.
|
||||||
|
|
||||||
cmp dword[edi+deflate_state.pending],0
|
cmp dword[edi+deflate_state.wrap],0
|
||||||
jle @f ;if (..>0) ;write the trailer only once!
|
jle @f ;if (..>0) ;write the trailer only once!
|
||||||
neg dword[edi+deflate_state.pending]
|
neg dword[edi+deflate_state.wrap]
|
||||||
inc dword[edi+deflate_state.pending]
|
|
||||||
@@:
|
@@:
|
||||||
mov eax,Z_OK
|
mov eax,Z_OK
|
||||||
cmp dword[edi+deflate_state.pending],0
|
cmp dword[edi+deflate_state.pending],0
|
||||||
je .end_f
|
jne .end_f
|
||||||
mov eax,Z_STREAM_END
|
mov eax,Z_STREAM_END
|
||||||
.end_f:
|
.end_f:
|
||||||
zlib_debug ' deflate.ret = %d',eax
|
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
@ -1731,7 +1755,6 @@ end if
|
|||||||
add [ebx+z_stream.total_in],eax
|
add [ebx+z_stream.total_in],eax
|
||||||
|
|
||||||
.end_f:
|
.end_f:
|
||||||
;zlib_debug ' read_buf.ret = %d',eax
|
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
@ -1968,8 +1991,7 @@ align 4
|
|||||||
cmp eax,[limit]
|
cmp eax,[limit]
|
||||||
jle .cycle0end
|
jle .cycle0end
|
||||||
dec dword[chain_length]
|
dec dword[chain_length]
|
||||||
cmp dword[chain_length],0
|
jnz .cycle0
|
||||||
jne .cycle0
|
|
||||||
align 4
|
align 4
|
||||||
.cycle0end: ;while (..>.. && ..!=0)
|
.cycle0end: ;while (..>.. && ..!=0)
|
||||||
|
|
||||||
@ -2796,6 +2818,7 @@ end if
|
|||||||
je .cycle0 ;if (..)
|
je .cycle0 ;if (..)
|
||||||
FLUSH_BLOCK edi, 0
|
FLUSH_BLOCK edi, 0
|
||||||
jmp .cycle0
|
jmp .cycle0
|
||||||
|
align 4
|
||||||
.end2: ;else if (..)
|
.end2: ;else if (..)
|
||||||
cmp dword[edi+deflate_state.match_available],0
|
cmp dword[edi+deflate_state.match_available],0
|
||||||
je .end3
|
je .end3
|
||||||
@ -2820,7 +2843,7 @@ end if
|
|||||||
jne .cycle0 ;if (..==0) return ..
|
jne .cycle0 ;if (..==0) return ..
|
||||||
mov eax,need_more
|
mov eax,need_more
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
jmp .cycle0 ;.end4
|
align 4
|
||||||
.end3: ;else
|
.end3: ;else
|
||||||
; There is no previous match to compare with, wait for
|
; There is no previous match to compare with, wait for
|
||||||
; the next step to decide.
|
; the next step to decide.
|
||||||
@ -2828,7 +2851,6 @@ end if
|
|||||||
mov dword[edi+deflate_state.match_available],1
|
mov dword[edi+deflate_state.match_available],1
|
||||||
inc dword[edi+deflate_state.strstart]
|
inc dword[edi+deflate_state.strstart]
|
||||||
dec dword[edi+deflate_state.lookahead]
|
dec dword[edi+deflate_state.lookahead]
|
||||||
;.end4:
|
|
||||||
jmp .cycle0
|
jmp .cycle0
|
||||||
align 4
|
align 4
|
||||||
.cycle0end:
|
.cycle0end:
|
||||||
@ -2931,7 +2953,7 @@ align 4
|
|||||||
mov [edx+deflate_state.match_length],edi
|
mov [edx+deflate_state.match_length],edi
|
||||||
mov eax,[edx+deflate_state.lookahead]
|
mov eax,[edx+deflate_state.lookahead]
|
||||||
cmp [edx+deflate_state.match_length],eax
|
cmp [edx+deflate_state.match_length],eax
|
||||||
jle .end2
|
jle .end2 ;if (..>..)
|
||||||
mov [edx+deflate_state.match_length],eax
|
mov [edx+deflate_state.match_length],eax
|
||||||
.end2:
|
.end2:
|
||||||
mov eax,[edx+deflate_state.window_size]
|
mov eax,[edx+deflate_state.window_size]
|
||||||
@ -3031,9 +3053,8 @@ align 4
|
|||||||
dec dword[edi+deflate_state.lookahead]
|
dec dword[edi+deflate_state.lookahead]
|
||||||
inc dword[edi+deflate_state.strstart]
|
inc dword[edi+deflate_state.strstart]
|
||||||
cmp dword[bflush],0
|
cmp dword[bflush],0
|
||||||
je @f ;if (..)
|
je .cycle0 ;if (..)
|
||||||
FLUSH_BLOCK edi, 0
|
FLUSH_BLOCK edi, 0
|
||||||
@@:
|
|
||||||
jmp .cycle0
|
jmp .cycle0
|
||||||
align 4
|
align 4
|
||||||
.cycle0end:
|
.cycle0end:
|
||||||
|
Loading…
Reference in New Issue
Block a user