Ignore:
Timestamp:
3 Jun 2013, 20:08:00 (12 years ago)
Author:
seregin
Message:

initial multilayer reference implementation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-2.1-multilayers-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r250 r253  
    180180Void TDecTop::setILRPic(TComPic *pcPic)
    181181{
    182   if(m_cIlpPic[0])
    183   {
    184     m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
    185     m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
    186     m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId
    187     m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
    188     m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     182  for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ )
     183  {
     184    Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i);
     185
     186    if(m_cIlpPic[refLayerIdc])
     187    {
     188      m_cIlpPic[refLayerIdc]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(i), m_cIlpPic[refLayerIdc]->getPicYuvRec());
     189      m_cIlpPic[refLayerIdc]->getSlice(0)->setPOC(pcPic->getPOC());
     190      m_cIlpPic[refLayerIdc]->setLayerId(pcPic->getSlice(0)->getBaseColPic(i)->getLayerId()); //set reference layerId
     191      m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false);
     192      m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder();
     193    }
    189194  }
    190195}
     
    248253    if(m_layerId > 0)
    249254    {
     255      for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ )
     256      {
     257        const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
     258        Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
     259
    250260#if VPS_EXTN_DIRECT_REF_LAYERS
    251       TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( m_layerId - 1 );
    252 #else
    253       TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 );
    254 #endif
    255       //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
    256       TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
    257       if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() )
    258       {
    259         rpcPic->setSpatialEnhLayerFlag( true );
    260 
    261         //only for scalable extension
    262         assert( pcSlice->getVPS()->getScalabilityMask(1) == true );
    263       }
     261        TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i );
     262#else
     263        TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 );
     264#endif
     265        //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
     266        TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
     267        if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets )
     268        {
     269          rpcPic->setSpatialEnhLayerFlag( i, true );
     270
     271          //only for scalable extension
     272          assert( pcSlice->getVPS()->getScalabilityMask(1) == true );
     273        }
    264274#if MAX_ONE_RESAMPLING_DIRECT_LAYERS
    265       if(pcSlice->getVPS()->getScalabilityMask(1))
    266       {
    267          pcSlice->setPic(rpcPic);
    268       }
    269 #endif
     275        if(pcSlice->getVPS()->getScalabilityMask(1))
     276        {
     277          pcSlice->setPic(rpcPic);
     278        }
     279#endif
     280      }
    270281    }
    271282#endif
     
    812823    if(m_layerId > 0)
    813824    {
     825      for( UInt i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     826      {
     827        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
    814828#if AVC_BASE
    815       if( m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
    816       {
    817         pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
     829        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
     830        {
     831          pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() );
    818832#if AVC_SYNTAX
    819         TComPic* pBLPic = pcSlice->getBaseColPic();
    820         if( pcSlice->getPOC() == 0 )
    821         {
    822           // initialize partition order.
    823           UInt* piTmp = &g_auiZscanToRaster[0];
    824           initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
    825           initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
    826         }     
    827         pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
    828         pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
    829 #endif
    830       }
    831       else
    832       {
     833          TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc);
     834          if( pcSlice->getPOC() == 0 )
     835          {
     836            // initialize partition order.
     837            UInt* piTmp = &g_auiZscanToRaster[0];
     838            initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
     839            initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
     840          }     
     841          pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
     842          pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
     843#endif
     844        }
     845        else
     846        {
    833847#if VPS_EXTN_DIRECT_REF_LAYERS
    834         TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId - 1 );
     848          TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );
     849#else
     850          TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
     851#endif
     852          TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
     853          pcSlice->setBaseColPic ( *cListPic, refLayerIdc );
     854        }
     855#else
     856#if VPS_EXTN_DIRECT_REF_LAYERS
     857        TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );
    835858#else
    836859        TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
    837860#endif
    838861        TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
    839         pcSlice->setBaseColPic ( *cListPic, m_layerId );
    840       }
    841 #else
    842 #if VPS_EXTN_DIRECT_REF_LAYERS
    843       TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId );
    844 #else
    845       TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
    846 #endif
    847       TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
    848       pcSlice->setBaseColPic ( *cListPic, m_layerId );
     862        pcSlice->setBaseColPic ( *cListPic, refLayerIdc );
    849863#endif
    850864
    851865#if SIMPLIFIED_MV_POS_SCALING
    852866#if SCALED_REF_LAYER_OFFSETS
    853       const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
    854 
    855       Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
    856       Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
    857 
    858       Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    859       Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
    860 #else
    861       const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
    862       const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
    863 
    864       Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
    865       Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
    866 
    867       Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
    868       Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    869 #endif
    870       g_mvScalingFactor[m_layerId][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
    871       g_mvScalingFactor[m_layerId][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
    872 
    873       g_posScalingFactor[m_layerId][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
    874       g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
     867        const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
     868
     869        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
     870        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
     871
     872        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     873        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     874#else
     875        const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
     876        const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     877
     878        Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     879        Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     880
     881        Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     882        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     883#endif
     884        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     885        g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     886
     887        g_posScalingFactor[refLayerIdc][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
     888        g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
    875889#endif
    876890
    877891#if SVC_UPSAMPLING
    878       if ( pcPic->isSpatialEnhLayer())
    879       {   
     892        if ( pcPic->isSpatialEnhLayer(refLayerIdc))
     893        {   
    880894#if SCALED_REF_LAYER_OFFSETS
    881         m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
    882 #else
    883         m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
    884 #endif
    885       }
    886       else
    887       {
    888         pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );
    889       }
    890       pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );
    891 #endif
     895          m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     896#else
     897          m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     898#endif
     899        }
     900        else
     901        {
     902          pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
     903        }
     904        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
     905#endif
     906      }
    892907    }
    893908
Note: See TracChangeset for help on using the changeset viewer.