=========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */
| 749 | * bl_tree. |
| 750 | */ |
| 751 | local void send_tree(deflate_state *s, ct_data *tree, int max_code) { |
| 752 | int n; /* iterates over all tree elements */ |
| 753 | int prevlen = -1; /* last emitted length */ |
| 754 | int curlen; /* length of current code */ |
| 755 | int nextlen = tree[0].Len; /* length of next code */ |
| 756 | int count = 0; /* repeat count of the current code */ |
| 757 | int max_count = 7; /* max repeat count */ |
| 758 | int min_count = 4; /* min repeat count */ |
| 759 | |
| 760 | /* tree[max_code + 1].Len = -1; */ /* guard already set */ |
| 761 | if (nextlen == 0) max_count = 138, min_count = 3; |
| 762 | |
| 763 | for (n = 0; n <= max_code; n++) { |
| 764 | curlen = nextlen; nextlen = tree[n + 1].Len; |
| 765 | if (++count < max_count && curlen == nextlen) { |
| 766 | continue; |
| 767 | } else if (count < min_count) { |
| 768 | do { send_code(s, curlen, s->bl_tree); } while (--count != 0); |
| 769 | |
| 770 | } else if (curlen != 0) { |
| 771 | if (curlen != prevlen) { |
| 772 | send_code(s, curlen, s->bl_tree); count--; |
| 773 | } |
| 774 | Assert(count >= 3 && count <= 6, " 3_6?"); |
| 775 | send_code(s, REP_3_6, s->bl_tree); send_bits(s, count - 3, 2); |
| 776 | |
| 777 | } else if (count <= 10) { |
| 778 | send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count - 3, 3); |
| 779 | |
| 780 | } else { |
| 781 | send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count - 11, 7); |
| 782 | } |
| 783 | count = 0; prevlen = curlen; |
| 784 | if (nextlen == 0) { |
| 785 | max_count = 138, min_count = 3; |
| 786 | } else if (curlen == nextlen) { |
| 787 | max_count = 6, min_count = 3; |
| 788 | } else { |
| 789 | max_count = 7, min_count = 4; |
| 790 | } |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | /* =========================================================================== |
| 795 | * Construct the Huffman tree for the bit lengths and return the index in |
no test coverage detected