Rev 6851 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6851 | Rev 6863 | ||
---|---|---|---|
Line 285... | Line 285... | ||
285 | je @f ;if (..!=0) |
285 | je @f ;if (..!=0) |
286 | mov dword[level],1 |
286 | mov dword[level],1 |
287 | @@: |
287 | @@: |
288 | else |
288 | else |
289 | cmp dword[level],Z_DEFAULT_COMPRESSION |
289 | cmp dword[level],Z_DEFAULT_COMPRESSION |
290 | jne @f ;if (..==0) |
290 | jne @f ;if (..==..) |
291 | mov dword[level],6 |
291 | mov dword[level],6 |
292 | @@: |
292 | @@: |
293 | end if |
293 | end if |
Line 294... | Line 294... | ||
294 | 294 | ||
295 | cmp dword[windowBits],0 |
295 | cmp dword[windowBits],0 |
296 | jge @f ;if (..<0) ;suppress zlib wrapper |
296 | jge @f ;if (..<0) ;suppress zlib wrapper |
297 | mov dword[wrap],0 |
297 | mov dword[wrap],0 |
298 | neg dword[windowBits] |
- | |
299 | inc dword[windowBits] |
298 | neg dword[windowBits] |
300 | jmp .end1 |
299 | jmp .end1 |
301 | @@: |
300 | @@: |
302 | if GZIP eq 1 |
301 | if GZIP eq 1 |
303 | cmp dword[windowBits],15 |
302 | cmp dword[windowBits],15 |
Line 409... | Line 408... | ||
409 | stdcall deflateEnd, ebx |
408 | stdcall deflateEnd, ebx |
410 | mov eax,Z_MEM_ERROR |
409 | mov eax,Z_MEM_ERROR |
411 | jmp .end_f |
410 | jmp .end_f |
412 | @@: |
411 | @@: |
413 | mov eax,[edi+deflate_state.lit_bufsize] |
412 | mov eax,[edi+deflate_state.lit_bufsize] |
414 | shr eax,1 ;/=sizeof(uint_16) |
- | |
415 | add eax,[overlay] |
413 | add eax,[overlay] |
416 | mov [edi+deflate_state.d_buf],eax |
414 | mov [edi+deflate_state.d_buf],eax |
417 | mov eax,[edi+deflate_state.lit_bufsize] |
415 | mov eax,[edi+deflate_state.lit_bufsize] |
418 | imul eax,3 ;1+sizeof(uint_16) |
416 | imul eax,3 ;1+sizeof(uint_16) |
419 | add eax,[edi+deflate_state.pending_buf] |
417 | add eax,[edi+deflate_state.pending_buf] |
Line 426... | Line 424... | ||
426 | mov eax,[method] |
424 | mov eax,[method] |
427 | mov [edi+deflate_state.method],al |
425 | mov [edi+deflate_state.method],al |
Line 428... | Line 426... | ||
428 | 426 | ||
429 | stdcall deflateReset, ebx |
427 | stdcall deflateReset, ebx |
430 | .end_f: |
- | |
431 | zlib_debug 'deflateInit2_ strategy = %d',[strategy] |
428 | .end_f: |
432 | ret |
429 | ret |
Line 433... | Line 430... | ||
433 | endp |
430 | endp |
434 | 431 | ||
Line 626... | Line 623... | ||
626 | ;int (strm) |
623 | ;int (strm) |
627 | ; z_streamp strm |
624 | ; z_streamp strm |
628 | align 4 |
625 | align 4 |
629 | proc deflateReset uses ebx, strm:dword |
626 | proc deflateReset uses ebx, strm:dword |
630 | mov ebx,[strm] |
627 | mov ebx,[strm] |
631 | zlib_debug 'deflateReset' |
- | |
632 | stdcall deflateResetKeep, ebx |
628 | stdcall deflateResetKeep, ebx |
633 | cmp eax,Z_OK |
629 | cmp eax,Z_OK |
634 | jne @f ;if (..==Z_OK) |
630 | jne @f ;if (..==Z_OK) |
635 | stdcall lm_init, [ebx+z_stream.state] |
631 | stdcall lm_init, [ebx+z_stream.state] |
636 | @@: |
632 | @@: |
Line 763... | Line 759... | ||
763 | je @f ;if (..!=0) |
759 | je @f ;if (..!=0) |
764 | mov dword[level],1 |
760 | mov dword[level],1 |
765 | @@: |
761 | @@: |
766 | else |
762 | else |
767 | cmp dword[level],Z_DEFAULT_COMPRESSION |
763 | cmp dword[level],Z_DEFAULT_COMPRESSION |
768 | jne @f ;if (..==0) |
764 | jne @f ;if (..==..) |
769 | mov dword[level],6 |
765 | mov dword[level],6 |
770 | @@: |
766 | @@: |
771 | end if |
767 | end if |
772 | cmp dword[level],0 |
768 | cmp dword[level],0 |
773 | jl @f |
769 | jl @f |
Line 855... | Line 851... | ||
855 | ; This function could be more sophisticated to provide closer upper bounds for |
851 | ; This function could be more sophisticated to provide closer upper bounds for |
856 | ; every combination of windowBits and memLevel. But even the conservative |
852 | ; every combination of windowBits and memLevel. But even the conservative |
857 | ; upper bound of about 14% expansion does not seem onerous for output buffer |
853 | ; upper bound of about 14% expansion does not seem onerous for output buffer |
858 | ; allocation. |
854 | ; allocation. |
Line 859... | Line 855... | ||
859 | 855 | ||
860 | ;uLong (strm, sourceLen) |
- | |
861 | ; z_streamp strm |
- | |
862 | ; uLong sourceLen |
856 | ;uLong (z_streamp strm, uLong sourceLen) |
863 | align 4 |
857 | align 4 |
864 | proc deflateBound, strm:dword, sourceLen:dword |
858 | proc deflateBound uses ebx edi, strm:dword, sourceLen:dword |
865 | ; deflate_state *s; |
859 | locals |
866 | ; uLong complen, wraplen; |
860 | complen dd ? |
- | 861 | wraplen dd ? |
|
867 | ; Bytef *str; |
862 | endl |
Line 868... | Line 863... | ||
868 | zlib_debug 'deflateBound' |
863 | ;edi = s |
869 | 864 | ||
- | 865 | ; conservative upper bound for compressed data |
|
- | 866 | mov ebx,[sourceLen] |
|
- | 867 | mov eax,ebx |
|
- | 868 | add eax,7 |
|
- | 869 | shr eax,3 |
|
- | 870 | add eax,ebx |
|
870 | ; conservative upper bound for compressed data |
871 | add ebx,63 |
- | 872 | shr ebx,6 |
|
Line 871... | Line 873... | ||
871 | ; complen = sourceLen + |
873 | lea eax,[eax+ebx+5] |
- | 874 | mov [complen],eax |
|
- | 875 | ||
- | 876 | ; if can't get parameters, return conservative bound plus zlib wrapper |
|
872 | ; ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; |
877 | mov eax,[strm] |
- | 878 | cmp eax,Z_NULL |
|
- | 879 | je .end0 |
|
- | 880 | mov edi,[eax+z_stream.state] ;s = strm.state |
|
873 | 881 | cmp edi,Z_NULL |
|
- | 882 | jne @f |
|
- | 883 | .end0: ;if (..==0 || ..==0) |
|
- | 884 | mov eax,[complen] |
|
Line 874... | Line 885... | ||
874 | ; if can't get parameters, return conservative bound plus zlib wrapper |
885 | add eax,6 |
875 | ; if (strm == Z_NULL || strm->state == Z_NULL) |
886 | jmp .end_f |
876 | ; return complen + 6; |
887 | @@: |
- | 888 | ||
- | 889 | ; compute wrapper length |
|
- | 890 | mov ebx,[edi+deflate_state.wrap] |
|
- | 891 | cmp ebx,0 |
|
- | 892 | je .end1 |
|
- | 893 | cmp ebx,1 |
|
877 | 894 | je .end2 |
|
878 | ; compute wrapper length |
895 | cmp ebx,2 |
879 | ; s = strm->state; |
896 | je .end3 |
880 | ; switch (s->wrap) { |
897 | jmp .end4 |
881 | ; case 0: /* raw deflate */ |
898 | .end1: ;raw deflate |
- | 899 | mov dword[wraplen],0 |
|
882 | ; wraplen = 0; |
900 | jmp .end5 |
- | 901 | .end2: ;zlib wrapper |
|
- | 902 | mov eax,[edi+deflate_state.strstart] |
|
- | 903 | neg eax |
|
- | 904 | sbb eax,eax |
|
883 | ; break; |
905 | and eax,4 |
884 | ; case 1: /* zlib wrapper */ |
906 | add eax,6 |
885 | ; wraplen = 6 + (s->strstart ? 4 : 0); |
907 | mov [wraplen],eax |
- | 908 | jmp .end5 |
|
886 | ; break; |
909 | .end3: ;gzip wrapper |
887 | ; case 2: /* gzip wrapper */ |
910 | mov dword[wraplen],18 |
- | 911 | cmp dword[edi+deflate_state.gzhead],Z_NULL ;user-supplied gzip header |
|
888 | ; wraplen = 18; |
912 | je .end5 |
889 | ; if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ |
913 | mov eax,[edi+deflate_state.gzhead] |
890 | ; if (s->gzhead->extra != Z_NULL) |
914 | cmp dword[eax+gz_header.extra],0 |
891 | ; wraplen += 2 + s->gzhead->extra_len; |
915 | je @f |
- | 916 | mov eax,[edi+deflate_state.gzhead] |
|
892 | ; str = s->gzhead->name; |
917 | mov eax,[eax+gz_header.extra_len] |
893 | ; if (str != Z_NULL) |
918 | add dword[wraplen],eax |
- | 919 | add dword[wraplen],2 |
|
- | 920 | @@: |
|
- | 921 | mov eax,[edi+deflate_state.gzhead] |
|
- | 922 | mov eax,[eax+gz_header.name] |
|
- | 923 | cmp eax,0 |
|
- | 924 | je @f |
|
- | 925 | .cycle0: ;do |
|
- | 926 | inc dword[wraplen] |
|
- | 927 | movzx ebx,byte[eax] |
|
894 | ; do { |
928 | inc eax |
- | 929 | test ebx,ebx |
|
- | 930 | jne .cycle0 |
|
- | 931 | @@: |
|
895 | ; wraplen++; |
932 | mov eax,[edi+deflate_state.gzhead] |
896 | ; } while (*str++); |
933 | mov eax,[eax+gz_header.comment] |
897 | ; str = s->gzhead->comment; |
934 | cmp eax,0 |
- | 935 | je @f |
|
- | 936 | .cycle1: ;do |
|
- | 937 | inc dword[wraplen] |
|
- | 938 | movzx ebx,byte[eax] |
|
898 | ; if (str != Z_NULL) |
939 | inc eax |
899 | ; do { |
940 | test ebx,ebx |
900 | ; wraplen++; |
941 | jne .cycle1 |
- | 942 | @@: |
|
901 | ; } while (*str++); |
943 | mov eax,[edi+deflate_state.gzhead] |
902 | ; if (s->gzhead->hcrc) |
944 | cmp dword[eax+gz_header.hcrc],0 |
903 | ; wraplen += 2; |
945 | je .end5 |
904 | ; } |
946 | add dword[wraplen],2 |
Line 905... | Line 947... | ||
905 | ; break; |
947 | jmp .end5 |
- | 948 | .end4: ;for compiler happiness |
|
- | 949 | mov dword[wraplen],6 |
|
- | 950 | .end5: |
|
- | 951 | ||
906 | ; default: /* for compiler happiness */ |
952 | ; if not default parameters, return conservative bound |
- | 953 | cmp dword[edi+deflate_state.w_bits],15 |
|
907 | ; wraplen = 6; |
954 | jne .end6 |
- | 955 | cmp dword[edi+deflate_state.hash_bits],8+7 |
|
- | 956 | je @f |
|
Line 908... | Line 957... | ||
908 | ; } |
957 | .end6: ;if (s->w_bits !=.. || s->hash_bits !=..) |
909 | 958 | mov eax,[complen] |
|
- | 959 | add eax,[wraplen] |
|
- | 960 | jmp .end_f |
|
- | 961 | @@: |
|
- | 962 | ||
- | 963 | ; default settings: return tight bound for that case |
|
- | 964 | mov eax,[sourceLen] |
|
- | 965 | mov ebx,eax |
|
910 | ; if not default parameters, return conservative bound |
966 | shr ebx,12 |
- | 967 | add ebx,eax |
|
911 | ; if (s->w_bits != 15 || s->hash_bits != 8 + 7) |
968 | mov edi,eax |
912 | ; return complen + wraplen; |
969 | shr edi,14 |
913 | 970 | add ebx,edi |
|
Line 914... | Line 971... | ||
914 | ; default settings: return tight bound for that case |
971 | shr eax,25 |
915 | ; return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
972 | add ebx,[wraplen] |
916 | ; (sourceLen >> 25) + 13 - 6 + wraplen; |
973 | lea eax,[eax+ebx+7] |
917 | .end_f: |
974 | .end_f: |
Line 918... | Line -... | ||
918 | ret |
- | |
919 | endp |
975 | ret |
920 | - | ||
921 | ; ========================================================================= |
976 | endp |
922 | ; Put a short in the pending buffer. The 16-bit value is put in MSB order. |
977 | |
923 | ; IN assertion: the stream state is correct and there is enough room in |
978 | ; ========================================================================= |
924 | ; pending_buf. |
979 | ; Put a short in the pending buffer. The 16-bit value is put in MSB order. |
925 | 980 | ; IN assertion: the stream state is correct and there is enough room in |
|
926 | ;void (s, b) |
981 | ; pending_buf. |
927 | ; deflate_state *s |
982 | |
Line 2002... | Line 2057... | ||
2002 | else ;FASTEST |
2057 | else ;FASTEST |
Line 2003... | Line 2058... | ||
2003 | 2058 | ||
2004 | ; --------------------------------------------------------------------------- |
2059 | ; --------------------------------------------------------------------------- |
2005 | ; Optimized version for FASTEST only |
2060 | ; Optimized version for FASTEST only |
2006 | mov edx,[s] |
- | |
Line 2007... | Line 2061... | ||
2007 | zlib_debug 'longest_match' |
2061 | mov edx,[s] |
2008 | 2062 | ||
Line 2009... | Line 2063... | ||
2009 | ; The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. |
2063 | ; The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. |
Line 2242... | Line 2296... | ||
2242 | 2296 | ||
2243 | ; Initialize the hash value now that we have some input: |
2297 | ; Initialize the hash value now that we have some input: |
2244 | mov eax,[edi+deflate_state.lookahead] |
2298 | mov eax,[edi+deflate_state.lookahead] |
2245 | add eax,[edi+deflate_state.insert] |
2299 | add eax,[edi+deflate_state.insert] |
2246 | cmp eax,MIN_MATCH |
2300 | cmp eax,MIN_MATCH |
2247 | jl .end1 ;if (..>=..) |
2301 | jb .end1 ;if (..>=..) |
2248 | mov esi,[edi+deflate_state.strstart] |
2302 | mov esi,[edi+deflate_state.strstart] |
2249 | sub esi,[edi+deflate_state.insert] |
2303 | sub esi,[edi+deflate_state.insert] |
2250 | ;esi = str |
2304 | ;esi = str |
2251 | mov eax,[edi+deflate_state.window] |
2305 | mov eax,[edi+deflate_state.window] |
Line 2412... | Line 2466... | ||
2412 | ; uncompressible data is probably not useful. This function is used |
2466 | ; uncompressible data is probably not useful. This function is used |
2413 | ; only for the level=0 compression option. |
2467 | ; only for the level=0 compression option. |
2414 | ; NOTE: this function should be optimized to avoid extra copying from |
2468 | ; NOTE: this function should be optimized to avoid extra copying from |
2415 | ; window to pending_buf. |
2469 | ; window to pending_buf. |
Line 2416... | Line 2470... | ||
2416 | 2470 | ||
2417 | ;block_state (s, flush) |
- | |
2418 | ; deflate_state *s |
- | |
2419 | ; int flush |
2471 | ;block_state (deflate_state *s, int flush) |
2420 | align 4 |
2472 | align 4 |
2421 | proc deflate_stored uses ebx ecx edi, s:dword, flush:dword |
2473 | proc deflate_stored uses ebx ecx edi, s:dword, flush:dword |
2422 | ; Stored blocks are limited to 0xffff bytes, pending_buf is limited |
2474 | ; Stored blocks are limited to 0xffff bytes, pending_buf is limited |
2423 | ; to pending_buf_size, and each stored block has a 5 byte header: |
2475 | ; to pending_buf_size, and each stored block has a 5 byte header: |