Ignore:
Timestamp:
14 Jul 2015, 12:31:09 (9 years ago)
Author:
tech
Message:

Merged HTM-14.1-update-dev3@1273.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComDataCU.cpp

    r1226 r1274  
    125125  m_bDecSubCu          = false;
    126126
    127 #if H_3D_NBDV
     127#if NH_3D_NBDV
    128128  m_pDvInfo              = NULL;
    129129#endif
    130 #if H_3D_VSP
     130#if NH_3D_VSP
    131131  m_piVSPFlag            = NULL;
    132132#endif
    133 #if H_3D_SPIVMP
     133#if NH_3D_SPIVMP
    134134  m_pbSPIVMPFlag         = NULL;
    135135#endif
    136 #if H_3D_ARP
     136#if NH_3D_ARP
    137137  m_puhARPW              = NULL;
    138138#endif
     
    142142#if H_3D_INTER_SDC
    143143#endif
    144 #if H_3D_DBBP
     144#if NH_3D_DBBP
    145145  m_pbDBBPFlag         = NULL;
    146146#endif
     
    185185    m_pbMergeFlag        = (Bool*  )xMalloc(Bool,   uiNumPartition);
    186186    m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
    187 #if H_3D_VSP
     187#if NH_3D_VSP
    188188    m_piVSPFlag          = (Char*  )xMalloc(Char,   uiNumPartition);
    189189#endif
    190 #if H_3D_SPIVMP
     190#if NH_3D_SPIVMP
    191191    m_pbSPIVMPFlag       = (Bool*  )xMalloc(Bool,   uiNumPartition);
    192192#endif
     
    208208    }
    209209
    210 #if H_3D_NBDV
     210#if NH_3D_NBDV
    211211    m_pDvInfo            = (DisInfo* )xMalloc(DisInfo,  uiNumPartition);
    212212#endif
     
    249249    }
    250250
    251 #if H_3D_ARP
    252     m_puhARPW            = new UChar[ uiNumPartition];
     251#if NH_3D_ARP
     252    m_puhARPW            = (UChar*  )xMalloc(UChar,   uiNumPartition);
    253253#endif
    254254#if NH_3D_IC
     
    273273#endif
    274274#endif
    275 #if H_3D_DBBP
     275#if NH_3D_DBBP
    276276    m_pbDBBPFlag         = (Bool*  )xMalloc(Bool,   uiNumPartition);
    277277#endif
     
    372372    }
    373373
    374 #if H_3D_VSP
    375     if ( m_piVSPFlag          ) { xFree(m_piVSPFlag);           m_piVSPFlag         = NULL; }
    376 #endif
    377 #if H_3D_SPIVMP
     374#if NH_3D_VSP
     375    if ( m_piVSPFlag )
     376    {
     377      xFree(m_piVSPFlag);
     378      m_piVSPFlag = NULL;
     379    }
     380#endif
     381#if NH_3D_SPIVMP
    378382    if ( m_pbSPIVMPFlag       ) { xFree(m_pbSPIVMPFlag);           m_pbSPIVMPFlag         = NULL; }
    379383#endif
     
    463467      m_acCUMvField[rpl].destroy();
    464468    }
    465 #if H_3D_NBDV
     469#if NH_3D_NBDV
    466470    if ( m_pDvInfo            ) { xFree(m_pDvInfo);             m_pDvInfo           = NULL; }
    467471#endif
    468472
    469473
    470 #if H_3D_ARP
    471     if ( m_puhARPW            ) { delete[] m_puhARPW;           m_puhARPW           = NULL; }
     474#if NH_3D_ARP
     475    if ( m_puhARPW            ) { xFree(m_puhARPW);             m_puhARPW           = NULL; }
    472476#endif
    473477#if NH_3D_IC
     
    493497#endif   
    494498#endif   
    495 #if H_3D_DBBP
     499#if NH_3D_DBBP
    496500    if ( m_pbDBBPFlag         ) { xFree(m_pbDBBPFlag);          m_pbDBBPFlag        = NULL; }
    497501#endif
     
    598602  memset( m_puhHeight         , maxCUHeight,                m_uiNumPartition * sizeof( *m_puhHeight ) );
    599603
    600 #if H_3D_ARP
    601     m_puhARPW   [ui] = pcFrom->getARPW( ui );
    602 #endif
    603604#if NH_3D_IC
    604605  memset( m_pbICFlag          , false,                      m_uiNumPartition * sizeof( *m_pbICFlag ) );
    605606#endif
    606 
    607607  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    608608  {
     
    623623  memset( m_puhMergeIndex     , 0,                        m_uiNumPartition * sizeof( *m_puhMergeIndex ) );
    624624
    625 #if H_3D_VSP
    626     m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui];
    627 #endif
    628 #if H_3D_SPIVMP
    629     m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui];
     625#if NH_3D_VSP
     626  memset( m_piVSPFlag         , 0,                        m_uiNumPartition * sizeof( *m_piVSPFlag ) );
     627#endif
     628#if NH_3D_SPIVMP
     629  memset( m_pbSPIVMPFlag      , 0,                     m_uiNumPartition * sizeof( *m_pbSPIVMPFlag ) );   
    630630#endif
    631631#if H_3D_DIM_SDC
    632632    m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui];
    633633#endif
    634 #if H_3D_DBBP
    635     m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui];
     634#if NH_3D_DBBP
     635  memset( m_pbDBBPFlag , false, m_uiNumPartition * sizeof( *m_pbDBBPFlag ));
    636636#endif
    637637#if H_3D
     
    639639    memset( m_uiDISType         + firstElement,     0,                    numElements * sizeof( *m_uiDISType) );
    640640#endif
    641 #if H_3D_VSP
    642     memset( m_piVSPFlag         + firstElement, 0,                        numElements * sizeof( *m_piVSPFlag ) );
    643 #endif
    644 #if H_3D_SPIVMP
    645     memset( m_pbSPIVMPFlag      + firstElement, 0,                        numElements * sizeof( *m_pbSPIVMPFlag ) );
    646 #endif
    647641
    648642  for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    651645  }
    652646
    653 #if H_3D_ARP
    654     memset( m_puhARPW           + firstElement, 0,                        numElements * sizeof( UChar )         );
     647#if NH_3D_ARP
     648  memset( m_puhARPW      ,      0,        m_uiNumPartition * sizeof( *m_puhARPW )         );
    655649#endif
    656650
     
    674668    m_apDmmPredictor[0] = 0;
    675669    m_apDmmPredictor[1] = 0;
    676 #endif
    677 #if H_3D_DBBP
    678     memset( m_pbDBBPFlag        + firstElement, false,                    numElements * sizeof( *m_pbDBBPFlag ) );
    679670#endif
    680671
     
    791782    m_pbMergeFlag[ui]   = 0;
    792783    m_puhMergeIndex[ui] = 0;
    793 #if H_3D_VSP
    794       m_piVSPFlag[ui] = 0;
    795 #endif
    796 #if H_3D_SPIVMP
    797       m_pbSPIVMPFlag[ui] = 0;
     784#if NH_3D_VSP
     785    m_piVSPFlag[ui]    = 0;
     786#endif
     787#if NH_3D_SPIVMP
     788    m_pbSPIVMPFlag[ui] = 0;
    798789#endif
    799790
     
    808799      m_puhCbf[comp][ui] = 0;
    809800    }
    810 #if H_3D_ARP
     801#if NH_3D_ARP
    811802      m_puhARPW[ui] = 0;
    812803#endif
     
    836827      m_apDmmPredictor[1] = 0;
    837828#endif
    838 #if H_3D_DBBP
     829#if NH_3D_DBBP
    839830      m_pbDBBPFlag[ui] = false;
    840831#endif
     
    892883  memset( m_pbMergeFlag,        0, iSizeInBool  );
    893884  memset( m_puhMergeIndex,      0, iSizeInUchar );
    894 #if H_3D_VSP
     885#if NH_3D_VSP
    895886  memset( m_piVSPFlag,          0, sizeof( Char  ) * m_uiNumPartition );
    896887#endif
    897 #if H_3D_SPIVMP
     888#if NH_3D_SPIVMP
    898889  memset( m_pbSPIVMPFlag,       0, sizeof( Bool  ) * m_uiNumPartition );
    899890#endif
     
    914905    memset( m_explicitRdpcmMode[comp],             NUMBER_OF_RDPCM_MODES, iSizeInUchar );
    915906  }
    916 #if H_3D_ARP
    917   memset( m_puhARPW,            0, iSizeInUchar  );
    918 #endif
    919907
    920908  memset( m_puhDepth,     uiDepth, iSizeInUchar );
     
    922910  memset( m_puhHeight,         uhHeight, iSizeInUchar );
    923911  memset( m_pbIPCMFlag,        0, iSizeInBool  );
     912#if NH_3D_ARP
     913  memset( m_puhARPW,           0, iSizeInUchar  );
     914#endif
    924915#if NH_3D_IC
    925916  memset( m_pbICFlag,          0, iSizeInBool  );
     
    945936  m_apDmmPredictor[1] = 0;
    946937#endif
    947 #if H_3D_DBBP
    948   memset( m_pbDBBPFlag,         0, iSizeInBool  );
     938#if NH_3D_DBBP
     939  memset( m_pbDBBPFlag,         0, sizeof(Bool) * m_uiNumPartition  );
    949940#endif
    950941
     
    972963      m_uiDISType[ui]   = pcCU->getDISType(uiPartOffset+ui);
    973964#endif
    974 #if H_3D_VSP
    975       m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui];
    976       m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
    977 #endif
    978 #if H_3D_SPIVMP
    979       m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
    980 #endif
    981 #if H_3D_ARP
     965#if NH_3D_VSP
     966    m_piVSPFlag[ui] = pcCU->m_piVSPFlag[uiPartOffset+ui];
     967    m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
     968#endif
     969#if NH_3D_SPIVMP
     970    m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
     971#endif
     972#if NH_3D_ARP
    982973      m_puhARPW           [ui] = pcCU->getARPW( uiPartOffset+ui );
    983974#endif
     
    1003994#endif
    1004995#endif
    1005 #if H_3D_DBBP
     996#if NH_3D_DBBP
    1006997      m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui];
    1007998#endif
     
    10741065  m_pePredMode=pcCU->getPredictionMode()  + uiPart;
    10751066  m_CUTransquantBypass  = pcCU->getCUTransquantBypass()+uiPart;
    1076 #if H_3D_NBDV
     1067#if NH_3D_NBDV
    10771068  m_pDvInfo             = pcCU->getDvInfo()           + uiPart;
    10781069#endif
     
    10801071  m_pbMergeFlag         = pcCU->getMergeFlag()        + uiPart;
    10811072  m_puhMergeIndex       = pcCU->getMergeIndex()       + uiPart;
    1082 #if H_3D_VSP
     1073#if NH_3D_VSP
    10831074  m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
    10841075#endif
    1085 #if H_3D_SPIVMP
     1076#if NH_3D_SPIVMP
    10861077  m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
    10871078#endif
    1088 #if H_3D_ARP
     1079#if NH_3D_ARP
    10891080  m_puhARPW             = pcCU->getARPW()             + uiPart;
    10901081#endif
     
    11261117#endif 
    11271118#endif 
    1128 #if H_3D_DBBP
     1119#if NH_3D_DBBP
    11291120  m_pbDBBPFlag              = pcCU->getDBBPFlag()         + uiPart;
    11301121#endif
     
    11731164}
    11741165
    1175 #if H_3D_NBDV
     1166#if NH_3D_NBDV
    11761167Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx)
    11771168{
     
    11821173// Copy inter prediction info from the biggest CU
    11831174Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
    1184 #if H_3D_NBDV
     1175#if NH_3D_NBDV
    11851176  , Bool bNBDV
    11861177#endif
     
    12131204
    12141205  m_pePartSize         = pcCU->getPartitionSize ()        + uiAbsPartIdx;
    1215 #if H_3D_NBDV
     1206#if NH_3D_NBDV
    12161207  if(bNBDV == true)
    12171208  {
     
    12341225  m_pbMergeFlag        = pcCU->getMergeFlag()             + uiAbsPartIdx;
    12351226  m_puhMergeIndex      = pcCU->getMergeIndex()            + uiAbsPartIdx;
    1236 #if H_3D_VSP
     1227#if NH_3D_VSP
    12371228  m_piVSPFlag          = pcCU->getVSPFlag()               + uiAbsPartIdx;
    12381229  m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
    12391230#endif
    1240 #if H_3D_SPIVMP
     1231#if NH_3D_SPIVMP
    12411232  m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()            + uiAbsPartIdx;
    12421233#endif
     
    12441235  m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
    12451236  m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;
    1246 #if H_3D_ARP
     1237#if NH_3D_ARP
    12471238  m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
    12481239#endif   
    1249 #if H_3D_DBBP
     1240#if NH_3D_DBBP
    12501241  m_pbDBBPFlag       = pcCU->getDBBPFlag()              + uiAbsPartIdx;
    12511242#endif
    12521243
    12531244  m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx );
    1254 #if H_3D_NBDV
     1245#if NH_3D_NBDV
    12551246  }
    12561247#endif
     
    12921283  memcpy( m_pbMergeFlag         + uiOffset, pcCU->getMergeFlag(),         iSizeInBool  );
    12931284  memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
    1294 #if H_3D_VSP
     1285#if NH_3D_VSP
    12951286  memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
    12961287  memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
    12971288#endif
    1298 #if H_3D_SPIVMP
     1289#if NH_3D_SPIVMP  || NH_3D_DBBP
    12991290  memcpy( m_pbSPIVMPFlag        + uiOffset, pcCU->getSPIVMPFlag(),        sizeof( Bool ) * uiNumPartition );
    13001291#endif
     
    13331324#endif
    13341325#endif
    1335 #if H_3D_DBBP
     1326#if NH_3D_DBBP
    13361327  memcpy( m_pbDBBPFlag          + uiOffset, pcCU->getDBBPFlag(),          iSizeInBool  );
     1328#endif
     1329#if NH_3D_ARP
     1330  memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
    13371331#endif
    13381332
     
    13761370  }
    13771371
    1378 #if H_3D_ARP
    1379   memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
    1380 #endif
    13811372#if NH_3D_IC
    13821373  memcpy( m_pbICFlag            + uiOffset, pcCU->getICFlag(),            iSizeInBool );
     
    14091400
    14101401  memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar  );
    1411 #if H_3D_NBDV
    1412   memcpy( rpcCU->getDvInfo()         + m_uiAbsIdxInLCU, m_pDvInfo,    sizeof(* m_pDvInfo)    * m_uiNumPartition );
     1402#if NH_3D_NBDV
     1403  memcpy( pCtu->getDvInfo() + m_absZIdxInCtu, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition );
    14131404#endif
    14141405
     
    14191410  memcpy( pCtu->getMergeFlag()         + m_absZIdxInCtu, m_pbMergeFlag,         iSizeInBool  );
    14201411  memcpy( pCtu->getMergeIndex()        + m_absZIdxInCtu, m_puhMergeIndex,       iSizeInUchar );
    1421   #if H_3D_VSP
    1422   memcpy( rpcCU->getVSPFlag()           + m_uiAbsIdxInLCU, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
    1423   memcpy( rpcCU->getDvInfo()            + m_uiAbsIdxInLCU, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
    1424 #endif
    1425 #if H_3D_SPIVMP
    1426   memcpy( rpcCU->getSPIVMPFlag()        + m_uiAbsIdxInLCU, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
     1412#if NH_3D_VSP
     1413  memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
     1414#endif
     1415#if NH_3D_DBBP
     1416  memcpy( pCtu->getDvInfo()            + m_absZIdxInCtu, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
     1417#endif
     1418#if NH_3D_SPIVMP
     1419  memcpy( pCtu->getSPIVMPFlag()        + m_absZIdxInCtu, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
    14271420#endif
    14281421
     
    14611454#endif
    14621455#endif
    1463 #if H_3D_DBBP
    1464   memcpy( rpcCU->getDBBPFlag()          + m_uiAbsIdxInLCU, m_pbDBBPFlag,          iSizeInBool  );
     1456#if NH_3D_DBBP
     1457  memcpy( pCtu->getDBBPFlag()          + m_absZIdxInCtu, m_pbDBBPFlag,          iSizeInBool  );
     1458#endif
     1459#if NH_3D_ARP
     1460  memcpy( pCtu->getARPW()              + m_absZIdxInCtu, m_puhARPW,             iSizeInUchar );
    14651461#endif
    14661462
     
    14971493  }
    14981494
    1499 #if H_3D_ARP
    1500   memcpy( rpcCU->getARPW()             + m_uiAbsIdxInLCU, m_puhARPW,             iSizeInUchar );
    1501 #endif
    15021495#if NH_3D_IC
    15031496  memcpy( pCtu->getICFlag() + m_absZIdxInCtu, m_pbICFlag, sizeof( *m_pbICFlag ) * m_uiNumPartition );
    15041497#endif
    1505 
    15061498  pCtu->getTotalBins() = m_uiTotalBins;
    15071499}
     
    15121504#endif
    15131505
    1514 #if H_3D_VSP
    1515   memcpy( rpcCU->getVSPFlag()           + uiPartOffset, m_piVSPFlag,           sizeof(Char) * uiQNumPart );
    1516 #endif
    15171506#if H_3D_SPIVMP
    15181507  memcpy( rpcCU->getSPIVMPFlag()        + uiPartOffset, m_pbSPIVMPFlag,        sizeof(Bool) * uiQNumPart );
     
    15351524  memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart);
    15361525#endif
    1537 #endif
    1538 #if H_3D_DBBP
    1539   memcpy( rpcCU->getDBBPFlag()          + uiPartOffset, m_pbDBBPFlag,          iSizeInBool  );
    1540 #endif
    1541 #if H_3D_ARP
    1542   memcpy( rpcCU->getARPW()             + uiPartOffset, m_puhARPW,             iSizeInUchar );
    15431526#endif
    15441527
     
    20932076  return uiCtx;
    20942077}
    2095 #if H_3D_ARP
     2078#if NH_3D_ARP
    20962079UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
    20972080{
     
    21002083  UInt        uiCtx = 0;
    21012084 
    2102   pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
     2085  pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
    21032086  uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
    21042087    return uiCtx;
    21052088}
    21062089#endif
    2107 #if H_3D_DBBP
     2090#if NH_3D_DBBP
    21082091Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride)
    21092092{
     2093  const TComSPS* sps = getSlice()->getSPS();
     2094  UInt uiMaxCUWidth = sps->getMaxCUWidth();
     2095  UInt uiMaxCUHeight = sps->getMaxCUHeight();
     2096 
    21102097  // get coded and reconstructed depth view
    21112098  TComPicYuv* depthPicYuv = NULL;
     
    21132100 
    21142101  // DBBP is a texture coding tool
    2115   if( getSlice()->getIsDepth() )
    2116   {
    2117     return NULL;
    2118   } 
     2102  assert( !getSlice()->getIsDepth() );
     2103 
    21192104#if H_3D_FCO
    21202105  TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
     
    21432128    depthPicYuv   = baseDepthPic->getPicYuvRec();
    21442129    depthPicYuv->extendPicBorder();
    2145     uiDepthStride = depthPicYuv->getStride();
     2130    uiDepthStride = depthPicYuv->getStride(COMPONENT_Y);
    21462131   
    2147     Int iBlkX = ( getAddr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
    2148     Int iBlkY = ( getAddr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
     2132    Int iBlkX = ( getCtuRsAddr() % baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ];
     2133    Int iBlkY = ( getCtuRsAddr() / baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ];
    21492134   
    2150     Int iPictureWidth  = depthPicYuv->getWidth();
    2151     Int iPictureHeight = depthPicYuv->getHeight();
     2135    Int iPictureWidth  = depthPicYuv->getWidth(COMPONENT_Y);
     2136    Int iPictureHeight = depthPicYuv->getHeight(COMPONENT_Y);
    21522137   
    21532138   
    21542139    Bool depthRefineFlag = false;
    2155 #if H_3D_NBDV_REF
    2156     depthRefineFlag = m_pcSlice->getDepthRefinementFlag(  );
    2157 #endif // H_3D_NBDV_REF
     2140#if NH_3D_NBDV_REF
     2141    depthRefineFlag = m_pcSlice->getDepthRefinementFlag();
     2142#endif // NH_3D_NBDV_REF
    21582143   
    21592144    TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV;
     
    21662151    Int depthPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((cDv.getVer()+2)>>2));
    21672152   
    2168     pDepthPels = depthPicYuv->getLumaAddr() + depthPosX + depthPosY * uiDepthStride;
     2153    pDepthPels = depthPicYuv->getAddr(COMPONENT_Y) + depthPosX + depthPosY * uiDepthStride;
    21692154  }
    21702155#endif
     
    21782163#endif
    21792164
    2180 #if H_3D_DBBP
     2165#if NH_3D_DBBP
    21812166Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    21822167{
     
    24902475}
    24912476
    2492 #if H_3D_SPIVMP
     2477#if NH_3D_SPIVMP
    24932478Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    24942479{
     
    24972482#endif
    24982483
    2499 #if H_3D_VSP
     2484#if NH_3D_VSP
    25002485Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    25012486{
    25022487  setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    25032488}
    2504 #if H_3D_VSP
    25052489template<typename T>
    25062490Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx )
    25072491{
    2508   UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2;
     2492  UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2;
    25092493  switch ( m_pePartSize[ uiCUAddr ] )
    25102494  {
     
    26382622}
    26392623#endif
    2640 #endif
    26412624
    26422625Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     
    27242707
    27252708// This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
    2726 #if NH_3D_IC
     2709#if NH_3D_IC || NH_3D_VSP
    27272710Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU)
    27282711{
     
    30583041}
    30593042
    3060 #if H_3D_VSP
    3061 
     3043#if NH_3D_VSP
    30623044/** Add a VSP merging candidate
    30633045 * \Inputs
     
    31133095        predFlag[iRefListIdX] = 1;
    31143096        mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
    3115 #if H_3D_NBDV
     3097#if NH_3D_NBDV
    31163098        mvVSP[0+iRefListIdX].getMv().setIDVFlag (false);
    31173099#endif
     
    31213103
    31223104  dirVSP = (predFlag[0] | (predFlag[1] << 1));
    3123   m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false);
     3105  m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true
     3106#if NH_3D_SPIVMP
     3107    , false
     3108#endif
     3109    );
    31243110  if ( mrgCandIdx == iCount )
    31253111  {
     
    31313117  return false;
    31323118}
    3133 
    3134 #endif
    3135 
    3136 #if H_3D_IV_MERGE
     3119#endif
     3120
     3121#if NH_3D_IV_MERGE
    31373122inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx )
    31383123{
     
    31653150      if(!bRemove)
    31663151      {
    3167 #if H_3D_NBDV
     3152#if NH_3D_NBDV
    31683153        if(iLoop) // For IvMcShift candidate
    31693154        {
     
    31863171
    31873172#endif
    3188 #if H_3D
     3173#if NH_3D_MLC
     3174/** Construct a extended list of merging candidates
     3175 * \param pcMvFieldNeighbours
     3176 * \param puhInterDirNeighbours
     3177 * \param vspFlag
     3178 * \param pbSPIVMPFlag
     3179 * \param numValidMergeCand
     3180 */
    31893181Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3190 #if H_3D_VSP
     3182#if NH_3D_VSP
    31913183  , Int* vspFlag
    31923184#endif
    3193 #if H_3D_SPIVMP
     3185#if NH_3D_SPIVMP
    31943186  , Bool* pbSPIVMPFlag
    31953187#endif
     
    31973189  )
    31983190{
    3199   if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // for only dependent texture
     3191  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
    32003192  {
    32013193    return;
     
    32133205    extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID);
    32143206    extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
     3207#if NH_3D_VSP
    32153208    vspFlag[ui] = 0;
    3216   }
    3217 
    3218   // add candidates to temporal list
    3219   // insert MPI ... IvShift candidate
     3209#endif
     3210  }
     3211
     3212  // insert MPI ... IvShift candidate to extMergeCandList
    32203213  for (Int i=0; i<=MRG_IVSHIFT; i++)
    32213214  {
    32223215    if (m_mergCands[i].m_bAvailable)
    32233216    {
    3224       m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag);
     3217      m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt
     3218#if NH_3D_VSP
     3219        , vspFlag
     3220#endif
     3221#if NH_3D_SPIVMP
     3222        , pbSPIVMPFlag
     3223#endif
     3224        );
    32253225      iCount++;
    32263226      if (iCount >= getSlice()->getMaxNumMergeCand())
     
    32293229  }
    32303230
    3231   // insert remaining base candidates
    3232   while (iCount < getSlice()->getMaxNumMergeCand() && m_baseListidc < getSlice()->getMaxNumMergeCand())
    3233   {
    3234     uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[m_baseListidc];
    3235     extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[m_baseListidc<<1].getMv(), pcMvFieldNeighbours[m_baseListidc<<1].getRefIdx());
     3231  Int iCountBase = m_numSpatialCands;
     3232  // insert remaining base candidates to extMergeCandList
     3233  while (iCount < getSlice()->getMaxNumMergeCand() && iCountBase < getSlice()->getMaxNumMergeCand())
     3234  {
     3235    uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[iCountBase];
     3236    extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[iCountBase<<1].getMv(), pcMvFieldNeighbours[iCountBase<<1].getRefIdx());
    32363237    if ( getSlice()->isInterB() )
    32373238    {
    3238       extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx());
    3239     }
    3240     m_baseListidc++;
     3239      extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(iCountBase<<1)+1].getMv(), pcMvFieldNeighbours[(iCountBase<<1)+1].getRefIdx());
     3240    }
     3241    iCountBase++;
    32413242    iCount++;
    32423243  }
     
    32603261}
    32613262
    3262 /** Constructs a list of merging candidates
     3263
     3264
     3265/** Derive 3D merge candidates
    32633266 * \param uiAbsPartIdx
    32643267 * \param uiPUIdx
    3265  * \param uiDepth
    32663268 * \param pcMvFieldNeighbours
     3269 * \param puhInterDirNeighbours
     3270 * \param pcMvFieldSP
    32673271 * \param puhInterDirNeighbours
    32683272 * \param numValidMergeCand
    32693273 */
    3270 // HM 12.0 based merge candidate list construction
    3271 
    3272 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
    3273 {
    3274 
    3275   UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
    3276   Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
     3274Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
     3275#if NH_3D_SPIVMP
     3276      , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
     3277#endif
     3278      , Int& numValidMergeCand, Int mrgCandIdx
     3279)
     3280{
     3281#if NH_3D_IV_MERGE
    32773282  TComMv cZeroMv;
    3278   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    3279   {
    3280     abCandIsInter[ui] = false;
    3281     pcMvFieldNeighbours[ ( ui << 1 )     ].setMvField(cZeroMv, NOT_VALID);
    3282     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID);
     3283  TComMvField tmpMV[2]; 
     3284#endif
     3285
     3286  //////////////////////////////////
     3287  //////// GET DISPARITIES  ////////
     3288  //////////////////////////////////
     3289#if NH_3D_IV_MERGE
     3290  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
     3291  m_cDefaultDisInfo = cDisInfo;
     3292#elif NH_3D_VSP
     3293  // for xAddVspCand()
     3294  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
     3295#endif
     3296
     3297  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
     3298  {
     3299    return;
    32833300  }
    32843301  numValidMergeCand = getSlice()->getMaxNumMergeCand();
     3302  //////////////////////////////////
     3303  //////// DERIVE LOCATIONS ////////
     3304  //////////////////////////////////
    32853305  // compute the location of the current PU
    32863306  Int xP, yP, nPSW, nPSH;
     
    32883308
    32893309  Int iCount = 0;
    3290 
    32913310  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    3292   PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
    32933311  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    32943312  deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    3295 
    3296   //left
    3297   UInt uiLeftPartIdx = 0;
    3298   TComDataCU* pcCULeft = 0;
    3299   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    3300   Bool isAvailableA1 = pcCULeft &&
    3301     pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    3302     !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    3303     !pcCULeft->isIntra( uiLeftPartIdx ) ;
    3304   if ( isAvailableA1 )
    3305   {
    3306     m_bAvailableFlagA1 = 1;
    3307     abCandIsInter[iCount] = true;
    3308     // get Inter Dir
    3309     puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
    3310     // get Mv from Left
    3311     pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3312     if ( getSlice()->isInterB() )
    3313     {
    3314       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3315     }
    3316 
    3317     iCount ++;
    3318   }
    3319  
    3320   // early termination
    3321   if (iCount == getSlice()->getMaxNumMergeCand())
    3322   {
    3323     return;
    3324   }
    3325   // above
    3326   UInt uiAbovePartIdx = 0;
    3327   TComDataCU* pcCUAbove = 0;
    3328   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    3329   Bool isAvailableB1 = pcCUAbove &&
    3330   pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    3331   !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
    3332   !pcCUAbove->isIntra( uiAbovePartIdx );
    3333   if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    3334   {
    3335     m_bAvailableFlagB1 = 1;
    3336     abCandIsInter[iCount] = true;
    3337     // get Inter Dir
    3338     puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
    3339     // get Mv from Left
    3340     pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3341     if ( getSlice()->isInterB() )
    3342     {
    3343       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3344     }
    3345     if ( mrgCandIdx == iCount )
    3346     {
    3347       return;
    3348     }
    3349     iCount ++;
    3350   }
    3351   // early termination
    3352   if (iCount == getSlice()->getMaxNumMergeCand())
    3353   {
    3354     return;
    3355   }
    3356 
    3357   // above right
    3358   UInt uiAboveRightPartIdx = 0;
    3359   TComDataCU* pcCUAboveRight = 0;
    3360   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    3361   Bool isAvailableB0 = pcCUAboveRight &&
    3362   pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    3363   !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
    3364   if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    3365   {
    3366     m_bAvailableFlagB0 = 1;
    3367     abCandIsInter[iCount] = true;
    3368     // get Inter Dir
    3369     puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
    3370     // get Mv from Left
    3371     pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3372     if ( getSlice()->isInterB() )
    3373     {
    3374       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3375     }
    3376     if ( mrgCandIdx == iCount )
    3377     {
    3378       return;
    3379     }
    3380     iCount ++;
    3381   }
    3382   // early termination
    3383   if (iCount == getSlice()->getMaxNumMergeCand())
    3384   {
    3385     return;
    3386   }
    3387 
    3388   //left bottom
    3389   UInt uiLeftBottomPartIdx = 0;
    3390   TComDataCU* pcCULeftBottom = 0;
    3391   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    3392   Bool isAvailableA0 = pcCULeftBottom &&
    3393   pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    3394   !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
    3395   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    3396   {
    3397     m_bAvailableFlagA0 = 1;
    3398     abCandIsInter[iCount] = true;
    3399     // get Inter Dir
    3400     puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
    3401     // get Mv from Left
    3402     pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3403     if ( getSlice()->isInterB() )
    3404     {
    3405       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3406     }
    3407     if ( mrgCandIdx == iCount )
    3408     {
    3409       return;
    3410     }
    3411     iCount ++;
    3412   }
    3413   // early termination
    3414   if (iCount == getSlice()->getMaxNumMergeCand())
    3415   {
    3416     return;
    3417   }
    3418   // above left
    3419   if( iCount < 4 )
    3420   {
    3421     UInt uiAboveLeftPartIdx = 0;
    3422     TComDataCU* pcCUAboveLeft = 0;
    3423     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    3424     Bool isAvailableB2 = pcCUAboveLeft &&
    3425     pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    3426     !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
    3427     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    3428         && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    3429     {
    3430       m_bAvailableFlagB2 = 1;
    3431       abCandIsInter[iCount] = true;
    3432       // get Inter Dir
    3433       puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
    3434       // get Mv from Left
    3435       pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3436       if ( getSlice()->isInterB() )
    3437       {
    3438         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3439       }
    3440       if ( mrgCandIdx == iCount )
    3441       {
    3442         return;
    3443       }
    3444       iCount ++;
    3445     }
    3446   }
    3447   // early termination
    3448   if (iCount == getSlice()->getMaxNumMergeCand())
    3449   {
    3450     return;
    3451   }
    3452   if ( getSlice()->getEnableTMVPFlag())
    3453   {
    3454     //>> MTK colocated-RightBottom
    3455     UInt uiPartIdxRB;
    3456 
    3457     deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 
    3458 
    3459     UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    3460     UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
    3461 
    3462     TComMv cColMv;
    3463     Int iRefIdx;
    3464     Int uiLCUIdx = -1;
    3465 
    3466     if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
    3467     {
    3468     }
    3469     else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    3470     {
    3471     }
    3472     else
    3473     {
    3474       if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    3475         ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
    3476       {
    3477         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
    3478         uiLCUIdx = getAddr();
    3479       }
    3480       else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
    3481       {
    3482         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
    3483       }
    3484       else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
    3485       {
    3486         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    3487         uiLCUIdx = getAddr() + 1;
    3488       }
    3489       else //is the right bottom corner of LCU                       
    3490       {
    3491         uiAbsPartAddr = 0;
    3492       }
    3493     }
    3494 
    3495     iRefIdx = 0;
    3496     Bool bExistMV = false;
    3497     UInt uiPartIdxCenter;
    3498     UInt uiCurLCUIdx = getAddr();
    3499     Int dir = 0;
    3500     UInt uiArrayAddr = iCount;
    3501     xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
    3502     bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
    3503     if( bExistMV == false )
    3504     {
    3505       bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
    3506     }
    3507     if( bExistMV )
    3508     {
    3509       dir |= 1;
    3510       pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
    3511     }
    3512 
    3513     if ( getSlice()->isInterB() )
    3514     {
    3515 #if NH_3D_TMVP //to be changed to NH_3D_TMVP in future migration
    3516       iRefIdx = 0;
    3517 #endif
    3518       bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
    3519       if( bExistMV == false )
    3520       {
    3521         bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
    3522       }
    3523       if( bExistMV )
    3524       {
    3525         dir |= 2;
    3526         pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
    3527       }
    3528     }
    3529 
    3530     if (dir != 0)
    3531     {
    3532       puhInterDirNeighbours[uiArrayAddr] = dir;
    3533       abCandIsInter[uiArrayAddr] = true;
    3534 #if H_3D_NBDV
    3535       pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
    3536       pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    3537 #endif
    3538       if ( mrgCandIdx == iCount )
    3539       {
    3540         return;
    3541       }
    3542       iCount++;
    3543     }
    3544   }
    3545   // early termination
    3546   if (iCount == getSlice()->getMaxNumMergeCand())
    3547   {
    3548     return;
    3549   }
    3550   UInt uiArrayAddr = iCount;
    3551   UInt uiCutoff = uiArrayAddr;
    3552  
    3553   if ( getSlice()->isInterB() && iCount<5)  // JCT3V-F0129 by Qualcomm
    3554   {
    3555     UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
    3556     UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
    3557 
    3558     for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
    3559     {
    3560       Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
    3561       if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
    3562       {
    3563         abCandIsInter[uiArrayAddr] = true;
    3564         puhInterDirNeighbours[uiArrayAddr] = 3;
    3565 
    3566         // get Mv from cand[i] and cand[j]
    3567         pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
    3568         pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
    3569 
    3570         Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
    3571         Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
    3572         if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
    3573         {
    3574           abCandIsInter[uiArrayAddr] = false;
    3575         }
    3576         else
    3577         {
    3578           uiArrayAddr++;
    3579         }
    3580       }
    3581     }
    3582   }
    3583   // early termination
    3584   if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
    3585   {
    3586     return;
    3587   }
    3588  
    3589   Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
    3590   Int r = 0;
    3591   Int refcnt = 0;
    3592   while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
    3593   {
    3594     abCandIsInter[uiArrayAddr] = true;
    3595     puhInterDirNeighbours[uiArrayAddr] = 1;
    3596     pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
    3597 
    3598     if ( getSlice()->isInterB() )
    3599     {
    3600       puhInterDirNeighbours[uiArrayAddr] = 3;
    3601       pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
    3602     }
    3603     uiArrayAddr++;
    3604     if ( refcnt == iNumRefIdx - 1 )
    3605     {
    3606       r = 0;
    3607     }
    3608     else
    3609     {
    3610       ++r;
    3611       ++refcnt;
    3612     }
    3613   }
    3614  
    3615   numValidMergeCand = uiArrayAddr;
    3616 }
    3617 
    3618 
    3619 
    3620 /** Constructs a list of merging candidates
    3621  * \param uiAbsPartIdx
    3622  * \param uiPUIdx
    3623  * \param uiDepth
    3624  * \param pcMvFieldNeighbours
    3625  * \param puhInterDirNeighbours
    3626  * \param numValidMergeCand
    3627  */
    3628 #if H_3D
    3629 Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3630 #else
    3631 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3632 #endif
    3633 #if H_3D_SPIVMP
    3634       , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    3635 #endif
    3636       , Int& numValidMergeCand, Int mrgCandIdx
    3637 )
    3638 {
    3639 #if H_3D_IV_MERGE
    3640   ////////////////////////////
    3641   //////// INIT LISTS ////////
    3642   ////////////////////////////
    3643   TComMv cZeroMv;
    3644 #else
    3645   Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
    3646 #endif
    3647 #if H_3D
    3648   TComMvField tmpMV[2];
    3649   UChar tmpDir;
    3650 
    3651 
    3652   //////////////////////////////////
    3653   //////// GET DISPARITIES  ////////
    3654   //////////////////////////////////
    3655   DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
    3656   m_cDefaultDisInfo = cDisInfo;
    3657 
    3658   if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // current slice is not both dependent view or depth
    3659   {
    3660     return;
    3661   }
    3662 #else
    3663   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    3664   {
    3665     abCandIsInter[ui] = false;
    3666     pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
    3667     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
    3668   }
    3669 #endif
    3670 
    3671   numValidMergeCand = getSlice()->getMaxNumMergeCand();
    3672 #if H_3D
    3673   //////////////////////////////////
    3674   //////// DERIVE LOCATIONS ////////
    3675   //////////////////////////////////
    3676 #endif
    3677   // compute the location of the current PU
    3678   Int xP, yP, nPSW, nPSH;
    3679   this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
    3680 
    3681   Int iCount = 0;
    3682 
    3683   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    3684 #if !H_3D
    3685   PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
    3686 #endif
    3687   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    3688   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    3689 #if H_3D
     3313#if NH_3D_TEXT_MERGE
    36903314  Bool bMPIFlag   = getSlice()->getMpiFlag();
     3315  Int  tmpDir;
     3316#endif
     3317#if NH_3D_IV_MERGE || NH_3D_TEXT_MERGE
    36913318  Bool bIsDepth = getSlice()->getIsDepth();
    3692 #endif 
     3319#endif
    36933320
    36943321#if NH_3D_IC
    36953322  Bool bICFlag = getICFlag(uiAbsPartIdx);
    36963323#endif
    3697 #if H_3D_ARP
     3324#if NH_3D_ARP
    36983325  Bool bARPFlag = getARPW(uiAbsPartIdx) > 0;
    36993326#endif
    3700 #if H_3D_DBBP
     3327#if NH_3D_DBBP
    37013328  Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx);
    37023329  assert(bDBBPFlag == getDBBPFlag(0)); 
    37033330#endif
    37043331
    3705 #if H_3D
    3706 #if H_3D_NBDV
     3332#if NH_3D_NBDV
    37073333  for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) 
    37083334  {
    3709     pcMvFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
    3710     pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
    3711   }
    3712 #endif
    3713   // Clean version for MCL construction align with WD
    3714   // init mergCands list
     3335    pcMFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
     3336    pcMFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
     3337  }
     3338#endif
     3339  // init containers
    37153340  for (Int i = 0; i<MRG_IVSHIFT+1; i++)
    3716   {
    37173341    m_mergCands[i].init();
    3718   }
    3719 
    3720   m_baseListidc = 0;
    3721 
     3342
     3343  m_numSpatialCands = 0;
     3344
     3345  //////////////////////////////////
     3346  ///////// GET VSP FLAGS //////////
     3347  //////////////////////////////////
    37223348  //left
    37233349  UInt uiLeftPartIdx = 0;
     
    37273353  if (getAvailableFlagA1())
    37283354  {
    3729     m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3730 #if H_3D_VSP
     3355    m_mergCands[MRG_A1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3356#if NH_3D_VSP
    37313357    , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
    37323358#if NH_3D_IC
    37333359      && !bICFlag
    37343360#endif
    3735 #if H_3D_ARP
     3361#if NH_3D_ARP
    37363362      && !bARPFlag
    37373363#endif
    3738 #if H_3D_DBBP
     3364#if NH_3D_DBBP
    37393365      && !bDBBPFlag
    37403366#endif
    37413367      )
    37423368#endif
     3369#if NH_3D_SPIVMP
    37433370      , false
     3371#endif
    37443372      );
    3745     m_baseListidc++;
     3373    m_numSpatialCands++;
    37463374  }
    37473375
    37483376  // above
    3749 
    37503377  if (getAvailableFlagB1())
    37513378  {
    3752     m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3753 #if H_3D_VSP
     3379    m_mergCands[MRG_B1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3380#if NH_3D_VSP
    37543381    , false
    37553382#endif
     3383#if NH_3D_SPIVMP
    37563384      , false
     3385#endif
    37573386      );
    3758     m_baseListidc++;
     3387    m_numSpatialCands++;
    37593388  }
    37603389
    37613390  // above right
    3762 
    37633391  if (getAvailableFlagB0())
    37643392  {
    3765     m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3766 #if H_3D_VSP
    3767     ,
    3768       false
    3769 #endif
     3393    m_mergCands[MRG_B0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3394#if NH_3D_VSP
     3395    , false
     3396#endif
     3397#if NH_3D_SPIVMP
    37703398      , false
     3399#endif
    37713400      );
    3772     m_baseListidc++;
     3401    m_numSpatialCands++;
    37733402  }
    37743403
    37753404  // left bottom
    3776 
    37773405  if (getAvailableFlagA0())
    37783406  {
    3779     m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3780 #if H_3D_VSP
     3407    m_mergCands[MRG_A0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3408#if NH_3D_VSP
    37813409    , false
    37823410#endif
     3411#if NH_3D_SPIVMP
    37833412      , false
     3413#endif
    37843414      );
    3785     m_baseListidc++;
     3415    m_numSpatialCands++;
    37863416  }
    37873417
    37883418  // above left
    3789 
    37903419  if (getAvailableFlagB2())
    37913420  {
    3792     m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3793 #if H_3D_VSP
     3421    m_mergCands[MRG_B2].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3422#if NH_3D_VSP
    37943423    , false
    37953424#endif
     3425#if NH_3D_SPIVMP
    37963426      , false
     3427#endif
    37973428      );
    3798     m_baseListidc++;
    3799   }
    3800 
    3801 #endif
    3802 
    3803 
    3804 #if H_3D_IV_MERGE
     3429    m_numSpatialCands++;
     3430  }
     3431
     3432
     3433#if NH_3D_TEXT_MERGE
    38053434
    38063435  /////////////////////////////////////////////
     
    38283457
    38293458      this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight );
    3830       pcTexRec->getTopLeftSamplePos( this->getAddr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
     3459      pcTexRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
    38313460
    38323461      Int iPUWidth, iPUHeight, iNumPart, iNumPartLine;
     
    38533482
    38543483      Int         iTexPosX, iTexPosY;
     3484#if NH_3D_INTEGER_MV_DEPTH
    38553485      const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
    3856 
     3486#endif
    38573487      Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iPUWidth ) >> 1 )  * iPUWidth + ( iPUWidth >> 1 );
    38583488      Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iPUHeight ) >> 1 )  * iPUHeight + (iPUHeight >> 1);
     
    38683498
    38693499      pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx );
    3870       TComDataCU* pcDefaultCU    = pcTexPic->getCU( iTexCenterCUAddr );
     3500      TComDataCU* pcDefaultCU    = pcTexPic->getCtu( iTexCenterCUAddr );
    38713501
    38723502      if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA )
     
    38873517              {
    38883518                bSPIVMPFlag = true;
     3519#if NH_3D_INTEGER_MV_DEPTH
    38893520                TComMv cMv = cDefaultMvField.getMv() + cMvRounding;
    38903521                cMv >>= 2;
     3522#else
     3523                TComMv cMv = cDefaultMvField.getMv();
     3524#endif
    38913525                cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ;
    38923526                break;
     
    39133547            iTexPosY     = i + iOffsetY;
    39143548            pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx );
    3915             pcTexCU  = pcTexPic->getCU( iTexCUAddr );
     3549            pcTexCU  = pcTexPic->getCtu( iTexCUAddr );
    39163550
    39173551            if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) )
     
    39253559                if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
    39263560                {
     3561#if NH_3D_INTEGER_MV_DEPTH
    39273562                  TComMv cMv = cTexMvField.getMv() + cMvRounding;
    39283563                  cMv >>=2;         
     3564#else
     3565                  TComMv cMv = cTexMvField.getMv();
     3566#endif         
    39293567                  pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef);
    39303568                }
     
    39453583          }
    39463584        }
    3947 #if H_3D
    3948       }
    3949 #endif
     3585      }
    39503586#if H_3D_FCO
    39513587    }
     
    39753611    }
    39763612  }
     3613#endif
     3614
     3615#if NH_3D_IV_MERGE
    39773616  /////////////////////////////////////////////////////////////////
    39783617  //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
     
    39923631  if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1)
    39933632  {
     3633#if H_3D_IC
    39943634    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag );
     3635#else
     3636    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, false );
     3637#endif
    39953638  } 
    39963639
     
    40483691        spiMvpFlag = true;
    40493692      }
    4050 #if H_3D_DBBP
     3693#if NH_3D_DBBP
    40513694      spiMvpFlag &= !bDBBPFlag;
    40523695#endif
     
    40693712#endif
    40703713
     3714  iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable;
     3715
     3716#if NH_3D_VSP
     3717  /////////////////////////////////////////////////
     3718  //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
     3719  /////////////////////////////////////////////////
     3720  if (iCount<getSlice()->getMaxNumMergeCand())
     3721  {
     3722    if (
     3723      (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) &&
     3724#if NH_3D_IC
     3725      !bICFlag &&
     3726#endif
     3727#if NH_3D_ARP
     3728      !bARPFlag &&
     3729#endif
    40713730#if H_3D
    4072   iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable;
     3731      (nPSW + nPSH > 12) &&
     3732#endif
     3733#if NH_3D_DBBP
     3734      !bDBBPFlag &&
     3735#endif
     3736      xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
     3737    {
     3738      return;
     3739    }
     3740
     3741    // early termination
     3742    if (iCount == getSlice()->getMaxNumMergeCand())
     3743    {
     3744      return;
     3745    }
     3746  }
     3747#endif
     3748
     3749  iCount += m_mergCands[MRG_B0].m_bAvailable;
     3750
     3751#if NH_3D_IV_MERGE
     3752  /////////////////////////////////////////////
     3753  //////// INTER VIEW DISP COMP (IvDC) ////////
     3754  /////////////////////////////////////////////
     3755  if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
     3756  {
     3757    assert(iCount < getSlice()->getMaxNumMergeCand());
     3758
     3759    tmpMV[0].setMvField( cZeroMv, NOT_VALID );
     3760    tmpMV[1].setMvField( cZeroMv, NOT_VALID );
     3761    if( ( ivCandDir[1] & 1 ) == 1 )
     3762    {
     3763      tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
     3764    }
     3765    if( ( ivCandDir[1] & 2 ) == 2 )
     3766    {
     3767      tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
     3768    }
     3769
     3770    Bool bRemoveSpa = false; //pruning to A1, B1
     3771    for(Int i = 0; i < 2; i ++)
     3772    {
     3773      if ( !m_mergCands[MRG_A1+i].m_bAvailable )
     3774      {
     3775        continue;
     3776      }
     3777      if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
     3778      {
     3779        bRemoveSpa                      = true;
     3780        break;
     3781      }     
     3782    }
     3783    if(!bRemoveSpa)
     3784    {
     3785#if NH_3D_NBDV
     3786      tmpMV[0].getMv().setIDVFlag (false);
     3787      tmpMV[1].getMv().setIDVFlag (false);
     3788#endif
     3789      m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
     3790
     3791      if ( mrgCandIdx == iCount )
     3792        return;
     3793      iCount ++;
     3794
     3795      // early termination
     3796      if (iCount == getSlice()->getMaxNumMergeCand())
     3797      {
     3798        return;
     3799      }
     3800    }
     3801  }
     3802#endif // H_3D_IV_MERGE
     3803
     3804  iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
     3805
     3806#if NH_3D_IV_MERGE
     3807  ////////////////////////////////////////////////////
     3808  //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
     3809  ////////////////////////////////////////////////////
     3810  if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
     3811  {
     3812    if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
     3813    {
     3814      return;
     3815    }
     3816    //early termination
     3817    if (iCount == getSlice()->getMaxNumMergeCand())
     3818    {
     3819      return;
     3820    }
     3821  }
     3822#endif
     3823}
     3824#endif
     3825
     3826//! Construct a list of merging candidates
     3827Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
     3828{
     3829  UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
     3830#if NH_3D_MLC
     3831  Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
    40733832#else
     3833  Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
     3834#endif
     3835  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
     3836  {
     3837    abCandIsInter[ui] = false;
     3838    pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
     3839    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
     3840  }
     3841  numValidMergeCand = getSlice()->getMaxNumMergeCand();
     3842  // compute the location of the current PU
     3843  Int xP, yP, nPSW, nPSH;
     3844  this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
     3845
     3846  Int iCount = 0;
     3847
     3848  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
     3849  PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
     3850  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
     3851  deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
     3852
    40743853  //left
    40753854  UInt uiLeftPartIdx = 0;
    40763855  TComDataCU* pcCULeft = 0;
    40773856  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
     3857
    40783858  Bool isAvailableA1 = pcCULeft &&
    4079     pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    4080     !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    4081     !pcCULeft->isIntra( uiLeftPartIdx ) ;
     3859                       pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
     3860                       !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
     3861                       pcCULeft->isInter( uiLeftPartIdx ) ;
     3862
    40823863  if ( isAvailableA1 )
    40833864  {
     3865#if NH_3D_MLC
     3866    m_bAvailableFlagA1 = 1;
     3867#endif
    40843868    abCandIsInter[iCount] = true;
    40853869    // get Inter Dir
     
    40913875      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    40923876    }
    4093 
    40943877    if ( mrgCandIdx == iCount )
    40953878    {
     
    41003883
    41013884  // early termination
    4102   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3885  if (iCount == getSlice()->getMaxNumMergeCand())
    41033886  {
    41043887    return;
    41053888  }
    4106 
    41073889  // above
    41083890  UInt uiAbovePartIdx = 0;
    41093891  TComDataCU* pcCUAbove = 0;
    41103892  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
     3893
    41113894  Bool isAvailableB1 = pcCUAbove &&
    4112     pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    4113     !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
    4114     !pcCUAbove->isIntra( uiAbovePartIdx );
     3895                       pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
     3896                       !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
     3897                       pcCUAbove->isInter( uiAbovePartIdx );
     3898
    41153899  if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    41163900  {
     3901#if NH_3D_MLC
     3902    m_bAvailableFlagB1 = 1;
     3903#endif
    41173904    abCandIsInter[iCount] = true;
    41183905    // get Inter Dir
     
    41243911      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    41253912    }
    4126 
    41273913    if ( mrgCandIdx == iCount )
    41283914    {
     
    41323918  }
    41333919  // early termination
    4134   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3920  if (iCount == getSlice()->getMaxNumMergeCand())
    41353921  {
    41363922    return;
     
    41413927  TComDataCU* pcCUAboveRight = 0;
    41423928  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
     3929
    41433930  Bool isAvailableB0 = pcCUAboveRight &&
    4144     pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    4145     !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
     3931                       pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
     3932                       pcCUAboveRight->isInter( uiAboveRightPartIdx );
     3933
    41463934  if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    41473935  {
     3936#if NH_3D_MLC
     3937    m_bAvailableFlagB0 = 1;
     3938#endif
    41483939    abCandIsInter[iCount] = true;
    41493940    // get Inter Dir
     
    41553946      pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    41563947    }
    4157 
    41583948    if ( mrgCandIdx == iCount )
    41593949    {
     
    41633953  }
    41643954  // early termination
    4165   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3955  if (iCount == getSlice()->getMaxNumMergeCand())
    41663956  {
    41673957    return;
    41683958  }
    4169 #endif
    4170 
    4171 
    4172 #if H_3D_VSP
    4173   /////////////////////////////////////////////////
    4174   //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
    4175   /////////////////////////////////////////////////
    4176   if (iCount<getSlice()->getMaxNumMergeCand())
    4177   {
    4178     if (
    4179       (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) &&
    4180 #if NH_3D_IC
    4181       !bICFlag &&
    4182 #endif
    4183 #if H_3D_ARP
    4184       !bARPFlag &&
    4185 #endif
    4186 #if H_3D
    4187       (nPSW + nPSH > 12) &&
    4188 #endif
    4189 #if H_3D_DBBP
    4190       !bDBBPFlag &&
    4191 #endif
    4192       xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
    4193     {
    4194       return;
    4195     }
    4196 
    4197     // early termination
    4198     if (iCount == getSlice()->getMaxNumMergeCand())
    4199     {
    4200       return;
    4201     }
    4202 #endif
    4203 #if H_3D_VSP
    4204   }
    4205 #endif
    4206 
    4207 #if H_3D
    4208   iCount += m_mergCands[MRG_B0].m_bAvailable;
    4209 #endif
    4210 
    4211 
    4212 #if H_3D_IV_MERGE
    4213   /////////////////////////////////////////////
    4214   //////// INTER VIEW DISP COMP (IvDC) ////////
    4215   /////////////////////////////////////////////
    4216   if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
    4217   {
    4218     assert(iCount < getSlice()->getMaxNumMergeCand());
    4219 
    4220     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    4221     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    4222     if( ( ivCandDir[1] & 1 ) == 1 )
    4223     {
    4224       tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
    4225     }
    4226     if( ( ivCandDir[1] & 2 ) == 2 )
    4227     {
    4228       tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
    4229     }
    4230 
    4231     Bool bRemoveSpa = false; //pruning to A1, B1
    4232     for(Int i = 0; i < 2; i ++)
    4233     {
    4234       if ( !m_mergCands[MRG_A1+i].m_bAvailable )
    4235       {
    4236         continue;
    4237       }
    4238       if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
    4239       {
    4240         bRemoveSpa                      = true;
    4241         break;
    4242       }     
    4243     }
    4244     if(!bRemoveSpa)
    4245     {
    4246 #if H_3D_NBDV
    4247       tmpMV[0].getMv().setIDVFlag (false);
    4248       tmpMV[1].getMv().setIDVFlag (false);
    4249 #endif
    4250       m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
    4251 
    4252       if ( mrgCandIdx == iCount )
    4253         return;
    4254       iCount ++;
    4255 
    4256       // early termination
    4257       if (iCount == getSlice()->getMaxNumMergeCand())
    4258       {
    4259         return;
    4260       }
    4261     }
    4262   }
    4263 #endif // H_3D_IV_MERGE
    4264 
    4265 
    4266 #if H_3D
    4267   iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
    4268 #else
     3959
    42693960  //left bottom
    42703961  UInt uiLeftBottomPartIdx = 0;
    42713962  TComDataCU* pcCULeftBottom = 0;
    42723963  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
     3964
    42733965  Bool isAvailableA0 = pcCULeftBottom &&
    4274   pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    4275   !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
     3966                       pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
     3967                       pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ;
     3968
    42763969  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    42773970  {
     3971#if NH_3D_MLC
     3972    m_bAvailableFlagA0 = 1;
     3973#endif
    42783974    abCandIsInter[iCount] = true;
    42793975    // get Inter Dir
     
    42923988  }
    42933989  // early termination
    4294   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3990  if (iCount == getSlice()->getMaxNumMergeCand())
    42953991  {
    42963992    return;
    42973993  }
    42983994
    4299   // above left 
     3995  // above left
    43003996  if( iCount < 4 )
    43013997  {
     
    43033999    TComDataCU* pcCUAboveLeft = 0;
    43044000    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
     4001
    43054002    Bool isAvailableB2 = pcCUAboveLeft &&
    4306     pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    4307     !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
     4003                         pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
     4004                         pcCUAboveLeft->isInter( uiAboveLeftPartIdx );
     4005
    43084006    if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    43094007        && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    43104008    {
     4009#if NH_3D_MLC
     4010      m_bAvailableFlagB2 = 1;
     4011#endif
    43114012      abCandIsInter[iCount] = true;
    43124013      // get Inter Dir
     
    43264027  }
    43274028  // early termination
    4328   if (iCount == getSlice()->getMaxNumMergeCand()) 
     4029  if (iCount == getSlice()->getMaxNumMergeCand())
    43294030  {
    43304031    return;
    43314032  }
    4332 #endif
    4333 
    4334 
    4335 #if H_3D_IV_MERGE
    4336   ////////////////////////////////////////////////////
    4337   //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
    4338   ////////////////////////////////////////////////////
    4339   if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
    4340   {
    4341     if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
    4342     {
    4343       return;
    4344     }
    4345     //early termination
    4346     if (iCount == getSlice()->getMaxNumMergeCand())
    4347     {
    4348       return;
    4349     }
    4350   }
    4351 #endif
    4352 #if !H_3D
    4353   if ( getSlice()->getEnableTMVPFlag())
     4033
     4034  if ( getSlice()->getEnableTMVPFlag() )
    43544035  {
    43554036    //>> MTK colocated-RightBottom
    43564037    UInt uiPartIdxRB;
    43574038
    4358     deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 
     4039    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );
    43594040
    43604041    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    4361     UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
     4042    const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
     4043    const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
    43624044
    43634045    TComMv cColMv;
    43644046    Int iRefIdx;
    4365     Int uiLCUIdx = -1;
    4366 
    4367     if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
    4368     {
    4369     }
    4370     else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    4371     {
    4372     }
    4373     else
    4374     {
    4375       if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    4376         ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
    4377       {
    4378         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
    4379         uiLCUIdx = getAddr();
    4380       }
    4381       else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
    4382       {
    4383         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
    4384       }
    4385       else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     4047    Int ctuRsAddr = -1;
     4048
     4049    if (   ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
     4050        && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
     4051    {
     4052      if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&           // is not at the last column of CTU
     4053        ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) )              // is not at the last row    of CTU
     4054      {
     4055        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ];
     4056        ctuRsAddr = getCtuRsAddr();
     4057      }
     4058      else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 )           // is not at the last column of CTU But is last row of CTU
     4059      {
     4060        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
     4061      }
     4062      else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 )          // is not at the last row of CTU But is last column of CTU
    43864063      {
    43874064        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    4388         uiLCUIdx = getAddr() + 1;
    4389       }
    4390       else //is the right bottom corner of LCU                       
     4065        ctuRsAddr = getCtuRsAddr() + 1;
     4066      }
     4067      else //is the right bottom corner of CTU
    43914068      {
    43924069        uiAbsPartAddr = 0;
    43934070      }
    43944071    }
    4395    
    4396    
     4072
    43974073    iRefIdx = 0;
     4074
    43984075    Bool bExistMV = false;
    43994076    UInt uiPartIdxCenter;
    4400     UInt uiCurLCUIdx = getAddr();
    44014077    Int dir = 0;
    44024078    UInt uiArrayAddr = iCount;
    44034079    xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
    4404     bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
     4080    bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx );
    44054081    if( bExistMV == false )
    44064082    {
    4407       bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
     4083      bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx );
    44084084    }
    44094085    if( bExistMV )
     
    44154091    if ( getSlice()->isInterB() )
    44164092    {
    4417       bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
     4093#if NH_3D_TMVP
     4094      iRefIdx = 0;
     4095#endif
     4096      bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx);
    44184097      if( bExistMV == false )
    44194098      {
    4420         bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
     4099        bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx );
    44214100      }
    44224101      if( bExistMV )
     
    44264105      }
    44274106    }
    4428    
     4107
    44294108    if (dir != 0)
    44304109    {
    44314110      puhInterDirNeighbours[uiArrayAddr] = dir;
    44324111      abCandIsInter[uiArrayAddr] = true;
     4112#if NH_3D_NBDV
     4113      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
     4114      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
     4115#endif
     4116
    44334117      if ( mrgCandIdx == iCount )
    44344118      {
     
    44384122    }
    44394123  }
    4440   // early termination 
    4441   if (iCount == getSlice()->getMaxNumMergeCand()) 
     4124  // early termination
     4125  if (iCount == getSlice()->getMaxNumMergeCand())
    44424126  {
    44434127    return;
    44444128  }
     4129
    44454130  UInt uiArrayAddr = iCount;
    44464131  UInt uiCutoff = uiArrayAddr;
    4447    
    4448   if ( getSlice()->isInterB())
    4449   {
    4450     UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
    4451     UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
     4132
     4133#if NH_3D_MLC
     4134  if ( getSlice()->isInterB() && iCount<5)
     4135#else
     4136  if ( getSlice()->isInterB() )
     4137#endif
     4138  {
     4139    static const UInt NUM_PRIORITY_LIST=12;
     4140    static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
     4141    static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
    44524142
    44534143    for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
    44544144    {
    4455       Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
     4145      assert(idx<NUM_PRIORITY_LIST);
     4146      Int i = uiPriorityList0[idx];
     4147      Int j = uiPriorityList1[idx];
    44564148      if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
    44574149      {
     
    44774169  }
    44784170  // early termination
    4479   if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 
     4171  if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
    44804172  {
    44814173    return;
    44824174  }
     4175
    44834176  Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
     4177
    44844178  Int r = 0;
    44854179  Int refcnt = 0;
     
    44964190    }
    44974191    uiArrayAddr++;
     4192
    44984193    if ( refcnt == iNumRefIdx - 1 )
    44994194    {
     
    45064201    }
    45074202  }
    4508 
    45094203  numValidMergeCand = uiArrayAddr;
    4510 #endif
    4511 }
    4512 #else
    4513 
    4514 //! Construct a list of merging candidates
    4515 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
    4516 {
    4517   UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
    4518   Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
    4519   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    4520   {
    4521     abCandIsInter[ui] = false;
    4522     pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
    4523     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
    4524   }
    4525   numValidMergeCand = getSlice()->getMaxNumMergeCand();
    4526   // compute the location of the current PU
    4527   Int xP, yP, nPSW, nPSH;
    4528   this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
    4529 
    4530   Int iCount = 0;
    4531 
    4532   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    4533   PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
    4534   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    4535   deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    4536 
    4537   //left
    4538   UInt uiLeftPartIdx = 0;
    4539   TComDataCU* pcCULeft = 0;
    4540   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    4541 
    4542   Bool isAvailableA1 = pcCULeft &&
    4543                        pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    4544                        !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    4545                        pcCULeft->isInter( uiLeftPartIdx ) ;
    4546 
    4547   if ( isAvailableA1 )
    4548   {
    4549     abCandIsInter[iCount] = true;
    4550     // get Inter Dir
    4551     puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
    4552     // get Mv from Left
    4553     pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4554     if ( getSlice()->isInterB() )
    4555     {
    4556       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4557     }
    4558     if ( mrgCandIdx == iCount )
    4559     {
    4560       return;
    4561     }
    4562     iCount ++;
    4563   }
    4564 
    4565   // early termination
    4566   if (iCount == getSlice()->getMaxNumMergeCand())
    4567   {
    4568     return;
    4569   }
    4570   // above
    4571   UInt uiAbovePartIdx = 0;
    4572   TComDataCU* pcCUAbove = 0;
    4573   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    4574 
    4575   Bool isAvailableB1 = pcCUAbove &&
    4576                        pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    4577                        !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
    4578                        pcCUAbove->isInter( uiAbovePartIdx );
    4579 
    4580   if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    4581   {
    4582     abCandIsInter[iCount] = true;
    4583     // get Inter Dir
    4584     puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
    4585     // get Mv from Left
    4586     pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4587     if ( getSlice()->isInterB() )
    4588     {
    4589       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4590     }
    4591     if ( mrgCandIdx == iCount )
    4592     {
    4593       return;
    4594     }
    4595     iCount ++;
    4596   }
    4597   // early termination
    4598   if (iCount == getSlice()->getMaxNumMergeCand())
    4599   {
    4600     return;
    4601   }
    4602 
    4603   // above right
    4604   UInt uiAboveRightPartIdx = 0;
    4605   TComDataCU* pcCUAboveRight = 0;
    4606   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    4607 
    4608   Bool isAvailableB0 = pcCUAboveRight &&
    4609                        pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    4610                        pcCUAboveRight->isInter( uiAboveRightPartIdx );
    4611 
    4612   if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    4613   {
    4614     abCandIsInter[iCount] = true;
    4615     // get Inter Dir
    4616     puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
    4617     // get Mv from Left
    4618     pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4619     if ( getSlice()->isInterB() )
    4620     {
    4621       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4622     }
    4623     if ( mrgCandIdx == iCount )
    4624     {
    4625       return;
    4626     }
    4627     iCount ++;
    4628   }
    4629   // early termination
    4630   if (iCount == getSlice()->getMaxNumMergeCand())
    4631   {
    4632     return;
    4633   }
    4634 
    4635   //left bottom
    4636   UInt uiLeftBottomPartIdx = 0;
    4637   TComDataCU* pcCULeftBottom = 0;
    4638   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    4639 
    4640   Bool isAvailableA0 = pcCULeftBottom &&
    4641                        pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    4642                        pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ;
    4643 
    4644   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    4645   {
    4646     abCandIsInter[iCount] = true;
    4647     // get Inter Dir
    4648     puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
    4649     // get Mv from Left
    4650     pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4651     if ( getSlice()->isInterB() )
    4652     {
    4653       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4654     }
    4655     if ( mrgCandIdx == iCount )
    4656     {
    4657       return;
    4658     }
    4659     iCount ++;
    4660   }
    4661   // early termination
    4662   if (iCount == getSlice()->getMaxNumMergeCand())
    4663   {
    4664     return;
    4665   }
    4666 
    4667   // above left
    4668   if( iCount < 4 )
    4669   {
    4670     UInt uiAboveLeftPartIdx = 0;
    4671     TComDataCU* pcCUAboveLeft = 0;
    4672     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    4673 
    4674     Bool isAvailableB2 = pcCUAboveLeft &&
    4675                          pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    4676                          pcCUAboveLeft->isInter( uiAboveLeftPartIdx );
    4677 
    4678     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    4679         && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    4680     {
    4681       abCandIsInter[iCount] = true;
    4682       // get Inter Dir
    4683       puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
    4684       // get Mv from Left
    4685       pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4686       if ( getSlice()->isInterB() )
    4687       {
    4688         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4689       }
    4690       if ( mrgCandIdx == iCount )
    4691       {
    4692         return;
    4693       }
    4694       iCount ++;
    4695     }
    4696   }
    4697   // early termination
    4698   if (iCount == getSlice()->getMaxNumMergeCand())
    4699   {
    4700     return;
    4701   }
    4702 
    4703   if ( getSlice()->getEnableTMVPFlag() )
    4704   {
    4705     //>> MTK colocated-RightBottom
    4706     UInt uiPartIdxRB;
    4707 
    4708     deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );
    4709 
    4710     UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    4711     const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
    4712     const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
    4713 
    4714     TComMv cColMv;
    4715     Int iRefIdx;
    4716     Int ctuRsAddr = -1;
    4717 
    4718     if (   ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
    4719         && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    4720     {
    4721       if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&           // is not at the last column of CTU
    4722         ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) )              // is not at the last row    of CTU
    4723       {
    4724         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ];
    4725         ctuRsAddr = getCtuRsAddr();
    4726       }
    4727       else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 )           // is not at the last column of CTU But is last row of CTU
    4728       {
    4729         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
    4730       }
    4731       else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 )          // is not at the last row of CTU But is last column of CTU
    4732       {
    4733         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    4734         ctuRsAddr = getCtuRsAddr() + 1;
    4735       }
    4736       else //is the right bottom corner of CTU
    4737       {
    4738         uiAbsPartAddr = 0;
    4739       }
    4740     }
    4741 
    4742     iRefIdx = 0;
    4743 
    4744     Bool bExistMV = false;
    4745     UInt uiPartIdxCenter;
    4746     Int dir = 0;
    4747     UInt uiArrayAddr = iCount;
    4748     xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
    4749     bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx );
    4750     if( bExistMV == false )
    4751     {
    4752       bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter,  cColMv, iRefIdx );
    4753     }
    4754     if( bExistMV )
    4755     {
    4756       dir |= 1;
    4757       pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
    4758     }
    4759 
    4760     if ( getSlice()->isInterB() )
    4761     {
    4762 #if NH_3D_TMVP
    4763       iRefIdx =0;
    4764 #endif
    4765       bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx);
    4766       if( bExistMV == false )
    4767       {
    4768         bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx );
    4769       }
    4770       if( bExistMV )
    4771       {
    4772         dir |= 2;
    4773         pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
    4774       }
    4775     }
    4776 
    4777     if (dir != 0)
    4778     {
    4779       puhInterDirNeighbours[uiArrayAddr] = dir;
    4780       abCandIsInter[uiArrayAddr] = true;
    4781 
    4782       if ( mrgCandIdx == iCount )
    4783       {
    4784         return;
    4785       }
    4786       iCount++;
    4787     }
    4788   }
    4789   // early termination
    4790   if (iCount == getSlice()->getMaxNumMergeCand())
    4791   {
    4792     return;
    4793   }
    4794 
    4795   UInt uiArrayAddr = iCount;
    4796   UInt uiCutoff = uiArrayAddr;
    4797 
    4798   if ( getSlice()->isInterB() )
    4799   {
    4800     static const UInt NUM_PRIORITY_LIST=12;
    4801     static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
    4802     static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
    4803 
    4804     for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
    4805     {
    4806       assert(idx<NUM_PRIORITY_LIST);
    4807       Int i = uiPriorityList0[idx];
    4808       Int j = uiPriorityList1[idx];
    4809       if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
    4810       {
    4811         abCandIsInter[uiArrayAddr] = true;
    4812         puhInterDirNeighbours[uiArrayAddr] = 3;
    4813 
    4814         // get Mv from cand[i] and cand[j]
    4815         pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
    4816         pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
    4817 
    4818         Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
    4819         Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
    4820         if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
    4821         {
    4822           abCandIsInter[uiArrayAddr] = false;
    4823         }
    4824         else
    4825         {
    4826           uiArrayAddr++;
    4827         }
    4828       }
    4829     }
    4830   }
    4831   // early termination
    4832   if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
    4833   {
    4834     return;
    4835   }
    4836 
    4837   Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
    4838 
    4839   Int r = 0;
    4840   Int refcnt = 0;
    4841   while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
    4842   {
    4843     abCandIsInter[uiArrayAddr] = true;
    4844     puhInterDirNeighbours[uiArrayAddr] = 1;
    4845     pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
    4846 
    4847     if ( getSlice()->isInterB() )
    4848     {
    4849       puhInterDirNeighbours[uiArrayAddr] = 3;
    4850       pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
    4851     }
    4852     uiArrayAddr++;
    4853 
    4854     if ( refcnt == iNumRefIdx - 1 )
    4855     {
    4856       r = 0;
    4857     }
    4858     else
    4859     {
    4860       ++r;
    4861       ++refcnt;
    4862     }
    4863   }
    4864   numValidMergeCand = uiArrayAddr;
    4865 }
    4866 #endif
     4204}
    48674205
    48684206/** Check whether the current PU and a spatial neighboring PU are in a same ME region.
     
    51224460  UInt partAddr;
    51234461
    5124 #if H_3D_DBBP
     4462#if NH_3D_DBBP
    51254463  if( getDBBPFlag(0) )
    51264464  {
     
    51424480  const TComSPS &sps=*(m_pcSlice->getSPS());
    51434481  Int  iMvShift = 2;
    5144 #if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
     4482#if NH_3D_INTEGER_MV_DEPTH
    51454483  if( getSlice()->getIsDepth() )
    51464484    iMvShift = 0;
     
    56665004#endif
    56675005
    5668 #if H_3D_IV_MERGE
     5006#if NH_3D_IV_MERGE
    56695007Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
    56705008{
     
    56765014    Int iViewIdx = getSlice()->getDefaultRefViewIdx();
    56775015    pDisp->m_aVIdxCan = iViewIdx;
    5678     Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepthY() - 1 )) ];
     5016    Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 )) ];
    56795017
    56805018    cMv.setHor(iDisp);
     
    57435081}
    57445082#endif
    5745 #if H_3D_NBDV
     5083#if NH_3D_NBDV
    57465084//Notes from QC:
    5747 //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
     5085//TBD#1: DoNBDV related contributions are just partially integrated under the marco of NH_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done
    57485086//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
    57495087//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
    57505088Void TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo
    5751 #if H_3D_NBDV_REF
     5089#if NH_3D_NBDV_REF
    57525090, Bool bDepthRefine
    57535091#endif
     
    57725110    }
    57735111  }
    5774 #if H_3D_NBDV_REF
     5112#if NH_3D_NBDV_REF
    57755113  if( !m_pcSlice->getDepthRefinementFlag( ) )
    57765114  {
     
    57955133    ///*** Derive center position ***
    57965134    UInt uiPartIdxCenter;
    5797     Int  uiLCUIdx   = getAddr();
     5135    Int  uiLCUIdx = getCtuRsAddr();
    57985136    xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter );
    57995137
     
    58225160        pDInfo->m_aVIdxCan  = iTargetViewIdx;
    58235161
    5824 #if H_3D_NBDV_REF
     5162#if NH_3D_NBDV_REF
    58255163        TComPic* picDepth = NULL;   
    58265164#if H_3D_FCO_VSP_DONBDV_E0163
     
    58445182        }
    58455183        pDInfo->m_acDoNBDV  = cColMv;
    5846 #endif //H_3D_NBDV_REF
     5184#endif //NH_3D_NBDV_REF
    58475185        return;
    58485186      }
     
    58585196  bCheckMcpDv = true;
    58595197  if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
    5860 #if H_3D_NBDV_REF
     5198#if NH_3D_NBDV_REF
    58615199    , bDepthRefine
    58625200#endif
     
    58685206  if(pcTmpCU != NULL )
    58695207  {
    5870     bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
     5208    bCheckMcpDv = ( ( getCtuRsAddr() - pcTmpCU->getCtuRsAddr() ) == 0);
    58715209    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE
    5872 #if H_3D_NBDV_REF
     5210#if NH_3D_NBDV_REF
    58735211      , bDepthRefine
    58745212#endif
     
    58895227          pDInfo->m_acNBDV = cDispVec;
    58905228          pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ];
    5891 #if H_3D_NBDV_REF
     5229#if NH_3D_NBDV_REF
    58925230#if H_3D_FCO_VSP_DONBDV_E0163
    58935231          TComPic* picDepth  = NULL;
     
    59275265    pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx();
    59285266
    5929 #if H_3D_NBDV_REF
     5267#if NH_3D_NBDV_REF
    59305268    TComPic* picDepth = NULL;
    59315269#if H_3D_FCO_VSP_DONBDV_E0163
     
    59535291}
    59545292
    5955 #if H_3D_NBDV_REF
     5293#if NH_3D_NBDV_REF
    59565294Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT )
    59575295{
    5958   Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth();
    5959   Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight();
    5960  
     5296  Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth(COMPONENT_Y);
     5297  Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(COMPONENT_Y);
     5298
    59615299  Int depthStartPosX = Clip3(0,   iPictureWidth - 1,  iBlkX + ((mv->getHor()+2)>>2));
    59625300  Int depthStartPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2));
     
    59645302  Int depthEndPosY   = Clip3(0,   iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2));
    59655303
    5966   Pel* depthTL  = pcBaseViewDepthPicYuv->getLumaAddr();
    5967   Int depStride =  pcBaseViewDepthPicYuv->getStride();
     5304  Pel* depthTL  = pcBaseViewDepthPicYuv->getAddr(COMPONENT_Y);
     5305  Int depStride =  pcBaseViewDepthPicYuv->getStride(COMPONENT_Y);
    59685306
    59695307  Pel  maxDepthVal = 0;
     
    59805318  if (picDepth)
    59815319  {
    5982     UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr;
     5320    UInt uiAbsPartAddrCurrCU = m_absZIdxInCtu + uiPartAddr;
    59835321    Int iWidth, iHeight;
    59845322    getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more
    59855323
    59865324    TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec();
    5987     Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
    5988     Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
     5325    const TComSPS   &sps =*(getSlice()->getSPS());
     5326    Int iBlkX = ( getCtuRsAddr() % picDepth->getFrameWidthInCtus() ) * sps.getMaxCUWidth()  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
     5327    Int iBlkY = ( getCtuRsAddr() / picDepth->getFrameWidthInCtus() ) * sps.getMaxCUHeight() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
    59895328
    59905329    Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx );
     
    59945333  }
    59955334}
    5996 #endif //H_3D_NBDV_REF
     5335#endif //NH_3D_NBDV_REF
    59975336
    59985337
    59995338Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
    6000 #if H_3D_NBDV_REF
     5339#if NH_3D_NBDV_REF
    60015340, Bool bDepthRefine
    60025341#endif
     
    60195358          pNbDvInfo->m_acNBDV = cMvPred;
    60205359          pNbDvInfo->m_aVIdxCan = refViewIdx;
    6021 #if H_3D_NBDV_REF
     5360#if NH_3D_NBDV_REF
    60225361          TComPic* picDepth = NULL;
    60235362          assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());         
     
    60655404{
    60665405  UInt uiPartIdx = 0;
    6067   UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 
    6068   Int uiLCUIdx = getAddr();
     5406  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInCtuWidth(); 
     5407  Int uiLCUIdx = getCtuRsAddr();
    60695408
    60705409  UInt uiPartIdxRB;
     
    60725411  UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    60735412
    6074   if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
     5413  if (( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
    60755414  {
    60765415    riLCUIdxRBNb  = -1;
    60775416    riPartIdxRBNb = -1;
    60785417  }
    6079   else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
     5418  else if(( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    60805419  {
    60815420    riLCUIdxRBNb  = -1;
     
    60855424  {
    60865425    if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    6087       ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
     5426      ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) ) // is not at the last row    of LCU
    60885427    {
    60895428      riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
     
    60955434      riLCUIdxRBNb  = -1;
    60965435    }
    6097     else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     5436    else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
    60985437    {
    60995438      riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
     
    61115450Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth )
    61125451{
    6113   UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);
     5452#if NH_3D_VSP // bug fix
     5453  UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
     5454  assert(m_pcPic->getNumPartitionsInCtu() ==m_pcPic->getNumPartInCtuWidth()*m_pcPic->getNumPartInCtuHeight());
     5455
     5456#else
     5457  UInt uiCurrPartNumb = m_pcPic->getNumPartInCtuWidth() >> (uiDepth << 1);
     5458#endif
    61145459  for (UInt ui = 0; ui < uiCurrPartNumb; ui++ )
    61155460  {
     
    61175462  }
    61185463}
    6119 #if H_3D_VSP
     5464#if NH_3D_VSP  || NH_3D_DBBP
    61205465Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth )
    61215466{
     
    61305475  Int iColViewIdx, iColRefViewIdx;
    61315476  TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
    6132   TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
     5477  TComDataCU *pColCU = pColPic->getCtu( uiCUAddr );
    61335478  iColViewIdx = pColCU->getSlice()->getViewIndex();
    6134   if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx))
     5479  if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES||pColCU->isIntra(uiPartUnitIdx))
    61355480  {
    61365481    return false;
     
    61945539
    61955540  Bool depthRefineFlag = false;
    6196 #if H_3D_NBDV_REF
     5541#if NH_3D_NBDV_REF
    61975542  depthRefineFlag = m_pcSlice->getDepthRefinementFlag( );
    6198 #endif // H_3D_NBDV_REF
     5543#endif // NH_3D_NBDV_REF
    61995544
    62005545  TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
     
    62505595#endif
    62515596
    6252 #if H_3D_SPIVMP
     5597#if NH_3D_SPIVMP
    62535598Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight)
    62545599{
     
    62675612Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr )
    62685613{
    6269   uiBaseAbsPartIdx += m_uiAbsIdxInLCU;
     5614  uiBaseAbsPartIdx += m_absZIdxInCtu;
    62705615  Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]];
    62715616  Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]];
    62725617  Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth;
    62735618  Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight;
    6274   Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + iCurrPelX/getPic()->getMinCUWidth();
     5619  Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + iCurrPelX/getPic()->getMinCUWidth();
    62755620  ruiPartAddr = g_auiRasterToZscan[iCurrRaster];
    6276   ruiPartAddr -= m_uiAbsIdxInLCU
     5621  ruiPartAddr -= m_absZIdxInCtu
    62775622}
    62785623
    62795624Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight )
    62805625{
    6281   uiAbsPartIdx += getZorderIdxInCU();
     5626  uiAbsPartIdx += getZorderIdxInCtu();
    62825627  Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
    62835628  Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
     
    62915636    for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth())
    62925637    {
    6293       iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + j/getPic()->getMinCUWidth();
     5638      iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + j/getPic()->getMinCUWidth();
    62945639      uiPartAddr = g_auiRasterToZscan[iCurrRaster];
    6295       uiPartAddr -= getZorderIdxInCU(); 
     5640      uiPartAddr -= getZorderIdxInCtu(); 
    62965641
    62975642      m_puhInterDir[uiPartAddr] = uiDir;
     
    63015646#endif
    63025647
    6303 #if H_3D_IV_MERGE
     5648#if NH_3D_IV_MERGE
    63045649Bool
    63055650TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth           
    6306 #if H_3D_SPIVMP
     5651#if NH_3D_SPIVMP
    63075652, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    63085653#endif
     
    63235668
    63245669  Int  iCurrPosX, iCurrPosY;
    6325   pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
    6326 
    6327 #if !H_3D_SPIVMP
     5670  pcBaseRec->getTopLeftSamplePos( getCtuRsAddr(), getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
     5671
     5672#if !NH_3D_SPIVMP
    63285673  iCurrPosX  += ( iWidth  >> 1 );
    63295674  iCurrPosY  += ( iHeight >> 1 );
     
    63315676
    63325677  Bool depthRefineFlag = false;
    6333 #if H_3D_NBDV_REF
     5678#if NH_3D_NBDV_REF
    63345679  depthRefineFlag = m_pcSlice->getDepthRefinementFlag( );
    6335 #endif // H_3D_NBDV_REF
     5680#endif // NH_3D_NBDV_REF
    63365681
    63375682  TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
     
    63425687
    63435688  Bool abPdmAvailable[8] =  {false, false, false, false, false, false, false, false};
    6344 #if H_3D_NBDV
     5689#if NH_3D_NBDV
    63455690  for( Int i = 0; i < 8; i++)
    63465691  {
     
    63525697  {
    63535698
    6354 #if H_3D_SPIVMP
     5699#if NH_3D_SPIVMP
    63555700    ////////////////////////////////
    63565701    //////////sub-PU IvMC///////////
     
    63585703    if(!m_pcSlice->getIsDepth())
    63595704    {
     5705#if H_3D_DBBP
    63605706      if (!getDBBPFlag(0))
     5707#else
     5708      if (1)
     5709#endif
    63615710      {
    63625711        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
     
    63905739        }
    63915740
    6392         Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    6393         Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) );
     5741        Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
     5742        Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) );
    63945743
    63955744        pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx );
    6396         TComDataCU* pcDefaultCU    = pcBasePic->getCU( iRefCenterCUAddr );
     5745        TComDataCU* pcDefaultCU    = pcBasePic->getCtu( iRefCenterCUAddr );
    63975746        if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA ))
    63985747        {
     
    64185767                      abPdmAvailable[ uiCurrRefListId ] = true;
    64195768                      TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
    6420 #if H_3D_NBDV
    6421 #if H_3D_IV_MERGE
     5769#if NH_3D_NBDV
     5770#if NH_3D_IV_MERGE
    64225771                      if( !bIsDepth )
    64235772                      {
     
    64275776                        cMv.setIDVVer    (cDv.getVer()); 
    64285777                        cMv.setIDVVId    (iViewIndex);
    6429 #if H_3D_IV_MERGE
     5778#if NH_3D_IV_MERGE
    64305779                      }
    64315780#endif
     
    64525801            for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth)
    64535802            {
    6454               iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
    6455               iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 ));
     5803              iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
     5804              iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 ));
    64565805
    64575806              pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
    6458               pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
     5807              pcBaseCU    = pcBasePic->getCtu( iBaseCUAddr );
    64595808              if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    64605809              {
     
    65245873    ////////////////////////////////
    65255874
    6526 #if H_3D_SPIVMP
     5875#if NH_3D_SPIVMP
    65275876    if(m_pcSlice->getIsDepth())
    65285877    {
     
    65305879      iCurrPosY  += ( iHeight >> 1 );
    65315880    }
     5881#if H_3D_DBBP
    65325882    for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    65335883#else
     5884    for(Int iLoopCan = ( m_pcSlice->getIsDepth() ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
     5885#endif
     5886#else
    65345887    for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    65355888#endif
     
    65415894      Int         iBaseAbsPartIdx;
    65425895
    6543       Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth  * 2 );
    6544       Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2 );
    6545 
    6546       Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
    6547       Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) );
     5896      Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth  * 2);
     5897      Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2);
     5898
     5899      Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
     5900      Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) );
    65485901      pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
    65495902
    6550       TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
     5903      TComDataCU* pcBaseCU    = pcBasePic->getCtu( iBaseCUAddr );
    65515904      if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    65525905      {
     
    65755928                    abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true;
    65765929                    TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
    6577 #if H_3D_NBDV
    6578 #if H_3D_IV_MERGE
     5930#if NH_3D_NBDV
     5931#if NH_3D_IV_MERGE
    65795932                    if( !bIsDepth )
    65805933                    {
     
    65845937                      cMv.setIDVVer    (cDv.getVer()); 
    65855938                      cMv.setIDVVId    (iViewIndex);
    6586 #if H_3D_IV_MERGE
     5939#if NH_3D_IV_MERGE
    65875940                    }
    65885941#endif
     
    66005953      }
    66015954    }
    6602 #if H_3D_SPIVMP
     5955#if NH_3D_SPIVMP
     5956#if H_3D_DBBP
    66035957    for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
     5958#else
     5959    for(Int iLoopCan = ( m_pcSlice->getIsDepth()  ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
     5960#endif
    66045961#else
    66055962    for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
     
    66305987            abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true;
    66315988            paiPdmRefIdx  [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx;
    6632 #if H_3D_NBDV_REF
     5989#if NH_3D_NBDV_REF
    66335990            TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    66345991#endif
    66355992            cMv.setHor( cMv.getHor() + ioffsetDV );
    6636 #if H_3D_IV_MERGE
     5993#if NH_3D_IV_MERGE
    66375994            if( bIsDepth )
    66385995            {
     
    66556012}
    66566013#endif
    6657 #if H_3D_ARP
     6014#if NH_3D_ARP
    66586015Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth )
    66596016{
    6660   assert( sizeof( *m_puhARPW) == 1 );
    6661   memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) );
     6017  setSubPart<UChar>( w, m_puhARPW, uiAbsPartIdx, uiDepth, 0 );
    66626018}
    66636019#endif
     
    67286084#endif
    67296085
    6730 #if H_3D_VSP
     6086#if NH_3D_VSP
    67316087Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize )
    67326088{
     
    67846140  TComCUMvField *cuMvField = cu->getCUMvField( refPicList );
    67856141  Int partAddrRasterSubPULine  = g_auiZscanToRaster[ partAddr ];
    6786   Int numPartsLine    = cu->getPic()->getNumPartInWidth();
     6142  Int numPartsLine    = cu->getPic()->getNumPartInCtuWidth();
    67876143
    67886144  Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth();
    67896145  Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight();
    67906146
    6791   Int refDepStride = picRefDepth->getStride();
     6147  Int refDepStride = picRefDepth->getStride( COMPONENT_Y );
    67926148
    67936149  TComMv tmpMv(0, 0);
     
    67956151
    67966152  Int refDepOffset  = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride;
    6797   Pel *refDepth     = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refDepOffset;
     6153  Pel *refDepth     = picRefDepth->getAddr( COMPONENT_Y, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refDepOffset;
    67986154
    67996155  if ((height % 8))
Note: See TracChangeset for help on using the changeset viewer.