=========================================================================== * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */
(s)
| 797 | * bl_order of the last bit length code to send. |
| 798 | */ |
| 799 | local int build_bl_tree(s) |
| 800 | deflate_state *s; |
| 801 | { |
| 802 | int max_blindex; /* index of last bit length code of non zero freq */ |
| 803 | |
| 804 | /* Determine the bit length frequencies for literal and distance trees */ |
| 805 | scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); |
| 806 | scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); |
| 807 | |
| 808 | /* Build the bit length tree: */ |
| 809 | build_tree(s, (tree_desc *)(&(s->bl_desc))); |
| 810 | /* opt_len now includes the length of the tree representations, except |
| 811 | * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. |
| 812 | */ |
| 813 | |
| 814 | /* Determine the number of bit length codes to send. The pkzip format |
| 815 | * requires that at least 4 bit length codes be sent. (appnote.txt says |
| 816 | * 3 but the actual value used is 4.) |
| 817 | */ |
| 818 | for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { |
| 819 | if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; |
| 820 | } |
| 821 | /* Update opt_len to include the bit length tree and counts */ |
| 822 | s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4; |
| 823 | Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", |
| 824 | s->opt_len, s->static_len)); |
| 825 | |
| 826 | return max_blindex; |
| 827 | } |
| 828 | |
| 829 | /* =========================================================================== |
| 830 | * Send the header for a block using dynamic Huffman trees: the counts, the |
no test coverage detected