Revision: 201002 RCL_3 PDK_3.0.h
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Sat, 20 Feb 2010 00:07:53 +0200
branchRCL_3
changeset 4 3993b8f65362
parent 0 469c91dae73b
child 6 9ebf3284bc56
Revision: 201002 Kit: 201007
imagingmodules/jp2kcodec/Inc/JP2KImageInfo.h
imagingmodules/jp2kcodec/Inc/JP2KImageInfo.inl
imagingmodules/jp2kcodec/Inc/JP2KImageWriter.h
imagingmodules/jp2kcodec/Inc/JP2KPacket.h
imagingmodules/jp2kcodec/Inc/JP2KUtils.h
imagingmodules/jp2kcodec/Src/JP2KCodec.cpp
imagingmodules/jp2kcodec/Src/JP2KComponentInfo.cpp
imagingmodules/jp2kcodec/Src/JP2KImageData.cpp
imagingmodules/jp2kcodec/Src/JP2KImageWriter.cpp
imagingmodules/jp2kcodec/Src/JP2KPacket.cpp
imagingmodules/jp2kcodec/Src/JP2KSubband.cpp
imagingmodules/jp2kcodec/Src/JP2KTileInfo.cpp
imagingmodules/jp2kcodec/Src/JP2KUtils.cpp
--- a/imagingmodules/jp2kcodec/Inc/JP2KImageInfo.h	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Inc/JP2KImageInfo.h	Sat Feb 20 00:07:53 2010 +0200
@@ -161,14 +161,14 @@
         * @since 2.6
         * @return TUint16: number of tiles in horizontal position.
         */
-        TUint16 NumOfHorizTiles() const;
+        TUint16 NumOfHorizTilesL() const;
 
         /**
         * Get total number of tiles in vertical position
         * @since 2.6
         * @return TUint16: number of tiles in vertical position.
         */
-        TUint16 NumOfVertTiles() const;
+        TUint16 NumOfVertTilesL() const;
 
         /**
         * Get total number of components
--- a/imagingmodules/jp2kcodec/Inc/JP2KImageInfo.inl	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Inc/JP2KImageInfo.inl	Sat Feb 20 00:07:53 2010 +0200
@@ -24,26 +24,26 @@
 // ============================ MEMBER FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
-// CJ2kImageInfo::NumOfHorizTiles
+// CJ2kImageInfo::NumOfHorizTilesL
 // Get total number of tiles in horizontal position
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-inline TUint16 CJ2kImageInfo::NumOfHorizTiles() const
+inline TUint16 CJ2kImageInfo::NumOfHorizTilesL() const
     {
-    return (TUint16)( TJ2kUtils::Ceil( iSizMarker.iXsiz - iSizMarker.iXTOsiz,
+    return (TUint16)( TJ2kUtils::CeilL( iSizMarker.iXsiz - iSizMarker.iXTOsiz,
                                        iSizMarker.iXTsiz ) );
     }
 
 // -----------------------------------------------------------------------------
-// CJ2kImageInfo::NumOfVertTiles
+// CJ2kImageInfo::NumOfVertTilesL
 // Get total number of tiles in vertical position
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-inline TUint16 CJ2kImageInfo::NumOfVertTiles() const
+inline TUint16 CJ2kImageInfo::NumOfVertTilesL() const
     {
-    return (TUint16)( TJ2kUtils::Ceil( iSizMarker.iYsiz - iSizMarker.iYTOsiz,
+    return (TUint16)( TJ2kUtils::CeilL( iSizMarker.iYsiz - iSizMarker.iYTOsiz,
                                        iSizMarker.iYTsiz ) );
     }
 
--- a/imagingmodules/jp2kcodec/Inc/JP2KImageWriter.h	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Inc/JP2KImageWriter.h	Sat Feb 20 00:07:53 2010 +0200
@@ -139,7 +139,7 @@
         * @param aSize: the size of the tile.
         * @param aImageInfo: a reference to CJ2kImageInfo object.
         */
-        void UpdateNextTileStartAt(TUint16 aTileIndex, const TSize& aSize, CJ2kImageInfo& aImageInfo );
+        void UpdateNextTileStartAtL(TUint16 aTileIndex, const TSize& aSize, CJ2kImageInfo& aImageInfo );
 
     public: // Functions from base classes
        
@@ -397,7 +397,7 @@
         * @param aSize: the size of component.
         * @param aBitDepth: the bit depth.
         */
