PageRenderTime 260ms CodeModel.GetById 81ms app.highlight 72ms RepoModel.GetById 99ms app.codeStats 1ms

/Utilities/Compression/Deflaters/DeflaterConstants.cs

#
C# | 171 lines | 60 code | 27 blank | 84 comment | 0 complexity | 87cb0b936a54ad45a5e6954896a1e9e9 MD5 | raw file
  1// Based on Mike Krueger's SharpZipLib, Copyright (C) 2001 (GNU license).
  2// Authors of the original java version: Jochen Hoenicke, John Leuner
  3// See http://www.ISeeSharpCode.com for more information.
  4
  5using System;
  6
  7namespace Delta.Utilities.Compression.Deflaters
  8{
  9	/// <summary>
 10	/// This class contains constants used for deflation.
 11	/// </summary>
 12	public class DeflaterConstants
 13	{
 14		#region Constants
 15		/// <summary>
 16		/// Written to Zip file to identify a stored block
 17		/// </summary>
 18		public const int StoredBlock = 0;
 19
 20		/// <summary>
 21		/// Identifies static tree in Zip file
 22		/// </summary>
 23		public const int StaticTrees = 1;
 24
 25		/// <summary>
 26		/// Identifies dynamic tree in Zip file
 27		/// </summary>
 28		public const int DynamicTrees = 2;
 29
 30		/// <summary>
 31		/// Header flag indicating a preset dictionary for deflation
 32		/// </summary>
 33		public const int PresetDictionary = 0x20;
 34
 35		/// <summary>
 36		/// Sets internal buffer sizes for Huffman encoding
 37		/// </summary>
 38		public const int DefaultMemoryLevel = 8;
 39
 40		/// <summary>
 41		/// Max match. Internal compression engine constant
 42		/// </summary>		
 43		public const int MaxMatch = 258;
 44
 45		/// <summary>
 46		/// Min match. Internal compression engine constant
 47		/// </summary>		
 48		public const int MinMatch = 3;
 49
 50		/// <summary>
 51		/// Max WBits for WSize. Internal compression engine constant
 52		/// </summary>		
 53		public const int MaxWBits = 15;
 54
 55		/// <summary>
 56		/// WSize. Internal compression engine constant
 57		/// </summary>		
 58		public const int WSize = 1 << MaxWBits;
 59
 60		/// <summary>
 61		/// WMask. Internal compression engine constant
 62		/// </summary>		
 63		public const int WMask = WSize - 1;
 64
 65		/// <summary>
 66		/// Hash bits. Internal compression engine constant
 67		/// </summary>		
 68		public const int HashBits = DefaultMemoryLevel + 7;
 69
 70		/// <summary>
 71		/// Hash size. Internal compression engine constant
 72		/// </summary>		
 73		public const int HashSize = 1 << HashBits;
 74
 75		/// <summary>
 76		/// Hash mask. Internal compression engine constant
 77		/// </summary>		
 78		public const int HashMask = HashSize - 1;
 79
 80		/// <summary>
 81		/// Hash shift. Internal compression engine constant
 82		/// </summary>		
 83		public const int HashShift = (HashBits + MinMatch - 1) / MinMatch;
 84
 85		/// <summary>
 86		/// Min look ahead. Internal compression engine constant
 87		/// </summary>		
 88		public const int MinLookAhead = MaxMatch + MinMatch + 1;
 89
 90		/// <summary>
 91		/// Max distance. Internal compression engine constant
 92		/// </summary>		
 93		public const int MaxDistance = WSize - MinLookAhead;
 94
 95		/// <summary>
 96		/// Pending buffer size. Internal compression engine constant
 97		/// </summary>		
 98		public const int PendingBufferSize = 1 << (DefaultMemoryLevel + 8);
 99
100		/// <summary>
101		/// Compression deflate stored. Internal compression engine constant
102		/// </summary>		
103		public const int CompressionDeflateStored = 0;
104
105		/// <summary>
106		/// Compression deflate fast. Internal compression engine constant
107		/// </summary>		
108		public const int CompressionDeflateFast = 1;
109
110		/// <summary>
111		/// Compression deflate slow. Internal compression engine constant
112		/// </summary>		
113		public const int CompressionDeflateSlow = 2;
114		#endregion
115
116		#region MaxBlockSize (Static)
117		/// <summary>
118		/// Max block size. Internal compression engine constant
119		/// </summary>		
120		public static int MaxBlockSize = Math.Min(65535, PendingBufferSize - 5);
121		#endregion
122
123		#region GoodLength (Static)
124		/// <summary>
125		/// Good length. Internal compression engine constant
126		/// </summary>		
127		public static int[] GoodLength = {
128			0, 4, 4, 4, 4, 8, 8, 8, 32, 32
129		};
130		#endregion
131
132		#region MaxLazy (Static)
133		/// <summary>
134		/// Max lazy. Internal compression engine constant
135		/// </summary>		
136		public static int[] MaxLazy = {
137			0, 4, 5, 6, 4, 16, 16, 32, 128, 258
138		};
139		#endregion
140
141		#region NiceLength (Static)
142		/// <summary>
143		/// Nice length. Internal compression engine constant
144		/// </summary>		
145		public static int[] NiceLength =
146			{
147				0, 8, 16, 32, 16, 32, 128, 128, 258, 258
148			};
149		#endregion
150
151		#region MaxChain (Static)
152		/// <summary>
153		/// Max chain. Internal compression engine constant
154		/// </summary>		
155		public static int[] MaxChain =
156			{
157				0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096
158			};
159		#endregion
160
161		#region CompressionFunction (Static)
162		/// <summary>
163		/// Compression function. Internal compression engine constant
164		/// </summary>		
165		public static int[] CompressionFunction =
166			{
167				0, 1, 1, 1, 1, 2, 2, 2, 2, 2
168			};
169		#endregion
170	}
171}