diff options
Diffstat (limited to 'trees.c')
-rw-r--r-- | trees.c | 104 |
1 files changed, 52 insertions, 52 deletions
@@ -193,7 +193,7 @@ local void send_bits(s, value, length) | |||
193 | s->bits_sent += (ulg)length; | 193 | s->bits_sent += (ulg)length; |
194 | 194 | ||
195 | /* If not enough room in bi_buf, use (valid) bits from bi_buf and | 195 | /* If not enough room in bi_buf, use (valid) bits from bi_buf and |
196 | * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) | 196 | * (16 - bi_valid) bits from value, leaving (width - (16 - bi_valid)) |
197 | * unused bits in value. | 197 | * unused bits in value. |
198 | */ | 198 | */ |
199 | if (s->bi_valid > (int)Buf_size - length) { | 199 | if (s->bi_valid > (int)Buf_size - length) { |
@@ -256,7 +256,7 @@ local void tr_static_init() | |||
256 | length = 0; | 256 | length = 0; |
257 | for (code = 0; code < LENGTH_CODES-1; code++) { | 257 | for (code = 0; code < LENGTH_CODES-1; code++) { |
258 | base_length[code] = length; | 258 | base_length[code] = length; |
259 | for (n = 0; n < (1<<extra_lbits[code]); n++) { | 259 | for (n = 0; n < (1 << extra_lbits[code]); n++) { |
260 | _length_code[length++] = (uch)code; | 260 | _length_code[length++] = (uch)code; |
261 | } | 261 | } |
262 | } | 262 | } |
@@ -265,13 +265,13 @@ local void tr_static_init() | |||
265 | * in two different ways: code 284 + 5 bits or code 285, so we | 265 | * in two different ways: code 284 + 5 bits or code 285, so we |
266 | * overwrite length_code[255] to use the best encoding: | 266 | * overwrite length_code[255] to use the best encoding: |
267 | */ | 267 | */ |
268 | _length_code[length-1] = (uch)code; | 268 | _length_code[length - 1] = (uch)code; |
269 | 269 | ||
270 | /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ | 270 | /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ |
271 | dist = 0; | 271 | dist = 0; |
272 | for (code = 0 ; code < 16; code++) { | 272 | for (code = 0 ; code < 16; code++) { |
273 | base_dist[code] = dist; | 273 | base_dist[code] = dist; |
274 | for (n = 0; n < (1<<extra_dbits[code]); n++) { | 274 | for (n = 0; n < (1 << extra_dbits[code]); n++) { |
275 | _dist_code[dist++] = (uch)code; | 275 | _dist_code[dist++] = (uch)code; |
276 | } | 276 | } |
277 | } | 277 | } |
@@ -279,11 +279,11 @@ local void tr_static_init() | |||
279 | dist >>= 7; /* from now on, all distances are divided by 128 */ | 279 | dist >>= 7; /* from now on, all distances are divided by 128 */ |
280 | for ( ; code < D_CODES; code++) { | 280 | for ( ; code < D_CODES; code++) { |
281 | base_dist[code] = dist << 7; | 281 | base_dist[code] = dist << 7; |
282 | for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { | 282 | for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { |
283 | _dist_code[256 + dist++] = (uch)code; | 283 | _dist_code[256 + dist++] = (uch)code; |
284 | } | 284 | } |
285 | } | 285 | } |
286 | Assert (dist == 256, "tr_static_init: 256+dist != 512"); | 286 | Assert (dist == 256, "tr_static_init: 256 + dist != 512"); |
287 | 287 | ||
288 | /* Construct the codes of the static literal tree */ | 288 | /* Construct the codes of the static literal tree */ |
289 | for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; | 289 | for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; |
@@ -321,7 +321,7 @@ local void tr_static_init() | |||
321 | 321 | ||
322 | # define SEPARATOR(i, last, width) \ | 322 | # define SEPARATOR(i, last, width) \ |
323 | ((i) == (last)? "\n};\n\n" : \ | 323 | ((i) == (last)? "\n};\n\n" : \ |
324 | ((i) % (width) == (width)-1 ? ",\n" : ", ")) | 324 | ((i) % (width) == (width) - 1 ? ",\n" : ", ")) |
325 | 325 | ||
326 | void gen_trees_header() | 326 | void gen_trees_header() |
327 | { | 327 | { |
@@ -458,7 +458,7 @@ local void pqdownheap(s, tree, k) | |||
458 | while (j <= s->heap_len) { | 458 | while (j <= s->heap_len) { |
459 | /* Set j to the smallest of the two sons: */ | 459 | /* Set j to the smallest of the two sons: */ |
460 | if (j < s->heap_len && | 460 | if (j < s->heap_len && |
461 | smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { | 461 | smaller(tree, s->heap[j + 1], s->heap[j], s->depth)) { |
462 | j++; | 462 | j++; |
463 | } | 463 | } |
464 | /* Exit if v is smaller than both sons */ | 464 | /* Exit if v is smaller than both sons */ |
@@ -507,7 +507,7 @@ local void gen_bitlen(s, desc) | |||
507 | */ | 507 | */ |
508 | tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ | 508 | tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ |
509 | 509 | ||
510 | for (h = s->heap_max+1; h < HEAP_SIZE; h++) { | 510 | for (h = s->heap_max + 1; h < HEAP_SIZE; h++) { |
511 | n = s->heap[h]; | 511 | n = s->heap[h]; |
512 | bits = tree[tree[n].Dad].Len + 1; | 512 | bits = tree[tree[n].Dad].Len + 1; |
513 | if (bits > max_length) bits = max_length, overflow++; | 513 | if (bits > max_length) bits = max_length, overflow++; |
@@ -518,7 +518,7 @@ local void gen_bitlen(s, desc) | |||
518 | 518 | ||
519 | s->bl_count[bits]++; | 519 | s->bl_count[bits]++; |
520 | xbits = 0; | 520 | xbits = 0; |
521 | if (n >= base) xbits = extra[n-base]; | 521 | if (n >= base) xbits = extra[n - base]; |
522 | f = tree[n].Freq; | 522 | f = tree[n].Freq; |
523 | s->opt_len += (ulg)f * (unsigned)(bits + xbits); | 523 | s->opt_len += (ulg)f * (unsigned)(bits + xbits); |
524 | if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits); | 524 | if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits); |
@@ -530,10 +530,10 @@ local void gen_bitlen(s, desc) | |||
530 | 530 | ||
531 | /* Find the first bit length which could increase: */ | 531 | /* Find the first bit length which could increase: */ |
532 | do { | 532 | do { |
533 | bits = max_length-1; | 533 | bits = max_length - 1; |
534 | while (s->bl_count[bits] == 0) bits--; | 534 | while (s->bl_count[bits] == 0) bits--; |
535 | s->bl_count[bits]--; /* move one leaf down the tree */ | 535 | s->bl_count[bits]--; /* move one leaf down the tree */ |
536 | s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ | 536 | s->bl_count[bits + 1] += 2; /* move one overflow item as its brother */ |
537 | s->bl_count[max_length]--; | 537 | s->bl_count[max_length]--; |
538 | /* The brother of the overflow item also moves one step up, | 538 | /* The brother of the overflow item also moves one step up, |
539 | * but this does not affect bl_count[max_length] | 539 | * but this does not affect bl_count[max_length] |
@@ -569,7 +569,7 @@ local void gen_bitlen(s, desc) | |||
569 | * OUT assertion: the field code is set for all tree elements of non | 569 | * OUT assertion: the field code is set for all tree elements of non |
570 | * zero code length. | 570 | * zero code length. |
571 | */ | 571 | */ |
572 | local void gen_codes (tree, max_code, bl_count) | 572 | local void gen_codes(tree, max_code, bl_count) |
573 | ct_data *tree; /* the tree to decorate */ | 573 | ct_data *tree; /* the tree to decorate */ |
574 | int max_code; /* largest code with non zero frequency */ | 574 | int max_code; /* largest code with non zero frequency */ |
575 | ushf *bl_count; /* number of codes at each bit length */ | 575 | ushf *bl_count; /* number of codes at each bit length */ |
@@ -583,13 +583,13 @@ local void gen_codes (tree, max_code, bl_count) | |||
583 | * without bit reversal. | 583 | * without bit reversal. |
584 | */ | 584 | */ |
585 | for (bits = 1; bits <= MAX_BITS; bits++) { | 585 | for (bits = 1; bits <= MAX_BITS; bits++) { |
586 | code = (code + bl_count[bits-1]) << 1; | 586 | code = (code + bl_count[bits - 1]) << 1; |
587 | next_code[bits] = (ush)code; | 587 | next_code[bits] = (ush)code; |
588 | } | 588 | } |
589 | /* Check that the bit counts in bl_count are consistent. The last code | 589 | /* Check that the bit counts in bl_count are consistent. The last code |
590 | * must be all ones. | 590 | * must be all ones. |
591 | */ | 591 | */ |
592 | Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1, | 592 | Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, |
593 | "inconsistent bit counts"); | 593 | "inconsistent bit counts"); |
594 | Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); | 594 | Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); |
595 | 595 | ||
@@ -600,7 +600,7 @@ local void gen_codes (tree, max_code, bl_count) | |||
600 | tree[n].Code = (ush)bi_reverse(next_code[len]++, len); | 600 | tree[n].Code = (ush)bi_reverse(next_code[len]++, len); |
601 | 601 | ||
602 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", | 602 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", |
603 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); | 603 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); |
604 | } | 604 | } |
605 | } | 605 | } |
606 | 606 | ||
@@ -624,7 +624,7 @@ local void build_tree(s, desc) | |||
624 | int node; /* new node being created */ | 624 | int node; /* new node being created */ |
625 | 625 | ||
626 | /* Construct the initial heap, with least frequent element in | 626 | /* Construct the initial heap, with least frequent element in |
627 | * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. | 627 | * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n + 1]. |
628 | * heap[0] is not used. | 628 | * heap[0] is not used. |
629 | */ | 629 | */ |
630 | s->heap_len = 0, s->heap_max = HEAP_SIZE; | 630 | s->heap_len = 0, s->heap_max = HEAP_SIZE; |
@@ -652,7 +652,7 @@ local void build_tree(s, desc) | |||
652 | } | 652 | } |
653 | desc->max_code = max_code; | 653 | desc->max_code = max_code; |
654 | 654 | ||
655 | /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, | 655 | /* The elements heap[heap_len/2 + 1 .. heap_len] are leaves of the tree, |
656 | * establish sub-heaps of increasing lengths: | 656 | * establish sub-heaps of increasing lengths: |
657 | */ | 657 | */ |
658 | for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); | 658 | for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); |
@@ -700,7 +700,7 @@ local void build_tree(s, desc) | |||
700 | * Scan a literal or distance tree to determine the frequencies of the codes | 700 | * Scan a literal or distance tree to determine the frequencies of the codes |
701 | * in the bit length tree. | 701 | * in the bit length tree. |
702 | */ | 702 | */ |
703 | local void scan_tree (s, tree, max_code) | 703 | local void scan_tree(s, tree, max_code) |
704 | deflate_state *s; | 704 | deflate_state *s; |
705 | ct_data *tree; /* the tree to be scanned */ | 705 | ct_data *tree; /* the tree to be scanned */ |
706 | int max_code; /* and its largest code of non zero frequency */ | 706 | int max_code; /* and its largest code of non zero frequency */ |
@@ -714,10 +714,10 @@ local void scan_tree (s, tree, max_code) | |||
714 | int min_count = 4; /* min repeat count */ | 714 | int min_count = 4; /* min repeat count */ |
715 | 715 | ||
716 | if (nextlen == 0) max_count = 138, min_count = 3; | 716 | if (nextlen == 0) max_count = 138, min_count = 3; |
717 | tree[max_code+1].Len = (ush)0xffff; /* guard */ | 717 | tree[max_code + 1].Len = (ush)0xffff; /* guard */ |
718 | 718 | ||
719 | for (n = 0; n <= max_code; n++) { | 719 | for (n = 0; n <= max_code; n++) { |
720 | curlen = nextlen; nextlen = tree[n+1].Len; | 720 | curlen = nextlen; nextlen = tree[n + 1].Len; |
721 | if (++count < max_count && curlen == nextlen) { | 721 | if (++count < max_count && curlen == nextlen) { |
722 | continue; | 722 | continue; |
723 | } else if (count < min_count) { | 723 | } else if (count < min_count) { |
@@ -745,7 +745,7 @@ local void scan_tree (s, tree, max_code) | |||
745 | * Send a literal or distance tree in compressed form, using the codes in | 745 | * Send a literal or distance tree in compressed form, using the codes in |
746 | * bl_tree. | 746 | * bl_tree. |
747 | */ | 747 | */ |
748 | local void send_tree (s, tree, max_code) | 748 | local void send_tree(s, tree, max_code) |
749 | deflate_state *s; | 749 | deflate_state *s; |
750 | ct_data *tree; /* the tree to be scanned */ | 750 | ct_data *tree; /* the tree to be scanned */ |
751 | int max_code; /* and its largest code of non zero frequency */ | 751 | int max_code; /* and its largest code of non zero frequency */ |
@@ -758,11 +758,11 @@ local void send_tree (s, tree, max_code) | |||
758 | int max_count = 7; /* max repeat count */ | 758 | int max_count = 7; /* max repeat count */ |
759 | int min_count = 4; /* min repeat count */ | 759 | int min_count = 4; /* min repeat count */ |
760 | 760 | ||
761 | /* tree[max_code+1].Len = -1; */ /* guard already set */ | 761 | /* tree[max_code + 1].Len = -1; */ /* guard already set */ |
762 | if (nextlen == 0) max_count = 138, min_count = 3; | 762 | if (nextlen == 0) max_count = 138, min_count = 3; |
763 | 763 | ||
764 | for (n = 0; n <= max_code; n++) { | 764 | for (n = 0; n <= max_code; n++) { |
765 | curlen = nextlen; nextlen = tree[n+1].Len; | 765 | curlen = nextlen; nextlen = tree[n + 1].Len; |
766 | if (++count < max_count && curlen == nextlen) { | 766 | if (++count < max_count && curlen == nextlen) { |
767 | continue; | 767 | continue; |
768 | } else if (count < min_count) { | 768 | } else if (count < min_count) { |
@@ -773,13 +773,13 @@ local void send_tree (s, tree, max_code) | |||
773 | send_code(s, curlen, s->bl_tree); count--; | 773 | send_code(s, curlen, s->bl_tree); count--; |
774 | } | 774 | } |
775 | Assert(count >= 3 && count <= 6, " 3_6?"); | 775 | Assert(count >= 3 && count <= 6, " 3_6?"); |
776 | send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); | 776 | send_code(s, REP_3_6, s->bl_tree); send_bits(s, count - 3, 2); |
777 | 777 | ||
778 | } else if (count <= 10) { | 778 | } else if (count <= 10) { |
779 | send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); | 779 | send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count - 3, 3); |
780 | 780 | ||
781 | } else { | 781 | } else { |
782 | send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); | 782 | send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count - 11, 7); |
783 | } | 783 | } |
784 | count = 0; prevlen = curlen; | 784 | count = 0; prevlen = curlen; |
785 | if (nextlen == 0) { | 785 | if (nextlen == 0) { |
@@ -807,8 +807,8 @@ local int build_bl_tree(s) | |||
807 | 807 | ||
808 | /* Build the bit length tree: */ | 808 | /* Build the bit length tree: */ |
809 | build_tree(s, (tree_desc *)(&(s->bl_desc))); | 809 | build_tree(s, (tree_desc *)(&(s->bl_desc))); |
810 | /* opt_len now includes the length of the tree representations, except | 810 | /* opt_len now includes the length of the tree representations, except the |
811 | * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. | 811 | * lengths of the bit lengths codes and the 5 + 5 + 4 bits for the counts. |
812 | */ | 812 | */ |
813 | 813 | ||
814 | /* Determine the number of bit length codes to send. The pkzip format | 814 | /* Determine the number of bit length codes to send. The pkzip format |
@@ -819,7 +819,7 @@ local int build_bl_tree(s) | |||
819 | if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; | 819 | if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; |
820 | } | 820 | } |
821 | /* Update opt_len to include the bit length tree and counts */ | 821 | /* Update opt_len to include the bit length tree and counts */ |
822 | s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4; | 822 | s->opt_len += 3*((ulg)max_blindex + 1) + 5 + 5 + 4; |
823 | Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", | 823 | Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", |
824 | s->opt_len, s->static_len)); | 824 | s->opt_len, s->static_len)); |
825 | 825 | ||
@@ -841,19 +841,19 @@ local void send_all_trees(s, lcodes, dcodes, blcodes) | |||
841 | Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, | 841 | Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, |
842 | "too many codes"); | 842 | "too many codes"); |
843 | Tracev((stderr, "\nbl counts: ")); | 843 | Tracev((stderr, "\nbl counts: ")); |
844 | send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ | 844 | send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */ |
845 | send_bits(s, dcodes-1, 5); | 845 | send_bits(s, dcodes - 1, 5); |
846 | send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ | 846 | send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */ |
847 | for (rank = 0; rank < blcodes; rank++) { | 847 | for (rank = 0; rank < blcodes; rank++) { |
848 | Tracev((stderr, "\nbl code %2d ", bl_order[rank])); | 848 | Tracev((stderr, "\nbl code %2d ", bl_order[rank])); |
849 | send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); | 849 | send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); |
850 | } | 850 | } |
851 | Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); | 851 | Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); |
852 | 852 | ||
853 | send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ | 853 | send_tree(s, (ct_data *)s->dyn_ltree, lcodes - 1); /* literal tree */ |
854 | Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); | 854 | Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); |
855 | 855 | ||
856 | send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ | 856 | send_tree(s, (ct_data *)s->dyn_dtree, dcodes - 1); /* distance tree */ |
857 | Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); | 857 | Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); |
858 | } | 858 | } |
859 | 859 | ||
@@ -866,7 +866,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) | |||
866 | ulg stored_len; /* length of input block */ | 866 | ulg stored_len; /* length of input block */ |
867 | int last; /* one if this is the last block for a file */ | 867 | int last; /* one if this is the last block for a file */ |
868 | { | 868 | { |
869 | send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ | 869 | send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ |
870 | bi_windup(s); /* align on byte boundary */ | 870 | bi_windup(s); /* align on byte boundary */ |
871 | put_short(s, (ush)stored_len); | 871 | put_short(s, (ush)stored_len); |
872 | put_short(s, (ush)~stored_len); | 872 | put_short(s, (ush)~stored_len); |
@@ -877,7 +877,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) | |||
877 | s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; | 877 | s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; |
878 | s->compressed_len += (stored_len + 4) << 3; | 878 | s->compressed_len += (stored_len + 4) << 3; |
879 | s->bits_sent += 2*16; | 879 | s->bits_sent += 2*16; |
880 | s->bits_sent += stored_len<<3; | 880 | s->bits_sent += stored_len << 3; |
881 | #endif | 881 | #endif |
882 | } | 882 | } |
883 | 883 | ||
@@ -943,8 +943,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) | |||
943 | max_blindex = build_bl_tree(s); | 943 | max_blindex = build_bl_tree(s); |
944 | 944 | ||
945 | /* Determine the best encoding. Compute the block lengths in bytes. */ | 945 | /* Determine the best encoding. Compute the block lengths in bytes. */ |
946 | opt_lenb = (s->opt_len+3+7)>>3; | 946 | opt_lenb = (s->opt_len + 3 + 7) >> 3; |
947 | static_lenb = (s->static_len+3+7)>>3; | 947 | static_lenb = (s->static_len + 3 + 7) >> 3; |
948 | 948 | ||
949 | Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", | 949 | Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", |
950 | opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, | 950 | opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, |
@@ -963,7 +963,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) | |||
963 | #ifdef FORCE_STORED | 963 | #ifdef FORCE_STORED |
964 | if (buf != (char*)0) { /* force stored block */ | 964 | if (buf != (char*)0) { /* force stored block */ |
965 | #else | 965 | #else |
966 | if (stored_len+4 <= opt_lenb && buf != (char*)0) { | 966 | if (stored_len + 4 <= opt_lenb && buf != (char*)0) { |
967 | /* 4: two words for the lengths */ | 967 | /* 4: two words for the lengths */ |
968 | #endif | 968 | #endif |
969 | /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. | 969 | /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. |
@@ -975,16 +975,16 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) | |||
975 | _tr_stored_block(s, buf, stored_len, last); | 975 | _tr_stored_block(s, buf, stored_len, last); |
976 | 976 | ||
977 | } else if (static_lenb == opt_lenb) { | 977 | } else if (static_lenb == opt_lenb) { |
978 | send_bits(s, (STATIC_TREES<<1)+last, 3); | 978 | send_bits(s, (STATIC_TREES<<1) + last, 3); |
979 | compress_block(s, (const ct_data *)static_ltree, | 979 | compress_block(s, (const ct_data *)static_ltree, |
980 | (const ct_data *)static_dtree); | 980 | (const ct_data *)static_dtree); |
981 | #ifdef ZLIB_DEBUG | 981 | #ifdef ZLIB_DEBUG |
982 | s->compressed_len += 3 + s->static_len; | 982 | s->compressed_len += 3 + s->static_len; |
983 | #endif | 983 | #endif |
984 | } else { | 984 | } else { |
985 | send_bits(s, (DYN_TREES<<1)+last, 3); | 985 | send_bits(s, (DYN_TREES<<1) + last, 3); |
986 | send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, | 986 | send_all_trees(s, s->l_desc.max_code + 1, s->d_desc.max_code + 1, |
987 | max_blindex+1); | 987 | max_blindex + 1); |
988 | compress_block(s, (const ct_data *)s->dyn_ltree, | 988 | compress_block(s, (const ct_data *)s->dyn_ltree, |
989 | (const ct_data *)s->dyn_dtree); | 989 | (const ct_data *)s->dyn_dtree); |
990 | #ifdef ZLIB_DEBUG | 990 | #ifdef ZLIB_DEBUG |
@@ -1003,18 +1003,18 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) | |||
1003 | s->compressed_len += 7; /* align on byte boundary */ | 1003 | s->compressed_len += 7; /* align on byte boundary */ |
1004 | #endif | 1004 | #endif |
1005 | } | 1005 | } |
1006 | Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, | 1006 | Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len >> 3, |
1007 | s->compressed_len-7*last)); | 1007 | s->compressed_len - 7*last)); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | /* =========================================================================== | 1010 | /* =========================================================================== |
1011 | * Save the match info and tally the frequency counts. Return true if | 1011 | * Save the match info and tally the frequency counts. Return true if |
1012 | * the current block must be flushed. | 1012 | * the current block must be flushed. |
1013 | */ | 1013 | */ |
1014 | int ZLIB_INTERNAL _tr_tally (s, dist, lc) | 1014 | int ZLIB_INTERNAL _tr_tally(s, dist, lc) |
1015 | deflate_state *s; | 1015 | deflate_state *s; |
1016 | unsigned dist; /* distance of matched string */ | 1016 | unsigned dist; /* distance of matched string */ |
1017 | unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ | 1017 | unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */ |
1018 | { | 1018 | { |
1019 | s->sym_buf[s->sym_next++] = (uch)dist; | 1019 | s->sym_buf[s->sym_next++] = (uch)dist; |
1020 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); | 1020 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); |
@@ -1030,7 +1030,7 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc) | |||
1030 | (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && | 1030 | (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && |
1031 | (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); | 1031 | (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); |
1032 | 1032 | ||
1033 | s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; | 1033 | s->dyn_ltree[_length_code[lc] + LITERALS + 1].Freq++; |
1034 | s->dyn_dtree[d_code(dist)].Freq++; | 1034 | s->dyn_dtree[d_code(dist)].Freq++; |
1035 | } | 1035 | } |
1036 | return (s->sym_next == s->sym_end); | 1036 | return (s->sym_next == s->sym_end); |
@@ -1060,7 +1060,7 @@ local void compress_block(s, ltree, dtree) | |||
1060 | } else { | 1060 | } else { |
1061 | /* Here, lc is the match length - MIN_MATCH */ | 1061 | /* Here, lc is the match length - MIN_MATCH */ |
1062 | code = _length_code[lc]; | 1062 | code = _length_code[lc]; |
1063 | send_code(s, code+LITERALS+1, ltree); /* send the length code */ | 1063 | send_code(s, code + LITERALS + 1, ltree); /* send length code */ |
1064 | extra = extra_lbits[code]; | 1064 | extra = extra_lbits[code]; |
1065 | if (extra != 0) { | 1065 | if (extra != 0) { |
1066 | lc -= base_length[code]; | 1066 | lc -= base_length[code]; |
@@ -1176,6 +1176,6 @@ local void bi_windup(s) | |||
1176 | s->bi_buf = 0; | 1176 | s->bi_buf = 0; |
1177 | s->bi_valid = 0; | 1177 | s->bi_valid = 0; |
1178 | #ifdef ZLIB_DEBUG | 1178 | #ifdef ZLIB_DEBUG |
1179 | s->bits_sent = (s->bits_sent+7) & ~7; | 1179 | s->bits_sent = (s->bits_sent + 7) & ~7; |
1180 | #endif | 1180 | #endif |
1181 | } | 1181 | } |