forked from KolibriOS/kolibrios
fix r6854, optimize
git-svn-id: svn://kolibrios.org@6860 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
53c5e5426f
commit
69005f1f95
@ -1,7 +1,7 @@
|
|||||||
; trees.asm -- output deflated data using Huffman coding
|
; trees.asm -- output deflated data using Huffman coding
|
||||||
; Copyright (C) 1995-2012 Jean-loup Gailly
|
; Copyright (C) 1995-2012 Jean-loup Gailly
|
||||||
; detect_data_type() function provided freely by Cosmin Truta, 2006
|
; detect_data_type() function provided freely by Cosmin Truta, 2006
|
||||||
; For conditions of distribution and use, see copyright notice in zlib.h
|
; For conditions of distribution and use, see copyright notice in zlib.inc
|
||||||
|
|
||||||
; ALGORITHM
|
; ALGORITHM
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ else
|
|||||||
include 'trees.inc'
|
include 'trees.inc'
|
||||||
end if ;GEN_TREES_H
|
end if ;GEN_TREES_H
|
||||||
|
|
||||||
struct static_tree_desc ;_s
|
struct static_tree_desc
|
||||||
static_tree dd ? ;const ct_data * ;static tree or NULL
|
static_tree dd ? ;const ct_data * ;static tree or NULL
|
||||||
extra_bits dd ? ;const intf * ;extra bits for each code or NULL
|
extra_bits dd ? ;const intf * ;extra bits for each code or NULL
|
||||||
extra_base dd ? ;int ;base index for extra_bits
|
extra_base dd ? ;int ;base index for extra_bits
|
||||||
@ -324,7 +324,7 @@ end if ;(GEN_TREES_H) | !(STDC)
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
; Genererate the file trees.h describing the static trees.
|
; Genererate the file trees.inc describing the static trees.
|
||||||
|
|
||||||
;# define SEPARATOR(i, last, width) \
|
;# define SEPARATOR(i, last, width) \
|
||||||
; ((i) == (last)? "\n};\n\n" : \
|
; ((i) == (last)? "\n};\n\n" : \
|
||||||
@ -491,8 +491,7 @@ local .end0
|
|||||||
mov ebx,m
|
mov ebx,m
|
||||||
imul ebx,sizeof.ct_data
|
imul ebx,sizeof.ct_data
|
||||||
add ebx,tree
|
add ebx,tree
|
||||||
mov bx,word[ebx+Freq]
|
cmp ax,word[ebx+Freq]
|
||||||
cmp ax,bx
|
|
||||||
jl .end0
|
jl .end0
|
||||||
jne m_end
|
jne m_end
|
||||||
mov eax,n
|
mov eax,n
|
||||||
@ -528,10 +527,7 @@ pushad
|
|||||||
; Set j to the smallest of the two sons:
|
; Set j to the smallest of the two sons:
|
||||||
;;cmp esi,[edi+deflate_state.heap_len]
|
;;cmp esi,[edi+deflate_state.heap_len]
|
||||||
jge .end1 ;if (..<.. &&
|
jge .end1 ;if (..<.. &&
|
||||||
mov edx,esi
|
lea edx,[edi+4*esi+deflate_state.heap]
|
||||||
shl edx,2
|
|
||||||
add edx,edi
|
|
||||||
add edx,deflate_state.heap
|
|
||||||
smaller [tree], dword[edx+4], dword[edx], edi+deflate_state.depth, .end1
|
smaller [tree], dword[edx+4], dword[edx], edi+deflate_state.depth, .end1
|
||||||
inc esi
|
inc esi
|
||||||
.end1:
|
.end1:
|
||||||
@ -629,21 +625,20 @@ align 4
|
|||||||
@@:
|
@@:
|
||||||
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+4*eax+deflate_state.heap]
|
mov ecx,[edi+4*eax+deflate_state.heap]
|
||||||
;ecx = n
|
;ecx = n
|
||||||
mov edx,[tree]
|
mov edx,[tree]
|
||||||
movzx eax,word[edx+sizeof.ct_data*ecx+Dad]
|
movzx eax,word[edx+sizeof.ct_data*ecx+Dad]
|
||||||
movzx eax,word[edx+sizeof.ct_data*eax+Len]
|
movzx eax,word[edx+sizeof.ct_data*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]
|
cmp eax,[max_length]
|
||||||
cmp [bits],eax
|
|
||||||
jle @f ;if (..>..)
|
jle @f ;if (..>..)
|
||||||
|
mov eax,[max_length]
|
||||||
mov [bits],eax
|
mov [bits],eax
|
||||||
inc dword[overflow]
|
inc dword[overflow]
|
||||||
@@:
|
@@:
|
||||||
mov eax,[bits]
|
|
||||||
mov [edx+sizeof.ct_data*ecx+Len],ax
|
mov [edx+sizeof.ct_data*ecx+Len],ax
|
||||||
; We overwrite tree[n].Dad which is no longer needed
|
; We overwrite tree[n].Dad which is no longer needed
|
||||||
|
|
||||||
@ -668,16 +663,13 @@ align 4
|
|||||||
imul eax,esi
|
imul eax,esi
|
||||||
add [edi+deflate_state.opt_len],eax
|
add [edi+deflate_state.opt_len],eax
|
||||||
cmp dword[stree],0
|
cmp dword[stree],0
|
||||||
je @f ;if (..)
|
jne .cycle1 ;if (..)
|
||||||
movzx eax,word[f]
|
movzx eax,word[f]
|
||||||
mov esi,sizeof.ct_data
|
mov esi,[stree]
|
||||||
imul esi,ecx
|
movzx esi,word[esi+sizeof.ct_data*ecx+Len]
|
||||||
add esi,[stree]
|
|
||||||
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
|
||||||
@@:
|
|
||||||
jmp .cycle1
|
jmp .cycle1
|
||||||
align 4
|
align 4
|
||||||
.cycle1end:
|
.cycle1end:
|
||||||
@ -736,8 +728,10 @@ align 4
|
|||||||
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,edx ;esi = &tree[m]
|
||||||
mov eax,[bits]
|
mov eax,[bits]
|
||||||
cmp word[edx+sizeof.ct_data*esi+Len],ax
|
cmp word[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]
|
||||||
@ -974,10 +968,8 @@ align 4
|
|||||||
imul edx,sizeof.ct_data
|
imul edx,sizeof.ct_data
|
||||||
add edx,[tree]
|
add edx,[tree]
|
||||||
mov ax,word[edx+Freq]
|
mov ax,word[edx+Freq]
|
||||||
mov edx,ecx
|
mov edx,[tree]
|
||||||
imul edx,sizeof.ct_data
|
add ax,word[edx+sizeof.ct_data*ecx+Freq]
|
||||||
add edx,[tree]
|
|
||||||
add ax,word[edx+Freq]
|
|
||||||
mov edx,[node]
|
mov edx,[node]
|
||||||
imul edx,sizeof.ct_data
|
imul edx,sizeof.ct_data
|
||||||
add edx,[tree]
|
add edx,[tree]
|
||||||
|
Loading…
Reference in New Issue
Block a user