sl@0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32\sfile\sf_deflate.h
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#ifndef __SF_DEFLATE_H__
|
sl@0
|
19 |
#define __SF_DEFLATE_H__
|
sl@0
|
20 |
#include "e32huffman.h"
|
sl@0
|
21 |
#include <e32base.h>
|
sl@0
|
22 |
#include <f32file.h>
|
sl@0
|
23 |
typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength);
|
sl@0
|
24 |
|
sl@0
|
25 |
#define __CONFIGURABLE_F32_LOADER_INFLATE_WINDOW_SIZE__ 0x8000
|
sl@0
|
26 |
|
sl@0
|
27 |
// deflation constants
|
sl@0
|
28 |
const TInt KDeflateLengthMag=8;
|
sl@0
|
29 |
const TInt KDeflateDistanceMag=12;
|
sl@0
|
30 |
//
|
sl@0
|
31 |
const TInt KDeflateMinLength=3;
|
sl@0
|
32 |
const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1<<KDeflateLengthMag);
|
sl@0
|
33 |
const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag);
|
sl@0
|
34 |
const TInt KDeflateDistCodeBase=0x200;
|
sl@0
|
35 |
// hashing
|
sl@0
|
36 |
const TUint KDeflateHashMultiplier=0xAC4B9B19u;
|
sl@0
|
37 |
const TInt KDeflateHashShift=24;
|
sl@0
|
38 |
// inflate
|
sl@0
|
39 |
const TInt KInflateWindowSize=__CONFIGURABLE_F32_LOADER_INFLATE_WINDOW_SIZE__ ;
|
sl@0
|
40 |
|
sl@0
|
41 |
class TEncoding
|
sl@0
|
42 |
{
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
enum {ELiterals=256,ELengths=(KDeflateLengthMag-1)*4,ESpecials=1,EDistances=(KDeflateDistanceMag-1)*4};
|
sl@0
|
45 |
enum {ELitLens=ELiterals+ELengths+ESpecials};
|
sl@0
|
46 |
enum {EEos=ELiterals+ELengths};
|
sl@0
|
47 |
public:
|
sl@0
|
48 |
TUint32 iLitLen[ELitLens];
|
sl@0
|
49 |
TUint32 iDistance[EDistances];
|
sl@0
|
50 |
};
|
sl@0
|
51 |
|
sl@0
|
52 |
const TInt KDeflationCodes=TEncoding::ELitLens+TEncoding::EDistances;
|
sl@0
|
53 |
|
sl@0
|
54 |
NONSHARABLE_CLASS(CInflater) : public CBase
|
sl@0
|
55 |
{
|
sl@0
|
56 |
public:
|
sl@0
|
57 |
enum {EBufSize = 0x800, ESafetyZone=8};
|
sl@0
|
58 |
public:
|
sl@0
|
59 |
static CInflater* NewLC(TBitInput& aInput);
|
sl@0
|
60 |
~CInflater();
|
sl@0
|
61 |
//
|
sl@0
|
62 |
TInt ReadL(TUint8* aBuffer,TInt aLength, TMemoryMoveFunction aMemMovefn);
|
sl@0
|
63 |
TInt SkipL(TInt aLength);
|
sl@0
|
64 |
private:
|
sl@0
|
65 |
CInflater(TBitInput& aInput);
|
sl@0
|
66 |
void ConstructL();
|
sl@0
|
67 |
void InitL();
|
sl@0
|
68 |
TInt InflateL();
|
sl@0
|
69 |
private:
|
sl@0
|
70 |
TBitInput* iBits;
|
sl@0
|
71 |
const TUint8* iRptr; // partial segment
|
sl@0
|
72 |
TInt iLen;
|
sl@0
|
73 |
const TUint8* iAvail; // available data
|
sl@0
|
74 |
const TUint8* iLimit;
|
sl@0
|
75 |
TEncoding* iEncoding;
|
sl@0
|
76 |
TUint8* iOut; // circular buffer for distance matches
|
sl@0
|
77 |
};
|
sl@0
|
78 |
|
sl@0
|
79 |
void DeflateL(const TUint8* aBuf, TInt aLength, TBitOutput& aOutput);
|
sl@0
|
80 |
|
sl@0
|
81 |
NONSHARABLE_CLASS(TFileInput) : public TBitInput
|
sl@0
|
82 |
{
|
sl@0
|
83 |
enum {KBufSize=KInflateWindowSize};
|
sl@0
|
84 |
public:
|
sl@0
|
85 |
TFileInput(RFile& aFile);
|
sl@0
|
86 |
void Cancel();
|
sl@0
|
87 |
private:
|
sl@0
|
88 |
void UnderflowL();
|
sl@0
|
89 |
private:
|
sl@0
|
90 |
RFile& iFile;
|
sl@0
|
91 |
TRequestStatus iStat;
|
sl@0
|
92 |
TUint8* iReadBuf;
|
sl@0
|
93 |
TPtr8 iPtr;
|
sl@0
|
94 |
TUint8 iBuf1[KBufSize];
|
sl@0
|
95 |
TUint8 iBuf2[KBufSize];
|
sl@0
|
96 |
};
|
sl@0
|
97 |
|
sl@0
|
98 |
#endif
|