imagingmodules/jp2kcodec/Src/JP2KSubband.cpp
changeset 0 469c91dae73b
child 4 3993b8f65362
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 // INCLUDE FILES
       
    21 #include <icl/imagecodec.h>
       
    22 #include "JP2KImageUtils.h"
       
    23 #include "JP2KFormat.h"
       
    24 #include "JP2KStreamReader.h"
       
    25 #include "JP2KTileInfo.h"
       
    26 #include "JP2KImageInfo.h"
       
    27 #include "JP2KCodec.h"
       
    28 #include "JP2KPacket.h"
       
    29 #include "JP2KSubband.h"
       
    30 #include "JP2KComponentInfo.h"
       
    31 
       
    32 // EXTERNAL DATA STRUCTURES
       
    33 
       
    34 // EXTERNAL FUNCTION PROTOTYPES  
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 // MACROS
       
    39 
       
    40 // LOCAL CONSTANTS AND MACROS
       
    41 
       
    42 // MODULE DATA STRUCTURES
       
    43 
       
    44 // LOCAL FUNCTION PROTOTYPES
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 
       
    48 // ============================ MEMBER FUNCTIONS ===============================
       
    49 
       
    50 // Destructor
       
    51 CJ2kSubband::~CJ2kSubband()
       
    52     {
       
    53     iPacketList.ResetAndDestroy();
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CJ2kSubband::BuildSubbandTreeL
       
    58 // Static method to set up the tree structure of the DWT subbands.
       
    59 // ( other items were commented in a header ).
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CJ2kSubband* CJ2kSubband::BuildSubbandTreeL( TUint8 aMaxLevel, CJ2kComponentInfo& aComponent )
       
    63     {
       
    64     CJ2kSubband *root = CJ2kSubbandLL::NewLC();
       
    65     root->iLevel = 0;
       
    66 
       
    67     // The root subband, LLO, original image
       
    68     root->iResLevel = (TUint8)( aMaxLevel + 1 ); 
       
    69     root->iSubbandCanvas = aComponent.ComponentCanvas();
       
    70     root->iHighPassFirst = TPoint( root->iSubbandCanvas.iTl.iX % 2,
       
    71                                    root->iSubbandCanvas.iTl.iY % 2 );
       
    72     CJ2kSubband *start = root;
       
    73     CJ2kSubband *tmpLL = 0;
       
    74     CJ2kSubband *tmpHL = 0;
       
    75     CJ2kSubband *tmpLH = 0;
       
    76     CJ2kSubband *tmpHH = 0;
       
    77 
       
    78     for ( TUint8 index = 1; index <= aMaxLevel; ++index )
       
    79         {
       
    80         // Must be built in the following order - LL, HL, LH, and HH
       
    81         // where all of them share the same parent - next lower LL
       
    82         // but only the LL subband can be further sub-divided into
       
    83         // lower resolution subband
       
    84         // create LL subband
       
    85         TUint8 highPassFirstX = (TUint8)( start->iHighPassFirst.iX );
       
    86         TUint8 highPassFirstY = (TUint8)( start->iHighPassFirst.iY );
       
    87 
       
    88         tmpLL = CJ2kSubbandLL::NewLC();
       
    89         tmpLL->iLevel = index;
       
    90         tmpLL->iResLevel = (TUint8)( aMaxLevel - index + 1 );
       
    91 
       
    92         tmpLL->iSubbandCanvas.iTl = TPoint( (TUint32)( start->iSubbandCanvas.iTl.iX + 1 ) >> 1,
       
    93                                             (TUint32)( start->iSubbandCanvas.iTl.iY + 1 ) >> 1 );
       
    94 
       
    95         tmpLL->iSubbandCanvas.SetWidth( ( start->iSubbandCanvas.Width() + ( 1-highPassFirstX ) ) / 2 );
       
    96 
       
    97         tmpLL->iSubbandCanvas.SetHeight( ( start->iSubbandCanvas.Height() + ( 1-highPassFirstY ) ) / 2 );
       
    98 
       
    99         tmpLL->iHighPassFirst = TPoint( tmpLL->iSubbandCanvas.iTl.iX % 2,
       
   100                                         tmpLL->iSubbandCanvas.iTl.iY % 2 );
       
   101         start->AddChildL( tmpLL );
       
   102         CleanupStack::Pop();
       
   103 
       
   104         // Create HL subband
       
   105         tmpHL = CJ2kSubbandNLL::NewLC();
       
   106         tmpHL->iType = EBandHL;
       
   107         tmpHL->iLevel = index;
       
   108         tmpHL->iGain  = 1;
       
   109         tmpHL->iResLevel = tmpLL->iResLevel;
       
   110         tmpHL->iSubbandCanvas.iTl = TPoint( (TUint32)start->iSubbandCanvas.iTl.iX >> 1,
       
   111                                             (TUint32)( start->iSubbandCanvas.iTl.iY + 1 ) >> 1 );
       
   112         tmpHL->iSubbandCanvas.SetWidth( ( start->iSubbandCanvas.Width() + highPassFirstX ) / 2 );
       
   113         tmpHL->iSubbandCanvas.SetHeight( tmpLL->iSubbandCanvas.Height() );
       
   114         tmpHL->iSubbandOrigin.iX = start->iSubbandOrigin.iX + ( ( start->iSubbandCanvas.Width() + ( 1-highPassFirstX ) ) / 2 );
       
   115         tmpHL->iSubbandOrigin.iY = start->iSubbandOrigin.iY;
       
   116         start->AddChildL( tmpHL );
       
   117         CleanupStack::Pop();
       
   118 
       
   119         // Create LH subband
       
   120         tmpLH = CJ2kSubbandNLL::NewLC();
       
   121         tmpLH->iType = EBandLH;
       
   122         tmpLH->iLevel = index;
       
   123         tmpLH->iGain  = 1;
       
   124         tmpLH->iResLevel = tmpLL->iResLevel;
       
   125         tmpLH->iSubbandCanvas.iTl = TPoint( (TUint32)( start->iSubbandCanvas.iTl.iX + 1 ) >> 1,
       
   126                                            (TUint32)start->iSubbandCanvas.iTl.iY >> 1 );
       
   127         tmpLH->iSubbandCanvas.SetWidth( tmpLL->iSubbandCanvas.Width() );
       
   128 
       
   129         tmpLH->iSubbandCanvas.SetHeight( ( start->iSubbandCanvas.Height() + highPassFirstY ) / 2 );
       
   130         tmpLH->iSubbandOrigin.iX = start->iSubbandOrigin.iX;
       
   131 
       
   132         tmpLH->iSubbandOrigin.iY = start->iSubbandOrigin.iY + ( ( start->iSubbandCanvas.Height() + ( 1-highPassFirstY ) ) / 2 );
       
   133         start->AddChildL( tmpLH );
       
   134         CleanupStack::Pop();
       
   135 
       
   136         // Create HH subband
       
   137         tmpHH = CJ2kSubbandNLL::NewLC();
       
   138         tmpHH->iType = EBandHH;
       
   139         tmpHH->iLevel = index;
       
   140         tmpHH->iGain  = 2;
       
   141         tmpHH->iResLevel = tmpLL->iResLevel;
       
   142         tmpHH->iSubbandCanvas.iTl = TPoint( ( TUint32 )start->iSubbandCanvas.iTl.iX >> 1,
       
   143                                            ( TUint32 )start->iSubbandCanvas.iTl.iY >> 1 );
       
   144         tmpHH->iSubbandCanvas.SetWidth( tmpHL->iSubbandCanvas.Width() );
       
   145         tmpHH->iSubbandCanvas.SetHeight( tmpLH->iSubbandCanvas.Height() );
       
   146         tmpHH->iSubbandOrigin.iX = tmpHL->iSubbandOrigin.iX;
       
   147         tmpHH->iSubbandOrigin.iY = tmpLH->iSubbandOrigin.iY;
       
   148         start->AddChildL( tmpHH );
       
   149         CleanupStack::Pop();
       
   150 
       
   151         start = start->ChildAt( EBandLL );
       
   152         }
       
   153 
       
   154     // The lowest resolution must be 0, so reset
       
   155     // the resolution of NLL from 1 to 0.
       
   156     start->iResLevel = 0;
       
   157 
       
   158     CleanupStack::Pop();
       
   159     return root;
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CJ2kSubband::BuildPacketsL
       
   164 // Build the possible packets that may be in the subband
       
   165 // (other items were commented in a header).
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CJ2kSubband::BuildPacketsL( CJ2kComponentInfo& aComponent, HBufC8 *aPrecinctSiz, TUint16 aLayer )
       
   169     {
       
   170     CJ2kSubband *subband = 0;
       
   171     CJ2kPacket  *packet = 0;
       
   172     TUint16 packetIndex = 0;
       
   173     TUint16 xIndex = 0;
       
   174     TUint16 yIndex = 0;
       
   175     TInt    denom = 0;
       
   176     TInt    ppx = 0;
       
   177     TInt    ppy = 0;
       
   178     TInt    ppxL = 0;
       
   179     TInt    ppyL = 0;
       
   180     TInt32  trx0 = 0;
       
   181     TInt32  try0 = 0;
       
   182     TInt32  trx1 = 0;
       
   183     TInt32  try1 = 0;
       
   184     TInt32  n = 0;
       
   185     TInt32  m = 0;
       
   186     TInt32  nOrig = 0;
       
   187     TInt32  mOrig = 0;
       
   188     TInt32  xCoord = 0;
       
   189     TInt32  yCoord = 0;
       
   190     TInt32  numOfPackets = 0;
       
   191     TInt32  tmpX = 0;
       
   192     TInt32  tmpY = 0;
       
   193     TSize   cblkSize( 0, 0 );
       
   194     TSize   tmpSize( 0, 0 );
       
   195 
       
   196     const TSize &compSize = aComponent.CodeBlockSize();
       
   197     TInt  compSizeLogWidth = TJ2kUtils::Log2( compSize.iWidth );
       
   198     TInt  compSizeLogHeight = TJ2kUtils::Log2( compSize.iHeight );
       
   199 
       
   200     for ( TUint8 resLevel = 0; resLevel <= aComponent.Levels(); ++resLevel )
       
   201         {
       
   202         subband = SubbandAt( resLevel );
       
   203         numOfPackets = aComponent.NumOfPackets( resLevel );
       
   204         if ( numOfPackets )
       
   205             {
       
   206             do
       
   207                 {
       
   208                 for ( packetIndex = 0; packetIndex < numOfPackets; ++packetIndex )
       
   209                     {
       
   210                     CJ2kPacket *packet = new ( ELeave ) CJ2kPacket( aLayer );   //lint !e578  must be declared also earlier.
       
   211                     CleanupStack::PushL( packet );
       
   212                     
       
   213                     User::LeaveIfError( subband->iPacketList.Append( packet ) );
       
   214                     CleanupStack::Pop( 1 );
       
   215 
       
   216                     if ( subband->iType == EBandLL || subband->iType == EBandHL )
       
   217                         {
       
   218                         subband->iPacketList[packetIndex]->BuildInclusiveInfoL();
       
   219                         }
       
   220                     }
       
   221                 subband = subband->NextSubbandRaster();
       
   222                 } while ( subband );
       
   223 
       
   224             // Set to the default
       
   225             ppx = ppy = 15;
       
   226 
       
   227             if ( aPrecinctSiz )
       
   228                 {
       
   229                 ppxL = ( *aPrecinctSiz )[resLevel] & 0x0f;
       
   230                 ppyL = ( ( *aPrecinctSiz )[resLevel] & 0xf0 ) >> 4;
       
   231                 }
       
   232             else
       
   233                 {
       
   234                 ppxL = ppyL = 15;
       
   235                 }
       
   236 
       
   237             if ( ppxL != 15 || ppyL != 15 )
       
   238                 {
       
   239                 ppx = ( resLevel ) ? ppxL - 1 : ppxL;
       
   240                 ppy = ( resLevel ) ? ppyL - 1 : ppyL;
       
   241                 cblkSize.iWidth = ( compSizeLogWidth < ppx ) ? compSize.iWidth : 1 << ppx;
       
   242                 cblkSize.iHeight = ( compSizeLogHeight < ppy ) ? compSize.iHeight : 1 << ppy;
       
   243                 }
       
   244             else
       
   245                 {
       
   246                 cblkSize = compSize;
       
   247                 }
       
   248 
       
   249             denom = 1 << ( aComponent.Levels() - resLevel );
       
   250 
       
   251             trx0 = TJ2kUtils::Ceil( aComponent.ComponentCanvas().iTl.iX, denom );
       
   252             try0 = TJ2kUtils::Ceil( aComponent.ComponentCanvas().iTl.iY, denom );
       
   253             trx1 = TJ2kUtils::Ceil( aComponent.ComponentCanvas().iBr.iX, denom );
       
   254             try1 = TJ2kUtils::Ceil( aComponent.ComponentCanvas().iBr.iY, denom );
       
   255 
       
   256             nOrig = ( trx0 / (  1 << ppxL  ) ) * ( 1 << ppxL );
       
   257             mOrig = ( try0 / (  1 << ppyL  ) ) * ( 1 << ppyL );
       
   258 
       
   259             // First subband at this resolution level
       
   260             // at r = 0, it will be nLL
       
   261             // at r > 0, it will be ( n-r+1 )HL
       
   262 
       
   263             tmpSize = aComponent.PrecinctSizeAt( resLevel );
       
   264             tmpX = 1 << ppx;
       
   265             tmpY = 1 << ppy;
       
   266             subband = SubbandAt( resLevel ); 
       
   267             do
       
   268                 {
       
   269                 if ( subband->SubbandCanvasSize().iWidth > 0 &&
       
   270                     subband->SubbandCanvasSize().iHeight > 0 )
       
   271                     {
       
   272                     n = nOrig;
       
   273                     m = mOrig;
       
   274 
       
   275                     if ( subband->iType != EBandLL )
       
   276                         {
       
   277                         n /= 2;
       
   278                         m /= 2;
       
   279                         }
       
   280 
       
   281                     yCoord = m;
       
   282                     for ( yIndex = 0; yIndex < tmpSize.iHeight; ++yIndex )
       
   283                         {
       
   284                         xCoord = n;
       
   285                         for ( xIndex = 0; xIndex < tmpSize.iWidth; ++xIndex )
       
   286                             {
       
   287                             // Reuse the variables trx0, trx1, try0, try1
       
   288                             trx0 = Max( subband->SubbandCanvas().iTl.iX, xCoord );
       
   289                             try0 = Max( subband->SubbandCanvas().iTl.iY, yCoord );
       
   290                             trx1 = Min( xCoord + tmpX, subband->SubbandCanvas().iBr.iX ) - trx0;
       
   291                             try1 = Min( yCoord + tmpY, subband->SubbandCanvas().iBr.iY ) - try0;
       
   292 
       
   293                             if ( trx1 > 0 && try1 > 0 )
       
   294                                 {
       
   295                                 packetIndex = ( TUint16 )( yIndex * tmpSize.iWidth + xIndex );
       
   296                                 packet = subband->iPacketList[packetIndex];
       
   297                                 packet->SetPacketCanvas( trx0, try0, trx1, try1 );
       
   298                                 packet->SetNumOfBlocks( cblkSize );
       
   299                                 packet->BuildCodeBlocksL( xCoord, yCoord, cblkSize );
       
   300                                 }
       
   301                             xCoord += tmpX;
       
   302                             } // end of xIndex
       
   303                         yCoord += tmpY;
       
   304                         } // end of yIndex
       
   305                     } // precinct size is greater than 0
       
   306                 subband = subband->NextSubbandRaster();
       
   307                 } while ( subband );
       
   308             } // num of packets is greater than 0
       
   309         } // end of resolution level
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // CJ2kSubband::LRCPProgressionL
       
   314 // At each subband, parse the bitstream with LRCP progression order
       
   315 // (other items were commented in a header).
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 TUint8 CJ2kSubband::LRCPProgressionL( CJ2kTileInfo& aTile, CJ2kComponentInfo& aComponent )
       
   319     {
       
   320     TUint8  incomplete = EFalse;
       
   321     TUint16 marker = 0;
       
   322     const TJ2kStreamReader& reader = aTile.StreamReader();
       
   323     while ( iLastPacket < iPacketList.Count() )
       
   324         {       
       
   325         if ( aTile.IsPOC() )
       
   326             {
       
   327             marker = PtrReadUtil::ReadBigEndianUint16( reader.iPtr );
       
   328             if ( marker == KSOT || marker == KEOC )
       
   329                 {
       
   330                 break;   //lint !e960    Break is OK.
       
   331                 }
       
   332             }
       
   333 
       
   334         incomplete = iPacketList[iLastPacket]->ReadPacketHeaderL( aTile, aComponent, *this );
       
   335         if ( incomplete )
       
   336             {
       
   337             // Underflow
       
   338             break;   //lint !e960    Break is OK.
       
   339             }
       
   340         if ( iPacketList[iLastPacket]->IsBodyIncomplete() )
       
   341             {
       
   342             incomplete = iPacketList[iLastPacket]->ReadPacketBodyL( aTile, aComponent, *this );
       
   343             if ( incomplete )
       
   344                 {
       
   345                 // Underflow
       
   346                 break;   //lint !e960    Break is OK.
       
   347                 }
       
   348             }
       
   349         iPacketList[iLastPacket]->ResetInternalFlags();
       
   350         ++iLastPacket;
       
   351         }
       
   352 
       
   353     if ( !incomplete && iLastPacket == iPacketList.Count() )
       
   354         {
       
   355         // Reset it back to 0 for the next layer
       
   356         iLastPacket = 0;
       
   357         }
       
   358 
       
   359     return incomplete;
       
   360     }
       
   361 
       
   362 // -----------------------------------------------------------------------------
       
   363 // CJ2kSubband::RPCLProgressionL
       
   364 // At each subband, parse the bitstream with RPCL progression order
       
   365 // (other items were commented in a header).
       
   366 // -----------------------------------------------------------------------------
       
   367 //
       
   368 TUint8 CJ2kSubband::RPCLProgressionL( CJ2kTileInfo& aTile, CJ2kComponentInfo& aComponent )
       
   369     {
       
   370     TUint8  incomplete = EFalse;
       
   371     TUint16 numOfLayers = aTile.NumOfLayersPOC();
       
   372     TUint16 marker = 0;
       
   373     const TJ2kStreamReader& reader = aTile.StreamReader();
       
   374     while ( aTile.LastLayerProcessed() < numOfLayers )
       
   375         {
       
   376         if ( iPacketList.Count() )
       
   377             {
       
   378             if ( aTile.IsPOC() )
       
   379                 {
       
   380                 marker = PtrReadUtil::ReadBigEndianUint16( reader.iPtr );
       
   381                 if ( marker == KSOT || marker == KEOC )
       
   382                     {
       
   383                     break;   //lint !e960    Break is OK.
       
   384                     }
       
   385                 }
       
   386 
       
   387             incomplete = iPacketList[iLastPacket]->ReadPacketHeaderL( aTile, aComponent, *this );
       
   388             if ( incomplete )
       
   389                 {
       
   390                 // Underflow
       
   391                 break;   //lint !e960    Break is OK.
       
   392                 }
       
   393             if ( iPacketList[iLastPacket]->IsBodyIncomplete() )
       
   394                 {
       
   395                 incomplete = iPacketList[iLastPacket]->ReadPacketBodyL( aTile, aComponent, *this );
       
   396                 if ( incomplete )
       
   397                     {
       
   398                     // Underflow
       
   399                     break;   //lint !e960    Break is OK.
       
   400                     }
       
   401                 }
       
   402             iPacketList[iLastPacket]->ResetInternalFlags();
       
   403             }
       
   404         aTile.IncrementLastLayerProcessed();
       
   405         }
       
   406 
       
   407     if ( !incomplete && aTile.LastLayerProcessed() == numOfLayers )
       
   408         {
       
   409         aTile.ResetLastLayerProcessed();
       
   410         ++iLastPacket;
       
   411         if ( iLastPacket == iPacketList.Count() )
       
   412             {
       
   413             iLastPacket = 0;
       
   414             }
       
   415         }
       
   416     return incomplete;
       
   417     }
       
   418 
       
   419 // -----------------------------------------------------------------------------
       
   420 // CJ2kSubband::CPRLProgressionL
       
   421 // At each subband, parse the bitstream with CPRL progression order.
       
   422 // (other items were commented in a header).
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 TUint8 CJ2kSubband::CPRLProgressionL( CJ2kTileInfo& aTile, CJ2kComponentInfo& aComponent )
       
   426     {
       
   427     TUint8  incomplete = EFalse;
       
   428     TUint16 numOfLayers = aTile.NumOfLayersPOC();
       
   429     TUint16 marker = 0;
       
   430     const TJ2kStreamReader& reader = aTile.StreamReader();
       
   431     while ( aTile.LastLayerProcessed() < numOfLayers )
       
   432         {
       
   433         if ( iPacketList.Count() )
       
   434             {
       
   435             if ( aTile.IsPOC() )
       
   436                 {
       
   437                 marker = PtrReadUtil::ReadBigEndianUint16( reader.iPtr );
       
   438                 if ( marker == KSOT || marker == KEOC )
       
   439                     {
       
   440                     break;   //lint !e960    Break is OK.
       
   441                     }
       
   442                 }
       
   443 
       
   444             incomplete = iPacketList[iLastPacket]->ReadPacketHeaderL( aTile, aComponent, *this );
       
   445             if ( incomplete )
       
   446                 {
       
   447                 // Underflow
       
   448                 break;   //lint !e960    Break is OK.
       
   449                 }
       
   450             if ( iPacketList[iLastPacket]->IsBodyIncomplete() )
       
   451                 {
       
   452                 incomplete = iPacketList[iLastPacket]->ReadPacketBodyL( aTile, aComponent, *this );
       
   453                 if ( incomplete )
       
   454                     {
       
   455                     // Underflow
       
   456                     break;   //lint !e960    Break is OK.
       
   457                     }
       
   458                 }
       
   459             iPacketList[iLastPacket]->ResetInternalFlags();
       
   460             }
       
   461         aTile.IncrementLastLayerProcessed();
       
   462         }
       
   463 
       
   464     if ( !incomplete && aTile.LastLayerProcessed() == numOfLayers )
       
   465         {
       
   466         aTile.ResetLastLayerProcessed();
       
   467         ++iLastPacket;
       
   468         if ( iLastPacket == iPacketList.Count() )
       
   469             {
       
   470             iLastPacket = 0;
       
   471             }
       
   472         }
       
   473     return incomplete;
       
   474     }
       
   475 
       
   476 // -----------------------------------------------------------------------------
       
   477 // CJ2kSubband::ChildAt
       
   478 // Get the child subband at specific index
       
   479 // (other items were commented in a header).
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 CJ2kSubband* CJ2kSubband::ChildAt( TInt /*aBand*/ )
       
   483     {
       
   484     return 0;
       
   485     }
       
   486 
       
   487 // -----------------------------------------------------------------------------
       
   488 // CJ2kSubband::NextSubbandRaster
       
   489 // Get the sibling subband
       
   490 // (other items were commented in a header).
       
   491 // -----------------------------------------------------------------------------
       
   492 //
       
   493 CJ2kSubband* CJ2kSubband::NextSubbandRaster()
       
   494     {
       
   495     return 0;
       
   496     }
       
   497 
       
   498 // -----------------------------------------------------------------------------
       
   499 // CJ2kSubband::SubbandAt
       
   500 // Get the subband at specific resolution level
       
   501 // (other items were commented in a header).
       
   502 // -----------------------------------------------------------------------------
       
   503 //
       
   504 CJ2kSubband* CJ2kSubband::SubbandAt( TUint8 /*aResLevel*/ )
       
   505     {
       
   506     return 0;
       
   507     }
       
   508 
       
   509 // -----------------------------------------------------------------------------
       
   510 // CJ2kSubband::AddChildL
       
   511 // Add the child subband into the list of child subbands ( No-op )
       
   512 // -----------------------------------------------------------------------------
       
   513 //
       
   514 void CJ2kSubband::AddChildL( CJ2kSubband* /*aChild*/ )
       
   515     {    }
       
   516 
       
   517 // -----------------------------------------------------------------------------
       
   518 // CJ2kSubband::SubbandTreeIndex
       
   519 // Get the subband tree index
       
   520 // (other items were commented in a header).
       
   521 // -----------------------------------------------------------------------------
       
   522 //
       
   523 TUint16 CJ2kSubband::SubbandTreeIndex() const
       
   524     {
       
   525     TUint16 bandIndex = 0;
       
   526     if ( iResLevel )
       
   527         {
       
   528         bandIndex = ( TUint16 )( ( iResLevel - 1 ) * 3 + iType );
       
   529         }
       
   530 
       
   531     return bandIndex;
       
   532     }
       
   533 
       
   534 // -----------------------------------------------------------------------------
       
   535 // CJ2kSubband::CJ2kSubband
       
   536 // C++ default constructor can NOT contain any code, that
       
   537 // might leave.
       
   538 // -----------------------------------------------------------------------------
       
   539 //
       
   540 CJ2kSubband::CJ2kSubband() : 
       
   541     iPacketList( 1 )
       
   542     {
       
   543     }
       
   544 
       
   545 // -----------------------------------------------------------------------------
       
   546 // CJ2kSubbandLL::NewL
       
   547 // Two-phased constructor.
       
   548 // -----------------------------------------------------------------------------
       
   549 //
       
   550 CJ2kSubbandLL* CJ2kSubbandLL::NewLC()
       
   551     {
       
   552     CJ2kSubbandLL* self = new ( ELeave ) CJ2kSubbandLL();
       
   553 
       
   554     CleanupStack::PushL( self );
       
   555     self->iType = EBandLL;
       
   556 
       
   557     return self;
       
   558     }
       
   559     
       
   560 // Destructor
       
   561 CJ2kSubbandLL::~CJ2kSubbandLL()
       
   562     {
       
   563     iChildList.ResetAndDestroy();
       
   564     }
       
   565 
       
   566 // -----------------------------------------------------------------------------
       
   567 // CJ2kSubbandLL::ChildAt
       
   568 // Get the child subband at specific index
       
   569 // (other items were commented in a header).
       
   570 // -----------------------------------------------------------------------------
       
   571 //
       
   572 CJ2kSubband* CJ2kSubbandLL::ChildAt( TInt aBand )
       
   573     {
       
   574     if ( iChildList.Count() > 0 )
       
   575         {
       
   576         return iChildList[aBand];
       
   577         }
       
   578 
       
   579     return 0;
       
   580     }
       
   581 
       
   582 // -----------------------------------------------------------------------------
       
   583 // CJ2kSubbandLL::SubbandAt
       
   584 // Get the subband at specific resolution level
       
   585 // (other items were commented in a header).
       
   586 // -----------------------------------------------------------------------------
       
   587 //
       
   588 CJ2kSubband* CJ2kSubbandLL::SubbandAt( TUint8 aResLevel )
       
   589     {
       
   590     if ( iResLevel > aResLevel )
       
   591         {
       
   592         return ChildAt( EBandLL )->SubbandAt( aResLevel );
       
   593         }
       
   594     if ( iResLevel == 0 && aResLevel == 0 )
       
   595         {
       
   596         return this;
       
   597         }
       
   598     else
       
   599         {
       
   600         return Parent()->ChildAt( EBandHL );
       
   601         }
       
   602     }
       
   603 
       
   604 // -----------------------------------------------------------------------------
       
   605 // CJ2kSubbandLL::AddChildL
       
   606 // Add the child subband into the list of child subbands
       
   607 // (other items were commented in a header).
       
   608 // -----------------------------------------------------------------------------
       
   609 //
       
   610 void CJ2kSubbandLL::AddChildL( CJ2kSubband* aChild )
       
   611     {
       
   612     aChild->SetParent( this );
       
   613     User::LeaveIfError( iChildList.Append( aChild ) );
       
   614     }
       
   615 
       
   616 // -----------------------------------------------------------------------------
       
   617 // CJ2kSubbandNLL::NewL
       
   618 // Two-phased constructor.
       
   619 // -----------------------------------------------------------------------------
       
   620 //
       
   621 CJ2kSubbandNLL* CJ2kSubbandNLL::NewLC()
       
   622     {
       
   623     CJ2kSubbandNLL* self = new ( ELeave ) CJ2kSubbandNLL();
       
   624     CleanupStack::PushL( self );
       
   625     return self;
       
   626     }
       
   627 
       
   628 // Destructor
       
   629 CJ2kSubbandNLL::~CJ2kSubbandNLL()
       
   630     { 
       
   631     }
       
   632 
       
   633 // -----------------------------------------------------------------------------
       
   634 // CJ2kSubbandNLL::NextSubbandRaster
       
   635 // Get the sibling subband
       
   636 // (other items were commented in a header).
       
   637 // -----------------------------------------------------------------------------
       
   638 //
       
   639 CJ2kSubband* CJ2kSubbandNLL::NextSubbandRaster()
       
   640     {
       
   641     CJ2kSubband *nextSubband = 0;
       
   642     switch ( iType )
       
   643         {
       
   644         case EBandHL:
       
   645             {
       
   646             nextSubband = Parent()->ChildAt( EBandLH );
       
   647             break;
       
   648             }
       
   649         case EBandLH:
       
   650             {
       
   651             nextSubband = Parent()->ChildAt( EBandHH );
       
   652             break;
       
   653             }
       
   654         default:
       
   655             {
       
   656             break;
       
   657             }
       
   658         }
       
   659 
       
   660     return nextSubband;
       
   661     }