|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // f32\sfile\sf_pgcompr.h |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __SF_PGCOMPR_H__ |
|
19 #define __SF_PGCOMPR_H__ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include<f32file.h> |
|
23 //#include "sf_std.h" |
|
24 #include <f32image.h> |
|
25 #include "sf_image.h" |
|
26 #include <e32uid.h> |
|
27 #include <e32rom.h> |
|
28 #include "sf_cache.h" |
|
29 |
|
30 |
|
31 const TUint KBytePairPageSize = 4096; |
|
32 |
|
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; |
|
36 |
|
37 typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength); |
|
38 |
|
39 struct IndexTableHeader |
|
40 { |
|
41 TInt iSizeOfData; // Includes the index and compressed pages |
|
42 TInt iDecompressedSize; |
|
43 TUint16 iNumberOfPages; |
|
44 }; |
|
45 |
|
46 // sizeof(IndexTableHeader) returns the wrong value due to rounding/padding, so calculate it |
|
47 const TUint KIndexTableHeaderSize = sizeof(TInt) + sizeof(TInt) + sizeof(TUint16); |
|
48 |
|
49 NONSHARABLE_CLASS(CBytePairReader) : public CBase |
|
50 { |
|
51 public: |
|
52 static CBytePairReader* NewLC(TUint8* aBuffer, TUint32 aLength); |
|
53 CBytePairReader(TUint8* aBuffer, TUint32 aLength); |
|
54 |
|
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); |
|
59 |
|
60 protected: |
|
61 virtual void ReadInTableL(); |
|
62 void ReleaseTable(); |
|
63 |
|
64 IndexTableHeader iHeader; |
|
65 TUint16* iIndexTable; |
|
66 TUint8* iNextPage; |
|
67 TUint iBytesLeft; |
|
68 TUint8 iPageBuf[KBytePairPageSize]; |
|
69 }; |
|
70 |
|
71 NONSHARABLE_CLASS(CBytePairFileReader) : public CBytePairReader |
|
72 { |
|
73 public: |
|
74 static CBytePairFileReader* NewLC(RFile& aFile); |
|
75 CBytePairFileReader(RFile& aFile); |
|
76 ~CBytePairFileReader(); |
|
77 |
|
78 virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMovefn); |
|
79 virtual void SeekForwardL(TUint aBytes); |
|
80 |
|
81 protected: |
|
82 virtual void ReadInTableL(); |
|
83 |
|
84 RFile& iFile; |
|
85 TUint8 iBuffer[KPagesBufferSize]; |
|
86 }; |
|
87 |
|
88 #endif // __SF_PGCOMPR_H__ |