Changeset 1279 in 3DVCSoftware for branches/HTM-14.1-update-dev1/source


Ignore:
Timestamp:
15 Jul 2015, 14:57:32 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev2@1277.

Location:
branches/HTM-14.1-update-dev1
Files:
59 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-14.1-update-dev1

  • branches/HTM-14.1-update-dev1/source/App/TAppEncoder/TAppEncTop.cpp

    r1249 r1279  
    291291    m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
    292292#endif // H_3D_VSO
    293 #if H_3D_IC
     293#if NH_3D_IC
    294294    m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC );
    295295    m_cTEncTop.setUseICLowLatencyEnc           ( m_bUseLowLatencyICEnc );
  • branches/HTM-14.1-update-dev1/source/Lib/TAppCommon/TAppComCamPara.cpp

    r1239 r1279  
    13731373  Int  iSourceViewNum = m_aiBaseViews[ iViewIdx ];
    13741374  Double dBaseLine = 0.0;
    1375   Double dFL1 = 0.0, dCS1 = 0.0, dCP1 = 0.0, dZN1 = 0.0, dZF1 = 0.0;
     1375  Double dFL1 = 1.0, dCS1 = 1.0, dCP1 = 1.0, dZN1 = 1.0, dZF1 = 1.0;
    13761376  Bool bInterpolated = false;
    13771377  double dPos[3] = {0.0, 0.0, 0.0};
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/CommonDef.h

    r1200 r1279  
    363363#endif
    364364
    365 #if H_3D_IV_MERGE
     365#if NH_3D_MLC  || NH_3D_ARP
    366366#define MRG_MAX_NUM_CANDS_MEM       (MRG_MAX_NUM_CANDS+1) // one extra for inter-view motion prediction
    367367#endif
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/ContextTables.h

    r1258 r1279  
    162162#define NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX  1
    163163
    164 #if H_3D_ARP
     164#if NH_3D_ARP
    165165#define NUM_ARPW_CTX                  3       ///< number of context models for weighting factor index used by advanced residual prediction
    166166#endif
    167167
    168 #if H_3D_IC
     168#if NH_3D_IC
    169169#define NUM_IC_FLAG_CTX               1       ///< number of context models for illumination compensation flag
    170170#endif
     
    186186#define NUM_DDC_FLAG_CTX              2       ///< number of context models for deltaDC flag (SDC only)
    187187#endif
    188 #if H_3D_DBBP
     188#if NH_3D_DBBP
    189189#define DBBP_NUM_FLAG_CTX                 1
    190190#endif
     
    540540//! \}
    541541
    542 #if H_3D_ARP
     542#if NH_3D_ARP
    543543static const UChar
    544544INIT_ARPW[3][NUM_ARPW_CTX] =
     
    550550
    551551#endif
    552 #if H_3D_IC
     552#if NH_3D_IC
    553553static const UChar
    554554INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] = 
     
    616616};
    617617#endif
    618 #if H_3D_DBBP
     618#if NH_3D_DBBP
    619619static const UChar INIT_DBBP_FLAG[3][DBBP_NUM_FLAG_CTX] =
    620620{
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComCodingStatistics.h

    r1239 r1279  
    8181  STATS__CABAC_BITS__ESCAPE_BITS,
    8282
     83#if NH_3D_DBBP
     84  STATS__CABAC_BITS__DBBP_FLAG,
     85#endif
     86#if NH_3D_ARP
     87  STATS__CABAC_BITS__ARP_FLAG,
     88#endif
    8389  STATS__CABAC_BITS__SAO,
    8490  STATS__CABAC_TRM_BITS,
     
    9399  STATS__CABAC_BITS__ALIGNED_ESCAPE_BITS,
    94100
     101#if NH_3D_IC
     102  STATS__CABAC_BITS__3D_IC,
     103#endif
    95104#if NH_3D_DMM || NH_3D_SDC_INTRA || H_3D_INTER_SDC
    96105  STATS__CABAC_BITS__DELTADC_SIGN_EP,
     
    147156    "CABAC_BITS__SIGN_BIT",
    148157    "CABAC_BITS__ESCAPE_BITS",
     158#if NH_3D_DBBP
     159    "CABAC_BITS__DBBP_FLAG",
     160#endif
    149161    "CABAC_BITS__SAO",
    150162    "CABAC_TRM_BITS",
     
    158170    "CABAC_BITS__ALIGNED_SIGN_BIT",
    159171    "CABAC_BITS__ALIGNED_ESCAPE_BITS"
     172
     173#if NH_3D_IC
     174    "CABAC_BITS__3D_IC"
     175#endif
    160176#if NH_3D_DMM || NH_3D_SDC_INTRA || H_3D_INTER_SDC
    161177   ,"STATS__CABAC_BITS__DELTADC_SIGN_EP"
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComDataCU.cpp

    r1258 r1279  
    120120  m_bDecSubCu          = false;
    121121
    122 #if H_3D_NBDV
     122#if NH_3D_NBDV
    123123  m_pDvInfo              = NULL;
    124124#endif
    125 #if H_3D_VSP
     125#if NH_3D_VSP
    126126  m_piVSPFlag            = NULL;
    127127#endif
    128 #if H_3D_SPIVMP
     128#if NH_3D_SPIVMP
    129129  m_pbSPIVMPFlag         = NULL;
    130130#endif
    131 #if H_3D_ARP
     131#if NH_3D_ARP
    132132  m_puhARPW              = NULL;
    133133#endif
    134 #if H_3D_IC
     134#if NH_3D_IC
    135135  m_pbICFlag             = NULL;
    136136#endif
    137137#if H_3D_INTER_SDC
    138138#endif
    139 #if H_3D_DBBP
     139#if NH_3D_DBBP
    140140  m_pbDBBPFlag         = NULL;
    141141#endif
     
    180180    m_pbMergeFlag        = (Bool*  )xMalloc(Bool,   uiNumPartition);
    181181    m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
    182 #if H_3D_VSP
     182#if NH_3D_VSP
    183183    m_piVSPFlag          = (Char*  )xMalloc(Char,   uiNumPartition);
    184184#endif
    185 #if H_3D_SPIVMP
     185#if NH_3D_SPIVMP
    186186    m_pbSPIVMPFlag       = (Bool*  )xMalloc(Bool,   uiNumPartition);
    187187#endif
     
    203203    }
    204204
    205 #if H_3D_NBDV
     205#if NH_3D_NBDV
    206206    m_pDvInfo            = (DisInfo* )xMalloc(DisInfo,  uiNumPartition);
    207207#endif
     
    244244    }
    245245
    246 #if H_3D_ARP
    247     m_puhARPW            = new UChar[ uiNumPartition];
    248 #endif
    249 #if H_3D_IC
     246#if NH_3D_ARP
     247    m_puhARPW            = (UChar*  )xMalloc(UChar,   uiNumPartition);
     248#endif
     249#if NH_3D_IC
    250250    m_pbICFlag           = (Bool* )xMalloc(Bool,   uiNumPartition);
    251251#endif
     
    263263    m_apSegmentDCOffset[1]  = (Pel*)xMalloc(Pel, uiNumPartition);
    264264#endif
    265 #if H_3D_DBBP
     265#if NH_3D_DBBP
    266266    m_pbDBBPFlag         = (Bool*  )xMalloc(Bool,   uiNumPartition);
    267267#endif
     
    362362    }
    363363
    364 #if H_3D_VSP
    365     if ( m_piVSPFlag          ) { xFree(m_piVSPFlag);           m_piVSPFlag         = NULL; }
    366 #endif
    367 #if H_3D_SPIVMP
     364#if NH_3D_VSP
     365    if ( m_piVSPFlag )
     366    {
     367      xFree(m_piVSPFlag);
     368      m_piVSPFlag = NULL;
     369    }
     370#endif
     371#if NH_3D_SPIVMP
    368372    if ( m_pbSPIVMPFlag       ) { xFree(m_pbSPIVMPFlag);           m_pbSPIVMPFlag         = NULL; }
    369373#endif
     
    453457      m_acCUMvField[rpl].destroy();
    454458    }
    455 #if H_3D_NBDV
     459#if NH_3D_NBDV
    456460    if ( m_pDvInfo            ) { xFree(m_pDvInfo);             m_pDvInfo           = NULL; }
    457461#endif
    458462
    459463
    460 #if H_3D_ARP
    461     if ( m_puhARPW            ) { delete[] m_puhARPW;           m_puhARPW           = NULL; }
    462 #endif
    463 #if H_3D_IC
     464#if NH_3D_ARP
     465    if ( m_puhARPW            ) { xFree(m_puhARPW);             m_puhARPW           = NULL; }
     466#endif
     467#if NH_3D_IC
    464468    if ( m_pbICFlag           ) { xFree(m_pbICFlag);            m_pbICFlag          = NULL; }
    465469#endif
     
    478482    if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]);  m_apSegmentDCOffset[1]  = NULL; }
    479483#endif   
    480 #if H_3D_DBBP
     484#if NH_3D_DBBP
    481485    if ( m_pbDBBPFlag         ) { xFree(m_pbDBBPFlag);          m_pbDBBPFlag        = NULL; }
    482486#endif
     
    583587  memset( m_puhHeight         , maxCUHeight,                m_uiNumPartition * sizeof( *m_puhHeight ) );
    584588
    585 #if H_3D_ARP
    586     m_puhARPW   [ui] = pcFrom->getARPW( ui );
    587 #endif
    588 #if H_3D_IC
    589     m_pbICFlag[ui]   =  pcFrom->m_pbICFlag[ui];
    590 #endif
    591 
     589#if NH_3D_IC
     590  memset( m_pbICFlag          , false,                      m_uiNumPartition * sizeof( *m_pbICFlag ) );
     591#endif
    592592  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    593593  {
     
    608608  memset( m_puhMergeIndex     , 0,                        m_uiNumPartition * sizeof( *m_puhMergeIndex ) );
    609609
    610 #if H_3D_VSP
    611     m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui];
    612 #endif
    613 #if H_3D_SPIVMP
    614     m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui];
     610#if NH_3D_VSP
     611  memset( m_piVSPFlag         , 0,                        m_uiNumPartition * sizeof( *m_piVSPFlag ) );
     612#endif
     613#if NH_3D_SPIVMP
     614  memset( m_pbSPIVMPFlag      , 0,                     m_uiNumPartition * sizeof( *m_pbSPIVMPFlag ) );   
    615615#endif
    616616#if NH_3D_SDC_INTRA
    617617  memset( m_pbSDCFlag, false, m_uiNumPartition * sizeof( *m_pbSDCFlag ) );
    618618#endif
    619 #if H_3D_DBBP
    620     m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui];
    621 #endif
    622 #if H_3D_VSP
    623     memset( m_piVSPFlag         + firstElement, 0,                        numElements * sizeof( *m_piVSPFlag ) );
    624 #endif
    625 #if H_3D_SPIVMP
    626     memset( m_pbSPIVMPFlag      + firstElement, 0,                        numElements * sizeof( *m_pbSPIVMPFlag ) );
     619#if NH_3D_DBBP
     620  memset( m_pbDBBPFlag , false, m_uiNumPartition * sizeof( *m_pbDBBPFlag ));
    627621#endif
    628622
     
    632626  }
    633627
    634 #if H_3D_ARP
    635     memset( m_puhARPW           + firstElement, 0,                        numElements * sizeof( UChar )         );
    636 #endif
    637 #if H_3D_IC
    638     memset( m_pbICFlag          + firstElement, false,                    numElements * sizeof( *m_pbICFlag )   );
    639 #endif
    640 
     628#if NH_3D_ARP
     629  memset( m_puhARPW      ,      0,        m_uiNumPartition * sizeof( *m_puhARPW )         );
     630#endif
    641631
    642632
     
    653643    memset( m_apSegmentDCOffset[0],     0,                m_uiNumPartition * sizeof( *m_apSegmentDCOffset[0] ) );
    654644    memset( m_apSegmentDCOffset[1],     0,                m_uiNumPartition * sizeof( *m_apSegmentDCOffset[1] ) );
    655 #endif
    656 #if H_3D_DBBP
    657     memset( m_pbDBBPFlag        + firstElement, false,                    numElements * sizeof( *m_pbDBBPFlag ) );
    658645#endif
    659646
     
    770757    m_pbMergeFlag[ui]   = 0;
    771758    m_puhMergeIndex[ui] = 0;
    772 #if H_3D_VSP
    773       m_piVSPFlag[ui] = 0;
    774 #endif
    775 #if H_3D_SPIVMP
    776       m_pbSPIVMPFlag[ui] = 0;
     759#if NH_3D_VSP
     760    m_piVSPFlag[ui]    = 0;
     761#endif
     762#if NH_3D_SPIVMP
     763    m_pbSPIVMPFlag[ui] = 0;
    777764#endif
    778765
     
    787774      m_puhCbf[comp][ui] = 0;
    788775    }
    789 #if H_3D_ARP
     776#if NH_3D_ARP
    790777      m_puhARPW[ui] = 0;
    791778#endif
    792 #if H_3D_IC
     779#if NH_3D_IC
    793780      m_pbICFlag[ui]  = false;
    794781#endif
     
    808795      m_apSegmentDCOffset[1][ui] = 0;
    809796#endif
    810 #if H_3D_DBBP
     797#if NH_3D_DBBP
    811798      m_pbDBBPFlag[ui] = false;
    812799#endif
     
    864851  memset( m_pbMergeFlag,        0, iSizeInBool  );
    865852  memset( m_puhMergeIndex,      0, iSizeInUchar );
    866 #if H_3D_VSP
     853#if NH_3D_VSP
    867854  memset( m_piVSPFlag,          0, sizeof( Char  ) * m_uiNumPartition );
    868855#endif
    869 #if H_3D_SPIVMP
     856#if NH_3D_SPIVMP
    870857  memset( m_pbSPIVMPFlag,       0, sizeof( Bool  ) * m_uiNumPartition );
    871858#endif
     
    886873    memset( m_explicitRdpcmMode[comp],             NUMBER_OF_RDPCM_MODES, iSizeInUchar );
    887874  }
    888 #if H_3D_ARP
    889   memset( m_puhARPW,            0, iSizeInUchar  );
    890 #endif
    891875
    892876  memset( m_puhDepth,     uiDepth, iSizeInUchar );
     
    894878  memset( m_puhHeight,         uhHeight, iSizeInUchar );
    895879  memset( m_pbIPCMFlag,        0, iSizeInBool  );
    896 #if H_3D_IC
     880#if NH_3D_ARP
     881  memset( m_puhARPW,           0, iSizeInUchar  );
     882#endif
     883#if NH_3D_IC
    897884  memset( m_pbICFlag,          0, iSizeInBool  );
    898885#endif
     
    910897  memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition   );
    911898#endif
    912 #if H_3D_DBBP
    913   memset( m_pbDBBPFlag,         0, iSizeInBool  );
     899#if NH_3D_DBBP
     900  memset( m_pbDBBPFlag,         0, sizeof(Bool) * m_uiNumPartition  );
    914901#endif
    915902
     
    937924      m_ucDISType[ui]   = pcCU->getDISType(uiPartOffset+ui);
    938925#endif
    939 #if H_3D_VSP
    940       m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui];
    941       m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
    942 #endif
    943 #if H_3D_SPIVMP
    944       m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
    945 #endif
    946 #if H_3D_ARP
     926#if NH_3D_VSP
     927    m_piVSPFlag[ui] = pcCU->m_piVSPFlag[uiPartOffset+ui];
     928    m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
     929#endif
     930#if NH_3D_SPIVMP
     931    m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
     932#endif
     933#if NH_3D_ARP
    947934      m_puhARPW           [ui] = pcCU->getARPW( uiPartOffset+ui );
    948935#endif
    949 #if H_3D_IC
     936#if NH_3D_IC
    950937      m_pbICFlag          [ui] = pcCU->m_pbICFlag[uiPartOffset+ui];
    951938#endif
     
    963950    m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ];
    964951#endif
    965 #if H_3D_DBBP
     952#if NH_3D_DBBP
    966953      m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui];
    967954#endif
     
    10341021  m_pePredMode=pcCU->getPredictionMode()  + uiPart;
    10351022  m_CUTransquantBypass  = pcCU->getCUTransquantBypass()+uiPart;
    1036 #if H_3D_NBDV
     1023#if NH_3D_NBDV
    10371024  m_pDvInfo             = pcCU->getDvInfo()           + uiPart;
    10381025#endif
     
    10401027  m_pbMergeFlag         = pcCU->getMergeFlag()        + uiPart;
    10411028  m_puhMergeIndex       = pcCU->getMergeIndex()       + uiPart;
    1042 #if H_3D_VSP
     1029#if NH_3D_VSP
    10431030  m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
    10441031#endif
    1045 #if H_3D_SPIVMP
     1032#if NH_3D_SPIVMP
    10461033  m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
    10471034#endif
    1048 #if H_3D_ARP
     1035#if NH_3D_ARP
    10491036  m_puhARPW             = pcCU->getARPW()             + uiPart;
    10501037#endif
    1051 #if H_3D_IC
     1038#if NH_3D_IC
    10521039  m_pbICFlag            = pcCU->getICFlag()           + uiPart;
    10531040#endif
     
    10811068  m_apSegmentDCOffset[1]    = pcCU->getSDCSegmentDCOffset(1)  + uiPart;
    10821069#endif 
    1083 #if H_3D_DBBP
     1070#if NH_3D_DBBP
    10841071  m_pbDBBPFlag              = pcCU->getDBBPFlag()         + uiPart;
    10851072#endif
     
    11281115}
    11291116
    1130 #if H_3D_NBDV
     1117#if NH_3D_NBDV
    11311118Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx)
    11321119{
     
    11371124// Copy inter prediction info from the biggest CU
    11381125Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
    1139 #if H_3D_NBDV
     1126#if NH_3D_NBDV
    11401127  , Bool bNBDV
    11411128#endif
     
    11681155
    11691156  m_pePartSize         = pcCU->getPartitionSize ()        + uiAbsPartIdx;
    1170 #if H_3D_NBDV
     1157#if NH_3D_NBDV
    11711158  if(bNBDV == true)
    11721159  {
     
    11891176  m_pbMergeFlag        = pcCU->getMergeFlag()             + uiAbsPartIdx;
    11901177  m_puhMergeIndex      = pcCU->getMergeIndex()            + uiAbsPartIdx;
    1191 #if H_3D_VSP
     1178#if NH_3D_VSP
    11921179  m_piVSPFlag          = pcCU->getVSPFlag()               + uiAbsPartIdx;
    11931180  m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
    11941181#endif
    1195 #if H_3D_SPIVMP
     1182#if NH_3D_SPIVMP
    11961183  m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()            + uiAbsPartIdx;
    11971184#endif
     
    11991186  m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
    12001187  m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;
    1201 #if H_3D_ARP
     1188#if NH_3D_ARP
    12021189  m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
    12031190#endif   
    1204 #if H_3D_DBBP
     1191#if NH_3D_DBBP
    12051192  m_pbDBBPFlag       = pcCU->getDBBPFlag()              + uiAbsPartIdx;
    12061193#endif
    12071194
    12081195  m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx );
    1209 #if H_3D_NBDV
    1210   }
    1211 #endif
    1212 #if H_3D_IC
     1196#if NH_3D_NBDV
     1197  }
     1198#endif
     1199#if NH_3D_IC
    12131200  m_pbICFlag           = pcCU->getICFlag()                + uiAbsPartIdx;
    12141201#endif
     
    12471234  memcpy( m_pbMergeFlag         + uiOffset, pcCU->getMergeFlag(),         iSizeInBool  );
    12481235  memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
    1249 #if H_3D_VSP
     1236#if NH_3D_VSP
    12501237  memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
    12511238  memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
    12521239#endif
    1253 #if H_3D_SPIVMP
     1240#if NH_3D_SPIVMP  || NH_3D_DBBP
    12541241  memcpy( m_pbSPIVMPFlag        + uiOffset, pcCU->getSPIVMPFlag(),        sizeof( Bool ) * uiNumPartition );
    12551242#endif
     
    12831270  memcpy( m_apSegmentDCOffset[1]  + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition);
    12841271#endif
    1285 #if H_3D_DBBP
     1272#if NH_3D_DBBP
    12861273  memcpy( m_pbDBBPFlag          + uiOffset, pcCU->getDBBPFlag(),          iSizeInBool  );
     1274#endif
     1275#if NH_3D_ARP
     1276  memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
    12871277#endif
    12881278
     
    13261316  }
    13271317
    1328 #if H_3D_ARP
    1329   memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
    1330 #endif
    1331 #if H_3D_IC
     1318#if NH_3D_IC
    13321319  memcpy( m_pbICFlag            + uiOffset, pcCU->getICFlag(),            iSizeInBool );
    13331320#endif
     
    13591346
    13601347  memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar  );
    1361 #if H_3D_NBDV
    1362   memcpy( rpcCU->getDvInfo()         + m_uiAbsIdxInLCU, m_pDvInfo,    sizeof(* m_pDvInfo)    * m_uiNumPartition );
     1348#if NH_3D_NBDV
     1349  memcpy( pCtu->getDvInfo() + m_absZIdxInCtu, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition );
    13631350#endif
    13641351
     
    13691356  memcpy( pCtu->getMergeFlag()         + m_absZIdxInCtu, m_pbMergeFlag,         iSizeInBool  );
    13701357  memcpy( pCtu->getMergeIndex()        + m_absZIdxInCtu, m_puhMergeIndex,       iSizeInUchar );
    1371   #if H_3D_VSP
    1372   memcpy( rpcCU->getVSPFlag()           + m_uiAbsIdxInLCU, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
    1373   memcpy( rpcCU->getDvInfo()            + m_uiAbsIdxInLCU, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
    1374 #endif
    1375 #if H_3D_SPIVMP
    1376   memcpy( rpcCU->getSPIVMPFlag()        + m_uiAbsIdxInLCU, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
     1358#if NH_3D_VSP
     1359  memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
     1360#endif
     1361#if NH_3D_DBBP
     1362  memcpy( pCtu->getDvInfo()            + m_absZIdxInCtu, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
     1363#endif
     1364#if NH_3D_SPIVMP
     1365  memcpy( pCtu->getSPIVMPFlag()        + m_absZIdxInCtu, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
    13771366#endif
    13781367
     
    14061395  memcpy( pCtu->getSDCSegmentDCOffset(1) + m_absZIdxInCtu, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition);
    14071396#endif
    1408 #if H_3D_DBBP
    1409   memcpy( rpcCU->getDBBPFlag()          + m_uiAbsIdxInLCU, m_pbDBBPFlag,          iSizeInBool  );
     1397#if NH_3D_DBBP
     1398  memcpy( pCtu->getDBBPFlag()          + m_absZIdxInCtu, m_pbDBBPFlag,          iSizeInBool  );
     1399#endif
     1400#if NH_3D_ARP
     1401  memcpy( pCtu->getARPW()              + m_absZIdxInCtu, m_puhARPW,             iSizeInUchar );
    14101402#endif
    14111403
     
    14421434  }
    14431435
    1444 #if H_3D_ARP
    1445   memcpy( rpcCU->getARPW()             + m_uiAbsIdxInLCU, m_puhARPW,             iSizeInUchar );
    1446 #endif
    1447 #if H_3D_IC
    1448   memcpy( rpcCU->getICFlag()           + m_uiAbsIdxInLCU, m_pbICFlag,            iSizeInBool );
    1449 #endif
    1450 
     1436#if NH_3D_IC
     1437  memcpy( pCtu->getICFlag() + m_absZIdxInCtu, m_pbICFlag, sizeof( *m_pbICFlag ) * m_uiNumPartition );
     1438#endif
    14511439  pCtu->getTotalBins() = m_uiTotalBins;
    14521440}
    1453 #if H_3D_VSP
    1454   memcpy( rpcCU->getVSPFlag()           + uiPartOffset, m_piVSPFlag,           sizeof(Char) * uiQNumPart );
    1455 #endif
    14561441#if H_3D_SPIVMP
    14571442  memcpy( rpcCU->getSPIVMPFlag()        + uiPartOffset, m_pbSPIVMPFlag,        sizeof(Bool) * uiQNumPart );
    1458 #endif
    1459 #if H_3D_DBBP
    1460   memcpy( rpcCU->getDBBPFlag()          + uiPartOffset, m_pbDBBPFlag,          iSizeInBool  );
    1461 #endif
    1462 #if H_3D_ARP
    1463   memcpy( rpcCU->getARPW()             + uiPartOffset, m_puhARPW,             iSizeInUchar );
    1464 #endif
    1465 #if H_3D_IC
    1466   memcpy( rpcCU->getICFlag()           + uiPartOffset, m_pbICFlag,            iSizeInBool );
    14671443#endif
    14681444
     
    20171993  return uiCtx;
    20181994}
    2019 #if H_3D_ARP
     1995#if NH_3D_ARP
    20201996UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
    20211997{
     
    20242000  UInt        uiCtx = 0;
    20252001 
    2026   pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
     2002  pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
    20272003  uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
    20282004    return uiCtx;
    20292005}
    20302006#endif
    2031 #if H_3D_DBBP
     2007#if NH_3D_DBBP
    20322008Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride)
    20332009{
     2010  const TComSPS* sps = getSlice()->getSPS();
     2011  UInt uiMaxCUWidth = sps->getMaxCUWidth();
     2012  UInt uiMaxCUHeight = sps->getMaxCUHeight();
     2013 
    20342014  // get coded and reconstructed depth view
    20352015  TComPicYuv* depthPicYuv = NULL;
     
    20372017 
    20382018  // DBBP is a texture coding tool
    2039   if( getSlice()->getIsDepth() )
    2040   {
    2041     return NULL;
    2042   } 
     2019  assert( !getSlice()->getIsDepth() );
     2020 
    20432021#if H_3D_FCO
    20442022  TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
     
    20672045    depthPicYuv   = baseDepthPic->getPicYuvRec();
    20682046    depthPicYuv->extendPicBorder();
    2069     uiDepthStride = depthPicYuv->getStride();
     2047    uiDepthStride = depthPicYuv->getStride(COMPONENT_Y);
    20702048   
    2071     Int iBlkX = ( getAddr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
    2072     Int iBlkY = ( getAddr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
     2049    Int iBlkX = ( getCtuRsAddr() % baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ];
     2050    Int iBlkY = ( getCtuRsAddr() / baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ];
    20732051   
    2074     Int iPictureWidth  = depthPicYuv->getWidth();
    2075     Int iPictureHeight = depthPicYuv->getHeight();
     2052    Int iPictureWidth  = depthPicYuv->getWidth(COMPONENT_Y);
     2053    Int iPictureHeight = depthPicYuv->getHeight(COMPONENT_Y);
    20762054   
    20772055   
    20782056    Bool depthRefineFlag = false;
    2079 #if H_3D_NBDV_REF
    2080     depthRefineFlag = m_pcSlice->getDepthRefinementFlag(  );
    2081 #endif // H_3D_NBDV_REF
     2057#if NH_3D_NBDV_REF
     2058    depthRefineFlag = m_pcSlice->getDepthRefinementFlag();
     2059#endif // NH_3D_NBDV_REF
    20822060   
    20832061    TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV;
     
    20902068    Int depthPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((cDv.getVer()+2)>>2));
    20912069   
    2092     pDepthPels = depthPicYuv->getLumaAddr() + depthPosX + depthPosY * uiDepthStride;
     2070    pDepthPels = depthPicYuv->getAddr(COMPONENT_Y) + depthPosX + depthPosY * uiDepthStride;
    20932071  }
    20942072#endif
     
    21022080#endif
    21032081
    2104 #if H_3D_DBBP
     2082#if NH_3D_DBBP
    21052083Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    21062084{
     
    23922370}
    23932371
    2394 #if H_3D_SPIVMP
     2372#if NH_3D_SPIVMP
    23952373Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    23962374{
     
    23992377#endif
    24002378
    2401 #if H_3D_VSP
     2379#if NH_3D_VSP
    24022380Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    24032381{
    24042382  setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    24052383}
    2406 #if H_3D_VSP
    24072384template<typename T>
    24082385Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx )
    24092386{
    2410   UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2;
     2387  UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2;
    24112388  switch ( m_pePartSize[ uiCUAddr ] )
    24122389  {
     
    25402517}
    25412518#endif
    2542 #endif
    25432519
    25442520Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     
    26262602
    26272603// This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
    2628 #if H_3D_IC
     2604#if NH_3D_IC || NH_3D_VSP
    26292605Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU)
    26302606{
     
    29602936}
    29612937
    2962 #if H_3D_VSP
    2963 
     2938#if NH_3D_VSP
    29642939/** Add a VSP merging candidate
    29652940 * \Inputs
     
    30152990        predFlag[iRefListIdX] = 1;
    30162991        mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
    3017 #if H_3D_NBDV
     2992#if NH_3D_NBDV
    30182993        mvVSP[0+iRefListIdX].getMv().setIDVFlag (false);
    30192994#endif
     
    30232998
    30242999  dirVSP = (predFlag[0] | (predFlag[1] << 1));
    3025   m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false);
     3000  m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true
     3001#if NH_3D_SPIVMP
     3002    , false
     3003#endif
     3004    );
    30263005  if ( mrgCandIdx == iCount )
    30273006  {
     
    30333012  return false;
    30343013}
    3035 
    3036 #endif
    3037 
    3038 #if H_3D_IV_MERGE
     3014#endif
     3015
     3016#if NH_3D_IV_MERGE
    30393017inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx )
    30403018{
     
    30673045      if(!bRemove)
    30683046      {
    3069 #if H_3D_NBDV
     3047#if NH_3D_NBDV
    30703048        if(iLoop) // For IvMcShift candidate
    30713049        {
     
    30883066
    30893067#endif
    3090 #if H_3D
     3068#if NH_3D_MLC
     3069/** Construct a extended list of merging candidates
     3070 * \param pcMvFieldNeighbours
     3071 * \param puhInterDirNeighbours
     3072 * \param vspFlag
     3073 * \param pbSPIVMPFlag
     3074 * \param numValidMergeCand
     3075 */
    30913076Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3092 #if H_3D_VSP
     3077#if NH_3D_VSP
    30933078  , Int* vspFlag
    30943079#endif
    3095 #if H_3D_SPIVMP
     3080#if NH_3D_SPIVMP
    30963081  , Bool* pbSPIVMPFlag
    30973082#endif
     
    30993084  )
    31003085{
    3101   if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // for only dependent texture
     3086  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
    31023087  {
    31033088    return;
     
    31153100    extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID);
    31163101    extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
     3102#if NH_3D_VSP
    31173103    vspFlag[ui] = 0;
    3118   }
    3119 
    3120   // add candidates to temporal list
    3121   // insert MPI ... IvShift candidate
     3104#endif
     3105  }
     3106
     3107  // insert MPI ... IvShift candidate to extMergeCandList
    31223108  for (Int i=0; i<=MRG_IVSHIFT; i++)
    31233109  {
    31243110    if (m_mergCands[i].m_bAvailable)
    31253111    {
    3126       m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag);
     3112      m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt
     3113#if NH_3D_VSP
     3114        , vspFlag
     3115#endif
     3116#if NH_3D_SPIVMP
     3117        , pbSPIVMPFlag
     3118#endif
     3119        );
    31273120      iCount++;
    31283121      if (iCount >= getSlice()->getMaxNumMergeCand())
     
    31313124  }
    31323125
    3133   // insert remaining base candidates
    3134   while (iCount < getSlice()->getMaxNumMergeCand() && m_baseListidc < getSlice()->getMaxNumMergeCand())
    3135   {
    3136     uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[m_baseListidc];
    3137     extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[m_baseListidc<<1].getMv(), pcMvFieldNeighbours[m_baseListidc<<1].getRefIdx());
     3126  Int iCountBase = m_numSpatialCands;
     3127  // insert remaining base candidates to extMergeCandList
     3128  while (iCount < getSlice()->getMaxNumMergeCand() && iCountBase < getSlice()->getMaxNumMergeCand())
     3129  {
     3130    uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[iCountBase];
     3131    extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[iCountBase<<1].getMv(), pcMvFieldNeighbours[iCountBase<<1].getRefIdx());
    31383132    if ( getSlice()->isInterB() )
    31393133    {
    3140       extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx());
    3141     }
    3142     m_baseListidc++;
     3134      extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(iCountBase<<1)+1].getMv(), pcMvFieldNeighbours[(iCountBase<<1)+1].getRefIdx());
     3135    }
     3136    iCountBase++;
    31433137    iCount++;
    31443138  }
     
    31623156}
    31633157
    3164 /** Constructs a list of merging candidates
     3158
     3159
     3160/** Derive 3D merge candidates
    31653161 * \param uiAbsPartIdx
    31663162 * \param uiPUIdx
    3167  * \param uiDepth
    31683163 * \param pcMvFieldNeighbours
     3164 * \param puhInterDirNeighbours
     3165 * \param pcMvFieldSP
    31693166 * \param puhInterDirNeighbours
    31703167 * \param numValidMergeCand
    31713168 */
    3172 // HM 12.0 based merge candidate list construction
    3173 
    3174 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
    3175 {
    3176 
    3177   UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
    3178   Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
     3169Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
     3170#if NH_3D_SPIVMP
     3171      , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
     3172#endif
     3173      , Int& numValidMergeCand, Int mrgCandIdx
     3174)
     3175{
     3176#if NH_3D_IV_MERGE
    31793177  TComMv cZeroMv;
    3180   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    3181   {
    3182     abCandIsInter[ui] = false;
    3183     pcMvFieldNeighbours[ ( ui << 1 )     ].setMvField(cZeroMv, NOT_VALID);
    3184     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID);
     3178  TComMvField tmpMV[2]; 
     3179#endif
     3180
     3181  //////////////////////////////////
     3182  //////// GET DISPARITIES  ////////
     3183  //////////////////////////////////
     3184#if NH_3D_IV_MERGE
     3185  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
     3186  m_cDefaultDisInfo = cDisInfo;
     3187#elif NH_3D_VSP
     3188  // for xAddVspCand()
     3189  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
     3190#endif
     3191
     3192  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
     3193  {
     3194    return;
    31853195  }
    31863196  numValidMergeCand = getSlice()->getMaxNumMergeCand();
     3197  //////////////////////////////////
     3198  //////// DERIVE LOCATIONS ////////
     3199  //////////////////////////////////
    31873200  // compute the location of the current PU
    31883201  Int xP, yP, nPSW, nPSH;
     
    31903203
    31913204  Int iCount = 0;
    3192 
    31933205  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    3194   PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
    31953206  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    31963207  deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    3197 
    3198   //left
    3199   UInt uiLeftPartIdx = 0;
    3200   TComDataCU* pcCULeft = 0;
    3201   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    3202   Bool isAvailableA1 = pcCULeft &&
    3203     pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    3204     !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    3205     !pcCULeft->isIntra( uiLeftPartIdx ) ;
    3206   if ( isAvailableA1 )
    3207   {
    3208     m_bAvailableFlagA1 = 1;
    3209     abCandIsInter[iCount] = true;
    3210     // get Inter Dir
    3211     puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
    3212     // get Mv from Left
    3213     pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3214     if ( getSlice()->isInterB() )
    3215     {
    3216       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3217     }
    3218 
    3219     iCount ++;
    3220   }
    3221  
    3222   // early termination
    3223   if (iCount == getSlice()->getMaxNumMergeCand())
    3224   {
    3225     return;
    3226   }
    3227   // above
    3228   UInt uiAbovePartIdx = 0;
    3229   TComDataCU* pcCUAbove = 0;
    3230   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    3231   Bool isAvailableB1 = pcCUAbove &&
    3232   pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    3233   !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
    3234   !pcCUAbove->isIntra( uiAbovePartIdx );
    3235   if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    3236   {
    3237     m_bAvailableFlagB1 = 1;
    3238     abCandIsInter[iCount] = true;
    3239     // get Inter Dir
    3240     puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
    3241     // get Mv from Left
    3242     pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3243     if ( getSlice()->isInterB() )
    3244     {
    3245       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3246     }
    3247     if ( mrgCandIdx == iCount )
    3248     {
    3249       return;
    3250     }
    3251     iCount ++;
    3252   }
    3253   // early termination
    3254   if (iCount == getSlice()->getMaxNumMergeCand())
    3255   {
    3256     return;
    3257   }
    3258 
    3259   // above right
    3260   UInt uiAboveRightPartIdx = 0;
    3261   TComDataCU* pcCUAboveRight = 0;
    3262   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    3263   Bool isAvailableB0 = pcCUAboveRight &&
    3264   pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    3265   !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
    3266   if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    3267   {
    3268     m_bAvailableFlagB0 = 1;
    3269     abCandIsInter[iCount] = true;
    3270     // get Inter Dir
    3271     puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
    3272     // get Mv from Left
    3273     pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3274     if ( getSlice()->isInterB() )
    3275     {
    3276       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3277     }
    3278     if ( mrgCandIdx == iCount )
    3279     {
    3280       return;
    3281     }
    3282     iCount ++;
    3283   }
    3284   // early termination
    3285   if (iCount == getSlice()->getMaxNumMergeCand())
    3286   {
    3287     return;
    3288   }
    3289 
    3290   //left bottom
    3291   UInt uiLeftBottomPartIdx = 0;
    3292   TComDataCU* pcCULeftBottom = 0;
    3293   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    3294   Bool isAvailableA0 = pcCULeftBottom &&
    3295   pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    3296   !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
    3297   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    3298   {
    3299     m_bAvailableFlagA0 = 1;
    3300     abCandIsInter[iCount] = true;
    3301     // get Inter Dir
    3302     puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
    3303     // get Mv from Left
    3304     pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3305     if ( getSlice()->isInterB() )
    3306     {
    3307       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3308     }
    3309     if ( mrgCandIdx == iCount )
    3310     {
    3311       return;
    3312     }
    3313     iCount ++;
    3314   }
    3315   // early termination
    3316   if (iCount == getSlice()->getMaxNumMergeCand())
    3317   {
    3318     return;
    3319   }
    3320   // above left
    3321   if( iCount < 4 )
    3322   {
    3323     UInt uiAboveLeftPartIdx = 0;
    3324     TComDataCU* pcCUAboveLeft = 0;
    3325     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    3326     Bool isAvailableB2 = pcCUAboveLeft &&
    3327     pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    3328     !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
    3329     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    3330         && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    3331     {
    3332       m_bAvailableFlagB2 = 1;
    3333       abCandIsInter[iCount] = true;
    3334       // get Inter Dir
    3335       puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
    3336       // get Mv from Left
    3337       pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3338       if ( getSlice()->isInterB() )
    3339       {
    3340         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3341       }
    3342       if ( mrgCandIdx == iCount )
    3343       {
    3344         return;
    3345       }
    3346       iCount ++;
    3347     }
    3348   }
    3349   // early termination
    3350   if (iCount == getSlice()->getMaxNumMergeCand())
    3351   {
    3352     return;
    3353   }
    3354   if ( getSlice()->getEnableTMVPFlag())
    3355   {
    3356     //>> MTK colocated-RightBottom
    3357     UInt uiPartIdxRB;
    3358 
    3359     deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 
    3360 
    3361     UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    3362     UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
    3363 
    3364     TComMv cColMv;
    3365     Int iRefIdx;
    3366     Int uiLCUIdx = -1;
    3367 
    3368     if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
    3369     {
    3370     }
    3371     else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    3372     {
    3373     }
    3374     else
    3375     {
    3376       if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    3377         ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
    3378       {
    3379         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
    3380         uiLCUIdx = getAddr();
    3381       }
    3382       else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
    3383       {
    3384         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
    3385       }
    3386       else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
    3387       {
    3388         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    3389         uiLCUIdx = getAddr() + 1;
    3390       }
    3391       else //is the right bottom corner of LCU                       
    3392       {
    3393         uiAbsPartAddr = 0;
    3394       }
    3395     }
    3396 
    3397     iRefIdx = 0;
    3398     Bool bExistMV = false;
    3399     UInt uiPartIdxCenter;
    3400     UInt uiCurLCUIdx = getAddr();
    3401     Int dir = 0;
    3402     UInt uiArrayAddr = iCount;
    3403     xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
    3404     bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
    3405     if( bExistMV == false )
    3406     {
    3407       bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
    3408     }
    3409     if( bExistMV )
    3410     {
    3411       dir |= 1;
    3412       pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
    3413     }
    3414 
    3415     if ( getSlice()->isInterB() )
    3416     {
    3417 #if H_3D_TMVP
    3418       iRefIdx = 0;
    3419 #endif
    3420       bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
    3421       if( bExistMV == false )
    3422       {
    3423         bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
    3424       }
    3425       if( bExistMV )
    3426       {
    3427         dir |= 2;
    3428         pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
    3429       }
    3430     }
    3431 
    3432     if (dir != 0)
    3433     {
    3434       puhInterDirNeighbours[uiArrayAddr] = dir;
    3435       abCandIsInter[uiArrayAddr] = true;
    3436 #if H_3D_NBDV
    3437       pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
    3438       pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    3439 #endif
    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   UInt uiArrayAddr = iCount;
    3453   UInt uiCutoff = uiArrayAddr;
    3454  
    3455   if ( getSlice()->isInterB() && iCount<5)  // JCT3V-F0129 by Qualcomm
    3456   {
    3457     UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
    3458     UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
    3459 
    3460     for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
    3461     {
    3462       Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
    3463       if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
    3464       {
    3465         abCandIsInter[uiArrayAddr] = true;
    3466         puhInterDirNeighbours[uiArrayAddr] = 3;
    3467 
    3468         // get Mv from cand[i] and cand[j]
    3469         pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
    3470         pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
    3471 
    3472         Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
    3473         Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
    3474         if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
    3475         {
    3476           abCandIsInter[uiArrayAddr] = false;
    3477         }
    3478         else
    3479         {
    3480           uiArrayAddr++;
    3481         }
    3482       }
    3483     }
    3484   }
    3485   // early termination
    3486   if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
    3487   {
    3488     return;
    3489   }
    3490  
    3491   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);
    3492   Int r = 0;
    3493   Int refcnt = 0;
    3494   while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
    3495   {
    3496     abCandIsInter[uiArrayAddr] = true;
    3497     puhInterDirNeighbours[uiArrayAddr] = 1;
    3498     pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
    3499 
    3500     if ( getSlice()->isInterB() )
    3501     {
    3502       puhInterDirNeighbours[uiArrayAddr] = 3;
    3503       pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
    3504     }
    3505     uiArrayAddr++;
    3506     if ( refcnt == iNumRefIdx - 1 )
    3507     {
    3508       r = 0;
    3509     }
    3510     else
    3511     {
    3512       ++r;
    3513       ++refcnt;
    3514     }
    3515   }
    3516  
    3517   numValidMergeCand = uiArrayAddr;
    3518 }
    3519 
    3520 
    3521 
    3522 /** Constructs a list of merging candidates
    3523  * \param uiAbsPartIdx
    3524  * \param uiPUIdx
    3525  * \param uiDepth
    3526  * \param pcMvFieldNeighbours
    3527  * \param puhInterDirNeighbours
    3528  * \param numValidMergeCand
    3529  */
    3530 #if H_3D
    3531 Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3532 #else
    3533 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3534 #endif
    3535 #if H_3D_SPIVMP
    3536       , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    3537 #endif
    3538       , Int& numValidMergeCand, Int mrgCandIdx
    3539 )
    3540 {
    3541 #if H_3D_IV_MERGE
    3542   ////////////////////////////
    3543   //////// INIT LISTS ////////
    3544   ////////////////////////////
    3545   TComMv cZeroMv;
    3546 #else
    3547   Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
    3548 #endif
    3549 #if H_3D
    3550   TComMvField tmpMV[2];
    3551   UChar tmpDir;
    3552 
    3553 
    3554   //////////////////////////////////
    3555   //////// GET DISPARITIES  ////////
    3556   //////////////////////////////////
    3557   DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
    3558   m_cDefaultDisInfo = cDisInfo;
    3559 
    3560   if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // current slice is not both dependent view or depth
    3561   {
    3562     return;
    3563   }
    3564 #else
    3565   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    3566   {
    3567     abCandIsInter[ui] = false;
    3568     pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
    3569     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
    3570   }
    3571 #endif
    3572 
    3573   numValidMergeCand = getSlice()->getMaxNumMergeCand();
    3574 #if H_3D
    3575   //////////////////////////////////
    3576   //////// DERIVE LOCATIONS ////////
    3577   //////////////////////////////////
    3578 #endif
    3579   // compute the location of the current PU
    3580   Int xP, yP, nPSW, nPSH;
    3581   this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
    3582 
    3583   Int iCount = 0;
    3584 
    3585   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    3586 #if !H_3D
    3587   PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
    3588 #endif
    3589   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    3590   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    3591 #if H_3D
     3208#if NH_3D_TEXT_MERGE
    35923209  Bool bMPIFlag   = getSlice()->getMpiFlag();
     3210  Int  tmpDir;
     3211#endif
     3212#if NH_3D_IV_MERGE || NH_3D_TEXT_MERGE
    35933213  Bool bIsDepth = getSlice()->getIsDepth();
    3594 #endif 
    3595 
    3596 #if H_3D_IC
     3214#endif
     3215
     3216#if NH_3D_IC
    35973217  Bool bICFlag = getICFlag(uiAbsPartIdx);
    35983218#endif
    3599 #if H_3D_ARP
     3219#if NH_3D_ARP
    36003220  Bool bARPFlag = getARPW(uiAbsPartIdx) > 0;
    36013221#endif
    3602 #if H_3D_DBBP
     3222#if NH_3D_DBBP
    36033223  Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx);
    36043224  assert(bDBBPFlag == getDBBPFlag(0)); 
    36053225#endif
    36063226
    3607 #if H_3D
    3608 #if H_3D_NBDV
     3227#if NH_3D_NBDV
    36093228  for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) 
    36103229  {
    3611     pcMvFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
    3612     pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
    3613   }
    3614 #endif
    3615   // Clean version for MCL construction align with WD
    3616   // init mergCands list
     3230    pcMFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
     3231    pcMFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
     3232  }
     3233#endif
     3234  // init containers
    36173235  for (Int i = 0; i<MRG_IVSHIFT+1; i++)
    3618   {
    36193236    m_mergCands[i].init();
    3620   }
    3621 
    3622   m_baseListidc = 0;
    3623 
     3237
     3238  m_numSpatialCands = 0;
     3239
     3240  //////////////////////////////////
     3241  ///////// GET VSP FLAGS //////////
     3242  //////////////////////////////////
    36243243  //left
    36253244  UInt uiLeftPartIdx = 0;
     
    36293248  if (getAvailableFlagA1())
    36303249  {
    3631     m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3632 #if H_3D_VSP
     3250    m_mergCands[MRG_A1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3251#if NH_3D_VSP
    36333252    , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
    3634 #if H_3D_IC
     3253#if NH_3D_IC
    36353254      && !bICFlag
    36363255#endif
    3637 #if H_3D_ARP
     3256#if NH_3D_ARP
    36383257      && !bARPFlag
    36393258#endif
    3640 #if H_3D_DBBP
     3259#if NH_3D_DBBP
    36413260      && !bDBBPFlag
    36423261#endif
    36433262      )
    36443263#endif
     3264#if NH_3D_SPIVMP
    36453265      , false
     3266#endif
    36463267      );
    3647     m_baseListidc++;
     3268    m_numSpatialCands++;
    36483269  }
    36493270
    36503271  // above
    3651 
    36523272  if (getAvailableFlagB1())
    36533273  {
    3654     m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3655 #if H_3D_VSP
     3274    m_mergCands[MRG_B1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3275#if NH_3D_VSP
    36563276    , false
    36573277#endif
     3278#if NH_3D_SPIVMP
    36583279      , false
     3280#endif
    36593281      );
    3660     m_baseListidc++;
     3282    m_numSpatialCands++;
    36613283  }
    36623284
    36633285  // above right
    3664 
    36653286  if (getAvailableFlagB0())
    36663287  {
    3667     m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3668 #if H_3D_VSP
    3669     ,
    3670       false
    3671 #endif
     3288    m_mergCands[MRG_B0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3289#if NH_3D_VSP
     3290    , false
     3291#endif
     3292#if NH_3D_SPIVMP
    36723293      , false
     3294#endif
    36733295      );
    3674     m_baseListidc++;
     3296    m_numSpatialCands++;
    36753297  }
    36763298
    36773299  // left bottom
    3678 
    36793300  if (getAvailableFlagA0())
    36803301  {
    3681     m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3682 #if H_3D_VSP
     3302    m_mergCands[MRG_A0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3303#if NH_3D_VSP
    36833304    , false
    36843305#endif
     3306#if NH_3D_SPIVMP
    36853307      , false
     3308#endif
    36863309      );
    3687     m_baseListidc++;
     3310    m_numSpatialCands++;
    36883311  }
    36893312
    36903313  // above left
    3691 
    36923314  if (getAvailableFlagB2())
    36933315  {
    3694     m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    3695 #if H_3D_VSP
     3316    m_mergCands[MRG_B2].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
     3317#if NH_3D_VSP
    36963318    , false
    36973319#endif
     3320#if NH_3D_SPIVMP
    36983321      , false
     3322#endif
    36993323      );
    3700     m_baseListidc++;
    3701   }
    3702 
    3703 #endif
    3704 
    3705 
    3706 #if H_3D_IV_MERGE
     3324    m_numSpatialCands++;
     3325  }
     3326
     3327
     3328#if NH_3D_TEXT_MERGE
    37073329
    37083330  /////////////////////////////////////////////
     
    37303352
    37313353      this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight );
    3732       pcTexRec->getTopLeftSamplePos( this->getAddr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
     3354      pcTexRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
    37333355
    37343356      Int iPUWidth, iPUHeight, iNumPart, iNumPartLine;
     
    37553377
    37563378      Int         iTexPosX, iTexPosY;
     3379#if NH_3D_INTEGER_MV_DEPTH
    37573380      const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
    3758 
     3381#endif
    37593382      Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iPUWidth ) >> 1 )  * iPUWidth + ( iPUWidth >> 1 );
    37603383      Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iPUHeight ) >> 1 )  * iPUHeight + (iPUHeight >> 1);
     
    37703393
    37713394      pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx );
    3772       TComDataCU* pcDefaultCU    = pcTexPic->getCU( iTexCenterCUAddr );
     3395      TComDataCU* pcDefaultCU    = pcTexPic->getCtu( iTexCenterCUAddr );
    37733396
    37743397      if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA )
     
    37893412              {
    37903413                bSPIVMPFlag = true;
     3414#if NH_3D_INTEGER_MV_DEPTH
    37913415                TComMv cMv = cDefaultMvField.getMv() + cMvRounding;
    37923416                cMv >>= 2;
     3417#else
     3418                TComMv cMv = cDefaultMvField.getMv();
     3419#endif
    37933420                cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ;
    37943421                break;
     
    38153442            iTexPosY     = i + iOffsetY;
    38163443            pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx );
    3817             pcTexCU  = pcTexPic->getCU( iTexCUAddr );
     3444            pcTexCU  = pcTexPic->getCtu( iTexCUAddr );
    38183445
    38193446            if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) )
     
    38273454                if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
    38283455                {
     3456#if NH_3D_INTEGER_MV_DEPTH
    38293457                  TComMv cMv = cTexMvField.getMv() + cMvRounding;
    38303458                  cMv >>=2;         
     3459#else
     3460                  TComMv cMv = cTexMvField.getMv();
     3461#endif         
    38313462                  pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef);
    38323463                }
     
    38473478          }
    38483479        }
    3849 #if H_3D
    3850       }
    3851 #endif
     3480      }
    38523481#if H_3D_FCO
    38533482    }
     
    38773506    }
    38783507  }
     3508#endif
     3509
     3510#if NH_3D_IV_MERGE
    38793511  /////////////////////////////////////////////////////////////////
    38803512  //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
     
    38943526  if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1)
    38953527  {
     3528#if NH_3D_IC
    38963529    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag );
     3530#else
     3531    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, false );
     3532#endif
    38973533  } 
    38983534
     
    39503586        spiMvpFlag = true;
    39513587      }
    3952 #if H_3D_DBBP
     3588#if NH_3D_DBBP
    39533589      spiMvpFlag &= !bDBBPFlag;
    39543590#endif
     
    39713607#endif
    39723608
     3609  iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable;
     3610
     3611#if NH_3D_VSP
     3612  /////////////////////////////////////////////////
     3613  //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
     3614  /////////////////////////////////////////////////
     3615  if (iCount<getSlice()->getMaxNumMergeCand())
     3616  {
     3617    if (
     3618      (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) &&
     3619#if NH_3D_IC
     3620      !bICFlag &&
     3621#endif
     3622#if NH_3D_ARP
     3623      !bARPFlag &&
     3624#endif
    39733625#if H_3D
    3974   iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable;
     3626      (nPSW + nPSH > 12) &&
     3627#endif
     3628#if NH_3D_DBBP
     3629      !bDBBPFlag &&
     3630#endif
     3631      xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
     3632    {
     3633      return;
     3634    }
     3635
     3636    // early termination
     3637    if (iCount == getSlice()->getMaxNumMergeCand())
     3638    {
     3639      return;
     3640    }
     3641  }
     3642#endif
     3643
     3644  iCount += m_mergCands[MRG_B0].m_bAvailable;
     3645
     3646#if NH_3D_IV_MERGE
     3647  /////////////////////////////////////////////
     3648  //////// INTER VIEW DISP COMP (IvDC) ////////
     3649  /////////////////////////////////////////////
     3650  if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
     3651  {
     3652    assert(iCount < getSlice()->getMaxNumMergeCand());
     3653
     3654    tmpMV[0].setMvField( cZeroMv, NOT_VALID );
     3655    tmpMV[1].setMvField( cZeroMv, NOT_VALID );
     3656    if( ( ivCandDir[1] & 1 ) == 1 )
     3657    {
     3658      tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
     3659    }
     3660    if( ( ivCandDir[1] & 2 ) == 2 )
     3661    {
     3662      tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
     3663    }
     3664
     3665    Bool bRemoveSpa = false; //pruning to A1, B1
     3666    for(Int i = 0; i < 2; i ++)
     3667    {
     3668      if ( !m_mergCands[MRG_A1+i].m_bAvailable )
     3669      {
     3670        continue;
     3671      }
     3672      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])
     3673      {
     3674        bRemoveSpa                      = true;
     3675        break;
     3676      }     
     3677    }
     3678    if(!bRemoveSpa)
     3679    {
     3680#if NH_3D_NBDV
     3681      tmpMV[0].getMv().setIDVFlag (false);
     3682      tmpMV[1].getMv().setIDVFlag (false);
     3683#endif
     3684      m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
     3685
     3686      if ( mrgCandIdx == iCount )
     3687        return;
     3688      iCount ++;
     3689
     3690      // early termination
     3691      if (iCount == getSlice()->getMaxNumMergeCand())
     3692      {
     3693        return;
     3694      }
     3695    }
     3696  }
     3697#endif // H_3D_IV_MERGE
     3698
     3699  iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
     3700
     3701#if NH_3D_IV_MERGE
     3702  ////////////////////////////////////////////////////
     3703  //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
     3704  ////////////////////////////////////////////////////
     3705  if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
     3706  {
     3707    if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
     3708    {
     3709      return;
     3710    }
     3711    //early termination
     3712    if (iCount == getSlice()->getMaxNumMergeCand())
     3713    {
     3714      return;
     3715    }
     3716  }
     3717#endif
     3718}
     3719#endif
     3720
     3721//! Construct a list of merging candidates
     3722Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
     3723{
     3724  UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
     3725#if NH_3D_MLC
     3726  Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
    39753727#else
     3728  Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
     3729#endif
     3730  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
     3731  {
     3732    abCandIsInter[ui] = false;
     3733    pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
     3734    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
     3735  }
     3736  numValidMergeCand = getSlice()->getMaxNumMergeCand();
     3737  // compute the location of the current PU
     3738  Int xP, yP, nPSW, nPSH;
     3739  this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
     3740
     3741  Int iCount = 0;
     3742
     3743  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
     3744  PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
     3745  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
     3746  deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
     3747
    39763748  //left
    39773749  UInt uiLeftPartIdx = 0;
    39783750  TComDataCU* pcCULeft = 0;
    39793751  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
     3752
    39803753  Bool isAvailableA1 = pcCULeft &&
    3981     pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    3982     !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    3983     !pcCULeft->isIntra( uiLeftPartIdx ) ;
     3754                       pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
     3755                       !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
     3756                       pcCULeft->isInter( uiLeftPartIdx ) ;
     3757
    39843758  if ( isAvailableA1 )
    39853759  {
     3760#if NH_3D_MLC
     3761    m_bAvailableFlagA1 = 1;
     3762#endif
    39863763    abCandIsInter[iCount] = true;
    39873764    // get Inter Dir
     
    39933770      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    39943771    }
    3995 
    39963772    if ( mrgCandIdx == iCount )
    39973773    {
     
    40023778
    40033779  // early termination
    4004   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3780  if (iCount == getSlice()->getMaxNumMergeCand())
    40053781  {
    40063782    return;
    40073783  }
    4008 
    40093784  // above
    40103785  UInt uiAbovePartIdx = 0;
    40113786  TComDataCU* pcCUAbove = 0;
    40123787  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
     3788
    40133789  Bool isAvailableB1 = pcCUAbove &&
    4014     pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    4015     !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
    4016     !pcCUAbove->isIntra( uiAbovePartIdx );
     3790                       pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
     3791                       !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
     3792                       pcCUAbove->isInter( uiAbovePartIdx );
     3793
    40173794  if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    40183795  {
     3796#if NH_3D_MLC
     3797    m_bAvailableFlagB1 = 1;
     3798#endif
    40193799    abCandIsInter[iCount] = true;
    40203800    // get Inter Dir
     
    40263806      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    40273807    }
    4028 
    40293808    if ( mrgCandIdx == iCount )
    40303809    {
     
    40343813  }
    40353814  // early termination
    4036   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3815  if (iCount == getSlice()->getMaxNumMergeCand())
    40373816  {
    40383817    return;
     
    40433822  TComDataCU* pcCUAboveRight = 0;
    40443823  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
     3824
    40453825  Bool isAvailableB0 = pcCUAboveRight &&
    4046     pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    4047     !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
     3826                       pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
     3827                       pcCUAboveRight->isInter( uiAboveRightPartIdx );
     3828
    40483829  if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    40493830  {
     3831#if NH_3D_MLC
     3832    m_bAvailableFlagB0 = 1;
     3833#endif
    40503834    abCandIsInter[iCount] = true;
    40513835    // get Inter Dir
     
    40573841      pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    40583842    }
    4059 
    40603843    if ( mrgCandIdx == iCount )
    40613844    {
     
    40653848  }
    40663849  // early termination
    4067   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3850  if (iCount == getSlice()->getMaxNumMergeCand())
    40683851  {
    40693852    return;
    40703853  }
    4071 #endif
    4072 
    4073 
    4074 #if H_3D_VSP
    4075   /////////////////////////////////////////////////
    4076   //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
    4077   /////////////////////////////////////////////////
    4078   if (iCount<getSlice()->getMaxNumMergeCand())
    4079   {
    4080     if (
    4081       (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) &&
    4082 #if H_3D_IC
    4083       !bICFlag &&
    4084 #endif
    4085 #if H_3D_ARP
    4086       !bARPFlag &&
    4087 #endif
    4088 #if H_3D
    4089       (nPSW + nPSH > 12) &&
    4090 #endif
    4091 #if H_3D_DBBP
    4092       !bDBBPFlag &&
    4093 #endif
    4094       xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
    4095     {
    4096       return;
    4097     }
    4098 
    4099     // early termination
    4100     if (iCount == getSlice()->getMaxNumMergeCand())
    4101     {
    4102       return;
    4103     }
    4104 #endif
    4105 #if H_3D_VSP
    4106   }
    4107 #endif
    4108 
    4109 #if H_3D
    4110   iCount += m_mergCands[MRG_B0].m_bAvailable;
    4111 #endif
    4112 
    4113 
    4114 #if H_3D_IV_MERGE
    4115   /////////////////////////////////////////////
    4116   //////// INTER VIEW DISP COMP (IvDC) ////////
    4117   /////////////////////////////////////////////
    4118   if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
    4119   {
    4120     assert(iCount < getSlice()->getMaxNumMergeCand());
    4121 
    4122     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    4123     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    4124     if( ( ivCandDir[1] & 1 ) == 1 )
    4125     {
    4126       tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
    4127     }
    4128     if( ( ivCandDir[1] & 2 ) == 2 )
    4129     {
    4130       tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
    4131     }
    4132 
    4133     Bool bRemoveSpa = false; //pruning to A1, B1
    4134     for(Int i = 0; i < 2; i ++)
    4135     {
    4136       if ( !m_mergCands[MRG_A1+i].m_bAvailable )
    4137       {
    4138         continue;
    4139       }
    4140       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])
    4141       {
    4142         bRemoveSpa                      = true;
    4143         break;
    4144       }     
    4145     }
    4146     if(!bRemoveSpa)
    4147     {
    4148 #if H_3D_NBDV
    4149       tmpMV[0].getMv().setIDVFlag (false);
    4150       tmpMV[1].getMv().setIDVFlag (false);
    4151 #endif
    4152       m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
    4153 
    4154       if ( mrgCandIdx == iCount )
    4155         return;
    4156       iCount ++;
    4157 
    4158       // early termination
    4159       if (iCount == getSlice()->getMaxNumMergeCand())
    4160       {
    4161         return;
    4162       }
    4163     }
    4164   }
    4165 #endif // H_3D_IV_MERGE
    4166 
    4167 
    4168 #if H_3D
    4169   iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
    4170 #else
     3854
    41713855  //left bottom
    41723856  UInt uiLeftBottomPartIdx = 0;
    41733857  TComDataCU* pcCULeftBottom = 0;
    41743858  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
     3859
    41753860  Bool isAvailableA0 = pcCULeftBottom &&
    4176   pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    4177   !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
     3861                       pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
     3862                       pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ;
     3863
    41783864  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    41793865  {
     3866#if NH_3D_MLC
     3867    m_bAvailableFlagA0 = 1;
     3868#endif
    41803869    abCandIsInter[iCount] = true;
    41813870    // get Inter Dir
     
    41943883  }
    41953884  // early termination
    4196   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3885  if (iCount == getSlice()->getMaxNumMergeCand())
    41973886  {
    41983887    return;
    41993888  }
    42003889
    4201   // above left 
     3890  // above left
    42023891  if( iCount < 4 )
    42033892  {
     
    42053894    TComDataCU* pcCUAboveLeft = 0;
    42063895    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
     3896
    42073897    Bool isAvailableB2 = pcCUAboveLeft &&
    4208     pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    4209     !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
     3898                         pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
     3899                         pcCUAboveLeft->isInter( uiAboveLeftPartIdx );
     3900
    42103901    if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    42113902        && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    42123903    {
     3904#if NH_3D_MLC
     3905      m_bAvailableFlagB2 = 1;
     3906#endif
    42133907      abCandIsInter[iCount] = true;
    42143908      // get Inter Dir
     
    42283922  }
    42293923  // early termination
    4230   if (iCount == getSlice()->getMaxNumMergeCand()) 
     3924  if (iCount == getSlice()->getMaxNumMergeCand())
    42313925  {
    42323926    return;
    42333927  }
    4234 #endif
    4235 
    4236 
    4237 #if H_3D_IV_MERGE
    4238   ////////////////////////////////////////////////////
    4239   //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
    4240   ////////////////////////////////////////////////////
    4241   if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
    4242   {
    4243     if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
    4244     {
    4245       return;
    4246     }
    4247     //early termination
    4248     if (iCount == getSlice()->getMaxNumMergeCand())
    4249     {
    4250       return;
    4251     }
    4252   }
    4253 #endif
    4254 #if !H_3D
    4255   if ( getSlice()->getEnableTMVPFlag())
     3928
     3929  if ( getSlice()->getEnableTMVPFlag() )
    42563930  {
    42573931    //>> MTK colocated-RightBottom
    42583932    UInt uiPartIdxRB;
    42593933
    4260     deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 
     3934    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );
    42613935
    42623936    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    4263     UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
     3937    const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
     3938    const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
    42643939
    42653940    TComMv cColMv;
    42663941    Int iRefIdx;
    4267     Int uiLCUIdx = -1;
    4268 
    4269     if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
    4270     {
    4271     }
    4272     else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    4273     {
    4274     }
    4275     else
    4276     {
    4277       if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    4278         ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
    4279       {
    4280         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
    4281         uiLCUIdx = getAddr();
    4282       }
    4283       else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
    4284       {
    4285         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
    4286       }
    4287       else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     3942    Int ctuRsAddr = -1;
     3943
     3944    if (   ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
     3945        && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
     3946    {
     3947      if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&           // is not at the last column of CTU
     3948        ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) )              // is not at the last row    of CTU
     3949      {
     3950        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ];
     3951        ctuRsAddr = getCtuRsAddr();
     3952      }
     3953      else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 )           // is not at the last column of CTU But is last row of CTU
     3954      {
     3955        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
     3956      }
     3957      else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 )          // is not at the last row of CTU But is last column of CTU
    42883958      {
    42893959        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    4290         uiLCUIdx = getAddr() + 1;
    4291       }
    4292       else //is the right bottom corner of LCU                       
     3960        ctuRsAddr = getCtuRsAddr() + 1;
     3961      }
     3962      else //is the right bottom corner of CTU
    42933963      {
    42943964        uiAbsPartAddr = 0;
    42953965      }
    42963966    }
    4297    
    4298    
     3967
    42993968    iRefIdx = 0;
     3969
    43003970    Bool bExistMV = false;
    43013971    UInt uiPartIdxCenter;
    4302     UInt uiCurLCUIdx = getAddr();
    43033972    Int dir = 0;
    43043973    UInt uiArrayAddr = iCount;
    43053974    xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
    4306     bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
     3975    bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx );
    43073976    if( bExistMV == false )
    43083977    {
    4309       bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
     3978      bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx );
    43103979    }
    43113980    if( bExistMV )
     
    43173986    if ( getSlice()->isInterB() )
    43183987    {
    4319       bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
     3988#if NH_3D_TMVP
     3989      iRefIdx = 0;
     3990#endif
     3991      bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx);
    43203992      if( bExistMV == false )
    43213993      {
    4322         bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
     3994        bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx );
    43233995      }
    43243996      if( bExistMV )
     
    43284000      }
    43294001    }
    4330    
     4002
    43314003    if (dir != 0)
    43324004    {
    43334005      puhInterDirNeighbours[uiArrayAddr] = dir;
    43344006      abCandIsInter[uiArrayAddr] = true;
     4007#if NH_3D_NBDV
     4008      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
     4009      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
     4010#endif
     4011
    43354012      if ( mrgCandIdx == iCount )
    43364013      {
     
    43404017    }
    43414018  }
    4342   // early termination 
    4343   if (iCount == getSlice()->getMaxNumMergeCand()) 
     4019  // early termination
     4020  if (iCount == getSlice()->getMaxNumMergeCand())
    43444021  {
    43454022    return;
    43464023  }
     4024
    43474025  UInt uiArrayAddr = iCount;
    43484026  UInt uiCutoff = uiArrayAddr;
    4349    
    4350   if ( getSlice()->isInterB())
    4351   {
    4352     UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
    4353     UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
     4027
     4028#if NH_3D_MLC
     4029  if ( getSlice()->isInterB() && iCount<5)
     4030#else
     4031  if ( getSlice()->isInterB() )
     4032#endif
     4033  {
     4034    static const UInt NUM_PRIORITY_LIST=12;
     4035    static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
     4036    static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
    43544037
    43554038    for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
    43564039    {
    4357       Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
     4040      assert(idx<NUM_PRIORITY_LIST);
     4041      Int i = uiPriorityList0[idx];
     4042      Int j = uiPriorityList1[idx];
    43584043      if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
    43594044      {
     
    43794064  }
    43804065  // early termination
    4381   if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 
     4066  if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
    43824067  {
    43834068    return;
    43844069  }
     4070
    43854071  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);
     4072
    43864073  Int r = 0;
    43874074  Int refcnt = 0;
     
    43984085    }
    43994086    uiArrayAddr++;
     4087
    44004088    if ( refcnt == iNumRefIdx - 1 )
    44014089    {
     
    44084096    }
    44094097  }
    4410 
    44114098  numValidMergeCand = uiArrayAddr;
    4412 #endif
    4413 }
    4414 #else
    4415 
    4416 //! Construct a list of merging candidates
    4417 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
    4418 {
    4419   UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
    4420   Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
    4421   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    4422   {
    4423     abCandIsInter[ui] = false;
    4424     pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
    4425     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
    4426   }
    4427   numValidMergeCand = getSlice()->getMaxNumMergeCand();
    4428   // compute the location of the current PU
    4429   Int xP, yP, nPSW, nPSH;
    4430   this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
    4431 
    4432   Int iCount = 0;
    4433 
    4434   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    4435   PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
    4436   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    4437   deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    4438 
    4439   //left
    4440   UInt uiLeftPartIdx = 0;
    4441   TComDataCU* pcCULeft = 0;
    4442   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    4443 
    4444   Bool isAvailableA1 = pcCULeft &&
    4445                        pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    4446                        !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    4447                        pcCULeft->isInter( uiLeftPartIdx ) ;
    4448 
    4449   if ( isAvailableA1 )
    4450   {
    4451     abCandIsInter[iCount] = true;
    4452     // get Inter Dir
    4453     puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
    4454     // get Mv from Left
    4455     pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4456     if ( getSlice()->isInterB() )
    4457     {
    4458       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4459     }
    4460     if ( mrgCandIdx == iCount )
    4461     {
    4462       return;
    4463     }
    4464     iCount ++;
    4465   }
    4466 
    4467   // early termination
    4468   if (iCount == getSlice()->getMaxNumMergeCand())
    4469   {
    4470     return;
    4471   }
    4472   // above
    4473   UInt uiAbovePartIdx = 0;
    4474   TComDataCU* pcCUAbove = 0;
    4475   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    4476 
    4477   Bool isAvailableB1 = pcCUAbove &&
    4478                        pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    4479                        !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
    4480                        pcCUAbove->isInter( uiAbovePartIdx );
    4481 
    4482   if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    4483   {
    4484     abCandIsInter[iCount] = true;
    4485     // get Inter Dir
    4486     puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
    4487     // get Mv from Left
    4488     pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4489     if ( getSlice()->isInterB() )
    4490     {
    4491       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4492     }
    4493     if ( mrgCandIdx == iCount )
    4494     {
    4495       return;
    4496     }
    4497     iCount ++;
    4498   }
    4499   // early termination
    4500   if (iCount == getSlice()->getMaxNumMergeCand())
    4501   {
    4502     return;
    4503   }
    4504 
    4505   // above right
    4506   UInt uiAboveRightPartIdx = 0;
    4507   TComDataCU* pcCUAboveRight = 0;
    4508   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    4509 
    4510   Bool isAvailableB0 = pcCUAboveRight &&
    4511                        pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    4512                        pcCUAboveRight->isInter( uiAboveRightPartIdx );
    4513 
    4514   if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    4515   {
    4516     abCandIsInter[iCount] = true;
    4517     // get Inter Dir
    4518     puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
    4519     // get Mv from Left
    4520     pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4521     if ( getSlice()->isInterB() )
    4522     {
    4523       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4524     }
    4525     if ( mrgCandIdx == iCount )
    4526     {
    4527       return;
    4528     }
    4529     iCount ++;
    4530   }
    4531   // early termination
    4532   if (iCount == getSlice()->getMaxNumMergeCand())
    4533   {
    4534     return;
    4535   }
    4536 
    4537   //left bottom
    4538   UInt uiLeftBottomPartIdx = 0;
    4539   TComDataCU* pcCULeftBottom = 0;
    4540   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    4541 
    4542   Bool isAvailableA0 = pcCULeftBottom &&
    4543                        pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    4544                        pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ;
    4545 
    4546   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    4547   {
    4548     abCandIsInter[iCount] = true;
    4549     // get Inter Dir
    4550     puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
    4551     // get Mv from Left
    4552     pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4553     if ( getSlice()->isInterB() )
    4554     {
    4555       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4556     }
    4557     if ( mrgCandIdx == iCount )
    4558     {
    4559       return;
    4560     }
    4561     iCount ++;
    4562   }
    4563   // early termination
    4564   if (iCount == getSlice()->getMaxNumMergeCand())
    4565   {
    4566     return;
    4567   }
    4568 
    4569   // above left
    4570   if( iCount < 4 )
    4571   {
    4572     UInt uiAboveLeftPartIdx = 0;
    4573     TComDataCU* pcCUAboveLeft = 0;
    4574     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    4575 
    4576     Bool isAvailableB2 = pcCUAboveLeft &&
    4577                          pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    4578                          pcCUAboveLeft->isInter( uiAboveLeftPartIdx );
    4579 
    4580     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    4581         && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    4582     {
    4583       abCandIsInter[iCount] = true;
    4584       // get Inter Dir
    4585       puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
    4586       // get Mv from Left
    4587       pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4588       if ( getSlice()->isInterB() )
    4589       {
    4590         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4591       }
    4592       if ( mrgCandIdx == iCount )
    4593       {
    4594         return;
    4595       }
    4596       iCount ++;
    4597     }
    4598   }
    4599   // early termination
    4600   if (iCount == getSlice()->getMaxNumMergeCand())
    4601   {
    4602     return;
    4603   }
    4604 
    4605   if ( getSlice()->getEnableTMVPFlag() )
    4606   {
    4607     //>> MTK colocated-RightBottom
    4608     UInt uiPartIdxRB;
    4609 
    4610     deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );
    4611 
    4612     UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    4613     const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
    4614     const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
    4615 
    4616     TComMv cColMv;
    4617     Int iRefIdx;
    4618     Int ctuRsAddr = -1;
    4619 
    4620     if (   ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
    4621         && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    4622     {
    4623       if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&           // is not at the last column of CTU
    4624         ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) )              // is not at the last row    of CTU
    4625       {
    4626         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ];
    4627         ctuRsAddr = getCtuRsAddr();
    4628       }
    4629       else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 )           // is not at the last column of CTU But is last row of CTU
    4630       {
    4631         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
    4632       }
    4633       else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 )          // is not at the last row of CTU But is last column of CTU
    4634       {
    4635         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    4636         ctuRsAddr = getCtuRsAddr() + 1;
    4637       }
    4638       else //is the right bottom corner of CTU
    4639       {
    4640         uiAbsPartAddr = 0;
    4641       }
    4642     }
    4643 
    4644     iRefIdx = 0;
    4645 
    4646     Bool bExistMV = false;
    4647     UInt uiPartIdxCenter;
    4648     Int dir = 0;
    4649     UInt uiArrayAddr = iCount;
    4650     xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
    4651     bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx );
    4652     if( bExistMV == false )
    4653     {
    4654       bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter,  cColMv, iRefIdx );
    4655     }
    4656     if( bExistMV )
    4657     {
    4658       dir |= 1;
    4659       pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
    4660     }
    4661 
    4662     if ( getSlice()->isInterB() )
    4663     {
    4664       bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx);
    4665       if( bExistMV == false )
    4666       {
    4667         bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx );
    4668       }
    4669       if( bExistMV )
    4670       {
    4671         dir |= 2;
    4672         pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
    4673       }
    4674     }
    4675 
    4676     if (dir != 0)
    4677     {
    4678       puhInterDirNeighbours[uiArrayAddr] = dir;
    4679       abCandIsInter[uiArrayAddr] = true;
    4680 
    4681       if ( mrgCandIdx == iCount )
    4682       {
    4683         return;
    4684       }
    4685       iCount++;
    4686     }
    4687   }
    4688   // early termination
    4689   if (iCount == getSlice()->getMaxNumMergeCand())
    4690   {
    4691     return;
    4692   }
    4693 
    4694   UInt uiArrayAddr = iCount;
    4695   UInt uiCutoff = uiArrayAddr;
    4696 
    4697   if ( getSlice()->isInterB() )
    4698   {
    4699     static const UInt NUM_PRIORITY_LIST=12;
    4700     static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
    4701     static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
    4702 
    4703     for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
    4704     {
    4705       assert(idx<NUM_PRIORITY_LIST);
    4706       Int i = uiPriorityList0[idx];
    4707       Int j = uiPriorityList1[idx];
    4708       if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
    4709       {
    4710         abCandIsInter[uiArrayAddr] = true;
    4711         puhInterDirNeighbours[uiArrayAddr] = 3;
    4712 
    4713         // get Mv from cand[i] and cand[j]
    4714         pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
    4715         pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
    4716 
    4717         Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
    4718         Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
    4719         if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
    4720         {
    4721           abCandIsInter[uiArrayAddr] = false;
    4722         }
    4723         else
    4724         {
    4725           uiArrayAddr++;
    4726         }
    4727       }
    4728     }
    4729   }
    4730   // early termination
    4731   if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
    4732   {
    4733     return;
    4734   }
    4735 
    4736   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);
    4737 
    4738   Int r = 0;
    4739   Int refcnt = 0;
    4740   while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
    4741   {
    4742     abCandIsInter[uiArrayAddr] = true;
    4743     puhInterDirNeighbours[uiArrayAddr] = 1;
    4744     pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
    4745 
    4746     if ( getSlice()->isInterB() )
    4747     {
    4748       puhInterDirNeighbours[uiArrayAddr] = 3;
    4749       pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
    4750     }
    4751     uiArrayAddr++;
    4752 
    4753     if ( refcnt == iNumRefIdx - 1 )
    4754     {
    4755       r = 0;
    4756     }
    4757     else
    4758     {
    4759       ++r;
    4760       ++refcnt;
    4761     }
    4762   }
    4763   numValidMergeCand = uiArrayAddr;
    4764 }
    4765 #endif
     4099}
    47664100
    47674101/** Check whether the current PU and a spatial neighboring PU are in a same ME region.
     
    49784312    }
    49794313    if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx_Col
    4980 #if H_3D_TMVP
     4314#if NH_3D_TMVP
    49814315         , 0
    49824316#endif
     
    49904324      xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter );
    49914325      if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, iRefIdx_Col
    4992 #if H_3D_TMVP
     4326#if NH_3D_TMVP
    49934327         , 0
    49944328#endif
     
    50214355  UInt partAddr;
    50224356
    5023 #if H_3D_DBBP
     4357#if NH_3D_DBBP
    50244358  if( getDBBPFlag(0) )
    50254359  {
     
    50414375  const TComSPS &sps=*(m_pcSlice->getSPS());
    50424376  Int  iMvShift = 2;
    5043 #if H_3D_IC
     4377#if NH_3D_INTEGER_MV_DEPTH
    50444378  if( getSlice()->getIsDepth() )
    50454379    iMvShift = 0;
     
    51144448  return ( getSkipFlag( uiPartIdx ) );
    51154449}
    5116 
    5117 #if H_3D_IC
    5118 Bool TComDataCU::isIC( UInt uiPartIdx )
    5119 {
    5120     if ( m_pcSlice->isIntra () )
    5121     {
    5122         return false;
    5123     }
    5124     return ( ( getSkipFlag(uiPartIdx) || getPredictionMode(uiPartIdx) == MODE_INTER) && getICFlag( uiPartIdx ) && isICFlagRequired( uiPartIdx ) );
    5125 }
    5126 #endif
    51274450
    51284451// ====================================================================================================================
     
    53424665
    53434666Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
    5344 #if H_3D_TMVP
     4667#if NH_3D_TMVP
    53454668  , Bool bMRG
    53464669#endif
     
    53944717  if ( bIsCurrRefLongTerm != bIsColRefLongTerm )
    53954718  {
    5396 #if H_3D_TMVP
     4719#if NH_3D_TMVP
    53974720    Int iAlterRefIdx  = m_pcSlice->getAlterRefIdx(eRefPicList);
    53984721    if(bMRG && iAlterRefIdx > 0)
     
    54074730#endif
    54084731    return false;
    5409 #if H_3D_TMVP
     4732#if NH_3D_TMVP
    54104733    }
    54114734#endif
     
    54144737  if ( bIsCurrRefLongTerm || bIsColRefLongTerm )
    54154738  {
    5416 #if H_3D_TMVP
     4739#if NH_3D_TMVP
    54174740    Int iCurrViewId    = m_pcSlice->getViewId ();
    54184741    Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewId ();
    5419     Int iColViewId     = pColCU->getSlice()->getViewId();
    5420     Int iColRefViewId  = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewId();
     4742    Int iColViewId     = pColCtu->getSlice()->getViewId();
     4743    Int iColRefViewId  = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewId();
    54214744    iScale = 4096;
    54224745    if ( iCurrRefViewId != iCurrViewId && iColViewId != iColRefViewId )
     
    54324755#endif
    54334756    rcMv = cColMv;
    5434 #if H_3D_TMVP
     4757#if NH_3D_TMVP
    54354758    }
    54364759#endif
     
    55754898#endif
    55764899
    5577 #if H_3D_IV_MERGE
     4900#if NH_3D_IV_MERGE
    55784901Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
    55794902{
     
    55854908    Int iViewIdx = getSlice()->getDefaultRefViewIdx();
    55864909    pDisp->m_aVIdxCan = iViewIdx;
    5587     Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepthY() - 1 )) ];
     4910    Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 )) ];
    55884911
    55894912    cMv.setHor(iDisp);
     
    56544977}
    56554978#endif
    5656 #if H_3D_NBDV
     4979#if NH_3D_NBDV
    56574980//Notes from QC:
    5658 //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
     4981//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
    56594982//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
    56604983//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
    56614984Void TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo
    5662 #if H_3D_NBDV_REF
     4985#if NH_3D_NBDV_REF
    56634986, Bool bDepthRefine
    56644987#endif
     
    56835006    }
    56845007  }
    5685 #if H_3D_NBDV_REF
     5008#if NH_3D_NBDV_REF
    56865009  if( !m_pcSlice->getDepthRefinementFlag( ) )
    56875010  {
     
    57065029    ///*** Derive center position ***
    57075030    UInt uiPartIdxCenter;
    5708     Int  uiLCUIdx   = getAddr();
     5031    Int  uiLCUIdx = getCtuRsAddr();
    57095032    xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter );
    57105033
     
    57335056        pDInfo->m_aVIdxCan  = iTargetViewIdx;
    57345057
    5735 #if H_3D_NBDV_REF
     5058#if NH_3D_NBDV_REF
    57365059        TComPic* picDepth = NULL;   
    57375060#if H_3D_FCO_VSP_DONBDV_E0163
     
    57555078        }
    57565079        pDInfo->m_acDoNBDV  = cColMv;
    5757 #endif //H_3D_NBDV_REF
     5080#endif //NH_3D_NBDV_REF
    57585081        return;
    57595082      }
     
    57695092  bCheckMcpDv = true;
    57705093  if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
    5771 #if H_3D_NBDV_REF
     5094#if NH_3D_NBDV_REF
    57725095    , bDepthRefine
    57735096#endif
     
    57795102  if(pcTmpCU != NULL )
    57805103  {
    5781     bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
     5104    bCheckMcpDv = ( ( getCtuRsAddr() - pcTmpCU->getCtuRsAddr() ) == 0);
    57825105    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE
    5783 #if H_3D_NBDV_REF
     5106#if NH_3D_NBDV_REF
    57845107      , bDepthRefine
    57855108#endif
     
    58005123          pDInfo->m_acNBDV = cDispVec;
    58015124          pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ];
    5802 #if H_3D_NBDV_REF
     5125#if NH_3D_NBDV_REF
    58035126#if H_3D_FCO_VSP_DONBDV_E0163
    58045127          TComPic* picDepth  = NULL;
     
    58385161    pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx();
    58395162
    5840 #if H_3D_NBDV_REF
     5163#if NH_3D_NBDV_REF
    58415164    TComPic* picDepth = NULL;
    58425165#if H_3D_FCO_VSP_DONBDV_E0163
     
    58645187}
    58655188
    5866 #if H_3D_NBDV_REF
     5189#if NH_3D_NBDV_REF
    58675190Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT )
    58685191{
    5869   Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth();
    5870   Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight();
    5871  
     5192  Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth(COMPONENT_Y);
     5193  Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(COMPONENT_Y);
     5194
    58725195  Int depthStartPosX = Clip3(0,   iPictureWidth - 1,  iBlkX + ((mv->getHor()+2)>>2));
    58735196  Int depthStartPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2));
     
    58755198  Int depthEndPosY   = Clip3(0,   iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2));
    58765199
    5877   Pel* depthTL  = pcBaseViewDepthPicYuv->getLumaAddr();
    5878   Int depStride =  pcBaseViewDepthPicYuv->getStride();
     5200  Pel* depthTL  = pcBaseViewDepthPicYuv->getAddr(COMPONENT_Y);
     5201  Int depStride =  pcBaseViewDepthPicYuv->getStride(COMPONENT_Y);
    58795202
    58805203  Pel  maxDepthVal = 0;
     
    58915214  if (picDepth)
    58925215  {
    5893     UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr;
     5216    UInt uiAbsPartAddrCurrCU = m_absZIdxInCtu + uiPartAddr;
    58945217    Int iWidth, iHeight;
    58955218    getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more
    58965219
    58975220    TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec();
    5898     Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
    5899     Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
     5221    const TComSPS   &sps =*(getSlice()->getSPS());
     5222    Int iBlkX = ( getCtuRsAddr() % picDepth->getFrameWidthInCtus() ) * sps.getMaxCUWidth()  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
     5223    Int iBlkY = ( getCtuRsAddr() / picDepth->getFrameWidthInCtus() ) * sps.getMaxCUHeight() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
    59005224
    59015225    Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx );
     
    59055229  }
    59065230}
    5907 #endif //H_3D_NBDV_REF
     5231#endif //NH_3D_NBDV_REF
    59085232
    59095233
    59105234Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
    5911 #if H_3D_NBDV_REF
     5235#if NH_3D_NBDV_REF
    59125236, Bool bDepthRefine
    59135237#endif
     
    59305254          pNbDvInfo->m_acNBDV = cMvPred;
    59315255          pNbDvInfo->m_aVIdxCan = refViewIdx;
    5932 #if H_3D_NBDV_REF
     5256#if NH_3D_NBDV_REF
    59335257          TComPic* picDepth = NULL;
    59345258          assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());         
     
    59765300{
    59775301  UInt uiPartIdx = 0;
    5978   UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 
    5979   Int uiLCUIdx = getAddr();
     5302  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInCtuWidth(); 
     5303  Int uiLCUIdx = getCtuRsAddr();
    59805304
    59815305  UInt uiPartIdxRB;
     
    59835307  UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    59845308
    5985   if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
     5309  if (( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
    59865310  {
    59875311    riLCUIdxRBNb  = -1;
    59885312    riPartIdxRBNb = -1;
    59895313  }
    5990   else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
     5314  else if(( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    59915315  {
    59925316    riLCUIdxRBNb  = -1;
     
    59965320  {
    59975321    if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    5998       ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
     5322      ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) ) // is not at the last row    of LCU
    59995323    {
    60005324      riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
     
    60065330      riLCUIdxRBNb  = -1;
    60075331    }
    6008     else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     5332    else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
    60095333    {
    60105334      riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
     
    60225346Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth )
    60235347{
    6024   UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);
     5348#if NH_3D_VSP // bug fix
     5349  UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
     5350  assert(m_pcPic->getNumPartitionsInCtu() ==m_pcPic->getNumPartInCtuWidth()*m_pcPic->getNumPartInCtuHeight());
     5351
     5352#else
     5353  UInt uiCurrPartNumb = m_pcPic->getNumPartInCtuWidth() >> (uiDepth << 1);
     5354#endif
    60255355  for (UInt ui = 0; ui < uiCurrPartNumb; ui++ )
    60265356  {
     
    60285358  }
    60295359}
    6030 #if H_3D_VSP
     5360#if NH_3D_VSP  || NH_3D_DBBP
    60315361Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth )
    60325362{
     
    60415371  Int iColViewIdx, iColRefViewIdx;
    60425372  TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
    6043   TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
     5373  TComDataCU *pColCU = pColPic->getCtu( uiCUAddr );
    60445374  iColViewIdx = pColCU->getSlice()->getViewIndex();
    6045   if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx))
     5375  if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES||pColCU->isIntra(uiPartUnitIdx))
    60465376  {
    60475377    return false;
     
    61055435
    61065436  Bool depthRefineFlag = false;
    6107 #if H_3D_NBDV_REF
     5437#if NH_3D_NBDV_REF
    61085438  depthRefineFlag = m_pcSlice->getDepthRefinementFlag( );
    6109 #endif // H_3D_NBDV_REF
     5439#endif // NH_3D_NBDV_REF
    61105440
    61115441  TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
     
    61615491#endif
    61625492
    6163 #if H_3D_SPIVMP
     5493#if NH_3D_SPIVMP
    61645494Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight)
    61655495{
     
    61785508Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr )
    61795509{
    6180   uiBaseAbsPartIdx += m_uiAbsIdxInLCU;
     5510  uiBaseAbsPartIdx += m_absZIdxInCtu;
    61815511  Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]];
    61825512  Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]];
    61835513  Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth;
    61845514  Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight;
    6185   Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + iCurrPelX/getPic()->getMinCUWidth();
     5515  Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + iCurrPelX/getPic()->getMinCUWidth();
    61865516  ruiPartAddr = g_auiRasterToZscan[iCurrRaster];
    6187   ruiPartAddr -= m_uiAbsIdxInLCU
     5517  ruiPartAddr -= m_absZIdxInCtu
    61885518}
    61895519
    61905520Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight )
    61915521{
    6192   uiAbsPartIdx += getZorderIdxInCU();
     5522  uiAbsPartIdx += getZorderIdxInCtu();
    61935523  Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
    61945524  Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
     
    62025532    for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth())
    62035533    {
    6204       iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + j/getPic()->getMinCUWidth();
     5534      iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + j/getPic()->getMinCUWidth();
    62055535      uiPartAddr = g_auiRasterToZscan[iCurrRaster];
    6206       uiPartAddr -= getZorderIdxInCU(); 
     5536      uiPartAddr -= getZorderIdxInCtu(); 
    62075537
    62085538      m_puhInterDir[uiPartAddr] = uiDir;
     
    62125542#endif
    62135543
    6214 #if H_3D_IV_MERGE
     5544#if NH_3D_IV_MERGE
    62155545Bool
    62165546TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth           
    6217 #if H_3D_SPIVMP
     5547#if NH_3D_SPIVMP
    62185548, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    62195549#endif
     
    62345564
    62355565  Int  iCurrPosX, iCurrPosY;
    6236   pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
    6237 
    6238 #if !H_3D_SPIVMP
     5566  pcBaseRec->getTopLeftSamplePos( getCtuRsAddr(), getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
     5567
     5568#if !NH_3D_SPIVMP
    62395569  iCurrPosX  += ( iWidth  >> 1 );
    62405570  iCurrPosY  += ( iHeight >> 1 );
     
    62425572
    62435573  Bool depthRefineFlag = false;
    6244 #if H_3D_NBDV_REF
     5574#if NH_3D_NBDV_REF
    62455575  depthRefineFlag = m_pcSlice->getDepthRefinementFlag( );
    6246 #endif // H_3D_NBDV_REF
     5576#endif // NH_3D_NBDV_REF
    62475577
    62485578  TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
     
    62535583
    62545584  Bool abPdmAvailable[8] =  {false, false, false, false, false, false, false, false};
    6255 #if H_3D_NBDV
     5585#if NH_3D_NBDV
    62565586  for( Int i = 0; i < 8; i++)
    62575587  {
     
    62635593  {
    62645594
    6265 #if H_3D_SPIVMP
     5595#if NH_3D_SPIVMP
    62665596    ////////////////////////////////
    62675597    //////////sub-PU IvMC///////////
     
    62695599    if(!m_pcSlice->getIsDepth())
    62705600    {
     5601#if H_3D_DBBP
    62715602      if (!getDBBPFlag(0))
     5603#else
     5604      if (1)
     5605#endif
    62725606      {
    62735607        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
     
    63015635        }
    63025636
    6303         Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    6304         Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) );
     5637        Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
     5638        Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) );
    63055639
    63065640        pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx );
    6307         TComDataCU* pcDefaultCU    = pcBasePic->getCU( iRefCenterCUAddr );
     5641        TComDataCU* pcDefaultCU    = pcBasePic->getCtu( iRefCenterCUAddr );
    63085642        if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA ))
    63095643        {
     
    63295663                      abPdmAvailable[ uiCurrRefListId ] = true;
    63305664                      TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
    6331 #if H_3D_NBDV
    6332 #if H_3D_IV_MERGE
     5665#if NH_3D_NBDV
     5666#if NH_3D_IV_MERGE
    63335667                      if( !bIsDepth )
    63345668                      {
     
    63385672                        cMv.setIDVVer    (cDv.getVer()); 
    63395673                        cMv.setIDVVId    (iViewIndex);
    6340 #if H_3D_IV_MERGE
     5674#if NH_3D_IV_MERGE
    63415675                      }
    63425676#endif
     
    63635697            for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth)
    63645698            {
    6365               iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
    6366               iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 ));
     5699              iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
     5700              iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 ));
    63675701
    63685702              pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
    6369               pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
     5703              pcBaseCU    = pcBasePic->getCtu( iBaseCUAddr );
    63705704              if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    63715705              {
     
    64355769    ////////////////////////////////
    64365770
    6437 #if H_3D_SPIVMP
     5771#if NH_3D_SPIVMP
    64385772    if(m_pcSlice->getIsDepth())
    64395773    {
     
    64415775      iCurrPosY  += ( iHeight >> 1 );
    64425776    }
     5777#if H_3D_DBBP
    64435778    for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    64445779#else
     5780    for(Int iLoopCan = ( m_pcSlice->getIsDepth() ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
     5781#endif
     5782#else
    64455783    for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    64465784#endif
     
    64525790      Int         iBaseAbsPartIdx;
    64535791
    6454       Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth  * 2 );
    6455       Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2 );
    6456 
    6457       Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
    6458       Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) );
     5792      Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth  * 2);
     5793      Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2);
     5794
     5795      Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
     5796      Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) );
    64595797      pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
    64605798
    6461       TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
     5799      TComDataCU* pcBaseCU    = pcBasePic->getCtu( iBaseCUAddr );
    64625800      if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    64635801      {
     
    64865824                    abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true;
    64875825                    TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
    6488 #if H_3D_NBDV
    6489 #if H_3D_IV_MERGE
     5826#if NH_3D_NBDV
     5827#if NH_3D_IV_MERGE
    64905828                    if( !bIsDepth )
    64915829                    {
     
    64955833                      cMv.setIDVVer    (cDv.getVer()); 
    64965834                      cMv.setIDVVId    (iViewIndex);
    6497 #if H_3D_IV_MERGE
     5835#if NH_3D_IV_MERGE
    64985836                    }
    64995837#endif
     
    65115849      }
    65125850    }
    6513 #if H_3D_SPIVMP
     5851#if NH_3D_SPIVMP
     5852#if H_3D_DBBP
    65145853    for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
     5854#else
     5855    for(Int iLoopCan = ( m_pcSlice->getIsDepth()  ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
     5856#endif
    65155857#else
    65165858    for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
     
    65415883            abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true;
    65425884            paiPdmRefIdx  [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx;
    6543 #if H_3D_NBDV_REF
     5885#if NH_3D_NBDV_REF
    65445886            TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    65455887#endif
    65465888            cMv.setHor( cMv.getHor() + ioffsetDV );
    6547 #if H_3D_IV_MERGE
     5889#if NH_3D_IV_MERGE
    65485890            if( bIsDepth )
    65495891            {
     
    65665908}
    65675909#endif
    6568 #if H_3D_ARP
     5910#if NH_3D_ARP
    65695911Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth )
    65705912{
    6571   assert( sizeof( *m_puhARPW) == 1 );
    6572   memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) );
    6573 }
    6574 #endif
    6575 
    6576 #if H_3D_IC
     5913  setSubPart<UChar>( w, m_puhARPW, uiAbsPartIdx, uiDepth, 0 );
     5914}
     5915#endif
     5916
     5917#if NH_3D_IC
    65775918Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    65785919{
    6579   memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) );
     5920  memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ))*sizeof(Bool) );
    65805921}
    65815922
     
    66365977#endif
    66375978
    6638 #if H_3D_VSP
     5979#if NH_3D_VSP
    66395980Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize )
    66405981{
     
    66926033  TComCUMvField *cuMvField = cu->getCUMvField( refPicList );
    66936034  Int partAddrRasterSubPULine  = g_auiZscanToRaster[ partAddr ];
    6694   Int numPartsLine    = cu->getPic()->getNumPartInWidth();
     6035  Int numPartsLine    = cu->getPic()->getNumPartInCtuWidth();
    66956036
    66966037  Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth();
    66976038  Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight();
    66986039
    6699   Int refDepStride = picRefDepth->getStride();
     6040  Int refDepStride = picRefDepth->getStride( COMPONENT_Y );
    67006041
    67016042  TComMv tmpMv(0, 0);
     
    67036044
    67046045  Int refDepOffset  = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride;
    6705   Pel *refDepth     = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refDepOffset;
     6046  Pel *refDepth     = picRefDepth->getAddr( COMPONENT_Y, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refDepOffset;
    67066047
    67076048  if ((height % 8))
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComDataCU.h

    r1258 r1279  
    5050#include "TComPattern.h"
    5151
    52 #if H_3D_ARP
    53 #include "TComYuv.h"
    54 #endif
    5552#if H_3D
    5653#include <algorithm>
     
    6562static const UInt NUM_MOST_PROBABLE_MODES=3;
    6663
    67 #if H_3D_DBBP
     64#if NH_3D_DBBP
    6865typedef struct _DBBPTmpData
    6966{
     
    167164  Char*         m_apiMVPNum[NUM_REF_PIC_LIST_01];       ///< array of number of possible motion vectors predictors
    168165  Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
    169 #if H_3D_NBDV
     166#if NH_3D_NBDV
    170167  DisInfo*      m_pDvInfo;
    171168#endif
    172 #if H_3D_VSP
     169#if NH_3D_VSP
    173170  Char*         m_piVSPFlag;          ///< array of VSP flags to indicate whehter a block uses VSP or not  ///< 0: non-VSP; 1: VSP
    174171#endif
    175 #if H_3D_SPIVMP
     172#if NH_3D_SPIVMP
    176173  Bool*         m_pbSPIVMPFlag;       ///< array of sub-PU IVMP flags to indicate whehter a block uses sub-PU IVMP ///< 0: non-SPIVMP; 1: SPIVMP
    177174#endif
    178 #if H_3D_ARP
     175#if NH_3D_ARP
    179176  UChar*        m_puhARPW;
    180177#endif
    181 #if H_3D_IC
     178#if NH_3D_IC
    182179  Bool*         m_pbICFlag;           ///< array of IC flags
    183180#endif
     
    190187  Pel*          m_apSegmentDCOffset[2];
    191188#endif
    192 #if H_3D_DBBP
     189#if NH_3D_DBBP
    193190  Bool*         m_pbDBBPFlag;        ///< array of DBBP flags
    194191  DbbpTmpData   m_sDBBPTmpData;
    195192#endif
    196 #if H_3D
     193#if NH_3D_MLC
    197194  Bool          m_bAvailableFlagA1;    ///< A1 available flag
    198195  Bool          m_bAvailableFlagB1;    ///< B1 available flag
     
    217214  UInt          m_uiTotalBins;        ///< sum of partition bins
    218215  Char          m_codedQP;
    219 #if H_3D
    220   DisInfo       m_cDefaultDisInfo;    ///< Default disparity information for initializing
    221 #endif
    222 #if H_3D_IV_MERGE
    223   TComMotionCand  m_mergCands[MRG_IVSHIFT+1];
    224   Int           m_baseListidc;
     216#if NH_3D_MLC
     217  DisInfo         m_cDefaultDisInfo;    ///< Default disparity information for initializing
     218  TComMotionCand  m_mergCands[MRG_IVSHIFT+1];   ///< Motion candidates for merge mode
     219  Int             m_numSpatialCands;
    225220#endif
    226221
     
    232227  Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
    233228  Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
    234 #if H_3D_VSP
     229#if NH_3D_VSP
    235230  Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount);
    236231#endif
    237 #if H_3D_IV_MERGE
     232#if NH_3D_IV_MERGE
    238233  Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int*   ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx );
    239234#endif
     
    241236  Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );
    242237  Bool          xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
    243 #if H_3D_TMVP
     238#if NH_3D_TMVP
    244239  ,  Bool bMRG = true
    245240#endif
     
    248243
    249244  /// compute scaling factor from POC difference
    250 #if !H_3D_ARP
     245#if !NH_3D_ARP
    251246  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
    252247#endif
     
    254249  Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
    255250
    256 #if H_3D_VSP
     251#if NH_3D_VSP
    257252  Void xSetMvFieldForVSP  ( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize );
    258253#endif
     
    265260  // create / destroy / initialize / copy
    266261  // -------------------------------------------------------------------------------------------------------------------
    267 #if H_3D_ARP
     262#if NH_3D_ARP
     263  /// compute scaling factor from POC difference
    268264  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
    269265#endif
     
    279275  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
    280276  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
    281 #if H_3D_NBDV
    282   Void          copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx);
     277#if NH_3D_NBDV
     278  Void          copyDVInfoFrom        (TComDataCU* pcCU, UInt uiAbsPartIdx);
    283279#endif
    284280
    285281  Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx );
    286282  Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
    287 #if H_3D_NBDV
     283#if NH_3D_NBDV
    288284  , Bool bNBDV = false
    289285#endif
     
    316312#endif
    317313
     314#if NH_3D_ARP
     315  Void          setSlice              ( TComSlice* pcSlice)     { m_pcSlice = pcSlice;       }
     316  Void          setPic                ( TComDataCU* pcCU  )     { m_pcPic              = pcCU->getPic(); }
     317#endif
    318318  // -------------------------------------------------------------------------------------------------------------------
    319319  // member functions for CU data
     
    326326  Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
    327327
    328 #if H_3D_DBBP
     328#if NH_3D_DBBP
    329329  Pel*          getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride);
    330330#endif
     
    350350  Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
    351351
    352 #if H_3D_DBBP
     352#if NH_3D_DBBP
    353353  Bool*         getDBBPFlag           ()                        { return m_pbDBBPFlag;               }
    354354  Bool          getDBBPFlag           ( UInt uiIdx )            { return m_pbDBBPFlag[uiIdx];        }
     
    451451  template <typename T>
    452452  Void          setSubPart            ( T bParameter, T* pbBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
    453 #if H_3D_VSP
     453#if H_3D_VSP || NH_3D_DBBP
    454454  template<typename T>
    455455  Void          setSubPartT           ( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
     
    477477  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
    478478  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
    479 #if H_3D_NBDV
     479#if NH_3D_NBDV
    480480  Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth );
     481#if H_3D_VSP || NH_3D_DBBP
    481482  Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth);
     483#endif
    482484  DisInfo*      getDvInfo             ()                        { return m_pDvInfo;                 }
    483485  DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
    484486#endif
    485 #if H_3D_NBDV
     487#if NH_3D_NBDV
    486488  Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
    487489  Bool          xCheckSpatialNBDV (TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
    488490                                   UInt uiMvpDvPos
    489 #if H_3D_NBDV_REF
     491#if NH_3D_NBDV_REF
    490492  , Bool bDepthRefine = false
    491493#endif
     
    493495  Bool          xGetColDisMV      ( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
    494496  Void          getDisMvpCandNBDV ( DisInfo* pDInfo
    495 #if H_3D_NBDV_REF
     497#if NH_3D_NBDV_REF
    496498   , Bool bDepthRefine = false
    497499#endif
    498500   );
    499501   
     502#if NH_3D_IV_MERGE
     503  Void          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
     504#endif
     505
    500506#if H_3D
    501507  Void          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
    502508  Bool          getDispMvPredCan(UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDis, Int* iPdm );
    503509#endif
    504 #if H_3D_NBDV_REF
     510#if NH_3D_NBDV_REF
    505511  Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT );
    506512  Void          estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred );
    507 #endif //H_3D_NBDV_REF
     513#endif //NH_3D_NBDV_REF
    508514#endif
    509515#if NH_3D_DIS
     
    513519  Void          getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge,  Int& iIVFMaxD);
    514520#endif
    515 #if H_3D_SPIVMP
     521#if NH_3D_SPIVMP
    516522  Void          getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight);
    517523  Void          getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr );
    518524  Void          setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight );
    519525#endif
    520 #if H_3D_IV_MERGE
     526#if NH_3D_IV_MERGE
    521527  Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc, Bool bIsDepth           
    522528
    523 #if H_3D_SPIVMP
     529#if NH_3D_SPIVMP
    524530    , TComMvField* pcMFieldSP, UChar* puhInterDirSP
    525531#endif   
     
    527533    );   
    528534#endif
    529 #if H_3D_ARP
     535#if NH_3D_ARP
    530536  UChar*        getARPW            ()                        { return m_puhARPW;               }
    531537  UChar         getARPW            ( UInt uiIdx )            { return m_puhARPW[uiIdx];        }
    532538  Void          setARPW            ( UInt uiIdx, UChar w )   { m_puhARPW[uiIdx] = w;           }
    533539  Void          setARPWSubParts    ( UChar w, UInt uiAbsPartIdx, UInt uiDepth );
    534   Double        getARPWFactor      ( UInt uiIdx );
    535 #endif
    536 #if H_3D_IC
     540#endif
     541#if NH_3D_IC
    537542  Bool*         getICFlag          ()                        { return m_pbICFlag;               }
    538543  Bool          getICFlag          ( UInt uiIdx )            { return m_pbICFlag[uiIdx];        }
     
    540545  Void          setICFlagSubParts  ( Bool bICFlag,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    541546  Bool          isICFlagRequired   ( UInt uiAbsPartIdx );
     547  Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
     548#elif NH_3D_VSP
    542549  Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
    543550#else
     
    647654  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
    648655
    649 #if H_3D
    650   Bool          getAvailableFlagA1() { return m_bAvailableFlagA1;}
    651   Bool          getAvailableFlagB1() { return m_bAvailableFlagB1;}
    652   Bool          getAvailableFlagB0() { return m_bAvailableFlagB0;}
    653   Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;}
    654   Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;}
     656#if NH_3D_MLC
     657  Bool          getAvailableFlagA1() { return m_bAvailableFlagA1;   }
     658  Bool          getAvailableFlagB1() { return m_bAvailableFlagB1;   }
     659  Bool          getAvailableFlagB0() { return m_bAvailableFlagB0;   }
     660  Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;   }
     661  Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;   }
    655662  Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
    656663  Void          buildMCL(TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
    657 #if H_3D_VSP
     664#if NH_3D_VSP
    658665    , Int* vspFlag
    659666#endif
    660 #if H_3D_SPIVMP
     667#if NH_3D_SPIVMP
    661668    , Bool* pbSPIVMPFlag
    662669#endif
    663670    , Int& numValidMergeCand
    664671    );
    665   Void          getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1);
    666   Void          xGetInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
    667 #else
     672  Void          xGetInterMergeCandidates      ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
     673#if NH_3D_SPIVMP
     674  , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
     675#endif
     676  , Int& numValidMergeCand, Int mrgCandIdx = -1 );
     677#endif
    668678  Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
    669 #endif
    670 #if H_3D_SPIVMP
    671                                             , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    672 #endif
    673 
    674 #if H_3D_VSP
    675 #if H_3D_SPIVMP
     679
     680#if NH_3D_VSP
     681#if NH_3D_SPIVMP
    676682  Bool*         getSPIVMPFlag        ()                        { return m_pbSPIVMPFlag;          }
    677683  Bool          getSPIVMPFlag        ( UInt uiIdx )            { return m_pbSPIVMPFlag[uiIdx];   }
     
    698704  Bool          isBipredRestriction( UInt puIdx );
    699705
    700 #if H_3D_IC
    701   Bool          isIC      ( UInt uiPartIdx );
    702 #endif
    703 
    704706  // -------------------------------------------------------------------------------------------------------------------
    705707  // member functions for symbol prediction (most probable / mode conversion)
     
    720722  UInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );
    721723  UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
    722 #if H_3D_ARP
     724#if NH_3D_ARP
    723725  UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
    724726#endif 
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComInterpolationFilter.cpp

    r1200 r1279  
    7575};
    7676
    77 #if H_3D_ARP
     77#if NH_3D_ARP
    7878const Short TComInterpolationFilter::m_lumaFilterARP[4][NTAPS_LUMA_ARP] =
    7979{
     
    361361 */
    362362Void TComInterpolationFilter::filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast, const ChromaFormat fmt, const Int bitDepth
    363 #if H_3D_ARP
     363#if NH_3D_ARP
    364364    , Bool filterType
    365365#endif
     
    372372  else if (isLuma(compID))
    373373  {
    374 #if H_3D_ARP
     374    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     375#if NH_3D_ARP
    375376    if(filterType)
    376377    {
    377       filterHor<NTAPS_LUMA_ARP>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
     378      filterHor<NTAPS_LUMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
    378379    }
    379380    else
    380381    {
    381382#endif
    382 
    383     assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    384383    filterHor<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
    385 #if H_3D_ARP
     384#if NH_3D_ARP
    386385    }
    387386#endif
     
    392391    const UInt csx = getComponentScaleX(compID, fmt);
    393392    assert(frac >=0 && csx<2 && (frac<<(1-csx)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     393#if NH_3D_ARP
     394    if(filterType)
     395    {
     396      filterHor<NTAPS_CHROMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);
     397    }
     398    else
     399    {
     400#endif
    394401    filterHor<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac<<(1-csx)]);
     402#if NH_3D_ARP
     403    }
     404#endif
    395405  }
    396406}
     
    414424 */
    415425Void TComInterpolationFilter::filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth
    416 #if H_3D_ARP
     426#if NH_3D_ARP
    417427    , Bool filterType
    418428#endif
     
    425435  else if (isLuma(compID))
    426436  {
    427 #if H_3D_ARP
     437    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     438#if NH_3D_ARP
    428439    if(filterType)
    429440    {
    430       filterVer<NTAPS_LUMA_ARP>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);   
     441      filterVer<NTAPS_LUMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);   
    431442    }
    432443    else
    433444    {
    434445#endif
    435     assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    436446    filterVer<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
    437 #if H_3D_ARP
     447#if NH_3D_ARP
    438448    }
    439449#endif
     
    444454    const UInt csy = getComponentScaleY(compID, fmt);
    445455    assert(frac >=0 && csy<2 && (frac<<(1-csy)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     456#if NH_3D_ARP
     457    if(filterType)
     458    {
     459      filterVer<NTAPS_CHROMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);   
     460    }
     461    else
     462    {
     463#endif
    446464    filterVer<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac<<(1-csy)]);
    447   }
    448 }
    449 
    450 #if H_3D_ARP
    451     , Bool filterType
    452 #endif
    453 
    454 #if H_3D_ARP
    455     if(filterType)
    456     {
    457       filterHor<NTAPS_CHROMA_ARP>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);
    458     }
    459     else
    460     {
    461 #endif
    462 #if H_3D_ARP
    463     }
    464 #endif
    465 #if H_3D_ARP
    466     , Bool filterType
    467 #endif
    468 #if H_3D_ARP
    469     if(filterType)
    470     {
    471       filterVer<NTAPS_CHROMA_ARP>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);
    472     }
    473     else
    474     {
    475 #endif
    476 #if H_3D_ARP
    477     }
    478 #endif
    479 
    480 
    481 
     465#if NH_3D_ARP
     466    }
     467#endif
     468    }
     469    }
    482470//! \}
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComInterpolationFilter.h

    r1200 r1279  
    4545//! \{
    4646
    47 #if H_3D_ARP
     47#if NH_3D_ARP
    4848#define NTAPS_LUMA_ARP    2 ///< Number of taps for luma
    4949#define NTAPS_CHROMA_ARP  2 ///< Number of taps for chroma
     
    6363  static const TFilterCoeff m_lumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA];     ///< Luma filter taps
    6464  static const TFilterCoeff m_chromaFilter[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA]; ///< Chroma filter taps
    65 #if H_3D_ARP
     65#if NH_3D_ARP
    6666  static const Short m_lumaFilterARP  [4][NTAPS_LUMA_ARP];     ///< Luma filter taps for ARP
    6767  static const Short m_chromaFilterARP[8][NTAPS_CHROMA_ARP];   ///< Chroma filter taps for ARP
     
    8383
    8484  Void filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast, const ChromaFormat fmt, const Int bitDepth
    85 #if H_3D_ARP
     85#if NH_3D_ARP
    8686    , Bool filterType = false
    8787#endif
    8888);
    8989  Void filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth
    90 #if H_3D_ARP
     90#if NH_3D_ARP
    9191    , Bool filterType = false
    9292#endif
     
    9494};
    9595
    96 #if H_3D_ARP
    97     , Bool filterType = false
    98 #endif
    99 #if H_3D_ARP
    100     , Bool filterType = false
    101 #endif
    102 
    10396//! \}
    10497
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComMotionInfo.cpp

    r1200 r1279  
    4040#include "assert.h"
    4141#include <stdlib.h>
    42 #if H_3D_SPIVMP
     42#if NH_3D_SPIVMP
    4343#include "TComDataCU.h"
    4444#include "TComPic.h"
     
    328328}
    329329
    330 #if H_3D_SPIVMP
     330#if NH_3D_SPIVMP
    331331Void TComCUMvField::setMvFieldSP( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  )
    332332{
    333   uiAbsPartIdx += pcCU->getZorderIdxInCU();
     333  uiAbsPartIdx += pcCU->getZorderIdxInCtu();
    334334  Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
    335335  Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
     
    341341    for (Int j=iStartPelX; j < iEndPelX; j += pcCU->getPic()->getMinCUWidth())
    342342    {
    343       Int iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInWidth() + j/pcCU->getPic()->getMinCUWidth();
     343      Int iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInCtuWidth() + j/pcCU->getPic()->getMinCUWidth();
    344344      Int uiPartAddr = g_auiRasterToZscan[iCurrRaster];
    345       uiPartAddr -= pcCU->getZorderIdxInCU(); 
     345      uiPartAddr -= pcCU->getZorderIdxInCtu(); 
    346346
    347347      m_pcMv[uiPartAddr] = cMvField.getMv();
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComMotionInfo.h

    r1196 r1279  
    5050// ====================================================================================================================
    5151
    52 #if H_3D_SPIVMP
     52#if NH_3D_SPIVMP
    5353class TComDataCU;
    5454#endif
     
    6060} AMVPInfo;
    6161
    62 #if H_3D_NBDV
     62#if NH_3D_NBDV
    6363typedef struct _DisCand
    6464{
    6565  TComMv m_acNBDV;              // DV from NBDV
    66 #if H_3D_NBDV_REF
     66#if NH_3D_NBDV_REF
    6767  TComMv m_acDoNBDV;            // DV from DoNBDV
    6868#endif 
     
    107107  Int getHor   () const { return  m_acMv.getHor(); }
    108108  Int getVer   () const { return  m_acMv.getVer(); }
    109 #if H_3D_IV_MERGE
     109#if NH_3D_IV_MERGE
    110110  Bool operator== ( const TComMvField& rcMv ) const
    111111  {
     
    167167  Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    168168  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    169 #if H_3D_SPIVMP
     169#if NH_3D_SPIVMP
    170170  Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
    171171#endif
    172 #if H_3D_VSP
     172#if NH_3D_VSP
    173173  Void    setMv         ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; }
    174174  Void    setRefIdx     ( Int iIdx, Int iRefIdx )         { m_piRefIdx[iIdx] = iRefIdx; }
     
    192192//! \}
    193193
    194 #if H_3D_IV_MERGE
     194#if NH_3D_MLC
     195/// class for container of merge candidate
    195196class TComMotionCand
    196197{
     
    199200  TComMvField           m_cMvField[2];
    200201  UChar                 m_uDir;
    201 #if H_3D_VSP
     202#if NH_3D_VSP
    202203  Int                   m_iVspFlag;
    203 #endif 
     204#endif
     205#if NH_3D_SPIVMP
    204206  Bool                  m_bSPIVMPFlag;
     207#endif
    205208
    206209public:
     
    209212    m_bAvailable = false;
    210213    m_uDir = 0;
    211 #if H_3D_VSP
     214#if NH_3D_VSP
    212215    m_iVspFlag = 0;
    213216#endif
     217#if NH_3D_SPIVMP
    214218    m_bSPIVMPFlag = false;
     219#endif
    215220  }
    216221
     
    226231    m_bAvailable = false;
    227232    m_uDir = 0;
    228 #if H_3D_VSP
     233#if NH_3D_VSP
    229234    m_iVspFlag = 0;
    230235#endif
     236#if NH_3D_SPIVMP
    231237    m_bSPIVMPFlag = false;
     238#endif
    232239    m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
    233240    m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
     
    235242
    236243  Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
    237 #if H_3D_VSP
     244#if NH_3D_VSP
    238245    , Int vspFlag
    239246#endif
     247#if NH_3D_SPIVMP
    240248    , Bool bSPIVMPFlag
     249#endif
    241250    )
    242251  {
     
    245254    m_cMvField[1] = pcMvFieldNeighbours[1];
    246255    m_uDir = uhInterDirNeighbours;
    247 #if H_3D_VSP
     256#if NH_3D_VSP
    248257    m_iVspFlag = vspFlag;
    249258#endif
     259#if NH_3D_SPIVMP
    250260    m_bSPIVMPFlag = bSPIVMPFlag;
    251   }
    252 
    253 
     261#endif
     262  }
     263 
    254264  Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    255 #if H_3D_VSP
     265#if NH_3D_VSP
    256266    , Int* vspFlag
    257267#endif
     268#if NH_3D_SPIVMP
    258269    , Bool* pbSPIVMPFlag
     270#endif
    259271    )
    260272  {
     
    262274    pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
    263275    puhInterDirNeighbours[iCount] = m_uDir;
    264 #if H_3D_VSP
     276#if NH_3D_VSP
    265277    vspFlag[iCount] = m_iVspFlag;
    266278#endif
     279#if NH_3D_SPIVMP
    267280    pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
     281#endif
    268282  }
    269283};
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComMv.h

    r1200 r1279  
    5757  Short m_iHor;     ///< horizontal component of motion vector
    5858  Short m_iVer;     ///< vertical component of motion vector
    59 #if H_3D_NBDV
     59#if NH_3D_NBDV
    6060  Bool  m_bIDV;       
    6161  Short m_iIDVHor;   
     
    7272  m_iHor(0),
    7373  m_iVer(0)
    74 #if H_3D_NBDV
     74#if NH_3D_NBDV
    7575  , m_bIDV(false)
    7676  , m_iIDVHor(0)
     
    8484  m_iHor(iHor),
    8585  m_iVer(iVer)
    86  #if H_3D_NBDV
     86 #if NH_3D_NBDV
    8787  , m_bIDV(false)
    8888  , m_iIDVHor(0)
     
    101101  Void  setVer    ( Short i )                   { m_iVer = i;                               }
    102102  Void  setZero   ()                            { m_iHor = m_iVer = 0;
    103  #if H_3D_NBDV
     103 #if NH_3D_NBDV
    104104   m_bIDV = false; m_iIDVHor = m_iIDVVer = 0;
    105105   m_iIDVVId = 0;
    106106#endif
    107107 }
    108 #if H_3D_NBDV
     108#if NH_3D_NBDV
    109109  Void   setIDVHor  (Short i)                    {m_iIDVHor = i;}
    110110  Void   setIDVVer  (Short i)                    {m_iIDVVer = i;}
     
    120120  Int   getAbsHor () const { return abs( m_iHor );   }
    121121  Int   getAbsVer () const { return abs( m_iVer );   }
    122 #if H_3D_NBDV
     122#if NH_3D_NBDV
    123123  Short getIDVHor () const { return m_iIDVHor;       }
    124124  Short getIDVVer () const { return m_iIDVVer;       }
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComPattern.h

    r1200 r1279  
    8181//  TComPatternParam  m_cPatternCb;
    8282  //TComPatternParam  m_cPatternCr;
    83 #if H_3D_IC
     83#if NH_3D_IC
    8484  Bool              m_bICFlag;
    8585#endif
     
    9898  Int   getBitDepthY()            { return m_cPatternY.m_bitDepth; }
    9999
    100 #if H_3D_IC
     100#if NH_3D_IC
    101101  Bool  getICFlag()               { return m_bICFlag; }
    102102  Void  setICFlag( Bool bICFlag ) { m_bICFlag = bICFlag; }
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComPic.cpp

    r1200 r1279  
    7575    m_apcPicYuv[i]      = NULL;
    7676  }
    77 #if H_3D_QTLPC
     77#if NH_3D_QTLPC
    7878  m_bReduceBitsQTL    = 0;
    7979#endif
    80 #if H_3D_NBDV
     80#if NH_3D_NBDV
    8181  m_iNumDdvCandPics   = 0;
    8282  m_eRapRefList       = REF_PIC_LIST_0;
     
    143143}
    144144#if NH_3D
     145#if NH_3D_ARP
     146Void TComPic::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx )
     147{
     148  Int iMaxCUWidth   = (Int) ( getPicSym()->getSPS().getMaxCUWidth()  );
     149  Int iMaxCuHeight  = (Int) ( getPicSym()->getSPS().getMaxCUHeight() );
     150
     151  UInt uiMaxTotalCUDepth = getPicSym()->getSPS().getMaxTotalCUDepth();
     152  Int iBaseUnitWidth  = iMaxCUWidth >> uiMaxTotalCUDepth;
     153  Int iBaseUnitHeight = iMaxCUWidth >> uiMaxTotalCUDepth;
     154
     155  Int iNumCuInWidth   = getPicYuvRec()->getWidth(COMPONENT_Y) / iMaxCUWidth;
     156  iNumCuInWidth      += ( getPicYuvRec()->getWidth(COMPONENT_Y) % iMaxCUWidth ) ? 1 : 0;
     157
     158
     159  Int iCuX            = iX / iMaxCUWidth;
     160  Int iCuY            = iY / iMaxCuHeight;
     161  Int iBaseX          = ( iX - iCuX * iMaxCUWidth  ) / iBaseUnitWidth;
     162  Int iBaseY          = ( iY - iCuY * iMaxCuHeight ) / iBaseUnitHeight;
     163  Int iCuSizeInBases  = iMaxCuHeight                 / iBaseUnitWidth;
     164
     165  riCuAddr            = iCuY   * iNumCuInWidth + iCuX;
     166  Int iRastPartIdx    = iBaseY * iCuSizeInBases  + iBaseX;
     167  riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
     168}
     169#endif
    145170Void TComPic::compressMotion(Int scale)
    146171#else
     
    283308  return getPicYuv( layerIdInNuh, poc, recon );
    284309}
    285 #if H_3D_ARP
     310#if NH_3D_ARP
    286311TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
    287312{
     
    303328#endif // NH_MV
    304329
    305 #if H_3D_NBDV
    306 Int TComPic::getDisCandRefPictures( Int iColPOC )
     330#if NH_3D_NBDV
     331Int TComPic::getDisCandRefPictures(Int iColPOC)
    307332{
    308333  UInt       uiTempLayerCurr = 7;
     
    310335  UInt       numDdvCandPics  = 0;
    311336
    312   if ( !currSlice->getEnableTMVPFlag() )
     337  if(!currSlice->getEnableTMVPFlag())
     338  {
    313339    return numDdvCandPics;
     340  }
    314341
    315342  numDdvCandPics += 1;
     
    318345  UInt pocDiff = 255;
    319346
    320   for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
    321   {
    322     UInt x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
    323 
    324     for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
     347  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr++)
     348  {
     349    Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
     350
     351    for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
    325352    {
    326353      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex()
    327         && (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) && numDdvCandPics!=2)
     354         && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC) && numDdvCandPics != 2)
    328355      {
    329356        TComSlice* refSlice    = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx());
    330         Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP())? 1: 0;
     357        Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP()) ? 1 : 0;
    331358        UInt       uiTempLayer = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer();
    332359       
    333         if( bRAP )
     360        if(bRAP)
    334361        {
    335362          this->setRapRefIdx(i);
     
    350377  UInt idx = 0;
    351378 
    352   for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
    353   {
    354     UInt x = lpNr? currSlice->getColFromL0Flag() : 1-currSlice->getColFromL0Flag();
     379  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2 : 1); lpNr++)
     380  {
     381    Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
    355382   
    356     for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
     383    for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
    357384    {
    358385      Int iTempPoc = currSlice->getRefPic((RefPicList)x, i)->getPOC();
    359       Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr): (pocCurr - iTempPoc);
     386      Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr) : (pocCurr - iTempPoc);
    360387     
    361       if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() &&  (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC)
    362         && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
     388      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC)
     389         && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
    363390      {
    364391        pocDiff = iTempDiff;
     
    369396  }
    370397
    371   if( pocDiff < 255 )
     398  if(pocDiff < 255)
    372399  {
    373400    this->setRapRefIdx(idx);
    374     this->setRapRefList((RefPicList) z );
     401    this->setRapRefList((RefPicList) z);
    375402    numDdvCandPics = 2;
    376403  }
     
    383410  TComSlice* currSlice = getSlice(getCurrSliceIdx());
    384411  const Int numCandPics = this->getNumDdvCandPics();
     412
    385413  for(Int curCandPic = 0; curCandPic < numCandPics; curCandPic++)
    386414  {
    387415    RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
    388416    Int        curCandPicRefIdx = 0;
    389     if( curCandPic == 0 )
     417    if(curCandPic == 0)
    390418    {
    391       eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1-currSlice->getColFromL0Flag() : 0);
     419      eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1 - currSlice->getColFromL0Flag() : 0);
    392420      curCandPicRefIdx = currSlice->getColRefIdx();
    393421    }
     
    397425      curCandPicRefIdx = this->getRapRefIdx();
    398426    }
    399     TComPic* pcCandColPic = currSlice->getRefPic( eCurRefPicList, curCandPicRefIdx);
    400     TComSlice* pcCandColSlice = pcCandColPic->getSlice(0);// currently only support single slice
     427
     428    TComPic* pcCandColPic = currSlice->getRefPic(eCurRefPicList, curCandPicRefIdx);
     429    TComSlice* pcCandColSlice = pcCandColPic->getSlice(0); // currently only support single slice
    401430
    402431    if(!pcCandColSlice->isIntra())
    403432    {
    404       for( Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2: 1); iColRefDir ++ )
    405       {
    406         for( Int iColRefIdx =0; iColRefIdx < pcCandColSlice->getNumRefIdx(( RefPicList )iColRefDir ); iColRefIdx++)
     433      for(Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2 : 1); iColRefDir++)
     434      {
     435        for(Int iColRefIdx = 0; iColRefIdx < pcCandColSlice->getNumRefIdx((RefPicList)iColRefDir); iColRefIdx++)
    407436        {
    408437          m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
    409438          Int iColViewIdx    = pcCandColSlice->getViewIndex();
    410           Int iColRefViewIdx = pcCandColSlice->getRefPic( ( RefPicList )iColRefDir, iColRefIdx)->getViewIndex();
     439          Int iColRefViewIdx = pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx)->getViewIndex();
    411440          if(iColViewIdx == iColRefViewIdx)
     441          {
    412442            continue;
    413 
    414           for(Int iCurrRefDir = 0;(iCurrRefDir < (currSlice->isInterB() ? 2: 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false ); iCurrRefDir++)
     443          }
     444
     445          for(Int iCurrRefDir = 0; (iCurrRefDir < (currSlice->isInterB() ? 2 : 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false); iCurrRefDir++)
    415446          {
    416             for( Int iCurrRefIdx =0; iCurrRefIdx < currSlice->getNumRefIdx(( RefPicList )iCurrRefDir ); iCurrRefIdx++)
     447            for(Int iCurrRefIdx = 0; iCurrRefIdx < currSlice->getNumRefIdx((RefPicList)iCurrRefDir); iCurrRefIdx++)
    417448            {
    418               if( currSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx )->getViewIndex() == iColRefViewIdx )
     449              if(currSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iColRefViewIdx)
    419450              { 
    420451                m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = true;
     
    428459  }
    429460}
     461
    430462Bool TComPic::isTempIVRefValid(Int currCandPic, Int iColRefDir, Int iColRefIdx)
    431463{
     
    433465}
    434466
    435 Void TComPic::checkTextureRef(  )
     467Void TComPic::checkTextureRef()
    436468{
    437469  TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx());
    438   TComPic* pcTextPic = pcCurrSlice->getTexturePic();
     470  TComPic* pcTextPic = pcCurrSlice->getIvPic(0, getViewIndex());
    439471#if H_3D_FCO
    440472  if ( pcTextPic )
    441473  {
    442474#endif
    443 
    444475    TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
    445476
    446     for( Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB()? 2:1) ) && !pcTextSlice->isIntra(); iTextRefDir ++ )
    447     {
    448       for( Int iTextRefIdx =0; iTextRefIdx<pcTextSlice->getNumRefIdx(( RefPicList )iTextRefDir ); iTextRefIdx++)
    449       {
    450         Int iTextRefPOC    = pcTextSlice->getRefPOC( ( RefPicList )iTextRefDir, iTextRefIdx);
    451         Int iTextRefViewId = pcTextSlice->getRefPic( ( RefPicList )iTextRefDir, iTextRefIdx)->getViewIndex();
     477    for(Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB() ? 2 :1) ) && !pcTextSlice->isIntra(); iTextRefDir++)
     478    {
     479      for(Int iTextRefIdx =0; iTextRefIdx < pcTextSlice->getNumRefIdx((RefPicList)iTextRefDir); iTextRefIdx++)
     480      {
     481        Int iTextRefPOC    = pcTextSlice->getRefPOC((RefPicList)iTextRefDir, iTextRefIdx);
     482        Int iTextRefViewId = pcTextSlice->getRefPic((RefPicList)iTextRefDir, iTextRefIdx)->getViewIndex();
    452483        m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
    453484        Int iCurrRefDir = iTextRefDir;
    454         for( Int iCurrRefIdx =0; ( iCurrRefIdx<pcCurrSlice->getNumRefIdx(( RefPicList )iCurrRefDir ) ) && ( m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0 ) ; iCurrRefIdx++)
     485
     486        for(Int iCurrRefIdx = 0; (iCurrRefIdx<pcCurrSlice->getNumRefIdx((RefPicList)iCurrRefDir)) && (m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0); iCurrRefIdx++)
    455487        {
    456           if( pcCurrSlice->getRefPOC( ( RefPicList )iCurrRefDir, iCurrRefIdx ) == iTextRefPOC &&
    457             pcCurrSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId )
     488          if(pcCurrSlice->getRefPOC((RefPicList)iCurrRefDir, iCurrRefIdx ) == iTextRefPOC &&
     489             pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId)
    458490          { 
    459491            m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
     
    461493        }
    462494      }
    463 
    464495    }
    465496#if H_3D_FCO
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComPic.h

    r1200 r1279  
    9494#endif
    9595#endif
    96 #if H_3D_QTLPC
     96#if NH_3D_QTLPC
    9797  Bool                  m_bReduceBitsQTL;
    9898#endif
    99 #if H_3D_NBDV
     99#if NH_3D_NBDV
    100100  UInt        m_uiRapRefIdx;
    101101  RefPicList  m_eRapRefList;
    102102  Int         m_iNumDdvCandPics;
    103   Bool        m_abTIVRINCurrRL  [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
     103  Bool        m_abTIVRINCurrRL [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
    104104  Int         m_aiTexToDepRef  [2][MAX_NUM_REF];
    105105#endif
     
    132132#endif
    133133#endif
    134 #if H_3D_QTLPC
     134#if NH_3D_QTLPC
    135135  Bool          getReduceBitsFlag ()             { return m_bReduceBitsQTL;     }
    136136  Void          setReduceBitsFlag ( Bool bFlag ) { m_bReduceBitsQTL = bFlag;    }
     
    182182#endif
    183183#if NH_3D
     184#if NH_3D_ARP
     185  Void          getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
     186#endif
    184187  Void          compressMotion(Int scale);
    185188#else   
     
    209212  Void          print( Bool legend );
    210213#endif
    211 #if H_3D_NBDV
     214#if NH_3D_NBDV
    212215  Int           getNumDdvCandPics()                    {return m_iNumDdvCandPics;   }
    213216  Int           getDisCandRefPictures(Int iColPOC);
     
    248251  Void        push_back( TComList<TComPic*>* list ) { m_lists.push_back( list );   }
    249252  Int         size     ()                           { return (Int) m_lists.size(); }
    250 #if H_3D_ARP
     253#if NH_3D_ARP
    251254  TComList<TComPic*>*  getPicList   ( Int layerIdInNuh );
    252255#endif
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComPicYuv.cpp

    r1200 r1279  
    9191  m_iPicHeight        = iPicHeight;
    9292
    93 #if H_3D_IV_MERGE
     93#if NH_3D_IV_MERGE
     94  m_iCuWidth        = uiMaxCUWidth;
     95  m_iCuHeight       = uiMaxCUHeight;
     96
    9497  m_iNumCuInWidth   = m_iPicWidth / m_iCuWidth;
    9598  m_iNumCuInWidth  += ( m_iPicWidth % m_iCuWidth ) ? 1 : 0;
     
    292295  fclose(pFile);
    293296}
    294 #if H_3D
    295 #if H_3D_IV_MERGE
     297#if NH_3D_IV_MERGE
    296298Void
    297299TComPicYuv::getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY )
     
    319321  riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
    320322}
    321 #endif
     323
     324#endif
     325
     326#if H_3D
    322327Void TComPicYuv::setLumaTo( Pel pVal )
    323328{
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComPicYuv.h

    r1200 r1279  
    8080
    8181  Bool  m_bIsBorderExtended;
    82 #if H_3D_IV_MERGE
     82#if NH_3D_IV_MERGE
    8383  Int   m_iBaseUnitWidth;       ///< Width of Base Unit (with maximum depth or minimum size, m_iCuWidth >> Max. Depth)
    8484  Int   m_iBaseUnitHeight;      ///< Height of Base Unit (with maximum depth or minimum size, m_iCuHeight >> Max. Depth)
    8585  Int   m_iNumCuInWidth;
     86  Int   m_iCuWidth;             ///< Width of Coding Unit (CU)
     87  Int   m_iCuHeight;            ///< Height of Coding Unit (CU)
    8688#endif
    8789
     
    168170  Void  setLumaTo    ( Pel pVal ); 
    169171  Void  setChromaTo  ( Pel pVal ); 
    170 #if H_3D_IV_MERGE
     172#if NH_3D_IV_MERGE
    171173  // sample to block and block to sample conversion
    172174  Void  getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY );
  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComPrediction.cpp

    r1243 r1279  
    8282    }
    8383  }
    84 #if H_3D_VSP
    85   m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int));
     84#if NH_3D_VSP
     85  m_pDepthBlock = (Int*) malloc(MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH*sizeof(Int));
    8686  if (m_pDepthBlock == NULL)
    8787  {
     
    9494TComPrediction::~TComPrediction()
    9595{
    96 #if H_3D_VSP
     96#if NH_3D_VSP
    9797  if (m_pDepthBlock != NULL)
    9898  {
     
    123123  m_cYuvPredTemp.destroy();
    124124
    125 #if H_3D_ARP
     125#if NH_3D_ARP
    126126  m_acYuvPredBase[0].destroy();
    127127  m_acYuvPredBase[1].destroy();
     
    182182
    183183    m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
    184 #if H_3D_ARP
    185     m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    186     m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    187 #endif
    188 #if H_3D_VSP
    189     m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     184#if NH_3D_ARP
     185    m_acYuvPredBase[0] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
     186    m_acYuvPredBase[1] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
     187#endif
     188#if NH_3D_VSP
     189    m_cYuvDepthOnVsp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
    190190#endif
    191191
     
    201201    }
    202202  }
    203 #if H_3D_IC
     203#if NH_3D_IC
    204204  m_uiaShift[0] = 0;
    205205  for( Int i = 1; i < 64; i++ )
     
    584584      Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC();
    585585      Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC();
    586 #if H_3D_ARP
     586#if NH_3D_ARP
    587587      if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
    588588#else
     
    597597}
    598598
    599 #if H_3D_SPIVMP
     599#if NH_3D_SPIVMP
    600600Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr )
    601601{
     
    606606    pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]);
    607607  }
     608#if H_3D_ARP // check this!
    608609  if( pcCU->getARPW( uiPartAddr ) != 0 )
    609610  {
    610611    return;
    611612  }
     613#endif
    612614
    613615  // horizontal sub-PU merge
     
    683685#endif
    684686
    685 #if H_3D_DBBP
     687#if NH_3D_DBBP
    686688PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU)
    687689{
     690  const TComSPS* sps = pcCU->getSlice()->getSPS();
     691  UInt uiMaxCUWidth = sps->getMaxCUWidth();
     692  UInt uiMaxCUHeight = sps->getMaxCUHeight();
     693 
    688694  // find virtual partitioning for this CU based on depth block
    689695  // segmentation of texture block --> mask IDs
     
    693699  Int iSumDepth = 0;
    694700  Int iSubSample = 4;
    695   Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth();
    696   Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight();
     701  Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y);
     702  Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y);
    697703  TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag(  ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV;
    698704  if( pcCU->getSlice()->getDepthRefinementFlag(  ) )
     
    700706    cDv.setVer(0);
    701707  }
    702   Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2);
    703   Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2);
     708  Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2);
     709  Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2);
    704710 
    705711  UInt t=0;
     
    788794  }
    789795
    790   PartSize matchedPartSize = SIZE_NONE;
     796  PartSize matchedPartSize = NUMBER_OF_PART_SIZES;
    791797
    792798  Int iMaxMatchSum = 0;
     
    803809  }
    804810
    805   AOF( matchedPartSize != SIZE_NONE );
     811  AOF( matchedPartSize != NUMBER_OF_PART_SIZES );
    806812
    807813  return matchedPartSize;
     
    810816Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU)
    811817{
     818  const TComSPS* sps = pcCU->getSlice()->getSPS();
     819  UInt uiMaxCUWidth = sps->getMaxCUWidth();
     820  UInt uiMaxCUHeight = sps->getMaxCUHeight();
     821 
    812822  // segmentation of texture block --> mask IDs
    813823  Pel*  pDepthBlockStart      = pDepthPels;
     
    821831  iSumDepth  = pDepthPels[ 0 ];
    822832 
    823   Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth();
    824   Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(); 
     833  Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y);
     834  Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y); 
    825835  TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag(  ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV;
    826836  if( pcCU->getSlice()->getDepthRefinementFlag(  ) )
     
    828838    cDv.setVer(0);
    829839  }
    830   Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2);
    831   Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2);
     840  Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2);
     841  Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2);
    832842  if (iBlkX>(Int)(iPictureWidth - uiWidth))
    833843  {
     
    944954}
    945955
    946 Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize )
    947 {
    948   Pel*  piSrc[2]    = {pInYuv[0]->getLumaAddr(uiPartAddr), pInYuv[1]->getLumaAddr(uiPartAddr)};
    949   UInt  uiSrcStride = pInYuv[0]->getStride();
    950   Pel*  piDst       = pOutYuv->getLumaAddr(uiPartAddr);
    951   UInt  uiDstStride = pOutYuv->getStride();
     956Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY )
     957{
     958  Pel*  piSrc[2]    = {pInYuv[0]->getAddr(COMPONENT_Y, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Y, uiPartAddr)};
     959  UInt  uiSrcStride = pInYuv[0]->getStride(COMPONENT_Y);
     960  Pel*  piDst       = pOutYuv->getAddr(COMPONENT_Y, uiPartAddr);
     961  UInt  uiDstStride = pOutYuv->getStride(COMPONENT_Y);
    952962 
    953963  UInt  uiMaskStride= MAX_CU_SIZE;
     
    988998        right  = (x==uiWidth-1)  ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1];
    989999       
    990         piDst[x] = (l!=r) ? ClipY( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 )) : tmpTar[y*uiWidth+x];
     1000        piDst[x] = (l!=r) ? ClipBD( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x];
    9911001      }
    9921002      piDst     += uiDstStride;
     
    10061016        bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x];
    10071017       
    1008         piDst[x] = (t!=b) ? ClipY( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 )) : tmpTar[y*uiWidth+x];
     1018        piDst[x] = (t!=b) ? ClipBD( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x];
    10091019      }
    10101020      piDst     += uiDstStride;
     
    10191029 
    10201030  // now combine chroma
    1021   Pel*  piSrcU[2]       = { pInYuv[0]->getCbAddr(uiPartAddr), pInYuv[1]->getCbAddr(uiPartAddr) };
    1022   Pel*  piSrcV[2]       = { pInYuv[0]->getCrAddr(uiPartAddr), pInYuv[1]->getCrAddr(uiPartAddr) };
    1023   UInt  uiSrcStrideC    = pInYuv[0]->getCStride();
    1024   Pel*  piDstU          = pOutYuv->getCbAddr(uiPartAddr);
    1025   Pel*  piDstV          = pOutYuv->getCrAddr(uiPartAddr);
    1026   UInt  uiDstStrideC    = pOutYuv->getCStride();
     1031  Pel*  piSrcU[2]       = { pInYuv[0]->getAddr(COMPONENT_Cb, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cb, uiPartAddr) };
     1032  Pel*  piSrcV[2]       = { pInYuv[0]->getAddr(COMPONENT_Cr, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cr, uiPartAddr) };
     1033  UInt  uiSrcStrideC    = pInYuv[0]->getStride(COMPONENT_Cb);
     1034  Pel*  piDstU          = pOutYuv->getAddr(COMPONENT_Cb, uiPartAddr);
     1035  Pel*  piDstV          = pOutYuv->getAddr(COMPONENT_Cr, uiPartAddr);
     1036  UInt  uiDstStrideC    = pOutYuv->getStride(COMPONENT_Cb);
    10271037  UInt  uiWidthC        = uiWidth >> 1;
    10281038  UInt  uiHeightC       = uiHeight >> 1;
     
    10701080        if (l!=r)
    10711081        {
    1072           filSrcU = ClipC( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ));
    1073           filSrcV = ClipC( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ));
     1082          filSrcU = ClipBD( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ), bitDepthY);
     1083          filSrcV = ClipBD( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ), bitDepthY);
    10741084        }
    10751085        else
     
    11031113        if (t!=b)
    11041114        {
    1105           filSrcU = ClipC( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ));
    1106           filSrcV = ClipC( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ));
     1115          filSrcU = ClipBD( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ), bitDepthY);
     1116          filSrcV = ClipBD( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ), bitDepthY);
    11071117        }
    11081118        else
     
    11411151  {
    11421152    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    1143 #if H_3D_VSP
     1153#if NH_3D_VSP
    11441154    if ( pcCU->getVSPFlag(uiPartAddr) == 0)
    11451155    {
    11461156#endif
    1147     if ( eRefPicList != REF_PIC_LIST_X )
    1148     {
    1149       if( pcCU->getSlice()->getPPS()->getUseWP())
    1150       {
    1151         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     1157      if ( eRefPicList != REF_PIC_LIST_X )
     1158      {
     1159        if( pcCU->getSlice()->getPPS()->getUseWP())
     1160        {
     1161          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     1162        }
     1163        else
     1164        {
     1165          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1166        }
     1167        if ( pcCU->getSlice()->getPPS()->getUseWP() )
     1168        {
     1169          xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1170        }
    11521171      }
    11531172      else
    11541173      {
    1155         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1156       }
    1157       if ( pcCU->getSlice()->getPPS()->getUseWP() )
    1158       {
    1159         xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1160       }
    1161     }
    1162     else
    1163     {
    1164 #if H_3D_SPIVMP
     1174#if NH_3D_SPIVMP
    11651175        if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
    11661176        {
     
    11941204        {
    11951205#endif
     1206          if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
     1207          {
     1208            xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
     1209          }
     1210          else
     1211          {
     1212            xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
     1213          }
     1214#if NH_3D_SPIVMP
     1215        }
     1216#endif
     1217      }
     1218#if NH_3D_VSP
     1219    }
     1220    else
     1221    {
    11961222      if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    11971223      {
    1198         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
     1224        xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    11991225      }
    12001226      else
    12011227      {
    1202         xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1203       }
    1204 #if H_3D_SPIVMP
    1205         }
    1206 #endif
    1207     }
    1208 #if H_3D_VSP
     1228        xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
     1229      }
     1230    }
     1231#endif
     1232    return;
     1233  }
     1234
     1235  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
     1236  {
     1237    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
     1238
     1239#if NH_3D_VSP
     1240    if ( pcCU->getVSPFlag(uiPartAddr) == 0 )
     1241    {
     1242#endif
     1243    if ( eRefPicList != REF_PIC_LIST_X )
     1244    {
     1245      if( pcCU->getSlice()->getPPS()->getUseWP())
     1246      {
     1247        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     1248      }
     1249      else
     1250      {
     1251        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1252      }
     1253      if ( pcCU->getSlice()->getPPS()->getUseWP() )
     1254      {
     1255        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1256      }
    12091257    }
    12101258    else
    12111259    {
    1212       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1213       {
    1214         xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1215       }
    1216       else
    1217       {
    1218         xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1219       }
    1220     }
    1221 #endif
    1222     return;
    1223   }
    1224 
    1225   for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
    1226   {
    1227     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    1228 
    1229 #if H_3D_VSP
    1230     if ( pcCU->getVSPFlag(uiPartAddr) == 0 )
    1231     {
    1232 #endif
    1233     if ( eRefPicList != REF_PIC_LIST_X )
    1234     {
    1235       if( pcCU->getSlice()->getPPS()->getUseWP())
    1236       {
    1237         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
    1238       }
    1239       else
    1240       {
    1241         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1242       }
    1243       if ( pcCU->getSlice()->getPPS()->getUseWP() )
    1244       {
    1245         xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1246       }
    1247     }
    1248     else
    1249     {
    1250 #if H_3D_SPIVMP
    1251        if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
     1260#if NH_3D_SPIVMP
     1261      if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
    12521262      {
    12531263        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
     
    12791289      {
    12801290#endif
    1281       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1282       {
    1283         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1284       }
    1285       else
    1286       {
    1287         xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1288       }
    1289 #if H_3D_SPIVMP
    1290        }
    1291 #endif
    1292     }
    1293 #if H_3D_VSP
     1291        if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
     1292        {
     1293          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
     1294        }
     1295        else
     1296        {
     1297          xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
     1298        }
     1299#if NH_3D_SPIVMP
     1300      }
     1301#endif
     1302    }
     1303#if NH_3D_VSP
    12941304    }
    12951305    else
     
    13171327  pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
    13181328#endif
    1319 #if H_3D_ARP
    1320   if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
    1321   {
    1322     xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi );
     1329#if NH_3D_ARP
     1330  if(  pcCU->getARPW( uiPartAddr ) > 0 )
     1331  {
     1332    if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC() )
     1333  {
     1334      xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , pcYuvPred , bi );
    13231335  }
    13241336  else
    13251337  {
    1326     if(  pcCU->getARPW( uiPartAddr ) > 0
    1327       && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N
    1328       && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC()
    1329       )
    1330     {
    1331       xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi );
     1338      xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, bi );
     1339    }     
    13321340    }
    13331341    else
    13341342    {
    13351343#endif
    1336 #if H_3D_IC
    1337       Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() );
    1338       xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
    1339 #if H_3D_ARP
    1340         , false
    1341 #endif
    1342         , bICFlag );
    1343       bICFlag = bICFlag && (iWidth > 8);
    1344       xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
    1345 #if H_3D_ARP
     1344  for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
     1345  {
     1346    const ComponentID compID=ComponentID(comp);
     1347#if NH_3D_IC
     1348    Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) );
     1349      xPredInterBlk(compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID))
     1350#if NH_3D_ARP
    13461351        , false
    13471352#endif
    13481353        , bICFlag );
    13491354#else
    1350 
    1351   for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
    1352   {
    1353     const ComponentID compID=ComponentID(comp);
    13541355    xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
    1355   }
    1356 #endif
    1357 #if H_3D_ARP
    1358     }
    1359   }
    1360 #endif
    1361 }
    1362 
    1363 #if H_3D_VSP
     1356#endif
     1357  }
     1358#if NH_3D_ARP
     1359  }
     1360#endif
     1361}
     1362
     1363#if NH_3D_VSP
    13641364Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
    13651365{
     
    13821382Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU )
    13831383{
    1384   UInt numPartsInLine       = pcCU->getPic()->getNumPartInWidth();
     1384  UInt numPartsInLine       = pcCU->getPic()->getNumPartInCtuWidth();
    13851385  UInt horiNumPartsInSubPU  = widthSubPU >> 2;
    13861386  UInt vertNumPartsInSubPU  = (heightSubPU >> 2) * numPartsInLine;
     
    13981398      pcCU->clipMv(cMv);
    13991399
    1400       xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
    1401       xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
    1402 
    1403     }
    1404   }
    1405 }
    1406 
    1407 #endif
    1408 
    1409 #if H_3D_ARP
    1410 Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
    1411 {
    1412   Int         iRefIdx      = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
    1413   TComMv      cMv          = pNewMvFiled ? pNewMvFiled->getMv()     : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
     1400      xPredInterBlk( COMPONENT_Y,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
     1401      xPredInterBlk( COMPONENT_Cb, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
     1402      xPredInterBlk( COMPONENT_Cr, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
     1403    }
     1404  }
     1405}
     1406#endif
     1407
     1408#if NH_3D_ARP
     1409//temporal ARP
     1410Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
     1411{
     1412  Int         iRefIdx      = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
     1413  TComMv      cMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    14141414  Bool        bTobeScaled  = false;
    14151415  TComPic* pcPicYuvBaseCol = NULL;
    14161416  TComPic* pcPicYuvBaseRef = NULL;
    14171417
    1418 #if H_3D_NBDV
     1418#if NH_3D_NBDV
    14191419  DisInfo cDistparity;
    14201420  cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;
     
    14251425  UChar dW = pcCU->getARPW ( uiPartAddr );
    14261426
    1427   {
    14281427    Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
    1429     if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() )
    1430     {
    1431       bTobeScaled = true;
    1432     }
    1433 
    1434     pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
    1435 
    1436     pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
    1437 
    1438     if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
     1428  if (arpRefIdx < 0 || !pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
    14391429    {
    14401430      dW = 0;
     
    14431433    else
    14441434    {
    1445       assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() );
     1435    if( arpRefIdx != iRefIdx )
     1436    {
     1437      bTobeScaled = true;
     1438    }
     1439    pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
     1440    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
    14461441    }
    14471442
     
    14501445      Int iCurrPOC    = pcCU->getSlice()->getPOC();
    14511446      Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
    1452       Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList,  0);
     1447    Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, arpRefIdx );
    14531448      Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
    14541449      if ( iScale != 4096 )
     
    14561451        cMv = cMv.scaleMv( iScale );
    14571452      }
    1458       iRefIdx = 0;
    1459     }
     1453    iRefIdx = arpRefIdx;
    14601454  }
    14611455
    14621456  pcCU->clipMv(cMv);
    14631457  TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
    1464   xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
    1465   xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
     1458
     1459  for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
     1460  {
     1461    const ComponentID compID=ComponentID(comp);
     1462    xPredInterBlk  ( compID,  pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1463  }
    14661464
    14671465  if( dW > 0 )
     
    14791477    pcCU->clipMv( cNBDV );
    14801478   
    1481     pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
    1482     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
    1483     if (iWidth > 8)
    1484       xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
     1479    TComPicYuv* pcPicYuvBaseColRec = pcPicYuvBaseCol->getPicYuvRec();
     1480    TComPicYuv* pcPicYuvBaseRefRec = pcPicYuvBaseRef->getPicYuvRec();
    14851481   
    1486     pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec();
    1487     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
    1488  
    1489     if (iWidth > 8)
    1490       xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
     1482    UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
     1483    for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
     1484    {
     1485      const ComponentID compID=ComponentID(comp);
     1486      xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseColRec, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1487      xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseRefRec, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1488    }   
    14911489   
    14921490    pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight );
     
    14961494      pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
    14971495    }
    1498     rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi );
     1496    rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() );
    14991497  }
    15001498}
     
    15051503  TComMv      cDMv          = pcCU->getCUMvField( eBaseRefPicList )->getMv( uiPartAddr );
    15061504  TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eBaseRefPicList, iRefIdx ); 
    1507   TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();
    1508   Int uiLCUAddr,uiAbsPartAddr;
    15091505  Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
    15101506  Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
     
    15121508  irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
    15131509  irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 
    1514   pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
    1515   TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
     1510
     1511  Int uiLCUAddr,uiAbsPartAddr;
     1512  pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
     1513  TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
    15161514
    15171515  TComPic* pcPicYuvBaseTRef = NULL;
     
    15651563}
    15661564
    1567 Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
     1565//inter-view ARP
     1566Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
    15681567{
    15691568  Int         iRefIdx       = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
     
    15781577  Bool bTMVAvai = false;     
    15791578  TComMv cBaseTMV;
    1580   if( pNewMvFiled )
    1581   {
    1582     iRefIdx = pNewMvFiled->getRefIdx();
    1583     cDMv = pNewMvFiled->getMv();
    1584   }
     1579
    15851580  pcCU->clipMv(cTempDMv);
    15861581
    1587   assert(dW > 0);
    1588   if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex()))
    1589   {
    1590     dW = 0;
    1591   }
    1592   Int uiLCUAddr,uiAbsPartAddr;
    15931582  Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
    15941583  Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
     
    15961585  irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
    15971586  irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 
    1598   pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
    1599   TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
     1587 
     1588  Int uiLCUAddr,uiAbsPartAddr;
     1589  pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
     1590  TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
    16001591  if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getIsDepth() )
    16011592  {
     
    16681659      RefPicList eRefPicListCurr = RefPicList(iList);
    16691660      Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
    1670       if( iRef != -1)
     1661      if( iRef != -1 && pcCU->getSlice()->getArpRefPicAvailable( eRefPicListCurr, pcPicYuvBaseCol->getViewIndex()))
    16711662      {
    16721663        pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); 
     
    17021693  }
    17031694
    1704   xPredInterLumaBlk  ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
    1705   xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
    1706 
    1707   if( dW > 0 && bTMVAvai )
    1708   {
     1695  for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
     1696  {
     1697    const ComponentID compID=ComponentID(comp);
     1698    xPredInterBlk  ( compID,  pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), bTMVAvai );
     1699  }
     1700
     1701  if( dW > 0 )
     1702  {
     1703    assert ( bTMVAvai );
    17091704    TComYuv*    pYuvCurrTRef    = &m_acYuvPredBase[0];
    17101705    TComYuv*    pYuvBaseTRef    = &m_acYuvPredBase[1];
     
    17201715      pYuvCurrTRef->clear(); pYuvBaseTRef->clear();
    17211716    }
    1722     xPredInterLumaBlk  ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
    1723 
    1724     if (iWidth > 8)
    1725       xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
    1726 
    1727     xPredInterLumaBlk  ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true);
    1728 
    1729     if (iWidth > 8)
    1730       xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true);
     1717
     1718    UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
     1719    for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
     1720    {
     1721      const ComponentID compID=ComponentID(comp);
     1722      xPredInterBlk  ( compID,  pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1723      xPredInterBlk  ( compID,  pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1724    }
    17311725
    17321726    pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight ); 
     
    17351729      pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
    17361730    }
    1737     rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi );
     1731    rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() );
    17381732  }
    17391733}
     
    17901784}
    17911785
    1792 #if H_3D_VSP
    1793 
     1786#if NH_3D_VSP
    17941787Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred )
    17951788{
     
    18131806  }
    18141807
    1815   xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
    1816 }
    1817 
     1808  xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() );
     1809}
    18181810#endif
    18191811
     
    18351827
    18361828Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth
    1837 #if H_3D_ARP
     1829#if NH_3D_ARP
    18381830    , Bool filterType
    18391831#endif
    1840 #if H_3D_IC
     1832#if NH_3D_IC
    18411833    , Bool bICFlag
    18421834#endif
     
    18571849  Int     yFrac  = mv->getVer() & ((1<<shiftVer)-1);
    18581850
    1859 #if H_3D_IC
     1851#if NH_3D_INTEGER_MV_DEPTH
    18601852  if( cu->getSlice()->getIsDepth() )
    18611853  {
    18621854    refOffset = mv->getHor() + mv->getVer() * refStride;
    1863     ref       = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset;
     1855    ref       = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset;
    18641856    xFrac     = 0;
    18651857    yFrac     = 0;
     
    18741866  if ( yFrac == 0 )
    18751867  {
    1876 #if H_3D_IC
    1877     m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi || bICFlag
     1868#if NH_3D_IC
     1869    m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag, chFmt, bitDepth
    18781870#else
    18791871    m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth
    18801872#endif
    1881 #if H_3D_ARP
     1873#if NH_3D_ARP
    18821874    , filterType
    18831875#endif
     
    18861878  else if ( xFrac == 0 )
    18871879  {
    1888 #if H_3D_IC
    1889     m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag
     1880#if NH_3D_IC
     1881    m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag, chFmt, bitDepth
    18901882#else
    18911883    m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth
    18921884#endif
    1893 #if H_3D_ARP
     1885#if NH_3D_ARP
    18941886    , filterType
    18951887#endif
     
    19041896
    19051897    m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false,      chFmt, bitDepth
    1906 #if H_3D_ARP
     1898#if NH_3D_ARP
    19071899    , filterType
    19081900#endif
    19091901);
    1910 #if H_3D_IC
    1911     m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi || bICFlag
     1902#if NH_3D_IC
     1903    m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi || bICFlag, chFmt, bitDepth
    19121904#else
    19131905    m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi, chFmt, bitDepth
    19141906#endif
    1915 #if H_3D_ARP
     1907#if NH_3D_ARP
    19161908    , filterType
    19171909#endif
     
    19191911  }
    19201912
    1921 #if H_3D_IC
     1913#if NH_3D_IC
    19221914  if( bICFlag )
    19231915  {
    19241916    Int a, b, i, j;
    19251917    const Int iShift = IC_CONST_SHIFT;
    1926 
    1927     xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA );
    1928 
    1929 
    1930     for ( i = 0; i < height; i++ )
    1931     {
    1932       for ( j = 0; j < width; j++ )
    1933       {
    1934           dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b );
     1918    Pel *dst2 = dst;
     1919
     1920    xGetLLSICPrediction( compID, cu, mv, refPic, a, b, bitDepth );
     1921
     1922    for ( i = 0; i < cxHeight; i++ )
     1923    {
     1924      for ( j = 0; j < cxWidth; j++ )
     1925      {
     1926        dst[j] = Clip3( 0, ( 1 << bitDepth ) - 1, ( ( a*dst[j] ) >> iShift ) + b );
    19351927      }
    19361928      dst += dstStride;
     
    19391931    if(bi)
    19401932    {
    1941       Pel *dst2      = dstPic->getLumaAddr( partAddr );
    1942       Int shift = IF_INTERNAL_PREC - g_bitDepthY;
    1943       for (i = 0; i < height; i++)
    1944       {
    1945         for (j = 0; j < width; j++)
    1946         {
    1947           Short val = dst2[j] << shift;
    1948           dst2[j] = val - (Short)IF_INTERNAL_OFFS;
     1933      Int shift = IF_INTERNAL_PREC - bitDepth;
     1934      for (i = 0; i < cxHeight; i++)
     1935      {
     1936        for (j = 0; j < cxWidth; j++)
     1937        {
     1938          Pel val = dst2[j] << shift;
     1939          dst2[j] = val - (Pel)IF_INTERNAL_OFFS;
    19491940        }
    19501941        dst2 += dstStride;
     
    19561947}
    19571948
    1958 
    1959 #if H_3D_ARP
    1960     , Bool filterType
    1961 #endif
    1962 #if H_3D_IC
    1963     , Bool bICFlag
    1964 #endif
    1965 #if H_3D_IC
    1966     m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    1967 #else
    1968 #endif
    1969 #if H_3D_ARP
    1970     , filterType
    1971 #endif
    1972 #if H_3D_IC
    1973     m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    1974 #else
    1975 #endif
    1976 #if H_3D_ARP
    1977     , filterType
    1978 #endif
    1979 #if H_3D_IC
    1980     m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    1981 #else
    1982 #endif
    1983 #if H_3D_ARP
    1984     , filterType
    1985 #endif
    1986 #if H_3D_IC
    1987     m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    1988 #else
    1989 #endif
    1990 #if H_3D_ARP
    1991     , filterType
    1992 #endif
    1993 #if H_3D_ARP
    1994     , filterType
    1995 #endif 
    1996 #if H_3D_IC
    1997     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    1998 #else
    1999 #endif
    2000 #if H_3D_ARP
    2001     , filterType
    2002 #endif
    2003 #if H_3D_ARP
    2004     , filterType
    2005 #endif
    2006 #if H_3D_IC
    2007     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    2008 #else
    2009 #endif
    2010 #if H_3D_ARP
    2011     , filterType
    2012 #endif
    2013 #if H_3D_IC
    2014   if( bICFlag )
    2015   {
    2016     Int a, b, i, j;
    2017     const Int iShift = IC_CONST_SHIFT;
    2018 
    2019     xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb
    2020     for ( i = 0; i < cxHeight; i++ )
    2021     {
    2022       for ( j = 0; j < cxWidth; j++ )
    2023       {<