1 // DeflaterConstants.cs
3 // Copyright (C) 2001 Mike Krueger
4 // Copyright (C) 2004 John Reilly
6 // This file was translated from java, it was part of the GNU Classpath
7 // Copyright (C) 2001 Free Software Foundation, Inc.
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.
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.
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.
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
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.
42 namespace ICSharpCode.SharpZipLib.Silverlight.Zip.Compression
45 /// This class contains constants used for deflation.
47 public class DeflaterConstants
50 /// Set to true to enable debugging
52 public const bool DEBUGGING = false;
55 /// Written to Zip file to identify a stored block
57 public const int STORED_BLOCK = 0;
60 /// Identifies static tree in Zip file
62 public const int STATIC_TREES = 1;
65 /// Identifies dynamic tree in Zip file
67 public const int DYN_TREES = 2;
70 /// Header flag indicating a preset dictionary for deflation
72 public const int PRESET_DICT = 0x20;
75 /// Sets internal buffer sizes for Huffman encoding
77 public const int DEFAULT_MEM_LEVEL = 8;
80 /// Internal compression engine constant
82 public const int MAX_MATCH = 258;
85 /// Internal compression engine constant
87 public const int MIN_MATCH = 3;
90 /// Internal compression engine constant
92 public const int MAX_WBITS = 15;
95 /// Internal compression engine constant
97 public const int WSIZE = 1 << MAX_WBITS;
100 /// Internal compression engine constant
102 public const int WMASK = WSIZE - 1;
105 /// Internal compression engine constant
107 public const int HASH_BITS = DEFAULT_MEM_LEVEL + 7;
110 /// Internal compression engine constant
112 public const int HASH_SIZE = 1 << HASH_BITS;
115 /// Internal compression engine constant
117 public const int HASH_MASK = HASH_SIZE - 1;
120 /// Internal compression engine constant
122 public const int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH;
125 /// Internal compression engine constant
127 public const int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;
130 /// Internal compression engine constant
132 public const int MAX_DIST = WSIZE - MIN_LOOKAHEAD;
135 /// Internal compression engine constant
137 public const int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8);
140 /// Internal compression engine constant
142 public static int MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE - 5);
145 /// Internal compression engine constant
147 public const int DEFLATE_STORED = 0;
150 /// Internal compression engine constant
152 public const int DEFLATE_FAST = 1;
155 /// Internal compression engine constant
157 public const int DEFLATE_SLOW = 2;
160 /// Internal compression engine constant
162 public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 };
165 /// Internal compression engine constant
167 public static int[] MAX_LAZY = { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 };
170 /// Internal compression engine constant
172 public static int[] NICE_LENGTH = { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 };
175 /// Internal compression engine constant
177 public static int[] MAX_CHAIN = { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 };
180 /// Internal compression engine constant
182 public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 };