Subversion Repositories Kolibri OS

Rev

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

Rev 6847 Rev 6851
Line 199... Line 199...
199
		mov cx,[edi+deflate_state.bi_buf]
199
		mov cx,[edi+deflate_state.bi_buf]
200
		put_short edi, cx
200
		put_short edi, cx
201
		mov eax,[value]
201
		mov eax,[value]
202
		mov ecx,Buf_size
202
		mov ecx,Buf_size
203
		sub ecx,[edi+deflate_state.bi_valid]
203
		sub ecx,[edi+deflate_state.bi_valid]
204
		shr eax,cl
204
		sar eax,cl
205
		mov [edi+deflate_state.bi_buf],ax
205
		mov [edi+deflate_state.bi_buf],ax
206
		mov eax,[length]
206
		mov eax,[length]
207
		sub eax,Buf_size
207
		sub eax,Buf_size
208
		jmp .end0
208
		jmp .end0
209
	@@: ;else
209
	@@: ;else
Line 1406... Line 1406...
1406
	xor ecx,ecx
1406
	xor ecx,ecx
1407
	.cycle0:
1407
	.cycle0:
1408
		cmp ecx,[blcodes]
1408
		cmp ecx,[blcodes]
1409
		jge .cycle0end ;for (..;..<..;..)
1409
		jge .cycle0end ;for (..;..<..;..)
1410
;        Tracev((stderr, "\nbl code %2d ", bl_order[ecx]));
1410
;        Tracev((stderr, "\nbl code %2d ", bl_order[ecx]));
1411
		mov eax,ecx
-
 
1412
		add eax,bl_order
-
 
1413
		movzx eax,byte[eax]
1411
		movzx eax,byte[ecx+bl_order]
1414
		imul eax,sizeof.ct_data
-
 
1415
		add eax,edi
-
 
1416
		movzx eax,word[eax+deflate_state.bl_tree+Len]
1412
		movzx eax,word[edi+sizeof.ct_data*eax+deflate_state.bl_tree+Len]
1417
		stdcall send_bits, edi, eax, 3
1413
		stdcall send_bits, edi, eax, 3
1418
		inc ecx
1414
		inc ecx
1419
		jmp .cycle0
1415
		jmp .cycle0
1420
align 4
1416
align 4
1421
	.cycle0end:
1417
	.cycle0end:
Line 1554... Line 1550...
1554
;        Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
1550
;        Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
1555
;                opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
1551
;                opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
1556
;                s->last_lit));
1552
;                s->last_lit));
Line 1557... Line 1553...
1557
 
1553
 
1558
		cmp eax,[opt_lenb]
1554
		cmp eax,[opt_lenb]
1559
		jg .end1 ;if (..<=..)
1555
		ja .end1 ;if (..<=..)
1560
			mov [opt_lenb],eax
1556
			mov [opt_lenb],eax
1561
		jmp .end1
1557
		jmp .end1
1562
	.end0: ;else
1558
	.end0: ;else
1563
		cmp dword[buf],0
1559
		cmp dword[buf],0
Line 1575... Line 1571...
1575
	je .end2 ;if (..!=0) ;force stored block
1571
	je .end2 ;if (..!=0) ;force stored block
1576
else
1572
else
1577
	mov eax,[stored_len]
1573
	mov eax,[stored_len]
1578
	add eax,4
1574
	add eax,4
1579
	cmp eax,[opt_lenb]
1575
	cmp eax,[opt_lenb]
1580
	jg .end2
1576
	ja .end2
1581
	cmp dword[buf],0
1577
	cmp dword[buf],0
1582
	je .end2 ;if (..<=.. && ..!=0)
1578
	je .end2 ;if (..<=.. && ..!=0)
1583
		;4: two words for the lengths
1579
		;4: two words for the lengths
1584
end if
1580
end if
1585
		; The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
1581
		; The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
Line 1664... Line 1660...
1664
;    unsigned dist ;distance of matched string
1660
;    unsigned dist ;distance of matched string
1665
;    unsigned lc   ;match length-MIN_MATCH or unmatched char (if dist==0)
1661
;    unsigned lc   ;match length-MIN_MATCH or unmatched char (if dist==0)
1666
align 4
1662
align 4
1667
proc _tr_tally uses ebx edi, s:dword, dist:dword, lc:dword
1663
proc _tr_tally uses ebx edi, s:dword, dist:dword, lc:dword
1668
	mov edi,[s]
