Subversion Repositories Kolibri OS

Rev

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

Rev 6855 Rev 6860
Line 1... Line 1...
1
; trees.asm -- output deflated data using Huffman coding
1
; trees.asm -- output deflated data using Huffman coding
2
; Copyright (C) 1995-2012 Jean-loup Gailly
2
; Copyright (C) 1995-2012 Jean-loup Gailly
3
; detect_data_type() function provided freely by Cosmin Truta, 2006
3
; detect_data_type() function provided freely by Cosmin Truta, 2006
4
; For conditions of distribution and use, see copyright notice in zlib.h
4
; For conditions of distribution and use, see copyright notice in zlib.inc
Line 5... Line 5...
5
 
5
 
Line 6... Line 6...
6
;  ALGORITHM
6
;  ALGORITHM
7
 
7
 
Line 105... Line 105...
105
 
105
 
106
else
106
else
107
include 'trees.inc'
107
include 'trees.inc'
Line 108... Line 108...
108
end if ;GEN_TREES_H
108
end if ;GEN_TREES_H
109
 
109
 
110
struct static_tree_desc ;_s
110
struct static_tree_desc
111
	static_tree dd ? ;const ct_data * ;static tree or NULL
111
	static_tree dd ? ;const ct_data * ;static tree or NULL
112
	extra_bits  dd ? ;const intf * ;extra bits for each code or NULL
112
	extra_bits  dd ? ;const intf * ;extra bits for each code or NULL
113
	extra_base  dd ? ;int ;base index for extra_bits
113
	extra_base  dd ? ;int ;base index for extra_bits
Line 322... Line 322...
322
end if ;(GEN_TREES_H) | !(STDC)
322
end if ;(GEN_TREES_H) | !(STDC)
323
	ret
323
	ret
324
endp
324
endp
Line 325... Line 325...
325
 
325
 
326
; ===========================================================================
326
; ===========================================================================
Line 327... Line 327...
327
; Genererate the file trees.h describing the static trees.
327
; Genererate the file trees.inc describing the static trees.
328
 
328
 
329
;#  define SEPARATOR(i, last, width) \
329
;#  define SEPARATOR(i, last, width) \
Line 489... Line 489...
489
	add eax,tree
489
	add eax,tree
490
	mov ax,word[eax+Freq]
490
	mov ax,word[eax+Freq]
491
	mov ebx,m
491
	mov ebx,m
492
	imul ebx,sizeof.ct_data
492
	imul ebx,sizeof.ct_data
493
	add ebx,tree
493
	add ebx,tree
494
	mov bx,word[ebx+Freq]
494
	cmp ax,word[ebx+Freq]
495
	cmp ax,bx
-
 
496
	jl .end0
495
	jl .end0
497
	jne m_end
496
	jne m_end
498
	mov eax,n
497
	mov eax,n
499
	mov al,byte[eax+depth]
498
	mov al,byte[eax+depth]
500
	mov ebx,m
499
	mov ebx,m
Line 526... Line 525...
526
		cmp esi,[edi+deflate_state.heap_len]
525
		cmp esi,[edi+deflate_state.heap_len]
527
		jg .cycle0end
526
		jg .cycle0end
528
		; Set j to the smallest of the two sons:
527
		; Set j to the smallest of the two sons:
529
		;;cmp esi,[edi+deflate_state.heap_len]
528
		;;cmp esi,[edi+deflate_state.heap_len]
