imagingmodules/jp2kcodec/Src/JP2KCodeBlock.cpp
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:  JP2KCodeBlock class used to collect the codeblock
       
    15 *                related information such as compressed data and data length.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "JP2KCodeBlock.h"
       
    22 #include "JP2KUtils.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES  
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // LOCAL CONSTANTS AND MACROS
       
    33 
       
    34 // MODULE DATA STRUCTURES
       
    35 
       
    36 // LOCAL FUNCTION PROTOTYPES
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 // ============================= LOCAL FUNCTIONS ===============================
       
    41 
       
    42 // ============================ MEMBER FUNCTIONS ===============================
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CJ2kCodeBlock::CJ2kCodeBlock
       
    46 // C++ default constructor can NOT contain any code, that
       
    47 // might leave.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CJ2kCodeBlock::CJ2kCodeBlock() : 
       
    51     iLastPass(-1), 
       
    52     iLengthBits(3)
       
    53     {
       
    54     }
       
    55 
       
    56 // Destructor
       
    57 CJ2kCodeBlock::~CJ2kCodeBlock()
       
    58     {
       
    59     delete iDataSize;
       
    60     iDataSize = 0;
       
    61 
       
    62     delete iPassesPerSegment;
       
    63     iPassesPerSegment = 0;
       
    64 
       
    65     delete iNumSegment;
       
    66     iNumSegment = 0;
       
    67 
       
    68     delete iData;
       
    69     iData = 0;
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CJ2kCodeBlock::SetCodeBlockCanvas
       
    74 // Set the canvas of the code block.
       
    75 // (other items were commented in a header).
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CJ2kCodeBlock::SetCodeBlockCanvas( TInt32 aX, TInt32 aY, TInt32 aWidth, TInt32 aHeight )
       
    79     {
       
    80     iCodeBlockCanvas.iTl = TPoint( aX, aY );
       
    81     iCodeBlockCanvas.SetWidth( aWidth );
       
    82     iCodeBlockCanvas.SetHeight( aHeight );
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CJ2kCodeBlock::InitializeL
       
    87 // Initialize the number of segment.
       
    88 // (other items were commented in a header).
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CJ2kCodeBlock::InitializeL( TUint16 aLayer )
       
    92     {
       
    93     iNumSegment = HBufC16::NewMaxL( aLayer );
       
    94     iNumSegment->Des().FillZ();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CJ2kCodeBlock::DataL
       
    99 // Get the data buffer descriptor.
       
   100 // (other items were commented in a header).
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 HBufC8* CJ2kCodeBlock::DataL()
       
   104     {
       
   105     if ( iData )
       
   106         {
       
   107         if ( iData->Des().MaxLength() < (TInt)iDataLength )
       
   108             {
       
   109             iData = iData->ReAllocL( iDataLength );
       
   110             }
       
   111         }
       
   112     else
       
   113         {
       
   114         iData = HBufC8::NewL( iDataLength );
       
   115         }
       
   116 
       
   117     return iData;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CJ2kCodeBlock::Data
       
   122 // Get the pointer to the data portion.
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 const TUint8* CJ2kCodeBlock::Data() const
       
   127     {
       
   128     if ( iData )
       
   129         {
       
   130         return iData->Ptr();
       
   131         }
       
   132 
       
   133     return 0;
       
   134     }
       
   135