forked from KolibriOS/kolibrios
new version 'longest_match'
git-svn-id: svn://kolibrios.org@6799 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
755c9fe4d1
commit
ccedb4ca44
@ -162,8 +162,9 @@ if FASTEST eq 0
|
|||||||
push ebx
|
push ebx
|
||||||
mov ebx,[s+deflate_state.w_mask]
|
mov ebx,[s+deflate_state.w_mask]
|
||||||
and ebx,str
|
and ebx,str
|
||||||
|
shl ebx,2
|
||||||
add ebx,[s+deflate_state.prev]
|
add ebx,[s+deflate_state.prev]
|
||||||
mov byte[ebx],al
|
mov [ebx],eax
|
||||||
pop ebx
|
pop ebx
|
||||||
end if
|
end if
|
||||||
mov eax,[s+deflate_state.ins_h]
|
mov eax,[s+deflate_state.ins_h]
|
||||||
@ -179,13 +180,13 @@ end if
|
|||||||
|
|
||||||
macro CLEAR_HASH s
|
macro CLEAR_HASH s
|
||||||
{
|
{
|
||||||
|
;mov eax,[s+deflate_state.hash_size]
|
||||||
|
;dec eax
|
||||||
|
;shl eax,2
|
||||||
|
;add eax,[s+deflate_state.head]
|
||||||
|
;mov dword[eax],NIL
|
||||||
mov eax,[s+deflate_state.hash_size]
|
mov eax,[s+deflate_state.hash_size]
|
||||||
dec eax
|
;dec eax
|
||||||
shl eax,2
|
|
||||||
add eax,[s+deflate_state.head]
|
|
||||||
mov dword[eax],NIL
|
|
||||||
mov eax,[s+deflate_state.hash_size]
|
|
||||||
dec eax
|
|
||||||
shl eax,2 ;sizeof(*s.head)
|
shl eax,2 ;sizeof(*s.head)
|
||||||
stdcall zmemzero, [s+deflate_state.head], eax
|
stdcall zmemzero, [s+deflate_state.head], eax
|
||||||
}
|
}
|
||||||
@ -587,7 +588,6 @@ if GZIP eq 1
|
|||||||
end if
|
end if
|
||||||
mov dword[ebx+z_stream.adler],eax
|
mov dword[ebx+z_stream.adler],eax
|
||||||
mov dword[edi+deflate_state.last_flush],Z_NO_FLUSH
|
mov dword[edi+deflate_state.last_flush],Z_NO_FLUSH
|
||||||
|
|
||||||
stdcall _tr_init, edi
|
stdcall _tr_init, edi
|
||||||
|
|
||||||
mov eax,Z_OK
|
mov eax,Z_OK
|
||||||
@ -1925,6 +1925,8 @@ align 4
|
|||||||
sub ecx,edi
|
sub ecx,edi
|
||||||
jz @f
|
jz @f
|
||||||
repe cmpsb
|
repe cmpsb
|
||||||
|
dec edi
|
||||||
|
dec esi
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
mov eax,[edx+deflate_state.window_size]
|
mov eax,[edx+deflate_state.window_size]
|
||||||
@ -1968,6 +1970,7 @@ align 4
|
|||||||
dec dword[chain_length]
|
dec dword[chain_length]
|
||||||
cmp dword[chain_length],0
|
cmp dword[chain_length],0
|
||||||
jne .cycle0
|
jne .cycle0
|
||||||
|
align 4
|
||||||
.cycle0end: ;while (..>.. && ..!=0)
|
.cycle0end: ;while (..>.. && ..!=0)
|
||||||
|
|
||||||
mov eax,[edx+deflate_state.lookahead]
|
mov eax,[edx+deflate_state.lookahead]
|
||||||
@ -2281,6 +2284,7 @@ end if
|
|||||||
jge .cycle0end
|
jge .cycle0end
|
||||||
cmp dword[edx+z_stream.avail_in],0
|
cmp dword[edx+z_stream.avail_in],0
|
||||||
jne .cycle0
|
jne .cycle0
|
||||||
|
align 4
|
||||||
.cycle0end: ;while (..<.. && ..!=..)
|
.cycle0end: ;while (..<.. && ..!=..)
|
||||||
|
|
||||||
; If the WIN_INIT bytes after the end of the current data have never been
|
; If the WIN_INIT bytes after the end of the current data have never been
|
||||||
@ -2405,18 +2409,18 @@ 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
|
||||||
; to pending_buf_size, and each stored block has a 5 byte header:
|
; to pending_buf_size, and each stored block has a 5 byte header:
|
||||||
mov edi,[s]
|
mov edi,[s]
|
||||||
zlib_debug 'deflate_stored'
|
zlib_debug 'deflate_stored'
|
||||||
|
|
||||||
mov ecx,0xffff
|
mov ecx,0xffff
|
||||||
mov eax,[edi+deflate_state.pending_buf_size]
|
mov eax,[edi+deflate_state.pending_buf_size]
|
||||||
sub eax,5
|
sub eax,5
|
||||||
cmp ecx,eax
|
cmp ecx,eax
|
||||||
jle @f ;if (..>..)
|
jle .cycle0 ;if (..>..)
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
@@:
|
|
||||||
;ecx = max_block_size
|
;ecx = max_block_size
|
||||||
|
|
||||||
; Copy as much as possible from input to output:
|
; Copy as much as possible from input to output:
|
||||||
|
align 4
|
||||||
.cycle0: ;for (;;) {
|
.cycle0: ;for (;;) {
|
||||||
; Fill the window as much as possible:
|
; Fill the window as much as possible:
|
||||||
cmp dword[edi+deflate_state.lookahead],1
|
cmp dword[edi+deflate_state.lookahead],1
|
||||||
@ -2435,7 +2439,10 @@ zlib_debug 'deflate_stored'
|
|||||||
cmp dword[edi+deflate_state.lookahead],0
|
cmp dword[edi+deflate_state.lookahead],0
|
||||||
je .cycle0end ;if (..==0) break ;flush the current block
|
je .cycle0end ;if (..==0) break ;flush the current block
|
||||||
.end0:
|
.end0:
|
||||||
; Assert(s->block_start >= 0, "block gone");
|
cmp dword[edi+deflate_state.block_start],0
|
||||||
|
jge @f
|
||||||
|
zlib_assert 'block gone' ;Assert(..>=0)
|
||||||
|
@@:
|
||||||
|
|
||||||
mov eax,[edi+deflate_state.lookahead]
|
mov eax,[edi+deflate_state.lookahead]
|
||||||
add [edi+deflate_state.strstart],eax
|
add [edi+deflate_state.strstart],eax
|
||||||
@ -2823,6 +2830,7 @@ end if
|
|||||||
dec dword[edi+deflate_state.lookahead]
|
dec dword[edi+deflate_state.lookahead]
|
||||||
;.end4:
|
;.end4:
|
||||||
jmp .cycle0
|
jmp .cycle0
|
||||||
|
align 4
|
||||||
.cycle0end:
|
.cycle0end:
|
||||||
cmp dword[flush],Z_NO_FLUSH
|
cmp dword[flush],Z_NO_FLUSH
|
||||||
jne @f
|
jne @f
|
||||||
|
@ -46,7 +46,7 @@ FINISH_STATE equ 800
|
|||||||
; Stream status
|
; Stream status
|
||||||
|
|
||||||
; Data structure describing a single value and its code string.
|
; Data structure describing a single value and its code string.
|
||||||
struct ct_data ;ct_data_s
|
struct ct_data
|
||||||
fc dw ? ;union
|
fc dw ? ;union
|
||||||
;uint_16 freq ;frequency count
|
;uint_16 freq ;frequency count
|
||||||
;uint_16 code ;bit string
|
;uint_16 code ;bit string
|
||||||
@ -60,7 +60,7 @@ Code equ ct_data.fc ;.code
|
|||||||
Dad equ ct_data.dale ;.dad
|
Dad equ ct_data.dale ;.dad
|
||||||
Len equ ct_data.dale ;.len
|
Len equ ct_data.dale ;.len
|
||||||
|
|
||||||
struct tree_desc ;tree_desc_s
|
struct tree_desc
|
||||||
dyn_tree dd ? ;ct_data * ;the dynamic tree
|
dyn_tree dd ? ;ct_data * ;the dynamic tree
|
||||||
max_code dd ? ;int ;largest code with non zero frequency
|
max_code dd ? ;int ;largest code with non zero frequency
|
||||||
stat_desc dd ? ;static_tree_desc * ;the corresponding static tree
|
stat_desc dd ? ;static_tree_desc * ;the corresponding static tree
|
||||||
@ -80,6 +80,7 @@ struct deflate_state ;internal_state
|
|||||||
gzhead dd ? ;gz_headerp ;gzip header information to write
|
gzhead dd ? ;gz_headerp ;gzip header information to write
|
||||||
gzindex dd ? ;uInt ;where in extra, name, or comment
|
gzindex dd ? ;uInt ;where in extra, name, or comment
|
||||||
method db ? ;Byte ;can only be DEFLATED
|
method db ? ;Byte ;can only be DEFLATED
|
||||||
|
rb 3 ;for align
|
||||||
last_flush dd ? ;int ;value of flush param for previous deflate call
|
last_flush dd ? ;int ;value of flush param for previous deflate call
|
||||||
|
|
||||||
; used by deflate.asm:
|
; used by deflate.asm:
|
||||||
@ -171,7 +172,7 @@ struct deflate_state ;internal_state
|
|||||||
; The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
|
; The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
|
||||||
; The same heap array is used to build all trees.
|
; The same heap array is used to build all trees.
|
||||||
|
|
||||||
depth rb 2*L_CODES+1 ;uch[]
|
depth rb ((2*L_CODES+1)+3) and (not 3) ;uch[]
|
||||||
; Depth of each subtree used as tie breaker for trees of equal frequency
|
; Depth of each subtree used as tie breaker for trees of equal frequency
|
||||||
|
|
||||||
l_buf dd ? ;uchf * ;buffer for literals or lengths
|
l_buf dd ? ;uchf * ;buffer for literals or lengths
|
||||||
@ -237,9 +238,6 @@ deflate_state.max_insert_length equ deflate_state.max_lazy_match
|
|||||||
|
|
||||||
macro put_byte s, c
|
macro put_byte s, c
|
||||||
{
|
{
|
||||||
;xor eax,eax
|
|
||||||
;mov al,c
|
|
||||||
;zlib_debug '(%d)',eax
|
|
||||||
movzx eax,word[s+deflate_state.pending]
|
movzx eax,word[s+deflate_state.pending]
|
||||||
add eax,[s+deflate_state.pending_buf]
|
add eax,[s+deflate_state.pending_buf]
|
||||||
mov byte[eax],c
|
mov byte[eax],c
|
||||||
|
@ -386,7 +386,7 @@ endp
|
|||||||
; Initialize the tree data structures for a new zlib stream.
|
; Initialize the tree data structures for a new zlib stream.
|
||||||
|
|
||||||
;void (s)
|
;void (s)
|
||||||
; deflate_state* s;
|
; deflate_state* s
|
||||||
align 4
|
align 4
|
||||||
proc _tr_init uses eax edi, s:dword
|
proc _tr_init uses eax edi, s:dword
|
||||||
mov edi,[s]
|
mov edi,[s]
|
||||||
@ -425,7 +425,6 @@ endp
|
|||||||
; deflate_state* s
|
; deflate_state* s
|
||||||
align 4
|
align 4
|
||||||
proc init_block uses eax ecx edi, s:dword
|
proc init_block uses eax ecx edi, s:dword
|
||||||
; int n ;iterates over tree elements
|
|
||||||
mov edi,[s]
|
mov edi,[s]
|
||||||
|
|
||||||
; Initialize the trees.
|
; Initialize the trees.
|
||||||
@ -451,8 +450,7 @@ proc init_block uses eax ecx edi, s:dword
|
|||||||
add eax,sizeof.ct_data
|
add eax,sizeof.ct_data
|
||||||
loop @b
|
loop @b
|
||||||
|
|
||||||
mov ecx,sizeof.ct_data*END_BLOCK+deflate_state.dyn_ltree+Freq
|
mov word[edi+sizeof.ct_data*END_BLOCK+deflate_state.dyn_ltree+Freq],1
|
||||||
mov word[ecx+edi],1
|
|
||||||
mov dword[edi+deflate_state.static_len],0
|
mov dword[edi+deflate_state.static_len],0
|
||||||
mov dword[edi+deflate_state.opt_len],0
|
mov dword[edi+deflate_state.opt_len],0
|
||||||
mov dword[edi+deflate_state.matches],0
|
mov dword[edi+deflate_state.matches],0
|
||||||
@ -1357,13 +1355,11 @@ endl
|
|||||||
mov eax,edi
|
mov eax,edi
|
||||||
add eax,deflate_state.dyn_ltree
|
add eax,deflate_state.dyn_ltree
|
||||||
stdcall scan_tree, edi, eax, [edi+deflate_state.l_desc.max_code]
|
stdcall scan_tree, edi, eax, [edi+deflate_state.l_desc.max_code]
|
||||||
mov eax,edi
|
add eax,deflate_state.dyn_dtree-deflate_state.dyn_ltree
|
||||||
add eax,deflate_state.dyn_dtree
|
|
||||||
stdcall scan_tree, edi, eax, [edi+deflate_state.d_desc.max_code]
|
stdcall scan_tree, edi, eax, [edi+deflate_state.d_desc.max_code]
|
||||||
|
|
||||||
; Build the bit length tree:
|
; Build the bit length tree:
|
||||||
mov eax,edi
|
add eax,deflate_state.bl_desc-deflate_state.dyn_dtree
|
||||||
add eax,deflate_state.bl_desc
|
|
||||||
stdcall build_tree, edi, eax
|
stdcall build_tree, edi, eax
|
||||||
; opt_len now includes the length of the tree representations, except
|
; opt_len now includes the length of the tree representations, except
|
||||||
; the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
|
; the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
|
||||||
@ -1506,7 +1502,7 @@ endp
|
|||||||
; Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
|
; Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
|
||||||
|
|
||||||
;void (s)
|
;void (s)
|
||||||
; deflate_state* s;
|
; deflate_state* s
|
||||||
align 4
|
align 4
|
||||||
proc _tr_flush_bits, s:dword
|
proc _tr_flush_bits, s:dword
|
||||||
stdcall bi_flush, [s]
|
stdcall bi_flush, [s]
|
||||||
@ -1745,13 +1741,11 @@ proc _tr_tally uses ebx edi, s:dword, dist:dword, lc:dword
|
|||||||
add eax,LITERALS+1
|
add eax,LITERALS+1
|
||||||
imul eax,sizeof.ct_data
|
imul eax,sizeof.ct_data
|
||||||
add eax,edi
|
add eax,edi
|
||||||
add eax,deflate_state.dyn_ltree+Freq
|
inc word[eax+deflate_state.dyn_ltree+Freq]
|
||||||
inc word[eax]
|
|
||||||
d_code [dist]
|
d_code [dist]
|
||||||
imul eax,sizeof.ct_data
|
imul eax,sizeof.ct_data
|
||||||
add eax,edi
|
add eax,edi
|
||||||
add eax,deflate_state.dyn_dtree+Freq
|
inc word[eax+deflate_state.dyn_dtree+Freq]
|
||||||
inc word[eax]
|
|
||||||
.end0:
|
.end0:
|
||||||
|
|
||||||
if TRUNCATE_BLOCK eq 1
|
if TRUNCATE_BLOCK eq 1
|
||||||
@ -1795,7 +1789,7 @@ endp
|
|||||||
; Send the block data compressed using the given Huffman trees
|
; Send the block data compressed using the given Huffman trees
|
||||||
|
|
||||||
;void (s, ltree, dtree)
|
;void (s, ltree, dtree)
|
||||||
; deflate_state* s;
|
; deflate_state* s
|
||||||
; ct_data *ltree ;literal tree
|
; ct_data *ltree ;literal tree
|
||||||
; ct_data *dtree ;distance tree
|
; ct_data *dtree ;distance tree
|
||||||
align 4
|
align 4
|
||||||
@ -1952,7 +1946,7 @@ endl
|
|||||||
.end0:
|
.end0:
|
||||||
mov ecx,32
|
mov ecx,32
|
||||||
mov ebx,edi
|
mov ebx,edi
|
||||||
add ebx,deflate_state.dyn_ltree+Freq
|
add ebx,deflate_state.dyn_ltree+Freq+32*sizeof.ct_data
|
||||||
.cycle1:
|
.cycle1:
|
||||||
cmp ecx,LITERALS
|
cmp ecx,LITERALS
|
||||||
jge .cycle1end ;for (..;..<..;..,..)
|
jge .cycle1end ;for (..;..<..;..,..)
|
||||||
|
@ -3,7 +3,7 @@ include '../../../../proc32.inc'
|
|||||||
include '../../../../macros.inc'
|
include '../../../../macros.inc'
|
||||||
include '../../../../KOSfuncs.inc'
|
include '../../../../KOSfuncs.inc'
|
||||||
|
|
||||||
FASTEST equ 1
|
FASTEST equ 0
|
||||||
GEN_TREES_H equ 0
|
GEN_TREES_H equ 0
|
||||||
DEBUG equ 0
|
DEBUG equ 0
|
||||||
DYNAMIC_CRC_TABLE equ 1
|
DYNAMIC_CRC_TABLE equ 1
|
||||||
|
Loading…
Reference in New Issue
Block a user