1664
	mov edi,[s]
1669
	zlib_debug '_tr_tally'
-
 
1670
	mov eax,[edi+deflate_state.last_lit]
1665
	mov eax,[edi+deflate_state.last_lit]
1671
	shl eax,1
1666
	shl eax,1
1672
	add eax,[edi+deflate_state.d_buf]
1667
	add eax,[edi+deflate_state.d_buf]
1673
	mov ebx,[dist]
1668
	mov ebx,[dist]
1674
	mov word[eax],bx
1669
	mov word[eax],bx
Line 1679... Line 1674...
1679
	inc dword[edi+deflate_state.last_lit]
1674
	inc dword[edi+deflate_state.last_lit]
1680
	cmp dword[dist],0
1675
	cmp dword[dist],0
1681
	jne @f ;if (..==0)
1676
	jne @f ;if (..==0)
1682
		; lc is the unmatched char
1677
		; lc is the unmatched char
1683
		mov eax,[lc]
1678
		mov eax,[lc]
1684
		imul eax,sizeof.ct_data
-
 
1685
		add eax,edi
-
 
1686
		inc word[eax+deflate_state.dyn_ltree+Freq]
1679
		inc word[edi+sizeof.ct_data*eax+deflate_state.dyn_ltree+Freq]
1687
		jmp .end0
1680
		jmp .end0
1688
align 4
1681
align 4
1689
	@@: ;else
1682
	@@: ;else
1690
		inc dword[edi+deflate_state.matches]
1683
		inc dword[edi+deflate_state.matches]
1691
		; Here, lc is the match length - MIN_MATCH
1684
		; Here, lc is the match length - MIN_MATCH
Line 1701... Line 1694...
1701
		@@:
1694
		@@:
1702
			zlib_assert '_tr_tally: bad match' ;Assert(..<.. && ..<=.. && ..<..)
1695
			zlib_assert '_tr_tally: bad match' ;Assert(..<.. && ..<=.. && ..<..)
1703
		.end2:
1696
		.end2:
1704
		mov eax,[lc]
1697
		mov eax,[lc]
1705
		movzx eax,byte[eax+_length_code]
1698
		movzx eax,byte[eax+_length_code]
1706
		add eax,LITERALS+1
-
 
1707
		imul eax,sizeof.ct_data
-
 
1708
		inc word[edi+eax+deflate_state.dyn_ltree+Freq]
1699
		inc word[edi+sizeof.ct_data*eax+deflate_state.dyn_ltree+sizeof.ct_data*(LITERALS+1)+Freq]
1709
		d_code [dist]
1700
		d_code [dist]
1710
		imul eax,sizeof.ct_data
-
 
1711
		inc word[edi+eax+deflate_state.dyn_dtree+Freq]
1701
		inc word[edi+sizeof.ct_data*eax+deflate_state.dyn_dtree+Freq]
1712
	.end0:
1702
	.end0:
Line 1713... Line 1703...
1713
 
1703
 
1714
if TRUNCATE_BLOCK eq 1
1704
if TRUNCATE_BLOCK eq 1
1715
	; Try to guess if it is profitable to stop the current block here
1705
	; Try to guess if it is profitable to stop the current block here
Line 1731... Line 1721...
1731
;               s->last_lit, in_length, out_length,
1721
;               s->last_lit, in_length, out_length,
1732
;               100L - out_length*100L/in_length));
1722
;               100L - out_length*100L/in_length));
1733
;        if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
1723
;        if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
1734
	.end1:
1724
	.end1:
1735
end if
1725
end if
1736
	mov ebx,[edi+deflate_state.last_lit]
-
 
1737
	mov edi,[edi+deflate_state.lit_bufsize]
1726
	mov ebx,[edi+deflate_state.lit_bufsize]
1738
	dec edi
1727
	dec ebx
1739
	xor eax,eax
1728
	xor eax,eax
1740
	cmp ebx,edi
1729
	cmp [edi+deflate_state.last_lit],ebx
1741
	jne @f
-
 
1742
		inc eax ;return (..==..)
1730
	sete al ;return (..==..)
1743
	@@:
1731
 
1744
	; We avoid equality with lit_bufsize because of wraparound at 64K
1732
	; We avoid equality with lit_bufsize because of wraparound at 64K
1745
	; on 16 bit machines and because stored blocks are restricted to
1733
	; on 16 bit machines and because stored blocks are restricted to
1746
	; 64K-1 bytes.
