forked from KolibriOS/kolibrios
fix r6851, optimize
git-svn-id: svn://kolibrios.org@6854 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
be199bc49c
commit
5f948ae4c6
@ -275,9 +275,12 @@ macro d_code dist
|
|||||||
;if (dist < 256) _dist_code[dist]
|
;if (dist < 256) _dist_code[dist]
|
||||||
;else _dist_code[ 256+(dist>>7) ]
|
;else _dist_code[ 256+(dist>>7) ]
|
||||||
local .end0
|
local .end0
|
||||||
|
if dist eq eax
|
||||||
|
else
|
||||||
mov eax,dist
|
mov eax,dist
|
||||||
|
end if
|
||||||
cmp eax,256
|
cmp eax,256
|
||||||
ja .end0
|
jb .end0
|
||||||
shr eax,7
|
shr eax,7
|
||||||
add eax,256
|
add eax,256
|
||||||
.end0:
|
.end0:
|
||||||
|
@ -566,10 +566,8 @@ endp
|
|||||||
; The length opt_len is updated; static_len is also updated if stree is
|
; The length opt_len is updated; static_len is also updated if stree is
|
||||||
; not null.
|
; not null.
|
||||||
|
|
||||||
;void (s, desc)
|
;void (deflate_state* s, tree_desc* desc)
|
||||||
; deflate_state* s
|
align 16
|
||||||
; tree_desc* desc ;the tree descriptor
|
|
||||||
align 4
|
|
||||||
proc gen_bitlen, s:dword, desc:dword
|
proc gen_bitlen, s:dword, desc:dword
|
||||||
locals
|
locals
|
||||||
tree dd ? ;ct_data* ;= desc.dyn_tree
|
tree dd ? ;ct_data* ;= desc.dyn_tree
|
||||||
@ -624,19 +622,19 @@ align 4
|
|||||||
mov eax,[edi+deflate_state.heap_max]
|
mov eax,[edi+deflate_state.heap_max]
|
||||||
inc eax
|
inc eax
|
||||||
mov [h],eax
|
mov [h],eax
|
||||||
|
jmp @f
|
||||||
|
align 4
|
||||||
.cycle1:
|
.cycle1:
|
||||||
|
inc dword[h]
|
||||||
|
@@:
|
||||||
cmp dword[h],HEAP_SIZE
|
cmp dword[h],HEAP_SIZE
|
||||||
jge .cycle1end ;for (..;..<..;..)
|
jge .cycle1end ;for (..;..<..;..)
|
||||||
mov eax,[h]
|
mov eax,[h]
|
||||||
mov ecx,[edi+deflate_state.heap+4*eax]
|
mov ecx,[edi+4*eax+deflate_state.heap]
|
||||||
;ecx = n
|
;ecx = n
|
||||||
mov eax,sizeof.ct_data
|
mov edx,[tree]
|
||||||
imul eax,ecx
|
movzx eax,word[edx+sizeof.ct_data*ecx+Dad]
|
||||||
add eax,[tree]
|
movzx eax,word[edx+sizeof.ct_data*eax+Len]
|
||||||
movzx eax,word[eax+Dad]
|
|
||||||
imul eax,sizeof.ct_data
|
|
||||||
add eax,[tree]
|
|
||||||
movzx eax,word[eax+Len]
|
|
||||||
inc eax
|
inc eax
|
||||||
mov [bits],eax ;bits = tree[tree[n].Dad].Len + 1
|
mov [bits],eax ;bits = tree[tree[n].Dad].Len + 1
|
||||||
mov eax,[max_length]
|
mov eax,[max_length]
|
||||||
@ -645,22 +643,14 @@ align 4
|
|||||||
mov [bits],eax
|
mov [bits],eax
|
||||||
inc dword[overflow]
|
inc dword[overflow]
|
||||||
@@:
|
@@:
|
||||||
mov esi,[bits]
|
mov eax,[bits]
|
||||||
mov eax,sizeof.ct_data
|
mov [edx+sizeof.ct_data*ecx+Len],ax
|
||||||
imul eax,ecx
|
|
||||||
add eax,[tree]
|
|
||||||
mov word[eax+Len],si
|
|
||||||
; We overwrite tree[n].Dad which is no longer needed
|
; We overwrite tree[n].Dad which is no longer needed
|
||||||
|
|
||||||
cmp ecx,[max_code]
|
cmp ecx,[max_code]
|
||||||
jle @f
|
jg .cycle1 ;if (..>..) continue ;not a leaf node
|
||||||
inc dword[h]
|
|
||||||
jmp .cycle1 ;if (..>..) continue ;not a leaf node
|
|
||||||
@@:
|
|
||||||
|
|
||||||
mov eax,[bits]
|
inc word[edi+2*eax+deflate_state.bl_count]
|
||||||
shl eax,1 ;*= sizeof.uint_16
|
|
||||||
inc word[eax+edi+deflate_state.bl_count]
|
|
||||||
mov dword[xbits],0
|
mov dword[xbits],0
|
||||||
cmp ecx,[base]
|
cmp ecx,[base]
|
||||||
jl @f ;if (..>=..)
|
jl @f ;if (..>=..)
|
||||||
@ -671,10 +661,7 @@ align 4
|
|||||||
mov eax,[eax]
|
mov eax,[eax]
|
||||||
mov [xbits],eax
|
mov [xbits],eax
|
||||||
@@:
|
@@:
|
||||||
mov eax,sizeof.ct_data
|
movzx eax,word[edx+sizeof.ct_data*ecx+Freq]
|
||||||
imul eax,ecx
|
|
||||||
add eax,[tree]
|
|
||||||
movzx eax,word[eax+Freq]
|
|
||||||
mov [f],ax
|
mov [f],ax
|
||||||
mov esi,[bits]
|
mov esi,[bits]
|
||||||
add esi,[xbits]
|
add esi,[xbits]
|
||||||
@ -685,13 +672,12 @@ align 4
|
|||||||
movzx eax,word[f]
|
movzx eax,word[f]
|
||||||
mov esi,sizeof.ct_data
|
mov esi,sizeof.ct_data
|
||||||
imul esi,ecx
|
imul esi,ecx
|
||||||
add esi,[tree]
|
add esi,[tree] ;;;must be [stree] but don't work
|
||||||
movzx esi,word[esi+Len]
|
movzx esi,word[esi+Len]
|
||||||
add esi,[xbits]
|
add esi,[xbits]
|
||||||
imul eax,esi
|
imul eax,esi
|
||||||
add [edi+deflate_state.static_len],eax
|
add [edi+deflate_state.static_len],eax
|
||||||
@@:
|
@@:
|
||||||
inc dword[h]
|
|
||||||
jmp .cycle1
|
jmp .cycle1
|
||||||
align 4
|
align 4
|
||||||
.cycle1end:
|
.cycle1end:
|
||||||
@ -739,22 +725,19 @@ align 4
|
|||||||
cmp dword[bits],0
|
cmp dword[bits],0
|
||||||
je .end_f ;for (..;..!=0;..)
|
je .end_f ;for (..;..!=0;..)
|
||||||
mov eax,[bits]
|
mov eax,[bits]
|
||||||
shl eax,1 ;*= sizeof.dw
|
movzx ecx,word[edi+2*eax+deflate_state.bl_count]
|
||||||
movzx ecx,word[eax+edi+deflate_state.bl_count]
|
|
||||||
.cycle4: ;while (..!=0)
|
.cycle4: ;while (..!=0)
|
||||||
cmp ecx,0
|
test ecx,ecx
|
||||||
je .cycle4end
|
jz .cycle4end
|
||||||
dec dword[h]
|
dec dword[h]
|
||||||
mov eax,[h]
|
mov eax,[h]
|
||||||
mov eax,[edi+deflate_state.heap+4*eax]
|
mov eax,[edi+4*eax+deflate_state.heap]
|
||||||
mov [m],eax ;m = s.heap[--h]
|
mov [m],eax ;m = s.heap[--h]
|
||||||
cmp eax,[max_code]
|
cmp eax,[max_code]
|
||||||
jg .cycle4 ;if (..>..) continue
|
jg .cycle4 ;if (..>..) continue
|
||||||
mov esi,[m]
|
mov esi,[m]
|
||||||
imul esi,sizeof.ct_data
|
|
||||||
add esi,[tree] ;esi = &tree[m]
|
|
||||||
mov eax,[bits]
|
mov eax,[bits]
|
||||||
cmp word[esi+Len],ax
|
cmp word[edx+sizeof.ct_data*esi+Len],ax
|
||||||
je @f ;if (..!=..)
|
je @f ;if (..!=..)
|
||||||
; Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
|
; Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
|
||||||
movzx ebx,word[esi+Len]
|
movzx ebx,word[esi+Len]
|
||||||
@ -899,7 +882,7 @@ endl
|
|||||||
xor ecx,ecx
|
xor ecx,ecx
|
||||||
.cycle0: ;for (..;..<..;..)
|
.cycle0: ;for (..;..<..;..)
|
||||||
cmp ecx,[elems]
|
cmp ecx,[elems]
|
||||||
jge .cycle0end
|
jge .cycle1
|
||||||
cmp word[edx+Freq],0
|
cmp word[edx+Freq],0
|
||||||
je @f ;if (..!=0)
|
je @f ;if (..!=0)
|
||||||
inc dword[edi+deflate_state.heap_len]
|
inc dword[edi+deflate_state.heap_len]
|
||||||
@ -915,14 +898,13 @@ align 4
|
|||||||
add edx,sizeof.ct_data
|
add edx,sizeof.ct_data
|
||||||
inc ecx
|
inc ecx
|
||||||
jmp .cycle0
|
jmp .cycle0
|
||||||
align 4
|
|
||||||
.cycle0end:
|
|
||||||
|
|
||||||
; The pkzip format requires that at least one distance code exists,
|
; The pkzip format requires that at least one distance code exists,
|
||||||
; and that at least one bit should be sent even if there is only one
|
; and that at least one bit should be sent even if there is only one
|
||||||
; possible code. So to avoid special checks later on we force at least
|
; possible code. So to avoid special checks later on we force at least
|
||||||
; two codes of non zero frequency.
|
; two codes of non zero frequency.
|
||||||
|
|
||||||
|
align 4
|
||||||
.cycle1: ;while (..<..)
|
.cycle1: ;while (..<..)
|
||||||
cmp dword[edi+deflate_state.heap_len],2
|
cmp dword[edi+deflate_state.heap_len],2
|
||||||
jge .cycle1end
|
jge .cycle1end
|
||||||
@ -960,7 +942,7 @@ align 4
|
|||||||
; establish sub-heaps of increasing lengths:
|
; establish sub-heaps of increasing lengths:
|
||||||
|
|
||||||
mov ecx,[edi+deflate_state.heap_len]
|
mov ecx,[edi+deflate_state.heap_len]
|
||||||
shr ecx,1
|
sar ecx,1
|
||||||
.cycle2: ;for (..;..>=..;..)
|
.cycle2: ;for (..;..>=..;..)
|
||||||
cmp ecx,1
|
cmp ecx,1
|
||||||
jl .cycle2end
|
jl .cycle2end
|
||||||
|
Loading…
Reference in New Issue
Block a user