Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6854 → Rev 6853

/programs/fs/kfar/trunk/zlib/deflate.inc
275,12 → 275,9
;if (dist < 256) _dist_code[dist]
;else _dist_code[ 256+(dist>>7) ]
local .end0
if dist eq eax
else
mov eax,dist
end if
cmp eax,256
jb .end0
ja .end0
shr eax,7
add eax,256
.end0:
/programs/fs/kfar/trunk/zlib/trees.asm
566,8 → 566,10
; The length opt_len is updated; static_len is also updated if stree is
; not null.
 
;void (deflate_state* s, tree_desc* desc)
align 16
;void (s, desc)
; deflate_state* s
; tree_desc* desc ;the tree descriptor
align 4
proc gen_bitlen, s:dword, desc:dword
locals
tree dd ? ;ct_data* ;= desc.dyn_tree
622,19 → 624,19
mov eax,[edi+deflate_state.heap_max]
inc eax
mov [h],eax
jmp @f
align 4
.cycle1:
inc dword[h]
@@:
cmp dword[h],HEAP_SIZE
jge .cycle1end ;for (..;..<..;..)
mov eax,[h]
mov ecx,[edi+4*eax+deflate_state.heap]
mov ecx,[edi+deflate_state.heap+4*eax]
;ecx = n
mov edx,[tree]
movzx eax,word[edx+sizeof.ct_data*ecx+Dad]
movzx eax,word[edx+sizeof.ct_data*eax+Len]
mov eax,sizeof.ct_data
imul eax,ecx
add eax,[tree]
movzx eax,word[eax+Dad]
imul eax,sizeof.ct_data
add eax,[tree]
movzx eax,word[eax+Len]
inc eax
mov [bits],eax ;bits = tree[tree[n].Dad].Len + 1
mov eax,[max_length]
643,14 → 645,22
mov [bits],eax
inc dword[overflow]
@@:
mov eax,[bits]
mov [edx+sizeof.ct_data*ecx+Len],ax
mov esi,[bits]
mov eax,sizeof.ct_data
imul eax,ecx
add eax,[tree]
mov word[eax+Len],si
; We overwrite tree[n].Dad which is no longer needed
 
cmp ecx,[max_code]
jg .cycle1 ;if (..>..) continue ;not a leaf node
jle @f
inc dword[h]
jmp .cycle1 ;if (..>..) continue ;not a leaf node
@@:
 
inc word[edi+2*eax+deflate_state.bl_count]
mov eax,[bits]
shl eax,1 ;*= sizeof.uint_16
inc word[eax+edi+deflate_state.bl_count]
mov dword[xbits],0
cmp ecx,[base]
jl @f ;if (..>=..)
661,7 → 671,10
mov eax,[eax]
mov [xbits],eax
@@:
movzx eax,word[edx+sizeof.ct_data*ecx+Freq]
mov eax,sizeof.ct_data
imul eax,ecx
add eax,[tree]
movzx eax,word[eax+Freq]
mov [f],ax
mov esi,[bits]
add esi,[xbits]
672,12 → 685,13
movzx eax,word[f]
mov esi,sizeof.ct_data
imul esi,ecx
add esi,[tree] ;;;must be [stree] but don't work
add esi,[tree]
movzx esi,word[esi+Len]
add esi,[xbits]
imul eax,esi
add [edi+deflate_state.static_len],eax
@@:
inc dword[h]
jmp .cycle1
align 4
.cycle1end:
725,19 → 739,22
cmp dword[bits],0
je .end_f ;for (..;..!=0;..)
mov eax,[bits]
movzx ecx,word[edi+2*eax+deflate_state.bl_count]
shl eax,1 ;*= sizeof.dw
movzx ecx,word[eax+edi+deflate_state.bl_count]
.cycle4: ;while (..!=0)
test ecx,ecx
jz .cycle4end
cmp ecx,0
je .cycle4end
dec dword[h]
mov eax,[h]
mov eax,[edi+4*eax+deflate_state.heap]
mov eax,[edi+deflate_state.heap+4*eax]
mov [m],eax ;m = s.heap[--h]
cmp eax,[max_code]
jg .cycle4 ;if (..>..) continue
mov esi,[m]
imul esi,sizeof.ct_data
add esi,[tree] ;esi = &tree[m]
mov eax,[bits]
cmp word[edx+sizeof.ct_data*esi+Len],ax
cmp word[esi+Len],ax
je @f ;if (..!=..)
; Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
movzx ebx,word[esi+Len]
882,7 → 899,7
xor ecx,ecx
.cycle0: ;for (..;..<..;..)
cmp ecx,[elems]
jge .cycle1
jge .cycle0end
cmp word[edx+Freq],0
je @f ;if (..!=0)
inc dword[edi+deflate_state.heap_len]
898,6 → 915,8
add edx,sizeof.ct_data
inc ecx
jmp .cycle0
align 4
.cycle0end:
 
; 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
904,7 → 923,6
; possible code. So to avoid special checks later on we force at least
; two codes of non zero frequency.
 
align 4
.cycle1: ;while (..<..)
cmp dword[edi+deflate_state.heap_len],2
jge .cycle1end
942,7 → 960,7
; establish sub-heaps of increasing lengths:
 
mov ecx,[edi+deflate_state.heap_len]
sar ecx,1
shr ecx,1
.cycle2: ;for (..;..>=..;..)
cmp ecx,1
jl .cycle2end