Changeset 455 in 3DVCSoftware for branches/HTM-DEV-0.3-dev2


Ignore:
Timestamp:
4 Jun 2013, 00:01:30 (11 years ago)
Author:
zhang
Message:

NBDV for 3D-HEVC

Location:
branches/HTM-DEV-0.3-dev2/source/Lib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp

    r446 r455  
    112112  m_sliceStartCU        = 0;
    113113  m_sliceSegmentStartCU = 0;
     114#if H_3D_NBDV
     115  m_pDvInfo              = NULL;
     116#endif
    114117}
    115118
     
    169172    m_pcTrCoeffCb        = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4);
    170173    m_pcTrCoeffCr        = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4);
     174#if H_3D_NBDV
     175    m_pDvInfo            = (DisInfo* )xMalloc(DisInfo,  uiNumPartition);
     176#endif
    171177    memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) );
    172178    memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) );
     
    284290    if ( m_apiMVPNum[0]       ) { delete[] m_apiMVPNum[0];      m_apiMVPNum[0]      = NULL; }
    285291    if ( m_apiMVPNum[1]       ) { delete[] m_apiMVPNum[1];      m_apiMVPNum[1]      = NULL; }
    286    
     292#if H_3D_NBDV
     293    if ( m_pDvInfo            ) { xFree(m_pDvInfo);             m_pDvInfo           = NULL; }
     294#endif
    287295    m_acCUMvField[0].destroy();
    288296    m_acCUMvField[1].destroy();
     
    652660  memset( m_puhCbf[2],          0, iSizeInUchar );
    653661  memset( m_puhDepth,     uiDepth, iSizeInUchar );
    654 
     662#if H_3D_NBDV
     663  m_pDvInfo->bDV = false;
     664#endif
    655665  UChar uhWidth  = g_uiMaxCUWidth  >> uiDepth;
    656666  UChar uhHeight = g_uiMaxCUHeight >> uiDepth;
     
    800810  m_CUTransquantBypass  = pcCU->getCUTransquantBypass()+uiPart;
    801811 
     812#if H_3D_NBDV
     813  m_pDvInfo             = pcCU->getDvInfo()           + uiPart;
     814#endif
    802815  m_pbMergeFlag         = pcCU->getMergeFlag()        + uiPart;
    803816  m_puhMergeIndex       = pcCU->getMergeIndex()       + uiPart;
     
    862875  memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition);
    863876}
    864 
     877#if H_3D_NBDV
     878Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx)
     879{
     880  m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
     881}
     882#endif
    865883// Copy inter prediction info from the biggest CU
    866 Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList )
     884Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
     885#if H_3D_NBDV
     886  , Bool bNBDV
     887#endif
     888  )
    867889{
    868890  m_pcPic              = pcCU->getPic();
     
    886908
    887909  m_pePartSize         = pcCU->getPartitionSize ()        + uiAbsPartIdx;
     910#if H_3D_NBDV
     911  if(bNBDV == true)
     912  {
     913    m_puhWidth           = pcCU->getWidth ()                + uiAbsPartIdx;
     914    m_puhHeight          = pcCU->getHeight()                + uiAbsPartIdx;
     915    m_puhDepth           = pcCU->getDepth ()                + uiAbsPartIdx;
     916  }
     917  else
     918  {
     919#endif
    888920  m_pePredMode         = pcCU->getPredictionMode()        + uiAbsPartIdx;
    889921  m_CUTransquantBypass = pcCU->getCUTransquantBypass()    + uiAbsPartIdx;
     
    904936  memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition);
    905937  memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition);
     938#if H_3D_NBDV
     939  }
     940#endif
    906941}
    907942
     
    10041039
    10051040  memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar  );
     1041#if H_3D_NBDV
     1042  memcpy( rpcCU->getDvInfo()         + m_uiAbsIdxInLCU, m_pDvInfo,    sizeof(* m_pDvInfo)     * m_uiNumPartition );
     1043#endif
    10061044
    10071045  memcpy( rpcCU->getPartitionSize()  + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition );
     
    24062444  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    24072445  deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    2408 
     2446#if H_3D_NBDV //Notes from QC: DvMCP related variables. 
     2447  //acPdmMv[0].m_bDvMcp = acPdmMv[1].m_bDvMcp = acPdmMv[2].m_bDvMcp = acPdmMv[3].m_bDvMcp = false;
     2448#endif
     2449
     2450#if H_3D_NBDV //Notes from QC: Some examples to show how to use the NBDV and DoNBDV variables. Remove this comment once it is done
     2451  DisInfo cDisInfo;
     2452  cDisInfo.bDV = false;
     2453  //if(!bNoPdmMerge)
     2454  //{
     2455    //cDisInfo.bDV = getDvInfo(uiAbsPartIdx).bDV;
     2456    //cDisInfo.m_aVIdxCan = getDvInfo(uiAbsPartIdx).m_aVIdxCan;
     2457    //cDisInfo.m_acNBDV = getDvInfo(uiAbsPartIdx).m_acNBDV;
     2458//#if H_3D_NBDV_REF
     2459    //cDisInfo.m_acDoNBDV = getDvInfo(uiAbsPartIdx).m_acDoNBDV;
     2460//#endif
     2461  //}
     2462#endif
    24092463  //left
    24102464  UInt uiLeftPartIdx = 0;
     
    38463900}
    38473901#endif
    3848 
     3902#if H_3D_NBDV
     3903//Notes from QC:
     3904//TBD#1: DoNBDV related contributions are just partially integrated under the marco of H_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done
     3905//TBD#2: set of DvMCP values need to be done as part of inter-view motion prediction process. Remove this comment once merge related integration is done
     3906//To be checked: Parallel Merge features for NBDV, related to DV_DERIVATION_PARALLEL_B0096 and LGE_IVMP_PARALLEL_MERGE_B0136 are not integrated. The need of these features due to the adoption of CU-based NBDV is not clear. We need confirmation on this, especially by proponents
     3907Bool TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo
     3908#if H_3D_NBDV_REF
     3909, Bool bDepthRefine
     3910#endif
     3911)
     3912{
     3913  //// ******* Init variables ******* /////
     3914  // Init disparity struct for results
     3915  pDInfo->bDV = false;   
     3916  // Init struct for disparities from MCP neighboring blocks
     3917  IDVInfo cIDVInfo;
     3918  cIDVInfo.m_bFound = false;
     3919  UInt uiPartIdx = 0;
     3920  UInt uiPartAddr = 0;
     3921  for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++)
     3922  {
     3923    for (UInt iList = 0; iList < 2; iList++)
     3924    {
     3925      cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero();
     3926      cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0;
     3927      cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false;
     3928    }
     3929  }
     3930  // Get Positions 
     3931  PartSize eCUMode    = getPartitionSize( uiPartAddr );   
     3932  assert(eCUMode == SIZE_2Nx2N);
     3933  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 
     3934
     3935  deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
     3936  deriveLeftBottomIdxGeneral  (uiPartAddr, uiPartIdx, uiPartIdxLB );
     3937
     3938  //// ******* Get disparity from temporal neighboring blocks ******* /////
     3939  if ( getSlice()->getEnableTMVPFlag() )
     3940  {
     3941    TComMv cColMv;
     3942    Int iTargetViewIdx = 0;
     3943    Int iTStartViewIdx = 0;   
     3944
     3945    ///*** Derive center position ***
     3946    UInt uiPartIdxCenter;
     3947    Int  uiLCUIdx   = getAddr();
     3948    xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter );
     3949
     3950    ///*** Derive bottom right neighbour position ***
     3951    Int iLCUIdxRBNb  = -1;   
     3952    Int iPartIdxRBNb = -1;
     3953    xDeriveRightBottomNbIdx(iLCUIdxRBNb, iPartIdxRBNb );
     3954
     3955    ///*** Search temporal candidate pictures for disparity vector ***
     3956    const Int iNumCandPics = getPic()->getNumDdvCandPics();
     3957    for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++)
     3958    {
     3959      RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
     3960      Int        curCandPicRefIdx = 0;
     3961      if( curCandPic == 0 )
     3962      {
     3963        eCurRefPicList   = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0);
     3964        curCandPicRefIdx = getSlice()->getColRefIdx();
     3965      }
     3966      else                 
     3967      {
     3968        eCurRefPicList   = getPic()->getRapRefList();
     3969        curCandPicRefIdx = getPic()->getRapRefIdx();
     3970      }
     3971
     3972      // Check BR and Center       
     3973      for(Int curPosition = 0; curPosition < 2; curPosition++)
     3974      {
     3975        Bool bCheck = false;
     3976        if ( curPosition == 0 && iLCUIdxRBNb >= 0 )
     3977          bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb,  cColMv, iTargetViewIdx, iTStartViewIdx);
     3978
     3979        if (curPosition == 1 )
     3980          bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, uiLCUIdx,   uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx );
     3981
     3982        if( bCheck )
     3983        {
     3984          clipMv(cColMv);
     3985          pDInfo->m_acNBDV = cColMv;
     3986          pDInfo->m_aVIdxCan  = iTargetViewIdx;
     3987          TComPic* picDepth = NULL;
     3988
     3989#if H_3D_NBDV_REF
     3990          /*Place DoNBDV*/
     3991          pDInfo->m_acDoNBDV  = cColMv;
     3992#endif
     3993          return true;
     3994        }
     3995      }
     3996    }
     3997  }
     3998
     3999  UInt uiIdx = 0;
     4000  Bool        bCheckMcpDv = false;   
     4001  TComDataCU* pcTmpCU     = NULL;
     4002
     4003  //// ******* Get disparity from left block ******* /////
     4004  pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
     4005  bCheckMcpDv = true;
     4006  if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
     4007#if H_3D_NBDV_REF
     4008  , bDepthRefine
     4009#endif
     4010    ) )
     4011    return true;
     4012
     4013  //// ******* Get disparity from above block ******* /////
     4014  pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
     4015  if(pcTmpCU != NULL )
     4016  {
     4017    bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
     4018    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE
     4019#if H_3D_NBDV_REF
     4020  , bDepthRefine
     4021#endif
     4022    ) )
     4023      return true;
     4024  }
     4025
     4026  //// ******* Get disparity from above right block ******* /////
     4027  pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true);
     4028  if(pcTmpCU != NULL )
     4029  {
     4030    bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
     4031    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVERIGHT
     4032#if H_3D_NBDV_REF
     4033  , bDepthRefine
     4034#endif
     4035    ) )
     4036      return true;
     4037  }
     4038
     4039  //// ******* Get disparity from below left block ******* /////
     4040  pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true);
     4041  if( pcTmpCU != NULL )
     4042  {
     4043    bCheckMcpDv = true;
     4044    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFTBELOW
     4045#if H_3D_NBDV_REF
     4046  , bDepthRefine
     4047#endif
     4048    ) )
     4049      return true;
     4050  }
     4051
     4052  //// ******* Get disparity from above left block ******* /////
     4053  pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true);
     4054  assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
     4055
     4056  if( pcTmpCU != NULL )
     4057  {
     4058    bCheckMcpDv = (( getAddr() - pcTmpCU->getAddr() ) <= 1);
     4059    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVELEFT
     4060#if H_3D_NBDV_REF
     4061  , bDepthRefine
     4062#endif
     4063    ) )
     4064      return true;
     4065  }
     4066
     4067  //// ******* Search MCP blocks ******* /////
     4068  if( cIDVInfo.m_bFound )
     4069  {
     4070    for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ )
     4071    {
     4072      for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4073      {
     4074        if( cIDVInfo.m_bAvailab[iList][curPos] )
     4075        {
     4076          TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ];
     4077          clipMv( cDispVec );
     4078          pDInfo->m_acNBDV = cDispVec;
     4079          pDInfo->m_aVIdxCan = 0;
     4080#if H_3D_NBDV_REF
     4081          /*Place DoNBDV*/
     4082
     4083          pDInfo->m_acDoNBDV = cDispVec;
     4084         
     4085#endif
     4086          return true;
     4087        }
     4088      }
     4089    }
     4090  }
     4091
     4092  TComPic* picDepth = NULL;
     4093  TComMv defaultDV(0, 0);
     4094  pDInfo->m_acNBDV = defaultDV;
     4095  pDInfo->m_aVIdxCan = 0;
     4096#if H_3D_NBDV_REF
     4097  /*Place DoNBDV*/
     4098 
     4099  pDInfo->m_acDoNBDV = defaultDV;
     4100#endif
     4101  return false;
     4102}
     4103
     4104Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
     4105#if H_3D_NBDV_REF
     4106, Bool bDepthRefine
     4107#endif
     4108)
     4109{
     4110  if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
     4111  {
     4112    Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     4113    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4114    {
     4115      RefPicList eRefPicList = RefPicList(iList);
     4116      Int      refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4117      TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4118
     4119      if( refId >= 0)
     4120      {
     4121        Int refViewIdx  = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex();
     4122        if (refViewIdx != m_pcSlice->getViewIndex())
     4123        {         
     4124          clipMv(cMvPred);
     4125          pNbDvInfo->m_acNBDV = cMvPred;
     4126          pNbDvInfo->m_aVIdxCan = refViewIdx;
     4127          TComPic* picDepth = NULL;
     4128#if H_3D_NBDV_REF
     4129          /*Place DoNBDV*/
     4130         
     4131          pNbDvInfo->m_acDoNBDV = cMvPred;
     4132#endif
     4133          return true;
     4134        }
     4135        else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped )
     4136        {
     4137          assert( uiMvpDvPos < IDV_CANDS );
     4138          paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() );
     4139          //Notes from QC: DvMCP is implemented in a way that doesn’t carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design.
     4140          paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = 0;
     4141          paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true;
     4142          paIDVInfo->m_bFound                        = true;
     4143        }
     4144      }
     4145    }
     4146  }
     4147  return false;
     4148}
     4149 
     4150Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb )
     4151{
     4152  UInt uiPartIdx = 0;
     4153  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 
     4154  Int uiLCUIdx = getAddr();
     4155
     4156  UInt uiPartIdxRB;
     4157  deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); 
     4158  UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
     4159
     4160  if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
     4161  {
     4162    riLCUIdxRBNb  = -1;
     4163    riPartIdxRBNb = -1;
     4164  }
     4165  else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
     4166  {
     4167    riLCUIdxRBNb  = -1;
     4168    riPartIdxRBNb = -1;
     4169  }
     4170  else
     4171  {
     4172    if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
     4173      ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
     4174    {
     4175      riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
     4176      riLCUIdxRBNb  = uiLCUIdx;
     4177    }
     4178    else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
     4179    {
     4180      riPartIdxRBNb = -1;
     4181      riLCUIdxRBNb  = -1;
     4182    }
     4183    else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     4184    {
     4185      riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
     4186      riLCUIdxRBNb = uiLCUIdx + 1;
     4187    }
     4188    else //is the right bottom corner of LCU                       
     4189    {
     4190      riPartIdxRBNb = -1;
     4191      riLCUIdxRBNb  = -1;
     4192    }
     4193  }
     4194}
     4195
     4196
     4197Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth )
     4198{
     4199  UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);
     4200  for (UInt ui = 0; ui < uiCurrPartNumb; ui++ )
     4201  {
     4202    m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo;
     4203  }
     4204}
     4205
     4206Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx )
     4207{
     4208
     4209  RefPicList  eColRefPicList = REF_PIC_LIST_0;
     4210  Int iColViewIdx, iColRefViewIdx;
     4211  TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
     4212  TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
     4213  iColViewIdx = pColCU->getSlice()->getViewIndex();
     4214  if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx))
     4215  {
     4216    return false;
     4217  }
     4218  for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++)
     4219  {
     4220    if(pColCU->getSlice()->isInterB())
     4221    {
     4222        eColRefPicList = RefPicList(ilist);
     4223    }
     4224
     4225    Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx);
     4226
     4227    if (iColRefIdx < 0)
     4228    {
     4229      continue;
     4230    }
     4231
     4232    iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewIndex();
     4233
     4234    if ( iColViewIdx    == iColRefViewIdx ) // temporal vector
     4235    {
     4236      continue;
     4237    }
     4238    else
     4239    {
     4240      rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx);
     4241      rcMv.setIDVFlag(0);
     4242      iTargetViewIdx  = iColRefViewIdx ;
     4243      iStartViewIdx   = iColViewIdx   ;
     4244      return true;   
     4245    }
     4246  }
     4247
     4248  return false;
     4249}
     4250#endif
    38494251//! \}
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.h

    r446 r455  
    187187  Char*         m_apiMVPNum[2];       ///< array of number of possible motion vectors predictors
    188188  Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
    189 
     189#if H_3D_NBDV
     190  DisInfo*      m_pDvInfo;
     191#endif
    190192  // -------------------------------------------------------------------------------------------------------------------
    191193  // misc. variables
     
    241243  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
    242244  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
    243 
     245#if H_3D_NBDV
     246  Void          copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx);
     247#endif
    244248  Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
    245   Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList );
     249  Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
     250#if H_3D_NBDV
     251  , Bool bNBDV = false
     252#endif
     253  );
    246254  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
    247255 
     
    391399  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
    392400  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
    393 
     401#if H_3D_NBDV
     402  Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth );
     403  DisInfo*      getDvInfo             ()                        { return m_pDvInfo;                 }
     404  DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
     405#endif
    394406  /// get slice ID for SU
    395407  Int           getSUSliceID          (UInt uiIdx)              {return m_piSliceSUMap[uiIdx];      }
     
    406418                                          ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
    407419                                          ,Bool bIndependentTileBoundaryEnabled );
     420#if H_3D_NBDV
     421  Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
     422  Bool          xCheckSpatialNBDV (TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
     423                                   UInt uiMvpDvPos
     424#if H_3D_NBDV_REF
     425  , Bool bDepthRefine = false
     426#endif
     427  );
     428  Bool          xGetColDisMV      ( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
     429  Bool          getDisMvpCandNBDV ( DisInfo* pDInfo
     430#if H_3D_NBDV_REF
     431   , Bool bDepthRefine = false
     432#endif
     433   );
     434   
     435#endif
    408436  // -------------------------------------------------------------------------------------------------------------------
    409437  // member functions for accessing partition information
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComMotionInfo.h

    r324 r455  
    5858} AMVPInfo;
    5959
     60#if H_3D_NBDV
     61typedef struct _DisCand
     62{
     63  Bool bDV;
     64  TComMv m_acNBDV;              // DV from NBDV
     65#if H_3D_NBDV_REF
     66  TComMv m_acDoNBDV;            // DV from DoNBDV
     67#endif 
     68  Int    m_aVIdxCan;            // View order index (the same with the NBDV and the DoNBDV)
     69} DisInfo;
     70
     71typedef struct _IDVCand // IDV
     72{
     73  TComMv m_acMvCand[2][ IDV_CANDS ];           
     74  Int    m_aVIdxCan[2][ IDV_CANDS ];           
     75  Bool   m_bAvailab[2][ IDV_CANDS ];
     76  Bool   m_bFound;                               
     77} IDVInfo;
     78#endif
    6079// ====================================================================================================================
    6180// Class definition
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComMv.h

    r324 r455  
    5454  Short m_iHor;     ///< horizontal component of motion vector
    5555  Short m_iVer;     ///< vertical component of motion vector
    56  
     56#if H_3D_NBDV
     57  Bool  m_bIDV;       
     58  Short m_iIDVHor;   
     59  Short m_iIDVVer;   
     60#endif
    5761public:
    5862 
     
    6468  m_iHor(0),
    6569  m_iVer(0)
     70#if H_3D_NBDV
     71  , m_bIDV(false)
     72  , m_iIDVHor(0)
     73  , m_iIDVVer(0)
     74#endif
    6675  {
    6776  }
     
    7079  m_iHor(iHor),
    7180  m_iVer(iVer)
     81 #if H_3D_NBDV
     82  , m_bIDV(false)
     83  , m_iIDVHor(0)
     84  , m_iIDVVer(0)
     85#endif
    7286  {
    7387  }
     
    8195  Void  setVer    ( Short i )                   { m_iVer = i;                               }
    8296  Void  setZero   ()                            { m_iHor = m_iVer = 0;  }
    83  
     97#if H_3D_NBDV
     98  Void   setIDVHor  (Short i)                    {m_iIDVHor = i;}
     99  Void   setIDVVer  (Short i)                    {m_iIDVVer = i;}
     100  Void   setIDVFlag (Bool b )                    {m_bIDV    = b;}
     101#endif
    84102  // ------------------------------------------------------------------------------------------------------------------
    85103  // get
     
    90108  Int   getAbsHor () const { return abs( m_iHor );   }
    91109  Int   getAbsVer () const { return abs( m_iVer );   }
    92  
     110#if H_3D_NBDV
     111  Short getIDVHor () const { return m_iIDVHor;       }
     112  Short getIDVVer () const { return m_iIDVVer;       }
     113  Bool  getIDVFlag() const { return m_bIDV;          }
     114#endif
    93115  // ------------------------------------------------------------------------------------------------------------------
    94116  // operations
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComPic.cpp

    r446 r455  
    7777  m_apcPicYuv[0]      = NULL;
    7878  m_apcPicYuv[1]      = NULL;
     79#if H_3D_NBDV
     80  m_iNumDdvCandPics   = 0;
     81  m_eRapRefList       = REF_PIC_LIST_0;
     82  m_uiRapRefIdx       = 0;
     83#endif
    7984}
    8085
     
    553558#endif // H_3D
    554559#endif // H_MV
     560#if H_3D_NBDV
     561Int TComPic::getDisCandRefPictures(Int iColPOC)
     562{
     563  UInt uiTempLayerCurr=7;
     564  TComSlice* currSlice = getSlice(getCurrSliceIdx());
     565  UInt NumDdvCandPics = 0;
     566  if ( !currSlice->getEnableTMVPFlag() )
     567    return NumDdvCandPics;
     568  NumDdvCandPics +=1;
     569
     570  UInt iPOCCurr=currSlice->getPOC();
     571  UInt iPOCDiff = 255;
     572  Bool bCheck = false;
     573
     574  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
     575  {
     576    UInt X = lpNr? currSlice->getColFromL0Flag() : 1-currSlice->getColFromL0Flag();
     577    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(X)); i++)
     578    {
     579      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)X, i)->getViewIndex()
     580        && (X == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)X, i)!= iColPOC) && NumDdvCandPics!=2)
     581      {
     582        TComSlice* refSlice = currSlice->getRefPic((RefPicList)X, i)->getSlice(getCurrSliceIdx());
     583        Bool bRAP = (refSlice->getViewIndex() && refSlice->isIRAP())? 1: 0;
     584        UInt uiTempLayer = currSlice->getRefPic((RefPicList)X, i)->getSlice(getCurrSliceIdx())->getTLayer();
     585        Int iTempPoc = currSlice->getRefPic((RefPicList)X, i)->getPOC();
     586        Int iTempDiff = (iTempPoc > iPOCCurr) ? (iTempPoc - iPOCCurr): (iPOCCurr - iTempPoc);
     587        if(bRAP)
     588        {
     589          this->setRapRefIdx(i);
     590          this->setRapRefList((RefPicList)X);
     591          NumDdvCandPics = 2;
     592          return NumDdvCandPics;
     593        }
     594        else if (uiTempLayerCurr > uiTempLayer)
     595           uiTempLayerCurr = uiTempLayer;
     596      }
     597    }
     598  }
     599  UInt Z;
     600  UInt idx=0;
     601  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
     602  {
     603    UInt X = lpNr? currSlice->getColFromL0Flag() : 1-currSlice->getColFromL0Flag();
     604    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(X)); i++)
     605    {
     606      Int iTempPoc = currSlice->getRefPic((RefPicList)X, i)->getPOC();
     607      Int iTempDiff = (iTempPoc > iPOCCurr) ? (iTempPoc - iPOCCurr): (iPOCCurr - iTempPoc);
     608      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)X, i)->getViewIndex() &&  (X == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)X, i)!= iColPOC)
     609        && currSlice->getRefPic((RefPicList)X, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && iPOCDiff > iTempDiff)
     610      {
     611        iPOCDiff=iTempDiff;
     612        Z=X;
     613        idx = i;
     614      }
     615    }
     616  }
     617  if(iPOCDiff<255)
     618  {
     619    this->setRapRefIdx(idx);
     620    this->setRapRefList((RefPicList)Z);
     621    NumDdvCandPics = 2;
     622  }
     623
     624  return NumDdvCandPics;
     625}
     626#endif
    555627//! \}
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComPic.h

    r446 r455  
    9696#endif
    9797#endif
     98#if H_3D_NBDV
     99  UInt        m_uiRapRefIdx;
     100  RefPicList  m_eRapRefList;
     101  Int         m_iNumDdvCandPics;
     102#endif
    98103public:
    99104  TComPic();
     
    194199  Void          print( Bool legend );
    195200#endif
     201#if H_3D_NBDV
     202  Int           getNumDdvCandPics()                    {return m_iNumDdvCandPics;   }
     203  Int           getDisCandRefPictures(Int iColPOC);
     204  Void          setRapRefIdx(UInt uiRapRefIdx)         {m_uiRapRefIdx = uiRapRefIdx;}
     205  Void          setRapRefList(RefPicList eRefPicList)  {m_eRapRefList = eRefPicList;}
     206  Void          setNumDdvCandPics (Int i)              {m_iNumDdvCandPics = i;       }
     207  UInt          getRapRefIdx()                         {return m_uiRapRefIdx;       }
     208  RefPicList    getRapRefList()                        {return m_eRapRefList;       }
     209#endif
    196210  /** transfer ownership of seis to this picture */
    197211  void setSEIs(SEIMessages& seis) { m_SEIs = seis; }
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TypeDef.h

    r446 r455  
    7878                                              // SAIT_VSO_EST_A0033, JCT3V-A0033 modification 3
    7979                                              // LGE_WVSO_A0119
     80#define H_3D_NBDV                         1   // Neighboring block disparity derivation
     81                                              // JCT3V-A0097
     82                                              // LGE_DVMCP_A0126
     83                                              // LGE_DVMCP_MEM_REDUCTION_B0135     
     84                                              // QC_SIMPLE_NBDV_B0047
     85                                              // FIX_LGE_DVMCP_B0133
     86                                              // QC_NBDV_LDB_FIX_C0055
     87                                              // MTK_SAIT_TEMPORAL_FIRST_ORDER_C0141_C0097
     88                                              // MTK_SIMPLIFY_DVTC_C0135           
     89                                              // QC_CU_NBDV_D0181
     90                                              // SEC_DEFAULT_DV_D0112
    8091#endif
    8192
     
    92103#define H_3D_VSO_SYNTH_DIST_OUT           0   // Output of synthesized view distortion instead of depth distortion in encoder output
    93104#endif
    94 
     105////   ****** Neighbouring block-based Disparity Vector  *********
     106#if H_3D_NBDV
     107#define IDV_CANDS                         6
     108#define DVFROM_LEFTBELOW                  1
     109#define DVFROM_LEFT                       2
     110#define DVFROM_ABOVERIGHT                 3
     111#define DVFROM_ABOVE                      4
     112#define DVFROM_ABOVELEFT                  5
     113#endif
    95114/////////////////////////////////////////////////////////////////////////////////////////
    96115///////////////////////////////////   HM RELATED DEFINES ////////////////////////////////
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCu.cpp

    r324 r455  
    269269    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
    270270  }
    271 
     271#if H_3D_NBDV
     272  DisInfo DvInfo;
     273  DvInfo.bDV = false;
     274  DvInfo.m_acNBDV.setZero();
     275  DvInfo.m_aVIdxCan = 0;
     276#if H_3D_NBDV_REF 
     277  DvInfo.m_acDoNBDV.setZero();
     278#endif
     279 
     280 
     281  if(!pcCU->getSlice()->isIntra())
     282  {
     283    if(pcCU->getSlice()->getViewIndex() && !pcCU->getSlice()->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
     284    {
     285      m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
     286      m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
     287      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
     288      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
     289      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
     290      m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
     291      m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
     292      m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
     293#if H_3D_NBDV_REF
     294      if(pcCU->getSlice()->getSPS()->getUseDVPRefine())  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
     295        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
     296      else
     297#endif
     298        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
     299
     300      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
     301      m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
     302      m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
     303      m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
     304     }
     305  }
     306#endif
    272307  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    273308  {
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.cpp

    r446 r455  
    152152    m_LFCrossSliceBoundaryFlag.push_back( pcSlice->getLFCrossSliceBoundaryFlag());
    153153  }
     154#if H_3D_NBDV
     155  if(pcSlice->getViewIndex() && !pcSlice->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
     156  {
     157    Int iColPoc = pcSlice->getRefPOC(RefPicList(1-pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
     158    rpcPic->setNumDdvCandPics(rpcPic->getDisCandRefPictures(iColPoc));
     159  }
     160#endif
    154161  m_pcSbacDecoders[0].load(m_pcSbacDecoder);
    155162  m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders);
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncCu.cpp

    r446 r455  
    457457
    458458      rpcTempCU->initEstData( uiDepth, iQP );
    459 
     459#if H_3D_NBDV
     460      DisInfo DvInfo;
     461      DvInfo.bDV = false;
     462      DvInfo.m_acNBDV.setZero();
     463      DvInfo.m_aVIdxCan = 0;
     464#if H_3D_NBDV_REF
     465      DvInfo.m_acDoNBDV.setZero();
     466#endif
     467
     468      if( rpcTempCU->getSlice()->getSliceType() != I_SLICE )
     469      {
     470        if(rpcTempCU->getSlice()->getViewIndex() && !rpcTempCU->getSlice()->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done. Remove this comment once it is done.
     471        {
     472          PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
     473          rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
     474#if H_3D_NBDV_REF
     475          if(m_pcSlice->getSPS()->getUseDVPRefine())  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
     476            DvInfo.bDV = rpcTempCU->getDisMvpCandNBDV(&DvInfo, true);
     477          else
     478#endif
     479            DvInfo.bDV = rpcTempCU->getDisMvpCandNBDV(&DvInfo);
     480
     481          rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
     482          rpcBestCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
     483          rpcTempCU->setPartSizeSubParts( ePartTemp, 0, uiDepth );
     484        }
     485      }
     486#endif
    460487      // do inter modes, SKIP and 2Nx2N
    461488      if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.cpp

    r446 r455  
    10281028    m_storedStartCUAddrForEncodingSliceSegment.push_back(nextCUAddr);
    10291029    startCUAddrSliceSegmentIdx++;
    1030 
     1030#if H_3D_NBDV
     1031      if(pcSlice->getViewIndex() && !pcSlice->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
     1032      {
     1033        Int iColPoc = pcSlice->getRefPOC(RefPicList(1-pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
     1034        pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc));
     1035      }
     1036#endif
    10311037    while(nextCUAddr<uiRealEndAddress) // determine slice boundaries
    10321038    {
Note: See TracChangeset for help on using the changeset viewer.