1734
	; 64K-1 bytes.
1747
	ret
1735
	ret
1748
endp
1736
endp
Line 1826... Line 1814...
1826
		jl @f
1814
		jl @f
1827
			zlib_assert 'pendingBuf overflow' ;Assert(..<..)
1815
			zlib_assert 'pendingBuf overflow' ;Assert(..<..)
1828
		@@:
1816
		@@:
1829
		mov eax,[edi+deflate_state.last_lit]
1817
		mov eax,[edi+deflate_state.last_lit]
1830
		cmp [lx],eax
1818
		cmp [lx],eax
1831
		jl .cycle0 ;while (..<..)
1819
		jb .cycle0 ;while (..<..)
1832
align 4
1820
align 4
1833
	.end0:
1821
	.end0:
Line 1834... Line 1822...
1834
 
1822
 
1835
	send_code edi, END_BLOCK, [ltree]
1823
	send_code edi, END_BLOCK, [ltree]
Line 1847... Line 1835...
1847
; - The following partially-portable control characters form a
1835
; - The following partially-portable control characters form a
1848
;   "gray list" that is ignored in this detection algorithm:
1836
;   "gray list" that is ignored in this detection algorithm:
1849
;   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
1837
;   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
1850
; IN assertion: the fields Freq of dyn_ltree are set.
1838
; IN assertion: the fields Freq of dyn_ltree are set.
Line 1851... Line -...
1851
 
-
 
1852
;int (s)
1839
 
1853
;    deflate_state* s
1840
;int (deflate_state* s)
1854
align 4
1841
align 4
1855
proc detect_data_type uses ebx ecx edi, s:dword
1842
proc detect_data_type uses ebx ecx edi, s:dword
1856
	; black_mask is the bit mask of black-listed bytes
1843
	; black_mask is the bit mask of black-listed bytes
1857
	; set bits 0..6, 14..25, and 28..31
1844
	; set bits 0..6, 14..25, and 28..31
1858
	; 0xf3ffc07f = binary 11110011111111111100000001111111
1845
	; 0xf3ffc07f = binary 11110011111111111100000001111111
1859
locals
1846
locals
1860
	black_mask dd 0xf3ffc07f
1847
	black_mask dd 0xf3ffc07f
1861
endl
1848
endl
1862
	mov edi,[s]
-
 
Line 1863... Line 1849...
1863
	zlib_debug 'detect_data_type'
1849
	mov edi,[s]
1864
 
1850
 
1865
	; Check for non-textual ("black-listed") bytes.
1851
	; Check for non-textual ("black-listed") bytes.
1866
	xor ecx,ecx
1852
	xor ecx,ecx
Line 1946... Line 1932...
1946
endp
1932
endp
Line 1947... Line 1933...
1947
 
1933
 
1948
; ===========================================================================
1934
; ===========================================================================
Line 1949... Line -...
1949
; Flush the bit buffer, keeping at most 7 bits in it.
-
 
1950
 
1935
; Flush the bit buffer, keeping at most 7 bits in it.
1951
;void (s)
1936
 
1952
;    deflate_state* s
1937
;void (deflate_state* s)
1953
align 4
1938
align 4
1954
proc bi_flush uses eax ecx edi, s:dword
1939
proc bi_flush uses eax ecx edi, s:dword
1955
	mov edi,[s]
1940
	mov edi,[s]
Line 2028... Line 2013...
2028
	mov ecx,[len]
2013
	mov ecx,[len]
2029
	shl ecx,3
2014
	shl ecx,3
2030
	add [edi+deflate_state.bits_sent],ecx
2015
	add [edi+deflate_state.bits_sent],ecx
2031
end if
2016
end if
2032
	mov ecx,[len]
2017
	mov ecx,[len]
-
 
2018
;	test ecx,ecx
-
 
2019
;	jz .end_f
2033
	mov esi,[buf]
2020
	mov esi,[buf]
2034
	jmp .end0
2021
	jmp .end0
2035
align 4
2022
align 4
2036
	@@: ;while (len--)
2023
	@@: ;while (len--)
2037
		lodsb
2024
		lodsb
2038
		mov bl,al
2025
		mov bl,al
2039
		put_byte edi, bl
2026
		put_byte edi, bl
2040
	.end0:
2027
	.end0:
2041
		loop @b
2028
		loop @b
-
 
2029
;	.end_f:
2042
	ret
2030
	ret
2043
endp
2031
endp