1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Declaration for Compression class
18 #ifndef __EZCOMPRESSOR_H__
19 #define __EZCOMPRESSOR_H__
26 The CEZCompressor class provides in-memory compression functions, including integrity checks of the uncompressed data.
27 This version of the library supports only one compression method (deflation). Compression can be done in a single step
28 (using CompressL()) if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls
29 of the DeflateL() function. The source data is compressed to the target buffer (both source and target contained within
30 the buffer manager argument), and various other arguments distinguish the different compression settings.
32 Note: In this version of the library a windowBits value of 8 is unsupported due to a problem with the window size being
33 set to 256 bytes. Although a value of 8 will be accepted by the CEZCompressor constructors, as it is being changed
34 internally by Zlib from 8 to 9, it will not be possible to use the same value for decompression. This is because the
35 Zlib functions called by the CEZDecompressor constructors do not make the same change internally and as a result a
36 KEZlibErrData is returned when calling InflateL(). It is therefore advised that for this version of the library
37 windowBits of 9 is used in place of 8.
42 class CEZCompressor : public CEZZStream
45 /** Compression strategy - used to tune the compression algorithm */
48 /** Use for normal data */
49 EDefaultStrategy = Z_DEFAULT_STRATEGY,
51 /** Use for data produced by a filter (or predictor) */
52 EFiltered = Z_FILTERED,
54 /** Force Huffman encoding only (no string match) */
55 EHuffmanOnly = Z_HUFFMAN_ONLY
58 /** Compression levels */
61 EDefaultCompression = Z_DEFAULT_COMPRESSION,
62 ENoCompression = Z_NO_COMPRESSION,
63 EBestSpeed = Z_BEST_SPEED,
64 EBestCompression = Z_BEST_COMPRESSION
67 /** Window Bits - the base two logarithm of the window size (the size of the history buffer) */
73 /** Memory level - specifies how much memory should be allocated for the internal compression state */
76 EDefMemLevel = MAX_MEM_LEVEL
79 /** Compression panic values */
82 EDeflateInitlialiserError = EUnexpected + 1,
89 IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression,
90 TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy);
91 IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression,
92 TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy);
93 IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, const TDesC8 &aDictionary,
94 TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel,
95 TStrategy aStrategy = EDefaultStrategy);
96 IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, const TDesC8 &aDictionary,
97 TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel,
98 TStrategy aStrategy = EDefaultStrategy);
100 IMPORT_C void ResetL(MEZBufferManager& aInit);
102 IMPORT_C TBool DeflateL();
104 IMPORT_C static void CompressL(TDes8 &aDestination, const TDesC8 &aSource, TInt aLevel = EDefaultCompression);
116 CEZCompressor(MEZBufferManager* aInit);
117 void ConstructL(TInt aLevel, const TUint8* aDictionary, TInt aLength, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy);
118 void ConstructL(TInt aLevel, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy);
121 MEZBufferManager* iBufferInit;
122 TDeflationState iDeflationState;