epoc32/include/ezcompressor.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/ezcompressor.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/ezcompressor.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,119 @@
     1.4 -ezcompressor.h
     1.5 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +// EZLib: COMPRESSOR.H
    1.19 +// Declaration for Compression class
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +#ifndef __EZCOMPRESSOR_H__
    1.24 +#define __EZCOMPRESSOR_H__
    1.25 +
    1.26 +#include <e32base.h>
    1.27 +#include <ezstream.h>
    1.28 +#include <ezbufman.h>
    1.29 +
    1.30 +/**
    1.31 +The CEZCompressor class provides in-memory compression functions, including integrity checks of the uncompressed data.
    1.32 +This version of the library supports only one compression method (deflation).  Compression can be done in a single step
    1.33 +(using CompressL()) if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls
    1.34 +of the DeflateL() function.  The source data is compressed to the target buffer (both source and target contained within 
    1.35 +the buffer manager argument), and various other arguments distinguish the different compression settings.
    1.36 +
    1.37 +@publishedAll
    1.38 +@released
    1.39 +*/
    1.40 +class CEZCompressor : public CEZZStream
    1.41 +	{
    1.42 +public:
    1.43 +	/** Compression strategy - used to tune the compression algorithm */
    1.44 +	enum TStrategy
    1.45 +		{
    1.46 +		/** Use for normal data */		
    1.47 +		EDefaultStrategy = Z_DEFAULT_STRATEGY, 
    1.48 +		
    1.49 +		/** Force Huffman encoding only (no string match) */
    1.50 +		EFiltered = Z_FILTERED, 
    1.51 +		
    1.52 +		/** Use for data produced by a filter (or predictor) */
    1.53 +		EHuffmanOnly = Z_HUFFMAN_ONLY
    1.54 +		};
    1.55 +
    1.56 +	/** Compression levels */
    1.57 +	enum 
    1.58 +		{
    1.59 +		EDefaultCompression = Z_DEFAULT_COMPRESSION,
    1.60 +		ENoCompression = Z_NO_COMPRESSION,
    1.61 +		EBestSpeed = Z_BEST_SPEED,
    1.62 +		EBestCompression = Z_BEST_COMPRESSION
    1.63 +		};
    1.64 +
    1.65 +	/** Window Bits - the base two logarithm of the window size (the size of the history buffer) */
    1.66 +	enum
    1.67 +		{
    1.68 +		EMaxWBits = MAX_WBITS
    1.69 +		};
    1.70 +
    1.71 +	/** Memory level - specifies how much memory should be allocated for the internal compression state */
    1.72 +	enum
    1.73 +		{
    1.74 +		EDefMemLevel = MAX_MEM_LEVEL
    1.75 +		};
    1.76 +
    1.77 +	/** Compression panic values */
    1.78 +	enum
    1.79 +		{
    1.80 +		EDeflateInitlialiserError = EUnexpected + 1,
    1.81 +		EDeflateTerminated
    1.82 +		};
    1.83 +
    1.84 +	public:
    1.85 +		~CEZCompressor();
    1.86 +
    1.87 +		IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression,
    1.88 +			TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy);
    1.89 +		IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression,
    1.90 +			TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy);
    1.91 +		IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, const TDesC8 &aDictionary, 
    1.92 +			TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, 
    1.93 +			TStrategy aStrategy = EDefaultStrategy);
    1.94 +		IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, const TDesC8 &aDictionary,  
    1.95 +			TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, 
    1.96 +			TStrategy aStrategy = EDefaultStrategy);
    1.97 +
    1.98 +		IMPORT_C void ResetL(MEZBufferManager& aInit);
    1.99 +
   1.100 +		IMPORT_C TBool DeflateL();
   1.101 +
   1.102 +		IMPORT_C static void CompressL(TDes8 &aDestination, const TDesC8 &aSource, TInt aLevel = EDefaultCompression);
   1.103 +
   1.104 +	private:
   1.105 +		enum TDeflationState
   1.106 +			{
   1.107 +			ENoFlush,
   1.108 +			EFinish,
   1.109 +			EFinalize,
   1.110 +			ETerminated
   1.111 +			};
   1.112 +
   1.113 +	private:
   1.114 +		CEZCompressor(MEZBufferManager* aInit);
   1.115 +		void ConstructL(TInt aLevel, const TUint8* aDictionary, TInt aLength, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy);
   1.116 +		void ConstructL(TInt aLevel, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy);
   1.117 +
   1.118 +	private:
   1.119 +		MEZBufferManager* iBufferInit;
   1.120 +		TDeflationState iDeflationState;
   1.121 +	};
   1.122 +
   1.123 +#endif