epoc32/include/ezcompressor.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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 // Declaration for Compression class
    15 // 
    16 //
    17 
    18 #ifndef __EZCOMPRESSOR_H__
    19 #define __EZCOMPRESSOR_H__
    20 
    21 #include <e32base.h>
    22 #include <ezstream.h>
    23 #include <ezbufman.h>
    24 
    25 /**
    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.
    31 
    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.
    38 
    39 @publishedAll
    40 @released
    41 */
    42 class CEZCompressor : public CEZZStream
    43 	{
    44 public:
    45 	/** Compression strategy - used to tune the compression algorithm */
    46 	enum TStrategy
    47 		{
    48 		/** Use for normal data */		
    49 		EDefaultStrategy = Z_DEFAULT_STRATEGY, 
    50 		
    51 		/** Use for data produced by a filter (or predictor) */
    52 		EFiltered = Z_FILTERED, 
    53 		
    54 		/** Force Huffman encoding only (no string match) */
    55 		EHuffmanOnly = Z_HUFFMAN_ONLY
    56 		};
    57 
    58 	/** Compression levels */
    59 	enum 
    60 		{
    61 		EDefaultCompression = Z_DEFAULT_COMPRESSION,
    62 		ENoCompression = Z_NO_COMPRESSION,
    63 		EBestSpeed = Z_BEST_SPEED,
    64 		EBestCompression = Z_BEST_COMPRESSION
    65 		};
    66 
    67 	/** Window Bits - the base two logarithm of the window size (the size of the history buffer) */
    68 	enum
    69 		{
    70 		EMaxWBits = MAX_WBITS
    71 		};
    72 
    73 	/** Memory level - specifies how much memory should be allocated for the internal compression state */
    74 	enum
    75 		{
    76 		EDefMemLevel = MAX_MEM_LEVEL
    77 		};
    78 
    79 	/** Compression panic values */
    80 	enum
    81 		{
    82 		EDeflateInitlialiserError = EUnexpected + 1,
    83 		EDeflateTerminated
    84 		};
    85 
    86 	public:
    87 		~CEZCompressor();
    88 
    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);
    99 
   100 		IMPORT_C void ResetL(MEZBufferManager& aInit);
   101 
   102 		IMPORT_C TBool DeflateL();
   103 
   104 		IMPORT_C static void CompressL(TDes8 &aDestination, const TDesC8 &aSource, TInt aLevel = EDefaultCompression);
   105 
   106 	private:
   107 		enum TDeflationState
   108 			{
   109 			ENoFlush,
   110 			EFinish,
   111 			EFinalize,
   112 			ETerminated
   113 			};
   114 
   115 	private:
   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);
   119 
   120 	private:
   121 		MEZBufferManager* iBufferInit;
   122 		TDeflationState iDeflationState;
   123 	};
   124 
   125 #endif
   126 
   127