Rev 6801 | Rev 6847 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6801 | Rev 6819 | ||
---|---|---|---|
Line 398... | Line 398... | ||
398 | cmp dword[edi+deflate_state.prev],Z_NULL |
398 | cmp dword[edi+deflate_state.prev],Z_NULL |
399 | je .end3 |
399 | je .end3 |
400 | cmp dword[edi+deflate_state.head],Z_NULL |
400 | cmp dword[edi+deflate_state.head],Z_NULL |
401 | je .end3 |
401 | je .end3 |
402 | cmp dword[edi+deflate_state.pending_buf],Z_NULL |
402 | cmp dword[edi+deflate_state.pending_buf],Z_NULL |
403 | je .end3 |
- | |
404 | jmp @f |
403 | jne @f |
405 | .end3: ;if (..==0 || ..==0 || ..==0 || ..==0) |
404 | .end3: ;if (..==0 || ..==0 || ..==0 || ..==0) |
406 | mov dword[edi+deflate_state.status],FINISH_STATE |
405 | mov dword[edi+deflate_state.status],FINISH_STATE |
407 | ERR_MSG Z_MEM_ERROR |
406 | ERR_MSG Z_MEM_ERROR |
408 | mov [ebx+z_stream.msg],eax |
407 | mov [ebx+z_stream.msg],eax |
409 | stdcall deflateEnd, ebx |
408 | stdcall deflateEnd, ebx |
Line 436... | Line 435... | ||
436 | ;int (strm, dictionary, dictLength) |
435 | ;int (strm, dictionary, dictLength) |
437 | ; z_streamp strm |
436 | ; z_streamp strm |
438 | ; const Bytef *dictionary |
437 | ; const Bytef *dictionary |
439 | ; uInt dictLength |
438 | ; uInt dictLength |
440 | align 4 |
439 | align 4 |
441 | proc deflateSetDictionary uses ebx edi, strm:dword, dictionary:dword, dictLength:dword |
440 | proc deflateSetDictionary uses ebx ecx edx edi esi, strm:dword, dictionary:dword, dictLength:dword |
442 | locals |
441 | locals |
443 | ; uInt str, n; |
- | |
444 | wrap dd ? ;int |
442 | wrap dd ? ;int |
445 | avail dd ? ;unsigned |
443 | avail dd ? ;unsigned |
446 | next dd ? ;unsigned char* |
444 | next dd ? ;unsigned char* |
447 | endl |
445 | endl |
448 | mov ebx,[strm] |
446 | mov ebx,[strm] |
Line 450... | Line 448... | ||
450 | je @f |
448 | je @f |
451 | mov edi,[ebx+z_stream.state] |
449 | mov edi,[ebx+z_stream.state] |
452 | cmp edi,Z_NULL |
450 | cmp edi,Z_NULL |
453 | je @f |
451 | je @f |
454 | cmp dword[dictionary],Z_NULL |
452 | cmp dword[dictionary],Z_NULL |
455 | je @f ;if (..==0 || ..==0 || ..==0) |
453 | jne .end0 ;if (..==0 || ..==0 || ..==0) |
456 | jmp .end0 |
- | |
457 | @@: |
454 | @@: |
458 | mov eax,Z_STREAM_ERROR |
455 | mov eax,Z_STREAM_ERROR |
459 | jmp .end_f |
456 | jmp .end_f |
460 | .end0: |
457 | .end0: |
Line 484... | Line 481... | ||
484 | 481 | ||
485 | ; if dictionary would fill window, just replace the history |
482 | ; if dictionary would fill window, just replace the history |
486 | mov eax,[edi+deflate_state.w_size] |
483 | mov eax,[edi+deflate_state.w_size] |
487 | cmp [dictLength],eax |
484 | cmp [dictLength],eax |
- | 485 | jl .end2 ;if (..>=..) |
|
488 | jl .end2 ;if (..>=..) |
486 | cmp dword[wrap],0 |
489 | ; if (wrap == 0) { /* already empty otherwise */ |
487 | jne @f ;if (..==0) ;already empty otherwise |
490 | ; CLEAR_HASH(s); |
488 | CLEAR_HASH edi |
491 | ; s->strstart = 0; |
489 | mov dword[edi+deflate_state.strstart],0 |
492 | ; s->block_start = 0L; |
490 | mov dword[edi+deflate_state.block_start],0 |
493 | ; s->insert = 0; |
491 | mov dword[edi+deflate_state.insert],0 |
- | 492 | @@: |
|
- | 493 | mov eax,[dictLength] |
|
494 | ; } |
494 | sub eax,[edi+deflate_state.w_size] |
495 | ; dictionary += dictLength - s->w_size; /* use the tail */ |
495 | add [dictionary],eax ;use the tail |
496 | mov eax,[edi+deflate_state.w_size] |
496 | mov eax,[edi+deflate_state.w_size] |
497 | mov [dictLength],eax |
497 | mov [dictLength],eax |
Line 498... | Line 498... | ||
498 | .end2: |
498 | .end2: |
499 | 499 | ||
- | 500 | ; insert dictionary into window and hash |
|
500 | ; insert dictionary into window and hash |
501 | mov eax,[ebx+z_stream.avail_in] |
- | 502 | mov [avail],eax |
|
501 | ; avail = strm->avail_in; |
503 | mov eax,[ebx+z_stream.next_in] |
- | 504 | mov [next],eax |
|
502 | ; next = strm->next_in; |
505 | mov eax,[dictLength] |
- | 506 | mov [ebx+z_stream.avail_in],eax |
|
503 | ; strm->avail_in = dictLength; |
507 | mov eax,[dictionary] |
- | 508 | mov [ebx+z_stream.next_in],eax |
|
504 | ; strm->next_in = (z_const Bytef *)dictionary; |
509 | stdcall fill_window, edi |
- | 510 | .cycle0: ;while (..>=..) |
|
- | 511 | mov ecx,[edi+deflate_state.lookahead] |
|
505 | ; fill_window(s); |
512 | cmp ecx,MIN_MATCH |
- | 513 | jl .cycle0end |
|
506 | ; while (s->lookahead >= MIN_MATCH) { |
514 | mov esi,[edi+deflate_state.strstart] |
- | 515 | ;esi = str |
|
- | 516 | sub ecx,MIN_MATCH-1 |
|
507 | ; str = s->strstart; |
517 | .cycle1: ;do |
- | 518 | mov eax,[edi+deflate_state.window] |
|
- | 519 | add eax,esi |
|
508 | ; n = s->lookahead - (MIN_MATCH-1); |
520 | add eax,MIN_MATCH-1 |
509 | ; do { |
521 | movzx eax,byte[eax] |
- | 522 | UPDATE_HASH edi, [edi+deflate_state.ins_h], eax |
|
- | 523 | if FASTEST eq 0 |
|
- | 524 | mov edx,[edi+deflate_state.ins_h] |
|
510 | ; UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); |
525 | shl edx,2 |
- | 526 | add edx,[edi+deflate_state.head] |
|
- | 527 | mov edx,[edx] ;edx = s.head[s.ins_h] |
|
- | 528 | mov eax,esi |
|
- | 529 | and eax,[edi+deflate_state.w_mask] |
|
- | 530 | shl eax,2 |
|
511 | if FASTEST eq 0 |
531 | add eax,[edi+deflate_state.prev] |
- | 532 | mov [eax],edx |
|
- | 533 | end if |
|
- | 534 | mov edx,[edi+deflate_state.ins_h] |
|
512 | ; s->prev[str & s->w_mask] = s->head[s->ins_h]; |
535 | shl edx,2 |
513 | end if |
536 | add edx,[edi+deflate_state.head] |
- | 537 | mov [edx],esi ;s.head[s.ins_h] = str |
|
514 | ; s->head[s->ins_h] = (Pos)str; |
538 | inc esi |
515 | ; str++; |
539 | dec ecx |
516 | ; } while (--n); |
540 | jnz .cycle1 ;while (--..) |
517 | ; s->strstart = str; |
541 | mov [edi+deflate_state.strstart],esi |
- | 542 | mov [edi+deflate_state.lookahead],MIN_MATCH-1 |
|
518 | ; s->lookahead = MIN_MATCH-1; |
543 | stdcall fill_window, edi |
- | 544 | jmp .cycle0 |
|
- | 545 | align 4 |
|
519 | ; fill_window(s); |
546 | .cycle0end: |
- | 547 | mov eax,[edi+deflate_state.strstart] |
|
520 | ; } |
548 | add eax,[edi+deflate_state.lookahead] |
521 | ; s->strstart += s->lookahead; |
549 | mov [edi+deflate_state.strstart],eax |
522 | ; s->block_start = (long)s->strstart; |
550 | mov [edi+deflate_state.block_start],eax |
523 | mov eax,[edi+deflate_state.lookahead] |
551 | mov eax,[edi+deflate_state.lookahead] |
524 | mov [edi+deflate_state.insert],eax |
552 | mov [edi+deflate_state.insert],eax |
525 | mov dword[edi+deflate_state.lookahead],0 |
553 | mov dword[edi+deflate_state.lookahead],0 |
Line 550... | Line 578... | ||
550 | cmp edi,Z_NULL |
578 | cmp edi,Z_NULL |
551 | je @f |
579 | je @f |
552 | cmp dword[ebx+z_stream.zalloc],0 |
580 | cmp dword[ebx+z_stream.zalloc],0 |
553 | je @f |
581 | je @f |
554 | cmp dword[ebx+z_stream.zfree],0 |
582 | cmp dword[ebx+z_stream.zfree],0 |
555 | je @f ;if (..==0 || ..==0 || ..==0 || ..==0) |
583 | jne .end0 ;if (..==0 || ..==0 || ..==0 || ..==0) |
556 | jmp .end0 |
- | |
557 | @@: |
584 | @@: |
558 | mov eax,Z_STREAM_ERROR |
585 | mov eax,Z_STREAM_ERROR |
559 | jmp .end_f |
586 | jmp .end_f |
560 | .end0: |
587 | .end0: |
Line 568... | Line 595... | ||
568 | mov eax,[edi+deflate_state.pending_buf] |
595 | mov eax,[edi+deflate_state.pending_buf] |
569 | mov [edi+deflate_state.pending_out],eax |
596 | mov [edi+deflate_state.pending_out],eax |
Line 570... | Line 597... | ||
570 | 597 | ||
571 | cmp dword[edi+deflate_state.wrap],0 |
598 | cmp dword[edi+deflate_state.wrap],0 |
572 | jge @f ;if (..<0) |
- | |
573 | neg dword[edi+deflate_state.wrap] |
599 | jge @f ;if (..<0) |
574 | inc dword[edi+deflate_state.wrap] ;was made negative by deflate(..., Z_FINISH) |
600 | neg dword[edi+deflate_state.wrap] ;was made negative by deflate(..., Z_FINISH) |
575 | @@: |
601 | @@: |
576 | mov eax,BUSY_STATE |
602 | mov eax,BUSY_STATE |
577 | cmp dword[edi+deflate_state.wrap],0 |
603 | cmp dword[edi+deflate_state.wrap],0 |
578 | je @f |
604 | je @f |
Line 1508... | Line 1534... | ||
1508 | .end17: |
1534 | .end17: |
1509 | stdcall flush_pending, ebx |
1535 | stdcall flush_pending, ebx |
1510 | ; If avail_out is zero, the application will call deflate again |
1536 | ; If avail_out is zero, the application will call deflate again |
1511 | ; to flush the rest. |
1537 | ; to flush the rest. |
Line 1512... | Line 1538... | ||
1512 | 1538 | ||
1513 | cmp dword[edi+deflate_state.pending],0 |
1539 | cmp dword[edi+deflate_state.wrap],0 |
1514 | jle @f ;if (..>0) ;write the trailer only once! |
1540 | jle @f ;if (..>0) ;write the trailer only once! |
1515 | neg dword[edi+deflate_state.pending] |
- | |
1516 | inc dword[edi+deflate_state.pending] |
1541 | neg dword[edi+deflate_state.wrap] |
1517 | @@: |
1542 | @@: |
1518 | mov eax,Z_OK |
1543 | mov eax,Z_OK |
1519 | cmp dword[edi+deflate_state.pending],0 |
1544 | cmp dword[edi+deflate_state.pending],0 |
1520 | je .end_f |
1545 | jne .end_f |
1521 | mov eax,Z_STREAM_END |
1546 | mov eax,Z_STREAM_END |
1522 | .end_f: |
- | |
1523 | zlib_debug ' deflate.ret = %d',eax |
1547 | .end_f: |
1524 | ret |
1548 | ret |
Line 1525... | Line 1549... | ||
1525 | endp |
1549 | endp |
1526 | 1550 | ||
Line 1729... | Line 1753... | ||
1729 | .end0: |
1753 | .end0: |
1730 | add [ebx+z_stream.next_in],eax |
1754 | add [ebx+z_stream.next_in],eax |
1731 | add [ebx+z_stream.total_in],eax |
1755 | add [ebx+z_stream.total_in],eax |
Line 1732... | Line 1756... | ||
1732 | 1756 | ||
1733 | .end_f: |
- | |
1734 | ;zlib_debug ' read_buf.ret = %d',eax |
1757 | .end_f: |
1735 | ret |
1758 | ret |
Line 1736... | Line 1759... | ||
1736 | endp |
1759 | endp |
1737 | 1760 | ||
Line 1966... | Line 1989... | ||
1966 | mov eax,[eax] ;eax = prev[cur_match & wmask] |
1989 | mov eax,[eax] ;eax = prev[cur_match & wmask] |
1967 | mov [cur_match],eax |
1990 | mov [cur_match],eax |
1968 | cmp eax,[limit] |
1991 | cmp eax,[limit] |
1969 | jle .cycle0end |
1992 | jle .cycle0end |
1970 | dec dword[chain_length] |
1993 | dec dword[chain_length] |
1971 | cmp dword[chain_length],0 |
- | |
1972 | jne .cycle0 |
1994 | jnz .cycle0 |
1973 | align 4 |
1995 | align 4 |
1974 | .cycle0end: ;while (..>.. && ..!=0) |
1996 | .cycle0end: ;while (..>.. && ..!=0) |
Line 1975... | Line 1997... | ||
1975 | 1997 | ||
1976 | mov eax,[edx+deflate_state.lookahead] |
1998 | mov eax,[edx+deflate_state.lookahead] |
Line 2794... | Line 2816... | ||
2794 | 2816 | ||
2795 | cmp dword[bflush],0 |
2817 | cmp dword[bflush],0 |
2796 | je .cycle0 ;if (..) |
2818 | je .cycle0 ;if (..) |
2797 | FLUSH_BLOCK edi, 0 |
2819 | FLUSH_BLOCK edi, 0 |
- | 2820 | jmp .cycle0 |
|
2798 | jmp .cycle0 |
2821 | align 4 |
2799 | .end2: ;else if (..) |
2822 | .end2: ;else if (..) |
2800 | cmp dword[edi+deflate_state.match_available],0 |
2823 | cmp dword[edi+deflate_state.match_available],0 |
2801 | je .end3 |
2824 | je .end3 |
2802 | ; If there was no match at the previous position, output a |
2825 | ; If there was no match at the previous position, output a |
Line 2818... | Line 2841... | ||
2818 | mov eax,[edi+deflate_state.strm] |
2841 | mov eax,[edi+deflate_state.strm] |
2819 | cmp dword[eax+z_stream.avail_out],0 |
2842 | cmp dword[eax+z_stream.avail_out],0 |
2820 | jne .cycle0 ;if (..==0) return .. |
2843 | jne .cycle0 ;if (..==0) return .. |
2821 | mov eax,need_more |
2844 | mov eax,need_more |
2822 | jmp .end_f |
2845 | jmp .end_f |
2823 | jmp .cycle0 ;.end4 |
2846 | align 4 |
2824 | .end3: ;else |
2847 | .end3: ;else |
2825 | ; There is no previous match to compare with, wait for |
2848 | ; There is no previous match to compare with, wait for |
2826 | ; the next step to decide. |
2849 | ; the next step to decide. |
Line 2827... | Line 2850... | ||
2827 | 2850 | ||
2828 | mov dword[edi+deflate_state.match_available],1 |
2851 | mov dword[edi+deflate_state.match_available],1 |
2829 | inc dword[edi+deflate_state.strstart] |
2852 | inc dword[edi+deflate_state.strstart] |
2830 | dec dword[edi+deflate_state.lookahead] |
- | |
2831 | ;.end4: |
2853 | dec dword[edi+deflate_state.lookahead] |
2832 | jmp .cycle0 |
2854 | jmp .cycle0 |
2833 | align 4 |
2855 | align 4 |
2834 | .cycle0end: |
2856 | .cycle0end: |
2835 | cmp dword[flush],Z_NO_FLUSH |
2857 | cmp dword[flush],Z_NO_FLUSH |
Line 2929... | Line 2951... | ||
2929 | sub edi,[edx+deflate_state.window] |
2951 | sub edi,[edx+deflate_state.window] |
2930 | sub edi,[edx+deflate_state.strstart] |
2952 | sub edi,[edx+deflate_state.strstart] |
2931 | mov [edx+deflate_state.match_length],edi |
2953 | mov [edx+deflate_state.match_length],edi |
2932 | mov eax,[edx+deflate_state.lookahead] |
2954 | mov eax,[edx+deflate_state.lookahead] |
2933 | cmp [edx+deflate_state.match_length],eax |
2955 | cmp [edx+deflate_state.match_length],eax |
2934 | jle .end2 |
2956 | jle .end2 ;if (..>..) |
2935 | mov [edx+deflate_state.match_length],eax |
2957 | mov [edx+deflate_state.match_length],eax |
2936 | .end2: |
2958 | .end2: |
2937 | mov eax,[edx+deflate_state.window_size] |
2959 | mov eax,[edx+deflate_state.window_size] |
2938 | dec eax |
2960 | dec eax |
2939 | add eax,[edx+deflate_state.window] |
2961 | add eax,[edx+deflate_state.window] |
Line 3029... | Line 3051... | ||
3029 | Tracevv eax, |
3051 | Tracevv eax, |
3030 | _tr_tally_lit edi, eax, [bflush] |
3052 | _tr_tally_lit edi, eax, [bflush] |
3031 | dec dword[edi+deflate_state.lookahead] |
3053 | dec dword[edi+deflate_state.lookahead] |
3032 | inc dword[edi+deflate_state.strstart] |
3054 | inc dword[edi+deflate_state.strstart] |
3033 | cmp dword[bflush],0 |
3055 | cmp dword[bflush],0 |
3034 | je @f ;if (..) |
3056 | je .cycle0 ;if (..) |
3035 | FLUSH_BLOCK edi, 0 |
3057 | FLUSH_BLOCK edi, 0 |
3036 | @@: |
- | |
3037 | jmp .cycle0 |
3058 | jmp .cycle0 |
3038 | align 4 |
3059 | align 4 |
3039 | .cycle0end: |
3060 | .cycle0end: |
3040 | mov dword[edi+deflate_state.insert],0 |
3061 | mov dword[edi+deflate_state.insert],0 |
3041 | cmp dword[flush],Z_FINISH |
3062 | cmp dword[flush],Z_FINISH |