MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / build_bl_tree

Function build_bl_tree

extlibs/minizip/src/trees.c:862–892  ·  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. */

(s)

Source from the content-addressed store, hash-verified

860 * bl_order of the last bit length code to send.
861 */
862local int build_bl_tree(s)
863
864deflate_state* s;
865{
866 int max_blindex; /* index of last bit length code of non zero freq */
867
868 /* Determine the bit length frequencies for literal and distance trees */
869 scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
870 scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
871
872 /* Build the bit length tree: */
873 build_tree(s, (tree_desc *)(&(s->bl_desc)));
874 /* opt_len now includes the length of the tree representations, except
875 * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
876 */
877
878 /* Determine the number of bit length codes to send. The pkzip format
879 * requires that at least 4 bit length codes be sent. (appnote.txt says
880 * 3 but the actual value used is 4.)
881 */
882 for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--)
883 {
884 if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
885 }
886 /* Update opt_len to include the bit length tree and counts */
887 s->opt_len += 3 * ((ulg)max_blindex + 1) + 5 + 5 + 4;
888 Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
889 s->opt_len, s->static_len));
890
891 return max_blindex;
892}
893
894/* ===========================================================================
895 * 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