MCPcopy Create free account
hub / github.com/RsyncProject/rsync / build_bl_tree

Function build_bl_tree

zlib/trees.c:780–807  ·  view source on GitHub ↗

=========================================================================== * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */

Source from the content-addressed store, hash-verified

778 * bl_order of the last bit length code to send.
779 */
780local int build_bl_tree(deflate_state *s)
781{
782 int max_blindex; /* index of last bit length code of non zero freq */
783
784 /* Determine the bit length frequencies for literal and distance trees */
785 scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
786 scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
787
788 /* Build the bit length tree: */
789 build_tree(s, (tree_desc *)(&(s->bl_desc)));
790 /* opt_len now includes the length of the tree representations, except
791 * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
792 */
793
794 /* Determine the number of bit length codes to send. The pkzip format
795 * requires that at least 4 bit length codes be sent. (appnote.txt says
796 * 3 but the actual value used is 4.)
797 */
798 for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
799 if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
800 }
801 /* Update opt_len to include the bit length tree and counts */
802 s->opt_len += 3*(max_blindex+1) + 5+5+4;
803 Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
804 s->opt_len, s->static_len));
805
806 return max_blindex;
807}
808
809/* ===========================================================================
810 * Send the header for a block using dynamic Huffman trees: the counts, the

Callers 1

trees.cFile · 0.85

Calls 2

scan_treeFunction · 0.85
build_treeFunction · 0.85

Tested by

no test coverage detected