1 ezcompressor.h |
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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // EZLib: COMPRESSOR.H |
|
15 // Declaration for Compression class |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __EZCOMPRESSOR_H__ |
|
20 #define __EZCOMPRESSOR_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <ezstream.h> |
|
24 #include <ezbufman.h> |
|
25 |
|
26 /** |
|
27 The CEZCompressor class provides in-memory compression functions, including integrity checks of the uncompressed data. |
|
28 This version of the library supports only one compression method (deflation). Compression can be done in a single step |
|
29 (using CompressL()) if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls |
|
30 of the DeflateL() function. The source data is compressed to the target buffer (both source and target contained within |
|
31 the buffer manager argument), and various other arguments distinguish the different compression settings. |
|
32 |
|
33 @publishedAll |
|
34 @released |
|
35 */ |
|
36 class CEZCompressor : public CEZZStream |
|
37 { |
|
38 public: |
|
39 /** Compression strategy - used to tune the compression algorithm */ |
|
40 enum TStrategy |
|
41 { |
|
42 /** Use for normal data */ |
|
43 EDefaultStrategy = Z_DEFAULT_STRATEGY, |
|
44 |
|
45 /** Force Huffman encoding only (no string match) */ |
|
46 EFiltered = Z_FILTERED, |
|
47 |
|
48 /** Use for data produced by a filter (or predictor) */ |
|
49 EHuffmanOnly = Z_HUFFMAN_ONLY |
|
50 }; |
|
51 |
|
52 /** Compression levels */ |
|
53 enum |
|
54 { |
|
55 EDefaultCompression = Z_DEFAULT_COMPRESSION, |
|
56 ENoCompression = Z_NO_COMPRESSION, |
|
57 EBestSpeed = Z_BEST_SPEED, |
|
58 EBestCompression = Z_BEST_COMPRESSION |
|
59 }; |
|
60 |
|
61 /** Window Bits - the base two logarithm of the window size (the size of the history buffer) */ |
|
62 enum |
|
63 { |
|
64 EMaxWBits = MAX_WBITS |
|
65 }; |
|
66 |
|
67 /** Memory level - specifies how much memory should be allocated for the internal compression state */ |
|
68 enum |
|
69 { |
|
70 EDefMemLevel = MAX_MEM_LEVEL |
|
71 }; |
|
72 |
|
73 /** Compression panic values */ |
|
74 enum |
|
75 { |
|
76 EDeflateInitlialiserError = EUnexpected + 1, |
|
77 EDeflateTerminated |
|
78 }; |
|
79 |
|
80 public: |
|
81 ~CEZCompressor(); |
|
82 |
|
83 IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression, |
|
84 TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy); |
|
85 IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression, |
|
86 TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy); |
|
87 IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, const TDesC8 &aDictionary, |
|
88 TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, |
|
89 TStrategy aStrategy = EDefaultStrategy); |
|
90 IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, const TDesC8 &aDictionary, |
|
91 TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, |
|
92 TStrategy aStrategy = EDefaultStrategy); |
|
93 |
|
94 IMPORT_C void ResetL(MEZBufferManager& aInit); |
|
95 |
|
96 IMPORT_C TBool DeflateL(); |
|
97 |
|
98 IMPORT_C static void CompressL(TDes8 &aDestination, const TDesC8 &aSource, TInt aLevel = EDefaultCompression); |
|
99 |
|
100 private: |
|
101 enum TDeflationState |
|
102 { |
|
103 ENoFlush, |
|
104 EFinish, |
|
105 EFinalize, |
|
106 ETerminated |
|
107 }; |
|
108 |
|
109 private: |
|
110 CEZCompressor(MEZBufferManager* aInit); |
|
111 void ConstructL(TInt aLevel, const TUint8* aDictionary, TInt aLength, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy); |
|
112 void ConstructL(TInt aLevel, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy); |
|
113 |
|
114 private: |
|
115 MEZBufferManager* iBufferInit; |
|
116 TDeflationState iDeflationState; |
|
117 }; |
|
118 |
|
119 #endif |