Ignore:
Timestamp:
26 Jan 2013, 19:36:53 (13 years ago)
Author:
mitsubishi-htm
Message:

-Integration of JCT3V-C0152 & JCT3V-C0131
-This check-in enable C0131 only

Location:
branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComDataCU.cpp

    r210 r231  
    5151#endif
    5252
     53#if MERL_VSP_C0152
     54
     55#define CHECK_ADD_YET(pcCURef,uiIdx,vspIdx) && !( (pcCURef)->getVSPIndex(uiIdx) == vspIdx && bVspMvZeroDone[vspIdx-1] )
     56
     57inline Void TComDataCU::xInheritVspMode( TComDataCU* pcCURef, UInt uiIdx, Bool* bVspMvZeroDone, Int iCount, Int* iVSPIndexTrue, TComMvField* pcMvFieldNeighbours, DisInfo* pDInfo )
     58{
     59  Int vspIdx = (Int) pcCURef->getVSPIndex(uiIdx);
     60  if( vspIdx != 0 )
     61  {
     62    Int idx = vspIdx - 1;
     63    bVspMvZeroDone[idx] = true;
     64    iVSPIndexTrue [idx] = iCount;
     65
     66    // no need to reset Inter Dir
     67
     68    // set MV using checked disparity
     69    if (vspIdx < 4)
     70    {
     71      pcMvFieldNeighbours[ iCount<<1].setMvField ( pDInfo->m_acMvCand[0],  NOT_VALID );
     72      if ( pcCURef->getSlice()->isInterB() )
     73      {
     74         pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField ( pDInfo->m_acMvCand[0],  NOT_VALID );
     75      }
     76    }
     77  }
     78}
     79
     80inline Bool TComDataCU::xAddVspMergeCand( UChar ucVspMergePos, Int vspIdx, Bool* bVspMvZeroDone, UInt uiDepth, Bool* abCandIsInter, Int& iCount,
     81                                          UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, Int* iVSPIndexTrue, Int mrgCandIdx, DisInfo* pDInfo )
     82{
     83  if( ucVspMergePos == VSP_MERGE_POS )
     84  {
     85    Int idx = vspIdx - 1;
     86    {
     87      if( getSlice()->getSPS()->getViewId() != 0 && bVspMvZeroDone[idx] == false )
     88      {
     89        {
     90          abCandIsInter [iCount] = true;
     91          bVspMvZeroDone[idx] = true;
     92
     93          // get Inter Dir
     94          Int iInterDir = ((getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 0 && getSlice()->getNumRefIdx(REF_PIC_LIST_1) > 0) ? 3 :
     95            (getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 0 ? 1 : 2));
     96          puhInterDirNeighbours[iCount] = iInterDir; // The direction information does not matter
     97          // get Mv using checked disparity vector
     98          if (vspIdx < 4) // spatial
     99          {
     100            pcMvFieldNeighbours[iCount<<1].setMvField(pDInfo->m_acMvCand[0], NOT_VALID );
     101            if ( getSlice()->isInterB() )
     102            {
     103              pcMvFieldNeighbours[(iCount<<1)+1].setMvField( pDInfo->m_acMvCand[0], NOT_VALID );
     104            }
     105          }
     106          iVSPIndexTrue[idx] = iCount;
     107#if SIMP_MRG_PRUN
     108          if ( mrgCandIdx == iCount )
     109          {
     110            return false;
     111          }
     112#endif
     113          iCount ++;
     114        }
     115      }
     116    }
     117  }
     118  return true;
     119}
     120#endif
     121
    53122// ====================================================================================================================
    54123// Constructor / destructor / create / destroy
     
    79148#endif
    80149  m_puhMergeIndex      = NULL;
     150#if MERL_VSP_C0152
     151  m_piVSPIndex         = NULL;
     152#endif
    81153  m_puhLumaIntraDir    = NULL;
    82154  m_puhChromaIntraDir  = NULL;
     
    213285#endif
    214286    m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
     287#if MERL_VSP_C0152
     288    m_piVSPIndex         = (Char*  )xMalloc(Char,   uiNumPartition);
     289#endif
    215290#if HHI_INTER_VIEW_RESIDUAL_PRED
    216291    m_pbResPredAvailable = (Bool*  )xMalloc(Bool,   uiNumPartition);
     
    364439    if ( m_pbICFlag           ) { xFree(m_pbICFlag);            m_pbICFlag          = NULL; }
    365440#endif
     441#if MERL_VSP_C0152
     442    if ( m_piVSPIndex         ) { xFree(m_piVSPIndex);          m_piVSPIndex        = NULL; }
     443#endif
    366444    if ( m_puhMergeIndex      ) { xFree(m_puhMergeIndex);       m_puhMergeIndex     = NULL; }
    367445#if HHI_INTER_VIEW_RESIDUAL_PRED
     
    558636#endif
    559637    m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui];
     638#if MERL_VSP_C0152
     639    m_piVSPIndex[ui] = pcFrom->m_piVSPIndex[ui];
     640#endif
    560641    m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui];
    561642    m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui];
     
    598679#endif
    599680    memset( m_puhMergeIndex     + firstElement, 0,                        numElements * sizeof( *m_puhMergeIndex ) );
     681#if MERL_VSP_C0152
     682    memset( m_piVSPIndex        + firstElement, 0,                        numElements * sizeof( *m_piVSPIndex ) );
     683#endif
    600684    memset( m_puhLumaIntraDir   + firstElement, 2,                        numElements * sizeof( *m_puhLumaIntraDir ) );
    601685    memset( m_puhChromaIntraDir + firstElement, 0,                        numElements * sizeof( *m_puhChromaIntraDir ) );
     
    781865#endif
    782866      m_puhMergeIndex[ui] = 0;
     867#if MERL_VSP_C0152
     868      m_piVSPIndex[ui] = 0;
     869#endif
    783870#if HHI_INTER_VIEW_RESIDUAL_PRED
    784871      m_pbResPredAvailable[ui] = 0;
     
    876963  Int iSizeInUchar = sizeof( UChar  ) * m_uiNumPartition;
    877964  Int iSizeInBool  = sizeof( Bool   ) * m_uiNumPartition;
     965#if MERL_VSP_C0152
     966  Int iSizeInChar  = sizeof( Char   ) * m_uiNumPartition;
     967#endif
    878968
    879969#if H0736_AVC_STYLE_QP_RANGE
     
    893983#endif
    894984  memset( m_puhMergeIndex,      0, iSizeInUchar );
     985#if MERL_VSP_C0152
     986  memset( m_piVSPIndex,         0, iSizeInChar );
     987#endif
    895988#if HHI_INTER_VIEW_RESIDUAL_PRED
    896989  memset( m_pbResPredAvailable, 0, iSizeInBool  );
     
    9731066#endif
    9741067      m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui];
     1068#if MERL_VSP_C0152
     1069      m_piVSPIndex[ui]=pcCU->m_piVSPIndex[uiPartOffset+ui];
     1070#endif
    9751071      m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui];
    9761072      m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui];
     
    11171213#endif
    11181214  m_puhMergeIndex       = pcCU->getMergeIndex()       + uiPart;
     1215#if MERL_VSP_C0152
     1216  m_piVSPIndex          = pcCU->getVSPIndex()         + uiPart;
     1217#endif
    11191218#if HHI_INTER_VIEW_RESIDUAL_PRED
    11201219  m_pbResPredAvailable  = pcCU->getResPredAvail()     + uiPart;
     
    12271326  m_uiCUAddr           = pcCU->getAddr();
    12281327  m_uiAbsIdxInLCU      = uiAbsPartIdx;
    1229  
     1328
    12301329  Int iRastPartIdx     = g_auiZscanToRaster[uiAbsPartIdx];
    12311330  m_uiCUPelX           = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() );
     
    12571356#endif
    12581357  m_puhMergeIndex      = pcCU->getMergeIndex()            + uiAbsPartIdx;
     1358#if MERL_VSP_C0152
     1359  m_piVSPIndex         = pcCU->getVSPIndex()              + uiAbsPartIdx;
     1360#endif
    12591361#if HHI_INTER_VIEW_RESIDUAL_PRED
    12601362  m_pbResPredAvailable = pcCU->getResPredAvail()          + uiAbsPartIdx;
     
    12881390  Int iSizeInUchar  = sizeof( UChar ) * uiNumPartition;
    12891391  Int iSizeInBool   = sizeof( Bool  ) * uiNumPartition;
     1392#if MERL_VSP_C0152
     1393  Int iSizeInChar   = sizeof( Char )  * uiNumPartition;
     1394#endif
    12901395 
    12911396#if H0736_AVC_STYLE_QP_RANGE
     
    13061411#endif
    13071412  memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
     1413#if MERL_VSP_C0152
     1414  memcpy( m_piVSPIndex          + uiOffset, pcCU->getVSPIndex(),          iSizeInChar );
     1415#endif
    13081416#if HHI_INTER_VIEW_RESIDUAL_PRED
    13091417  memcpy( m_pbResPredAvailable  + uiOffset, pcCU->getResPredAvail(),      iSizeInBool  );
     
    14191527  Int iSizeInUchar  = sizeof( UChar ) * m_uiNumPartition;
    14201528  Int iSizeInBool   = sizeof( Bool  ) * m_uiNumPartition;
     1529#if MERL_VSP_C0152
     1530  Int iSizeInChar   = sizeof( Char  ) * m_uiNumPartition;
     1531#endif
    14211532 
    14221533#if H0736_AVC_STYLE_QP_RANGE
     
    14401551#endif
    14411552  memcpy( rpcCU->getMergeIndex()        + m_uiAbsIdxInLCU, m_puhMergeIndex,       iSizeInUchar );
     1553#if MERL_VSP_C0152
     1554  memcpy( rpcCU->getVSPIndex()          + m_uiAbsIdxInLCU, m_piVSPIndex,         iSizeInChar );
     1555#endif
    14421556#if HHI_INTER_VIEW_RESIDUAL_PRED
    14431557  memcpy( rpcCU->getResPredAvail()      + m_uiAbsIdxInLCU, m_pbResPredAvailable,  iSizeInBool  );
     
    15471661  Int iSizeInUchar  = sizeof( UChar  ) * uiQNumPart;
    15481662  Int iSizeInBool   = sizeof( Bool   ) * uiQNumPart;
     1663#if MERL_VSP_C0152
     1664  Int iSizeInChar   = sizeof( Char   ) * uiQNumPart;
     1665#endif
    15491666 
    15501667#if H0736_AVC_STYLE_QP_RANGE
     
    15661683#endif
    15671684  memcpy( rpcCU->getMergeIndex()        + uiPartOffset, m_puhMergeIndex,       iSizeInUchar );
     1685#if MERL_VSP_C0152
     1686  memcpy( rpcCU->getVSPIndex()          + uiPartOffset, m_piVSPIndex,         iSizeInChar );
     1687#endif
    15681688#if HHI_INTER_VIEW_RESIDUAL_PRED
    15691689  memcpy( rpcCU->getResPredAvail()      + uiPartOffset, m_pbResPredAvailable,  iSizeInBool  );
     
    30333153}
    30343154
     3155#if MERL_VSP_C0152
     3156Void TComDataCU::setVSPIndexSubParts ( Char iVSPIdx, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     3157{
     3158  setSubPart<Char>( iVSPIdx, m_piVSPIndex, uiAbsPartIdx, uiDepth, uiPartIdx );
     3159}
     3160#endif
     3161
    30353162#if HHI_INTER_VIEW_RESIDUAL_PRED
    30363163Void TComDataCU::setResPredAvailSubParts( Bool bResPredAvailable, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     
    30843211
    30853212      if((getInterDir(uiPartAddr) & (uiRefIdx+1)) && iBestRefIdx >= 0 && getSlice()->getViewId() != getSlice()->getRefViewId(eRefList, iBestRefIdx))
    3086       {
    30873213        return true;
    3088       }
    30893214    }
    30903215  }
     
    36183743 */
    36193744#if SIMP_MRG_PRUN
     3745#if MERL_VSP_C0152
     3746Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int* iVSPIndexTrue, Int mrgCandIdx )
     3747#else
    36203748Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
     3749#endif
    36213750#else
    36223751Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand )
     
    36453774#endif
    36463775
     3776#if MERL_VSP_C0152
     3777  Bool bVspMvZeroDone[3] = {false, false, false};
     3778#endif
     3779 
    36473780  Int iCount = 0;
    36483781
     
    36873820    getDisMvpCand2(uiPUIdx, uiAbsPartIdx, &cDisInfo
    36883821#if LGE_IVMP_PARALLEL_MERGE_B0136==QC_SIMPLE_NBDV_B0047
    3689 ,
    3690 true
     3822            , true
     3823#endif
     3824#if MERL_VSP_C0152
     3825            , true
    36913826#endif
    36923827);
     
    37143849  Int     iPdmInterDir      = getPdmMergeCandidate( uiPUIdx, aiPdmRefIdx, acPdmMv );
    37153850#endif
     3851
    37163852#if QC_MRG_CANS_B0048
    37173853  if( iPdmDir[0] && !bNoPdmMerge && PDM_MERGE_POS == 0 )
     
    37853921  }
    37863922#endif
     3923
     3924#if MERL_VSP_COMPENSATION_C0152
     3925  //===== vsp 0 =====
     3926  if( iCount < 4 + extraMergeCand )
     3927    if ( !xAddVspMergeCand(0, 1, bVspMvZeroDone, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) )
     3928      return;
     3929#endif
     3930
    37873931  //left
    37883932  UInt uiLeftPartIdx = 0;
     
    38053949  if (!(uiPUIdx == 1 && (partSize == SIZE_Nx2N || partSize == SIZE_nLx2N || partSize == SIZE_nRx2N)))
    38063950  {
    3807   if ( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) )
     3951  if ( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx )
     3952#if MERL_VSP_C0152
     3953     CHECK_ADD_YET(pcCULeft, uiLeftPartIdx, 1)
     3954#endif
     3955  )
    38083956  {
    38093957    abCandIsInter[iCount] = true;
     
    38524000    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
    38534001#endif
     4002#if MERL_VSP_C0152
     4003     xInheritVspMode( pcCULeft, uiLeftPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
     4004#endif
    38544005#if SIMP_MRG_PRUN
    38554006    if ( mrgCandIdx == iCount )
     
    39024053    iCount ++;
    39034054  }
     4055#endif
     4056
     4057#if MERL_VSP_COMPENSATION_C0152
     4058  //===== vsp 1 =====
     4059  if( iCount < 4 + extraMergeCand )
     4060    if ( !xAddVspMergeCand(1, 1, bVspMvZeroDone, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) )
     4061      return;
    39044062#endif
    39054063
     
    39284086#if SIMP_MRG_PRUN
    39294087  if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx )
     4088#if MERL_VSP_C0152
     4089    CHECK_ADD_YET(pcCUAbove, uiAbovePartIdx, 1)
     4090#endif
    39304091    && !(uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD))
    39314092    && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
     
    39784139    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
    39794140#endif
     4141#if MERL_VSP_C0152
     4142     xInheritVspMode( pcCUAbove, uiAbovePartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
     4143#endif
    39804144#if SIMP_MRG_PRUN
    39814145    if ( mrgCandIdx == iCount )
     
    40304194    iCount ++;
    40314195  }
     4196#endif
     4197
     4198#if MERL_VSP_COMPENSATION_C0152
     4199  //===== vsp 2 =====
     4200  if( iCount < 4 + extraMergeCand )
     4201    if ( !xAddVspMergeCand(2, 1, bVspMvZeroDone, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) )
     4202      return;
    40324203#endif
    40334204
     
    40504221#endif
    40514222#if SIMP_MRG_PRUN
    4052   if ( pcCUAboveRight && !pcCUAboveRight->isIntra( uiAboveRightPartIdx ) && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
     4223  if ( pcCUAboveRight && !pcCUAboveRight->isIntra( uiAboveRightPartIdx )
     4224#if MERL_VSP_C0152
     4225    CHECK_ADD_YET(pcCUAboveRight, uiAboveRightPartIdx, 1)
     4226#endif
     4227    && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    40534228#else
    40544229  if ( pcCUAboveRight && !pcCUAboveRight->isIntra( uiAboveRightPartIdx ) )
     
    40744249    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
    40754250#endif
     4251#if MERL_VSP_C0152
     4252    xInheritVspMode( pcCUAboveRight, uiAboveRightPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
     4253#endif
    40764254#if SIMP_MRG_PRUN
    40774255    if ( mrgCandIdx == iCount )
     
    41284306    {
    41294307      assert(iCount < MRG_MAX_NUM_CANDS_MEM);
    4130       Bool bRemoveSpa = false; //prunign to A1, B1
     4308      Bool bRemoveSpa = false; //pruning to A1, B1
    41314309      abCandIsInter        [ iCount ] = true;
    41324310      puhInterDirNeighbours[ iCount ] = iPdmDir[1];
     
    41734351  }
    41744352#endif
     4353#if MERL_VSP_COMPENSATION_C0152
     4354  //===== vsp 3 =====
     4355  if( iCount < 4 + extraMergeCand )
     4356    if ( !xAddVspMergeCand(3, 1, bVspMvZeroDone, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) )
     4357      return;
     4358#endif
     4359
     4360#if MERL_VSP_C0152
     4361#if VSP_MERGE_POS < 4
     4362#if HHI_INTER_VIEW_MOTION_PRED
     4363  if( iCount < 4 + extraMergeCand )
     4364#else
     4365  if( iCount < 4 )
     4366#endif
     4367  {
     4368#endif
     4369#endif
     4370
    41754371  //left bottom
    41764372  UInt uiLeftBottomPartIdx = 0;
     
    41914387#endif
    41924388#if SIMP_MRG_PRUN
    4193   if ( pcCULeftBottom && !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
     4389  if ( pcCULeftBottom && !pcCULeftBottom->isIntra( uiLeftBottomPartIdx )
     4390#if MERL_VSP_C0152
     4391    CHECK_ADD_YET(pcCULeftBottom, uiLeftBottomPartIdx, 1)
     4392#endif
     4393    && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    41944394#else
    41954395  if ( pcCULeftBottom && !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) )
     
    42154415    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
    42164416#endif
     4417#if MERL_VSP_C0152
     4418     xInheritVspMode( pcCULeftBottom, uiLeftBottomPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
     4419#endif
    42174420#if SIMP_MRG_PRUN
    42184421    if ( mrgCandIdx == iCount )
     
    42234426    iCount ++;
    42244427  }
    4225 
     4428#if MERL_VSP_C0152
     4429#if VSP_MERGE_POS < 4
     4430  }
     4431#endif
     4432#endif
     4433 
    42264434#if HHI_INTER_VIEW_MOTION_PRED
    42274435#if QC_MRG_CANS_B0048
     
    42634471#endif
    42644472
    4265   // above left
     4473#if MERL_VSP_COMPENSATION_C0152
     4474  //===== vsp 4 =====
     4475  if( iCount < 4 + extraMergeCand )
     4476    if ( !xAddVspMergeCand(4, 1, bVspMvZeroDone, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) )
     4477      return;
     4478#endif
     4479 
     4480  // above left
    42664481#if HHI_INTER_VIEW_MOTION_PRED
    42674482  if( iCount < 4 + extraMergeCand )
     
    42884503#if SIMP_MRG_PRUN
    42894504    if( pcCUAboveLeft && !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx )
     4505#if MERL_VSP_C0152
     4506     CHECK_ADD_YET(pcCUAboveLeft, uiAboveLeftPartIdx, 1)
     4507#endif
    42904508     && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    42914509     && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
     
    43144532      pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
    43154533#endif
     4534#if MERL_VSP_C0152
     4535     xInheritVspMode( pcCUAboveLeft, uiAboveLeftPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
     4536#endif
    43164537#if SIMP_MRG_PRUN
    43174538      if ( mrgCandIdx == iCount )
     
    43234544    }
    43244545  }
     4546
     4547#if MERL_VSP_COMPENSATION_C0152
     4548  //===== vsp 5 =====
     4549  if( iCount < 4 + extraMergeCand )
     4550    if ( !xAddVspMergeCand(5, 1, bVspMvZeroDone, uiDepth, abCandIsInter, iCount, puhInterDirNeighbours, pcMvFieldNeighbours, iVSPIndexTrue, mrgCandIdx, &cDisInfo) )
     4551      return;
     4552#endif
    43254553
    43264554  if ( getSlice()->getPPS()->getEnableTMVPFlag()
     
    43564584    Int uiLCUIdx = getAddr();
    43574585    PartSize eCUMode = getPartitionSize( 0 );
     4586
     4587#if MERL_VSP_C0152 // Potential bug, not related to BW_VSP
     4588    if (eCUMode==SIZE_NxN)
     4589    {
     4590      printf("Size NxN ???");
     4591      assert(0);
     4592    }
     4593#endif
    43584594
    43594595    deriveRightBottomIdx( eCUMode, uiPUIdx, uiPartIdxRB ); 
     
    45984834    {
    45994835      Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
    4600       if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
     4836#if MERL_VSP_C0152
     4837      Bool bValid = true;
     4838      if (pcMvFieldNeighbours[i<<1].getRefIdx() < 0 || pcMvFieldNeighbours[(j<<1)+1].getRefIdx() < 0) // NOT_VALID
     4839        bValid = false;
     4840#endif
     4841      if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)
     4842#if MERL_VSP_C0152
     4843       && bValid
     4844#endif
     4845         )
    46014846      {
    46024847        abCandIsInter[uiArrayAddr] = true;
     
    47705015  if( uiIter == 0 )
    47715016  {
    4772     if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) )
     5017    if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx )
     5018#if MERL_VSP_C0152
     5019     && !pcCorner->getVSPIndex( uiCornerPUIdx )
     5020#endif
     5021    )
    47735022    {
    47745023      rbValidCand = true;
     
    48055054  else
    48065055  {
    4807     if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) )
     5056    if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx )
     5057#if MERL_VSP_C0152
     5058     && !pcCorner->getVSPIndex( uiCornerPUIdx )
     5059#endif
     5060    )
    48085061    {
    48095062      rbValidCand = true;
     
    49545207#endif
    49555208  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
     5209#if MERL_VSP_C0152
     5210  if(! pcTmpCU->getVSPIndex(uiIdx))
     5211#endif
    49565212  {
    49575213    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     
    49805236
    49815237  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     5238#if MERL_VSP_C0152
     5239  if(! pcTmpCU->getVSPIndex(uiIdx))
     5240#endif
    49825241  {
    49835242    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     
    50065265#endif
    50075266  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
     5267#if MERL_VSP_C0152
     5268  if(! pcTmpCU->getVSPIndex(uiIdx))
     5269#endif
    50085270  {
    50095271    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     
    50315293#endif
    50325294  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     5295#if MERL_VSP_C0152
     5296  if(! pcTmpCU->getVSPIndex(uiIdx))
     5297#endif
    50335298  {
    50345299    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     
    50595324#endif
    50605325  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     5326#if MERL_VSP_C0152
     5327  if(! pcTmpCU->getVSPIndex(uiIdx))
     5328#endif
    50615329  {
    50625330    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     
    52575525}
    52585526
     5527#if MERL_VSP_C0152
     5528Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT, Int iShiftPrec)
     5529{
     5530  Int depStride =  pcBaseViewDepthPicYuv->getStride();
     5531
     5532  Int width  = pcBaseViewDepthPicYuv->getWidth();
     5533  Int height = pcBaseViewDepthPicYuv->getHeight();
     5534
     5535  Int depthPosX = Clip3(0,   width - iWidth  - 1,  iBlkX + (mv->getHor()>>2));
     5536  Int depthPosY = Clip3(0,   height- iHeight - 1,  iBlkY + (mv->getVer()>>2));
     5537
     5538  Pel *depth  = pcBaseViewDepthPicYuv->getLumaAddr() + depthPosX + depthPosY * depStride;
     5539  Pel  maxDepth = 0;
     5540
     5541  for (Int j = 0; j < iHeight; j++)
     5542  {
     5543    for (Int i = 0; i < iWidth; i++)
     5544    {
     5545      if (maxDepth < depth[i])
     5546        maxDepth = depth[i];
     5547    }
     5548    depth += depStride;
     5549  }
     5550
     5551  Int disparity = aiShiftLUT[ maxDepth ] << iShiftPrec;
     5552
     5553  return disparity;
     5554}
     5555
     5556Void TComDataCU::estimateDVFromDM(UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred)
     5557{
     5558  if (picDepth)
     5559  {
     5560    UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr;
     5561    Int iWidth, iHeight;
     5562    getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more
     5563   
     5564    TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec();
     5565    Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
     5566    Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
     5567    Int* aiShiftLUT;
     5568    Int  iShiftPrec;
     5569    getSlice()->getBWVSPLUTParam(aiShiftLUT, iShiftPrec);
     5570   
     5571    Pel x = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT, iShiftPrec );
     5572
     5573    cMvPred->setHor(x);
     5574    clipMv(*cMvPred);
     5575  }
     5576}
     5577#endif
     5578
    52595579#if LGE_DVMCP_A0126
    52605580#if QC_SIMPLE_NBDV_B0047
     
    52635583                                , Bool bParMerge
    52645584#endif
     5585#if MERL_VSP_C0152
     5586                                , Bool bDepthRefine
     5587#endif
    52655588#else
    52665589Void TComDataCU::getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo, Bool bMerge, RefPicList eRefPicList0, Int iRefIdx0
     
    53455668      {
    53465669        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
    5347         if (refViewIdx!= m_pcSlice->getViewId()) // DCP
     5670        if (refViewIdx != m_pcSlice->getViewId()) // DCP
    53485671        {
    53495672          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    53505673          clipMv(cMvPred);
     5674#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
    53515675          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
    53525676          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5677#else
     5678          {
     5679            TComPic* picDepth = NULL;
     5680            picDepth = getSlice()->getRefPicBaseDepth();
     5681            if (picDepth && bDepthRefine)
     5682              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
     5683            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     5684            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5685          }
     5686#endif
    53535687          return;
    53545688        }
     
    53645698        }
    53655699      }
     5700#if MERL_VSP_C0152
     5701      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
     5702      {
     5703        TComPic* picDepth = NULL;
     5704        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
     5705        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
     5706        if (picDepth && bDepthRefine)
     5707          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
     5708        myMv.setVer(0);
     5709
     5710        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
     5711        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
     5712        return;
     5713      }
     5714#endif
    53665715    }
    53675716  }
     
    54055754          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    54065755          clipMv(cMvPred);
     5756#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
    54075757          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
    54085758          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5759#else
     5760          {
     5761            TComPic* picDepth = NULL;
     5762            picDepth = getSlice()->getRefPicBaseDepth();
     5763            if (picDepth && bDepthRefine)
     5764              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
     5765            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     5766            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5767          }
     5768#endif
    54095769          return;
    54105770        }
     
    54245784        }
    54255785      }
     5786#if MERL_VSP_C0152
     5787      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
     5788      {
     5789        TComPic* picDepth = NULL;
     5790        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
     5791        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
     5792        if (picDepth && bDepthRefine)
     5793          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
     5794        myMv.setVer(0);
     5795
     5796        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
     5797        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
     5798        return;
     5799      }
     5800#endif
    54265801    }
    54275802  }
     
    54595834          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    54605835          clipMv(cMvPred);
     5836#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
    54615837          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
    54625838          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5839#else
     5840          {
     5841            TComPic* picDepth = NULL;
     5842            picDepth = getSlice()->getRefPicBaseDepth();
     5843            if (picDepth && bDepthRefine)
     5844              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
     5845            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     5846            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5847          }
     5848#endif
    54635849          return;
    54645850        }
     
    54785864        }
    54795865      }
     5866#if MERL_VSP_C0152
     5867      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
     5868      {
     5869        TComPic* picDepth = NULL;
     5870        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
     5871        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
     5872        if (picDepth && bDepthRefine)
     5873          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
     5874        myMv.setVer(0);
     5875
     5876        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
     5877        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
     5878        return;
     5879      }
     5880#endif
    54805881    }
    54815882  }
     
    55095910          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    55105911          clipMv(cMvPred);
     5912#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
    55115913          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
    55125914          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5915#else
     5916          {
     5917            TComPic* picDepth = NULL;
     5918            picDepth = getSlice()->getRefPicBaseDepth();
     5919            if (picDepth && bDepthRefine)
     5920              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
     5921            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     5922            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5923          }
     5924#endif
    55135925          return;
    55145926        }
     
    55245936        }
    55255937      }
     5938#if MERL_VSP_C0152
     5939      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
     5940      {
     5941        TComPic* picDepth = NULL;
     5942        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
     5943        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
     5944        if (picDepth && bDepthRefine)
     5945          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
     5946        myMv.setVer(0);
     5947
     5948        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
     5949        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
     5950        return;
     5951      }
     5952#endif
    55265953    }
    55275954  }
     
    55615988          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    55625989          clipMv(cMvPred);
     5990#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
    55635991          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
    55645992          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     5993#else
     5994          {
     5995            TComPic* picDepth = NULL;
     5996            picDepth = getSlice()->getRefPicBaseDepth();
     5997            if (picDepth && bDepthRefine)
     5998              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
     5999            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     6000            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     6001          }
     6002#endif
    55656003          return;
    55666004        }
     
    55806018        }
    55816019      }
     6020#if MERL_VSP_C0152
     6021      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
     6022      {
     6023        TComPic* picDepth = NULL;
     6024        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
     6025        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
     6026        if (picDepth && bDepthRefine)
     6027          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
     6028        myMv.setVer(0);
     6029
     6030        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
     6031        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
     6032        return;
     6033      }
     6034#endif
    55826035    }
    55836036  }
     
    58106263          {
    58116264            clipMv(cColMv);
    5812             pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
    5813             pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     6265#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
     6266            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     6267            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
     6268#else
     6269            {
     6270              TComPic* picDepth = NULL;
     6271              picDepth = getSlice()->getRefPicBaseDepth();
     6272              if (picDepth && bDepthRefine)
     6273                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
     6274
     6275              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     6276              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
     6277            }
     6278#endif
    58146279            return ;
    58156280          }
     
    58196284        {
    58206285          clipMv(cColMv);
    5821           pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
    5822           pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     6286#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
     6287            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     6288            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
     6289#else
     6290            {
     6291              TComPic* picDepth = NULL;
     6292              picDepth = getSlice()->getRefPicBaseDepth();
     6293              if (picDepth && bDepthRefine)
     6294                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
     6295              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     6296              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
     6297            }
     6298#endif
    58236299          return ;
    58246300        }
     
    58286304          {
    58296305            clipMv(cColMv);
    5830             pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
    5831             pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     6306#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
     6307            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     6308            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
     6309#else
     6310            {
     6311              TComPic* picDepth = NULL;
     6312              picDepth = getSlice()->getRefPicBaseDepth();
     6313              if (picDepth && bDepthRefine)
     6314                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
     6315              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     6316              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
     6317            }
     6318#endif
    58326319            return ;
    58336320          }
     
    58526339          TComMv dv( aiDvMcpDvCand[iList][ i ], 0 );
    58536340          clipMv( dv );
    5854           pDInfo->m_acMvCand[ pDInfo->iN  ] = dv;
    5855           pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0;
     6341#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
     6342          pDInfo->m_acMvCand[ pDInfo->iN] = dv;
     6343          pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0;
     6344#else
     6345          {
     6346            TComPic* picDepth = NULL;
     6347            picDepth = getSlice()->getRefPicBaseDepth();
     6348            if (picDepth && bDepthRefine)
     6349              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &dv);
     6350            pDInfo->m_acMvCand[ pDInfo->iN] = dv;
     6351            pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0;
     6352          }
     6353#endif
    58566354          return;
    58576355        }
     
    58636361}
    58646362#endif
     6363
    58656364#endif
    58666365
     
    59046403#if QC_SIMPLE_NBDV_B0047
    59056404#if FIX_LGE_IVMP_PARALLEL_MERGE_B0136
    5906       getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false);
     6405      getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false
     6406#if MERL_VSP_C0152
     6407            , true
     6408#endif
     6409              );
    59076410#else
    59086411      getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo);
     
    64076910  }
    64086911 
     6912#if MERL_VSP_C0152
     6913  if(pcTmpCU != NULL && pcTmpCU->getVSPIndex(uiIdx))
     6914  {
     6915    return false;
     6916  }
     6917#endif
     6918
    64096919  if ( pcTmpCU != NULL && m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) )
    64106920  {
     
    65157025  TComDataCU* pcTmpCU = NULL;
    65167026  UInt uiIdx;
     7027
    65177028  switch( eDir )
    65187029  {
     
    65727083    return false;
    65737084  }
    6574  
     7085
     7086#if MERL_VSP_C0152
     7087  if(pcTmpCU->getVSPIndex(uiIdx))
     7088  {
     7089    return false;
     7090  }
     7091#endif
    65757092  RefPicList eRefPicList2nd = REF_PIC_LIST_0;
    65767093  if(       eRefPicList == REF_PIC_LIST_0 )
     
    67027219  TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
    67037220  iColViewIdx = pColCU->getSlice()->getViewId();
    6704 
     7221#if MERL_VSP_C0152
     7222  //TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
     7223  if( pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr) < 0)
     7224  {
     7225    return false;
     7226  }
     7227#endif
    67057228
    67067229  if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiAbsPartAddr))
     
    70267549    return false;
    70277550  }
    7028  
     7551
    70297552  if( m_pcSlice->getRefPic( eRefPicList, iRefIdx )->getViewId() != m_pcSlice->getViewId() )
    70307553  {
     
    70717594    }
    70727595  }
     7596
     7597#if MERL_VSP_C0152 // Preventive
     7598  if (pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartIdxCenter) < 0) // NOT_VALID
     7599    return false;
     7600#endif
    70737601 
    70747602  // Scale the vector.
     
    78468374  memcpy( m_puhInterDir + uiAbsPartIdxDst, pcCU->getInterDir() + uiAbsPartIdxSrc,       sizeof( m_puhInterDir[0] ) * uiNumPartition );
    78478375
     8376#if MERL_VSP_C0152 && MTK_UNCONSTRAINED_MVI_B0083
     8377  memcpy( m_piVSPIndex + uiAbsPartIdxDst,  pcCU->getVSPIndex() + uiAbsPartIdxSrc, sizeof( m_piVSPIndex[0] ) * uiNumPartition );
     8378#endif
     8379
    78488380#if !MTK_UNCONSTRAINED_MVI_B0083
    78498381  memcpy( m_apiMVPIdx[0] + uiAbsPartIdxDst, pcCU->getMVPIdx(REF_PIC_LIST_0) + uiAbsPartIdxSrc, sizeof(*m_apiMVPIdx[0]) * uiNumPartition );
     
    79538485#if QC_SIMPLE_NBDV_B0047
    79548486#if FIX_LGE_IVMP_PARALLEL_MERGE_B0136
    7955   getDisMvpCand2( 0, 0,  &cDisInfo, false);
     8487  getDisMvpCand2( 0, 0,  &cDisInfo, false );
    79568488#else
    79578489  getDisMvpCand2( 0, 0,  &cDisInfo);
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComDataCU.h

    r189 r231  
    197197#endif
    198198  UChar*        m_puhMergeIndex;      ///< array of merge candidate indices
     199#if MERL_VSP_C0152
     200  Char*         m_piVSPIndex;         ///< array of VSP flags to indicate the current block uses synthetic predictor or not
     201                                      ///< value 0: non-VSP, value 1: VSP
     202#endif
    199203#if AMP_MRG
    200204  Bool          m_bIsMergeAMP;
     
    279283  Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
    280284  Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
    281 
     285#if MERL_VSP_C0152
     286  inline Bool   xAddVspMergeCand      ( UChar ucVspMergePos, Int vspIdx, Bool* bVspMvZeroDone, UInt uiDepth, Bool* abCandIsInter, Int& iCount,
     287                                        UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, Int* iVSPIndexTrue, Int mrgCandIdx, DisInfo* pDisInfo );
     288  inline Void   xInheritVspMode       ( TComDataCU* pcCURef, UInt uiIdx, Bool* bVspMvZeroDone, Int iCount, Int* iVSPIndexTrue, TComMvField* pcMvFieldNeighbours, DisInfo* pDInfo ) ;
     289#endif
    282290  Void          deriveRightBottomIdx        ( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxRB );
    283291  Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx );
     
    366374  Void          copyTextureMotionDataFrom( TComDataCU* pcCU, UInt uiDepth, UInt uiAbsPartIdxSrc, UInt uiAbsPartIdxDst = 0 );
    367375#endif
    368  
    369   // -------------------------------------------------------------------------------------------------------------------
     376
     377   // -------------------------------------------------------------------------------------------------------------------
    370378  // member functions for CU data
    371379  // -------------------------------------------------------------------------------------------------------------------
     
    471479  Void          setMergeIndex         ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex;  }
    472480  Void          setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
     481
     482#if MERL_VSP_C0152
     483  Char*         getVSPIndex        ()                        { return m_piVSPIndex;        }
     484  Char          getVSPIndex        ( UInt uiIdx )            { return m_piVSPIndex[uiIdx]; }
     485  Void          setVSPIndex        ( UInt uiIdx, Int n )     { m_piVSPIndex[uiIdx] = n;    }
     486  Void          setVSPIndexSubParts( Char bVSPIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
     487#endif
     488
    473489  template <typename T>
    474490  Void          setSubPart            ( T bParameter, T* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
     
    555571  Void          getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo
    556572#if LGE_IVMP_PARALLEL_MERGE_B0136
    557     , Bool bParMerg = false
     573                              , Bool bParMerg = false
     574#endif
     575#if MERL_VSP_C0152
     576                              , Bool bDepthRefine = false
    558577#endif
    559578    );
     
    567586#endif
    568587
     588#endif
     589
     590#if MERL_VSP_C0152
     591  Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT, Int iShiftPrec);
     592  Void          estimateDVFromDM(UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred);
    569593#endif
    570594  Bool          getIViewOrgDepthMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv );
     
    685709  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
    686710#if SIMP_MRG_PRUN
    687   Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
    688 #else
    689   Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand );
    690 #endif
    691   Void          deriveLeftRightTopIdxGeneral  ( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
    692   Void          deriveLeftBottomIdxGeneral    ( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
     711#if MERL_VSP_C0152
     712  Void          getInterMergeCandidates     ( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int* uiVSPIndexTrue, Int mrgCandIdx = -1 );
     713#else
     714  Void          getInterMergeCandidates     ( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
     715#endif
     716#else
     717  Void          getInterMergeCandidates     ( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand );
     718#endif
     719  Void          deriveLeftRightTopIdxGeneral( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
     720  Void          deriveLeftBottomIdxGeneral  ( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
    693721 
    694722 
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComDepthMapGenerator.cpp

    r189 r231  
    562562  m_cTmpPic.dump( acFilename, ( pcPic->getPOC() != 0 )  );
    563563}
     564
    564565#endif
    565566
     
    744745      Int         iNumRefPics       = pcSlice->getNumRefIdx( eRefPicList );
    745746      for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
    746 {
     747      {
    747748        if( pcSlice->getRefPOC( eRefPicList, iPdmRefIdx ) == pcSlice->getPOC())
    748749        {
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComLoopFilter.cpp

    r56 r231  
    439439 
    440440  //-- Set BS for Intra MB : BS = 4 or 3
    441   if ( pcCUP->isIntra(uiPartP) || pcCUQ->isIntra(uiPartQ) )
     441  if ( pcCUP->isIntra(uiPartP) || pcCUQ->isIntra(uiPartQ)
     442#if MERL_VSP_C0152
     443    || pcCUP->getVSPIndex(uiPartP) || pcCUQ->getVSPIndex(uiPartQ)
     444#endif
     445     )
    442446  {
    443447    uiBs = 2;
     
    445449 
    446450  //-- Set BS for not Intra MB : BS = 2 or 1 or 0
    447   if ( !pcCUP->isIntra(uiPartP) && !pcCUQ->isIntra(uiPartQ) )
     451  if ( !pcCUP->isIntra(uiPartP) && !pcCUQ->isIntra(uiPartQ)
     452#if MERL_VSP_C0152
     453    && !pcCUP->getVSPIndex(uiPartP) && !pcCUQ->getVSPIndex(uiPartQ)
     454#endif
     455  )
    448456  {
    449457#if NSQT_LFFIX
     
    542550  }   // enf of "if( not Intra )"
    543551 
     552#if MERL_VSP_C0152
     553  if ( pcCUP->getVSPIndex(uiPartP) || pcCUQ->getVSPIndex(uiPartQ))
     554  {
     555    uiBs = 0;
     556  }
     557#endif
     558
    544559  m_aapucBS[iDir][uiAbsPartIdx] = uiBs;
    545560}
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComMotionInfo.cpp

    r189 r231  
    378378
    379379#if MTK_UNCONSTRAINED_MVI_B0083
    380 Void TComCUMvField::setUndefinedMv( Int iPartAddr, Int iNumPart, Char* pePredMode, UChar* puhInterDir, Int refIdx, Int InterDir )
     380Void TComCUMvField::setUndefinedMv( Int iPartAddr, Int iNumPart, Char* pePredMode, UChar* puhInterDir, Int refIdx, Int InterDir
     381                                   )
    381382{
    382383  PredMode predMode = MODE_INTRA;
     
    386387  {
    387388    predMode = static_cast<PredMode>( pePredMode[ iPartAddr+i ] );
    388     if( predMode==MODE_INTRA )
     389    if( predMode == MODE_INTRA )
    389390    {
    390391      m_pcMv[iPartAddr+i] = cMv;
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComPic.cpp

    r210 r231  
    703703}
    704704
    705 
    706705//! \}
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComPrediction.cpp

    r210 r231  
    5454{
    5555  m_piYuvExt = NULL;
     56#if MERL_VSP_C0152
     57  m_pDepth = (Int*) malloc(64*64*sizeof(Int)); // TODO: Use a smart way to determine the size of the array
     58  if (m_pDepth == NULL)
     59  {
     60      printf("ERROR: UKTGHU, No memory allocated.\n");
     61  }
     62#endif
    5663}
    5764
     
    5966{
    6067 
     68#if MERL_VSP_C0152
     69  if (m_pDepth != NULL)
     70  {
     71      free(m_pDepth);
     72  }
     73#endif
    6174  delete[] m_piYuvExt;
    6275
     
    886899  }
    887900}
     901
     902#if MERL_VSP_C0152
     903#if DEPTH_MAP_GENERATION
     904Void TComPrediction::motionCompensationBWVSP( TComDataCU* pcCU, TComYuv* pcYuvPred, UInt uiAbsPartIdx, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
     905#else
     906Void TComPrediction::motionCompensationBWVSP ( TComDataCU* pcCU, TComYuv* pcYuvPred, UInt uiAbsPartIdx, RefPicList eRefPicList, Int iPartIdx )
     907#endif
     908{
     909  Int         iWidth;
     910  Int         iHeight;
     911  UInt        uiPartAddr;
     912
     913  if ( iPartIdx >= 0 )
     914  {
     915    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
     916
     917#if DEPTH_MAP_GENERATION
     918    if( bPrdDepthMap )
     919    {
     920      iWidth  >>= uiSubSampExpX;
     921      iHeight >>= uiSubSampExpY;
     922    }
     923#endif
     924
     925    if ( eRefPicList != REF_PIC_LIST_X )
     926    {
     927#if LGE_ILLUCOMP_B0045
     928      if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr))
     929#else
     930      if( pcCU->getSlice()->getPPS()->getUseWP())
     931#endif
     932      {
     933#if DEPTH_MAP_GENERATION
     934        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr , iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     935#else
     936        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr , iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true );
     937#endif
     938      }
     939      else
     940      {
     941#if DEPTH_MAP_GENERATION
     942        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr , iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     943#else
     944        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
     945#endif
     946      }
     947#if LGE_ILLUCOMP_B0045
     948      if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr))
     949#else
     950      if( pcCU->getSlice()->getPPS()->getUseWP())
     951#endif
     952      {
     953        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx );
     954      }
     955    }
     956    else
     957    {
     958#if DEPTH_MAP_GENERATION
     959      if( xCheckIdenticalMotion( pcCU, uiPartAddr ) && !bPrdDepthMap )
     960#else
     961      if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
     962#endif
     963      {
     964#if DEPTH_MAP_GENERATION
     965        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr , iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     966#else
     967        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr , iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false );
     968#endif
     969      }
     970      else
     971      {
     972#if DEPTH_MAP_GENERATION
     973        xPredInterBiBWVSP  (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr , iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
     974#else
     975        xPredInterBiBWVSP  (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr , iWidth, iHeight, pcYuvPred, iPartIdx );
     976#endif
     977      }
     978    }
     979    return;
     980  }
     981
     982  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ )
     983  {
     984    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
     985
     986#if DEPTH_MAP_GENERATION
     987    if( bPrdDepthMap )
     988    {
     989      iWidth  >>= uiSubSampExpX;
     990      iHeight >>= uiSubSampExpY;
     991    }
     992#endif
     993
     994    if ( eRefPicList != REF_PIC_LIST_X )
     995    {
     996#if LGE_ILLUCOMP_B0045
     997      if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr))
     998#else
     999      if( pcCU->getSlice()->getPPS()->getUseWP())
     1000#endif
     1001      {
     1002#if DEPTH_MAP_GENERATION
     1003        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr , iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     1004#else
     1005        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true );
     1006#endif   
     1007      }
     1008      else
     1009      {
     1010#if DEPTH_MAP_GENERATION
     1011        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     1012#else
     1013        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
     1014#endif   
     1015      }
     1016#if DEPTH_MAP_GENERATION
     1017      xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     1018#else
     1019      xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
     1020#endif 
     1021#if LGE_ILLUCOMP_B0045
     1022      if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr))
     1023#else
     1024      if( pcCU->getSlice()->getPPS()->getUseWP())
     1025#endif
     1026      {
     1027        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx );
     1028      }
     1029    }
     1030    else
     1031    {
     1032      if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
     1033      {
     1034#if DEPTH_MAP_GENERATION
     1035        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     1036#else
     1037        xPredInterUniBWVSP (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false );
     1038#endif
     1039      }
     1040      else
     1041      {
     1042#if DEPTH_MAP_GENERATION
     1043        xPredInterBiBWVSP  (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
     1044#else
     1045        xPredInterBiBWVSP  (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
     1046#endif
     1047      }
     1048    }
     1049  }
     1050
     1051  return;
     1052}
     1053
     1054
     1055// Output: rpcYuvPred
     1056#if DEPTH_MAP_GENERATION
     1057Void TComPrediction::xPredInterUniBWVSP ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi )
     1058#else
     1059Void TComPrediction::xPredInterUniBWVSP ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi )
     1060#endif
     1061{
     1062  Int  iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );   
     1063  Int  vspIdx  = pcCU->getVSPIndex(uiPartAddr);
     1064  if (vspIdx != 0)
     1065  {
     1066    if (iRefIdx >= 0)
     1067    {
     1068      printf("vspIdx = %d, iRefIdx = %d\n", vspIdx, iRefIdx);
     1069    }
     1070    assert (iRefIdx < 0); // assert (iRefIdx == NOT_VALID);
     1071  }
     1072  else
     1073  {
     1074    assert (iRefIdx >= 0);
     1075  }
     1076
     1077  TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
     1078  pcCU->clipMv(cMv);
     1079
     1080#if DEPTH_MAP_GENERATION
     1081  if( bPrdDepthMap )
     1082  {
     1083    UInt uiRShift = 0;
     1084#if PDM_REMOVE_DEPENDENCE
     1085    if( pcCU->getPic()->getStoredPDMforV2() == 1 )
     1086      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMapTemp(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 );
     1087    else
     1088#endif
     1089      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 );
     1090
     1091    return;
     1092  }
     1093#endif
     1094
     1095#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
     1096  if( pcCU->getSlice()->getSPS()->isDepth() )
     1097  {
     1098    if (vspIdx != 0)
     1099    { // depth, vsp
     1100      // get depth estimator here
     1101      TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth();
     1102      TComPicYuv* pcBaseViewDepthPicYuv = NULL;
     1103      if (vspIdx < 4) // spatial
     1104      {
     1105        pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec();
     1106      }
     1107      Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     1108      Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     1109      Int* pShiftLUT;
     1110      Int iShiftPrec;
     1111      pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec);
     1112      //using disparity to find the depth block of the base view as the depth block estimator of the current block
     1113      //using depth block estimator and base view texture to get Backward warping
     1114      xPredInterLumaBlkFromDM  ( pcBaseViewDepthPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,     pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     1115      xPredInterChromaBlkFromDM( pcBaseViewDepthPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1,  pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     1116    }
     1117    else
     1118    { // depth, non-vsp
     1119      UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 );
     1120      UInt uiOffset = bi ? IF_INTERNAL_OFFS : 0;
     1121#if DEPTH_MAP_GENERATION
     1122      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift, uiOffset );
     1123#else
     1124      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, uiOffset );
     1125#endif
     1126
     1127      xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
     1128    }
     1129  }
     1130  else // texture
     1131  {
     1132#endif
     1133    if ( vspIdx != 0 && !pcCU->getSlice()->getSPS()->isDepth())
     1134    { // texture, vsp
     1135      TComPic*    pRefPicBaseTxt        = pcCU->getSlice()->getRefPicBaseTxt();
     1136      TComPicYuv* pcBaseViewTxtPicYuv   = pRefPicBaseTxt->getPicYuvRec();
     1137      TComPicYuv* pcBaseViewDepthPicYuv = NULL;
     1138      if (vspIdx < 4) // spatial
     1139      {
     1140        TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth();
     1141        pcBaseViewDepthPicYuv     = pRefPicBaseDepth->getPicYuvRec();
     1142      }
     1143      Int iBlkX = ( pcCU->getAddr() % pRefPicBaseTxt->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     1144      Int iBlkY = ( pcCU->getAddr() / pRefPicBaseTxt->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     1145      Int* pShiftLUT;
     1146      Int iShiftPrec;
     1147      pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec);
     1148
     1149      //using disparity to find the depth block of the base view as the depth block estimator of the current block
     1150      //using depth block estimator and base view texture to get Backward warping
     1151      xPredInterLumaBlkFromDM  ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,    pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     1152      xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     1153    }
     1154    else
     1155    { // texture, non-vsp
     1156#if LGE_ILLUCOMP_B0045
     1157      Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId());
     1158
     1159      xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag);
     1160      xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag );
     1161#else
     1162      xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
     1163      xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
     1164#endif
     1165    }
     1166#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
     1167  }
     1168#endif
     1169}
     1170
     1171
     1172#if DEPTH_MAP_GENERATION
     1173Void TComPrediction::xPredInterBiBWVSP ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
     1174#else
     1175Void TComPrediction::xPredInterBiSDM ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx )
     1176#endif
     1177{
     1178  TComYuv* pcMbYuv;
     1179  Int      iRefIdx[2] = {-1, -1};
     1180
     1181  for ( Int iRefList = 0; iRefList < 2; iRefList++ )
     1182  {
     1183    RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
     1184    iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
     1185#if MERL_VSP_C0152
     1186    if(!pcCU->getVSPIndex(uiPartAddr))
     1187    {
     1188      if ( iRefIdx[iRefList] < 0 )
     1189      {
     1190        continue;
     1191      }
     1192    }
     1193    else
     1194    {
     1195      if ( iRefList== REF_PIC_LIST_1 && iRefIdx[iRefList] < 0 ) // iRefIdx[iRefList] ==NOT_VALID
     1196      {
     1197        continue;
     1198      }
     1199    }
     1200#else
     1201    if ( iRefIdx[iRefList] < 0 )
     1202    {
     1203      continue;
     1204    }
     1205#endif
     1206    assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) );
     1207
     1208    pcMbYuv = &m_acYuvPred[iRefList];
     1209    if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 )
     1210    {
     1211#if DEPTH_MAP_GENERATION
     1212      xPredInterUniBWVSP ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     1213#else
     1214      xPredInterUniBWVSP ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
     1215#endif
     1216    }
     1217    else
     1218    {
     1219      if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() )
     1220      {
     1221#if DEPTH_MAP_GENERATION
     1222        xPredInterUniBWVSP ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     1223#else
     1224        xPredInterUniBWVSP ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
     1225#endif
     1226      }
     1227      else
     1228      {
     1229#if DEPTH_MAP_GENERATION
     1230        xPredInterUniBWVSP ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     1231#else
     1232        xPredInterUniBWVSP ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, false );
     1233#endif
     1234      }
     1235    }
     1236  }
     1237
     1238  if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() )
     1239  {
     1240#if MERL_VSP_C0152
     1241    if(pcCU->getVSPIndex(uiPartAddr))
     1242      m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight );
     1243    else
     1244#endif
     1245    xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
     1246  }
     1247  else
     1248  {
     1249#if DEPTH_MAP_GENERATION
     1250    if ( bPrdDepthMap )
     1251    {
     1252      xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY );
     1253    }
     1254    else
     1255    {
     1256#if MERL_VSP_C0152
     1257      if(pcCU->getVSPIndex(uiPartAddr))
     1258        m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight );
     1259      else
     1260#endif
     1261      xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
     1262    }
     1263#else
     1264    xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
     1265#endif
     1266  }
     1267}
     1268#endif
    8881269
    8891270Void
     
    11191500}
    11201501
     1502#if MERL_VSP_C0152
     1503// Input:
     1504// refPic: Ref picture. Full picture, with padding
     1505// posX, posY:     PU position, texture
     1506// size_x, size_y: PU size
     1507// partAddr: z-order index
     1508// mv: disparity vector. derived from neighboring blocks
     1509//
     1510// Output: dstPic, PU predictor 64x64
     1511Void TComPrediction::xPredInterLumaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv* mv, UInt partAddr,Int posX, Int posY, Int size_x, Int size_y, Bool isDepth, Int vspIdx
     1512                                            , TComYuv *&dstPic )
     1513{
     1514  Int widthLuma;
     1515  Int heightLuma;
     1516
     1517  if (isDepth)
     1518  {
     1519    widthLuma   =  pPicBaseDepth->getWidth();
     1520    heightLuma  =  pPicBaseDepth->getHeight();
     1521  }
     1522  else
     1523  {
     1524    widthLuma   =  refPic->getWidth();
     1525    heightLuma  =  refPic->getHeight();
     1526  }
     1527
     1528#if MERL_VSP_BLOCKSIZE_C0152 != 1
     1529  Int widthDepth  = pPicBaseDepth->getWidth();
     1530  Int heightDepth = pPicBaseDepth->getHeight();
     1531#endif
     1532
     1533  Int nTxtPerDepthX = widthLuma  / ( pPicBaseDepth->getWidth() );  // texture pixel # per depth pixel
     1534  Int nTxtPerDepthY = heightLuma / ( pPicBaseDepth->getHeight() );
     1535
     1536  Int refStride = refPic->getStride();
     1537  Int dstStride = dstPic->getStride();
     1538  Int depStride =  pPicBaseDepth->getStride();
     1539
     1540  Int depthPosX = Clip3(0,   widthLuma - size_x - 1,  (posX/nTxtPerDepthX) + (mv->getHor()>>2));
     1541  Int depthPosY = Clip3(0,   heightLuma- size_y - 1,  (posY/nTxtPerDepthY) + (mv->getVer()>>2));
     1542
     1543  Pel *ref    = refPic->getLumaAddr() + posX + posY * refStride;
     1544  Pel *dst    = dstPic->getLumaAddr(partAddr);
     1545  Pel *depth  = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride;
     1546
     1547#if MERL_VSP_BLOCKSIZE_C0152 != 1
     1548#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1549  Int  dW = size_x>>1;
     1550  Int  dH = size_y>>1;
     1551#endif
     1552#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1553  Int  dW = size_x>>2;
     1554  Int  dH = size_y>>2;
     1555#endif
     1556  {
     1557    Pel* depthi = depth;
     1558    for (Int j = 0; j < dH; j++)
     1559    {
     1560      for (Int i = 0; i < dW; i++)
     1561      {
     1562        Pel* depthTmp;
     1563#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1564        if (depthPosX + (i<<1) < widthDepth)
     1565          depthTmp = depthi + (i << 1);
     1566        else
     1567          depthTmp = depthi + (widthDepth - depthPosX - 1);
     1568#endif
     1569#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1570        if (depthPosX + (i<<2) < widthDepth)
     1571          depthTmp = depthi + (i << 2);
     1572        else
     1573          depthTmp = depthi + (widthDepth - depthPosX - 1);
     1574#endif
     1575        Int maxV = 0;
     1576        for (Int blockj = 0; blockj < MERL_VSP_BLOCKSIZE_C0152; blockj++)
     1577        {
     1578          Int iX = 0;
     1579          for (Int blocki = 0; blocki < MERL_VSP_BLOCKSIZE_C0152; blocki++)
     1580          {
     1581            if (maxV < depthTmp[iX])
     1582              maxV = depthTmp[iX];
     1583#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1584            if (depthPosX + (i<<1) + blocki < widthDepth - 1)
     1585#else // MERL_VSP_BLOCKSIZE_C0152 == 4
     1586            if (depthPosX + (i<<2) + blocki < widthDepth - 1)
     1587#endif
     1588              iX++;
     1589          }
     1590#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1591          if (depthPosY + (j<<1) + blockj < heightDepth - 1)
     1592#else // MERL_VSP_BLOCKSIZE_C0152 == 4
     1593          if (depthPosY + (j<<2) + blockj < heightDepth - 1)
     1594#endif
     1595            depthTmp += depStride;
     1596        }
     1597        m_pDepth[i+j*dW] = maxV;
     1598      } // end of i < dW
     1599#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1600      if (depthPosY + ((j+1)<<1) < heightDepth)
     1601        depthi += (depStride << 1);
     1602      else
     1603        depthi  = depth + (heightDepth-depthPosY-1)*depStride;
     1604#endif
     1605#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1606      if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1
     1607        depthi += (depStride << 2);
     1608      else
     1609        depthi  = depth + (heightDepth-depthPosY-1)*depStride; // the last line
     1610#endif
     1611    }
     1612  }
     1613#endif
     1614 
     1615#if MERL_VSP_BLOCKSIZE_C0152 != 1
     1616  Int yDepth = 0;
     1617#endif
     1618  for ( Int yTxt = 0; yTxt < size_y; yTxt += nTxtPerDepthY )
     1619  {
     1620    for ( Int xTxt = 0, xDepth = 0; xTxt < size_x; xTxt += nTxtPerDepthX, xDepth++ )
     1621    {
     1622      Pel rep_depth = 0; // to store the depth value used for warping
     1623#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1624      rep_depth = depth[xDepth];
     1625#endif
     1626#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1627      rep_depth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW];
     1628#endif
     1629#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1630      rep_depth = m_pDepth[(xTxt>>2) + (yTxt>>2)*dW];
     1631#endif
     1632
     1633      assert( rep_depth >= 0 && rep_depth <= 255 );
     1634      Int disparity = pShiftLUT[ rep_depth ] << iShiftPrec;
     1635      Int refOffset = xTxt + (disparity >> 2);
     1636      Int xFrac = disparity & 0x3;
     1637      Int absX  = posX + refOffset;
     1638
     1639      if (xFrac == 0)
     1640        absX = Clip3(0, widthLuma-1, absX);
     1641      else
     1642        absX = Clip3(4, widthLuma-5, absX);
     1643
     1644      refOffset = absX - posX;
     1645
     1646      assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 );
     1647      m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true );
     1648    }
     1649    ref   += refStride*nTxtPerDepthY;
     1650    dst   += dstStride*nTxtPerDepthY;
     1651    depth += depStride;
     1652#if MERL_VSP_BLOCKSIZE_C0152 != 1
     1653    yDepth++;
     1654#endif
     1655  }
     1656}
     1657
     1658Void TComPrediction::xPredInterChromaBlkFromDM ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv*mv, UInt partAddr, Int posX, Int posY, Int size_x, Int size_y, Bool isDepth, Int vspIdx
     1659                                               , TComYuv *&dstPic )
     1660{
     1661  Int refStride = refPic->getCStride();
     1662  Int dstStride = dstPic->getCStride();
     1663  Int depStride = pPicBaseDepth->getStride();
     1664
     1665  Int widthChroma, heightChroma;
     1666  if( isDepth)
     1667  {
     1668     widthChroma   = pPicBaseDepth->getWidth()>>1;
     1669     heightChroma  = pPicBaseDepth->getHeight()>>1;
     1670  }
     1671  else
     1672  {
     1673     widthChroma   = refPic->getWidth()>>1;
     1674     heightChroma  = refPic->getHeight()>>1;
     1675  }
     1676
     1677  // Below is only for Texture chroma component
     1678
     1679  Int widthDepth  = pPicBaseDepth->getWidth();
     1680  Int heightDepth = pPicBaseDepth->getHeight();
     1681
     1682  Int nTxtPerDepthX, nTxtPerDepthY;  // Number of texture samples per one depth sample
     1683  Int nDepthPerTxtX, nDepthPerTxtY;  // Number of depth samples per one texture sample
     1684
     1685  Int depthPosX;  // Starting position in depth image
     1686  Int depthPosY;
     1687
     1688  if ( widthChroma > widthDepth )
     1689  {
     1690    nTxtPerDepthX = widthChroma / widthDepth;
     1691    nDepthPerTxtX = 1;
     1692    depthPosX = posX / nTxtPerDepthX + (mv->getHor()>>2);        //mv denotes the disparity for VSP
     1693  }
     1694  else
     1695  {
     1696    nTxtPerDepthX = 1;
     1697    nDepthPerTxtX = widthDepth / widthChroma;
     1698    depthPosX = posX * nDepthPerTxtX + (mv->getHor()>>2);        //mv denotes the disparity for VSP
     1699  }
     1700  depthPosX = Clip3(0, widthDepth - (size_x<<1) - 1, depthPosX);
     1701 
     1702  if ( heightChroma > heightDepth )
     1703  {
     1704    nTxtPerDepthY = heightChroma / heightDepth;
     1705    nDepthPerTxtY = 1;
     1706    depthPosY = posY / nTxtPerDepthY + (mv->getVer()>>2);     //mv denotes the disparity for VSP
     1707  }
     1708  else
     1709  {
     1710    nTxtPerDepthY = 1;
     1711    nDepthPerTxtY = heightDepth / heightChroma;
     1712    depthPosY = posY * nDepthPerTxtY + (mv->getVer()>>2);     //mv denotes the disparity for VSP
     1713  }
     1714  depthPosY = Clip3(0, heightDepth - (size_y<<1) - 1, depthPosY);
     1715
     1716  Pel *refCb  = refPic->getCbAddr() + posX + posY * refStride;
     1717  Pel *refCr  = refPic->getCrAddr() + posX + posY * refStride;
     1718  Pel *dstCb  = dstPic->getCbAddr(partAddr);
     1719  Pel *dstCr  = dstPic->getCrAddr(partAddr);
     1720  Pel *depth  = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride;  // move the pointer to the current depth pixel position
     1721 
     1722  Int refStrideBlock = refStride * nTxtPerDepthY;
     1723  Int dstStrideBlock = dstStride * nTxtPerDepthY;
     1724  Int depStrideBlock = depStride * nDepthPerTxtY;
     1725
     1726  if (isDepth)
     1727  {
     1728     // DT: Since the call for this function is redundant, ..
     1729     for (Int y = 0; y < size_y; y++)
     1730     {
     1731       for (Int x = 0; x < size_x; x++)
     1732       {
     1733         dstCb[x] = 128;
     1734         dstCr[x] = 128;
     1735       }
     1736       dstCb += dstStride;
     1737       dstCr += dstStride;
     1738     }
     1739     return;
     1740  }
     1741 
     1742  if ( widthChroma > widthDepth ) // We assume
     1743  {
     1744    assert( heightChroma > heightDepth );
     1745    printf("This branch should never been reached.\n");
     1746    exit(0);
     1747  }
     1748  else
     1749  {
     1750#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1751  Int  dW = size_x;
     1752  Int  dH = size_y;
     1753  Int  sW = 2; // search window size
     1754  Int  sH = 2;
     1755#endif
     1756#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1757  Int  dW = size_x;
     1758  Int  dH = size_y;
     1759  Int  sW = 2; // search window size
     1760  Int  sH = 2;
     1761#endif
     1762#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1763  Int  dW = size_x>>1;
     1764  Int  dH = size_y>>1;
     1765  Int  sW = 4; // search window size
     1766  Int  sH = 4;
     1767#endif
     1768
     1769  {
     1770    Pel* depthi = depth;
     1771    for (Int j = 0; j < dH; j++)
     1772    {
     1773      for (Int i = 0; i < dW; i++)
     1774      {
     1775        Pel* depthTmp;
     1776#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1777        depthTmp = depthi + (i << 1);
     1778#endif
     1779#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1780        if (depthPosX + (i<<1) < widthDepth)
     1781          depthTmp = depthi + (i << 1);
     1782        else
     1783          depthTmp = depthi + (widthDepth - depthPosX - 1);
     1784#endif
     1785#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1786        if (depthPosX + (i<<2) < widthDepth)
     1787          depthTmp = depthi + (i << 2);
     1788        else
     1789          depthTmp = depthi + (widthDepth - depthPosX - 1);
     1790#endif
     1791        Int maxV = 0;
     1792        for (Int blockj = 0; blockj < sH; blockj++)
     1793        {
     1794          Int iX = 0;
     1795          for (Int blocki = 0; blocki < sW; blocki++)
     1796          {
     1797            if (maxV < depthTmp[iX])
     1798              maxV = depthTmp[iX];
     1799            if (depthPosX + i*sW + blocki < widthDepth - 1)
     1800              iX++;
     1801          }
     1802          if (depthPosY + j*sH + blockj < heightDepth - 1)
     1803            depthTmp += depStride;
     1804        }
     1805        m_pDepth[i+j*dW] = maxV;
     1806      } // end of i < dW
     1807#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1808      if (depthPosY + ((j+1)<<1) < heightDepth)
     1809        depthi += (depStride << 1);
     1810      else
     1811        depthi  = depth + (heightDepth-1)*depStride;
     1812#endif
     1813#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1814      if (depthPosY + ((j+1)<<1) < heightDepth)
     1815        depthi += (depStride << 1);
     1816      else
     1817        depthi  = depth + (heightDepth-depthPosY-1)*depStride;
     1818#endif
     1819#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1820      if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1
     1821        depthi += (depStride << 2);
     1822      else
     1823        depthi  = depth + (heightDepth-depthPosY-1)*depStride; // the last line
     1824#endif
     1825    }
     1826  }
     1827
     1828
     1829    // (size_x, size_y) is Chroma block size
     1830    for ( Int yTxt = 0, yDepth = 0; yTxt < size_y; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY )
     1831    {
     1832      for ( Int xTxt = 0, xDepth = 0; xTxt < size_x; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX )
     1833      {
     1834        Pel rep_depth = 0; // to store the depth value used for warping
     1835#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1836        rep_depth = m_pDepth[(xTxt) + (yTxt)*dW];
     1837#endif
     1838#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1839        rep_depth = m_pDepth[(xTxt) + (yTxt)*dW];
     1840#endif
     1841#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1842        rep_depth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW];
     1843#endif
     1844
     1845      // calculate the offset in the reference picture
     1846        Int disparity = pShiftLUT[ rep_depth ] << iShiftPrec;
     1847        Int refOffset = xTxt + (disparity >> 3); // in integer pixel in chroma image
     1848        Int xFrac = disparity & 0x7;
     1849        Int absX  = posX + refOffset;
     1850
     1851        if (xFrac == 0)
     1852          absX = Clip3(0, widthChroma-1, absX);
     1853        else
     1854          absX = Clip3(4, widthChroma-5, absX);
     1855
     1856        refOffset = absX - posX;
     1857
     1858        assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 );
     1859        assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 );
     1860        m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true);
     1861        m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true);
     1862      }
     1863      refCb += refStrideBlock;
     1864      refCr += refStrideBlock;
     1865      dstCb += dstStrideBlock;
     1866      dstCr += dstStrideBlock;
     1867      depth += depStrideBlock;
     1868    }
     1869  }
     1870}
     1871
     1872#endif // MERL_VSP_C0152
     1873
    11211874#if DEPTH_MAP_GENERATION
    11221875Void TComPrediction::xWeightedAveragePdm( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY )
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComPrediction.h

    r210 r231  
    7878  UInt   m_uiaShift[ 63 ];       // Table for multiplication to substitue of division operation
    7979
     80#if MERL_VSP_C0152
     81  Int*   m_pDepth; ///< Local variable, to store a depth block, just to prevent allocate memory every time
     82#endif
     83
    8084  Void xPredIntraAng            ( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, Bool bFilter );
    8185  Void xPredIntraPlanar         ( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height );
     
    9498  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred, Int iPartIdx          );
    9599  Void xPredInterPrdDepthMap    ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset );
     100#endif
     101#if MERL_VSP_C0152
     102  Void xPredInterUniBWVSP         ( TComDataCU* pcCU,                          UInt uiPartAddr, UInt uiAbsPartIdx,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi=false );
     103  Void xPredInterBiBWVSP          ( TComDataCU* pcCU,                          UInt uiPartAddr, UInt uiAbsPartIdx,               Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap );
    96104#endif
    97105
     
    108116#endif
    109117  Void xWeightedAverage         ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );
    110  
     118
     119#if MERL_VSP_C0152
     120  Void xPredInterLumaBlkFromDM    ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv *mv, UInt partAddr,Int posX, Int posY, Int size_x, Int size_y, Bool isDepth, Int vspIdx
     121                                  , TComYuv *&dstPic );
     122  Void xPredInterChromaBlkFromDM  ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv *mv, UInt partAddr,Int posX, Int posY, Int size_x, Int size_y, Bool isDepth, Int vspIdx
     123                                  , TComYuv *&dstPic );
     124#endif
    111125  Void xGetLLSPrediction ( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 );
    112126#if LGE_ILLUCOMP_B0045
     
    150164  Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );
    151165#endif
    152  
     166
     167#if MERL_VSP_C0152
     168   Void motionCompensationBWVSP   ( TComDataCU*  pcCU, TComYuv* pcYuvPred, UInt uiAbsPartIdx, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false, UInt uiSubSampExpX = 0, UInt uiSubSampExpY = 0 );
     169#endif
     170
    153171  // motion vector prediction
    154172  Void getMvPredAMVP              ( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred );
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComSlice.cpp

    r210 r231  
    121121{
    122122  m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0;
    123  
     123
    124124  initEqualRef();
    125125 
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TComSlice.h

    r210 r231  
    12651265#endif
    12661266#if QC_IV_AS_LT_B0046
    1267   Bool                  m_bWasLongTerm[2][MAX_NUM_REF+1]; //was long-term picture
     1267  Bool        m_bWasLongTerm[2][MAX_NUM_REF+1]; //was long-term picture
    12681268#endif
    12691269  TComSPS*    m_pcSPS;
     
    13411341
    13421342#if SONY_COLPIC_AVAILABILITY|QC_MVHEVC_B0046
    1343   Int         m_iViewOrderIdx;
     1343  Int        m_iViewOrderIdx;
    13441344#endif
    13451345#if LGE_ILLUCOMP_B0045
    13461346  Bool        m_bApplyIC;
     1347#endif
     1348
     1349#if MERL_VSP_C0152
     1350  TComPic*     m_apcRefPicBaseTxt;
     1351  TComPic*     m_apcRefPicBaseDepth;
     1352  Int*         m_aiShiftLUT;
     1353  Int          m_iShiftPrec;
    13471354#endif
    13481355
     
    16551662#endif
    16561663
     1664#if MERL_VSP_C0152
     1665  TComPic*     getRefPicBaseTxt          ()                        { return  m_apcRefPicBaseTxt; }
     1666  Void         setRefPicBaseTxt          ( TComPic* RefPic)        { m_apcRefPicBaseTxt = RefPic; }
     1667  TComPic*     getRefPicBaseDepth        ()                        { return  m_apcRefPicBaseDepth; }
     1668  Void         setRefPicBaseDepth        ( TComPic* RefPic)        { m_apcRefPicBaseDepth = RefPic; }
     1669
     1670  Void setBWVSPLUTParam( Int *pShiftLUT, Int iLoG2LUTPrec) { m_aiShiftLUT = pShiftLUT; m_iShiftPrec = iLoG2LUTPrec; }
     1671  Void getBWVSPLUTParam( Int*&pShiftLUT, Int&iLoG2LUTPrec) { pShiftLUT = m_aiShiftLUT; iLoG2LUTPrec = m_iShiftPrec; }
     1672#endif
     1673
    16571674protected:
    16581675  TComPic*  xGetRefPic        (TComList<TComPic*>& rcListPic, UInt uiPOC);
  • branches/HTM-5.1-dev3-MERL/source/Lib/TLibCommon/TypeDef.h

    r211 r231  
    5151
    5252#if !QC_MVHEVC_B0046
     53
     54///// ***** VSP MODES *********
     55#define MERL_VSP_C0152                       1 // JCT3V-C0152: 1: enable VSP-related tools; 0: disable VSP-related tools
     56
     57#if MERL_VSP_C0152
     58
     59/*
     60 * Two macros are used to configure combinations of JCT3V-C0152 and JCT3V-C0131
     61 *
     62 *   a) (full) A full JCT3V-C0152 implementation, including JCT3V-C0131
     63 *      #define MERL_VSP_COMPENSATION_C0152          1
     64 *      #define MERL_MTK_VSP_DVP_REFINE_C0152_C0131  1
     65 *
     66 *   b) (mvp2off) For partial JCT3V-C0152 excluding overlaps from JCT3V-C0131
     67 *      #define MERL_VSP_COMPENSATION_C0152          1
     68 *      #define MERL_MTK_VSP_DVP_REFINE_C0152_C0131  0
     69 *
     70 *   c) (nocand) For JCT3V-C0131 only
     71 *      #define MERL_VSP_COMPENSATION_C0152          0
     72 *      #define MERL_MTK_VSP_DVP_REFINE_C0152_C0131  1
     73 */
     74
     75#define MERL_VSP_COMPENSATION_C0152          0 // JCT3V-C0152: 1: add VSP merge candidate to merging candidate list; 0: not to add   (nocand).
     76#define MERL_MTK_VSP_DVP_REFINE_C0152_C0131  1 // JCT3V-C0152 && JCT3V-C0131: 1: refine disparity vector using a warped depth block; 0: not to refine  (mvp2off).
     77
     78#define MERL_VSP_BLOCKSIZE_C0152             4 // JCT3V-C0152: VSP block size, supported values: 1, 2 and 4.
     79#define VSP_MERGE_POS                        5 // JCT3V-C0152: fixed position of VSP candidate in merge list, supported values: 5.
     80
     81#else // !MERL_VSP_C0152
     82#define MERL_VSP_COMPENSATION_C0152          0 // JCT3V-C0152: 1: add VSP merge candidate to merging candidate list; 0: not to add
     83#define MERL_MTK_VSP_DVP_REFINE_C0152_C0131  0 // JCT3V-C0152 && JCT3V-C0131: 1: refine disparity vector using a warped depth block; 0: not to refine
     84#define MERL_VSP_BLOCKSIZE_C0152             4 // JCT3V-C0152: VSP block size, supported values: 1, 2 and 4.
     85#endif
     86
    5387///// ***** FIXES *********
    5488// A
Note: See TracChangeset for help on using the changeset viewer.