Update contrib.
1 // Copyright (c) 1995-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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfile\sf_pgcompr.h
18 #ifndef __SF_PGCOMPR_H__
19 #define __SF_PGCOMPR_H__
31 const TUint KBytePairPageSize = 4096;
33 // Buffer sized for at least 8 compressed pages - a noncompressible page is one byte larger
34 const TUint KReadNumberOfPages = 8;
35 const TUint KPagesBufferSize = (KBytePairPageSize + 1) * KReadNumberOfPages;
37 typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength);
39 struct IndexTableHeader
41 TInt iSizeOfData; // Includes the index and compressed pages
42 TInt iDecompressedSize;
43 TUint16 iNumberOfPages;
46 // sizeof(IndexTableHeader) returns the wrong value due to rounding/padding, so calculate it
47 const TUint KIndexTableHeaderSize = sizeof(TInt) + sizeof(TInt) + sizeof(TUint16);
49 NONSHARABLE_CLASS(CBytePairReader) : public CBase
52 static CBytePairReader* NewLC(TUint8* aBuffer, TUint32 aLength);
53 CBytePairReader(TUint8* aBuffer, TUint32 aLength);
55 virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn);
56 void GetPageOffsetsL(TInt32 aInitialOffset, TInt& aPageCount, TInt32*& aPageStarts);
57 TUint GetPageL(TUint aPageNum, TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn);
58 virtual void SeekForwardL(TUint aBytes);
61 virtual void ReadInTableL();
64 IndexTableHeader iHeader;
68 TUint8 iPageBuf[KBytePairPageSize];
71 NONSHARABLE_CLASS(CBytePairFileReader) : public CBytePairReader
74 static CBytePairFileReader* NewLC(RFile& aFile);
75 CBytePairFileReader(RFile& aFile);
76 ~CBytePairFileReader();
78 virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMovefn);
79 virtual void SeekForwardL(TUint aBytes);
82 virtual void ReadInTableL();
85 TUint8 iBuffer[KPagesBufferSize];
88 #endif // __SF_PGCOMPR_H__