Rev 6819 | Rev 6851 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6819 | Rev 6847 | ||
---|---|---|---|
Line 53... | Line 53... | ||
53 | 53 | ||
54 | ; =========================================================================== |
54 | ; =========================================================================== |
Line 55... | Line 55... | ||
55 | ; Function prototypes. |
55 | ; Function prototypes. |
56 | 56 | ||
57 | ;enum block_state |
57 | ;enum block_state |
58 | need_more equ 1 ;block not completed, need more input or more output |
58 | need_more equ 0 ;block not completed, need more input or more output |
59 | block_done equ 2 ;block flush performed |
59 | block_done equ 1 ;block flush performed |
Line 60... | Line 60... | ||
60 | finish_started equ 3 ;finish started, need only more output at next deflate |
60 | finish_started equ 2 ;finish started, need only more output at next deflate |
61 | finish_done equ 4 ;finish done, accept no more input or output |
61 | finish_done equ 3 ;finish done, accept no more input or output |
Line 62... | Line 62... | ||
62 | 62 | ||
Line 152... | Line 152... | ||
152 | add eax,str |
152 | add eax,str |
153 | add eax,MIN_MATCH-1 |
153 | add eax,MIN_MATCH-1 |
154 | movzx eax,byte[eax] |
154 | movzx eax,byte[eax] |
155 | UPDATE_HASH s, [s+deflate_state.ins_h], eax |
155 | UPDATE_HASH s, [s+deflate_state.ins_h], eax |
156 | mov eax,[s+deflate_state.ins_h] |
156 | mov eax,[s+deflate_state.ins_h] |
157 | shl eax,2 |
157 | shl eax,1 |
158 | add eax,[s+deflate_state.head] |
158 | add eax,[s+deflate_state.head] |
159 | mov eax,[eax] |
159 | movzx eax,word[eax] |
160 | mov match_head,eax |
160 | mov match_head,eax |
161 | if FASTEST eq 0 |
- | |
162 | push ebx |
161 | push ebx |
- | 162 | if FASTEST eq 0 |
|
163 | mov ebx,[s+deflate_state.w_mask] |
163 | mov ebx,[s+deflate_state.w_mask] |
164 | and ebx,str |
164 | and ebx,str |
165 | shl ebx,2 |
165 | shl ebx,1 |
166 | add ebx,[s+deflate_state.prev] |
166 | add ebx,[s+deflate_state.prev] |
167 | mov [ebx],eax |
167 | mov [ebx],ax |
168 | pop ebx |
168 | |
169 | end if |
169 | end if |
170 | mov eax,[s+deflate_state.ins_h] |
170 | mov eax,[s+deflate_state.ins_h] |
171 | shl eax,2 |
171 | shl eax,1 |
172 | add eax,[s+deflate_state.head] |
172 | add eax,[s+deflate_state.head] |
173 | push str |
173 | mov ebx,str |
174 | pop dword[eax] |
174 | mov [eax],bx |
- | 175 | pop ebx |
|
175 | } |
176 | } |
Line 176... | Line 177... | ||
176 | 177 | ||
177 | ; =========================================================================== |
178 | ; =========================================================================== |
178 | ; Initialize the hash table (avoiding 64K overflow for 16 bit systems). |
179 | ; Initialize the hash table (avoiding 64K overflow for 16 bit systems). |
Line 179... | Line 180... | ||
179 | ; prev[] will be initialized on the fly. |
180 | ; prev[] will be initialized on the fly. |
180 | 181 | ||
181 | macro CLEAR_HASH s |
182 | macro CLEAR_HASH s |
182 | { |
183 | { |
183 | ;mov eax,[s+deflate_state.hash_size] |
184 | ;mov eax,[s+deflate_state.hash_size] |
184 | ;dec eax |
185 | ;dec eax |
185 | ;shl eax,2 |
186 | ;shl eax,1 |
186 | ;add eax,[s+deflate_state.head] |
187 | ;add eax,[s+deflate_state.head] |
187 | ;mov dword[eax],NIL |
188 | ;mov word[eax],NIL |
188 | mov eax,[s+deflate_state.hash_size] |
189 | mov eax,[s+deflate_state.hash_size] |
189 | ;dec eax |
190 | ;dec eax |
190 | shl eax,2 ;sizeof(*s.head) |
191 | shl eax,1 ;sizeof(*s.head) |
Line 191... | Line 192... | ||
191 | stdcall zmemzero, [s+deflate_state.head], eax |
192 | stdcall zmemzero, [s+deflate_state.head], eax |
192 | } |
193 | } |
Line 370... | Line 371... | ||
370 | div ecx |
371 | div ecx |
371 | mov [edi+deflate_state.hash_shift],eax |
372 | mov [edi+deflate_state.hash_shift],eax |
Line 372... | Line 373... | ||
372 | 373 | ||
373 | ZALLOC ebx, [edi+deflate_state.w_size], 2 ;2*sizeof(Byte) |
374 | ZALLOC ebx, [edi+deflate_state.w_size], 2 ;2*sizeof(Byte) |
374 | mov [edi+deflate_state.window],eax |
375 | mov [edi+deflate_state.window],eax |
375 | ZALLOC ebx, [edi+deflate_state.w_size], 4 ;sizeof(Pos) |
376 | ZALLOC ebx, [edi+deflate_state.w_size], 2 ;sizeof(Pos) |
376 | mov [edi+deflate_state.prev],eax |
377 | mov [edi+deflate_state.prev],eax |
377 | ZALLOC ebx, [edi+deflate_state.hash_size], 4 ;sizeof(Pos) |
378 | ZALLOC ebx, [edi+deflate_state.hash_size], 2 ;sizeof(Pos) |
Line 378... | Line 379... | ||
378 | mov [edi+deflate_state.head],eax |
379 | mov [edi+deflate_state.head],eax |
Line 379... | Line 380... | ||
379 | 380 | ||
Line 520... | Line 521... | ||
520 | add eax,MIN_MATCH-1 |
521 | add eax,MIN_MATCH-1 |
521 | movzx eax,byte[eax] |
522 | movzx eax,byte[eax] |
522 | UPDATE_HASH edi, [edi+deflate_state.ins_h], eax |
523 | UPDATE_HASH edi, [edi+deflate_state.ins_h], eax |
523 | if FASTEST eq 0 |
524 | if FASTEST eq 0 |
524 | mov edx,[edi+deflate_state.ins_h] |
525 | mov edx,[edi+deflate_state.ins_h] |
525 | shl edx,2 |
526 | shl edx,1 |
526 | add edx,[edi+deflate_state.head] |
527 | add edx,[edi+deflate_state.head] |
527 | mov edx,[edx] ;edx = s.head[s.ins_h] |
528 | movzx edx,word[edx] ;edx = s.head[s.ins_h] |
528 | mov eax,esi |
529 | mov eax,esi |
529 | and eax,[edi+deflate_state.w_mask] |
530 | and eax,[edi+deflate_state.w_mask] |
530 | shl eax,2 |
531 | shl eax,1 |
531 | add eax,[edi+deflate_state.prev] |
532 | add eax,[edi+deflate_state.prev] |
532 | mov [eax],edx |
533 | mov [eax],dx |
533 | end if |
534 | end if |
534 | mov edx,[edi+deflate_state.ins_h] |
535 | mov edx,[edi+deflate_state.ins_h] |
535 | shl edx,2 |
536 | shl edx,1 |
536 | add edx,[edi+deflate_state.head] |
537 | add edx,[edi+deflate_state.head] |
537 | mov [edx],esi ;s.head[s.ins_h] = str |
538 | mov [edx],si ;s.head[s.ins_h] = str |
538 | inc esi |
539 | inc esi |
539 | dec ecx |
540 | dec ecx |
540 | jnz .cycle1 ;while (--..) |
541 | jnz .cycle1 ;while (--..) |
541 | mov [edi+deflate_state.strstart],esi |
542 | mov [edi+deflate_state.strstart],esi |
542 | mov [edi+deflate_state.lookahead],MIN_MATCH-1 |
543 | mov [edi+deflate_state.lookahead],MIN_MATCH-1 |
Line 938... | Line 939... | ||
938 | ; Flush as much pending output as possible. All deflate() output goes |
939 | ; Flush as much pending output as possible. All deflate() output goes |
939 | ; through this function so some applications may wish to modify it |
940 | ; through this function so some applications may wish to modify it |
940 | ; to avoid allocating a large strm->next_out buffer and copying into it. |
941 | ; to avoid allocating a large strm->next_out buffer and copying into it. |
941 | ; (See also read_buf()). |
942 | ; (See also read_buf()). |
Line 942... | Line -... | ||
942 | - | ||
943 | ;void (strm) |
943 | |
944 | ; z_streamp strm |
944 | ;void (z_streamp strm) |
945 | align 4 |
945 | align 16 |
946 | proc flush_pending uses eax ebx ecx edx, strm:dword |
946 | proc flush_pending uses eax ebx ecx edx, strm:dword |
947 | ;ecx - len |
947 | ;ecx - len |
948 | ;edx - deflate_state *s |
948 | ;edx - deflate_state *s |
949 | ;ebx - strm |
- | |
950 | zlib_debug 'flush_pending' |
949 | ;ebx - strm |
951 | mov ebx,[strm] |
950 | mov ebx,[strm] |
Line 952... | Line 951... | ||
952 | mov edx,[ebx+z_stream.state] |
951 | mov edx,[ebx+z_stream.state] |
953 | 952 | ||
954 | stdcall _tr_flush_bits, edx |
953 | stdcall _tr_flush_bits, edx |
955 | mov ecx,[edx+deflate_state.pending] |
954 | mov ecx,[edx+deflate_state.pending] |
956 | mov eax,[ebx+z_stream.avail_out] |
955 | mov eax,[ebx+z_stream.avail_out] |
957 | cmp ecx,eax |
956 | cmp ecx,eax |
958 | jle @f ;if (..>..) |
957 | jle @f ;if (..>..) |
959 | mov ecx,eax |
958 | mov ecx,eax |
960 | @@: |
959 | @@: |
Line 961... | Line 960... | ||
961 | cmp ecx,0 |
960 | test ecx,ecx |
962 | je @f |
961 | jz @f |
963 | 962 | ||
964 | stdcall zmemcpy, [ebx+z_stream.next_out], [edx+deflate_state.pending_out], ecx |
963 | stdcall zmemcpy, [ebx+z_stream.next_out], [edx+deflate_state.pending_out], ecx |
Line 977... | Line 976... | ||
977 | 976 | ||
978 | ; ========================================================================= |
977 | ; ========================================================================= |
979 | ;int (strm, flush) |
978 | ;int (strm, flush) |
980 | ; z_streamp strm |
979 | ; z_streamp strm |
981 | ; int flush |
980 | ; int flush |
982 | align 4 |
981 | align 16 |
983 | proc deflate uses ebx ecx edx edi esi, strm:dword, flush:dword |
982 | proc deflate uses ebx ecx edx edi esi, strm:dword, flush:dword |
984 | locals |
983 | locals |
985 | old_flush dd ? ;int ;value of flush param for previous deflate call |
984 | old_flush dd ? ;int ;value of flush param for previous deflate call |
986 | val dd ? |
985 | val dd ? |
987 | endl |
986 | endl |
988 | mov ebx,[strm] |
- | |
989 | zlib_debug 'deflate strm = %d',ebx |
987 | mov ebx,[strm] |
990 | cmp ebx,Z_NULL |
988 | cmp ebx,Z_NULL |
991 | je @f |
989 | je @f |
992 | mov edi,[ebx+z_stream.state] ;s = strm.state |
990 | mov edi,[ebx+z_stream.state] ;s = strm.state |
993 | cmp edi,Z_NULL |
991 | cmp edi,Z_NULL |
Line 1178... | Line 1176... | ||
1178 | je .end21 ;if (..!=..) |
1176 | je .end21 ;if (..!=..) |
1179 | mov esi,[edi+deflate_state.pending] |
1177 | mov esi,[edi+deflate_state.pending] |
1180 | ;esi = beg ;start of bytes to update crc |
1178 | ;esi = beg ;start of bytes to update crc |
Line 1181... | Line 1179... | ||
1181 | 1179 | ||
- | 1180 | movzx ecx,word[edx+gz_header.extra_len] |
|
1182 | movzx ecx,word[edx+gz_header.extra_len] |
1181 | align 4 |
1183 | .cycle0: ;while (..<..) |
1182 | .cycle0: ;while (..<..) |
1184 | cmp dword[edi+deflate_state.gzindex],ecx |
1183 | cmp dword[edi+deflate_state.gzindex],ecx |
1185 | jge .cycle0end |
1184 | jge .cycle0end |
1186 | mov eax,[edi+deflate_state.pending] |
1185 | mov eax,[edi+deflate_state.pending] |
Line 1286... | Line 1285... | ||
1286 | jne .end6 ;if (val == 0) |
1285 | jne .end6 ;if (val == 0) |
1287 | mov dword[edi+deflate_state.gzindex],0 |
1286 | mov dword[edi+deflate_state.gzindex],0 |
1288 | mov dword[edi+deflate_state.status],COMMENT_STATE |
1287 | mov dword[edi+deflate_state.status],COMMENT_STATE |
1289 | jmp .end6 |
1288 | jmp .end6 |
1290 | .end22: ;else |
1289 | .end22: ;else |
1291 | mov dword[edi+deflate_state.status],COMMENT_STATE; |
1290 | mov dword[edi+deflate_state.status],COMMENT_STATE |
1292 | .end6: |
1291 | .end6: |
1293 | cmp dword[edi+deflate_state.status],COMMENT_STATE |
1292 | cmp dword[edi+deflate_state.status],COMMENT_STATE |
1294 | jne .end7 ;if (..==..) |
1293 | jne .end7 ;if (..==..) |
1295 | cmp dword[edx+gz_header.comment],Z_NULL |
1294 | cmp dword[edx+gz_header.comment],Z_NULL |
1296 | je .end23 ;if (..!=..) |
1295 | je .end23 ;if (..!=..) |
Line 1359... | Line 1358... | ||
1359 | stdcall flush_pending, ebx |
1358 | stdcall flush_pending, ebx |
1360 | @@: |
1359 | @@: |
1361 | mov ecx,[edi+deflate_state.pending] |
1360 | mov ecx,[edi+deflate_state.pending] |
1362 | add ecx,2 |
1361 | add ecx,2 |
1363 | cmp ecx,[edi+deflate_state.pending_buf_size] |
1362 | cmp ecx,[edi+deflate_state.pending_buf_size] |
1364 | jg @f ;if (..<=..) |
1363 | jg .end8 ;if (..<=..) |
1365 | mov ecx,[ebx+z_stream.adler] |
1364 | mov ecx,[ebx+z_stream.adler] |
1366 | put_byte edi, cl |
1365 | put_byte edi, cl |
1367 | put_byte edi, ch |
1366 | put_byte edi, ch |
1368 | xor eax,eax ;stdcall calc_crc32, 0, Z_NULL, 0 |
1367 | xor eax,eax ;stdcall calc_crc32, 0, Z_NULL, 0 |
1369 | mov [ebx+z_stream.adler],eax |
1368 | mov [ebx+z_stream.adler],eax |
1370 | mov dword[edi+deflate_state.status],BUSY_STATE |
1369 | mov dword[edi+deflate_state.status],BUSY_STATE |
1371 | @@: |
- | |
1372 | jmp .end8 |
1370 | jmp .end8 |
1373 | .end9: ;else |
1371 | .end9: ;else |
1374 | mov dword[edi+deflate_state.status],BUSY_STATE |
1372 | mov dword[edi+deflate_state.status],BUSY_STATE |
1375 | .end8: |
1373 | .end8: |
1376 | end if |
1374 | end if |
Line 1388... | Line 1386... | ||
1388 | ; return OK instead of BUF_ERROR at next call of deflate: |
1386 | ; return OK instead of BUF_ERROR at next call of deflate: |
Line 1389... | Line 1387... | ||
1389 | 1387 | ||
1390 | mov dword[edi+deflate_state.last_flush],-1 |
1388 | mov dword[edi+deflate_state.last_flush],-1 |
1391 | mov eax,Z_OK |
1389 | mov eax,Z_OK |
1392 | jmp .end_f |
- | |
1393 | @@: |
1390 | jmp .end_f |
1394 | ; Make sure there is something to do and avoid duplicate consecutive |
1391 | ; Make sure there is something to do and avoid duplicate consecutive |
1395 | ; flushes. For repeated and useless calls with Z_FINISH, we keep |
1392 | ; flushes. For repeated and useless calls with Z_FINISH, we keep |
1396 | ; returning Z_STREAM_END instead of Z_BUF_ERROR. |
1393 | ; returning Z_STREAM_END instead of Z_BUF_ERROR. |
1397 | jmp @f |
1394 | align 4 |
1398 | .end13: |
1395 | .end13: |
1399 | cmp dword[ebx+z_stream.avail_in],0 |
1396 | cmp dword[ebx+z_stream.avail_in],0 |
1400 | jne @f |
1397 | jne @f |
1401 | RANK dword[old_flush],esi |
1398 | RANK dword[old_flush],esi |
Line 1552... | Line 1549... | ||
1552 | ;int (strm) |
1549 | ;int (strm) |
1553 | ; z_streamp strm |
1550 | ; z_streamp strm |
1554 | align 4 |
1551 | align 4 |
1555 | proc deflateEnd uses ebx ecx edx, strm:dword |
1552 | proc deflateEnd uses ebx ecx edx, strm:dword |
1556 | mov ebx,[strm] |
1553 | mov ebx,[strm] |
1557 | zlib_debug 'deflateEnd' |
- | |
1558 | cmp ebx,Z_NULL |
1554 | cmp ebx,Z_NULL |
1559 | je @f |
1555 | je @f |
1560 | mov edx,[ebx+z_stream.state] |
1556 | mov edx,[ebx+z_stream.state] |
1561 | cmp edx,Z_NULL |
1557 | cmp edx,Z_NULL |
1562 | jne .end0 |
1558 | jne .end0 |
Line 1642... | Line 1638... | ||
1642 | stdcall zmemcpy, edi, esi, sizeof.deflate_state |
1638 | stdcall zmemcpy, edi, esi, sizeof.deflate_state |
1643 | mov dword[edi+deflate_state.strm],edx |
1639 | mov dword[edi+deflate_state.strm],edx |
Line 1644... | Line 1640... | ||
1644 | 1640 | ||
1645 | ZALLOC edx, [edi+deflate_state.w_size], 2 ;2*sizeof.db |
1641 | ZALLOC edx, [edi+deflate_state.w_size], 2 ;2*sizeof.db |
1646 | mov dword[edi+deflate_state.window],eax |
1642 | mov dword[edi+deflate_state.window],eax |
1647 | ZALLOC edx, [edi+deflate_state.w_size], 4 ;sizeof.dd |
1643 | ZALLOC edx, [edi+deflate_state.w_size], 2 ;sizeof.dw |
1648 | mov dword[edi+deflate_state.prev],eax |
1644 | mov dword[edi+deflate_state.prev],eax |
1649 | ZALLOC edx, [edi+deflate_state.hash_size], 4 ;sizeof.dd |
1645 | ZALLOC edx, [edi+deflate_state.hash_size], 2 ;sizeof.dw |
1650 | mov dword[edi+deflate_state.head],eax |
1646 | mov dword[edi+deflate_state.head],eax |
1651 | ZALLOC edx, [edi+deflate_state.lit_bufsize], 4 ;sizeof.dw+2 |
1647 | ZALLOC edx, [edi+deflate_state.lit_bufsize], 4 ;sizeof.dw+2 |
1652 | mov ebx,eax |
1648 | mov ebx,eax |
Line 1669... | Line 1665... | ||
1669 | ; following zmemcpy do not work for 16-bit MSDOS |
1665 | ; following zmemcpy do not work for 16-bit MSDOS |
1670 | mov eax,[edi+deflate_state.w_size] |
1666 | mov eax,[edi+deflate_state.w_size] |
1671 | shl eax,1 ;*= 2*sizeof.db |
1667 | shl eax,1 ;*= 2*sizeof.db |
1672 | stdcall zmemcpy, [edi+deflate_state.window], [esi+deflate_state.window], eax |
1668 | stdcall zmemcpy, [edi+deflate_state.window], [esi+deflate_state.window], eax |
1673 | mov eax,[edi+deflate_state.w_size] |
1669 | mov eax,[edi+deflate_state.w_size] |
1674 | shl eax,2 ;*= sizeof.dd |
1670 | shl eax,1 ;*= sizeof.dw |
1675 | stdcall zmemcpy, [edi+deflate_state.prev], [esi+deflate_state.prev], eax |
1671 | stdcall zmemcpy, [edi+deflate_state.prev], [esi+deflate_state.prev], eax |
1676 | mov eax,[edi+deflate_state.hash_size] |
1672 | mov eax,[edi+deflate_state.hash_size] |
1677 | shl eax,2 ;*= sizeof.dd |
1673 | shl eax,1 ;*= sizeof.dw |
1678 | stdcall zmemcpy, [edi+deflate_state.head], [esi+deflate_state.head], eax |
1674 | stdcall zmemcpy, [edi+deflate_state.head], [esi+deflate_state.head], eax |
1679 | stdcall zmemcpy, [edi+deflate_state.pending_buf], [esi+deflate_state.pending_buf], [edi+deflate_state.pending_buf_size] |
1675 | stdcall zmemcpy, [edi+deflate_state.pending_buf], [esi+deflate_state.pending_buf], [edi+deflate_state.pending_buf_size] |
Line 1680... | Line 1676... | ||
1680 | 1676 | ||
1681 | mov eax,[edi+deflate_state.pending_buf] |
1677 | mov eax,[edi+deflate_state.pending_buf] |
Line 1713... | Line 1709... | ||
1713 | 1709 | ||
1714 | ;int (strm, buf, size) |
1710 | ;int (strm, buf, size) |
1715 | ; z_streamp strm |
1711 | ; z_streamp strm |
1716 | ; Bytef *buf |
1712 | ; Bytef *buf |
1717 | ; unsigned size |
1713 | ; unsigned size |
1718 | align 4 |
1714 | align 16 |
1719 | proc read_buf uses ebx ecx, strm:dword, buf:dword, size:dword |
1715 | proc read_buf uses ebx ecx, strm:dword, buf:dword, size:dword |
1720 | mov ebx,[strm] |
1716 | mov ebx,[strm] |
Line 1721... | Line 1717... | ||
1721 | mov eax,[ebx+z_stream.avail_in] |
1717 | mov eax,[ebx+z_stream.avail_in] |
Line 1738... | Line 1734... | ||
1738 | jne @f ;if (..==..) |
1734 | jne @f ;if (..==..) |
1739 | push eax |
1735 | push eax |
1740 | stdcall adler32, [ebx+z_stream.adler], [buf], eax |
1736 | stdcall adler32, [ebx+z_stream.adler], [buf], eax |
1741 | mov [ebx+z_stream.adler],eax |
1737 | mov [ebx+z_stream.adler],eax |
1742 | pop eax |
1738 | pop eax |
- | 1739 | if GZIP eq 1 |
|
1743 | jmp .end0 |
1740 | jmp .end0 |
- | 1741 | end if |
|
1744 | @@: |
1742 | @@: |
1745 | if GZIP eq 1 |
1743 | if GZIP eq 1 |
1746 | cmp dword[ecx+deflate_state.wrap],2 |
1744 | cmp dword[ecx+deflate_state.wrap],2 |
1747 | jne .end0 ;else if (..==..) |
1745 | jne .end0 ;else if (..==..) |
1748 | push eax |
1746 | push eax |
1749 | stdcall calc_crc32, [ebx+z_stream.adler], [buf], eax |
1747 | stdcall calc_crc32, [ebx+z_stream.adler], [buf], eax |
1750 | mov [ebx+z_stream.adler],eax |
1748 | mov [ebx+z_stream.adler],eax |
1751 | pop eax |
1749 | pop eax |
1752 | end if |
- | |
1753 | .end0: |
1750 | .end0: |
- | 1751 | end if |
|
1754 | add [ebx+z_stream.next_in],eax |
1752 | add [ebx+z_stream.next_in],eax |
1755 | add [ebx+z_stream.total_in],eax |
1753 | add [ebx+z_stream.total_in],eax |
Line 1756... | Line 1754... | ||
1756 | 1754 | ||
1757 | .end_f: |
1755 | .end_f: |
1758 | ret |
1756 | ret |
Line 1759... | Line 1757... | ||
1759 | endp |
1757 | endp |
1760 | 1758 | ||
Line 1761... | Line -... | ||
1761 | ; =========================================================================== |
- | |
1762 | ; Initialize the "longest match" routines for a new zlib stream |
1759 | ; =========================================================================== |
1763 | 1760 | ; Initialize the "longest match" routines for a new zlib stream |
|
1764 | ;void (s) |
1761 | |
1765 | ; deflate_state *s |
1762 | ;void (deflate_state *s) |
1766 | align 4 |
1763 | align 16 |
1767 | proc lm_init uses eax ebx edi, s:dword |
1764 | proc lm_init uses eax ebx edi, s:dword |
1768 | mov edi,[s] |
1765 | mov edi,[s] |
Line 1803... | Line 1800... | ||
1803 | endp |
1800 | endp |
Line 1804... | Line 1801... | ||
1804 | 1801 | ||
1805 | ;uInt (s, cur_match) |
1802 | ;uInt (s, cur_match) |
1806 | ; deflate_state *s |
1803 | ; deflate_state *s |
1807 | ; IPos cur_match ;current match |
1804 | ; IPos cur_match ;current match |
1808 | align 4 |
1805 | align 16 |
1809 | proc longest_match uses ebx ecx edx edi esi, s:dword, cur_match:dword |
1806 | proc longest_match uses ebx ecx edx edi esi, s:dword, cur_match:dword |
1810 | if FASTEST eq 0 |
1807 | if FASTEST eq 0 |
1811 | ; =========================================================================== |
1808 | ; =========================================================================== |
1812 | ; Set match_start to the longest match starting at the given string and |
1809 | ; Set match_start to the longest match starting at the given string and |
Line 1982... | Line 1979... | ||
1982 | mov bx,[edi+eax] |
1979 | mov bx,[edi+eax] |
Line 1983... | Line 1980... | ||
1983 | 1980 | ||
1984 | .cycle0cont: |
1981 | .cycle0cont: |
1985 | mov eax,[cur_match] |
1982 | mov eax,[cur_match] |
1986 | and eax,[wmask] |
1983 | and eax,[wmask] |
1987 | shl eax,2 |
1984 | shl eax,1 |
1988 | add eax,[prev] |
1985 | add eax,[prev] |
1989 | mov eax,[eax] ;eax = prev[cur_match & wmask] |
1986 | movzx eax,word[eax] ;eax = prev[cur_match & wmask] |
1990 | mov [cur_match],eax |
1987 | mov [cur_match],eax |
1991 | cmp eax,[limit] |
1988 | cmp eax,[limit] |
1992 | jle .cycle0end |
1989 | jle .cycle0end |
1993 | dec dword[chain_length] |
1990 | dec dword[chain_length] |
Line 2092... | Line 2089... | ||
2092 | jg @f ;if (len <= s.lookahead) ? len : s.lookahead |
2089 | jg @f ;if (len <= s.lookahead) ? len : s.lookahead |
2093 | mov eax,edi |
2090 | mov eax,edi |
2094 | @@: |
2091 | @@: |
2095 | end if ;FASTEST |
2092 | end if ;FASTEST |
2096 | .end_f: |
2093 | .end_f: |
2097 | ;zlib_debug ' longest_match.ret = %d',eax |
- | |
2098 | ret |
2094 | ret |
2099 | endp |
2095 | endp |
Line 2100... | Line -... | ||
2100 | - | ||
2101 | 2096 | ||
2102 | ; =========================================================================== |
2097 | ; =========================================================================== |
Line 2103... | Line 2098... | ||
2103 | ; Check that the match at match_start is indeed a match. |
2098 | ; Check that the match at match_start is indeed a match. |
2104 | 2099 | ||
Line 2125... | Line 2120... | ||
2125 | ; } |
2120 | ; } |
2126 | end if ;DEBUG |
2121 | end if ;DEBUG |
2127 | ret |
2122 | ret |
2128 | endp |
2123 | endp |
Line 2129... | Line -... | ||
2129 | - | ||
2130 | 2124 | ||
2131 | ; =========================================================================== |
2125 | ; =========================================================================== |
2132 | ; Fill the window when the lookahead becomes insufficient. |
2126 | ; Fill the window when the lookahead becomes insufficient. |
Line 2133... | Line 2127... | ||
2133 | ; Updates strstart and lookahead. |
2127 | ; Updates strstart and lookahead. |
2134 | 2128 | ||
2135 | ; IN assertion: lookahead < MIN_LOOKAHEAD |
2129 | ; IN assertion: lookahead < MIN_LOOKAHEAD |
2136 | ; OUT assertions: strstart <= window_size-MIN_LOOKAHEAD |
2130 | ; OUT assertions: strstart <= window_size-MIN_LOOKAHEAD |
2137 | ; At least one byte has been read, or avail_in == 0; reads are |
2131 | ; At least one byte has been read, or avail_in == 0; reads are |
Line 2138... | Line -... | ||
2138 | ; performed for at least two bytes (required for the zip translate_eol |
- | |
2139 | ; option -- not supported here). |
2132 | ; performed for at least two bytes (required for the zip translate_eol |
2140 | 2133 | ; option -- not supported here). |
|
2141 | ;void (s) |
2134 | |
2142 | ; deflate_state *s |
2135 | ;void (deflate_state *s) |
2143 | align 4 |
2136 | align 16 |
2144 | proc fill_window, s:dword |
2137 | proc fill_window, s:dword |
2145 | pushad |
2138 | pushad |
2146 | ;esi = p, str, curr |
2139 | ;esi = p, str, curr |
2147 | ;ebx = more ;Amount of free space at the end of the window. |
2140 | ;ebx = more ;Amount of free space at the end of the window. |
2148 | ;Объем свободного пространства в конце окна. |
- | |
2149 | ;ecx = wsize ;uInt |
2141 | ;Объем свободного пространства в конце окна. |
2150 | ;edx = s.strm |
2142 | ;ecx = wsize ;uInt |
2151 | zlib_debug 'fill_window' |
2143 | ;edx = s.strm |
2152 | mov edi,[s] |
2144 | mov edi,[s] |
2153 | cmp dword[edi+deflate_state.lookahead],MIN_LOOKAHEAD |
2145 | cmp dword[edi+deflate_state.lookahead],MIN_LOOKAHEAD |
Line 2154... | Line 2146... | ||
2154 | jl @f |
2146 | jl @f |
2155 | zlib_assert 'already enough lookahead' ;Assert(..<..) |
2147 | zlib_assert 'already enough lookahead' ;Assert(..<..) |
2156 | @@: |
2148 | @@: |
2157 | - | ||
2158 | mov ecx,[edi+deflate_state.w_size] |
2149 | |
2159 | mov edx,[edi+deflate_state.strm] |
2150 | mov ecx,[edi+deflate_state.w_size] |
2160 | .cycle0: ;do |
2151 | mov edx,[edi+deflate_state.strm] |
Line 2161... | Line 2152... | ||
2161 | zlib_debug 'do' |
2152 | .cycle0: ;do |
Line 2175... | Line 2166... | ||
2175 | add eax,ecx |
2166 | add eax,ecx |
2176 | stdcall zmemcpy, [edi+deflate_state.window], eax |
2167 | stdcall zmemcpy, [edi+deflate_state.window], eax |
2177 | sub [edi+deflate_state.match_start],ecx |
2168 | sub [edi+deflate_state.match_start],ecx |
2178 | sub [edi+deflate_state.strstart],ecx ;we now have strstart >= MAX_DIST |
2169 | sub [edi+deflate_state.strstart],ecx ;we now have strstart >= MAX_DIST |
2179 | sub [edi+deflate_state.block_start],ecx |
2170 | sub [edi+deflate_state.block_start],ecx |
2180 | - | ||
2181 | ; Slide the hash table (could be avoided with 32 bit values |
2171 | ; Slide the hash table (could be avoided with 32 bit values |
2182 | ; at the expense of memory usage). We slide even when level == 0 |
2172 | ; at the expense of memory usage). We slide even when level == 0 |
2183 | ; to keep the hash table consistent if we switch back to level > 0 |
2173 | ; to keep the hash table consistent if we switch back to level > 0 |
2184 | ; later. (Using level 0 permanently is not an optimal usage of |
2174 | ; later. (Using level 0 permanently is not an optimal usage of |
2185 | ; zlib, so we don't care about this pathological case.) |
2175 | ; zlib, so we don't care about this pathological case.) |
Line 2188... | Line 2178... | ||
2188 | ;ebx = wsize |
2178 | ;ebx = wsize |
2189 | ;ecx = n |
2179 | ;ecx = n |
2190 | mov ebx,ecx |
2180 | mov ebx,ecx |
2191 | mov ecx,[edi+deflate_state.hash_size] |
2181 | mov ecx,[edi+deflate_state.hash_size] |
2192 | mov esi,ecx |
2182 | mov esi,ecx |
2193 | shl esi,2 |
2183 | shl esi,1 |
2194 | add esi,[edi+deflate_state.head] |
2184 | add esi,[edi+deflate_state.head] |
2195 | .cycle1: ;do |
2185 | .cycle1: ;do |
2196 | sub esi,4 |
2186 | sub esi,2 |
2197 | mov eax,[esi] |
2187 | movzx eax,word[esi] |
2198 | mov dword[esi],NIL |
2188 | mov word[esi],NIL |
2199 | cmp eax,ebx |
2189 | cmp eax,ebx |
2200 | jl @f |
2190 | jl @f |
2201 | sub eax,ebx |
2191 | sub eax,ebx |
2202 | mov dword[esi],eax |
2192 | mov [esi],ax |
2203 | @@: |
2193 | @@: |
2204 | loop .cycle1 ;while (..) |
2194 | loop .cycle1 ;while (..) |
2205 | - | ||
2206 | if FASTEST eq 0 |
2195 | if FASTEST eq 0 |
2207 | mov ecx,ebx |
2196 | mov ecx,ebx |
2208 | mov esi,ecx |
2197 | mov esi,ecx |
2209 | shl esi,2 |
2198 | shl esi,1 |
2210 | add esi,[edi+deflate_state.prev] |
2199 | add esi,[edi+deflate_state.prev] |
2211 | .cycle2: ;do |
2200 | .cycle2: ;do |
2212 | sub esi,4 |
2201 | sub esi,2 |
2213 | mov eax,[esi] |
2202 | movzx eax,word[esi] |
2214 | mov dword[esi],NIL |
2203 | mov word[esi],NIL |
2215 | cmp eax,ebx |
2204 | cmp eax,ebx |
2216 | jl @f |
2205 | jl @f |
2217 | sub eax,ebx |
2206 | sub eax,ebx |
2218 | mov dword[esi],eax |
2207 | mov [esi],ax |
2219 | @@: |
2208 | @@: |
2220 | ; If n is not on any hash chain, prev[n] is garbage but |
2209 | ; If n is not on any hash chain, prev[n] is garbage but |
2221 | ; its value will never be used. |
2210 | ; its value will never be used. |
Line 2222... | Line 2211... | ||
2222 | 2211 | ||
Line 2274... | Line 2263... | ||
2274 | add eax,[edi+deflate_state.window] |
2263 | add eax,[edi+deflate_state.window] |
2275 | movzx eax,byte[eax] |
2264 | movzx eax,byte[eax] |
2276 | UPDATE_HASH edi, [edi+deflate_state.ins_h], eax |
2265 | UPDATE_HASH edi, [edi+deflate_state.ins_h], eax |
2277 | if FASTEST eq 0 |
2266 | if FASTEST eq 0 |
2278 | mov eax,[edi+deflate_state.ins_h] |
2267 | mov eax,[edi+deflate_state.ins_h] |
2279 | shl eax,2 |
2268 | shl eax,1 |
2280 | add eax,[edi+deflate_state.head] |
2269 | add eax,[edi+deflate_state.head] |
2281 | push ebx |
2270 | push ebx |
2282 | mov ebx,[edi+deflate_state.w_mask] |
2271 | mov ebx,[edi+deflate_state.w_mask] |
2283 | and ebx,esi |
2272 | and ebx,esi |
2284 | shl ebx,2 |
2273 | shl ebx,1 |
2285 | add ebx,[edi+deflate_state.prev] |
2274 | add ebx,[edi+deflate_state.prev] |
2286 | mov eax,[eax] |
2275 | mov ax,[eax] |
2287 | mov [ebx],eax |
2276 | mov [ebx],ax |
2288 | pop ebx |
2277 | pop ebx |
2289 | end if |
2278 | end if |
2290 | mov eax,[edi+deflate_state.ins_h] |
2279 | mov eax,[edi+deflate_state.ins_h] |
2291 | shl eax,2 |
2280 | shl eax,1 |
2292 | add eax,[edi+deflate_state.head] |
2281 | add eax,[edi+deflate_state.head] |
2293 | mov [eax],esi |
2282 | mov [eax],si |
2294 | inc esi |
2283 | inc esi |
2295 | dec dword[edi+deflate_state.insert] |
2284 | dec dword[edi+deflate_state.insert] |
2296 | mov eax,[edi+deflate_state.lookahead] |
2285 | mov eax,[edi+deflate_state.lookahead] |
2297 | add eax,[edi+deflate_state.insert] |
2286 | add eax,[edi+deflate_state.insert] |
2298 | cmp eax,MIN_MATCH |
2287 | cmp eax,MIN_MATCH |
Line 2383... | Line 2372... | ||
2383 | push dword last |
2372 | push dword last |
2384 | mov eax,[s+deflate_state.strstart] |
2373 | mov eax,[s+deflate_state.strstart] |
2385 | sub eax,[s+deflate_state.block_start] |
2374 | sub eax,[s+deflate_state.block_start] |
2386 | push eax |
2375 | push eax |
2387 | xor eax,eax |
2376 | xor eax,eax |
2388 | cmp dword[s+deflate_state.block_start],0 |
2377 | cmp [s+deflate_state.block_start],eax |
2389 | jl .end0 |
2378 | jl .end0 |
2390 | mov eax,[s+deflate_state.block_start] |
2379 | mov eax,[s+deflate_state.block_start] |
2391 | add eax,[s+deflate_state.window] |
2380 | add eax,[s+deflate_state.window] |
2392 | .end0: |
2381 | .end0: |
2393 | stdcall _tr_flush_block, s, eax |
2382 | stdcall _tr_flush_block, s, eax |
Line 2429... | Line 2418... | ||
2429 | align 4 |
2418 | align 4 |
2430 | proc deflate_stored uses ebx ecx edi, s:dword, flush:dword |
2419 | proc deflate_stored uses ebx ecx edi, s:dword, flush:dword |
2431 | ; Stored blocks are limited to 0xffff bytes, pending_buf is limited |
2420 | ; Stored blocks are limited to 0xffff bytes, pending_buf is limited |
2432 | ; to pending_buf_size, and each stored block has a 5 byte header: |
2421 | ; to pending_buf_size, and each stored block has a 5 byte header: |
2433 | mov edi,[s] |
2422 | mov edi,[s] |
2434 | zlib_debug 'deflate_stored' |
- | |
Line 2435... | Line 2423... | ||
2435 | 2423 | ||
2436 | mov ecx,0xffff |
2424 | mov ecx,0xffff |
2437 | mov eax,[edi+deflate_state.pending_buf_size] |
2425 | mov eax,[edi+deflate_state.pending_buf_size] |
2438 | sub eax,5 |
2426 | sub eax,5 |
Line 2441... | Line 2429... | ||
2441 | mov ecx,eax |
2429 | mov ecx,eax |
2442 | ;ecx = max_block_size |
2430 | ;ecx = max_block_size |
Line 2443... | Line 2431... | ||
2443 | 2431 | ||
2444 | ; Copy as much as possible from input to output: |
2432 | ; Copy as much as possible from input to output: |
2445 | align 4 |
2433 | align 4 |
2446 | .cycle0: ;for (;;) { |
2434 | .cycle0: ;for (;;) |
2447 | ; Fill the window as much as possible: |
2435 | ; Fill the window as much as possible: |
2448 | cmp dword[edi+deflate_state.lookahead],1 |
2436 | cmp dword[edi+deflate_state.lookahead],1 |
2449 | jg .end0 ;if (..<=..) |
2437 | jg .end0 ;if (..<=..) |
2450 | ; Assert(s->strstart < s->w_size+MAX_DIST(s) || |
2438 | ; Assert(s->strstart < s->w_size+MAX_DIST(s) || |
Line 2529... | Line 2517... | ||
2529 | locals |
2517 | locals |
2530 | bflush dd ? ;int ;set if current block must be flushed |
2518 | bflush dd ? ;int ;set if current block must be flushed |
2531 | endl |
2519 | endl |
2532 | ;ecx = hash_head ;IPos ;head of the hash chain |
2520 | ;ecx = hash_head ;IPos ;head of the hash chain |
2533 | mov edi,[s] |
2521 | mov edi,[s] |
2534 | zlib_debug 'deflate_fast' |
- | |
Line 2535... | Line 2522... | ||
2535 | 2522 | ||
2536 | .cycle0: ;for (..) |
2523 | .cycle0: ;for (..) |
2537 | ; Make sure that we always have enough lookahead, except |
2524 | ; Make sure that we always have enough lookahead, except |
2538 | ; at the end of the input file. We need MAX_MATCH bytes |
2525 | ; at the end of the input file. We need MAX_MATCH bytes |
Line 2684... | Line 2671... | ||
2684 | locals |
2671 | locals |
2685 | bflush dd ? ;int ;set if current block must be flushed |
2672 | bflush dd ? ;int ;set if current block must be flushed |
2686 | endl |
2673 | endl |
2687 | ;ecx = hash_head ;IPos ;head of the hash chain |
2674 | ;ecx = hash_head ;IPos ;head of the hash chain |
2688 | mov edi,[s] |
2675 | mov edi,[s] |
2689 | zlib_debug 'deflate_slow' |
- | |
Line 2690... | Line 2676... | ||
2690 | 2676 | ||
2691 | ; Process the input block. |
2677 | ; Process the input block. |
2692 | .cycle0: ;for (;;) |
2678 | .cycle0: ;for (;;) |
2693 | ; Make sure that we always have enough lookahead, except |
2679 | ; Make sure that we always have enough lookahead, except |
Line 2901... | Line 2887... | ||
2901 | proc deflate_rle uses ecx edx edi esi, s:dword, flush:dword |
2887 | proc deflate_rle uses ecx edx edi esi, s:dword, flush:dword |
2902 | locals |
2888 | locals |
2903 | bflush dd ? ;int ;set if current block must be flushed |
2889 | bflush dd ? ;int ;set if current block must be flushed |
2904 | endl |
2890 | endl |
2905 | mov edx,[s] |
2891 | mov edx,[s] |
2906 | zlib_debug 'deflate_rle' |
- | |
2907 | align 4 |
2892 | align 4 |
2908 | .cycle0: ;for (;;) |
2893 | .cycle0: ;for (;;) |
2909 | ; Make sure that we always have enough lookahead, except |
2894 | ; Make sure that we always have enough lookahead, except |
2910 | ; at the end of the input file. We need MAX_MATCH bytes |
2895 | ; at the end of the input file. We need MAX_MATCH bytes |
2911 | ; for the longest run, plus one for the unrolled loop. |
2896 | ; for the longest run, plus one for the unrolled loop. |
Line 3024... | Line 3009... | ||
3024 | proc deflate_huff uses ebx edi, s:dword, flush:dword |
3009 | proc deflate_huff uses ebx edi, s:dword, flush:dword |
3025 | locals |
3010 | locals |
3026 | bflush dd ? ;int ;set if current block must be flushed |
3011 | bflush dd ? ;int ;set if current block must be flushed |
3027 | endl |
3012 | endl |
3028 | mov edi,[s] |
3013 | mov edi,[s] |
3029 | zlib_debug 'deflate_huff' |
- | |
3030 | align 4 |
3014 | align 4 |
3031 | .cycle0: ;for (;;) |
3015 | .cycle0: ;for (;;) |
3032 | ; Make sure that we have a literal to write. |
3016 | ; Make sure that we have a literal to write. |
3033 | cmp dword[edi+deflate_state.lookahead],0 |
3017 | cmp dword[edi+deflate_state.lookahead],0 |
3034 | jne .end0 ;if (..==0) |
3018 | jne .end0 ;if (..==0) |