Subversion Repositories Kolibri OS

Rev

Rev 6797 | Rev 6813 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6797 Rev 6799
Line 384... Line 384...
384
 
384
 
385
; ===========================================================================
385
; ===========================================================================
Line 386... Line 386...
386
; Initialize the tree data structures for a new zlib stream.
386
; Initialize the tree data structures for a new zlib stream.
387
 
387
 
388
;void (s)
388
;void (s)
389
;    deflate_state* s;
389
;    deflate_state* s
390
align 4
390
align 4
391
proc _tr_init uses eax edi, s:dword
391
proc _tr_init uses eax edi, s:dword
392
	mov edi,[s]
392
	mov edi,[s]
Line 423... Line 423...
423
 
423
 
424
;void (s)
424
;void (s)
425
;    deflate_state* s
425
;    deflate_state* s
426
align 4
426
align 4
427
proc init_block uses eax ecx edi, s:dword
-
 
428
;    int n ;iterates over tree elements
427
proc init_block uses eax ecx edi, s:dword
Line 429... Line 428...
429
	mov edi,[s]
428
	mov edi,[s]
430
 
429
 
431
	; Initialize the trees.
430
	; Initialize the trees.
Line 449... Line 448...
449
	@@:
448
	@@:
450
		mov word[eax],0
449
		mov word[eax],0
451
		add eax,sizeof.ct_data
450
		add eax,sizeof.ct_data
452
		loop @b
451
		loop @b
Line 453... Line 452...
453
 
452
 
454
	mov ecx,sizeof.ct_data*END_BLOCK+deflate_state.dyn_ltree+Freq
-
 
455
	mov word[ecx+edi],1
453
	mov word[edi+sizeof.ct_data*END_BLOCK+deflate_state.dyn_ltree+Freq],1
456
	mov dword[edi+deflate_state.static_len],0
454
	mov dword[edi+deflate_state.static_len],0
457
	mov dword[edi+deflate_state.opt_len],0
455
	mov dword[edi+deflate_state.opt_len],0
458
	mov dword[edi+deflate_state.matches],0
456
	mov dword[edi+deflate_state.matches],0
459
	mov dword[edi+deflate_state.last_lit],0
457
	mov dword[edi+deflate_state.last_lit],0
Line 1355... Line 1353...
1355
	mov edi,[s]
1353
	mov edi,[s]
1356
	; Determine the bit length frequencies for literal and distance trees
1354
	; Determine the bit length frequencies for literal and distance trees
1357
	mov eax,edi
1355
	mov eax,edi
1358
	add eax,deflate_state.dyn_ltree
1356
	add eax,deflate_state.dyn_ltree
1359
	stdcall scan_tree, edi, eax, [edi+deflate_state.l_desc.max_code]
1357
	stdcall scan_tree, edi, eax, [edi+deflate_state.l_desc.max_code]
1360
	mov eax,edi
-
 
1361
	add eax,deflate_state.dyn_dtree
1358
	add eax,deflate_state.dyn_dtree-deflate_state.dyn_ltree
1362
	stdcall scan_tree, edi, eax, [edi+deflate_state.d_desc.max_code]
1359
	stdcall scan_tree, edi, eax, [edi+deflate_state.d_desc.max_code]
Line 1363... Line 1360...
1363
 
1360
 
1364
	; Build the bit length tree:
-
 
1365
	mov eax,edi
1361
	; Build the bit length tree:
1366
	add eax,deflate_state.bl_desc
1362
	add eax,deflate_state.bl_desc-deflate_state.dyn_dtree
1367
	stdcall build_tree, edi, eax
1363
	stdcall build_tree, edi, eax
1368
	; opt_len now includes the length of the tree representations, except
1364
	; opt_len now includes the length of the tree representations, except
Line 1369... Line 1365...
1369
	; the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
1365
	; the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
Line 1504... Line 1500...
1504
 
1500
 
1505
; ===========================================================================
1501
; ===========================================================================
Line 1506... Line 1502...
1506
; Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
1502
; Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
1507
 
1503
 
1508
;void (s)
1504
;void (s)
1509
;    deflate_state* s;
1505
;    deflate_state* s
1510
align 4
1506
align 4
1511
proc _tr_flush_bits, s:dword
1507
proc _tr_flush_bits, s:dword
1512
	stdcall bi_flush, [s]
1508
	stdcall bi_flush, [s]
Line 1743... Line 1739...
1743
		add eax,_length_code
1739
		add eax,_length_code
1744
		movzx eax,byte[eax]
1740
		movzx eax,byte[eax]
1745
		add eax,LITERALS+1
1741
		add eax,LITERALS+1
1746
		imul eax,sizeof.ct_data
1742
		imul eax,sizeof.ct_data
1747
		add eax,edi
1743
		add eax,edi
1748
		add eax,deflate_state.dyn_ltree+Freq
1744
		inc word[eax+deflate_state.dyn_ltree+Freq]
1749
		inc word[eax]
-
 
1750
		d_code [dist]
1745
		d_code [dist]
1751
		imul eax,sizeof.ct_data
1746
		imul eax,sizeof.ct_data
1752
		add eax,edi
1747
		add eax,edi
1753
		add eax,deflate_state.dyn_dtree+Freq
1748
		inc word[eax+deflate_state.dyn_dtree+Freq]
1754
		inc word[eax]
-
 
1755
	.end0:
1749
	.end0:
Line 1756... Line 1750...
1756
 
1750
 
1757
if TRUNCATE_BLOCK eq 1
1751
if TRUNCATE_BLOCK eq 1
1758
	; Try to guess if it is profitable to stop the current block here
1752
	; Try to guess if it is profitable to stop the current block here
Line 1793... Line 1787...
1793
 
1787
 
1794
; ===========================================================================
1788
; ===========================================================================
Line 1795... Line 1789...
1795
; Send the block data compressed using the given Huffman trees
1789
; Send the block data compressed using the given Huffman trees
1796
 
1790
 
1797
;void (s, ltree, dtree)
1791
;void (s, ltree, dtree)
1798
;    deflate_state* s;
1792
;    deflate_state* s
1799
;    ct_data *ltree ;literal tree
1793
;    ct_data *ltree ;literal tree
1800
;    ct_data *dtree ;distance tree
1794
;    ct_data *dtree ;distance tree
1801
align 4
1795
align 4
Line 1950... Line 1944...
1950
		mov eax,Z_TEXT
1944
		mov eax,Z_TEXT
1951
		jmp .end_f
1945
		jmp .end_f
1952
	.end0:
1946
	.end0:
1953
	mov ecx,32
1947
	mov ecx,32
1954
	mov ebx,edi
1948
	mov ebx,edi
1955
	add ebx,deflate_state.dyn_ltree+Freq
1949
	add ebx,deflate_state.dyn_ltree+Freq+32*sizeof.ct_data
1956
	.cycle1:
1950
	.cycle1:
1957
	cmp ecx,LITERALS
1951
	cmp ecx,LITERALS
1958
	jge .cycle1end ;for (..;..<..;..,..)
1952
	jge .cycle1end ;for (..;..<..;..,..)
1959
		cmp word[ebx],0
1953
		cmp word[ebx],0
1960
		je @f ;if (..!=0)
1954
		je @f ;if (..!=0)