Changeset 125 in SHVCSoftware for trunk/source/Lib/TLibDecoder/TDecSlice.cpp


Ignore:
Timestamp:
16 Apr 2013, 06:39:31 (12 years ago)
Author:
seregin
Message:

copy from HM-10.0-dev-SHM

File:
1 edited

Legend:

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

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4141//! \{
    4242
     43#if SVC_EXTENSION
     44  ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS);
     45#endif
     46
    4347//////////////////////////////////////////////////////////////////////
    4448// Construction/Destruction
     
    5559TDecSlice::~TDecSlice()
    5660{
    57 #if DEPENDENT_SLICES
    5861  for (std::vector<TDecSbac*>::iterator i = CTXMem.begin(); i != CTXMem.end(); i++)
    5962  {
     
    6164  }
    6265  CTXMem.clear();
    63 #endif
    64 }
    65 
    66 #if DEPENDENT_SLICES
     66}
     67
    6768Void TDecSlice::initCtxMem(  UInt i )               
    6869{   
     
    7475  CTXMem.resize(i);
    7576}
    76 #endif
    77 
    78 Void TDecSlice::create( TComSlice* pcSlice, Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth )
     77
     78Void TDecSlice::create()
    7979{
    8080}
     
    106106#if SVC_EXTENSION
    107107Void TDecSlice::init(TDecTop** ppcDecTop,TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
     108{
     109  m_pcEntropyDecoder  = pcEntropyDecoder;
     110  m_pcCuDecoder       = pcCuDecoder;
     111  m_ppcTDecTop        = ppcDecTop;
     112}
    108113#else
    109114Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
    110 #endif
    111115{
    112116  m_pcEntropyDecoder  = pcEntropyDecoder;
    113117  m_pcCuDecoder       = pcCuDecoder;
    114 #if SVC_EXTENSION   
    115   m_ppcTDecTop        = ppcDecTop;
    116 #endif
    117 }
    118 
    119 Void TDecSlice::decompressSlice(TComInputBitstream* pcBitstream, TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders)
     118}
     119#endif
     120
     121Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders)
    120122{
    121123  TComDataCU* pcCU;
    122124  UInt        uiIsLast = 0;
    123   Int   iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getDependentSliceCurStartCUAddr()/rpcPic->getNumPartInCU());
     125  Int   iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU());
    124126  Int   iStartCUAddr = rpcPic->getPicSym()->getCUOrderMap(iStartCUEncOrder);
    125127
     
    194196  UInt uiTileStartLCU;
    195197  UInt uiTileLCUX;
    196   UInt uiTileLCUY;
    197   UInt uiTileWidth;
    198   UInt uiTileHeight;
    199198  Int iNumSubstreamsPerTile = 1; // if independent.
    200 
    201199#if INTRA_BL
    202200  m_pcCuDecoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec() : NULL);
    203201#endif
    204 #if DEPENDENT_SLICES
    205   Bool bAllowDependence = false;
    206 #if TILES_WPP_ENTROPYSLICES_FLAGS
    207   if( rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceEnabledFlag()&& (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getEntropySliceEnabledFlag()) )
    208 #else
    209   if( rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceEnabledFlag()&& (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getCabacIndependentFlag()) )
    210 #endif
    211   {
    212     bAllowDependence = true;
    213   }
    214   if( bAllowDependence )
    215   {
    216     if( !rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice() )
    217     {
    218       uiTileCol = 0;
    219 #if TILES_WPP_ENTROPYSLICES_FLAGS
     202  Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
     203  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr();
     204  if( depSliceSegmentsEnabled )
     205  {
     206    if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) &&
     207       iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr())
     208    {
    220209      if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    221 #else
    222       if(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)
    223 #endif
    224       {
     210      {
     211        uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
    225212        m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1]  );//2.LCU
     213        if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs  )
     214        {
     215          uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     216          uiCol     = iStartCUAddr % uiWidthInLCUs;
     217          if(uiCol==uiTileLCUX)
     218          {
     219            CTXMem[0]->loadContexts(pcSbacDecoder);
     220          }
     221        }
    226222      }
    227223      pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1
     
    230226    else
    231227    {
    232 #if TILES_WPP_ENTROPYSLICES_FLAGS
    233228      if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    234 #else
    235       if(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)
    236 #endif
    237229      {
    238230        CTXMem[1]->loadContexts(pcSbacDecoder);
     
    241233    }
    242234  }
    243 #endif
    244235  for( Int iCUAddr = iStartCUAddr; !uiIsLast && iCUAddr < rpcPic->getNumCUsInFrame(); iCUAddr = rpcPic->getPicSym()->xCalculateNxtCUAddr(iCUAddr) )
    245236  {
     
    249240    uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr();
    250241    uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
    251     uiTileLCUY = uiTileStartLCU / uiWidthInLCUs;
    252     uiTileWidth = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getTileWidth();
    253     uiTileHeight = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getTileHeight();
    254242    uiCol     = iCUAddr % uiWidthInLCUs;
    255243    // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture.
    256244    uiLin     = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs);
    257245    // inherit from TR if necessary, select substream to use.
    258 #if DEPENDENT_SLICES
    259 #if TILES_WPP_ENTROPYSLICES_FLAGS
    260     if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( bAllowDependence  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ))
    261 #else
    262     if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( bAllowDependence  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2) ))
    263 #endif
    264 #else
    265     if( pcSlice->getPPS()->getNumSubstreams() > 1 )
    266 #endif
     246    if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ))
    267247    {
    268248      // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
     
    272252      m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] );
    273253      // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
    274 #if DEPENDENT_SLICES
    275 #if TILES_WPP_ENTROPYSLICES_FLAGS
    276       if (((pcSlice->getPPS()->getNumSubstreams() > 1) || bAllowDependence ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()))
    277 #else
    278       if (((pcSlice->getPPS()->getNumSubstreams() > 1) || bAllowDependence ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2))
    279 #endif
    280 #else
    281       if (pcSlice->getPPS()->getNumSubstreams() > 1 && uiCol == uiTileLCUX)
    282 #endif
     254      if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()))
    283255      {
    284256        // We'll sync if the TR is available.
     
    296268             ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr()) ||
    297269             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)))
    298              ))||
    299              (true/*bEnforceDependentSliceRestriction*/ &&
    300              ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    301              ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getDependentSliceCurStartCUAddr()) ||
    302              ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)))
    303270             ))
    304271           )
    305272        {
    306 #if DEPENDENT_SLICES
    307           if( (iCUAddr!=0) && ((pcCUTR->getSCUAddr()+uiMaxParts-1) >= pcSlice->getSliceCurStartCUAddr()) && bAllowDependence)
    308           {
    309              pcSbacDecoders[uiSubStrm].loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );
    310           }
    311 #endif
    312273          // TR not available.
    313274        }
     
    328289    if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile.
    329290         (iCUAddr!=0) && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU())
    330 #if DEPENDENT_SLICES
    331          && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getDependentSliceCurStartCUAddr())/rpcPic->getNumPartInCU())
    332 #endif
     291         && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU())
    333292         ) // !1st in frame && !1st in slice
    334293    {
     
    366325    g_bJustDoIt = g_bEncDecTraceEnable;
    367326#endif
    368 #if !SAO_LUM_CHROMA_ONOFF_FLAGS
    369     if ( pcSlice->getSPS()->getUseSAO() && pcSlice->getSaoEnabledFlag() )
    370 #else
    371327    if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) )
    372 #endif
    373     {
    374 #if REMOVE_APS
     328    {
    375329      SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam();
    376 #else
    377       SAOParam *saoParam = pcSlice->getAPS()->getSaoParam();
    378 #endif
    379330      saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag();
    380331      if (iCUAddr == iStartCUAddr)
    381332      {
    382 #if SAO_TYPE_SHARING
    383333        saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma();
    384 #else
    385         saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagCb();
    386         saoParam->bSaoFlag[2] = pcSlice->getSaoEnabledFlagCr();
    387 #endif
    388334      }
    389335      Int numCuInWidth     = saoParam->numCuInWidth;
     
    410356      pcSbacDecoder->parseSaoOneLcuInterleaving(rx, ry, saoParam,pcCU, cuAddrInSlice, cuAddrUpInSlice, allowMergeLeft, allowMergeUp);
    411357    }
    412 #if !REMOVE_ALF
    413     if(pcSlice->getSPS()->getUseALF())
    414     {
    415       UInt alfEnabledFlag;
    416       for(Int compIdx=0; compIdx< 3; compIdx++)
    417       {
    418         alfEnabledFlag = 0;
    419         if(pcSlice->getAlfEnabledFlag(compIdx))
    420         {
    421           pcSbacDecoder->parseAlfCtrlFlag(compIdx, alfEnabledFlag);
    422         }
    423         pcCU->setAlfLCUEnabled((alfEnabledFlag==1)?true:false, compIdx);
    424       }
    425     }
    426 #endif
     358    else if ( pcSlice->getSPS()->getUseSAO() )
     359    {
     360      Int addr = pcCU->getAddr();
     361      SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam();
     362      for (Int cIdx=0; cIdx<3; cIdx++)
     363      {
     364        SaoLcuParam *saoLcuParam = &(saoParam->saoLcuParam[cIdx][addr]);
     365        if ( ((cIdx == 0) && !pcSlice->getSaoEnabledFlag()) || ((cIdx == 1 || cIdx == 2) && !pcSlice->getSaoEnabledFlagChroma()))
     366        {
     367          saoLcuParam->mergeUpFlag   = 0;
     368          saoLcuParam->mergeLeftFlag = 0;
     369          saoLcuParam->subTypeIdx    = 0;
     370          saoLcuParam->typeIdx       = -1;
     371          saoLcuParam->offset[0]     = 0;
     372          saoLcuParam->offset[1]     = 0;
     373          saoLcuParam->offset[2]     = 0;
     374          saoLcuParam->offset[3]     = 0;
     375        }
     376      }
     377    }
    427378    m_pcCuDecoder->decodeCU     ( pcCU, uiIsLast );
    428379    m_pcCuDecoder->decompressCU ( pcCU );
     
    431382    g_bJustDoIt = g_bEncDecTraceDisable;
    432383#endif
    433     /*If at the end of a LCU line but not at the end of a substream, perform CABAC flush*/
    434     if (!uiIsLast && pcSlice->getPPS()->getNumSubstreams() > 1)
    435     {
    436       if ((uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight))
    437       {
    438         m_pcEntropyDecoder->decodeFlush();
    439       }
    440     }
    441384    pcSbacDecoders[uiSubStrm].load(pcSbacDecoder);
    442385
    443386    //Store probabilities of second LCU in line into buffer
    444 #if DEPENDENT_SLICES
    445 #if TILES_WPP_ENTROPYSLICES_FLAGS
    446     if ( (uiCol == uiTileLCUX+1)&& (bAllowDependence || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )
    447 #else
    448     if ( (uiCol == uiTileLCUX+1)&& (bAllowDependence || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc() == 2))
    449 #endif
    450 #else
    451     if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX+1))
    452 #endif
     387    if ( (uiCol == uiTileLCUX+1)&& (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )
    453388    {
    454389      m_pcBufferSbacDecoders[uiTileCol].loadContexts( &pcSbacDecoders[uiSubStrm] );
    455390    }
    456 #if DEPENDENT_SLICES
    457     if( uiIsLast && bAllowDependence )
    458     {
    459 #if TILES_WPP_ENTROPYSLICES_FLAGS
     391    if( uiIsLast && depSliceSegmentsEnabled )
     392    {
    460393      if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    461 #else
    462       if (pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)
    463 #endif
    464394       {
    465395         CTXMem[1]->loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );//ctx 2.LCU
     
    468398      return;
    469399    }
    470 #endif
    471400  }
    472401}
    473402
    474403ParameterSetManagerDecoder::ParameterSetManagerDecoder()
     404#if SVC_EXTENSION
     405: m_spsBuffer(MAX_NUM_SPS)
     406, m_ppsBuffer(MAX_NUM_PPS)
     407#else
    475408: m_vpsBuffer(MAX_NUM_VPS)
    476 ,m_spsBuffer(256)
    477 , m_ppsBuffer(16)
    478 #if !REMOVE_APS
    479 , m_apsBuffer(64)
    480 #endif
    481 {
    482 
     409, m_spsBuffer(MAX_NUM_SPS)
     410, m_ppsBuffer(MAX_NUM_PPS)
     411#endif
     412{
    483413}
    484414
     
    525455}
    526456
    527 #if !REMOVE_APS
    528 TComAPS* ParameterSetManagerDecoder::getPrefetchedAPS  (Int apsId)
    529 {
    530   if (m_apsBuffer.getPS(apsId) != NULL )
    531   {
    532     return m_apsBuffer.getPS(apsId);
    533   }
    534   else
    535   {
    536     return getAPS(apsId);
    537   }
    538 }
    539 #endif
    540 
    541457Void     ParameterSetManagerDecoder::applyPrefetchedPS()
    542458{
    543459  m_vpsMap.mergePSList(m_vpsBuffer);
    544 #if !REMOVE_APS
    545   m_apsMap.mergePSList(m_apsBuffer);
    546 #endif
    547460  m_ppsMap.mergePSList(m_ppsBuffer);
    548461  m_spsMap.mergePSList(m_spsBuffer);
Note: See TracChangeset for help on using the changeset viewer.