-        void WriteOutputFile( CJ2kTileInfo& aTile, TUint16 aCompIndex, const TSize& aSize,
+        void WriteOutputFileL( CJ2kTileInfo& aTile, TUint16 aCompIndex, const TSize& aSize,
                               TUint16 aBitDepth );
 
         /**
@@ -406,7 +406,7 @@
         * @param aTile: a reference to CJ2kTileInfo object.
         * @param aSize: the size to output.
         */
-        void CombineOutputFile( CJ2kTileInfo& aTile, const TSize& aSize );
+        void CombineOutputFileL( CJ2kTileInfo& aTile, const TSize& aSize );
 
         /**
         * Write out a color pixel
--- a/imagingmodules/jp2kcodec/Inc/JP2KPacket.h	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Inc/JP2KPacket.h	Sat Feb 20 00:07:53 2010 +0200
@@ -80,7 +80,7 @@
         * @since 2.6
         * @param aCodeBlock: the size of the codeblock.
         */
-        void SetNumOfBlocks( TSize& aCodeBlock );
+        void SetNumOfBlocksL( TSize& aCodeBlock );
 
         /**
         * Build the inclusive informaiton of the packet
--- a/imagingmodules/jp2kcodec/Inc/JP2KUtils.h	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Inc/JP2KUtils.h	Sat Feb 20 00:07:53 2010 +0200
@@ -64,7 +64,7 @@
         * @param aR: second integer to compute.
         * @return TInt32: the ceiling between two integers aL and aR.
         */
-        static TInt32 Ceil( TInt32 aL, TInt32 aR );
+        static TInt32 CeilL( TInt32 aL, TInt32 aR );
 
         /**
         * Get the floor between two integers
@@ -73,7 +73,7 @@
         * @param aR: second integer to compute.
         * @return TInt32: the floor between two integers aL and aR.
         */
-        static TInt32 Floor( TInt32 aL, TInt32 aR );
+        static TInt32 FloorL( TInt32 aL, TInt32 aR );
 
         /**
         * Get the quotient and remainder
@@ -82,7 +82,7 @@
         * @param aDenom: divisor integer.
         * @return TDiv: the structure contains the quotient and remainder.
         */
-        static TDiv Div( TInt aNum, TInt aDenom );
+        static TDiv DivL( TInt aNum, TInt aDenom );
 
         /**
         * Get the log2 value of an integer
--- a/imagingmodules/jp2kcodec/Src/JP2KCodec.cpp	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KCodec.cpp	Sat Feb 20 00:07:53 2010 +0200
@@ -295,7 +295,7 @@
         // To get the right output image size, we must compute the size tile by tile.
         // Compute the width of the output image
         TInt32 tileCompCanvasWidth = 0;
-        TInt32 numHorTiles = iImageInfo->NumOfHorizTiles(); 
+        TInt32 numHorTiles = iImageInfo->NumOfHorizTilesL(); 
         TInt32 tileStartCanvas;
         TInt32 tileEndCanvas;
         TInt32 tileCompStartCanvas;
@@ -305,21 +305,21 @@
             tileEndCanvas = Min( ( sizMarker.iXTOsiz + ( indexX + 1 ) * sizMarker.iXTsiz ), sizMarker.iXsiz );
 
             // Add this tile's contribution to the total size
-            tileCompStartCanvas = TJ2kUtils::Ceil( tileStartCanvas, sizMarker.iXRsiz[0] );
-            tileCompCanvasWidth += TJ2kUtils::Ceil( tileEndCanvas, sizMarker.iXRsiz[0] ) - tileCompStartCanvas;
+            tileCompStartCanvas = TJ2kUtils::CeilL( tileStartCanvas, sizMarker.iXRsiz[0] );
+            tileCompCanvasWidth += TJ2kUtils::CeilL( tileEndCanvas, sizMarker.iXRsiz[0] ) - tileCompStartCanvas;
             }
         
         // Compute the height of the output image
         TInt32 tileCompCanvasHeight = 0;
-        TInt32 numVerTiles = iImageInfo->NumOfVertTiles(); 
+        TInt32 numVerTiles = iImageInfo->NumOfVertTilesL(); 
         for(TUint16 indexY = 0; indexY < numVerTiles; ++indexY )  
             {
             tileStartCanvas = Max( ( sizMarker.iYTOsiz + indexY * sizMarker.iYTsiz ), sizMarker.iYOsiz );
             tileEndCanvas = Min( ( sizMarker.iYTOsiz + ( indexY + 1 ) * sizMarker.iYTsiz ), sizMarker.iYsiz );
 
             // Add this tile's contribution to the total size
-            tileCompStartCanvas = TJ2kUtils::Ceil( tileStartCanvas, sizMarker.iYRsiz[0] );
-            tileCompCanvasHeight += TJ2kUtils::Ceil( tileEndCanvas, sizMarker.iYRsiz[0] ) - tileCompStartCanvas;
+            tileCompStartCanvas = TJ2kUtils::CeilL( tileStartCanvas, sizMarker.iYRsiz[0] );
+            tileCompCanvasHeight += TJ2kUtils::CeilL( tileEndCanvas, sizMarker.iYRsiz[0] ) - tileCompStartCanvas;
             }
         
         iFrame->iOverallSizeInPixels = TSize( tileCompCanvasWidth, tileCompCanvasHeight );
@@ -456,8 +456,8 @@
     iStyleUsed = EUnknownDecoder;
 
     iProgressBar = EFalse;
-    if ( ( iImageInfo->NumOfHorizTiles() == 1 ) &&
-         ( iImageInfo->NumOfVertTiles() == 1 ) )
+    if ( ( iImageInfo->NumOfHorizTilesL() == 1 ) &&
+         ( iImageInfo->NumOfVertTilesL() == 1 ) )
         {
         // To force a return immediately from ProcessFrameL()
         // on first entry to stimulate the occurrance of
@@ -841,7 +841,8 @@
         {
         // COD in Tile Part Header
         codMarker = new ( ELeave ) TCODMarker;        
-        CleanupDeletePushL( codMarker );
+        //CleanupDeletePushL( codMarker );
+        CleanupStack::PushL(codMarker);
         }
 
     codMarker->iScod = *iReader.iPtr++;
@@ -863,6 +864,7 @@
         {
         // Entropy coder with precincts defined below
         codMarker->iPrecinctSiz = HBufC8::NewL( codMarker->iNumOfLevels + 1 );
+        CleanupStack::PushL(codMarker->iPrecinctSiz);
         for ( TUint8 index = 0; index < codMarker->iNumOfLevels + 1; ++index )
             {
             codMarker->iPrecinctSiz->Des().Append( *iReader.iPtr++ );
@@ -875,14 +877,17 @@
         // We must be missing some data in the marker
         User::Leave( KErrCorrupt );
         }
-
+    if ( codMarker->iScod & 0x01 )
+        {
+            CleanupStack::Pop(codMarker->iPrecinctSiz);
+        }
     if ( !aMain )
         {
         CJ2kTileInfo& tile = CONST_CAST( CJ2kTileInfo&, iImageInfo->TileAt( iLastTileIndex ) );
 
         // Append COD to the current tile and decrement the tile length
         tile.AppendCOD( codMarker, markerLength + KMarkerSize );
-        CleanupStack::Pop();
+        CleanupStack::PopAndDestroy(codMarker);
         }
 
     // Any valid marker may come after COD marker
@@ -922,7 +927,8 @@
     const TSizMarker& sizMarker = iImageInfo->SizMarker();
 
     TCOCMarker *cocMarker = new ( ELeave ) TCOCMarker;    
-    CleanupDeletePushL(cocMarker);
+    //CleanupDeletePushL(cocMarker);
+    CleanupStack::PushL(cocMarker);
 
     if ( sizMarker.iCsiz < 257 )
         {
@@ -951,6 +957,7 @@
         {
         // Entropy coder with precincts defined below
         cocMarker->iPrecinctSiz = HBufC8::NewL( cocMarker->iNumOfLevels + 1 );
+        CleanupStack::PushL(cocMarker->iPrecinctSiz);
         for ( TUint8 index = 0; index < cocMarker->iNumOfLevels + 1; ++index )
             {
             cocMarker->iPrecinctSiz->Des().Append( *iReader.iPtr++ );
@@ -975,7 +982,12 @@
         // Append COC to the current tile and decrement the tile length
         tile.AppendCOCL( cocMarker, markerLength + KMarkerSize );
         }
-    CleanupStack::Pop();
+    
+    if ( cocMarker->iScoc & 0x01 )
+        {    
+            CleanupStack::Pop(cocMarker->iPrecinctSiz);
+        }
+    CleanupStack::PopAndDestroy(cocMarker);
 
     // Any valid marker may come after COC marker
     iFHState = EStateInUnknown;
@@ -1023,7 +1035,8 @@
         // QCD in Tile Part Header
         qcdMarker = new ( ELeave ) TQCDMarker;
         
-        CleanupDeletePushL( qcdMarker );
+        //CleanupDeletePushL( qcdMarker );
+        CleanupStack::PushL( qcdMarker );
         }
 
     qcdMarker->iSqcd = *iReader.iPtr++;
@@ -1066,6 +1079,12 @@
                 }
             }
         }
+    
+    CleanupStack::PushL( qcdMarker->iExponent );
+    if ((qcdMarker->iSqcd & 0x1f) || (qcdMarker->iSqcd & 0x01))
+    {
+        CleanupStack::PushL( qcdMarker->iMantissa );       
+    }
 
     // Make sure we read all the data
     if ( ( iReader.iPtr - iReader.iPtrStartMarker ) != ( markerLength + KMarkerSize ) )
@@ -1074,13 +1093,22 @@
         User::Leave( KErrCorrupt );
         }
 
+    
+    if ((qcdMarker->iSqcd & 0x1f) || (qcdMarker->iSqcd & 0x01))
+    {
+        CleanupStack::Pop( qcdMarker->iMantissa );       
+    }   
+    
+    CleanupStack::Pop( qcdMarker->iExponent );
+    
     if ( !aMain )
         {
         CJ2kTileInfo& tile = CONST_CAST( CJ2kTileInfo&, iImageInfo->TileAt( iLastTileIndex ) );
 
         // Append QCD to the current tile and decrement the tile length
         tile.AppendQCD( qcdMarker, markerLength + KMarkerSize );
-        CleanupStack::Pop();
+        //CleanupStack::PopAndDestroy(qcdMarker);
+        CleanupStack::PopAndDestroy(qcdMarker);
         }
 
     // Any valid marker may come after QCD marker
@@ -1121,7 +1149,8 @@
 
     TQCCMarker *qccMarker = new (ELeave) TQCCMarker;
 
-    CleanupDeletePushL( qccMarker );
+    //CleanupDeletePushL( qccMarker );
+    CleanupStack::PushL( qccMarker );
 
     if ( sizMarker.iCsiz < 257 )
         {
@@ -1174,6 +1203,12 @@
                 }
             }
         }
+    
+    CleanupStack::PushL( qccMarker->iExponent );
+    if( (qccMarker->iSqcc & 0x1f) || (qccMarker->iSqcc & 0x01) )
+    {
+        CleanupStack::PushL( qccMarker->iMantissa );
+    }
 
     // Make sure we read all the data
     if ( ( iReader.iPtr - iReader.iPtrStartMarker ) != ( markerLength + KMarkerSize ) )
@@ -1193,7 +1228,14 @@
         // Append QCC to the current tile and decrement the tile length
         tile.AppendQCCL( qccMarker, markerLength + KMarkerSize );
         }
-    CleanupStack::Pop();
+    
+    if( (qccMarker->iSqcc & 0x1f) || (qccMarker->iSqcc & 0x01) )
+    {
+        CleanupStack::Pop( qccMarker->iMantissa );
+    }    
+    
+    CleanupStack::Pop( qccMarker->iExponent );
+    CleanupStack::PopAndDestroy(qccMarker);
 
     // Any valid marker may come after QCC marker
     iFHState = EStateInUnknown;
@@ -1233,7 +1275,7 @@
     const TSizMarker& sizMarker = iImageInfo->SizMarker();
 
     TRGNMarker *rgnMarker = new ( ELeave ) TRGNMarker;
-    CleanupDeletePushL( rgnMarker );
+    CleanupStack::PushL( rgnMarker );
 
     if ( sizMarker.iCsiz < 257 )
         {
@@ -1267,7 +1309,7 @@
         // Append RGN to the current tile and decrement the tile length
         tile.AppendRGNL( rgnMarker, markerLength + KMarkerSize );
         }
-    CleanupStack::Pop();
+    CleanupStack::PopAndDestroy(rgnMarker);
 
     // Any valid marker may come after RGN marker
     iFHState = EStateInUnknown;
@@ -1407,13 +1449,14 @@
             }
 
         TPPMMarker *ppmMarker = new ( ELeave ) TPPMMarker;        
-        CleanupDeletePushL( ppmMarker );
+        CleanupStack::PushL( ppmMarker );
 
         ppmMarker->iZppm = *iReader.iPtr++;
         TUint32 entries = (TUint32)( markerLength - KMarkerSize - 1 );
 
         ppmMarker->iNppm = entries;
         ppmMarker->iIppm = HBufC8::NewL( entries );
+        CleanupStack::PushL( ppmMarker->iIppm );
 
         if ( !isUnderflow )
             {
@@ -1459,7 +1502,8 @@
             {
             User::LeaveIfError( mainMarker.iPpm.Append( ppmMarker ) );
             }
-        CleanupStack::Pop();
+        CleanupStack::Pop(ppmMarker->iIppm);
+        CleanupStack::Pop(ppmMarker);
         }
     else
         {
@@ -1622,13 +1666,14 @@
         }
 
     TPLMMarker *plmMarker =  new ( ELeave ) TPLMMarker;    
-    CleanupDeletePushL( plmMarker );
+    CleanupStack::PushL( plmMarker );
 
     plmMarker->iZplm = *iReader.iPtr++;
     TUint32 entries = (TUint32)( markerLength - KMarkerSize - 1 );
 
     plmMarker->iNplm = (TUint8)entries;
     plmMarker->iIplm = HBufC8::NewL( entries );
+    CleanupStack::PushL( plmMarker->iIplm );
     plmMarker->iIplm->Des().Append( iReader.iPtr, entries );
     iReader.iPtr += entries;
 
@@ -1662,7 +1707,8 @@
         {
         User::LeaveIfError( mainMarker.iPlm.Append( plmMarker ) );
         }
-    CleanupStack::Pop();
+    CleanupStack::Pop(plmMarker->iIplm);
+    CleanupStack::PopAndDestroy(plmMarker);
 
     // Any valid marker may come after PLM marker
     iFHState = EStateInUnknown;
@@ -1767,13 +1813,16 @@
             isUnderflow = ETrue;
             }
 
-        TCOMMarker* comMarker = new ( ELeave ) TCOMMarker;        
-        CleanupDeletePushL( comMarker );
+        TCOMMarker* comMarker = new ( ELeave ) TCOMMarker;   
+        //CleanupDeletePushL(comMarker);
+        CleanupStack::PushL( comMarker );
 
         comMarker->iRcom = PtrReadUtil::ReadBigEndianUint16Inc( iReader.iPtr );
         TInt entries = markerLength - ( 2 * KMarkerSize );
 
         comMarker->iCcom = HBufC8::NewL( entries );
+        //CleanupDeletePushL( comMarker->iCcom );
+        CleanupStack::PushL(comMarker->iCcom);
         if ( !isUnderflow )
             {
             comMarker->iCcom->Des().Append( iReader.iPtr, entries );
@@ -1806,7 +1855,8 @@
             // Append COM to the current tile and decrement the tile length
             tile.AppendCOML( comMarker, markerLength + KMarkerSize );
             }
-        CleanupStack::Pop();
+        CleanupStack::Pop(comMarker->iCcom);
+        CleanupStack::Pop(comMarker);
         }
     else
         {
@@ -1879,7 +1929,7 @@
     sotMarker.iTPsot = *iReader.iPtr++;
     sotMarker.iTNsot = *iReader.iPtr++;
     
-    if(sotMarker.iIsot >= ( iImageInfo->NumOfHorizTiles() * iImageInfo->NumOfVertTiles() ))
+    if(sotMarker.iIsot >= ( iImageInfo->NumOfHorizTilesL() * iImageInfo->NumOfVertTilesL() ))
         {
         // Invalid tile index, exceeds the number of tiles, exit
         User::Leave( KErrCorrupt );
@@ -2035,8 +2085,8 @@
         tile.SetPacketHeaderReader( &iReader );
         }
 
-    if ( ( iImageInfo->NumOfHorizTiles() == 1 ) &&
-         ( iImageInfo->NumOfVertTiles() == 1 ) )
+    if ( ( iImageInfo->NumOfHorizTilesL() == 1 ) &&
+         ( iImageInfo->NumOfVertTilesL() == 1 ) )
         {
         // To force a return immediately from ProcessFrameL()
         // on first entry to stimulate the occurrance of
@@ -2260,8 +2310,8 @@
             }
         }
 
-    if ( ( iImageInfo->NumOfHorizTiles() == 1 ) &&
-         ( iImageInfo->NumOfVertTiles() == 1 ) )
+    if ( ( iImageInfo->NumOfHorizTilesL() == 1 ) &&
+         ( iImageInfo->NumOfVertTilesL() == 1 ) )
         {
         // To force a return immediately from ProcessFrameL()
         // on first entry to stimulate the occurrance of
@@ -2302,11 +2352,12 @@
         }
 
     TPPTMarker *pptMarker = new ( ELeave ) TPPTMarker;    
-    CleanupDeletePushL( pptMarker );
+    CleanupStack::PushL( pptMarker );
 
     TInt entries = markerLength - KMarkerSize - 1;
     pptMarker->iZppt = *iReader.iPtr++;
     pptMarker->iIppt = HBufC8::NewL( entries );
+    CleanupStack::PushL( pptMarker->iIppt );
     pptMarker->iIppt->Des(  ).Append( iReader.iPtr, entries );
     iReader.iPtr += entries;
 
@@ -2321,7 +2372,8 @@
     
     // Append PPT to the current tile and decrement the tile length
     tile.AppendPPTL( pptMarker, markerLength + KMarkerSize );
-    CleanupStack::Pop();
+    CleanupStack::Pop(pptMarker->iIppt);
+    CleanupStack::PopAndDestroy(pptMarker);
 
     // Any valid marker may come after PPT marker
     iFHState = EStateInUnknown;
@@ -2359,8 +2411,8 @@
         }
 
     TPLTMarker *pltMarker = new ( ELeave ) TPLTMarker;
-    //CleanupStack::PushL( pltMarker );
-    CleanupDeletePushL( pltMarker );
+    CleanupStack::PushL( pltMarker );
+    //CleanupDeletePushL( pltMarker );
 
     pltMarker->iZplt = *iReader.iPtr++;
 
@@ -2382,7 +2434,8 @@
 
     // Append PLT to the current tile and decrement the tile length
     tile.AppendPLTL( pltMarker, markerLength + KMarkerSize );
-    CleanupStack::Pop();
+    //CleanupStack::Pop();
+    CleanupStack::PopAndDestroy(pltMarker);
 
     // Any valid marker may come after PLT marker
     iFHState = EStateInUnknown;
--- a/imagingmodules/jp2kcodec/Src/JP2KComponentInfo.cpp	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KComponentInfo.cpp	Sat Feb 20 00:07:53 2010 +0200
@@ -99,8 +99,8 @@
     TUint8 diff = (TUint8)( iNumOfLevels - level );
     if ( level <= iNumOfLevels )
         {
-        TInt trx0 = TJ2kUtils::Ceil( iComponentCanvas.iTl.iX, 1 << diff );
-        TInt try0 = TJ2kUtils::Ceil( iComponentCanvas.iTl.iY, 1 << diff );
+        TInt trx0 = TJ2kUtils::CeilL( iComponentCanvas.iTl.iX, 1 << diff );
+        TInt try0 = TJ2kUtils::CeilL( iComponentCanvas.iTl.iY, 1 << diff );
         const TSizMarker& sizMarker = aTile.ImageInfo().SizMarker();
 
         if ( ( ( aTile.LastN1Processed() % (TInt)( sizMarker.iYRsiz[aTile.LastComponentProcessed()] * iGridList[level].iHeight ) == 0) ||
@@ -130,8 +130,8 @@
 
     if (level <= iNumOfLevels)
         {
-        TInt trx0 = TJ2kUtils::Ceil( iComponentCanvas.iTl.iX, 1 << diff );
-        TInt try0 = TJ2kUtils::Ceil( iComponentCanvas.iTl.iY, 1 << diff );
+        TInt trx0 = TJ2kUtils::CeilL( iComponentCanvas.iTl.iX, 1 << diff );
+        TInt try0 = TJ2kUtils::CeilL( iComponentCanvas.iTl.iY, 1 << diff );
         const TSizMarker& sizMarker = aTile.ImageInfo().SizMarker();
 
         if ( ( ( aTile.LastN1Processed() % (TInt)( sizMarker.iYRsiz[aTile.LastComponentProcessed()] * iGridList[level].iHeight ) == 0 ) ||
@@ -254,10 +254,10 @@
     const TSizMarker& sizMarker = imageInfo.SizMarker();
     const TRect& tileCanvas = aTile.TileCanvas();
 
-    iComponentCanvas.iTl = TPoint( TJ2kUtils::Ceil( tileCanvas.iTl.iX, sizMarker.iXRsiz[aIndex] ),
-                                   TJ2kUtils::Ceil( tileCanvas.iTl.iY, sizMarker.iYRsiz[aIndex] ) );
-    iComponentCanvas.iBr = TPoint( TJ2kUtils::Ceil( tileCanvas.iBr.iX, sizMarker.iXRsiz[aIndex] ),
-                                   TJ2kUtils::Ceil( tileCanvas.iBr.iY, sizMarker.iYRsiz[aIndex] ) );
+    iComponentCanvas.iTl = TPoint( TJ2kUtils::CeilL( tileCanvas.iTl.iX, sizMarker.iXRsiz[aIndex] ),
+                                   TJ2kUtils::CeilL( tileCanvas.iTl.iY, sizMarker.iYRsiz[aIndex] ) );
+    iComponentCanvas.iBr = TPoint( TJ2kUtils::CeilL( tileCanvas.iBr.iX, sizMarker.iXRsiz[aIndex] ),
+                                   TJ2kUtils::CeilL( tileCanvas.iBr.iY, sizMarker.iYRsiz[aIndex] ) );
 
     if ( iComponentCanvas.Width(  ) <= 0 || iComponentCanvas.Height(  ) <= 0 )
         {
@@ -325,14 +325,14 @@
             }
         denom = 1 << ( iNumOfLevels - index );
 
-        trx0 = TJ2kUtils::Ceil( iComponentCanvas.iTl.iX, denom );
-        try0 = TJ2kUtils::Ceil( iComponentCanvas.iTl.iY, denom );
-        trx1 = TJ2kUtils::Ceil( iComponentCanvas.iBr.iX, denom );
-        try1 = TJ2kUtils::Ceil( iComponentCanvas.iBr.iY, denom );
+        trx0 = TJ2kUtils::CeilL( iComponentCanvas.iTl.iX, denom );
+        try0 = TJ2kUtils::CeilL( iComponentCanvas.iTl.iY, denom );
+        trx1 = TJ2kUtils::CeilL( iComponentCanvas.iBr.iX, denom );
+        try1 = TJ2kUtils::CeilL( iComponentCanvas.iBr.iY, denom );
 
         if ( trx1 > trx0 )
             {
-            precinct.iWidth = TJ2kUtils::Ceil( trx1, 1 << ppx ) - TJ2kUtils::Floor( trx0, 1 << ppx );
+            precinct.iWidth = TJ2kUtils::CeilL( trx1, 1 << ppx ) - TJ2kUtils::FloorL( trx0, 1 << ppx );
             }
         else
             {
@@ -341,7 +341,7 @@
 
         if ( try1 > try0 )
             {
-            precinct.iHeight = TJ2kUtils::Ceil( try1, 1 << ppy ) - TJ2kUtils::Floor( try0, 1 << ppy );
+            precinct.iHeight = TJ2kUtils::CeilL( try1, 1 << ppy ) - TJ2kUtils::FloorL( try0, 1 << ppy );
             }
         else
             {
--- a/imagingmodules/jp2kcodec/Src/JP2KImageData.cpp	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KImageData.cpp	Sat Feb 20 00:07:53 2010 +0200
@@ -63,9 +63,11 @@
 TImageDataBlock* TJp2kComment::DuplicateL( CFrameImageData& aFrameImageData ) const
     {
     TJp2kComment *jp2kComment = new ( ELeave ) TJp2kComment( *this );
-    CleanupDeletePushL( jp2kComment );
+    //CleanupDeletePushL( jp2kComment );
+    CleanupStack::PushL( jp2kComment );
 
     jp2kComment->iComment = jp2kComment->iComment->AllocLC();
+    CleanupStack::PushL( jp2kComment->iComment );
 
     User::LeaveIfError( aFrameImageData.AppendImageBuffer( jp2kComment->iComment ) );
     CleanupStack::Pop( 2 ); // jp2kComment and jp2kComment->iComment
@@ -93,9 +95,11 @@
 TImageDataBlock* TJp2kIprBox::DuplicateL( CFrameImageData& aFrameImageData ) const
     {
     TJp2kIprBox *jp2kIprBox = new ( ELeave ) TJp2kIprBox( *this );
-    CleanupDeletePushL( jp2kIprBox );
+    //CleanupDeletePushL( jp2kIprBox );
+    CleanupStack::PushL( jp2kIprBox );
 
     jp2kIprBox->iIprData = jp2kIprBox->iIprData->AllocLC();
+    CleanupStack::PushL( jp2kIprBox->iIprData );
 
     User::LeaveIfError( aFrameImageData.AppendImageBuffer( jp2kIprBox->iIprData ) );
     CleanupStack::Pop( 2 ); // jp2kIprBox and jp2kIprBox->iIprData
@@ -123,9 +127,11 @@
 TImageDataBlock* TJp2kXmlBox::DuplicateL( CFrameImageData& aFrameImageData ) const
     {
     TJp2kXmlBox *jp2kXmlBox = new ( ELeave ) TJp2kXmlBox( *this );
-    CleanupDeletePushL( jp2kXmlBox );
+    //CleanupDeletePushL( jp2kXmlBox );
+    CleanupStack::PushL(jp2kXmlBox);
 
     jp2kXmlBox->iXmlData = jp2kXmlBox->iXmlData->AllocLC();
+    CleanupStack::PushL(jp2kXmlBox->iXmlData);
 
     User::LeaveIfError( aFrameImageData.AppendImageBuffer( jp2kXmlBox->iXmlData ) );
     CleanupStack::Pop( 2 ); // jp2kXmlBox and jp2kXmlBox->iXmlData
@@ -154,9 +160,11 @@
 TImageDataBlock* TJp2kUuidBox::DuplicateL( CFrameImageData& aFrameImageData ) const
     {
     TJp2kUuidBox *jp2kUuidBox = new ( ELeave ) TJp2kUuidBox( *this );
-    CleanupDeletePushL( jp2kUuidBox );
+    //CleanupDeletePushL( jp2kUuidBox );
+    CleanupStack::PushL( jp2kUuidBox );
 
     jp2kUuidBox->iUuidData = jp2kUuidBox->iUuidData->AllocLC();
+    CleanupStack::PushL( jp2kUuidBox->iUuidData );
 
     User::LeaveIfError( aFrameImageData.AppendImageBuffer( jp2kUuidBox->iUuidData ) );
     CleanupStack::Pop( 2 ); // jp2kUuidBox and jp2kUuidBox->iUuidData
@@ -188,13 +196,16 @@
 TImageDataBlock* TJp2kUuidInfoBox::DuplicateL( CFrameImageData& aFrameImageData ) const
     {
     TJp2kUuidInfoBox *jp2kUuidInfoBox = new ( ELeave ) TJp2kUuidInfoBox( *this );
-    CleanupDeletePushL( jp2kUuidInfoBox );
+    //CleanupDeletePushL( jp2kUuidInfoBox );
+    CleanupStack::PushL( jp2kUuidInfoBox );
 
     jp2kUuidInfoBox->iUuidInfoId = jp2kUuidInfoBox->iUuidInfoId->AllocLC();
+    CleanupStack::PushL( jp2kUuidInfoBox->iUuidInfoId );
     User::LeaveIfError( aFrameImageData.AppendImageBuffer( jp2kUuidInfoBox->iUuidInfoId ) );
     CleanupStack::Pop( 1 ); // jp2kUuidInfoBox->iUuidInfoId
 
     jp2kUuidInfoBox->iUuidInfoData = jp2kUuidInfoBox->iUuidInfoData->AllocLC();
+    CleanupStack::PushL( jp2kUuidInfoBox->iUuidInfoData );
     User::LeaveIfError( aFrameImageData.AppendImageBuffer( jp2kUuidInfoBox->iUuidInfoData ) );
     CleanupStack::Pop( 2 ); // jp2kUuidInfoBox and jp2kUuidInfoBox->iUuidInfoData
 
--- a/imagingmodules/jp2kcodec/Src/JP2KImageWriter.cpp	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KImageWriter.cpp	Sat Feb 20 00:07:53 2010 +0200
@@ -111,20 +111,20 @@
     }
 
 // -----------------------------------------------------------------------------
-// CJ2kWriterComponentInfo::UpdateNextTileStartAt
+// CJ2kWriterComponentInfo::UpdateNextTileStartAtL
 // Update the starting point of next tile
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-void CJ2kWriterComponentInfo::UpdateNextTileStartAt( TUint16 aTileIndex, 
+void CJ2kWriterComponentInfo::UpdateNextTileStartAtL( TUint16 aTileIndex, 
                                                      const TSize& aSize,
                                                      CJ2kImageInfo& aImageInfo )
     {
-    TUint16 numOfHorizTiles = aImageInfo.NumOfHorizTiles();
-    TUint16 numOfVertTiles  = aImageInfo.NumOfVertTiles();
+    TUint16 numOfHorizTiles = aImageInfo.NumOfHorizTilesL();
+    TUint16 numOfVertTiles  = aImageInfo.NumOfVertTilesL();
 
     // Calculate the p and q of a tile
-    TDiv tDiv = TJ2kUtils::Div( aTileIndex, numOfHorizTiles );
+    TDiv tDiv = TJ2kUtils::DivL( aTileIndex, numOfHorizTiles );
     if ( tDiv.rem != ( numOfHorizTiles - 1 ) )
         {
         iTileStartList[aTileIndex + 1].iX = iTileStartList[aTileIndex].iX + aSize.iWidth;
@@ -282,7 +282,7 @@
                 iColorPixelBlock = STATIC_CAST( TRgb*, User::AllocL( 2 * KPixelsBlock * sizeof( TRgb ) ) );
                 }
 
-            CombineOutputFile( aTile, subbandSize );
+            CombineOutputFileL( aTile, subbandSize );
             for ( c = 0; c < iNumComponents; c++ )
                 {
                 iComponents[c]->FreeData();
@@ -308,7 +308,7 @@
                 }
 
             // Output a single component
-            WriteOutputFile( aTile, c, subbandSize, bitdepth );
+            WriteOutputFileL( aTile, c, subbandSize, bitdepth );
             iComponents[c]->FreeData();
             }
         }
@@ -328,7 +328,7 @@
                 bitdepth = iImageInfo.DepthOfComponent( c );
 
                 // Output single files 
-                WriteOutputFile( aTile, c, subbandSize, bitdepth );
+                WriteOutputFileL( aTile, c, subbandSize, bitdepth );
                 iComponents[c]->FreeData();
                 }
             }
@@ -340,7 +340,7 @@
                 bitdepth = ( TUint8 )( ( iJ2kInfo.iPalette.iBList[0] & 0x7f )+1 );
 
                 // Output single files 
-                WriteOutputFile( aTile, c, subbandSize, bitdepth );
+                WriteOutputFileL( aTile, c, subbandSize, bitdepth );
                 iComponents[c]->FreeData();
                 }
             }
@@ -351,7 +351,7 @@
             // Output only the first component to screen
             if( aComponentIndex == 0 )
                 {
-                WriteOutputFile( aTile, aComponentIndex, subbandSize, bitdepth );
+                WriteOutputFileL( aTile, aComponentIndex, subbandSize, bitdepth );
                 }
             iComponents[aComponentIndex]->FreeData();
             }
@@ -439,7 +439,7 @@
                 iColorPixelBlock = STATIC_CAST( TRgb*, User::AllocL( 2 * KPixelsBlock * sizeof( TRgb ) ) );
                 }
 
-            CombineOutputFile( aTile, subbandSize );
+            CombineOutputFileL( aTile, subbandSize );
             for ( c = 0; c < iNumComponents; c++ )
                 {
                 iComponents[c]->FreeData();
@@ -465,7 +465,7 @@
                 }
 
             // Output a single component
-            WriteOutputFile( aTile, c, subbandSize, bitdepth );
+            WriteOutputFileL( aTile, c, subbandSize, bitdepth );
             iComponents[c]->FreeData();
             }
         }
@@ -485,7 +485,7 @@
                 bitdepth = iImageInfo.DepthOfComponent( c );
 
                 // Output single files 
-                WriteOutputFile( aTile, c, subbandSize, bitdepth );
+                WriteOutputFileL( aTile, c, subbandSize, bitdepth );
                 iComponents[c]->FreeData();
                 }
             }
@@ -497,7 +497,7 @@
                 bitdepth = (TUint8)( ( iJ2kInfo.iPalette.iBList[0] & 0x7f )+1 );
 
                 // Output single files 
-                WriteOutputFile( aTile, c, subbandSize, bitdepth );
+                WriteOutputFileL( aTile, c, subbandSize, bitdepth );
                 iComponents[c]->FreeData();
                 }
             }
@@ -508,7 +508,7 @@
             // Output only the first component to screen
             if( aComponentIndex == 0 )
                 {
-                WriteOutputFile( aTile, aComponentIndex, subbandSize, bitdepth );
+                WriteOutputFileL( aTile, aComponentIndex, subbandSize, bitdepth );
                 }
 
             iComponents[aComponentIndex]->FreeData();
@@ -1078,6 +1078,8 @@
         iMatrix[8] = ( TInt32 )( KSRGBMaxIntShifted * ( KSRGB20 * blueX  + KSRGB21 * blueY  + KSRGB22 * blueZ ) );
         
         iRedTRCLut = STATIC_CAST( TInt32*, User::AllocL( lutSize * sizeof( TInt32 ) ) );
+        //ASSERT(redTRC);
+        User::LeaveIfNull(redTRC);
         if ( redTRC->Length() == 1 )
             {
             gamma = (TReal)( *redTRC )[0] / KGamma;
@@ -1112,6 +1114,8 @@
             }
 
         iGreenTRCLut = STATIC_CAST( TInt32*, User::AllocL( lutSize * sizeof( TInt32 ) ) );
+        //ASSERT(greenTRC);
+        User::LeaveIfNull(greenTRC);
         if ( greenTRC->Length() == 1 )
             {
             gamma = (TReal)( *greenTRC )[0] / KGamma;
@@ -1146,6 +1150,8 @@
             }
 
         iBlueTRCLut = STATIC_CAST( TInt32*, User::AllocL( lutSize * sizeof( TInt32 ) ) );
+        //ASSERT(blueTRC);
+        User::LeaveIfNull(blueTRC);
         if ( blueTRC->Length() == 1 )
             {
             gamma = (TReal)( *blueTRC )[0] / KGamma;
@@ -1174,6 +1180,8 @@
         {
 
         iGrayTRCLut = STATIC_CAST( TInt32*, User::AllocL( lutSize * sizeof( TInt32 ) ) );
+        //ASSERT(grayTRC);
+        User::LeaveIfNull(grayTRC);
         if ( grayTRC->Length() == 1 )
             {
 
@@ -1257,8 +1265,8 @@
     TUint16 tileIndex = 0;            
     TUint16 tileYIndex = 0;
     TPoint tileStart( 0, 0 );
-    TUint16 numOfHorizTiles = iImageInfo.NumOfHorizTiles();
-    TUint16 numOfVertTiles  = iImageInfo.NumOfVertTiles();
+    TUint16 numOfHorizTiles = iImageInfo.NumOfHorizTilesL();
+    TUint16 numOfVertTiles  = iImageInfo.NumOfVertTilesL();
     TRect tileCanvas( 0, 0, 0, 0 );
     TRect componentCanvas( 0, 0, 0, 0 );
     const TSizMarker &sizMarker = iImageInfo.SizMarker();
@@ -1286,11 +1294,11 @@
                 tileCanvas.iBr = TPoint( Min( sizMarker.iXTOsiz + ( m + 1 ) * sizMarker.iXTsiz, sizMarker.iXsiz ),
                                          Min( sizMarker.iYTOsiz + ( l + 1 ) * sizMarker.iYTsiz, sizMarker.iYsiz ) );
                 // Component canvas
-                componentCanvas.iTl = TPoint( TJ2kUtils::Ceil( tileCanvas.iTl.iX, sizMarker.iXRsiz[compIndex] ),
-                                              TJ2kUtils::Ceil( tileCanvas.iTl.iY, sizMarker.iYRsiz[compIndex] ) );
+                componentCanvas.iTl = TPoint( TJ2kUtils::CeilL( tileCanvas.iTl.iX, sizMarker.iXRsiz[compIndex] ),
+                                              TJ2kUtils::CeilL( tileCanvas.iTl.iY, sizMarker.iYRsiz[compIndex] ) );
 
-                componentCanvas.iBr = TPoint( TJ2kUtils::Ceil( tileCanvas.iBr.iX, sizMarker.iXRsiz[compIndex] ),
-                                              TJ2kUtils::Ceil( tileCanvas.iBr.iY, sizMarker.iYRsiz[compIndex] ) );
+                componentCanvas.iBr = TPoint( TJ2kUtils::CeilL( tileCanvas.iBr.iX, sizMarker.iXRsiz[compIndex] ),
+                                              TJ2kUtils::CeilL( tileCanvas.iBr.iY, sizMarker.iYRsiz[compIndex] ) );
 
                 if ( m )
                     {
@@ -1547,12 +1555,12 @@
     }
 
 // -----------------------------------------------------------------------------
-// CJ2kImageWriter::WriteOutputFile
+// CJ2kImageWriter::WriteOutputFileL
 // Write the component to the single output file
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-void CJ2kImageWriter::WriteOutputFile( CJ2kTileInfo& aTile,
+void CJ2kImageWriter::WriteOutputFileL( CJ2kTileInfo& aTile,
                                        TUint16 aCompIndex,
                                        const TSize& aSize,
                                        TUint16 aBitDepth )
@@ -1565,7 +1573,7 @@
     TInt16 tempNumLevels = (TUint16)( numLevels - iImageInfo.LevelDrop() );
    
     TPoint tileStartCoord = currentComponent->TileStartAt( aTile.SotMarker().iIsot );
-    currentComponent->UpdateNextTileStartAt( aTile.SotMarker().iIsot, aSize, iImageInfo );
+    currentComponent->UpdateNextTileStartAtL( aTile.SotMarker().iIsot, aSize, iImageInfo );
 
     if ( tempNumLevels < 0 )
         {
@@ -1589,7 +1597,7 @@
         // Also take care of next tile's starting position
         outputSize.iHeight /= stepSize;
         outputSize.iWidth /= stepSize;
-        iComponents[0]->UpdateNextTileStartAt( aTile.SotMarker().iIsot, outputSize, iImageInfo );
+        iComponents[0]->UpdateNextTileStartAtL( aTile.SotMarker().iIsot, outputSize, iImageInfo );
         }
 
     TInt32 dcShift = 0;
@@ -1669,12 +1677,12 @@
     }
 
 // -----------------------------------------------------------------------------
-// CJ2kImageWriter::CombineOutputFile
+// CJ2kImageWriter::CombineOutputFileL
 // Write all components of the tile to the single output file
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-void CJ2kImageWriter::CombineOutputFile( CJ2kTileInfo& aTile, const TSize& aSize )
+void CJ2kImageWriter::CombineOutputFileL( CJ2kTileInfo& aTile, const TSize& aSize )
     {
     TInt32 i = 0;
     TInt32 j = 0;
@@ -1683,7 +1691,7 @@
 
     TSize outputSize = aSize;
     TPoint& tileStartCoord = iComponents[0]->TileStartAt( aTile.SotMarker().iIsot );
-    iComponents[0]->UpdateNextTileStartAt( aTile.SotMarker().iIsot, outputSize, iImageInfo );
+    iComponents[0]->UpdateNextTileStartAtL( aTile.SotMarker().iIsot, outputSize, iImageInfo );
 
     if ( tempNumLevels < 0 )
         {
@@ -1705,7 +1713,7 @@
         // Also take care of next tile's starting position
         outputSize.iHeight /= stepSize;
         outputSize.iWidth /= stepSize;
-        iComponents[0]->UpdateNextTileStartAt( aTile.SotMarker().iIsot, outputSize, iImageInfo );
+        iComponents[0]->UpdateNextTileStartAtL( aTile.SotMarker().iIsot, outputSize, iImageInfo );
         
         tempNumLevels = 0;
         }
--- a/imagingmodules/jp2kcodec/Src/JP2KPacket.cpp	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KPacket.cpp	Sat Feb 20 00:07:53 2010 +0200
@@ -97,17 +97,17 @@
     }
 
 // -----------------------------------------------------------------------------
-// CJ2kPacket::SetNumOfBlocks
+// CJ2kPacket::SetNumOfBlocksL
 // Set the number of blocks
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-void CJ2kPacket::SetNumOfBlocks( TSize& aCodeBlock )
+void CJ2kPacket::SetNumOfBlocksL( TSize& aCodeBlock )
     {
-    TInt32 x0 = TJ2kUtils::Floor( iPacketCanvas.iTl.iX, aCodeBlock.iWidth ) * aCodeBlock.iWidth;
-    TInt32 y0 = TJ2kUtils::Floor( iPacketCanvas.iTl.iY, aCodeBlock.iHeight ) * aCodeBlock.iHeight;
-    TInt32 x1 = TJ2kUtils::Ceil( iPacketCanvas.iTl.iX + iPacketCanvas.Width(), aCodeBlock.iWidth ) * aCodeBlock.iWidth;
-    TInt32 y1 = TJ2kUtils::Ceil( iPacketCanvas.iTl.iY + iPacketCanvas.Height(), aCodeBlock.iHeight ) * aCodeBlock.iHeight;
+    TInt32 x0 = TJ2kUtils::FloorL( iPacketCanvas.iTl.iX, aCodeBlock.iWidth ) * aCodeBlock.iWidth;
+    TInt32 y0 = TJ2kUtils::FloorL( iPacketCanvas.iTl.iY, aCodeBlock.iHeight ) * aCodeBlock.iHeight;
+    TInt32 x1 = TJ2kUtils::CeilL( iPacketCanvas.iTl.iX + iPacketCanvas.Width(), aCodeBlock.iWidth ) * aCodeBlock.iWidth;
+    TInt32 y1 = TJ2kUtils::CeilL( iPacketCanvas.iTl.iY + iPacketCanvas.Height(), aCodeBlock.iHeight ) * aCodeBlock.iHeight;
     iCodeBlockSize.iWidth  = ( x1 - x0 ) / aCodeBlock.iWidth;
     iCodeBlockSize.iHeight = ( y1 - y0 ) / aCodeBlock.iHeight;
     }
@@ -237,6 +237,7 @@
                         while ( subband->SubbandType() != aSubband.LastSubbandProcessed() )
                             {
                             subband = subband->NextSubbandRaster();
+                            User::LeaveIfNull(subband);
                             }
                         }
                     }
@@ -865,6 +866,7 @@
                 while ( subband->SubbandType() != aSubband.LastSubbandProcessed() )
                     {
                     subband = subband->NextSubbandRaster();
+                    User::LeaveIfNull(subband); 
                     }
                 }
             }
@@ -877,9 +879,10 @@
         TUint16 layer = aTile.LastLayerProcessed();
         TInt32  totalLength = 0;
         TUint8 *rollbackPtr = CONST_CAST( TUint8*, reader.iPtr );
+        CJ2kCodeBlock *codeBlock = 0;
         
-        CJ2kPacket *packet = CONST_CAST( CJ2kPacket*, &subband->PacketAt( aSubband.LastPacketProcessed() ) );
-        CJ2kCodeBlock *codeBlock = 0;
+        CJ2kPacket * packet = CONST_CAST( CJ2kPacket*, &subband->PacketAt( aSubband.LastPacketProcessed() ) );
+        
         do
             {
         
--- a/imagingmodules/jp2kcodec/Src/JP2KSubband.cpp	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KSubband.cpp	Sat Feb 20 00:07:53 2010 +0200
@@ -248,10 +248,10 @@
 
             denom = 1 << ( aComponent.Levels() - resLevel );
 
-            trx0 = TJ2kUtils::Ceil( aComponent.ComponentCanvas().iTl.iX, denom );
-            try0 = TJ2kUtils::Ceil( aComponent.ComponentCanvas().iTl.iY, denom );
-            trx1 = TJ2kUtils::Ceil( aComponent.ComponentCanvas().iBr.iX, denom );
-            try1 = TJ2kUtils::Ceil( aComponent.ComponentCanvas().iBr.iY, denom );
+            trx0 = TJ2kUtils::CeilL( aComponent.ComponentCanvas().iTl.iX, denom );
+            try0 = TJ2kUtils::CeilL( aComponent.ComponentCanvas().iTl.iY, denom );
+            trx1 = TJ2kUtils::CeilL( aComponent.ComponentCanvas().iBr.iX, denom );
+            try1 = TJ2kUtils::CeilL( aComponent.ComponentCanvas().iBr.iY, denom );
 
             nOrig = ( trx0 / (  1 << ppxL  ) ) * ( 1 << ppxL );
             mOrig = ( try0 / (  1 << ppyL  ) ) * ( 1 << ppyL );
@@ -295,7 +295,7 @@
                                 packetIndex = ( TUint16 )( yIndex * tmpSize.iWidth + xIndex );
                                 packet = subband->iPacketList[packetIndex];
                                 packet->SetPacketCanvas( trx0, try0, trx1, try1 );
-                                packet->SetNumOfBlocks( cblkSize );
+                                packet->SetNumOfBlocksL( cblkSize );
                                 packet->BuildCodeBlocksL( xCoord, yCoord, cblkSize );
                                 }
                             xCoord += tmpX;
--- a/imagingmodules/jp2kcodec/Src/JP2KTileInfo.cpp	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KTileInfo.cpp	Sat Feb 20 00:07:53 2010 +0200
@@ -84,10 +84,10 @@
 void CJ2kTileInfo::InitializeL()
     {
     const TSizMarker &sizMarker = iImageInfo.SizMarker();
-    TUint16 numOfHorizTiles = iImageInfo.NumOfHorizTiles();
+    TUint16 numOfHorizTiles = iImageInfo.NumOfHorizTilesL();
 
     // Calculate the tile canvas
-    TDiv    tDiv = TJ2kUtils::Div( iSot.iIsot, numOfHorizTiles );
+    TDiv    tDiv = TJ2kUtils::DivL( iSot.iIsot, numOfHorizTiles );
     iTileCanvas.iTl = TPoint( Max( sizMarker.iXTOsiz + tDiv.rem * sizMarker.iXTsiz, sizMarker.iXOsiz ),
                               Max( sizMarker.iYTOsiz + tDiv.quot * sizMarker.iYTsiz, sizMarker.iYOsiz ) );
     iTileCanvas.iBr = TPoint( Min( sizMarker.iXTOsiz + ( tDiv.rem + 1 ) * sizMarker.iXTsiz, sizMarker.iXsiz ),
--- a/imagingmodules/jp2kcodec/Src/JP2KUtils.cpp	Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KUtils.cpp	Sat Feb 20 00:07:53 2010 +0200
@@ -47,12 +47,12 @@
 // ============================ MEMBER FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
-// TJ2kUtils::Ceil
+// TJ2kUtils::CeilL
 // Get the ceiling between two integers.
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-TInt32 TJ2kUtils::Ceil( TInt32 aL, TInt32 aR )
+TInt32 TJ2kUtils::CeilL( TInt32 aL, TInt32 aR )
     {
     // Check that no divided by zero calculation are done.
     if ( aR == 0 )
@@ -84,12 +84,12 @@
     }
 
 // -----------------------------------------------------------------------------
-// TJ2kUtils::Floor
+// TJ2kUtils::FloorL
 // Get the floor between two integers.
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-TInt32 TJ2kUtils::Floor( TInt32 aL, TInt32 aR )
+TInt32 TJ2kUtils::FloorL( TInt32 aL, TInt32 aR )
     {
     // Check that no divided by zero calculation are done.
     if ( aR == 0 )
@@ -108,12 +108,12 @@
     }
 
 // -----------------------------------------------------------------------------
-// TJ2kUtils::Div
+// TJ2kUtils::DivL
 // Get the quotient and remainder.
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-TDiv TJ2kUtils::Div( TInt aNum, TInt aDenom )
+TDiv TJ2kUtils::DivL( TInt aNum, TInt aDenom )
     {
     // Check that no divided by zero calculation are done.
     if ( aDenom == 0 )