PageRenderTime 28ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  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. using System;
  5. namespace Delta.Utilities.Compression.Deflaters
  6. {
  7. /// <summary>
  8. /// This class contains constants used for deflation.
  9. /// </summary>
  10. public class DeflaterConstants
  11. {
  12. #region Constants
  13. /// <summary>
  14. /// Written to Zip file to identify a stored block
  15. /// </summary>
  16. public const int StoredBlock = 0;
  17. /// <summary>
  18. /// Identifies static tree in Zip file
  19. /// </summary>
  20. public const int StaticTrees = 1;
  21. /// <summary>
  22. /// Identifies dynamic tree in Zip file
  23. /// </summary>
  24. public const int DynamicTrees = 2;
  25. /// <summary>
  26. /// Header flag indicating a preset dictionary for deflation
  27. /// </summary>
  28. public const int PresetDictionary = 0x20;
  29. /// <summary>
  30. /// Sets internal buffer sizes for Huffman encoding
  31. /// </summary>
  32. public const int DefaultMemoryLevel = 8;
  33. /// <summary>
  34. /// Max match. Internal compression engine constant
  35. /// </summary>
  36. public const int MaxMatch = 258;
  37. /// <summary>
  38. /// Min match. Internal compression engine constant
  39. /// </summary>
  40. public const int MinMatch = 3;
  41. /// <summary>
  42. /// Max WBits for WSize. Internal compression engine constant
  43. /// </summary>
  44. public const int MaxWBits = 15;
  45. /// <summary>
  46. /// WSize. Internal compression engine constant
  47. /// </summary>
  48. public const int WSize = 1 << MaxWBits;
  49. /// <summary>
  50. /// WMask. Internal compression engine constant
  51. /// </summary>
  52. public const int WMask = WSize - 1;
  53. /// <summary>
  54. /// Hash bits. Internal compression engine constant
  55. /// </summary>
  56. public const int HashBits = DefaultMemoryLevel + 7;
  57. /// <summary>
  58. /// Hash size. Internal compression engine constant
  59. /// </summary>
  60. public const int HashSize = 1 << HashBits;
  61. /// <summary>
  62. /// Hash mask. Internal compression engine constant
  63. /// </summary>
  64. public const int HashMask = HashSize - 1;
  65. /// <summary>
  66. /// Hash shift. Internal compression engine constant
  67. /// </summary>
  68. public const int HashShift = (HashBits + MinMatch - 1) / MinMatch;
  69. /// <summary>
  70. /// Min look ahead. Internal compression engine constant
  71. /// </summary>
  72. public const int MinLookAhead = MaxMatch + MinMatch + 1;
  73. /// <summary>
  74. /// Max distance. Internal compression engine constant
  75. /// </summary>
  76. public const int MaxDistance = WSize - MinLookAhead;
  77. /// <summary>
  78. /// Pending buffer size. Internal compression engine constant
  79. /// </summary>
  80. public const int PendingBufferSize = 1 << (DefaultMemoryLevel + 8);
  81. /// <summary>
  82. /// Compression deflate stored. Internal compression engine constant
  83. /// </summary>
  84. public const int CompressionDeflateStored = 0;
  85. /// <summary>
  86. /// Compression deflate fast. Internal compression engine constant
  87. /// </summary>
  88. public const int CompressionDeflateFast = 1;
  89. /// <summary>
  90. /// Compression deflate slow. Internal compression engine constant
  91. /// </summary>
  92. public const int CompressionDeflateSlow = 2;
  93. #endregion
  94. #region MaxBlockSize (Static)
  95. /// <summary>
  96. /// Max block size. Internal compression engine constant
  97. /// </summary>
  98. public static int MaxBlockSize = Math.Min(65535, PendingBufferSize - 5);
  99. #endregion
  100. #region GoodLength (Static)
  101. /// <summary>
  102. /// Good length. Internal compression engine constant
  103. /// </summary>
  104. public static int[] GoodLength = {
  105. 0, 4, 4, 4, 4, 8, 8, 8, 32, 32
  106. };
  107. #endregion
  108. #region MaxLazy (Static)
  109. /// <summary>
  110. /// Max lazy. Internal compression engine constant
  111. /// </summary>
  112. public static int[] MaxLazy = {
  113. 0, 4, 5, 6, 4, 16, 16, 32, 128, 258
  114. };
  115. #endregion
  116. #region NiceLength (Static)
  117. /// <summary>
  118. /// Nice length. Internal compression engine constant
  119. /// </summary>
  120. public static int[] NiceLength =
  121. {
  122. 0, 8, 16, 32, 16, 32, 128, 128, 258, 258
  123. };
  124. #endregion
  125. #region MaxChain (Static)
  126. /// <summary>
  127. /// Max chain. Internal compression engine constant
  128. /// </summary>
  129. public static int[] MaxChain =
  130. {
  131. 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096
  132. };
  133. #endregion
  134. #region CompressionFunction (Static)
  135. /// <summary>
  136. /// Compression function. Internal compression engine constant
  137. /// </summary>
  138. public static int[] CompressionFunction =
  139. {
  140. 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
  141. };
  142. #endregion
  143. }
  144. }