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