/Utilities/Compression/Deflaters/DeflaterConstants.cs
C# | 171 lines | 60 code | 27 blank | 84 comment | 0 complexity | 87cb0b936a54ad45a5e6954896a1e9e9 MD5 | raw file
Possible License(s): Apache-2.0
- // Based on Mike Krueger's SharpZipLib, Copyright (C) 2001 (GNU license).
- // Authors of the original java version: Jochen Hoenicke, John Leuner
- // See http://www.ISeeSharpCode.com for more information.
-
- using System;
-
- namespace Delta.Utilities.Compression.Deflaters
- {
- /// <summary>
- /// This class contains constants used for deflation.
- /// </summary>
- public class DeflaterConstants
- {
- #region Constants
- /// <summary>
- /// Written to Zip file to identify a stored block
- /// </summary>
- public const int StoredBlock = 0;
-
- /// <summary>
- /// Identifies static tree in Zip file
- /// </summary>
- public const int StaticTrees = 1;
-
- /// <summary>
- /// Identifies dynamic tree in Zip file
- /// </summary>
- public const int DynamicTrees = 2;
-
- /// <summary>
- /// Header flag indicating a preset dictionary for deflation
- /// </summary>
- public const int PresetDictionary = 0x20;
-
- /// <summary>
- /// Sets internal buffer sizes for Huffman encoding
- /// </summary>
- public const int DefaultMemoryLevel = 8;
-
- /// <summary>
- /// Max match. Internal compression engine constant
- /// </summary>
- public const int MaxMatch = 258;
-
- /// <summary>
- /// Min match. Internal compression engine constant
- /// </summary>
- public const int MinMatch = 3;
-
- /// <summary>
- /// Max WBits for WSize. Internal compression engine constant
- /// </summary>
- public const int MaxWBits = 15;
-
- /// <summary>
- /// WSize. Internal compression engine constant
- /// </summary>
- public const int WSize = 1 << MaxWBits;
-
- /// <summary>
- /// WMask. Internal compression engine constant
- /// </summary>
- public const int WMask = WSize - 1;
-
- /// <summary>
- /// Hash bits. Internal compression engine constant
- /// </summary>
- public const int HashBits = DefaultMemoryLevel + 7;
-
- /// <summary>
- /// Hash size. Internal compression engine constant
- /// </summary>
- public const int HashSize = 1 << HashBits;
-
- /// <summary>
- /// Hash mask. Internal compression engine constant
- /// </summary>
- public const int HashMask = HashSize - 1;
-
- /// <summary>
- /// Hash shift. Internal compression engine constant
- /// </summary>
- public const int HashShift = (HashBits + MinMatch - 1) / MinMatch;
-
- /// <summary>
- /// Min look ahead. Internal compression engine constant
- /// </summary>
- public const int MinLookAhead = MaxMatch + MinMatch + 1;
-
- /// <summary>
- /// Max distance. Internal compression engine constant
- /// </summary>
- public const int MaxDistance = WSize - MinLookAhead;
-
- /// <summary>
- /// Pending buffer size. Internal compression engine constant
- /// </summary>
- public const int PendingBufferSize = 1 << (DefaultMemoryLevel + 8);
-
- /// <summary>
- /// Compression deflate stored. Internal compression engine constant
- /// </summary>
- public const int CompressionDeflateStored = 0;
-
- /// <summary>
- /// Compression deflate fast. Internal compression engine constant
- /// </summary>
- public const int CompressionDeflateFast = 1;
-
- /// <summary>
- /// Compression deflate slow. Internal compression engine constant
- /// </summary>
- public const int CompressionDeflateSlow = 2;
- #endregion
-
- #region MaxBlockSize (Static)
- /// <summary>
- /// Max block size. Internal compression engine constant
- /// </summary>
- public static int MaxBlockSize = Math.Min(65535, PendingBufferSize - 5);
- #endregion
-
- #region GoodLength (Static)
- /// <summary>
- /// Good length. Internal compression engine constant
- /// </summary>
- public static int[] GoodLength = {
- 0, 4, 4, 4, 4, 8, 8, 8, 32, 32
- };
- #endregion
-
- #region MaxLazy (Static)
- /// <summary>
- /// Max lazy. Internal compression engine constant
- /// </summary>
- public static int[] MaxLazy = {
- 0, 4, 5, 6, 4, 16, 16, 32, 128, 258
- };
- #endregion
-
- #region NiceLength (Static)
- /// <summary>
- /// Nice length. Internal compression engine constant
- /// </summary>
- public static int[] NiceLength =
- {
- 0, 8, 16, 32, 16, 32, 128, 128, 258, 258
- };
- #endregion
-
- #region MaxChain (Static)
- /// <summary>
- /// Max chain. Internal compression engine constant
- /// </summary>
- public static int[] MaxChain =
- {
- 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096
- };
- #endregion
-
- #region CompressionFunction (Static)
- /// <summary>
- /// Compression function. Internal compression engine constant
- /// </summary>
- public static int[] CompressionFunction =
- {
- 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
- };
- #endregion
- }
- }