Subversion Repositories Kolibri OS

Rev

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

Rev 6813 Rev 6815
Line 498... Line 498...
498
	mov bx,word[ebx+Freq]
498
	mov bx,word[ebx+Freq]
499
	cmp ax,bx
499
	cmp ax,bx
500
	jl .end0
500
	jl .end0
501
	jne m_end
501
	jne m_end
502
	movzx eax,n
502
	movzx eax,n
503
	add eax,depth
-
 
504
	mov al,byte[eax]
503
	mov al,byte[eax+depth]
505
	movzx ebx,m
504
	movzx ebx,m
506
	add ebx,depth
-
 
507
	mov bl,byte[ebx]
505
	cmp al,byte[ebx+depth]
508
	cmp al,bl
-
 
509
	jg m_end
506
	jg m_end
510
	.end0:
507
	.end0:
511
}
508
}
Line 512... Line 509...
512
 
509
 
Line 520... Line 517...
520
;    deflate_state* s
517
;    deflate_state* s
521
;    ct_data* tree ;the tree to restore
518
;    ct_data* tree ;the tree to restore
522
;    int      k    ;node to move down
519
;    int      k    ;node to move down
523
align 4
520
align 4
524
proc pqdownheap, s:dword, tree:dword, k:dword
521
proc pqdownheap, s:dword, tree:dword, k:dword
525
locals
-
 
526
	v dw ?
-
 
527
endl
-
 
528
pushad
522
pushad
-
 
523
	;ecx - v dw
529
	mov edi,[s]
524
	mov edi,[s]
530
	mov eax,[k]
525
	mov esi,[k]
531
	zlib_debug 'pqdownheap k = %d',eax
526
	zlib_debug 'pqdownheap k = %d',esi
532
	mov esi,eax
527
	mov cx,[edi+deflate_state.heap+2*esi]
533
	shl esi,1
528
	shl esi,1
534
	mov ax,[edi+deflate_state.heap+2*eax]
-
 
535
	mov [v],ax
-
 
536
	;esi = j ;left son of k
529
	;esi = j ;left son of k
537
	.cycle0: ;while (..<=..)
530
	.cycle0: ;while (..<=..)
538
		cmp esi,[edi+deflate_state.heap_len]
531
		cmp esi,[edi+deflate_state.heap_len]
539
		jg .cycle0end
532
		jg .cycle0end
540
		; Set j to the smallest of the two sons:
533
		; Set j to the smallest of the two sons:
541
		;;cmp esi,[edi+deflate_state.heap_len]
534
		;;cmp esi,[edi+deflate_state.heap_len]
