imgtools/imglib/e32image/deflate/deflate.h
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * e32tools\petran\Szip\deflate.h
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __DECODE_H__
       
    21 #define __DECODE_H__
       
    22 
       
    23 #include "huffman.h"
       
    24 #include <e32base.h>
       
    25 
       
    26 // deflation constants
       
    27 const TInt KDeflateLengthMag=8;
       
    28 const TInt KDeflateDistanceMag=12;
       
    29 //
       
    30 const TInt KDeflateMinLength=3;
       
    31 const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1<<KDeflateLengthMag);
       
    32 const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag);
       
    33 const TInt KDeflateDistCodeBase=0x200;
       
    34 // hashing
       
    35 const TUint KDeflateHashMultiplier=0xAC4B9B19u;
       
    36 const TInt KDeflateHashShift=24;
       
    37 
       
    38 class TEncoding
       
    39 	{
       
    40 public:
       
    41 	enum {ELiterals=256,ELengths=(KDeflateLengthMag-1)*4,ESpecials=1,EDistances=(KDeflateDistanceMag-1)*4};
       
    42 	enum {ELitLens=ELiterals+ELengths+ESpecials};
       
    43 	enum {EEos=ELiterals+ELengths};
       
    44 public:
       
    45 	TUint32 iLitLen[ELitLens];
       
    46 	TUint32 iDistance[EDistances];
       
    47 	};
       
    48 
       
    49 const TInt KDeflationCodes=TEncoding::ELitLens+TEncoding::EDistances;
       
    50 
       
    51 class CInflater
       
    52 	{
       
    53 public:
       
    54 	enum {EBufSize = 0x800, ESafetyZone=8};
       
    55 public:
       
    56 	static CInflater* NewLC(TBitInput& aInput);
       
    57 	~CInflater();
       
    58 //
       
    59 	TInt ReadL(TUint8* aBuffer,TInt aLength);
       
    60 	TInt SkipL(TInt aLength);
       
    61 private:
       
    62 	CInflater(TBitInput& aInput);
       
    63 	void ConstructL();
       
    64 	void InitL();
       
    65 	TInt InflateL();
       
    66 private:
       
    67 	TBitInput* iBits;
       
    68 	const TUint8* iRptr;			// partial segment
       
    69 	TInt iLen;
       
    70 	const TUint8* iAvail;			// available data
       
    71 	const TUint8* iLimit;
       
    72 	TEncoding* iEncoding;
       
    73 	TUint8* iOut;					// circular buffer for distance matches
       
    74 	TUint8 iHuff[EBufSize+ESafetyZone];			// huffman data
       
    75 	};
       
    76 
       
    77 void DeflateL(const TUint8* aBuf, TInt aLength, TBitOutput& aOutput);
       
    78 
       
    79 #endif
       
    80