DeflaterConstants.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // DeflaterConstants.cs
  2. //
  3. // Copyright (C) 2001 Mike Krueger
  4. // Copyright (C) 2004 John Reilly
  5. //
  6. // This file was translated from java, it was part of the GNU Classpath
  7. // Copyright (C) 2001 Free Software Foundation, Inc.
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public License
  11. // as published by the Free Software Foundation; either version 2
  12. // of the License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. //
  23. // Linking this library statically or dynamically with other modules is
  24. // making a combined work based on this library. Thus, the terms and
  25. // conditions of the GNU General Public License cover the whole
  26. // combination.
  27. //
  28. // As a special exception, the copyright holders of this library give you
  29. // permission to link this library with independent modules to produce an
  30. // executable, regardless of the license terms of these independent
  31. // modules, and to copy and distribute the resulting executable under
  32. // terms of your choice, provided that you also meet, for each linked
  33. // independent module, the terms and conditions of the license of that
  34. // module. An independent module is a module which is not derived from
  35. // or based on this library. If you modify this library, you may extend
  36. // this exception to your version of the library, but you are not
  37. // obligated to do so. If you do not wish to do so, delete this
  38. // exception statement from your version.
  39. using System;
  40. namespace CommonMPQ.SharpZipLib.Zip.Compression
  41. {
  42. /// <summary>
  43. /// This class contains constants used for deflation.
  44. /// </summary>
  45. public class DeflaterConstants
  46. {
  47. /// <summary>
  48. /// Set to true to enable debugging
  49. /// </summary>
  50. public const bool DEBUGGING = false;
  51. /// <summary>
  52. /// Written to Zip file to identify a stored block
  53. /// </summary>
  54. public const int STORED_BLOCK = 0;
  55. /// <summary>
  56. /// Identifies static tree in Zip file
  57. /// </summary>
  58. public const int STATIC_TREES = 1;
  59. /// <summary>
  60. /// Identifies dynamic tree in Zip file
  61. /// </summary>
  62. public const int DYN_TREES = 2;
  63. /// <summary>
  64. /// Header flag indicating a preset dictionary for deflation
  65. /// </summary>
  66. public const int PRESET_DICT = 0x20;
  67. /// <summary>
  68. /// Sets internal buffer sizes for Huffman encoding
  69. /// </summary>
  70. public const int DEFAULT_MEM_LEVEL = 8;
  71. /// <summary>
  72. /// Internal compression engine constant
  73. /// </summary>
  74. public const int MAX_MATCH = 258;
  75. /// <summary>
  76. /// Internal compression engine constant
  77. /// </summary>
  78. public const int MIN_MATCH = 3;
  79. /// <summary>
  80. /// Internal compression engine constant
  81. /// </summary>
  82. public const int MAX_WBITS = 15;
  83. /// <summary>
  84. /// Internal compression engine constant
  85. /// </summary>
  86. public const int WSIZE = 1 << MAX_WBITS;
  87. /// <summary>
  88. /// Internal compression engine constant
  89. /// </summary>
  90. public const int WMASK = WSIZE - 1;
  91. /// <summary>
  92. /// Internal compression engine constant
  93. /// </summary>
  94. public const int HASH_BITS = DEFAULT_MEM_LEVEL + 7;
  95. /// <summary>
  96. /// Internal compression engine constant
  97. /// </summary>
  98. public const int HASH_SIZE = 1 << HASH_BITS;
  99. /// <summary>
  100. /// Internal compression engine constant
  101. /// </summary>
  102. public const int HASH_MASK = HASH_SIZE - 1;
  103. /// <summary>
  104. /// Internal compression engine constant
  105. /// </summary>
  106. public const int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH;
  107. /// <summary>
  108. /// Internal compression engine constant
  109. /// </summary>
  110. public const int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;
  111. /// <summary>
  112. /// Internal compression engine constant
  113. /// </summary>
  114. public const int MAX_DIST = WSIZE - MIN_LOOKAHEAD;
  115. /// <summary>
  116. /// Internal compression engine constant
  117. /// </summary>
  118. public const int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8);
  119. /// <summary>
  120. /// Internal compression engine constant
  121. /// </summary>
  122. public static int MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE - 5);
  123. /// <summary>
  124. /// Internal compression engine constant
  125. /// </summary>
  126. public const int DEFLATE_STORED = 0;
  127. /// <summary>
  128. /// Internal compression engine constant
  129. /// </summary>
  130. public const int DEFLATE_FAST = 1;
  131. /// <summary>
  132. /// Internal compression engine constant
  133. /// </summary>
  134. public const int DEFLATE_SLOW = 2;
  135. /// <summary>
  136. /// Internal compression engine constant
  137. /// </summary>
  138. public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 };
  139. /// <summary>
  140. /// Internal compression engine constant
  141. /// </summary>
  142. public static int[] MAX_LAZY = { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 };
  143. /// <summary>
  144. /// Internal compression engine constant
  145. /// </summary>
  146. public static int[] NICE_LENGTH = { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 };
  147. /// <summary>
  148. /// Internal compression engine constant
  149. /// </summary>
  150. public static int[] MAX_CHAIN = { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 };
  151. /// <summary>
  152. /// Internal compression engine constant
  153. /// </summary>
  154. public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
  155. }
  156. }