|
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: CJ2kTileInfo class used to collect tile related |
|
15 * information such as Tile Part Header, SOT marker and |
|
16 * list of components. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __JP2KTILEINFO_H__ |
|
22 #define __JP2KTILEINFO_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32std.h> |
|
26 #include <e32base.h> |
|
27 #include "JP2KMarker.h" |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // DATA TYPES |
|
34 struct TPOCMarker; |
|
35 |
|
36 // FUNCTION PROTOTYPES |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class CJ2kImageInfo; |
|
40 class TJ2kStreamReader; |
|
41 class CJ2kComponentInfo; |
|
42 |
|
43 // CLASS DECLARATION |
|
44 |
|
45 /** |
|
46 * CJ2kTileInfo class used to collect tile related |
|
47 * information such as Tile Part Header, SOT marker, |
|
48 * List of components, and etc. It's also implement the |
|
49 * MJ2kPacketHeaderReader interface for reading the |
|
50 * packet header from PPT marker. It contains the data |
|
51 * to control where to resume the parsing of the bitstream. |
|
52 * |
|
53 * JP2KCodec.dll |
|
54 * @since 2.6 |
|
55 */ |
|
56 class CJ2kTileInfo : public CBase, public MJ2kPacketHeaderReader |
|
57 { |
|
58 public: // Constructors and destructor |
|
59 |
|
60 /** |
|
61 * Two-phased constructor. |
|
62 */ |
|
63 static CJ2kTileInfo* NewLC( CJ2kImageInfo& aImageInfo, TJ2kStreamReader& aReader ); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 virtual ~CJ2kTileInfo(); |
|
69 |
|
70 public: // New functions |
|
71 |
|
72 /** |
|
73 * Initialize the components in the tile |
|
74 * @since 2.6 |
|
75 */ |
|
76 void InitializeL(); |
|
77 |
|
78 /** |
|
79 * Verify and append COD to the tile part header |
|
80 * @since 2.6 |
|
81 * @param aMarker: pointer to TCODMarker. |
|
82 * @param aLength: the marker length. |
|
83 */ |
|
84 void AppendCOD( TCODMarker *aMarker, TUint32 aLength ); |
|
85 |
|
86 /** |
|
87 * Verify and append COC to the tile part header |
|
88 * @since 2.6 |
|
89 * @param aMarker: pointer to TCOCMarker. |
|
90 * @param aLength: the marker length. |
|
91 */ |
|
92 void AppendCOCL( TCOCMarker *aMarker, TUint32 aLength ); |
|
93 |
|
94 /** |
|
95 * Verify and append QCD to the tile part header |
|
96 * @since 2.6 |
|
97 * @param aMarker: pointer to TQCDMarker. |
|
98 * @param aLength: the marker length. |
|
99 */ |
|
100 void AppendQCD( TQCDMarker *aMarker, TUint32 aLength ); |
|
101 |
|
102 /** |
|
103 * Verify and append QCC to the tile part header |
|
104 * @since 2.6 |
|
105 * @param aMarker: pointer to TQCCMarker. |
|
106 * @param aLength: the marker length. |
|
107 */ |
|
108 void AppendQCCL( TQCCMarker *aMarker, TUint32 aLength ); |
|
109 |
|
110 /** |
|
111 * Verify and append RGN to the tile part header |
|
112 * @since 2.6 |
|
113 * @param aMarker: pointer to TRGNMarker. |
|
114 * @param aLength: the marker length. |
|
115 */ |
|
116 void AppendRGNL( TRGNMarker *aMarker, TUint32 aLength ); |
|
117 |
|
118 /** |
|
119 * Verify and append POC to the tile part header |
|
120 * @since 2.6 |
|
121 * @param aMarker: pointer to TPOCMarker. |
|
122 * @param aLength: the marker length. |
|
123 */ |
|
124 void AppendPOCL( TPOCMarker *aMarker, TUint32 aLength ); |
|
125 |
|
126 /** |
|
127 * Verify and append COM to the tile part header |
|
128 * @since 2.6 |
|
129 * @param aMarker: pointer to TCOMMarker. |
|
130 * @param aLength: the marker length. |
|
131 */ |
|
132 void AppendCOML( TCOMMarker *aMarker, TUint32 aLength ); |
|
133 |
|
134 /** |
|
135 * Verify and append PPT to the tile part header |
|
136 * @since 2.6 |
|
137 * @param aMarker: pointer to TPPTMarker. |
|
138 * @param aLength: the marker length. |
|
139 */ |
|
140 void AppendPPTL( TPPTMarker *aMarker, TUint32 aLength ); |
|
141 |
|
142 /** |
|
143 * Verify and append PLT to the tile part header |
|
144 * @since 2.6 |
|
145 * @param aMarker: pointer to TPLTMarker. |
|
146 * @param aLength: the marker length. |
|
147 */ |
|
148 void AppendPLTL( TPLTMarker *aMarker, TUint32 aLength ); |
|
149 |
|
150 /** |
|
151 * Parsing the bitstream data based on progression order |
|
152 * @since 2.6 |
|
153 * @param aBool: to check next SOT/EOC marker if true. |
|
154 */ |
|
155 void ReadBitStreamL( TUint8 aBool = EFalse ); |
|
156 |
|
157 /** |
|
158 * Get the color transformation |
|
159 * @since 2.6 |
|
160 * @return TUint8: color transformation from tile COD or main COD. |
|
161 */ |
|
162 TUint8 ColorTransformation() const; |
|
163 |
|
164 /** |
|
165 * Get the progression order |
|
166 * @since 2.6 |
|
167 * @return TUint8: progression order from tile COD or main COD. |
|
168 */ |
|
169 TUint8 ProgressionOrder() const; |
|
170 |
|
171 /** |
|
172 * Get the number of layers |
|
173 * @since 2.6 |
|
174 * @return TUint16: number of layers from tile COD or main COD. |
|
175 */ |
|
176 TUint16 NumOfLayers() const; |
|
177 |
|
178 /** |
|
179 * Get the number of resolution level |
|
180 * @since 2.6 |
|
181 * @return TUint8: max number of resolution level from each component. |
|
182 */ |
|
183 TUint8 NumOfLevels() const; |
|
184 |
|
185 /** |
|
186 * Get the minimum grid among the components in the tile |
|
187 * @since 2.6 |
|
188 * @param aGrid: get the minimum grid size. |
|
189 */ |
|
190 void GetMinGrid( TSize &aGrid ) const; |
|
191 |
|
192 /** |
|
193 * Set up to read the packet header from the PPT marker |
|
194 * @since 2.6 |
|
195 */ |
|
196 void UsePPTL(); |
|
197 |
|
198 /** |
|
199 * From MJ2kPacketHeaderReader |
|
200 * Try to consume the EPH marker if there is one |
|
201 * @since 2.6 |
|
202 * @return TUint8: true if end of buffer. |
|
203 */ |
|
204 TUint8 ReadEPHMarker(); |
|
205 |
|
206 /** |
|
207 * From MJ2kPacketHeaderReader |
|
208 * Read a bit from the packet header stream |
|
209 * @since 2.6 |
|
210 * @param aBit: get a bit from the packet header bitstream. |
|
211 * @return TUint8: true if end of buffer. |
|
212 */ |
|
213 TUint8 ReadBit( TUint8& aBit ); |
|
214 |
|
215 /** |
|
216 * From MJ2kPacketHeaderReader |
|
217 * Read some bits from the packet header stream |
|
218 * @since 2.6 |
|
219 * @param aBit: get some bits from the packet header bitstream. |
|
220 * @param aBitLen: how many bits to read. |
|
221 * @return TUint8: true if end of buffer. |
|
222 */ |
|
223 TUint8 ReadBits( TUint8& aBit, TUint8 aBitLen ); |
|
224 |
|
225 /** |
|
226 * From MJ2kPacketHeaderReader |
|
227 * Read some bits from the packet header stream |
|
228 * @since 2.6 |
|
229 * @param aBit: get some bits from the packet header bitstream. |
|
230 * @param aBitLen: how many bits to read. |
|
231 * @return TUint8: true if end of buffer. |
|
232 */ |
|
233 TUint8 ReadBits( TUint32& aBit, TUint8 aBitLen ); |
|
234 |
|
235 /** |
|
236 * From MJ2kPacketHeaderReader |
|
237 * Start reading from packet header stream |
|
238 * @since 2.6 |
|
239 * @return TUint8: true if end of buffer. |
|
240 */ |
|
241 TUint8 StartReadBit(); |
|
242 |
|
243 /** |
|
244 * From MJ2kPacketHeaderReader |
|
245 * Align the stream to the next byte boundary if necessary |
|
246 * @since 2.6 |
|
247 */ |
|
248 void AlignReader(); |
|
249 |
|
250 /** |
|
251 * Release unused markers in tile part header |
|
252 * @since 2.6 |
|
253 */ |
|
254 void DoReleaseUnusedMarkers(); |
|
255 |
|
256 /** |
|
257 * Set the tile length |
|
258 * @since 2.6 |
|
259 * @param aLength: the tile length to set. |
|
260 */ |
|
261 void SetTileLength( TUint32 aLength ); |
|
262 |
|
263 /** |
|
264 * Get the tile length |
|
265 * @since 2.6 |
|
266 * @return TUint32&: reference to the tile length. |
|
267 */ |
|
268 TUint32& TileLength(); |
|
269 |
|
270 /** |
|
271 * Get the tile canvas |
|
272 * @since 2.6 |
|
273 * @return TRect&: reference to the canvas of the tile. |
|
274 */ |
|
275 const TRect& TileCanvas() const; |
|
276 |
|
277 /** |
|
278 * Get the number of components |
|
279 * @since 2.6 |
|
280 * @return TUint16: the number of components. |
|
281 */ |
|
282 TUint16 NumOfComponents() const; |
|
283 |
|
284 /** |
|
285 * Get the end of layer to process |
|
286 * @since 2.6 |
|
287 * @return TUint16: the last layer to process. |
|
288 */ |
|
289 TUint16 NumOfLayersPOC() const; |
|
290 |
|
291 /** |
|
292 * Get the end of level to process |
|
293 * @since 2.6 |
|
294 * @return TUint8: the last level to process. |
|
295 */ |
|
296 TUint8 NumOfLevelsPOC() const; |
|
297 |
|
298 /** |
|
299 * Get the component at specific location |
|
300 * @since 2.6 |
|
301 * @param aIndex: component index. |
|
302 * @return CJ2kComponentInfo&: a specific component. |
|
303 */ |
|
304 const CJ2kComponentInfo& ComponentAt( TUint16 aIndex ) const; |
|
305 |
|
306 /** |
|
307 * Get the last layer processed |
|
308 * @since 2.6 |
|
309 * @return TUint16: the last layer processed. |
|
310 */ |
|
311 TUint16 LastLayerProcessed() const; |
|
312 |
|
313 /** |
|
314 * Get the last resolution level processed |
|
315 * @since 2.6 |
|
316 * @return TUint8: the last resolution level processed. |
|
317 */ |
|
318 TUint8 LastLevelProcessed() const; |
|
319 |
|
320 /** |
|
321 * Get the last component processed |
|
322 * @since 2.6 |
|
323 * @return TUint16: the last component processed. |
|
324 */ |
|
325 TUint16 LastComponentProcessed() const; |
|
326 |
|
327 /** |
|
328 * Get the last position processed in vertical direction |
|
329 * @since 2.6 |
|
330 * @return TInt: the last vertical position processed. |
|
331 */ |
|
332 TInt LastN1Processed() const; |
|
333 |
|
334 /** |
|
335 * Get the last position processed in horizontal direction |
|
336 * @since 2.6 |
|
337 * @return TInt: the last horizontal position processed. |
|
338 */ |
|
339 TInt LastN2Processed() const; |
|
340 |
|
341 /** |
|
342 * Increment the last layer processed |
|
343 * @since 2.6 |
|
344 */ |
|
345 void IncrementLastLayerProcessed(); |
|
346 |
|
347 /** |
|
348 * Reset the last layer processed to 0 |
|
349 * @since 2.6 |
|
350 */ |
|
351 void ResetLastLayerProcessed(); |
|
352 |
|
353 /** |
|
354 * |
|
355 * @since 2.6Get the reference to the image info |
|
356 * @return CJ2kImageInfo&: a reference to CJ2kImageInfo object. |
|
357 */ |
|
358 const CJ2kImageInfo& ImageInfo() const; |
|
359 |
|
360 /** |
|
361 * Get the reference to the stream reader |
|
362 * @since 2.6 |
|
363 * @return TJ2kStreamReader&: a reference to TJ2kStreamReader object. |
|
364 */ |
|
365 const TJ2kStreamReader& StreamReader() const; |
|
366 |
|
367 /** |
|
368 * Set the SOT marker |
|
369 * @since 2.6 |
|
370 * @param aSotMarker: the TSotMarker to set. |
|
371 */ |
|
372 void SetSotMarker( const TSotMarker &aSotMarker ); |
|
373 |
|
374 /** |
|
375 * Get the SOT marker |
|
376 * @since 2.6 |
|
377 * @return TSotMarker&: a reference to TSotMarker object. |
|
378 */ |
|
379 const TSotMarker& SotMarker() const; |
|
380 |
|
381 /** |
|
382 * Get the Tile Part Header |
|
383 * @since 2.6 |
|
384 * @return TTileMarker&: a reference to TTileMarker object. |
|
385 */ |
|
386 const TTileMarker& TileMarker() const; |
|
387 |
|
388 /** |
|
389 * Set the SOT/EOC check indicator |
|
390 * @since 2.6 |
|
391 * @param aCheckMarker: true if SOT/EOC need to be checked. |
|
392 */ |
|
393 void SetCheckMarker( TUint8 aCheckMarker ); |
|
394 |
|
395 /** |
|
396 * Get the packet header reader |
|
397 * @since 2.6 |
|
398 * @return MJ2kPacketHeaderReader&: a reference to MJ2kPacketHeaderReader object. |
|
399 */ |
|
400 MJ2kPacketHeaderReader& PacketHeaderReader(); |
|
401 |
|
402 /** |
|
403 * Set the packet header reader |
|
404 * @since 2.6 |
|
405 * @param aReader: set the packet header reader to aReader. |
|
406 */ |
|
407 void SetPacketHeaderReader( MJ2kPacketHeaderReader* aReader ); |
|
408 |
|
409 /** |
|
410 * Is this the first tile part |
|
411 * @since 2.6 |
|
412 * @return TUint8: true if this is the first tile part. |
|
413 */ |
|
414 TUint8 IsFirstTilePart() const; |
|
415 |
|
416 /** |
|
417 * Is packet header should be read from PPT marker |
|
418 * @since 2.6 |
|
419 * @return TUint8: true if tile contains PPT. |
|
420 */ |
|
421 TUint8 IsPPT() const; |
|
422 |
|
423 /** |
|
424 * Is POC marker should be used for progression order |
|
425 * @since 2.6 |
|
426 * @return TUint8: true if tile contains POC. |
|
427 */ |
|
428 TUint8 IsPOC() const; |
|
429 |
|
430 /** |
|
431 * Is this the last tile part |
|
432 * @since 2.6 |
|
433 * @return TUint8: true if this is the last tile part. |
|
434 */ |
|
435 TUint8 IsLastTilePart() const; |
|
436 |
|
437 /** |
|
438 * Is SOT/EOC marker should be checked during progression |
|
439 * @since 2.6 |
|
440 * @return TUint8: true if SOT/EOC should be checked. |
|
441 */ |
|
442 TUint8 IsCheckMarker() const; |
|
443 |
|
444 /** |
|
445 * Is RLCP/RPCL progression order used |
|
446 * @since 2.6 |
|
447 * @return TUint8: true if RLCP/RPCL progression order used. |
|
448 */ |
|
449 TUint8 IsSpeedup() const; |
|
450 |
|
451 public: // Functions from base classes |
|
452 |
|
453 protected: // New functions |
|
454 |
|
455 protected: // Functions from base classes |
|
456 |
|
457 private: |
|
458 |
|
459 /** |
|
460 * C++ default constructor. |
|
461 */ |
|
462 CJ2kTileInfo( CJ2kImageInfo& aImageInfo, TJ2kStreamReader& aReader ); |
|
463 |
|
464 /** |
|
465 * Parse the bitstream with LRCP progression order |
|
466 * @since 2.6 |
|
467 * @return TUint8: true if next SOT or EOC marker is found. |
|
468 */ |
|
469 TUint8 LRCPProgressionL(); |
|
470 |
|
471 /** |
|
472 * Parse the bitstream with RLCP progression order |
|
473 * @since 2.6 |
|
474 * @return TUint8: true if next SOT or EOC marker is found. |
|
475 */ |
|
476 TUint8 RLCPProgressionL(); |
|
477 |
|
478 /** |
|
479 * Parse the bitstream with RPCL progression order |
|
480 * @since 2.6 |
|
481 * @return TUint8: true if next SOT or EOC marker is found. |
|
482 */ |
|
483 TUint8 RPCLProgressionL(); |
|
484 |
|
485 /** |
|
486 * Parse the bitstream with PCRL progression order |
|
487 * @since 2.6 |
|
488 * @return TUint8: true if next SOT or EOC marker is found. |
|
489 */ |
|
490 TUint8 PCRLProgressionL(); |
|
491 |
|
492 /** |
|
493 * Parse the bitstream with CPRL progression order |
|
494 * @since 2.6 |
|
495 * @return TUint8: true if next SOT or EOC marker is found. |
|
496 */ |
|
497 TUint8 CPRLProgressionL(); |
|
498 |
|
499 public: // Data |
|
500 |
|
501 protected: // Data |
|
502 |
|
503 // Progression order |
|
504 enum TProgression |
|
505 { |
|
506 EProgression_L_R_C_P = 0, |
|
507 EProgression_R_L_C_P = 1, |
|
508 EProgression_R_P_C_L = 2, |
|
509 EProgression_P_C_R_L = 3, |
|
510 EProgression_C_P_R_L = 4 |
|
511 }; |
|
512 |
|
513 // Structure to hold the information on reading packet header |
|
514 struct TPPTStream |
|
515 { |
|
516 TUint32 iPtr; // Current byte position in buffer |
|
517 TUint32 iPtrEnd; // End of byte position in buffer |
|
518 TUint8 iData; // Current data in 8 bits |
|
519 TUint8 iPos; // Current bit position |
|
520 TUint8 iNextPos; // Bit position of next byte |
|
521 }; |
|
522 |
|
523 private: // Data |
|
524 |
|
525 // SOT marker |
|
526 TSotMarker iSot; |
|
527 |
|
528 // Tile Part Header |
|
529 TTileMarker iTileMarker; |
|
530 |
|
531 // List of components |
|
532 RPointerArray<CJ2kComponentInfo> iComponentList; |
|
533 |
|
534 // Canvas of the tile |
|
535 TRect iTileCanvas; |
|
536 |
|
537 // Remaining tile length |
|
538 TUint32 iTileLength; |
|
539 |
|
540 // Last layer processed |
|
541 TUint16 iLastLayer; |
|
542 |
|
543 // Last component processed |
|
544 TUint16 iLastComponent; |
|
545 |
|
546 // Original starting component |
|
547 TUint16 iLastComponentOrig; |
|
548 |
|
549 // End of layer to process |
|
550 TUint16 iNumOfLayersPOC; |
|
551 |
|
552 // End of component to process |
|
553 TUint16 iNumOfComponentsPOC; |
|
554 |
|
555 // Last resolution level processed |
|
556 TUint8 iLastLevel; |
|
557 |
|
558 // Original starting resolution level |
|
559 TUint8 iLastLevelOrig; |
|
560 |
|
561 // End of resolution level to process |
|
562 TUint8 iNumOfLevelsPOC; |
|
563 |
|
564 // Last POC processed |
|
565 TUint8 iLastPOC; |
|
566 |
|
567 // To indicate not to load from iPOC |
|
568 TUint8 iDoLoadPOC; |
|
569 |
|
570 // To indicate whether to check SOT/EOC marker |
|
571 TUint8 iCheckMarker; |
|
572 |
|
573 // Pointer to the POC in Tile Part Header or Main Header |
|
574 TPOCMarker *iPOC; |
|
575 |
|
576 // Last position processed in vertical direction |
|
577 TInt iLastN1; |
|
578 |
|
579 // Last position processed in horizontal direction |
|
580 TInt iLastN2; |
|
581 |
|
582 // Reference to the image info |
|
583 CJ2kImageInfo &iImageInfo; |
|
584 |
|
585 // Reference to the stream reader (buffer provided by ICL framework) |
|
586 TJ2kStreamReader &iReader; |
|
587 |
|
588 // Control the reading of packet header |
|
589 TPPTStream *iPpt; |
|
590 |
|
591 // Pointed to PPT in Tile Part Header |
|
592 HBufC8 *iPptBuffer; |
|
593 |
|
594 // Packet header reader |
|
595 MJ2kPacketHeaderReader *iPacketHeaderReader; |
|
596 |
|
597 public: // Friend classes |
|
598 |
|
599 protected: // Friend classes |
|
600 |
|
601 private: // Friend classes |
|
602 |
|
603 }; |
|
604 |
|
605 // For inliners. |
|
606 #include "JP2KTileInfo.inl" |
|
607 |
|
608 #endif // __JP2KTILEINFO_H__ |