530
		jge .end1 ;if (..<.. &&
529
		jge .end1 ;if (..<.. &&
531
		mov edx,esi
-
 
532
		shl edx,2
-
 
533
		add edx,edi
-
 
534
		add edx,deflate_state.heap
530
		lea edx,[edi+4*esi+deflate_state.heap]
535
		smaller [tree], dword[edx+4], dword[edx], edi+deflate_state.depth, .end1
531
		smaller [tree], dword[edx+4], dword[edx], edi+deflate_state.depth, .end1
536
			inc esi
532
			inc esi
537
		.end1:
533
		.end1:
538
		; Exit if v is smaller than both sons
534
		; Exit if v is smaller than both sons
539
		mov edx,[edi+deflate_state.heap+4*esi]
535
		mov edx,[edi+deflate_state.heap+4*esi]
Line 635... Line 631...
635
		mov edx,[tree]
631
		mov edx,[tree]
636
		movzx eax,word[edx+sizeof.ct_data*ecx+Dad]
632
		movzx eax,word[edx+sizeof.ct_data*ecx+Dad]
637
		movzx eax,word[edx+sizeof.ct_data*eax+Len]
633
		movzx eax,word[edx+sizeof.ct_data*eax+Len]
638
		inc eax
634
		inc eax
639
		mov [bits],eax ;bits = tree[tree[n].Dad].Len + 1
635
		mov [bits],eax ;bits = tree[tree[n].Dad].Len + 1
640
		mov eax,[max_length]
636
		cmp eax,[max_length]
641
		cmp [bits],eax
-
 
642
		jle @f ;if (..>..)
637
		jle @f ;if (..>..)
-
 
638
			mov eax,[max_length]
643
			mov [bits],eax
639
			mov [bits],eax
644
			inc dword[overflow]
640
			inc dword[overflow]
645
		@@:
641
		@@:
646
		mov eax,[bits]
-
 
647
		mov [edx+sizeof.ct_data*ecx+Len],ax
642
		mov [edx+sizeof.ct_data*ecx+Len],ax
648
		; We overwrite tree[n].Dad which is no longer needed
643
		; We overwrite tree[n].Dad which is no longer needed
Line 649... Line 644...
649
 
644
 
650
		cmp ecx,[max_code]
645
		cmp ecx,[max_code]
Line 666... Line 661...
666
		mov esi,[bits]
661
		mov esi,[bits]
667
		add esi,[xbits]
662
		add esi,[xbits]
668
		imul eax,esi
663
		imul eax,esi
669
		add [edi+deflate_state.opt_len],eax
664
		add [edi+deflate_state.opt_len],eax
670
		cmp dword[stree],0
665
		cmp dword[stree],0
671
		je @f ;if (..)
666
		jne .cycle1 ;if (..)
672
			movzx eax,word[f]
667
			movzx eax,word[f]
673
			mov esi,sizeof.ct_data
-
 
674
			imul esi,ecx
-
 
675
			add esi,[stree]
668
			mov esi,[stree]
676
			movzx esi,word[esi+Len]
669
			movzx esi,word[esi+sizeof.ct_data*ecx+Len]
677
			add esi,[xbits]
670
			add esi,[xbits]
678
			imul eax,esi
671
			imul eax,esi
679
			add [edi+deflate_state.static_len],eax
672
			add [edi+deflate_state.static_len],eax
680
		@@:
-
 
681
		jmp .cycle1
673
		jmp .cycle1
682
align 4
674
align 4
683
	.cycle1end:
675
	.cycle1end:
684
	cmp dword[overflow],0
676
	cmp dword[overflow],0
685
	je .end_f ;if (..==0) return
677
	je .end_f ;if (..==0) return
Line 734... Line 726...
734
			mov eax,[edi+4*eax+deflate_state.heap]
726
			mov eax,[edi+4*eax+deflate_state.heap]
735
			mov [m],eax ;m = s.heap[--h]
727
			mov [m],eax ;m = s.heap[--h]
736
			cmp eax,[max_code]
728
			cmp eax,[max_code]
737
			jg .cycle4 ;if (..>..) continue
729
			jg .cycle4 ;if (..>..) continue
738
			mov esi,[m]
730
			mov esi,[m]
-
 
731
			imul esi,sizeof.ct_data
-
 
732
			add esi,edx ;esi = &tree[m]
739
			mov eax,[bits]
733
			mov eax,[bits]
740
			cmp word[edx+sizeof.ct_data*esi+Len],ax
734
			cmp word[esi+Len],ax
741
			je @f ;if (..!=..)
735
			je @f ;if (..!=..)
742
;                Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
736
;                Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
743
				movzx ebx,word[esi+Len]
737
				movzx ebx,word[esi+Len]
744
				sub eax,ebx
738
				sub eax,ebx
745
				movzx ebx,word[esi+Freq]
739
				movzx ebx,word[esi+Freq]
Line 972... Line 966...
972
		; Create a new node father of n and m
966
		; Create a new node father of n and m
973
		;;mov edx,[m]
967
		;;mov edx,[m]
974
		imul edx,sizeof.ct_data
968
		imul edx,sizeof.ct_data
975
		add edx,[tree]
969
		add edx,[tree]
976
		mov ax,word[edx+Freq]
970
		mov ax,word[edx+Freq]
977
		mov edx,ecx
-
 
978
		imul edx,sizeof.ct_data
-
 
979
		add edx,[tree]
971
		mov edx,[tree]
980
		add ax,word[edx+Freq]
972
		add ax,word[edx+sizeof.ct_data*ecx+Freq]
981
		mov edx,[node]
973
		mov edx,[node]
982
		imul edx,sizeof.ct_data
974
		imul edx,sizeof.ct_data
983
		add edx,[tree]
975
		add edx,[tree]
984
		mov word[edx+Freq],ax
976
		mov word[edx+Freq],ax