imagingmodules/jp2kcodec/Inc/JP2KConvert.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:  JPEG2000 image encoder/decoder plugin class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __JP2KCONVERT_H__
       
    20 #define __JP2KCONVERT_H__
       
    21 
       
    22 //  INCLUDES
       
    23 #include <icl/imageplugin.h>
       
    24 #include <icl/imagedata.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // MACROS
       
    29 
       
    30 // DATA TYPES
       
    31 
       
    32 // FUNCTION PROTOTYPES
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class TJ2kInfo;
       
    36 class CJp2kReadCodec;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41  * CJp2kDecoder JPEG2000 image decoder plugin class.
       
    42  * Implement the ICL decoder plugin interface.
       
    43  *
       
    44  * JP2KCodec.dll
       
    45  * @since 2.6
       
    46  */
       
    47 class CJp2kDecoder : public CImageDecoderPlugin
       
    48 {
       
    49     public:  // Constructors and destructor
       
    50         
       
    51         /**
       
    52         * Two-phased constructor.
       
    53         */
       
    54         static CJp2kDecoder* NewL();
       
    55 
       
    56         /**
       
    57         * Destructor.
       
    58         */
       
    59         virtual ~CJp2kDecoder();
       
    60 
       
    61     public: // New functions
       
    62         
       
    63     public: // Functions from base classes
       
    64 
       
    65         /**
       
    66         * From CImageDecoderPlugin
       
    67         * @since 2.6
       
    68         * @param aFrameNumber: Number of frame whose type is needed.
       
    69         * @param aImageType: Return image type UID.
       
    70         * @param aImageSubType: Returned image sub type UID.
       
    71         */
       
    72         void ImageType( TInt aFrameNumber, TUid& aImageType, TUid& aImageSubType ) const;
       
    73 
       
    74         /**
       
    75         * From CImageDecoderPlugin
       
    76         * @since 2.6
       
    77         */
       
    78         TInt NumberOfImageComments() const;
       
    79 
       
    80         /**
       
    81         * From CImageDecoderPlugin
       
    82         * @since 2.6
       
    83         * @param aCommentNumber: Number of comment whose comment is needed.
       
    84         */
       
    85         HBufC* ImageCommentL( TInt aCommentNumber ) const;
       
    86 
       
    87         /**
       
    88         * From CImageDecoderPlugin
       
    89         * @since 2.6
       
    90         * @param aFrameNumber: Number of frame whose comment is needed.
       
    91         */
       
    92         TInt NumberOfFrameComments( TInt aFrameNumber ) const;
       
    93 
       
    94         /**
       
    95         * From CImageDecoderPlugin
       
    96         * @since 2.6
       
    97         * @param aFrameNumber: Number of frame whose comment is needed.
       
    98         * @param aCommentNumber: Number of comment whose comment is needed.
       
    99         */
       
   100         HBufC* FrameCommentL( TInt aFrameNumber, TInt aCommentNumber ) const;
       
   101 
       
   102     protected:  // New functions
       
   103         
       
   104     protected:  // Functions from base classes
       
   105         
       
   106         /**
       
   107         * From CImageDecoderPlugin
       
   108         */
       
   109         CFrameInfoStrings* FrameInfoStringsL( RFs& aFs, TInt aFrameNumber );
       
   110 
       
   111         /**
       
   112         * From CImageDecoderPlugin
       
   113         */
       
   114         TInt FrameHeaderBlockSize( TInt aFrameNumber ) const;
       
   115 
       
   116         /**
       
   117         * From CImageDecoderPlugin
       
   118         */
       
   119         TInt FrameBlockSize( TInt aFrameNumber ) const;
       
   120 
       
   121         /**
       
   122         * From CImageDecoderPlugin
       
   123         */
       
   124         void DoConvert();
       
   125 
       
   126     private:
       
   127 
       
   128         /**
       
   129         * C++ default constructor.
       
   130         */
       
   131         CJp2kDecoder();
       
   132 
       
   133         /**
       
   134         * Main state machine
       
   135         * Verify and start parsing the JP2 file format
       
   136         * or JP2 codestream.
       
   137         * @since 2.6
       
   138         */
       
   139         void ReadFormatL();
       
   140 
       
   141         /**
       
   142         * Verify and process JP2 Signature box 
       
   143         * @since 2.6
       
   144         */
       
   145         void ReadSignatureBoxL();
       
   146         /**
       
   147         * Verify and process JP2 File Type box
       
   148         * @since 2.6
       
   149         */
       
   150         void ReadFileTypeBoxL();
       
   151 
       
   152         /**
       
   153         * Verify and process JP2 Header box (superbox)
       
   154         * @since 2.6
       
   155         */
       
   156         void ReadJp2HeaderBoxL();
       
   157 
       
   158         /**
       
   159         * Verify and process Image Header box (in JP2 Header box)
       
   160         * @since 2.6
       
   161         */
       
   162         void ReadImageHeaderBoxL();
       
   163 
       
   164         /**
       
   165         * Verify and process Colour Specification box (in JP2 Header box)
       
   166         * @since 2.6
       
   167         * @param aBoxLength: the length of the Colour Specification box
       
   168         */
       
   169         void ReadColorSpecBoxL( const TUint32 aBoxLength );
       
   170 
       
   171         /**
       
   172         * Verify and process Bits Per Component box (in JP2 Header box)
       
   173         * @since 2.6
       
   174         * @param aBoxLength: the length of the Bits Per Component box
       
   175         */
       
   176         void ReadBitsPerCompBoxL( TUint32 aBoxLength );
       
   177 
       
   178         /**
       
   179         * Verify and process Resolution box (in JP2 Header box, which itself is superbox)
       
   180         * @since 2.6
       
   181         * @param aPtrLimit: the boundary of the data to be read
       
   182         * @param aBoxLength: the length of the Resolution box
       
   183         */
       
   184         void ReadResolutionBoxL( const TUint8 *aPtrLimit, TUint32 aBoxLength );
       
   185 
       
   186         /**
       
   187         * Verify and process Default Display Resolution box (in Resolution box)
       
   188         * @since 2.6
       
   189         */
       
   190         void ReadDisplayResBoxL();
       
   191 
       
   192         /**
       
   193         * Verify and process Capture Resolution box (in Resolution box)
       
   194         * @since 2.6
       
   195         * @param aBoxLength: the length of the Capture Resolution box
       
   196         */
       
   197         void ReadCaptureResBoxL( TUint32 aBoxLength );
       
   198 
       
   199         /**
       
   200         * Verify and process Palette box (in JP2 Header box)
       
   201         * @since 2.6
       
   202         */
       
   203         void ReadPaletteBoxL();
       
   204 
       
   205         /**
       
   206         * Verify and process Component Mapping box (in JP2 Header box)
       
   207         * @since 2.6
       
   208         * @param aBoxLength: the length of the Component Mapping box
       
   209         */
       
   210         void ReadComponentMapBoxL( TUint32 aBoxLength );
       
   211 
       
   212         /**
       
   213         * Verify and process Channel Definition box (in JP2 Header box)
       
   214         * @since 2.6
       
   215         * @param aBoxLength: the length of the Channel Definition box
       
   216         */
       
   217         void ReadChannelDefBoxL( TUint32 aBoxLength );
       
   218 
       
   219         /**
       
   220         * Verify and process IPR box
       
   221         * @since 2.6
       
   222         */
       
   223         void ReadIPRBoxL();
       
   224 
       
   225         /**
       
   226         * Verify and process XML box
       
   227         * @since 2.6
       
   228         */
       
   229         void ReadXMLBoxL();
       
   230 
       
   231         /**
       
   232         * Verify and process UUID box
       
   233         * @since 2.6
       
   234         */
       
   235         void ReadUUIDBoxL();
       
   236 
       
   237         /**
       
   238         * Verify and process UUID Info box (superbox)
       
   239         * @since 2.6
       
   240         */
       
   241         void ReadUUIDInfoBoxL();
       
   242 
       
   243         /**
       
   244         * Ignore the content and advance the iterator to the next box
       
   245         * @since 2.6
       
   246         */
       
   247         void IgnoreBoxL();
       
   248 
       
   249         /**
       
   250         * Update the current state according to the box type
       
   251         * @since 2.6
       
   252         */
       
   253         void UpdateStateFromBoxTypeL();
       
   254 
       
   255         /**
       
   256         * Read frame headers and instantiate decoder for application.
       
   257         * @since 2.6
       
   258         */
       
   259         void ScanDataL();
       
   260 
       
   261     public:     // Data
       
   262         
       
   263         // State machine represent the state when parsing the JP2 file format.
       
   264         enum TDecoderState
       
   265             {
       
   266             EStateInUnknown,
       
   267             EStateInSignatureBox,
       
   268             EStateInFileTypeBox,
       
   269             EStateInJP2SuperBox,
       
   270             EStateInIPRBox,
       
   271             EStateInXMLBox,
       
   272             EStateInUUIDBox,
       
   273             EStateInUUIDInfoBox,
       
   274             EStateInCodestreamBox
       
   275             };
       
   276     
       
   277     protected:  // Data
       
   278 
       
   279     private:    // Data
       
   280 
       
   281         // JP2 file format information
       
   282         TJ2kInfo iJ2kInfo;    
       
   283 
       
   284         // Descriptor of the buffer
       
   285         TPtrC8 iBufferDes;  
       
   286 
       
   287         // Length of box read
       
   288         TUint32 iBoxLength;  
       
   289 
       
   290         // Type of box read
       
   291         TUint32 iBoxType;    
       
   292 
       
   293         // Position of last ReadDataL() used
       
   294         TUint32 iLastRead;   
       
   295 
       
   296         // Enter the method from ICL framework
       
   297         TBool    iCallFromFramework; 
       
   298 
       
   299         // Pointer into the data represented by iBufferDes
       
   300         const TUint8 *iPtr;   
       
   301 
       
   302         // Current state of the parsing of file or data
       
   303         TDecoderState iState; 
       
   304 
       
   305     public:     // Friend classes
       
   306 
       
   307     protected:  // Friend classes
       
   308 
       
   309     private:    // Friend classes
       
   310 };
       
   311 
       
   312 #endif // __JP2KCONVERT_H__