|
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". |
|
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 __EZLIB_EZCOMPRESSOR_H__ |
|
20 #define __EZLIB_EZCOMPRESSOR_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "OldEZstream.h" |
|
24 #include "OldEZBufman.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 namespace TOLDEZLIB |
|
37 { |
|
38 |
|
39 class CEZCompressor : public CEZZStream |
|
40 { |
|
41 public: |
|
42 /** Compression strategy - used to tune the compression algorithm */ |
|
43 enum TStrategy |
|
44 { |
|
45 /** Use for normal data */ |
|
46 EDefaultStrategy = Z_DEFAULT_STRATEGY, |
|
47 |
|
48 /** Force Huffman encoding only (no string match) */ |
|
49 EFiltered = Z_FILTERED, |
|
50 |
|
51 /** Use for data produced by a filter (or predictor) */ |
|
52 EHuffmanOnly = Z_HUFFMAN_ONLY |
|
53 }; |
|
54 |
|
55 /** Compression levels */ |
|
56 enum |
|
57 { |
|
58 EDefaultCompression = Z_DEFAULT_COMPRESSION, |
|
59 ENoCompression = Z_NO_COMPRESSION, |
|
60 EBestSpeed = Z_BEST_SPEED, |
|
61 EBestCompression = Z_BEST_COMPRESSION |
|
62 }; |
|
63 |
|
64 /** Window Bits - the base two logarithm of the window size (the size of the history buffer) */ |
|
65 enum |
|
66 { |
|
67 EMaxWBits = MAX_WBITS |
|
68 }; |
|
69 |
|
70 /** Memory level - specifies how much memory should be allocated for the internal compression state */ |
|
71 enum |
|
72 { |
|
73 EDefMemLevel = MAX_MEM_LEVEL |
|
74 }; |
|
75 |
|
76 /** Compression panic values */ |
|
77 enum |
|
78 { |
|
79 EDeflateInitlialiserError = EUnexpected + 1, |
|
80 EDeflateTerminated |
|
81 }; |
|
82 |
|
83 public: |
|
84 ~CEZCompressor(); |
|
85 |
|
86 IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression, |
|
87 TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy); |
|
88 IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression, |
|
89 TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy); |
|
90 IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, const TDesC8 &aDictionary, |
|
91 TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, |
|
92 TStrategy aStrategy = EDefaultStrategy); |
|
93 IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, const TDesC8 &aDictionary, |
|
94 TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, |
|
95 TStrategy aStrategy = EDefaultStrategy); |
|
96 |
|
97 IMPORT_C void ResetL(MEZBufferManager& aInit); |
|
98 |
|
99 IMPORT_C TBool DeflateL(); |
|
100 |
|
101 IMPORT_C static void CompressL(TDes8 &aDestination, const TDesC8 &aSource, TInt aLevel = EDefaultCompression); |
|
102 |
|
103 private: |
|
104 enum TDeflationState |
|
105 { |
|
106 ENoFlush, |
|
107 EFinish, |
|
108 EFinalize, |
|
109 ETerminated |
|
110 }; |
|
111 |
|
112 private: |
|
113 CEZCompressor(MEZBufferManager* aInit); |
|
114 void ConstructL(TInt aLevel, const TUint8* aDictionary, TInt aLength, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy); |
|
115 void ConstructL(TInt aLevel, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy); |
|
116 |
|
117 private: |
|
118 MEZBufferManager* iBufferInit; |
|
119 TDeflationState iDeflationState; |
|
120 }; |
|
121 } //namespace TOLDEZLIB |
|
122 #endif |
|
123 |
|
124 |