e32tools/e32lib/e32image/deflate/deflate.h
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 // Copyright (c) 1998-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 // e32tools\petran\Szip\deflate.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __DECODE_H__
       
    19 #define __DECODE_H__
       
    20 
       
    21 #include "huffman.h"
       
    22 #include <e32base.h>
       
    23 
       
    24 // deflation constants
       
    25 const TInt KDeflateLengthMag=8;
       
    26 const TInt KDeflateDistanceMag=12;
       
    27 //
       
    28 const TInt KDeflateMinLength=3;
       
    29 const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1<<KDeflateLengthMag);
       
    30 const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag);
       
    31 const TInt KDeflateDistCodeBase=0x200;
       
    32 // hashing
       
    33 const TUint KDeflateHashMultiplier=0xAC4B9B19u;
       
    34 const TInt KDeflateHashShift=24;
       
    35 
       
    36 class TEncoding
       
    37 	{
       
    38 public:
       
    39 	enum {ELiterals=256,ELengths=(KDeflateLengthMag-1)*4,ESpecials=1,EDistances=(KDeflateDistanceMag-1)*4};
       
    40 	enum {ELitLens=ELiterals+ELengths+ESpecials};
       
    41 	enum {EEos=ELiterals+ELengths};
       
    42 public:
       
    43 	TUint32 iLitLen[ELitLens];
       
    44 	TUint32 iDistance[EDistances];
       
    45 	};
       
    46 
       
    47 const TInt KDeflationCodes=TEncoding::ELitLens+TEncoding::EDistances;
       
    48 
       
    49 class CInflater
       
    50 	{
       
    51 public:
       
    52 	enum {EBufSize = 0x800, ESafetyZone=8};
       
    53 public:
       
    54 	static CInflater* NewLC(TBitInput& aInput);
       
    55 	~CInflater();
       
    56 //
       
    57 	TInt ReadL(TUint8* aBuffer,TInt aLength);
       
    58 	TInt SkipL(TInt aLength);
       
    59 private:
       
    60 	CInflater(TBitInput& aInput);
       
    61 	void ConstructL();
       
    62 	void InitL();
       
    63 	TInt InflateL();
       
    64 private:
       
    65 	TBitInput* iBits;
       
    66 	const TUint8* iRptr;			// partial segment
       
    67 	TInt iLen;
       
    68 	const TUint8* iAvail;			// available data
       
    69 	const TUint8* iLimit;
       
    70 	TEncoding* iEncoding;
       
    71 	TUint8* iOut;					// circular buffer for distance matches
       
    72 	TUint8 iHuff[EBufSize+ESafetyZone];			// huffman data
       
    73 	};
       
    74 
       
    75 void DeflateL(const TUint8* aBuf, TInt aLength, TBitOutput& aOutput);
       
    76 
       
    77 #endif
       
    78