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

Function scan_tree

extlibs/minizip/src/trees.c:726–782  ·  view source on GitHub ↗

=========================================================================== * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. */

(s, tree, max_code)

Source from the content-addressed store, hash-verified

724 * in the bit length tree.
725 */
726local void scan_tree(s, tree, max_code)
727deflate_state* s;
728ct_data* tree; /* the tree to be scanned */
729int max_code; /* and its largest code of non zero frequency */
730{
731 int n; /* iterates over all tree elements */
732 int prevlen = -1; /* last emitted length */
733 int curlen; /* length of current code */
734 int nextlen = tree[0].Len; /* length of next code */
735 int count = 0; /* repeat count of the current code */
736 int max_count = 7; /* max repeat count */
737 int min_count = 4; /* min repeat count */
738
739 if (nextlen == 0) max_count = 138 , min_count = 3;
740 tree[max_code + 1].Len = (ush)0xffff; /* guard */
741
742 for (n = 0; n <= max_code; n++)
743 {
744 curlen = nextlen;
745 nextlen = tree[n + 1].Len;
746 if (++count < max_count && curlen == nextlen)
747 {
748 continue;
749 }
750 else if (count < min_count)
751 {
752 s->bl_tree[curlen].Freq += count;
753 }
754 else if (curlen != 0)
755 {
756 if (curlen != prevlen) s->bl_tree[curlen].Freq++;
757 s->bl_tree[REP_3_6].Freq++;
758 }
759 else if (count <= 10)
760 {
761 s->bl_tree[REPZ_3_10].Freq++;
762 }
763 else
764 {
765 s->bl_tree[REPZ_11_138].Freq++;
766 }
767 count = 0;
768 prevlen = curlen;
769 if (nextlen == 0)
770 {
771 max_count = 138 , min_count = 3;
772 }
773 else if (curlen == nextlen)
774 {
775 max_count = 6 , min_count = 3;
776 }
777 else
778 {
779 max_count = 7 , min_count = 4;
780 }
781 }
782}
783

Callers 1

build_bl_treeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected