|
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: CJ2kImageInfo class used to collect image related |
|
15 * information such as Main Header, SIZ marker and |
|
16 * list of tiles. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __JP2KIMAGEINFO_H__ |
|
22 #define __JP2KIMAGEINFO_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include "JP2KMarker.h" |
|
26 #include "JP2KUtils.h" |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // MACROS |
|
31 |
|
32 // DATA TYPES |
|
33 |
|
34 // FUNCTION PROTOTYPES |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CJ2kTileInfo; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 /** |
|
41 * CJ2kImageInfo class used to collect image related |
|
42 * information such as Main Header, SIZ marker, |
|
43 * List of tiles, and etc. It's also implement the |
|
44 * MJ2kPacketHeaderReader interface for reading the |
|
45 * packet header from PPM marker. |
|
46 * |
|
47 * JP2KCodec.dll |
|
48 * @since 2.6 |
|
49 */ |
|
50 class CJ2kImageInfo : public CBase, public MJ2kPacketHeaderReader |
|
51 { |
|
52 public: // Constructors and destructor |
|
53 |
|
54 /** |
|
55 * C++ default constructor. |
|
56 */ |
|
57 CJ2kImageInfo(); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 virtual ~CJ2kImageInfo(); |
|
63 |
|
64 public: // New functions |
|
65 |
|
66 /** |
|
67 * Verify and append COC to the main header |
|
68 * @since 2.6 |
|
69 * @param aMarker: pointer to TCOCMarker. |
|
70 */ |
|
71 void AppendCOCL( TCOCMarker *aMarker ); |
|
72 |
|
73 /** |
|
74 * Verify and append QCC to the main header |
|
75 * @since 2.6 |
|
76 * @param aMarker: pointer to TQCCMarker. |
|
77 */ |
|
78 void AppendQCCL( TQCCMarker *aMarker ); |
|
79 |
|
80 /** |
|
81 * Verify and append RGN to the main header |
|
82 * @since 2.6 |
|
83 * @param aMarker: pointer to TRGNMarker. |
|
84 */ |
|
85 void AppendRGNL( TRGNMarker *aMarker ); |
|
86 |
|
87 /** |
|
88 * Verify and append POC to the main header |
|
89 * @since 2.6 |
|
90 * @param aMarker: pointer to TPOCMarker. |
|
91 */ |
|
92 void AppendPOCL( TPOCMarker *aMarker ); |
|
93 |
|
94 /** |
|
95 * Verify and append CRG to the main header |
|
96 * @since 2.6 |
|
97 * @param aMarker: pointer to TCRGMarker. |
|
98 */ |
|
99 void AppendCRGL( TCRGMarker *aMarker ); |
|
100 |
|
101 /** |
|
102 * Verify and append COM to the main header |
|
103 * @since 2.6 |
|
104 * @param aMarker: pointer to TCOMMarker. |
|
105 */ |
|
106 void AppendCOML( const TCOMMarker *aMarker ); |
|
107 |
|
108 /** |
|
109 * Retrieve the right Coding Style Marker |
|
110 * @since 2.6 |
|
111 * @param aCod: a reference to TCODMarker pointer. |
|
112 * @param aCoc: a reference to TCOCMarker pointer. |
|
113 * @param aTile: a reference to CJ2kTileInfo object. |
|
114 * @param aComponentIndex: the index of component. |
|
115 */ |
|
116 void GetCodingStyle( TCODMarker*& aCod, TCOCMarker*& aCoc, |
|
117 const CJ2kTileInfo& aTile, TUint16 aComponentIndex ); |
|
118 |
|
119 /** |
|
120 * Retrieve the right Quantization Marker |
|
121 * @since 2.6 |
|
122 * @param aQcd: a reference to TQCDMarker pointer. |
|
123 * @param aQcc: a reference to TQCCMarker pointer. |
|
124 * @param aTile: a reference to CJ2kTileInfo object. |
|
125 * @param aComponentIndex: the index of component. |
|
126 */ |
|
127 void GetQuantization( TQCDMarker*& aQcd, TQCCMarker*& aQcc, |
|
128 const CJ2kTileInfo& aTile, TUint16 aComponentIndex ); |
|
129 |
|
130 /** |
|
131 * Retrieve the right Region of Interest Marker |
|
132 * @since 2.6 |
|
133 * @param aRgn: a reference to TRGNMarker pointer. |
|
134 * @param aTile: a reference to CJ2kTileInfo object. |
|
135 * @param aComponentIndex: the index of component. |
|
136 */ |
|
137 void GetRegion( TRGNMarker*& aRgn, const CJ2kTileInfo& aTile, TUint16 aComponentIndex ) const; |
|
138 |
|
139 /** |
|
140 * Retrieve the tile length field from TLM marker |
|
141 * @since 2.6 |
|
142 * @param aSotMarker: a reference to TSotMarker. |
|
143 */ |
|
144 void GetFromTLM( TSotMarker& aSotMarker ) const; |
|
145 |
|
146 /** |
|
147 * Set up to read the packet header from the PPM marker |
|
148 * @since 2.6 |
|
149 * @param aTile: a reference to CJ2kTileInfo object. |
|
150 */ |
|
151 void UsePPM( CJ2kTileInfo& aTile ); |
|
152 |
|
153 /** |
|
154 * Re-arrange the PPM and PLM buffers |
|
155 * @since 2.6 |
|
156 */ |
|
157 void DoCompactMainHeaderL(); |
|
158 |
|
159 /** |
|
160 * Get total number of tiles in horizontal position |
|
161 * @since 2.6 |
|
162 * @return TUint16: number of tiles in horizontal position. |
|
163 */ |
|
164 TUint16 NumOfHorizTiles() const; |
|
165 |
|
166 /** |
|
167 * Get total number of tiles in vertical position |
|
168 * @since 2.6 |
|
169 * @return TUint16: number of tiles in vertical position. |
|
170 */ |
|
171 TUint16 NumOfVertTiles() const; |
|
172 |
|
173 /** |
|
174 * Get total number of components |
|
175 * @since 2.6 |
|
176 * @return TUint16: number of components. |
|
177 */ |
|
178 TUint16 NumOfComponents() const; |
|
179 |
|
180 /** |
|
181 * Get the bit depth of a component |
|
182 * @since 2.6 |
|
183 * @param aIndex: the component index. |
|
184 * @return TUint8: bit depth of a component. |
|
185 */ |
|
186 TUint8 DepthOfComponent( TUint16 aIndex ) const; |
|
187 |
|
188 /** |
|
189 * Get the sign bit of a component |
|
190 * @since 2.6 |
|
191 * @param aIndex: the component index. |
|
192 * @return TUint8: sign bit of a component. |
|
193 */ |
|
194 TUint8 SignOfComponent( TUint16 aIndex ) const; |
|
195 |
|
196 /** |
|
197 * Get the SIZ marker |
|
198 * @since 2.6 |
|
199 * @return TSizMarker&: a reference to TSizMarker object. |
|
200 */ |
|
201 const TSizMarker& SizMarker() const; |
|
202 |
|
203 /** |
|
204 * Get the Main Header marker |
|
205 * @since 2.6 |
|
206 * @return TMainMarker&: a reference to TMainMarker object. |
|
207 */ |
|
208 const TMainMarker& MainMarker() const; |
|
209 |
|
210 /** |
|
211 * Get the maximum block size |
|
212 * @since 2.6 |
|
213 * @return TSize&: a reference to the maximum size. |
|
214 */ |
|
215 const TSize& MaxBlockSize() const; |
|
216 |
|
217 /** |
|
218 * Get the cropped area |
|
219 * @since 2.6 |
|
220 * @return TRect&: a reference to the cropped area. |
|
221 */ |
|
222 const TRect& CropArea() const; |
|
223 |
|
224 /** |
|
225 * Get the total number of tiles in the tile list |
|
226 * @since 2.6 |
|
227 * @return TUint16: number of tiles in the tile list. |
|
228 */ |
|
229 TUint16 TileCount() const; |
|
230 |
|
231 /** |
|
232 * Get the tile at specific location |
|
233 * @since 2.6 |
|
234 * @param aIndex: the location. |
|
235 * @return CJ2kTileInfo&: a reference to CJ2kTileInfo object. |
|
236 */ |
|
237 const CJ2kTileInfo& TileAt( TUint16 aIndex ) const; |
|
238 |
|
239 /** |
|
240 * Append tile into the tile list |
|
241 * @since 2.6 |
|
242 * @param aTile: the pointer to CJ2kTileInfo object. |
|
243 */ |
|
244 void Append( CJ2kTileInfo *aTile ); |
|
245 |
|
246 /** |
|
247 * Remove a tile at specific location |
|
248 * @since 2.6 |
|
249 * @param aIndex: the location. |
|
250 */ |
|
251 void Remove( TUint16 aIndex ); |
|
252 |
|
253 /** |
|
254 * Get the mask of a tile at specific location |
|
255 * @since 2.6 |
|
256 * @param aIndex: the location. |
|
257 * @return TUint8: the mask of the tile. |
|
258 */ |
|
259 TUint8 TileMaskAt( TUint16 aIndex ) const; |
|
260 |
|
261 /** |
|
262 * Set the mask of a tile at specific location |
|
263 * @since 2.6 |
|
264 * @param aIndex: the location. |
|
265 * @param aTileMask: the mask. |
|
266 */ |
|
267 void SetTileMask( TUint16 aIndex, TUint8 aTileMask ); |
|
268 |
|
269 /** |
|
270 * Set the resolution level to drop |
|
271 * @since 2.6 |
|
272 * @param aDrop: the resolution level to drop. |
|
273 */ |
|
274 void SetLevelDrop( TUint8 aDrop ); |
|
275 |
|
276 /** |
|
277 * Set the extra resolution level to drop |
|
278 * @since 2.6 |
|
279 * @param aDrop: the extra levels to drop. |
|
280 */ |
|
281 void SetExtraLevelDrop( TUint8 aDrop ); |
|
282 |
|
283 /** |
|
284 * Get the component to drop |
|
285 * @since 2.6 |
|
286 * @return TUint8: the component to drop. |
|
287 */ |
|
288 TUint8 ComponentDrop() const; |
|
289 |
|
290 /** |
|
291 * Get the resolution level to drop |
|
292 * @since 2.6 |
|
293 * @return TUint8: the resolution level to drop. |
|
294 */ |
|
295 TUint8 LevelDrop() const; |
|
296 |
|
297 /** |
|
298 * Get the extra resolution level to drop |
|
299 * @since 2.6 |
|
300 * @return TUint8: the extra resolution level to drop. |
|
301 */ |
|
302 TUint8 ExtraLevelDrop() const; |
|
303 |
|
304 /** |
|
305 * Get the crop |
|
306 * @since 2.6 |
|
307 * @return TUint8: the crop flag. |
|
308 */ |
|
309 TUint8 Crop() const; |
|
310 |
|
311 /** |
|
312 * Set the last tile part processed |
|
313 * @since 2.6 |
|
314 * @param aLastTilePart: the last tile part processed. |
|
315 */ |
|
316 void SetLastTilePartProcessed( TUint16 aLastTilePart ); |
|
317 |
|
318 /** |
|
319 * Increment the counter for tracking the last tile part processed |
|
320 * @since 2.6 |
|
321 */ |
|
322 void IncrementLastTilePartProcessed(); |
|
323 |
|
324 /** |
|
325 * Is packet header should be read from PPM marker |
|
326 * @since 2.6 |
|
327 * @return TUint8: true if PPM marker exists. |
|
328 */ |
|
329 TUint8 IsPPM() const; |
|
330 |
|
331 /** |
|
332 * Reset packet header pointer to the end of the PPM marker |
|
333 * @since 2.6 |
|
334 */ |
|
335 void ResetPPM(); |
|
336 |
|
337 public: // Functions from base classes |
|
338 |
|
339 /** |
|
340 * From MJ2kPacketHeaderReader |
|
341 * Try to consume the EPH marker if there is one |
|
342 * @since 2.6 |
|
343 * @return TUint8: true if end of buffer. |
|
344 */ |
|
345 TUint8 ReadEPHMarker(); |
|
346 |
|
347 /** |
|
348 * From MJ2kPacketHeaderReader |
|
349 * Read a bit from the packet header stream |
|
350 * @since 2.6 |
|
351 * @param aBit: get a bit from the packet header bitstream. |
|
352 * @return TUint8: true if end of buffer. |
|
353 */ |
|
354 TUint8 ReadBit( TUint8& aBit ); |
|
355 |
|
356 /** |
|
357 * From MJ2kPacketHeaderReader |
|
358 * Read some bits from the packet header stream |
|
359 * @since 2.6 |
|
360 * @param aBit: get some bits from the packet header bitstream. |
|
361 * @param aBitLen: how many bits to read. |
|
362 * @return TUint8: true if end of buffer. |
|
363 */ |
|
364 TUint8 ReadBits( TUint8& aBit, TUint8 aBitLen ); |
|
365 |
|
366 /** |
|
367 * From MJ2kPacketHeaderReader |
|
368 * Read some bits from the packet header stream |
|
369 * @since 2.6 |
|
370 * @param aBit: get some bits from the packet header bitstream. |
|
371 * @param aBitLen: how many bits to read. |
|
372 * @return TUint8: true if end of buffer. |
|
373 */ |
|
374 TUint8 ReadBits( TUint32& aBit, TUint8 aBitLen ); |
|
375 |
|
376 /** |
|
377 * From MJ2kPacketHeaderReader |
|
378 * Start reading from packet header stream |
|
379 * @since 2.6 |
|
380 * @return TUint8: true if end of buffer. |
|
381 */ |
|
382 TUint8 StartReadBit(); |
|
383 |
|
384 /** |
|
385 * From MJ2kPacketHeaderReader |
|
386 * Align the stream to the next byte boundary if necessary |
|
387 * @since 2.6 |
|
388 */ |
|
389 void AlignReader(); |
|
390 |
|
391 protected: // New functions |
|
392 |
|
393 protected: // Functions from base classes |
|
394 |
|
395 private: |
|
396 |
|
397 public: // Data |
|
398 |
|
399 protected: // Data |
|
400 |
|
401 // Structure to hold the information on reading packet header |
|
402 struct TPPMStream |
|
403 { |
|
404 TUint32 iPtr; // Current byte position in buffer |
|
405 TUint32 iPtrEnd; // End of byte position in buffer |
|
406 TUint8 iData; // Current data in 8 bits |
|
407 TUint8 iPos; // Current bit position |
|
408 TUint8 iNextPos; // Bit position of next byte |
|
409 }; |
|
410 |
|
411 private: // Data |
|
412 |
|
413 // SIZ marker |
|
414 TSizMarker iSizMarker; |
|
415 |
|
416 // Main Header |
|
417 TMainMarker iMainMarker; |
|
418 |
|
419 // Current tile in progress |
|
420 CJ2kTileInfo *iTile; |
|
421 |
|
422 // Current tile mask |
|
423 TUint8 iTileMask; |
|
424 |
|
425 // Max block size |
|
426 TSize iMaxBlockSize; |
|
427 |
|
428 // Cropped area |
|
429 TRect iCropArea; |
|
430 |
|
431 // Component to drop |
|
432 TUint8 iComponentDrop; |
|
433 |
|
434 // Resolution level to drop |
|
435 TUint8 iLevelDrop; |
|
436 |
|
437 // Resolution drop |
|
438 TUint8 iExtraLevelDrop; |
|
439 |
|
440 // Is cropped |
|
441 TUint8 iCrop; |
|
442 |
|
443 // Last tile part processed |
|
444 TInt16 iLastTilePartProcessed; |
|
445 |
|
446 // Control the reading of packet header |
|
447 TPPMStream *iPpm; |
|
448 |
|
449 // Pointer to PPM in Main Header |
|
450 HBufC8 *iPpmBuffer; |
|
451 |
|
452 public: // Friend classes |
|
453 |
|
454 protected: // Friend classes |
|
455 |
|
456 private: // Friend classes |
|
457 }; |
|
458 |
|
459 // For inliners. |
|
460 #include "JP2KImageInfo.inl" |
|
461 |
|
462 #endif // __JP2KIMAGEINFO_H__ |
|
463 |