Rev 6847 | Rev 6863 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6847 | Rev 6851 | ||
---|---|---|---|
Line 1352... | Line 1352... | ||
1352 | cmp dword[edx+gz_header.hcrc],0 |
1352 | cmp dword[edx+gz_header.hcrc],0 |
1353 | je .end9 ;if (..) |
1353 | je .end9 ;if (..) |
1354 | mov ecx,[edi+deflate_state.pending] |
1354 | mov ecx,[edi+deflate_state.pending] |
1355 | add ecx,2 |
1355 | add ecx,2 |
1356 | cmp ecx,[edi+deflate_state.pending_buf_size] |
1356 | cmp ecx,[edi+deflate_state.pending_buf_size] |
1357 | jle @f ;if (..>..) |
1357 | jbe @f ;if (..>..) |
1358 | stdcall flush_pending, ebx |
1358 | stdcall flush_pending, ebx |
1359 | @@: |
1359 | @@: |
1360 | mov ecx,[edi+deflate_state.pending] |
1360 | mov ecx,[edi+deflate_state.pending] |
1361 | add ecx,2 |
1361 | add ecx,2 |
1362 | cmp ecx,[edi+deflate_state.pending_buf_size] |
1362 | cmp ecx,[edi+deflate_state.pending_buf_size] |
1363 | jg .end8 ;if (..<=..) |
1363 | ja .end8 ;if (..<=..) |
1364 | mov ecx,[ebx+z_stream.adler] |
1364 | mov ecx,[ebx+z_stream.adler] |
1365 | put_byte edi, cl |
1365 | put_byte edi, cl |
1366 | put_byte edi, ch |
1366 | put_byte edi, ch |
1367 | xor eax,eax ;stdcall calc_crc32, 0, Z_NULL, 0 |
1367 | xor eax,eax ;stdcall calc_crc32, 0, Z_NULL, 0 |
1368 | mov [ebx+z_stream.adler],eax |
1368 | mov [ebx+z_stream.adler],eax |
Line 2155... | Line 2155... | ||
2155 | sub ebx,[edi+deflate_state.strstart] |
2155 | sub ebx,[edi+deflate_state.strstart] |
Line 2156... | Line 2156... | ||
2156 | 2156 | ||
2157 | ; If the window is almost full and there is insufficient lookahead, |
2157 | ; If the window is almost full and there is insufficient lookahead, |
Line 2158... | Line 2158... | ||
2158 | ; move the upper half to the lower one to make room in the upper half. |
2158 | ; move the upper half to the lower one to make room in the upper half. |
2159 | 2159 | ||
- | 2160 | ;;MAX_DIST edi |
|
- | 2161 | ;;add eax,ecx |
|
2160 | MAX_DIST edi |
2162 | mov eax,[edi+deflate_state.w_size] |
2161 | add eax,ecx |
2163 | lea eax,[ecx+eax-MIN_LOOKAHEAD] |
2162 | cmp [edi+deflate_state.strstart],eax |
2164 | cmp [edi+deflate_state.strstart],eax |
2163 | jl .end0 ;if (..>=..) |
2165 | jb .end0 ;if (..>=..) |
2164 | push ecx |
2166 | push ecx |
2165 | mov eax,[edi+deflate_state.window] |
2167 | mov eax,[edi+deflate_state.window] |
2166 | add eax,ecx |
2168 | add eax,ecx |
Line 2283... | Line 2285... | ||
2283 | inc esi |
2285 | inc esi |
2284 | dec dword[edi+deflate_state.insert] |
2286 | dec dword[edi+deflate_state.insert] |
2285 | mov eax,[edi+deflate_state.lookahead] |
2287 | mov eax,[edi+deflate_state.lookahead] |
2286 | add eax,[edi+deflate_state.insert] |
2288 | add eax,[edi+deflate_state.insert] |
2287 | cmp eax,MIN_MATCH |
2289 | cmp eax,MIN_MATCH |
2288 | jl .end1 ;if (..<..) break |
2290 | jb .end1 ;if (..<..) break |
2289 | jmp .cycle3 |
2291 | jmp .cycle3 |
2290 | .end1: |
2292 | .end1: |
2291 | ; If the whole input has less than MIN_MATCH bytes, ins_h is garbage, |
2293 | ; If the whole input has less than MIN_MATCH bytes, ins_h is garbage, |
2292 | ; but this is not important since only literal bytes will be emitted. |
2294 | ; but this is not important since only literal bytes will be emitted. |
Line 2293... | Line 2295... | ||
2293 | 2295 | ||
2294 | cmp dword[edi+deflate_state.lookahead],MIN_LOOKAHEAD |
2296 | cmp dword[edi+deflate_state.lookahead],MIN_LOOKAHEAD |
2295 | jge .cycle0end |
2297 | jae .cycle0end |
2296 | cmp dword[edx+z_stream.avail_in],0 |
2298 | cmp dword[edx+z_stream.avail_in],0 |
2297 | jne .cycle0 |
2299 | jne .cycle0 |
2298 | align 4 |
2300 | align 4 |
Line 2305... | Line 2307... | ||
2305 | ; time through here. WIN_INIT is set to MAX_MATCH since the longest match |
2307 | ; time through here. WIN_INIT is set to MAX_MATCH since the longest match |
2306 | ; routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. |
2308 | ; routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. |
Line 2307... | Line 2309... | ||
2307 | 2309 | ||
2308 | mov eax,[edi+deflate_state.window_size] |
2310 | mov eax,[edi+deflate_state.window_size] |
2309 | cmp [edi+deflate_state.high_water],eax |
2311 | cmp [edi+deflate_state.high_water],eax |
2310 | jge .end2 ;if (..<..) |
2312 | jae .end2 ;if (..<..) |
2311 | mov esi,[edi+deflate_state.lookahead] |
2313 | mov esi,[edi+deflate_state.lookahead] |
2312 | add esi,[edi+deflate_state.strstart] |
2314 | add esi,[edi+deflate_state.strstart] |
Line 2313... | Line 2315... | ||
2313 | ;esi = curr |
2315 | ;esi = curr |
2314 | 2316 | ||
2315 | cmp [edi+deflate_state.high_water],esi |
2317 | cmp [edi+deflate_state.high_water],esi |
2316 | jge .end3 ;if (..<..) |
2318 | jae .end3 ;if (..<..) |
Line 2317... | Line 2319... | ||
2317 | ; Previous high water mark below current data -- zero WIN_INIT |
2319 | ; Previous high water mark below current data -- zero WIN_INIT |
2318 | ; bytes or up to end of window, whichever is less. |
2320 | ; bytes or up to end of window, whichever is less. |
2319 | 2321 | ||
2320 | mov eax,[edi+deflate_state.window_size] |
2322 | mov eax,[edi+deflate_state.window_size] |
2321 | sub eax,esi |
2323 | sub eax,esi |
2322 | cmp eax,WIN_INIT |
2324 | cmp eax,WIN_INIT |
2323 | jle @f ;if (..>..) |
2325 | jbe @f ;if (..>..) |
2324 | mov eax,WIN_INIT |
2326 | mov eax,WIN_INIT |
2325 | @@: |
2327 | @@: |
Line 2331... | Line 2333... | ||
2331 | jmp .end2 |
2333 | jmp .end2 |
2332 | .end3: ;else if (..<..) |
2334 | .end3: ;else if (..<..) |
2333 | mov eax,esi |
2335 | mov eax,esi |
2334 | add eax,WIN_INIT |
2336 | add eax,WIN_INIT |
2335 | cmp [edi+deflate_state.high_water],eax |
2337 | cmp [edi+deflate_state.high_water],eax |
2336 | jge .end2 |
2338 | jae .end2 |
2337 | ; High water mark at or above current data, but below current data |
2339 | ; High water mark at or above current data, but below current data |
2338 | ; plus WIN_INIT -- zero out to current data plus WIN_INIT, or up |
2340 | ; plus WIN_INIT -- zero out to current data plus WIN_INIT, or up |
2339 | ; to end of window, whichever is less. |
2341 | ; to end of window, whichever is less. |
Line 2340... | Line 2342... | ||
2340 | 2342 | ||
2341 | ;eax = esi+WIN_INIT |
2343 | ;eax = esi+WIN_INIT |
2342 | sub eax,[edi+deflate_state.high_water] |
2344 | sub eax,[edi+deflate_state.high_water] |
2343 | mov edx,[edi+deflate_state.window_size] |
2345 | mov edx,[edi+deflate_state.window_size] |
2344 | sub edx,[edi+deflate_state.high_water] |
2346 | sub edx,[edi+deflate_state.high_water] |
2345 | cmp eax,edx ;if (..>..) |
2347 | cmp eax,edx ;if (..>..) |
2346 | jle @f |
2348 | jbe @f |
2347 | mov eax,edx |
2349 | mov eax,edx |
2348 | @@: |
2350 | @@: |
2349 | mov edx,[edi+deflate_state.window] |
2351 | mov edx,[edi+deflate_state.window] |
2350 | add edx,[edi+deflate_state.high_water] |
2352 | add edx,[edi+deflate_state.high_water] |
Line 2680... | Line 2682... | ||
2680 | ; at the end of the input file. We need MAX_MATCH bytes |
2682 | ; at the end of the input file. We need MAX_MATCH bytes |
2681 | ; for the next match, plus MIN_MATCH bytes to insert the |
2683 | ; for the next match, plus MIN_MATCH bytes to insert the |
2682 | ; string following the next match. |
2684 | ; string following the next match. |
Line 2683... | Line 2685... | ||
2683 | 2685 | ||
2684 | cmp dword[edi+deflate_state.lookahead],MIN_LOOKAHEAD |
2686 | cmp dword[edi+deflate_state.lookahead],MIN_LOOKAHEAD |
2685 | jge .end0 ;if (..<..) |
2687 | jae .end0 ;if (..<..) |
2686 | stdcall fill_window, edi |
2688 | stdcall fill_window, edi |
2687 | cmp dword[edi+deflate_state.lookahead],MIN_LOOKAHEAD |
2689 | cmp dword[edi+deflate_state.lookahead],MIN_LOOKAHEAD |
2688 | jge @f ;if (..<.. && ..==..) |
2690 | jae @f ;if (..<.. && ..==..) |
2689 | cmp dword[flush],Z_NO_FLUSH |
2691 | cmp dword[flush],Z_NO_FLUSH |
2690 | jne @f |
2692 | jne @f |
2691 | mov eax,need_more |
2693 | mov eax,need_more |
2692 | jmp .end_f |
2694 | jmp .end_f |
Line 2700... | Line 2702... | ||
2700 | ; Insert the string window[strstart .. strstart+2] in the |
2702 | ; Insert the string window[strstart .. strstart+2] in the |
2701 | ; dictionary, and set hash_head to the head of the hash chain: |
2703 | ; dictionary, and set hash_head to the head of the hash chain: |
Line 2702... | Line 2704... | ||
2702 | 2704 | ||
2703 | mov ecx,NIL |
2705 | mov ecx,NIL |
2704 | cmp dword[edi+deflate_state.lookahead],MIN_MATCH |
2706 | cmp dword[edi+deflate_state.lookahead],MIN_MATCH |
2705 | jl @f ;if (..>=..) |
2707 | jb @f ;if (..>=..) |
2706 | INSERT_STRING edi, [edi+deflate_state.strstart], ecx |
2708 | INSERT_STRING edi, [edi+deflate_state.strstart], ecx |
Line 2707... | Line 2709... | ||
2707 | @@: |
2709 | @@: |
Line 2716... | Line 2718... | ||
2716 | 2718 | ||
2717 | cmp ecx,NIL |
2719 | cmp ecx,NIL |
2718 | je .end1 |
2720 | je .end1 |
2719 | mov eax,[edi+deflate_state.prev_length] |
2721 | mov eax,[edi+deflate_state.prev_length] |
2720 | cmp eax,[edi+deflate_state.max_lazy_match] |
2722 | cmp eax,[edi+deflate_state.max_lazy_match] |
2721 | jge .end1 |
2723 | jae .end1 |
2722 | MAX_DIST edi |
2724 | MAX_DIST edi |
2723 | mov ebx,[edi+deflate_state.strstart] |
2725 | mov ebx,[edi+deflate_state.strstart] |
2724 | sub ebx,ecx |
2726 | sub ebx,ecx |
2725 | cmp ebx,eax |
2727 | cmp ebx,eax |
2726 | jg .end1 ;if (..!=0 && ..<.. && ..<=..) |
2728 | ja .end1 ;if (..!=0 && ..<.. && ..<=..) |
2727 | ; To simplify the code, we prevent matches with the string |
2729 | ; To simplify the code, we prevent matches with the string |
2728 | ; of window index 0 (in particular we have to avoid a match |
2730 | ; of window index 0 (in particular we have to avoid a match |
Line 2729... | Line 2731... | ||
2729 | ; of the string with itself at the start of the input file). |
2731 | ; of the string with itself at the start of the input file). |
2730 | 2732 | ||
2731 | stdcall longest_match, edi, ecx |
2733 | stdcall longest_match, edi, ecx |
Line 2732... | Line 2734... | ||
2732 | mov [edi+deflate_state.match_length],eax |
2734 | mov [edi+deflate_state.match_length],eax |
2733 | ; longest_match() sets match_start |
2735 | ; longest_match() sets match_start |
2734 | 2736 | ||
2735 | cmp dword[edi+deflate_state.match_length],5 |
2737 | cmp dword[edi+deflate_state.match_length],5 |
2736 | jg .end1 |
2738 | ja .end1 |
2737 | cmp word[edi+deflate_state.strategy],Z_FILTERED |
2739 | cmp word[edi+deflate_state.strategy],Z_FILTERED |
2738 | if TOO_FAR <= 32767 |
2740 | if TOO_FAR <= 32767 |
2739 | je @f |
2741 | je @f |
2740 | cmp dword[edi+deflate_state.match_length],MIN_MATCH |
2742 | cmp dword[edi+deflate_state.match_length],MIN_MATCH |
2741 | jne .end1 |
2743 | jne .end1 |
2742 | mov eax,[edi+deflate_state.strstart] |
2744 | mov eax,[edi+deflate_state.strstart] |
2743 | sub eax,[edi+deflate_state.match_start] |
2745 | sub eax,[edi+deflate_state.match_start] |
2744 | cmp eax,TOO_FAR |
2746 | cmp eax,TOO_FAR |
2745 | jle .end1 ;if (..<=.. && (..==.. || (..==.. && ..>..))) |
2747 | jbe .end1 ;if (..<=.. && (..==.. || (..==.. && ..>..))) |
2746 | @@: |
2748 | @@: |
2747 | else |
2749 | else |
Line 2756... | Line 2758... | ||
2756 | ; match is not better, output the previous match: |
2758 | ; match is not better, output the previous match: |
Line 2757... | Line 2759... | ||
2757 | 2759 | ||
2758 | 2760 | ||
2759 | mov eax,[edi+deflate_state.prev_length] |
2761 | mov eax,[edi+deflate_state.prev_length] |
2760 | cmp eax,MIN_MATCH |
2762 | cmp eax,MIN_MATCH |
2761 | jl .end2 |
2763 | jb .end2 |
2762 | cmp [edi+deflate_state.match_length],eax |
2764 | cmp [edi+deflate_state.match_length],eax |
2763 | jg .end2 ;if (..>=.. && ..<=..) |
2765 | ja .end2 ;if (..>=.. && ..<=..) |
2764 | mov edx,[edi+deflate_state.strstart] |
2766 | mov edx,[edi+deflate_state.strstart] |
2765 | add edx,[edi+deflate_state.lookahead] |
2767 | add edx,[edi+deflate_state.lookahead] |
2766 | sub edx,MIN_MATCH |
2768 | sub edx,MIN_MATCH |
Line 2788... | Line 2790... | ||
2788 | sub [edi+deflate_state.lookahead],eax |
2790 | sub [edi+deflate_state.lookahead],eax |
2789 | sub dword[edi+deflate_state.prev_length],2 |
2791 | sub dword[edi+deflate_state.prev_length],2 |
2790 | .cycle1: ;do |
2792 | .cycle1: ;do |
2791 | inc dword[edi+deflate_state.strstart] |
2793 | inc dword[edi+deflate_state.strstart] |
2792 | cmp [edi+deflate_state.strstart],edx |
2794 | cmp [edi+deflate_state.strstart],edx |
2793 | jg @f ;if (..<=..) |
2795 | ja @f ;if (..<=..) |
2794 | INSERT_STRING edi, [edi+deflate_state.strstart], ecx |
2796 | INSERT_STRING edi, [edi+deflate_state.strstart], ecx |
2795 | @@: |
2797 | @@: |
2796 | dec dword[edi+deflate_state.prev_length] |
2798 | dec dword[edi+deflate_state.prev_length] |
2797 | cmp dword[edi+deflate_state.prev_length],0 |
2799 | cmp dword[edi+deflate_state.prev_length],0 |
2798 | jne .cycle1 ;while (..!=0) |
2800 | jne .cycle1 ;while (..!=0) |
Line 2854... | Line 2856... | ||
2854 | _tr_tally_lit edi, eax, [bflush] |
2856 | _tr_tally_lit edi, eax, [bflush] |
2855 | mov dword[edi+deflate_state.match_available],0 |
2857 | mov dword[edi+deflate_state.match_available],0 |
2856 | @@: |
2858 | @@: |
2857 | mov eax,[edi+deflate_state.strstart] |
2859 | mov eax,[edi+deflate_state.strstart] |
2858 | cmp eax,MIN_MATCH-1 |
2860 | cmp eax,MIN_MATCH-1 |
2859 | jl @f |
2861 | jb @f |
2860 | mov eax,MIN_MATCH-1 |
2862 | mov eax,MIN_MATCH-1 |
2861 | @@: |
2863 | @@: |
2862 | mov [edi+deflate_state.insert],eax |
2864 | mov [edi+deflate_state.insert],eax |
2863 | cmp dword[flush],Z_FINISH |
2865 | cmp dword[flush],Z_FINISH |
2864 | jne @f ;if (..==..) |
2866 | jne @f ;if (..==..) |