MCPcopy Create free account
hub / github.com/TruthHun/BookStack / build_bl_tree

Function build_bl_tree

static/word2md/mammoth.browser.js:23243–23271  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

23241 * bl_order of the last bit length code to send.
23242 */
23243function build_bl_tree(s) {
23244 var max_blindex; /* index of last bit length code of non zero freq */
23245
23246 /* Determine the bit length frequencies for literal and distance trees */
23247 scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
23248 scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
23249
23250 /* Build the bit length tree: */
23251 build_tree(s, s.bl_desc);
23252 /* opt_len now includes the length of the tree representations, except
23253 * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
23254 */
23255
23256 /* Determine the number of bit length codes to send. The pkzip format
23257 * requires that at least 4 bit length codes be sent. (appnote.txt says
23258 * 3 but the actual value used is 4.)
23259 */
23260 for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {
23261 if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {
23262 break;
23263 }
23264 }
23265 /* Update opt_len to include the bit length tree and counts */
23266 s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;
23267 //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
23268 // s->opt_len, s->static_len));
23269
23270 return max_blindex;
23271}
23272
23273
23274/* ===========================================================================

Callers 1

_tr_flush_blockFunction · 0.70

Calls 2

scan_treeFunction · 0.70
build_treeFunction · 0.70

Tested by

no test coverage detected