Ignore:
Timestamp:
11 Jun 2013, 20:35:00 (11 years ago)
Author:
zhang
Message:

Implementation of ARP from QC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-0.3-dev2a/source/Lib/TLibCommon/TComPrediction.cpp

    r446 r464  
    6363  m_cYuvPredTemp.destroy();
    6464
     65#if H_3D_ARP
     66  m_acYuvPredBase[0].destroy();
     67  m_acYuvPredBase[1].destroy();
     68#endif
     69
    6570  if( m_pLumaRecBuffer )
    6671  {
     
    103108
    104109    m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE );
     110#if H_3D_ARP
     111    m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     112    m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     113#endif
    105114  }
    106115
     
    485494  TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    486495  pcCU->clipMv(cMv);
     496#if H_3D_ARP
     497  if(  pcCU->getARPW( uiPartAddr ) > 0
     498    && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N
     499    && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC()
     500    )
     501  {
     502    xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi );
     503  }
     504  else
     505  {
     506#endif
    487507  xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
    488508  xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
    489 }
     509#if H_3D_ARP
     510  }
     511#endif
     512}
     513
     514#if H_3D_ARP
     515Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
     516{
     517  Int         iRefIdx      = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
     518  TComMv      cMv          = pNewMvFiled ? pNewMvFiled->getMv()     : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
     519  Bool        bTobeScaled  = false;
     520  TComPic* pcPicYuvBaseCol = NULL;
     521  TComPic* pcPicYuvBaseRef = NULL;
     522
     523#if H_3D_NBDV
     524  DisInfo cDistparity;
     525  cDistparity.bDV           = pcCU->getDvInfo(uiPartAddr).bDV;
     526  if( cDistparity.bDV )
     527  {
     528    cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;
     529    assert(pcCU->getDvInfo(uiPartAddr).bDV ==  pcCU->getDvInfo(0).bDV);
     530    cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;
     531  }
     532#else
     533  assert(0); // ARP can be applied only when a DV is available
     534#endif
     535
     536  UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0;
     537
     538  if( cDistparity.bDV )
     539  {
     540    if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC() )
     541    {
     542      bTobeScaled = true;
     543    }
     544
     545    pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
     546    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan );
     547   
     548    if( ( !pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC() ) || ( !pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ) )
     549    {
     550      dW = 0;
     551      bTobeScaled = false;
     552    }
     553    else
     554    {
     555      assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() );
     556    }
     557
     558    if(bTobeScaled)
     559    {     
     560      Int iCurrPOC    = pcCU->getSlice()->getPOC();
     561      Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
     562      Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList,  0);
     563      Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
     564      if ( iScale != 4096 )
     565      {
     566        cMv = cMv.scaleMv( iScale );
     567      }
     568      iRefIdx = 0;
     569    }
     570  }
     571
     572  pcCU->clipMv(cMv);
     573  TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
     574  xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true );
     575  xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true );
     576
     577  if( dW > 0 )
     578  {
     579    TComYuv * pYuvB0 = &m_acYuvPredBase[0];
     580    TComYuv * pYuvB1  = &m_acYuvPredBase[1];
     581
     582    TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV;
     583    pcCU->clipMv(cMVwithDisparity);
     584
     585    assert ( cDistparity.bDV );
     586
     587    pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
     588    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true );
     589    xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true );
     590   
     591    pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec();
     592    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true );
     593    xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true );
     594
     595    pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight );
     596
     597    if( 2 == dW )
     598    {
     599      pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
     600    }
     601
     602    rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi );
     603  }
     604}
     605#endif
    490606
    491607Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred )
     
    551667 * \param bi       Flag indicating whether bipred is used
    552668 */
    553 Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi )
     669Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
     670#if H_3D_ARP
     671    , Bool filterType
     672#endif
     673  )
    554674{
    555675  Int refStride = refPic->getStride(); 
     
    565685  if ( yFrac == 0 )
    566686  {
    567     m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi );
     687    m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi
     688#if H_3D_ARP
     689    , filterType
     690#endif
     691      );
    568692  }
    569693  else if ( xFrac == 0 )
    570694  {
    571     m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi );
     695    m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi
     696#if H_3D_ARP
     697    , filterType
     698#endif
     699      );
    572700  }
    573701  else
     
    579707    Int halfFilterSize = ( filterSize >> 1 );
    580708
    581     m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false     );
    582     m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi);   
     709    m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false     
     710#if H_3D_ARP
     711    , filterType
     712#endif
     713      );
     714    m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi
     715#if H_3D_ARP
     716    , filterType
     717#endif
     718      );   
    583719  }
    584720}
     
    596732 * \param bi       Flag indicating whether bipred is used
    597733 */
    598 Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi )
     734Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
     735#if H_3D_ARP
     736    , Bool filterType
     737#endif   
     738  )
    599739{
    600740  Int     refStride  = refPic->getCStride();
     
    623763  if ( yFrac == 0 )
    624764  {
    625     m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi);   
    626     m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi);   
     765    m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi
     766#if H_3D_ARP
     767    , filterType
     768#endif
     769    );   
     770    m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi
     771#if H_3D_ARP
     772    , filterType
     773#endif
     774    );
    627775  }
    628776  else if ( xFrac == 0 )
    629777  {
    630     m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi);   
    631     m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi);   
     778    m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi
     779#if H_3D_ARP
     780    , filterType
     781#endif
     782    );
     783    m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi
     784#if H_3D_ARP
     785    , filterType
     786#endif
     787    );
    632788  }
    633789  else
    634790  {
    635     m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false);
    636     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi);
     791    m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false
     792#if H_3D_ARP
     793    , filterType
     794#endif 
     795      );
     796    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi
     797#if H_3D_ARP
     798    , filterType
     799#endif
     800      );
    637801   
    638     m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false);
    639     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi);   
     802    m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false
     803#if H_3D_ARP
     804    , filterType
     805#endif
     806      );
     807    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi
     808#if H_3D_ARP
     809    , filterType
     810#endif
     811      );   
    640812  }
    641813}
Note: See TracChangeset for help on using the changeset viewer.