|
1 /* |
|
2 * Copyright (c) 2003, 2004 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 "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: TJ2kStreamReader class is to implement the |
|
15 * MJ2kPacketHeaderReader interface for reading the |
|
16 * packet header and packet body from the stream |
|
17 * buffer provided by ICL framework. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef __JP2KSTREAMREADER_H__ |
|
23 #define __JP2KSTREAMREADER_H__ |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include "JP2KMarker.h" |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // DATA TYPES |
|
34 |
|
35 // FUNCTION PROTOTYPES |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * TJ2kStreamReader class is to implement the |
|
43 * MJ2kPacketHeaderReader interface for reading the |
|
44 * packet header and packet body from the stream |
|
45 * buffer provided by ICL framework. |
|
46 * |
|
47 * JP2KCodec.dll |
|
48 * @since 2.6 |
|
49 */ |
|
50 class TJ2kStreamReader : public MJ2kPacketHeaderReader |
|
51 { |
|
52 public: // Constructors and destructor |
|
53 |
|
54 public: // New functions |
|
55 |
|
56 /** |
|
57 * Update the codestream length read and offset of SOT marker |
|
58 * @since 2.6 |
|
59 */ |
|
60 void UpdateMainHeader(); |
|
61 |
|
62 /** |
|
63 * Update the codestream length read and length of data consumed |
|
64 * @since 2.6 |
|
65 */ |
|
66 void UpdateTileHeader(); |
|
67 |
|
68 /** |
|
69 * From MJ2kPacketHeaderReader |
|
70 * Try to consume the EPH marker if there is one |
|
71 * @since 2.6 |
|
72 * @return TUint8: true if end of buffer. |
|
73 */ |
|
74 TUint8 ReadEPHMarker(); |
|
75 |
|
76 /** |
|
77 * From MJ2kPacketHeaderReader |
|
78 * Read a bit from the packet header stream |
|
79 * @since 2.6 |
|
80 * @param aBit: get a bit from the packet header bitstream. |
|
81 * @return TUint8: true if end of buffer. |
|
82 */ |
|
83 TUint8 ReadBit( TUint8& aBit ); |
|
84 |
|
85 /** |
|
86 * From MJ2kPacketHeaderReader |
|
87 * Read some bits from the packet header stream |
|
88 * @since 2.6 |
|
89 * @param aBit: get some bits from the packet header bitstream. |
|
90 * @param aBitLen: how many bits to read. |
|
91 * @return TUint8: true if end of buffer. |
|
92 */ |
|
93 TUint8 ReadBits( TUint8& aBit, TUint8 aBitLen ); |
|
94 |
|
95 /** |
|
96 * From MJ2kPacketHeaderReader |
|
97 * Read some bits from the packet header stream |
|
98 * @since 2.6 |
|
99 * @param aBit: get some bits from the packet header bitstream. |
|
100 * @param aBitLen: how many bits to read. |
|
101 * @return TUint8: true if end of buffer. |
|
102 */ |
|
103 TUint8 ReadBits( TUint32& aBit, TUint8 aBitLen ); |
|
104 |
|
105 /** |
|
106 * From MJ2kPacketHeaderReader |
|
107 * Start reading from packet header stream |
|
108 * @since 2.6 |
|
109 * @return TUint8: true if end of buffer. |
|
110 */ |
|
111 TUint8 StartReadBit(); |
|
112 |
|
113 /** |
|
114 * From MJ2kPacketHeaderReader |
|
115 * Align the stream to the next byte boundary if necessary |
|
116 * @since 2.6 |
|
117 */ |
|
118 void AlignReader(); |
|
119 |
|
120 /** |
|
121 * Try to consume the SOP marker if there is one |
|
122 * @since 2.6 |
|
123 * @return TUint8: true if end of buffer. |
|
124 */ |
|
125 TUint8 ReadSOPMarker(); |
|
126 |
|
127 /** |
|
128 * Try to consume the EPH marker after failure on previous try |
|
129 * @since 2.6 |
|
130 * @return TUint8: true if end of buffer. |
|
131 */ |
|
132 TUint8 TryReadEPHMarker(); |
|
133 |
|
134 /** |
|
135 * Try to align to byte boundary after failure on previous try |
|
136 * @since 2.6 |
|
137 * @return TUint8: true if end of buffer. |
|
138 */ |
|
139 TUint8 TryReAlignReader(); |
|
140 |
|
141 public: // Functions from base classes |
|
142 |
|
143 protected: // New functions |
|
144 |
|
145 protected: // Functions from base classes |
|
146 |
|
147 private: |
|
148 |
|
149 public: // Data |
|
150 |
|
151 // Iterator pointed to current position in the buffer |
|
152 const TUint8 *iPtr; |
|
153 |
|
154 // Iterator pointed to the start of buffer |
|
155 TUint8 *iPtrStart; |
|
156 |
|
157 // Iterator pointed to the end of buffer |
|
158 TUint8 *iPtrEnd; |
|
159 |
|
160 // Iterator pointed to the start of marker |
|
161 TUint8 *iPtrStartMarker; |
|
162 |
|
163 // Data consumed during decoding |
|
164 TUint32 iDataUsed; |
|
165 |
|
166 // Length of codestream left to be read |
|
167 TUint32 iCSLength; |
|
168 |
|
169 // Offset position of first SOT |
|
170 TUint32 iStartSOT; |
|
171 |
|
172 // Offset position of next tile to be processed |
|
173 TUint32 iNewDataStart; |
|
174 |
|
175 // Length of data to skip |
|
176 TUint32 iSkipLength; |
|
177 |
|
178 // Current data in 8 bits |
|
179 TUint8 iData; |
|
180 |
|
181 // Current bit position |
|
182 TUint8 iPos; |
|
183 |
|
184 // Bit position of next byte |
|
185 TUint8 iNextPos; |
|
186 |
|
187 // To indicate byte alignment is required |
|
188 TUint8 iAlign; |
|
189 |
|
190 // To indicate EPH marker should be tried |
|
191 TUint8 iTryEPHMarker; |
|
192 |
|
193 protected: // Data |
|
194 |
|
195 private: // Data |
|
196 |
|
197 public: // Friend classes |
|
198 |
|
199 protected: // Friend classes |
|
200 |
|
201 private: // Friend classes |
|
202 |
|
203 }; |
|
204 |
|
205 #endif // __JP2KSTREAMREADER_H__ |
|
206 |