MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / build_bl_tree

Function build_bl_tree

extern/zlib/src/trees.c:798–824  ·  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

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