ICSharpCode.SharpZipLib.Zip.Compression.DeflaterHuffman.Tree.CalcBLFreq C# (CSharp) Method

CalcBLFreq() public method

Scan a literal or distance tree to determine the frequencies of the codes in the bit length tree.
public CalcBLFreq ( Tree blTree ) : void
blTree Tree
return void
            public void CalcBLFreq(Tree blTree)
            {
                int max_count;               /* max repeat count */
                int min_count;               /* min repeat count */
                int count;                   /* repeat count of the current code */
                int curlen = -1;             /* length of current code */

                int i = 0;
                while (i < numCodes) {
                    count = 1;
                    int nextlen = length[i];
                    if (nextlen == 0) {
                        max_count = 138;
                        min_count = 3;
                    } else {
                        max_count = 6;
                        min_count = 3;
                        if (curlen != nextlen) {
                            blTree.freqs[nextlen]++;
                            count = 0;
                        }
                    }
                    curlen = nextlen;
                    i++;

                    while (i < numCodes && curlen == length[i]) {
                        i++;
                        if (++count >= max_count) {
                            break;
                        }
                    }

                    if (count < min_count) {
                        blTree.freqs[curlen] += (short)count;
                    } else if (curlen != 0) {
                        blTree.freqs[REP_3_6]++;
                    } else if (count <= 10) {
                        blTree.freqs[REP_3_10]++;
                    } else {
                        blTree.freqs[REP_11_138]++;
                    }
                }
            }