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