542
		jge .end1 ;if (..<.. &&
535
		jge .end1 ;if (..<.. &&
543
		mov ecx,edi
-
 
544
		add ecx,deflate_state.depth
-
 
545
		mov edx,esi
536
		mov edx,esi
546
		shl edx,1
537
		shl edx,1
547
		add edx,edi
538
		add edx,edi
548
		add edx,deflate_state.heap
539
		add edx,deflate_state.heap
549
		smaller [tree], word[edx+2], word[edx], ecx, .end1
540
		smaller [tree], word[edx+2], word[edx], edi+deflate_state.depth, .end1
550
			inc esi
541
			inc esi
551
		.end1:
542
		.end1:
552
		; Exit if v is smaller than both sons
543
		; Exit if v is smaller than both sons
553
		mov ecx,edi
-
 
554
		add ecx,deflate_state.depth
-
 
555
		mov dx,[edi+deflate_state.heap+2*esi]
544
		mov dx,[edi+deflate_state.heap+2*esi]
556
		smaller [tree], [v], dx, ecx, .end2
545
		smaller [tree], cx, dx, edi+deflate_state.depth, .end2
557
			jmp .cycle0end ;break
546
			jmp .cycle0end ;break
558
		.end2:
547
		.end2:
559
		; Exchange v with the smallest son
548
		; Exchange v with the smallest son
560
		mov dx,[edi+deflate_state.heap+2*esi]
549
		;;mov dx,[edi+deflate_state.heap+2*esi]
561
		mov eax,[k]
550
		mov eax,[k]
562
		mov [edi+deflate_state.heap+2*eax],dx
551
		mov [edi+deflate_state.heap+2*eax],dx
563
		mov [k],esi
552
		mov [k],esi
564
		; And continue down the tree, setting j to the left son of k
553
		; And continue down the tree, setting j to the left son of k
565
		shl esi,1
554
		shl esi,1
566
		jmp .cycle0
555
		jmp .cycle0
-
 
556
align 4
567
	.cycle0end:
557
	.cycle0end:
568
	mov eax,[k]
558
	mov eax,[k]
569
	mov bx,[v]
-
 
570
	mov [edi+deflate_state.heap+2*eax],bx
559
	mov [edi+deflate_state.heap+2*eax],cx
571
popad
560
popad
572
	ret
561
	ret
573
endp
562
endp
Line 574... Line 563...
574
 
563
 
Line 1024... Line 1013...
1024
		mov al,byte[eax+deflate_state.depth]
1013
		mov al,byte[eax+deflate_state.depth]
1025
		mov edx,[m]
1014
		mov edx,[m]
1026
		add edx,edi
1015
		add edx,edi
1027
		mov ah,byte[edx+deflate_state.depth]
1016
		mov ah,byte[edx+deflate_state.depth]
1028
		cmp al,ah
1017
		cmp al,ah
1029
		jl @f ;if (al>=ah) al=al : al=ah
1018
		jge @f ;if (al>=ah) al=al : al=ah
1030
			mov al,ah
1019
			mov al,ah
1031
		@@:
1020
		@@:
1032
		inc al
1021
		inc al
1033
		mov edx,[node]
1022
		mov edx,[node]
1034
		add edx,edi
1023
		add edx,edi
Line 1096... Line 1085...
1096
	mov edi,[s]
1085
	mov edi,[s]
1097
	zlib_debug 'scan_tree'
1086
	zlib_debug 'scan_tree'
1098
	mov eax,[tree]
1087
	mov eax,[tree]
1099
	movzx eax,word[eax+Len]
1088
	movzx eax,word[eax+Len]
1100
	mov [nextlen],eax
1089
	mov [nextlen],eax
1101
	cmp eax,0
1090
	test eax,eax
1102
	jne @f ;if (..==0)
1091
	jnz @f ;if (..==0)
1103
		mov dword[max_count],138
1092
		mov dword[max_count],138
1104
		mov dword[min_count],3
1093
		mov dword[min_count],3
1105
	@@:
1094
	@@:
1106
	mov eax,[max_code]
1095
	mov eax,[max_code]
1107
	inc eax
1096
	inc eax
1108
	imul eax,sizeof.ct_data
1097
	imul eax,sizeof.ct_data
1109
	add eax,[tree]
1098
	add eax,[tree]
1110
	mov word[eax+Len],0xffff ;guard
1099
	mov word[eax+Len],0xffff ;guard
Line 1111... Line 1100...
1111
 
1100
 
-
 
1101
	xor ecx,ecx
1112
	xor ecx,ecx
1102
align 4
1113
	.cycle0:
1103
	.cycle0:
1114
		cmp ecx,[max_code]
1104
		cmp ecx,[max_code]
1115
		jg .cycle0end ;for (..;..<=..;..)
1105
		jg .cycle0end ;for (..;..<=..;..)
1116
		mov eax,[nextlen]
1106
		mov eax,[nextlen]
1117
		mov [curlen],eax
-
 
1118
		mov eax,ecx
1107
		mov [curlen],eax
1119
		inc eax
1108
		inc ecx
-
 
1109
		mov eax,sizeof.ct_data
1120
		imul eax,sizeof.ct_data
1110
		imul eax,ecx
1121
		add eax,[tree]
1111
		add eax,[tree]
1122
		movzx eax,word[eax+Len]
1112
		movzx eax,word[eax+Len]
1123
		mov [nextlen],eax
1113
		mov [nextlen],eax
1124
		inc dword[count]
1114
		inc dword[count]
1125
		mov ebx,[count]
1115
		mov ebx,[count]
1126
		cmp ebx,[max_count]
1116
		cmp ebx,[max_count]
1127
		jge .end0
1117
		jge .end0
1128
		mov eax,[nextlen]
1118
		mov eax,[nextlen]
1129
		cmp [curlen],eax
1119
		cmp [curlen],eax
1130
		jne .end0 ;if (..<.. && ..==..)
1120
		je .cycle0 ;if (..<.. && ..==..) continue
1131
			inc ecx
-
 
1132
			jmp .cycle0 ;continue
1121
align 4
1133
		.end0:
1122
		.end0:
1134
		cmp ebx,[min_count]
1123
		cmp ebx,[min_count]
1135
		jge .end1 ;else if (..<..)
1124
		jge .end1 ;else if (..<..)
1136
			mov eax,[curlen]
1125
			mov eax,[curlen]
1137
			imul eax,sizeof.ct_data
1126
			imul eax,sizeof.ct_data
1138
			add eax,edi
1127
			add eax,edi
1139
			add word[eax+deflate_state.bl_tree+Freq],bx
1128
			add word[eax+deflate_state.bl_tree+Freq],bx
-
 
1129
			jmp .end4
1140
			jmp .end4
1130
align 4
1141
		.end1:
1131
		.end1:
1142
		cmp dword[curlen],0
1132
		cmp dword[curlen],0
1143
		je .end2 ;else if (..!=0)
1133
		je .end2 ;else if (..!=0)
1144
			mov eax,[curlen]
1134
			mov eax,[curlen]
Line 1151... Line 1141...
1151
			mov eax,REP_3_6
1141
			mov eax,REP_3_6
1152
			imul eax,sizeof.ct_data
1142
			imul eax,sizeof.ct_data
1153
			add eax,edi
1143
			add eax,edi
1154
			inc word[eax+deflate_state.bl_tree+Freq]
1144
			inc word[eax+deflate_state.bl_tree+Freq]
1155
			jmp .end4
1145
			jmp .end4
-
 
1146
align 4
1156
		.end2:
1147
		.end2:
1157
		cmp ebx,10
1148
		cmp ebx,10
1158
		jg .end3 ;else if (..<=..)
1149
		jg .end3 ;else if (..<=..)
1159
			mov eax,REPZ_3_10
1150
			mov eax,REPZ_3_10
1160
			imul eax,sizeof.ct_data
1151
			imul eax,sizeof.ct_data
1161
			add eax,edi
1152
			add eax,edi
1162
			inc word[eax+deflate_state.bl_tree+Freq]
1153
			inc word[eax+deflate_state.bl_tree+Freq]
1163
			jmp .end4
1154
			jmp .end4
-
 
1155
align 4
1164
		.end3: ;else
1156
		.end3: ;else
1165
			mov eax,REPZ_11_138
1157
			mov eax,REPZ_11_138
1166
			imul eax,sizeof.ct_data
1158
			imul eax,sizeof.ct_data
1167
			add eax,edi
1159
			add eax,edi
1168
			inc word[eax+deflate_state.bl_tree+Freq]
1160
			inc word[eax+deflate_state.bl_tree+Freq]
1169
		.end4:
1161
		.end4:
1170
		mov dword[curlen],0
1162
		mov dword[count],0
1171
		mov eax,[curlen]
1163
		mov eax,[curlen]
1172
		mov [prevlen],eax
1164
		mov [prevlen],eax
1173
		mov [nextlen],eax
1165
		cmp dword[nextlen],0
1174
		cmp eax,0
-
 
1175
		jne .end5 ;if (..==0)
1166
		jne .end5 ;if (..==0)
1176
			mov dword[max_count],138
1167
			mov dword[max_count],138
1177
			mov dword[min_count],3
1168
			mov dword[min_count],3
1178
			jmp .end7
1169
			jmp .cycle0
-
 
1170
align 4
1179
		.end5:
1171
		.end5:
1180
		mov eax,[curlen]
-
 
1181
		cmp eax,[nextlen]
1172
		cmp eax,[nextlen]
1182
		jne .end6 ;else if (..==..)
1173
		jne .end6 ;else if (..==..)
1183
			mov dword[max_count],6
1174
			mov dword[max_count],6
1184
			mov dword[min_count],3
1175
			mov dword[min_count],3
1185
			jmp .end7
1176
			jmp .cycle0
-
 
1177
align 4
1186
		.end6: ;else
1178
		.end6: ;else
1187
			mov dword[max_count],7
1179
			mov dword[max_count],7
1188
			mov dword[min_count],4
1180
			mov dword[min_count],4
1189
		.end7:
-
 
1190
		inc ecx
-
 
1191
		jmp .cycle0
1181
		jmp .cycle0
-
 
1182
align 4
1192
	.cycle0end:
1183
	.cycle0end:
1193
	ret
1184
	ret
1194
endp
1185
endp
Line 1195... Line 1186...
1195
 
1186
 
Line 1705... Line 1696...
1705
		mov eax,[lc]
1696
		mov eax,[lc]
1706
		imul eax,sizeof.ct_data
1697
		imul eax,sizeof.ct_data
1707
		add eax,edi
1698
		add eax,edi
1708
		inc word[eax+deflate_state.dyn_ltree+Freq]
1699
		inc word[eax+deflate_state.dyn_ltree+Freq]
1709
		jmp .end0
1700
		jmp .end0
-
 
1701
align 4
1710
	@@: ;else
1702
	@@: ;else
1711
		inc dword[edi+deflate_state.matches]
1703
		inc dword[edi+deflate_state.matches]
1712
		; Here, lc is the match length - MIN_MATCH
1704
		; Here, lc is the match length - MIN_MATCH
1713
		dec dword[dist] ;dist = match distance - 1
1705
		dec dword[dist] ;dist = match distance - 1
1714
		MAX_DIST edi
1706
		MAX_DIST edi
Line 1721... Line 1713...
1721
		jl .end2
1713
		jl .end2
1722
		@@:
1714
		@@:
1723
			zlib_assert '_tr_tally: bad match' ;Assert(..<.. && ..<=.. && ..<..)
1715
			zlib_assert '_tr_tally: bad match' ;Assert(..<.. && ..<=.. && ..<..)
1724
		.end2:
1716
		.end2:
1725
		mov eax,[lc]
1717
		mov eax,[lc]
1726
		add eax,_length_code
-
 
1727
		movzx eax,byte[eax]
1718
		movzx eax,byte[eax+_length_code]
1728
		add eax,LITERALS+1
1719
		add eax,LITERALS+1
1729
		imul eax,sizeof.ct_data
1720
		imul eax,sizeof.ct_data
1730
		add eax,edi
-
 
1731
		inc word[eax+deflate_state.dyn_ltree+Freq]
1721
		inc word[edi+eax+deflate_state.dyn_ltree+Freq]
1732
		d_code [dist]
1722
		d_code [dist]
1733
		imul eax,sizeof.ct_data
1723
		imul eax,sizeof.ct_data
1734
		add eax,edi
-
 
1735
		inc word[eax+deflate_state.dyn_dtree+Freq]
1724
		inc word[edi+eax+deflate_state.dyn_dtree+Freq]
1736
	.end0:
1725
	.end0:
Line 1737... Line 1726...
1737
 
1726
 
1738
if TRUNCATE_BLOCK eq 1
1727
if TRUNCATE_BLOCK eq 1
1739
	; Try to guess if it is profitable to stop the current block here
1728
	; Try to guess if it is profitable to stop the current block here
Line 2065... Line 2054...
2065
	shl ecx,3
2054
	shl ecx,3
2066
	add [edi+deflate_state.bits_sent],ecx
2055
	add [edi+deflate_state.bits_sent],ecx
2067
end if
2056
end if
2068
	mov ecx,[len]
2057
	mov ecx,[len]
2069
	mov esi,[buf]
2058
	mov esi,[buf]
-
 
2059
	jmp .end0
-
 
2060
align 4
2070
	@@: ;while (len--)
2061
	@@: ;while (len--)
2071
		lodsb
2062
		lodsb
2072
		mov bl,al
2063
		mov bl,al
2073
		put_byte edi, bl
2064
		put_byte edi, bl
-
 
2065
	.end0:
2074
		loop @b
2066
		loop @b
2075
	ret
2067
	ret
2076
endp
2068
endp