6 #ifndef CRYPTOPP_ZDEFLATE_H 7 #define CRYPTOPP_ZDEFLATE_H 24 void PutBits(
unsigned long value,
unsigned int length);
25 void FlushBitBuffer();
26 void ClearBitBuffer();
29 unsigned long FinishCounting();
33 unsigned long m_bitCount;
34 unsigned long m_buffer;
35 unsigned int m_bitsBuffered, m_bytesBuffered;
44 typedef unsigned int code_t;
45 typedef unsigned int value_t;
58 void Initialize(
const unsigned int *codeBits,
unsigned int nCodes);
60 static void GenerateCodeLengths(
unsigned int *codeBits,
unsigned int maxCodeBits,
const unsigned int *codeCounts,
size_t nCodes);
81 MIN_DEFLATE_LEVEL = 0,
83 DEFAULT_DEFLATE_LEVEL = 6,
85 MAX_DEFLATE_LEVEL = 9};
90 MIN_LOG2_WINDOW_SIZE = 9,
92 DEFAULT_LOG2_WINDOW_SIZE = 15,
94 MAX_LOG2_WINDOW_SIZE = 15};
104 Deflator(
BufferedTransformation *attachment=NULLPTR,
int deflateLevel=DEFAULT_DEFLATE_LEVEL,
int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE,
bool detectUncompressible=
true);
114 void SetDeflateLevel(
int deflateLevel);
125 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking);
126 bool IsolatedFlush(
bool hardFlush,
bool blocking);
129 virtual void WritePrestreamHeader() {}
130 virtual void ProcessUncompressedData(
const byte *
string,
size_t length)
131 {CRYPTOPP_UNUSED(
string), CRYPTOPP_UNUSED(length);}
132 virtual void WritePoststreamTail() {}
134 enum {STORED = 0, STATIC = 1, DYNAMIC = 2};
135 enum {MIN_MATCH = 3, MAX_MATCH = 258};
137 void InitializeStaticEncoders();
138 void Reset(
bool forceReset =
false);
139 unsigned int FillWindow(
const byte *str,
size_t length);
140 unsigned int ComputeHash(
const byte *str)
const;
141 unsigned int LongestMatch(
unsigned int &bestMatch)
const;
142 void InsertString(
unsigned int start);
143 void ProcessBuffer();
145 void LiteralByte(byte b);
146 void MatchFound(
unsigned int distance,
unsigned int length);
147 void EncodeBlock(
bool eof,
unsigned int blockType);
148 void EndBlock(
bool eof);
152 unsigned literalCode : 9;
153 unsigned literalExtra : 5;
154 unsigned distanceCode : 5;
155 unsigned distanceExtra : 13;
158 int m_deflateLevel, m_log2WindowSize, m_compressibleDeflateLevel;
159 unsigned int m_detectSkip, m_detectCount;
160 unsigned int DSIZE, DMASK, HSIZE, HMASK, GOOD_MATCH, MAX_LAZYLENGTH, MAX_CHAIN_LENGTH;
161 bool m_headerWritten, m_matchAvailable;
162 unsigned int m_dictionaryEnd, m_stringStart, m_lookahead, m_minLookahead, m_previousMatch, m_previousLength;
163 HuffmanEncoder m_staticLiteralEncoder, m_staticDistanceEncoder, m_dynamicLiteralEncoder, m_dynamicDistanceEncoder;
169 unsigned int m_matchBufferEnd, m_blockStart, m_blockLength;
Utility functions for the Crypto++ library.
Secure memory block with allocator and cleanup.
Abstract base classes that provide a uniform interface to this library.
DEFLATE compressor (RFC 1951)
HuffmanEncoder()
Construct a HuffmanEncoder.
int GetLog2WindowSize() const
Retrieves the window size.
Implementation of BufferedTransformation's attachment interface.
int GetDeflateLevel() const
Retrieves the deflation level.
void Initialize(const unsigned int *codeBits, unsigned int nCodes)
Initialize or reinitialize this object.
Implementation of BufferedTransformation's attachment interface.
Crypto++ library namespace.
Interface for retrieving values given their names.