void DoDyn() // Dynamic huffman encoding, the most complex case, RFC1951 page 12. { uint nLitCode = 257 + GetBits(5), nDistCode = 1 + GetBits(5), nLenCode = 4 + GetBits(4); for (uint i = 0; i < nLenCode; i += 1) { ClenLen[ClenAlphabet[i]] = (byte)GetBits(3); } for (uint i = nLenCode; i < 19; i += 1) { ClenLen[ClenAlphabet[i]] = 0; } Clen.MakeTree(ClenLen, 19); Plenc = 0; uint carry = GetLengths(LitLen, nLitCode, 0); GetLengths(DistLen, nDistCode, carry); Lit.MakeTree(LitLen, nLitCode); Dist.MakeTree(DistLen, nDistCode); while (true) { uint x = Lit.Decode(this); if (x < 256) { OB.Add((byte)x); } else if (x == 256) { break; } else { x -= 257; uint length = MatchOff[x] + GetBits(MatchExtra[x]); uint dc = Dist.Decode(this); uint distance = DistOff[dc] + GetBits(DistExtra[dc]); if (TraceLevel > 1) { System.Console.WriteLine("Copy at " + OB.Count + " length=" + length + " distance=" + distance); } OB.Copy(distance, length); } } } // end DoDyn