Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/TDecSlice.cpp


Ignore:
Timestamp:
13 Aug 2015, 17:38:13 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibDecoder/TDecSlice.cpp

    r1179 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
    5  *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     4 * granted under this license.
     5 *
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4747TDecSlice::TDecSlice()
    4848{
    49   m_pcBufferSbacDecoders = NULL;
    50   m_pcBufferBinCABACs    = NULL;
    51   m_pcBufferLowLatSbacDecoders = NULL;
    52   m_pcBufferLowLatBinCABACs    = NULL;
    5349}
    5450
    5551TDecSlice::~TDecSlice()
    5652{
    57   for (std::vector<TDecSbac*>::iterator i = CTXMem.begin(); i != CTXMem.end(); i++)
    58   {
    59     delete (*i);
    60   }
    61   CTXMem.clear();
    62 }
    63 
    64 Void TDecSlice::initCtxMem(  UInt i )               
    65 {   
    66   for (std::vector<TDecSbac*>::iterator j = CTXMem.begin(); j != CTXMem.end(); j++)
    67   {
    68     delete (*j);
    69   }
    70   CTXMem.clear();
    71   CTXMem.resize(i);
    7253}
    7354
     
    7859Void TDecSlice::destroy()
    7960{
    80   if ( m_pcBufferSbacDecoders )
    81   {
    82     delete[] m_pcBufferSbacDecoders;
    83     m_pcBufferSbacDecoders = NULL;
    84   }
    85   if ( m_pcBufferBinCABACs )
    86   {
    87     delete[] m_pcBufferBinCABACs;
    88     m_pcBufferBinCABACs = NULL;
    89   }
    90   if ( m_pcBufferLowLatSbacDecoders )
    91   {
    92     delete[] m_pcBufferLowLatSbacDecoders;
    93     m_pcBufferLowLatSbacDecoders = NULL;
    94   }
    95   if ( m_pcBufferLowLatBinCABACs )
    96   {
    97     delete[] m_pcBufferLowLatBinCABACs;
    98     m_pcBufferLowLatBinCABACs = NULL;
    99   }
    10061}
    10162
     
    10667}
    10768
    108 Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders)
    109 {
    110   TComDataCU* pcCU;
    111   UInt        uiIsLast = 0;
    112   Int   iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU());
    113   Int   iStartCUAddr = rpcPic->getPicSym()->getCUOrderMap(iStartCUEncOrder);
    114 
    115   // decoder don't need prediction & residual frame buffer
    116   rpcPic->setPicYuvPred( 0 );
    117   rpcPic->setPicYuvResi( 0 );
    118  
     69Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic* pcPic, TDecSbac* pcSbacDecoder)
     70{
     71  TComSlice* pcSlice                 = pcPic->getSlice(pcPic->getCurrSliceIdx());
     72
     73  const Int  startCtuTsAddr          = pcSlice->getSliceSegmentCurStartCtuTsAddr();
     74  const Int  startCtuRsAddr          = pcPic->getPicSym()->getCtuTsToRsAddrMap(startCtuTsAddr);
     75  const UInt numCtusInFrame          = pcPic->getNumberOfCtusInFrame();
     76
     77  const UInt frameWidthInCtus        = pcPic->getPicSym()->getFrameWidthInCtus();
     78  const Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag();
     79  const Bool wavefrontsEnabled       = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag();
     80
     81  m_pcEntropyDecoder->setEntropyDecoder ( pcSbacDecoder  );
     82  m_pcEntropyDecoder->setBitstream      ( ppcSubstreams[0] );
     83  m_pcEntropyDecoder->resetEntropy      (pcSlice);
     84
     85  // decoder doesn't need prediction & residual frame buffer
     86  pcPic->setPicYuvPred( 0 );
     87  pcPic->setPicYuvResi( 0 );
     88
    11989#if ENC_DEC_TRACE
    12090  g_bJustDoIt = g_bEncDecTraceEnable;
    12191#endif
     92#if H_MV_ENC_DEC_TRAC
     93#if ENC_DEC_TRACE
     94  incSymbolCounter();
     95#endif
     96  DTRACE_CABAC_VL( g_nSymbolCounter );
     97#else
    12298  DTRACE_CABAC_VL( g_nSymbolCounter++ );
     99#endif
    123100  DTRACE_CABAC_T( "\tPOC: " );
    124   DTRACE_CABAC_V( rpcPic->getPOC() );
     101  DTRACE_CABAC_V( pcPic->getPOC() );
    125102#if H_MV_ENC_DEC_TRAC
    126103  DTRACE_CABAC_T( " Layer: " );
    127   DTRACE_CABAC_V( rpcPic->getLayerId() );
     104  DTRACE_CABAC_V( pcPic->getLayerId() );
    128105#endif
    129106  DTRACE_CABAC_T( "\n" );
     
    133110#endif
    134111
    135   UInt uiTilesAcross   = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
    136   TComSlice*  pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());
    137   Int  iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
    138 
    139   // delete decoders if already allocated in previous slice
    140   if (m_pcBufferSbacDecoders)
    141   {
    142     delete [] m_pcBufferSbacDecoders;
    143   }
    144   if (m_pcBufferBinCABACs)
    145   {
    146     delete [] m_pcBufferBinCABACs;
    147   }
    148   // allocate new decoders based on tile numbaer
    149   m_pcBufferSbacDecoders = new TDecSbac    [uiTilesAcross]; 
    150   m_pcBufferBinCABACs    = new TDecBinCABAC[uiTilesAcross];
    151   for (UInt ui = 0; ui < uiTilesAcross; ui++)
    152   {
    153     m_pcBufferSbacDecoders[ui].init(&m_pcBufferBinCABACs[ui]);
    154   }
    155   //save init. state
    156   for (UInt ui = 0; ui < uiTilesAcross; ui++)
    157   {
    158     m_pcBufferSbacDecoders[ui].load(pcSbacDecoder);
    159   }
    160 
    161   // free memory if already allocated in previous call
    162   if (m_pcBufferLowLatSbacDecoders)
    163   {
    164     delete [] m_pcBufferLowLatSbacDecoders;
    165   }
    166   if (m_pcBufferLowLatBinCABACs)
    167   {
    168     delete [] m_pcBufferLowLatBinCABACs;
    169   }
    170   m_pcBufferLowLatSbacDecoders = new TDecSbac    [uiTilesAcross]; 
    171   m_pcBufferLowLatBinCABACs    = new TDecBinCABAC[uiTilesAcross];
    172   for (UInt ui = 0; ui < uiTilesAcross; ui++)
    173   {
    174     m_pcBufferLowLatSbacDecoders[ui].init(&m_pcBufferLowLatBinCABACs[ui]);
    175   }
    176   //save init. state
    177   for (UInt ui = 0; ui < uiTilesAcross; ui++)
    178   {
    179     m_pcBufferLowLatSbacDecoders[ui].load(pcSbacDecoder);
    180   }
    181 
    182   UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
    183   //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU();
    184   UInt uiCol=0, uiLin=0, uiSubStrm=0;
    185 
    186   UInt uiTileCol;
    187   UInt uiTileStartLCU;
    188   UInt uiTileLCUX;
    189   Int iNumSubstreamsPerTile = 1; // if independent.
    190   Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
    191   uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr();
    192   if( depSliceSegmentsEnabled )
    193   {
    194     if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) &&
    195        iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr())
    196     {
    197       if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    198       {
    199         uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
    200         m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1]  );//2.LCU
    201         if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs  )
    202         {
    203           uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
    204           uiCol     = iStartCUAddr % uiWidthInLCUs;
    205           if(uiCol==uiTileLCUX)
    206           {
    207             CTXMem[0]->loadContexts(pcSbacDecoder);
    208           }
    209         }
    210       }
    211       pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1
    212       pcSbacDecoders[uiSubStrm].loadContexts(pcSbacDecoder);
    213     }
    214     else
    215     {
    216       if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    217       {
    218         CTXMem[1]->loadContexts(pcSbacDecoder);
    219       }
    220       CTXMem[0]->loadContexts(pcSbacDecoder);
    221     }
    222   }
    223 #if  H_3D
     112  // The first CTU of the slice is the first coded substream, but the global substream number, as calculated by getSubstreamForCtuAddr may be higher.
     113  // This calculates the common offset for all substreams in this slice.
     114  const UInt subStreamOffset=pcPic->getSubstreamForCtuAddr(startCtuRsAddr, true, pcSlice);
     115
     116
     117  if (depSliceSegmentsEnabled)
     118  {
     119    // modify initial contexts with previous slice segment if this is a dependent slice.
     120    const UInt startTileIdx=pcPic->getPicSym()->getTileIdxMap(startCtuRsAddr);
     121    const TComTile *pCurrentTile=pcPic->getPicSym()->getTComTile(startTileIdx);
     122    const UInt firstCtuRsAddrOfTile = pCurrentTile->getFirstCtuRsAddr();
     123
     124    if( pcSlice->getDependentSliceSegmentFlag() && startCtuRsAddr != firstCtuRsAddrOfTile)
     125    {
     126      if ( pCurrentTile->getTileWidthInCtus() >= 2 || !wavefrontsEnabled)
     127      {
     128        pcSbacDecoder->loadContexts(&m_lastSliceSegmentEndContextState);
     129      }
     130    }
     131  }
     132#if  NH_3D_DLT
    224133  if( pcSlice->getPPS()->getDLT() != NULL )
    225134  {
    226       assert( pcSlice->getSPS()->getBitDepthY() == pcSlice->getPPS()->getDLT()->getDepthViewBitDepth() );
    227   }
    228 #endif
    229   for( Int iCUAddr = iStartCUAddr; !uiIsLast && iCUAddr < rpcPic->getNumCUsInFrame(); iCUAddr = rpcPic->getPicSym()->xCalculateNxtCUAddr(iCUAddr) )
    230   {
    231     pcCU = rpcPic->getCU( iCUAddr );
    232     pcCU->initCU( rpcPic, iCUAddr );
    233     uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
    234     uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr();
    235     uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
    236     uiCol     = iCUAddr % uiWidthInLCUs;
    237     // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture.
    238     uiLin     = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs);
    239     // inherit from TR if necessary, select substream to use.
    240     if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ))
    241     {
    242       // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
    243       iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    244       uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(iCUAddr)*iNumSubstreamsPerTile
    245                   + uiLin%iNumSubstreamsPerTile;
    246       m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] );
    247       // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
    248       if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()))
    249       {
    250         // We'll sync if the TR is available.
    251         TComDataCU *pcCUUp = pcCU->getCUAbove();
    252         UInt uiWidthInCU = rpcPic->getFrameWidthInCU();
    253         TComDataCU *pcCUTR = NULL;
    254         if ( pcCUUp && ((iCUAddr%uiWidthInCU+1) < uiWidthInCU)  )
    255         {
    256           pcCUTR = rpcPic->getCU( iCUAddr - uiWidthInCU + 1 );
    257         }
    258         UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1);
    259 
    260         if ( (true/*bEnforceSliceRestriction*/ &&
    261              ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    262              ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr()) ||
    263              ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)))
    264              ))
    265            )
    266         {
    267           // TR not available.
    268         }
    269         else
    270         {
    271           // TR is available, we use it.
    272           pcSbacDecoders[uiSubStrm].loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );
    273         }
    274       }
    275       pcSbacDecoder->load(&pcSbacDecoders[uiSubStrm]);  //this load is used to simplify the code (avoid to change all the call to pcSbacDecoders)
    276     }
    277     else if ( pcSlice->getPPS()->getNumSubstreams() <= 1 )
    278     {
    279       // Set variables to appropriate values to avoid later code change.
    280       iNumSubstreamsPerTile = 1;
    281     }
    282 
    283     if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile.
    284          (iCUAddr!=0) && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU())
    285          && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU())
    286          ) // !1st in frame && !1st in slice
    287     {
    288       if (pcSlice->getPPS()->getNumSubstreams() > 1)
    289       {
    290         // We're crossing into another tile, tiles are independent.
    291         // When tiles are independent, we have "substreams per tile".  Each substream has already been terminated, and we no longer
    292         // have to perform it here.
    293         // For TILES_DECODER, there can be a header at the start of the 1st substream in a tile.  These are read when the substreams
    294         // are extracted, not here.
    295       }
    296       else
    297       {
    298         SliceType sliceType  = pcSlice->getSliceType();
    299         if (pcSlice->getCabacInitFlag())
    300         {
    301           switch (sliceType)
    302           {
    303           case P_SLICE:           // change initialization table to B_SLICE intialization
    304             sliceType = B_SLICE;
    305             break;
    306           case B_SLICE:           // change initialization table to P_SLICE intialization
    307             sliceType = P_SLICE;
    308             break;
    309           default     :           // should not occur
    310             assert(0);
    311           }
    312         }
    313         m_pcEntropyDecoder->updateContextTables( sliceType, pcSlice->getSliceQp() );
    314       }
    315      
     135      assert( pcSlice->getSPS()->getBitDepth( CHANNEL_TYPE_LUMA ) == pcSlice->getPPS()->getDLT()->getDepthViewBitDepth() );
     136  }
     137#endif
     138
     139  // for every CTU in the slice segment...
     140
     141  Bool isLastCtuOfSliceSegment = false;
     142  for( UInt ctuTsAddr = startCtuTsAddr; !isLastCtuOfSliceSegment && ctuTsAddr < numCtusInFrame; ctuTsAddr++)
     143  {
     144    const UInt ctuRsAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddr);
     145    const TComTile &currentTile = *(pcPic->getPicSym()->getTComTile(pcPic->getPicSym()->getTileIdxMap(ctuRsAddr)));
     146    const UInt firstCtuRsAddrOfTile = currentTile.getFirstCtuRsAddr();
     147    const UInt tileXPosInCtus = firstCtuRsAddrOfTile % frameWidthInCtus;
     148    const UInt tileYPosInCtus = firstCtuRsAddrOfTile / frameWidthInCtus;
     149    const UInt ctuXPosInCtus  = ctuRsAddr % frameWidthInCtus;
     150    const UInt ctuYPosInCtus  = ctuRsAddr / frameWidthInCtus;
     151    const UInt uiSubStrm=pcPic->getSubstreamForCtuAddr(ctuRsAddr, true, pcSlice)-subStreamOffset;
     152    TComDataCU* pCtu = pcPic->getCtu( ctuRsAddr );
     153    pCtu->initCtu( pcPic, ctuRsAddr );
     154
     155    m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] );
     156
     157    // set up CABAC contexts' state for this CTU
     158    if (ctuRsAddr == firstCtuRsAddrOfTile)
     159    {
     160      if (ctuTsAddr != startCtuTsAddr) // if it is the first CTU, then the entropy coder has already been reset
     161      {
     162        m_pcEntropyDecoder->resetEntropy(pcSlice);
     163      }
     164    }
     165    else if (ctuXPosInCtus == tileXPosInCtus && wavefrontsEnabled)
     166    {
     167      // Synchronize cabac probabilities with upper-right CTU if it's available and at the start of a line.
     168      if (ctuTsAddr != startCtuTsAddr) // if it is the first CTU, then the entropy coder has already been reset
     169      {
     170        m_pcEntropyDecoder->resetEntropy(pcSlice);
     171      }
     172      TComDataCU *pCtuUp = pCtu->getCtuAbove();
     173      if ( pCtuUp && ((ctuRsAddr%frameWidthInCtus+1) < frameWidthInCtus)  )
     174      {
     175        TComDataCU *pCtuTR = pcPic->getCtu( ctuRsAddr - frameWidthInCtus + 1 );
     176        if ( pCtu->CUIsFromSameSliceAndTile(pCtuTR) )
     177        {
     178          // Top-right is available, so use it.
     179          pcSbacDecoder->loadContexts( &m_entropyCodingSyncContextState );
     180        }
     181      }
    316182    }
    317183
     
    321187
    322188    if ( pcSlice->getSPS()->getUseSAO() )
    323       {
    324       SAOBlkParam& saoblkParam = (rpcPic->getPicSym()->getSAOBlkParam())[iCUAddr];
    325       if (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma())
    326       {
    327         Bool sliceEnabled[NUM_SAO_COMPONENTS];
    328         sliceEnabled[SAO_Y] = pcSlice->getSaoEnabledFlag();
    329         sliceEnabled[SAO_Cb]= sliceEnabled[SAO_Cr]= pcSlice->getSaoEnabledFlagChroma();
    330 
     189    {
     190      SAOBlkParam& saoblkParam = (pcPic->getPicSym()->getSAOBlkParam())[ctuRsAddr];
     191      Bool bIsSAOSliceEnabled = false;
     192      Bool sliceEnabled[MAX_NUM_COMPONENT];
     193      for(Int comp=0; comp < MAX_NUM_COMPONENT; comp++)
     194      {
     195        ComponentID compId=ComponentID(comp);
     196        sliceEnabled[compId] = pcSlice->getSaoEnabledFlag(toChannelType(compId)) && (comp < pcPic->getNumberValidComponents());
     197        if (sliceEnabled[compId])
     198        {
     199          bIsSAOSliceEnabled=true;
     200        }
     201        saoblkParam[compId].modeIdc = SAO_MODE_OFF;
     202      }
     203      if (bIsSAOSliceEnabled)
     204      {
    331205        Bool leftMergeAvail = false;
    332206        Bool aboveMergeAvail= false;
    333207
    334208        //merge left condition
    335         Int rx = (iCUAddr % uiWidthInLCUs);
     209        Int rx = (ctuRsAddr % frameWidthInCtus);
    336210        if(rx > 0)
    337211        {
    338           leftMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-1);
     212          leftMergeAvail = pcPic->getSAOMergeAvailability(ctuRsAddr, ctuRsAddr-1);
    339213        }
    340214        //merge up condition
    341         Int ry = (iCUAddr / uiWidthInLCUs);
     215        Int ry = (ctuRsAddr / frameWidthInCtus);
    342216        if(ry > 0)
    343217        {
    344           aboveMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-uiWidthInLCUs);
    345       }
    346 
    347         pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail);
    348     }
    349       else
    350         {
    351         saoblkParam[SAO_Y ].modeIdc = SAO_MODE_OFF;
    352         saoblkParam[SAO_Cb].modeIdc = SAO_MODE_OFF;
    353         saoblkParam[SAO_Cr].modeIdc = SAO_MODE_OFF;
    354       }
    355     }
    356     m_pcCuDecoder->decodeCU     ( pcCU, uiIsLast );
    357     m_pcCuDecoder->decompressCU ( pcCU );
    358    
     218          aboveMergeAvail = pcPic->getSAOMergeAvailability(ctuRsAddr, ctuRsAddr-frameWidthInCtus);
     219        }
     220
     221        pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, pcSlice->getSPS()->getBitDepths());
     222      }
     223    }
     224
     225    m_pcCuDecoder->decodeCtu     ( pCtu, isLastCtuOfSliceSegment );
     226    m_pcCuDecoder->decompressCtu ( pCtu );
     227
    359228#if ENC_DEC_TRACE
    360229    g_bJustDoIt = g_bEncDecTraceDisable;
    361230#endif
    362     pcSbacDecoders[uiSubStrm].load(pcSbacDecoder);
    363 
    364     if ( uiCol == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getRightEdgePosInCU()
    365         && pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()
    366         && !uiIsLast )
    367     {
    368       // Parse end_of_substream_one_bit for WPP case
     231
     232    //Store probabilities of second CTU in line into buffer
     233    if ( ctuXPosInCtus == tileXPosInCtus+1 && wavefrontsEnabled)
     234    {
     235      m_entropyCodingSyncContextState.loadContexts( pcSbacDecoder );
     236    }
     237
     238    if (isLastCtuOfSliceSegment)
     239    {
     240#if DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES
     241      pcSbacDecoder->parseRemainingBytes(false);
     242#endif
     243      if(!pcSlice->getDependentSliceSegmentFlag())
     244      {
     245        pcSlice->setSliceCurEndCtuTsAddr( ctuTsAddr+1 );
     246      }
     247      pcSlice->setSliceSegmentCurEndCtuTsAddr( ctuTsAddr+1 );
     248    }
     249    else if (  ctuXPosInCtus + 1 == tileXPosInCtus + currentTile.getTileWidthInCtus() &&
     250             ( ctuYPosInCtus + 1 == tileYPosInCtus + currentTile.getTileHeightInCtus() || wavefrontsEnabled)
     251            )
     252    {
     253      // The sub-stream/stream should be terminated after this CTU.
     254      // (end of slice-segment, end of tile, end of wavefront-CTU-row)
    369255      UInt binVal;
    370256      pcSbacDecoder->parseTerminatingBit( binVal );
    371257      assert( binVal );
    372     }
    373 
    374     //Store probabilities of second LCU in line into buffer
    375     if ( (uiCol == uiTileLCUX+1)&& (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )
    376     {
    377       m_pcBufferSbacDecoders[uiTileCol].loadContexts( &pcSbacDecoders[uiSubStrm] );
    378     }
    379     if( uiIsLast && depSliceSegmentsEnabled )
    380     {
    381       if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    382        {
    383          CTXMem[1]->loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );//ctx 2.LCU
    384        }
    385       CTXMem[0]->loadContexts( pcSbacDecoder );//ctx end of dep.slice
    386       return;
    387     }
    388   }
    389 }
    390 
    391 ParameterSetManagerDecoder::ParameterSetManagerDecoder()
    392 : m_vpsBuffer(MAX_NUM_VPS)
    393 , m_spsBuffer(MAX_NUM_SPS)
    394 , m_ppsBuffer(MAX_NUM_PPS)
    395 {
    396 }
    397 
    398 ParameterSetManagerDecoder::~ParameterSetManagerDecoder()
    399 {
    400 
    401 }
    402 
    403 TComVPS* ParameterSetManagerDecoder::getPrefetchedVPS  (Int vpsId)
    404 {
    405   if (m_vpsBuffer.getPS(vpsId) != NULL )
    406   {
    407     return m_vpsBuffer.getPS(vpsId);
    408   }
    409   else
    410   {
    411     return getVPS(vpsId);
    412   }
    413 }
    414 
    415 
    416 TComSPS* ParameterSetManagerDecoder::getPrefetchedSPS  (Int spsId)
    417 {
    418   if (m_spsBuffer.getPS(spsId) != NULL )
    419   {
    420     return m_spsBuffer.getPS(spsId);
    421   }
    422   else
    423   {
    424     return getSPS(spsId);
    425   }
    426 }
    427 
    428 TComPPS* ParameterSetManagerDecoder::getPrefetchedPPS  (Int ppsId)
    429 {
    430   if (m_ppsBuffer.getPS(ppsId) != NULL )
    431   {
    432     return m_ppsBuffer.getPS(ppsId);
    433   }
    434   else
    435   {
    436     return getPPS(ppsId);
    437   }
    438 }
    439 
    440 Void     ParameterSetManagerDecoder::applyPrefetchedPS()
    441 {
    442   m_vpsMap.mergePSList(m_vpsBuffer);
    443   m_ppsMap.mergePSList(m_ppsBuffer);
    444   m_spsMap.mergePSList(m_spsBuffer);
     258#if DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES
     259      pcSbacDecoder->parseRemainingBytes(true);
     260#endif
     261    }
     262
     263  }
     264
     265  assert(isLastCtuOfSliceSegment == true);
     266
     267
     268  if( depSliceSegmentsEnabled )
     269  {
     270    m_lastSliceSegmentEndContextState.loadContexts( pcSbacDecoder );//ctx end of dep.slice
     271  }
     272
    445273}
    446274
Note: See TracChangeset for help on using the changeset viewer.