sl@0
|
1 |
// Copyright (c) 1995-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_pgcompr.h
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#ifndef __SF_PGCOMPR_H__
|
sl@0
|
19 |
#define __SF_PGCOMPR_H__
|
sl@0
|
20 |
|
sl@0
|
21 |
#include <e32base.h>
|
sl@0
|
22 |
#include<f32file.h>
|
sl@0
|
23 |
//#include "sf_std.h"
|
sl@0
|
24 |
#include <f32image.h>
|
sl@0
|
25 |
#include "sf_image.h"
|
sl@0
|
26 |
#include <e32uid.h>
|
sl@0
|
27 |
#include <e32rom.h>
|
sl@0
|
28 |
#include "sf_cache.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
const TUint KBytePairPageSize = 4096;
|
sl@0
|
32 |
|
sl@0
|
33 |
// Buffer sized for at least 8 compressed pages - a noncompressible page is one byte larger
|
sl@0
|
34 |
const TUint KReadNumberOfPages = 8;
|
sl@0
|
35 |
const TUint KPagesBufferSize = (KBytePairPageSize + 1) * KReadNumberOfPages;
|
sl@0
|
36 |
|
sl@0
|
37 |
typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength);
|
sl@0
|
38 |
|
sl@0
|
39 |
struct IndexTableHeader
|
sl@0
|
40 |
{
|
sl@0
|
41 |
TInt iSizeOfData; // Includes the index and compressed pages
|
sl@0
|
42 |
TInt iDecompressedSize;
|
sl@0
|
43 |
TUint16 iNumberOfPages;
|
sl@0
|
44 |
};
|
sl@0
|
45 |
|
sl@0
|
46 |
// sizeof(IndexTableHeader) returns the wrong value due to rounding/padding, so calculate it
|
sl@0
|
47 |
const TUint KIndexTableHeaderSize = sizeof(TInt) + sizeof(TInt) + sizeof(TUint16);
|
sl@0
|
48 |
|
sl@0
|
49 |
NONSHARABLE_CLASS(CBytePairReader) : public CBase
|
sl@0
|
50 |
{
|
sl@0
|
51 |
public:
|
sl@0
|
52 |
static CBytePairReader* NewLC(TUint8* aBuffer, TUint32 aLength);
|
sl@0
|
53 |
CBytePairReader(TUint8* aBuffer, TUint32 aLength);
|
sl@0
|
54 |
|
sl@0
|
55 |
virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn);
|
sl@0
|
56 |
void GetPageOffsetsL(TInt32 aInitialOffset, TInt& aPageCount, TInt32*& aPageStarts);
|
sl@0
|
57 |
TUint GetPageL(TUint aPageNum, TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn);
|
sl@0
|
58 |
virtual void SeekForwardL(TUint aBytes);
|
sl@0
|
59 |
|
sl@0
|
60 |
protected:
|
sl@0
|
61 |
virtual void ReadInTableL();
|
sl@0
|
62 |
void ReleaseTable();
|
sl@0
|
63 |
|
sl@0
|
64 |
IndexTableHeader iHeader;
|
sl@0
|
65 |
TUint16* iIndexTable;
|
sl@0
|
66 |
TUint8* iNextPage;
|
sl@0
|
67 |
TUint iBytesLeft;
|
sl@0
|
68 |
TUint8 iPageBuf[KBytePairPageSize];
|
sl@0
|
69 |
};
|
sl@0
|
70 |
|
sl@0
|
71 |
NONSHARABLE_CLASS(CBytePairFileReader) : public CBytePairReader
|
sl@0
|
72 |
{
|
sl@0
|
73 |
public:
|
sl@0
|
74 |
static CBytePairFileReader* NewLC(RFile& aFile);
|
sl@0
|
75 |
CBytePairFileReader(RFile& aFile);
|
sl@0
|
76 |
~CBytePairFileReader();
|
sl@0
|
77 |
|
sl@0
|
78 |
virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMovefn);
|
sl@0
|
79 |
virtual void SeekForwardL(TUint aBytes);
|
sl@0
|
80 |
|
sl@0
|
81 |
protected:
|
sl@0
|
82 |
virtual void ReadInTableL();
|
sl@0
|
83 |
|
sl@0
|
84 |
RFile& iFile;
|
sl@0
|
85 |
TUint8 iBuffer[KPagesBufferSize];
|
sl@0
|
86 |
};
|
sl@0
|
87 |
|
sl@0
|
88 |
#endif // __SF_PGCOMPR_H__
|