imagingmodules/jp2kcodec/Inc/JP2KSubband.h
changeset 0 469c91dae73b
equal deleted inserted replaced
-1:000000000000 0:469c91dae73b
       
     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:  JP2KSubband class used to collect the subband related
       
    15 *                information such as list of packets and list of subbands.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __JP2KSUBBAND_H__
       
    21 #define __JP2KSUBBAND_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // MACROS
       
    29 
       
    30 // DATA TYPES
       
    31 
       
    32 // FUNCTION PROTOTYPES
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CJ2kPacket;
       
    36 class CJ2kTileInfo;
       
    37 class CJ2kComponentInfo;
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42 *  JP2KSubband class used to collect the subband related
       
    43 *  information such as list of packets, list of subbands
       
    44 *  if it is EBandLL, and etc. It contains the data to control
       
    45 *  where to resume the parsing of the bitstream. It is 
       
    46 *  implemented in Composite pattern.
       
    47 *
       
    48 *  JP2KCodec.dll
       
    49 *  @since 2.6
       
    50 */
       
    51 class CJ2kSubband : public CBase
       
    52     {
       
    53     public:  // Constructors and destructor
       
    54         
       
    55         /**
       
    56         * Destructor.
       
    57         */
       
    58         virtual ~CJ2kSubband();
       
    59 
       
    60     public: // New functions
       
    61         
       
    62         // Subband type        
       
    63         enum TSubbandType
       
    64             {
       
    65             EBandLL,  // LL subband, which may further subdivided into subband
       
    66             EBandHL,  // HL Subband
       
    67             EBandLH,  // LH Subband
       
    68             EBandHH   // HH Subband
       
    69             };
       
    70 
       
    71         /**
       
    72         * Static method to set up the tree structure of the DWT subbands
       
    73         * @since 2.6
       
    74         * @param aMaxLevel: maximum level of DWT subbands.
       
    75         * @param aComponent: a reference to CJ2kComponentInfo object.
       
    76         * @return CJ2kSubband*: pointer to root CJ2kSubband object.
       
    77         */
       
    78         static CJ2kSubband* BuildSubbandTreeL( TUint8 aMaxLevel, CJ2kComponentInfo& aComponent );
       
    79 
       
    80         /**
       
    81         * Build the possible packets that may be in the subband
       
    82         * @since 2.6
       
    83         * @param aComponent: a reference to CJ2kComponentInfo object.
       
    84         * @param aPrecinctSize: a pointer to descriptor of precinct size.
       
    85         * @param aLayer: the layer.
       
    86         */
       
    87         void BuildPacketsL( CJ2kComponentInfo& aComponent, HBufC8 *aPrecinctSiz, TUint16 aLayer );
       
    88 
       
    89         /**
       
    90         * At each subband, parse the bitstream with LRCP progression order
       
    91         * @since 2.6
       
    92         * @param aTile: a reference to CJ2kTileInfo object.
       
    93         * @param aComponent: a reference to CJ2kComponentInfo object.
       
    94         * @return TUint8: true if incomplete, false if completed.
       
    95         */
       
    96         TUint8 LRCPProgressionL( CJ2kTileInfo& aTile, CJ2kComponentInfo& aComponent );
       
    97 
       
    98         /**
       
    99         * At each subband, parse the bitstream with RPCL progression order
       
   100         * @since 2.6
       
   101         * @param aTile: a reference to CJ2kTileInfo object.
       
   102         * @param aComponent: a reference to CJ2kComponentInfo object.
       
   103         * @return TUint8: true if incomplete, false if completed.
       
   104         */
       
   105         TUint8 RPCLProgressionL( CJ2kTileInfo& aTile, CJ2kComponentInfo& aComponent );
       
   106 
       
   107         /**
       
   108         * At each subband, parse the bitstream with CPRL progression order
       
   109         * @since 2.6
       
   110         * @param aTile: a reference to CJ2kTileInfo object.
       
   111         * @param aComponent: a reference to CJ2kComponentInfo object.
       
   112         * @return TUint8: true if incomplete, false if completed.
       
   113         */
       
   114         TUint8 CPRLProgressionL( CJ2kTileInfo& aTile, CJ2kComponentInfo& aComponent );
       
   115 
       
   116         /**
       
   117         * Get the child subband at specific band
       
   118         * @since 2.6
       
   119         * @param aBand: the band index.
       
   120         * @return CJ2kSubband*: the child at specific band.
       
   121         */
       
   122         virtual CJ2kSubband* ChildAt( TInt aBand );
       
   123 
       
   124         /**
       
   125         * Get the sibling subband
       
   126         * @since 2.6
       
   127         * @return CJ2kSubband*: pointer to the sibling subband.
       
   128         */
       
   129         virtual CJ2kSubband* NextSubbandRaster();
       
   130 
       
   131         /**
       
   132         * Get the subband at specific resolution level
       
   133         * @since 2.6
       
   134         * @param aResLevel: the resolution level.
       
   135         * @return CJ2kSubband*: pointer to the subband at specific resolution level.
       
   136         */
       
   137         virtual CJ2kSubband* SubbandAt( TUint8 aResLevel );
       
   138 
       
   139         /**
       
   140         * Add the child subband into the list of child subbands
       
   141         * @since 2.6
       
   142         * @param aChild: add the child subband.
       
   143         */
       
   144         virtual void AddChildL( CJ2kSubband* aChild );
       
   145 
       
   146         /**
       
   147         * Get the subband tree index
       
   148         * @since 2.6
       
   149         * @return TUint16: the subband tree index.
       
   150         */
       
   151         TUint16 SubbandTreeIndex() const;
       
   152 
       
   153         /**
       
   154         * Get the parent subband of the current subband
       
   155         * @since 2.6
       
   156         * @return CJ2kSubband*: a pointer to the parent.
       
   157         */
       
   158         CJ2kSubband* Parent();
       
   159 
       
   160         /**
       
   161         * Set the parent subband of the current subband
       
   162         * @since 2.6
       
   163         * @param aParent: the parent of current subband.
       
   164         */
       
   165         void SetParent(CJ2kSubband* aParent);
       
   166  
       
   167         /**
       
   168         * Set the subband level
       
   169         * @since 2.6
       
   170         * @param aLevel: the level.
       
   171         */
       
   172         void SetSubbandLevel( TUint8 aLevel );
       
   173 
       
   174         /**
       
   175         * Get the subband type
       
   176         * @since 2.6
       
   177         * @return CJ2kSubband::TSubbandType: the subband's type.
       
   178         */
       
   179         CJ2kSubband::TSubbandType SubbandType() const;
       
   180 
       
   181         /**
       
   182         * Get the subband level
       
   183         * @since 2.6
       
   184         * @return TUint8: the subband's level.
       
   185         */
       
   186         TUint8 SubbandLevel() const;
       
   187 
       
   188         /**
       
   189         * Get the subband resolution level
       
   190         * @since 2.6
       
   191         * @return TUint8: the subband's resolution level.
       
   192         */
       
   193         TUint8 SubbandResLevel() const;
       
   194 
       
   195         /**
       
   196         * Get the subband gain
       
   197         * @since 2.6
       
   198         * @return TUint8: the subband gain.
       
   199         */
       
   200         TUint8 SubbandGain() const;
       
   201 
       
   202         /**
       
   203         * Get the subband high pass first
       
   204         * @since 2.6
       
   205         * @return TPoint&: a reference to the subband's high pass first.
       
   206         */
       
   207         const TPoint& HighPassFirst() const;
       
   208 
       
   209         /**
       
   210         * Get the subband origin
       
   211         * @since 2.6
       
   212         * @return TPoint&: a reference ot the subband's origin point.
       
   213         */
       
   214         const TPoint& SubbandOrigin() const;
       
   215 
       
   216         /**
       
   217         * Get the subband canvas
       
   218         * @since 2.6
       
   219         * @return TRect&: a reference to the subband's canvas.
       
   220         */
       
   221         const TRect& SubbandCanvas() const;
       
   222 
       
   223         /**
       
   224         * Get the subband canvas size
       
   225         * @since 2.6
       
   226         * @return TSize: the subband's canvas size.
       
   227         */
       
   228         TSize SubbandCanvasSize() const;
       
   229 
       
   230         /**
       
   231         * Get the list of packets
       
   232         * @since 2.6
       
   233         * @return RPointerArray<CJ2kPacket>&: a reference to the packet list.
       
   234         */
       
   235         const RPointerArray<CJ2kPacket>& PacketList() const;
       
   236 
       
   237         /**
       
   238         * Get the last packet processed
       
   239         * @since 2.6
       
   240         * @return TUint16: the last packet processed.
       
   241         */
       
   242         TUint16 LastPacketProcessed() const;
       
   243 
       
   244         /**
       
   245         * Reset the last packet processed to 0
       
   246         * @since 2.6
       
   247         */
       
   248         void ResetLastPacketProcessed();
       
   249 
       
   250         /**
       
   251         * Set the last subband processed
       
   252         * @since 2.6
       
   253         * @param aSubbandType: the subband type.
       
   254         */
       
   255         void SetLastSubbandProcessed( TUint8 aSubbandType );
       
   256 
       
   257         /**
       
   258         * Get the last subband processed
       
   259         * @since 2.6
       
   260         * @return TUint8: the last subband processed.
       
   261         */
       
   262         TUint8 LastSubbandProcessed() const;
       
   263 
       
   264         /**
       
   265         * Get the packet at specific location
       
   266         * @since 2.6
       
   267         * @param aIndex: the index.
       
   268         * @return CJ2kPacket&: a reference to the CJ2kPacket object.
       
   269         */
       
   270         const CJ2kPacket& PacketAt( TUint16 aIndex ) const;
       
   271 
       
   272     public: // Functions from base classes
       
   273         
       
   274     protected:  // New functions
       
   275         
       
   276         /**
       
   277         * C++ default constructor.
       
   278         */
       
   279         CJ2kSubband();
       
   280 
       
   281     protected:  // Functions from base classes
       
   282         
       
   283     private:
       
   284 
       
   285     public:     // Data
       
   286     
       
   287     protected:  // Data
       
   288             
       
   289         // Parent of the Subband
       
   290         CJ2kSubband *iParent;        
       
   291 
       
   292         // Canvas of the Subband
       
   293         TRect iSubbandCanvas; 
       
   294 
       
   295         // Origin of the baSubbandnd
       
   296         TPoint iSubbandOrigin; 
       
   297 
       
   298         // High pass first
       
   299         TPoint iHighPassFirst; 
       
   300 
       
   301         // Last packet processed
       
   302         TUint16 iLastPacket;  
       
   303         
       
   304         // Type of the Subband
       
   305         TSubbandType iType;          
       
   306 
       
   307         // Gain of the Subband
       
   308         TUint8 iGain;  
       
   309         
       
   310         // Level of the Subband
       
   311         TUint8 iLevel;       
       
   312         
       
   313         // Resolution level of the Subband
       
   314         TUint8 iResLevel;    
       
   315 
       
   316         // Last Subband processed
       
   317         TUint8 iLastSubband;   
       
   318 
       
   319         // List of packets
       
   320         RPointerArray<CJ2kPacket> iPacketList; 
       
   321 
       
   322     private:    // Data
       
   323 
       
   324     public:     // Friend classes
       
   325        
       
   326     protected:  // Friend classes
       
   327       
       
   328     private:    // Friend classes  
       
   329 
       
   330     };
       
   331 
       
   332 
       
   333 /**
       
   334 *  CJ2kSubbandLL class is a subband class that can 
       
   335 *  have children, i.e. can be divided into new subbands.
       
   336 *
       
   337 *  JP2KCodec.dll
       
   338 *  @since 2.6
       
   339 */
       
   340 class CJ2kSubbandLL : public CJ2kSubband
       
   341     {
       
   342     public:  // Constructors and destructor
       
   343         
       
   344         /**
       
   345         * Two-phased constructor.
       
   346         */
       
   347         static CJ2kSubbandLL * NewLC();
       
   348         
       
   349         /**
       
   350         * Destructor.
       
   351         */
       
   352         virtual ~CJ2kSubbandLL();
       
   353 
       
   354     public: // New functions
       
   355         
       
   356         /**
       
   357         * Get the child subband at specific band
       
   358         * @since 2.6
       
   359         * @param aBand: the band index.
       
   360         * @return CJ2kSubband*: the child at specific band.
       
   361         */
       
   362         CJ2kSubband* ChildAt( TInt aBand );
       
   363 
       
   364         /**
       
   365         * Get the subband at specific resolution level
       
   366         * @since 2.6
       
   367         * @param aResLevel: the resolution level.
       
   368         * @return CJ2kSubband*: pointer to the subband at specific resolution level.
       
   369         */
       
   370         CJ2kSubband* SubbandAt( TUint8 aResLevel );
       
   371 
       
   372         /**
       
   373         * Add the child subband into the list of child subbands
       
   374         * @since 2.6
       
   375         * @param aChild: add the child subband.
       
   376         */
       
   377         void AddChildL( CJ2kSubband* aChild );
       
   378 
       
   379     public: // Functions from base classes
       
   380        
       
   381     protected:  // New functions
       
   382         
       
   383     protected:  // Functions from base classes
       
   384 
       
   385     private:
       
   386 
       
   387     public:     // Data
       
   388     
       
   389     protected:  // Data
       
   390 
       
   391     private:    // Data
       
   392         
       
   393         // List of child subbands
       
   394         RPointerArray<CJ2kSubband> iChildList;   
       
   395 
       
   396     public:     // Friend classes
       
   397        
       
   398     protected:  // Friend classes
       
   399        
       
   400     private:    // Friend classes
       
   401 
       
   402     };
       
   403 
       
   404 /**
       
   405 *  CJ2kSubbandNLL class is a subband class that can not
       
   406 *  have children.
       
   407 *
       
   408 *  JP2KCodec.dll
       
   409 *  @since 2.6
       
   410 */
       
   411 class CJ2kSubbandNLL : public CJ2kSubband
       
   412     {
       
   413     public:  // Constructors and destructor
       
   414         
       
   415         /**
       
   416         * Two-phased constructor.
       
   417         */
       
   418         static CJ2kSubbandNLL * NewLC();
       
   419         
       
   420         /**
       
   421         * Destructor.
       
   422         */
       
   423         virtual ~CJ2kSubbandNLL();
       
   424 
       
   425     public: // New functions
       
   426         
       
   427         /**
       
   428         * Get the sibling subband
       
   429         * @since 2.6
       
   430         * @return CJ2kSubband*: pointer to the sibling subband.
       
   431         */
       
   432         CJ2kSubband* NextSubbandRaster();
       
   433 
       
   434     public: // Functions from base classes
       
   435        
       
   436     protected:  // New functions
       
   437 
       
   438     protected:  // Functions from base classes
       
   439 
       
   440     private:
       
   441 
       
   442     public:     // Data
       
   443      
       
   444     protected:  // Data
       
   445 
       
   446     private:    // Data
       
   447 
       
   448     public:     // Friend classes
       
   449         
       
   450     protected:  // Friend classes
       
   451         
       
   452     private:    // Friend classes
       
   453         
       
   454 
       
   455     };
       
   456 
       
   457 // For inliners.
       
   458 #include "JP2KSubband.inl"
       
   459 
       
   460 #endif // __JP2KSUBBAND_H__