--- a/imagingmodules/jp2kcodec/Src/JP2KCodec.cpp Thu Dec 17 09:22:31 2009 +0200
+++ b/imagingmodules/jp2kcodec/Src/JP2KCodec.cpp Fri Mar 19 09:58:47 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;