Changeset 1386 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComDataCU.cpp


Ignore:
Timestamp:
13 Nov 2015, 16:29:39 (9 years ago)
Author:
tech
Message:

Merged 15.1-dev1@1381.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComDataCU.cpp

    r1356 r1386  
    160160  if ( !bDecSubCu )
    161161  {
    162     m_phQP               = (Char*     )xMalloc(Char,     uiNumPartition);
     162    m_phQP               = (SChar*    )xMalloc(SChar,    uiNumPartition);
    163163    m_puhDepth           = (UChar*    )xMalloc(UChar,    uiNumPartition);
    164164    m_puhWidth           = (UChar*    )xMalloc(UChar,    uiNumPartition);
     
    171171    m_ucDISType          = (UChar*)xMalloc(UChar, uiNumPartition);
    172172#endif
    173     m_pePartSize         = new Char[ uiNumPartition ];
     173    m_pePartSize         = new SChar[ uiNumPartition ];
    174174    memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) );
    175     m_pePredMode         = new Char[ uiNumPartition ];
     175    m_pePredMode         = new SChar[ uiNumPartition ];
    176176    m_CUTransquantBypass = new Bool[ uiNumPartition ];
    177177
     
    179179    m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
    180180#if NH_3D_VSP
    181     m_piVSPFlag          = (Char*  )xMalloc(Char,  uiNumPartition);
     181    m_piVSPFlag          = (SChar* )xMalloc(SChar, uiNumPartition);
    182182#endif
    183183#if NH_3D_SPIVMP
     
    196196    {
    197197      const RefPicList rpl=RefPicList(i);
    198       m_apiMVPIdx[rpl]       = new Char[ uiNumPartition ];
    199       m_apiMVPNum[rpl]       = new Char[ uiNumPartition ];
    200       memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( Char ) );
     198      m_apiMVPIdx[rpl]       = new SChar[ uiNumPartition ];
     199      m_apiMVPNum[rpl]       = new SChar[ uiNumPartition ];
     200      memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( SChar ) );
    201201    }
    202202
     
    212212      const UInt totalSize   = (uiWidth * uiHeight) >> chromaShift;
    213213
    214       m_crossComponentPredictionAlpha[compID] = (Char*  )xMalloc(Char,   uiNumPartition);
     214      m_crossComponentPredictionAlpha[compID] = (SChar* )xMalloc(SChar,  uiNumPartition);
    215215      m_puhTransformSkip[compID]              = (UChar* )xMalloc(UChar,  uiNumPartition);
    216216      m_explicitRdpcmMode[compID]             = (UChar* )xMalloc(UChar,  uiNumPartition);
     
    524524}
    525525
    526 Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx)
     526Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) const
    527527{
    528528  const TComSPS &sps=*(getSlice()->getSPS());
     
    844844  Int iSizeInUchar = sizeof( UChar  ) * m_uiNumPartition;
    845845  Int iSizeInBool  = sizeof( Bool   ) * m_uiNumPartition;
    846   Int sizeInChar = sizeof( Char  ) * m_uiNumPartition;
     846  Int sizeInChar = sizeof( SChar  ) * m_uiNumPartition;
    847847
    848848  memset( m_phQP,              qp,  sizeInChar );
     
    850850  memset( m_puhMergeIndex,      0, iSizeInUchar );
    851851#if NH_3D_VSP
    852   memset( m_piVSPFlag,          0, sizeof( Char ) * m_uiNumPartition );
     852  memset( m_piVSPFlag,          0, sizeof( SChar ) * m_uiNumPartition );
    853853#endif
    854854#if NH_3D_SPIVMP
     
    11211121
    11221122// Copy inter prediction info from the biggest CU
    1123 Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
    11241123#if NH_3D_NBDV
    1125   , Bool bNBDV
    1126 #endif
    1127 )
     1124Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList   , Bool bNBDV )
     1125#else
     1126Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList )
     1127#endif
    11281128{
    11291129  m_pcPic              = pcCU->getPic();
     
    12191219  Int iSizeInBool   = sizeof( Bool  ) * uiNumPartition;
    12201220
    1221   Int sizeInChar  = sizeof( Char ) * uiNumPartition;
     1221  Int sizeInChar  = sizeof( SChar ) * uiNumPartition;
    12221222  memcpy( m_skipFlag   + uiOffset, pcCU->getSkipFlag(),       sizeof( *m_skipFlag )   * uiNumPartition );
    12231223#if NH_3D_DIS
     
    12331233  memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
    12341234#if NH_3D_VSP
    1235   memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
     1235  memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( SChar ) * uiNumPartition );
    12361236  memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
    12371237#endif
     
    13351335  Int iSizeInUchar  = sizeof( UChar ) * m_uiNumPartition;
    13361336  Int iSizeInBool   = sizeof( Bool  ) * m_uiNumPartition;
    1337   Int sizeInChar  = sizeof( Char ) * m_uiNumPartition;
     1337  Int sizeInChar  = sizeof( SChar ) * m_uiNumPartition;
    13381338
    13391339  memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition );
     
    13551355  memcpy( pCtu->getMergeIndex()        + m_absZIdxInCtu, m_puhMergeIndex,       iSizeInUchar );
    13561356#if NH_3D_VSP
    1357   memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
     1357  memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( SChar ) * m_uiNumPartition );
    13581358#endif
    13591359#if NH_3D_DBBP
     
    14471447// --------------------------------------------------------------------------------------------------------------------
    14481448
    1449 TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx,
     1449const TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx,
    14501450                                   UInt uiCurrPartUnitIdx,
    14511451                                   Bool bEnforceSliceRestriction,
    1452                                    Bool bEnforceTileRestriction )
     1452                                         Bool bEnforceTileRestriction ) const
    14531453{
    14541454  UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    14791479
    14801480
    1481 TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx,
     1481const TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx,
    14821482                                    UInt uiCurrPartUnitIdx,
    14831483                                    Bool bEnforceSliceRestriction,
    14841484                                    Bool planarAtCtuBoundary,
    1485                                     Bool bEnforceTileRestriction )
     1485                                          Bool bEnforceTileRestriction ) const
    14861486{
    14871487  UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    15171517}
    15181518
    1519 TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction )
     1519const TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) const
    15201520{
    15211521  UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    15641564}
    15651565
    1566 TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx,  UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction)
     1566const TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx,  UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const
    15671567{
    15681568  UInt uiAbsPartIdxLB     = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    16081608}
    16091609
    1610 TComDataCU* TComDataCU::getPUAboveRight(UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction)
     1610const TComDataCU* TComDataCU::getPUAboveRight(UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const
    16111611{
    16121612  UInt uiAbsPartIdxRT     = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    16681668*\returns TComDataCU*   point of TComDataCU of left QpMinCu
    16691669*/
    1670 TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu )
     1670const TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const
    16711671{
    16721672  const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth();
     
    16951695*\returns TComDataCU*   point of TComDataCU of above QpMinCu
    16961696*/
    1697 TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu )
     1697const TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const
    16981698{
    16991699  const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth();
     
    17211721/** Get reference QP from left QpMinCu or latest coded QP
    17221722*\param   uiCurrAbsIdxInCtu
    1723 *\returns Char   reference QP value
     1723*\returns SChar   reference QP value
    17241724*/
    1725 Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu )
     1725SChar TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) const
    17261726{
    17271727  UInt lPartIdx = MAX_UINT;
    17281728  UInt aPartIdx = MAX_UINT;
    1729   TComDataCU* cULeft  = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
    1730   TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
     1729  const TComDataCU* cULeft  = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
     1730  const TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
    17311731  return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1);
    17321732}
    17331733
    1734 Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx )
     1734Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) const
    17351735{
    17361736  Int iLastValidPartIdx = iAbsPartIdx-1;
     
    17441744}
    17451745
    1746 Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx )
     1746SChar TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) const
    17471747{
    17481748  UInt uiQUPartIdxMask = ~((1<<((getSlice()->getSPS()->getMaxTotalCUDepth() - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1);
     
    17841784 * \returns true if the CU is coded in lossless coding mode; false if otherwise
    17851785 */
    1786 Bool TComDataCU::isLosslessCoded(UInt absPartIdx)
     1786Bool TComDataCU::isLosslessCoded(UInt absPartIdx) const
    17871787{
    17881788  return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx));
     
    17961796*\param   [out] uiModeList pointer to chroma intra modes array
    17971797*/
    1798 Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] )
     1798Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) const
    17991799{
    18001800  uiModeList[0] = PLANAR_IDX;
     
    18241824*\returns Number of MPM
    18251825*/
    1826 Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode  )
    1827 {
    1828   TComDataCU* pcCULeft, *pcCUAbove;
     1826Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) const
     1827{
    18291828  UInt        LeftPartIdx  = MAX_UINT;
    18301829  UInt        AbovePartIdx = MAX_UINT;
     
    18361835  const ChromaFormat chForm = getPic()->getChromaFormat();
    18371836  // Get intra direction of left PU
    1838   pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
     1837  const TComDataCU *pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
    18391838
    18401839  if (isChroma(compID))
     
    18481847
    18491848  // Get intra direction of above PU
    1850   pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true );
     1849  const TComDataCU *pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true );
    18511850
    18521851  if (isChroma(compID))
     
    19171916}
    19181917
    1919 UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth )
    1920 {
    1921   TComDataCU* pcTempCU;
     1918UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) const
     1919{
     1920  const TComDataCU* pcTempCU;
    19221921  UInt        uiTempPartIdx;
    19231922  UInt        uiCtx;
     
    19331932}
    19341933
    1935 UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType )
     1934UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) const
    19361935{
    19371936  const UInt transformDepth = rTu.GetTransformDepthRel();
     
    19481947}
    19491948
    1950 UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx )
     1949UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) const
    19511950{
    19521951  UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2;
     
    19751974}
    19761975
    1977 UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx )
    1978 {
    1979   TComDataCU* pcTempCU;
     1976UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) const
     1977{
     1978  const TComDataCU* pcTempCU;
    19801979  UInt        uiTempPartIdx;
    19811980  UInt        uiCtx = 0;
     
    19941993UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
    19951994{
    1996   TComDataCU* pcTempCU;
     1995  const TComDataCU* pcTempCU;
    19971996  UInt        uiTempPartIdx;
    19981997  UInt        uiCtx = 0;
    1999  
     1998
    20001999  pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
    20012000  uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
    2002     return uiCtx;
     2001  return uiCtx;
    20032002}
    20042003#endif
     
    20862085
    20872086
    2088 UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx )
     2087UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) const
    20892088{
    20902089  return getDepth( uiAbsPartIdx );
     
    20922091
    20932092
    2094 UChar TComDataCU::getQtRootCbf( UInt uiIdx )
     2093UChar TComDataCU::getQtRootCbf( UInt uiIdx ) const
    20952094{
    20962095  const UInt numberValidComponents = getPic()->getNumberValidComponents();
     
    21482147}
    21492148
    2150 Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth)
     2149Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) const
    21512150{
    21522151  UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
     
    23762375
    23772376#if NH_3D_VSP
    2378 Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2379 {
    2380   setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
     2377Void TComDataCU::setVSPFlagSubParts( SChar iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     2378{
     2379  setSubPart<SChar>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    23812380}
    23822381template<typename T>
     
    25232522Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    25242523{
    2525   setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx );
     2524  setSubPart<SChar>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx );
    25262525}
    25272526
    25282527Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    25292528{
    2530   setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx );
     2529  setSubPart<SChar>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx );
    25312530}
    25322531
     
    25612560}
    25622561
    2563 Void TComDataCU::setCrossComponentPredictionAlphaPartRange( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes )
    2564 {
    2565   memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(Char) * uiCoveredPartIdxes));
     2562Void TComDataCU::setCrossComponentPredictionAlphaPartRange( SChar alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes )
     2563{
     2564  memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(SChar) * uiCoveredPartIdxes));
    25662565}
    25672566
     
    25792578}
    25802579
    2581 UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx)
     2580UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) const
    25822581{
    25832582  UChar iNumPart = 0;
     
    26012600// This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
    26022601#if NH_3D_IC || NH_3D_VSP
    2603 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU)
     2602Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) const
    26042603{
    26052604  UInt uiNumPartition  = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;
     
    26452644#else
    26462645
    2647 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight )
     2646Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight )  const
    26482647{
    26492648  switch ( m_pePartSize[0] )
     
    26862685#endif
    26872686
    2688 
    2689 Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField )
     2687// static member function
     2688Void TComDataCU::getMvField ( const TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField )
    26902689{
    26912690  if ( pcCU == NULL )  // OUT OF BOUNDARY
     
    26962695  }
    26972696
    2698   TComCUMvField*  pcCUMvField = pcCU->getCUMvField( eRefPicList );
     2697  const TComCUMvField*  pcCUMvField = pcCU->getCUMvField( eRefPicList );
    26992698  rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) );
    27002699}
    27012700
    2702 Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT )
     2701Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const
    27032702{
    27042703  ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx;
     
    27492748}
    27502749
    2751 Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB )
     2750Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) const
    27522751{
    27532752  UInt uiPUHeight = 0;
     
    27962795}
    27972796
    2798 Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT )
     2797Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const
    27992798{
    28002799  ruiPartIdxLT = m_absZIdxInCtu;
     
    28362835}
    28372836
    2838 Void TComDataCU::deriveLeftBottomIdx( UInt  uiPartIdx,      UInt&      ruiPartIdxLB )
     2837Void TComDataCU::deriveLeftBottomIdx( UInt  uiPartIdx,      UInt&      ruiPartIdxLB ) const
    28392838{
    28402839  ruiPartIdxLB      = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()];
     
    28762875 * \param [out] ruiPartIdxRB  partition index of neighbouring bottom right block
    28772876 */
    2878 Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB )
     2877Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB ) const
    28792878{
    28802879  ruiPartIdxRB      = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth() +  m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1];
     
    29122911}
    29132912
    2914 Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx )
     2913Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, const TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) const
    29152914{
    29162915  if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) )
     
    30983097
    30993098
    3100 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
     3099#if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    31013100  if ( g_traceMergeCandListConst )
    31023101  {
     
    31773176  }
    31783177
    3179 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
     3178#if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    31803179  if ( g_traceMergeCandListConst )
    31813180  {
     
    33063305  //left
    33073306  UInt uiLeftPartIdx = 0;
    3308   TComDataCU* pcCULeft = 0;
     3307  const TComDataCU* pcCULeft = 0;
    33093308  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 
    33103309
     
    37833782
    37843783//! Construct a list of merging candidates
     3784#if NH_3D
    37853785Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
     3786#else
     3787Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) const
     3788#endif
    37863789{
    37873790  UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
     
    38113814  //left
    38123815  UInt uiLeftPartIdx = 0;
    3813   TComDataCU* pcCULeft = 0;
    3814   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
     3816  const TComDataCU *pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    38153817
    38163818  Bool isAvailableA1 = pcCULeft &&
     
    38283830    puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
    38293831    // get Mv from Left
    3830     pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3832    TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    38313833    if ( getSlice()->isInterB() )
    38323834    {
    3833       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3835      TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    38343836    }
    38353837    if ( mrgCandIdx == iCount )
     
    38473849  // above
    38483850  UInt uiAbovePartIdx = 0;
    3849   TComDataCU* pcCUAbove = 0;
    3850   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
     3851  const TComDataCU *pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    38513852
    38523853  Bool isAvailableB1 = pcCUAbove &&
     
    38643865    puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
    38653866    // get Mv from Left
    3866     pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3867    TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    38673868    if ( getSlice()->isInterB() )
    38683869    {
    3869       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3870      TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    38703871    }
    38713872    if ( mrgCandIdx == iCount )
     
    38833884  // above right
    38843885  UInt uiAboveRightPartIdx = 0;
    3885   TComDataCU* pcCUAboveRight = 0;
    3886   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
     3886  const TComDataCU *pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    38873887
    38883888  Bool isAvailableB0 = pcCUAboveRight &&
     
    38993899    puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
    39003900    // get Mv from Left
    3901     pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3901    TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    39023902    if ( getSlice()->isInterB() )
    39033903    {
    3904       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3904      TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    39053905    }
    39063906    if ( mrgCandIdx == iCount )
     
    39183918  //left bottom
    39193919  UInt uiLeftBottomPartIdx = 0;
    3920   TComDataCU* pcCULeftBottom = 0;
    3921   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
     3920  const TComDataCU *pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    39223921
    39233922  Bool isAvailableA0 = pcCULeftBottom &&
     
    39343933    puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
    39353934    // get Mv from Left
    3936     pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3935    TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    39373936    if ( getSlice()->isInterB() )
    39383937    {
    3939       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3938      TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    39403939    }
    39413940    if ( mrgCandIdx == iCount )
     
    39553954  {
    39563955    UInt uiAboveLeftPartIdx = 0;
    3957     TComDataCU* pcCUAboveLeft = 0;
    3958     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
     3956    const TComDataCU *pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    39593957
    39603958    Bool isAvailableB2 = pcCUAboveLeft &&
     
    39723970      puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
    39733971      // get Mv from Left
    3974       pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3972      TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    39753973      if ( getSlice()->isInterB() )
    39763974      {
    3977         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3975        TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    39783976      }
    39793977      if ( mrgCandIdx == iCount )
     
    41664164 * \param xP, yP   location of the upper-left corner pixel of the current PU
    41674165 */
    4168 Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP)
     4166Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) const
    41694167{
    41704168
     
    41864184 * \param nPSW, nPSH    size of the current PU
    41874185 */
    4188 Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH)
     4186Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) const
    41894187{
    41904188  UInt col = m_uiCUPelX;
     
    42474245}
    42484246
    4249 /** Constructs a list of candidates for AMVP
     4247/** Constructs a list of candidates for AMVP (See specification, section "Derivation process for motion vector predictor candidates")
    42504248 * \param uiPartIdx
    42514249 * \param uiPartAddr
     
    42544252 * \param pInfo
    42554253 */
    4256 Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo )
    4257 {
    4258   TComMv cMvPred;
    4259   Bool bAddedSmvp = false;
    4260 
     4254Void TComDataCU::fillMvpCand ( const UInt partIdx, const UInt partAddr, const RefPicList eRefPicList, const Int refIdx, AMVPInfo* pInfo ) const
     4255{
    42614256  pInfo->iN = 0;
    4262   if (iRefIdx < 0)
     4257  if (refIdx < 0)
    42634258  {
    42644259    return;
     
    42664261
    42674262  //-- Get Spatial MV
    4268   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    4269   const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
    4270   const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
    4271   Bool bAdded = false;
    4272 
    4273   deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT );
    4274   deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB );
    4275 
    4276   TComDataCU* tmpCU = NULL;
    4277   UInt idx;
    4278   tmpCU = getPUBelowLeft(idx, uiPartIdxLB);
    4279   bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx));
    4280 
    4281   if (!bAddedSmvp)
    4282   {
    4283     tmpCU = getPULeft(idx, uiPartIdxLB);
    4284     bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx));
     4263  UInt partIdxLT, partIdxRT, partIdxLB;
     4264  deriveLeftRightTopIdx( partIdx, partIdxLT, partIdxRT );
     4265  deriveLeftBottomIdx( partIdx, partIdxLB );
     4266
     4267  Bool isScaledFlagLX = false; /// variable name from specification; true when the PUs below left or left are available (availableA0 || availableA1).
     4268  {
     4269    UInt idx;
     4270    const TComDataCU* tmpCU = getPUBelowLeft(idx, partIdxLB);
     4271    isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx));
     4272    if (!isScaledFlagLX)
     4273    {
     4274      tmpCU = getPULeft(idx, partIdxLB);
     4275      isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx));
     4276    }
    42854277  }
    42864278
    42874279  // Left predictor search
    4288   bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT);
    4289   if (!bAdded)
    4290   {
    4291     bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT );
    4292   }
    4293 
    4294   if(!bAdded)
    4295   {
    4296     bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT);
     4280  if (isScaledFlagLX)
     4281  {
     4282    Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT);
    42974283    if (!bAdded)
    42984284    {
    4299       xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT );
     4285      bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT );
     4286      if(!bAdded)
     4287      {
     4288        bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT);
     4289        if (!bAdded)
     4290        {
     4291          xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT );
     4292        }
     4293      }
    43004294    }
    43014295  }
    43024296
    43034297  // Above predictor search
    4304   bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
    4305 
    4306   if (!bAdded)
    4307   {
    4308     bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE);
    4309   }
    4310 
    4311   if(!bAdded)
    4312   {
    4313     xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
    4314   }
    4315 
    4316   if(!bAddedSmvp)
    4317   {
    4318     bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
     4298  {
     4299    Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT);
    43194300    if (!bAdded)
    43204301    {
    4321       bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE);
    4322     }
    4323 
    4324     if(!bAdded)
    4325     {
    4326       xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
     4302      bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE);
     4303      if(!bAdded)
     4304      {
     4305        xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT);
     4306      }
     4307    }
     4308  }
     4309
     4310  if(!isScaledFlagLX)
     4311  {
     4312    Bool bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT);
     4313    if (!bAdded)
     4314    {
     4315      bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE);
     4316      if(!bAdded)
     4317      {
     4318        xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT);
     4319      }
    43274320    }
    43284321  }
     
    43364329  }
    43374330
    4338   if ( getSlice()->getEnableTMVPFlag() )
     4331  if (pInfo->iN < AMVP_MAX_NUM_CANDS && getSlice()->getEnableTMVPFlag() )
    43394332  {
    43404333    // Get Temporal Motion Predictor
    4341     Int iRefIdx_Col = iRefIdx;
     4334    const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
     4335    const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
     4336#if NH_3D_TMVP
     4337    Int refIdx_Col = refIdx;
     4338#else
     4339    const Int refIdx_Col = refIdx;
     4340#endif
    43424341    TComMv cColMv;
    4343     UInt uiPartIdxRB;
    4344     UInt uiAbsPartIdx;
    4345     UInt uiAbsPartAddr;
    4346 
    4347     deriveRightBottomIdx( uiPartIdx, uiPartIdxRB );
    4348     uiAbsPartAddr = m_absZIdxInCtu + uiPartAddr;
     4342    UInt partIdxRB;
     4343    UInt absPartIdx;
     4344
     4345    deriveRightBottomIdx( partIdx, partIdxRB );
     4346    UInt absPartAddr = m_absZIdxInCtu + partAddr;
    43494347
    43504348    //----  co-located RightBottom Temporal Predictor (H) ---//
    4351     uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB];
     4349    absPartIdx = g_auiZscanToRaster[partIdxRB];
    43524350    Int ctuRsAddr = -1;
    4353     if (  ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
    4354        && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    4355     {
    4356       if ( ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&  // is not at the last column of CTU
    4357            ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) )  // is not at the last row    of CTU
    4358       {
    4359         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth + 1 ];
     4351    if (  ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[absPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
     4352      && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[absPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
     4353    {
     4354      if ( ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&  // is not at the last column of CTU
     4355        ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) )  // is not at the last row    of CTU
     4356      {
     4357        absPartAddr = g_auiRasterToZscan[ absPartIdx + numPartInCtuWidth + 1 ];
    43604358        ctuRsAddr = getCtuRsAddr();
    43614359      }
    4362       else if ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 )  // is not at the last column of CTU But is last row of CTU
    4363       {
    4364         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
    4365       }
    4366       else if ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU
    4367       {
    4368         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ];
     4360      else if ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 )  // is not at the last column of CTU But is last row of CTU
     4361      {
     4362        absPartAddr = g_auiRasterToZscan[ (absPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
     4363      }
     4364      else if ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU
     4365      {
     4366        absPartAddr = g_auiRasterToZscan[ absPartIdx + 1 ];
    43694367        ctuRsAddr = getCtuRsAddr() + 1;
    43704368      }
    43714369      else //is the right bottom corner of CTU
    43724370      {
    4373         uiAbsPartAddr = 0;
    4374       }
    4375     }
    4376     if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx_Col
     4371        absPartAddr = 0;
     4372      }
     4373    }
    43774374#if NH_3D_TMVP
    4378          , 0
    4379 #endif
    4380  ) )
     4375        if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col  , 0 ) )
     4376#else
     4377    if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col ) )
     4378#endif
    43814379    {
    43824380      pInfo->m_acMvCand[pInfo->iN++] = cColMv;
     
    43854383    {
    43864384      UInt uiPartIdxCenter;
    4387       xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter );
    4388       if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, iRefIdx_Col
     4385      xDeriveCenterIdx( partIdx, uiPartIdxCenter );
    43894386#if NH_3D_TMVP
    4390          , 0
    4391 #endif
    4392 ))
     4387      if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, refIdx_Col , 0 ))
     4388#else
     4389      if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, refIdx_Col ))
     4390#endif
    43934391      {
    43944392        pInfo->m_acMvCand[pInfo->iN++] = cColMv;
     
    43964394    }
    43974395    //----  co-located RightBottom Temporal Predictor  ---//
    4398   }
    4399 
    4400   if (pInfo->iN > AMVP_MAX_NUM_CANDS)
    4401   {
    4402     pInfo->iN = AMVP_MAX_NUM_CANDS;
    44034396  }
    44044397
     
    44124405
    44134406
    4414 Bool TComDataCU::isBipredRestriction(UInt puIdx)
     4407Bool TComDataCU::isBipredRestriction(UInt puIdx) const
    44154408{
    44164409  Int width = 0;
     
    44344427
    44354428
    4436 Void TComDataCU::clipMv    (TComMv&  rcMv)
     4429Void TComDataCU::clipMv    (TComMv&  rcMv) const
    44374430{
    44384431  const TComSPS &sps=*(m_pcSlice->getSPS());
     
    44704463#endif
    44714464
    4472 UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx)
     4465UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) const
    44734466{
    44744467  UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 );
     
    45074500 * \returns true if the current the block is skipped
    45084501 */
    4509 Bool TComDataCU::isSkipped( UInt uiPartIdx )
     4502Bool TComDataCU::isSkipped( UInt uiPartIdx ) const
    45104503{
    45114504  return ( getSkipFlag( uiPartIdx ) );
     
    45164509// ====================================================================================================================
    45174510
    4518 Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir )
    4519 {
    4520   TComDataCU* pcTmpCU = NULL;
    4521   UInt uiIdx;
     4511Bool TComDataCU::xAddMVPCandUnscaled( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const
     4512{
     4513  const TComDataCU* neibCU = NULL;
     4514  UInt neibPUPartIdx;
    45224515  switch( eDir )
    45234516  {
    45244517    case MD_LEFT:
    45254518    {
    4526       pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx);
     4519      neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx);
    45274520      break;
    45284521    }
    45294522    case MD_ABOVE:
    45304523    {
    4531       pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx);
     4524      neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx);
    45324525      break;
    45334526    }
    45344527    case MD_ABOVE_RIGHT:
    45354528    {
    4536       pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx);
     4529      neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx);
    45374530      break;
    45384531    }
    45394532    case MD_BELOW_LEFT:
    45404533    {
    4541       pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx);
     4534      neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx);
    45424535      break;
    45434536    }
    45444537    case MD_ABOVE_LEFT:
    45454538    {
    4546       pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx);
     4539      neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx);
    45474540      break;
    45484541    }
     
    45534546  }
    45544547
    4555   if ( pcTmpCU == NULL )
     4548  if ( neibCU == NULL )
    45564549  {
    45574550    return false;
    45584551  }
    45594552
    4560   if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ))
    4561   {
    4562     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    4563 
    4564     pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
    4565     return true;
    4566   }
    4567 
    4568   RefPicList eRefPicList2nd = REF_PIC_LIST_0;
    4569   if(       eRefPicList == REF_PIC_LIST_0 )
    4570   {
    4571     eRefPicList2nd = REF_PIC_LIST_1;
    4572   }
    4573   else if ( eRefPicList == REF_PIC_LIST_1)
    4574   {
    4575     eRefPicList2nd = REF_PIC_LIST_0;
    4576   }
    4577 
    4578 
    4579   Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
    4580   Int iNeibRefPOC;
    4581 
    4582 
    4583   if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 )
    4584   {
    4585     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
    4586     if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List//
    4587     {
    4588       TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
    4589       pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
     4553  const Int        currRefPOC     = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
     4554  const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     4555
     4556  for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list.
     4557  {
     4558    const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd;
     4559    const Int        neibRefIdx       = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx);
     4560
     4561    if ( neibRefIdx >= 0 && currRefPOC == neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx ))
     4562    {
     4563      info.m_acMvCand[info.iN++] = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx);
    45904564      return true;
    45914565    }
     
    46024576 * \returns Bool
    46034577 */
    4604 Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir )
    4605 {
    4606   TComDataCU* pcTmpCU = NULL;
    4607   UInt uiIdx;
     4578Bool TComDataCU::xAddMVPCandWithScaling( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const
     4579{
     4580  const TComDataCU* neibCU = NULL;
     4581  UInt neibPUPartIdx;
    46084582  switch( eDir )
    46094583  {
    46104584  case MD_LEFT:
    46114585    {
    4612       pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx);
     4586      neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx);
    46134587      break;
    46144588    }
    46154589  case MD_ABOVE:
    46164590    {
    4617       pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx);
     4591      neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx);
    46184592      break;
    46194593    }
    46204594  case MD_ABOVE_RIGHT:
    46214595    {
    4622       pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx);
     4596      neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx);
    46234597      break;
    46244598    }
    46254599  case MD_BELOW_LEFT:
    46264600    {
    4627       pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx);
     4601      neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx);
    46284602      break;
    46294603    }
    46304604  case MD_ABOVE_LEFT:
    46314605    {
    4632       pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx);
     4606      neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx);
    46334607      break;
    46344608    }
     
    46394613  }
    46404614
    4641   if ( pcTmpCU == NULL )
     4615  if ( neibCU == NULL )
    46424616  {
    46434617    return false;
    46444618  }
    46454619
    4646   RefPicList eRefPicList2nd = REF_PIC_LIST_0;
    4647   if(       eRefPicList == REF_PIC_LIST_0 )
    4648   {
    4649     eRefPicList2nd = REF_PIC_LIST_1;
    4650   }
    4651   else if ( eRefPicList == REF_PIC_LIST_1)
    4652   {
    4653     eRefPicList2nd = REF_PIC_LIST_0;
    4654   }
    4655 
    4656   Int iCurrPOC = m_pcSlice->getPOC();
    4657   Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
    4658   Int iNeibPOC = iCurrPOC;
    4659   Int iNeibRefPOC;
    4660   Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm();
    4661   Bool bIsNeibRefLongTerm = false;
    4662 
    4663   //---------------  V1 (END) ------------------//
    4664   if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0)
    4665   {
    4666     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) );
    4667     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    4668     TComMv rcMv;
    4669 
    4670     bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm();
    4671     if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
    4672     {
    4673       if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm )
    4674       {
    4675         rcMv = cMvPred;
    4676       }
    4677       else
    4678       {
    4679         Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC );
    4680         if ( iScale == 4096 )
     4620  const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     4621
     4622  const Int  currPOC            = m_pcSlice->getPOC();
     4623  const Int  currRefPOC         = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
     4624  const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm();
     4625  const Int  neibPOC            = currPOC;
     4626
     4627  for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list.
     4628  {
     4629    const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd;
     4630    const Int        neibRefIdx       = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx);
     4631    if( neibRefIdx >= 0)
     4632    {
     4633      const Bool bIsNeibRefLongTerm = neibCU->getSlice()->getRefPic( eRefPicListIndex, neibRefIdx )->getIsLongTerm();
     4634
     4635      if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
     4636      {
     4637        const TComMv &cMvPred = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx);
     4638        TComMv rcMv;
     4639        if ( bIsCurrRefLongTerm /* || bIsNeibRefLongTerm*/ )
    46814640        {
    46824641          rcMv = cMvPred;
     
    46844643        else
    46854644        {
    4686           rcMv = cMvPred.scaleMv( iScale );
     4645          const Int neibRefPOC = neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx );
     4646          const Int scale      = xGetDistScaleFactor( currPOC, currRefPOC, neibPOC, neibRefPOC );
     4647          if ( scale == 4096 )
     4648          {
     4649            rcMv = cMvPred;
     4650          }
     4651          else
     4652          {
     4653            rcMv = cMvPred.scaleMv( scale );
     4654          }
    46874655        }
    4688       }
    4689 
    4690       pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
    4691       return true;
    4692     }
    4693   }
    4694   //---------------------- V2(END) --------------------//
    4695   if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0)
    4696   {
    4697     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
    4698     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
    4699     TComMv rcMv;
    4700 
    4701     bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm();
    4702     if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
    4703     {
    4704       if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm )
    4705       {
    4706         rcMv = cMvPred;
    4707       }
    4708       else
    4709       {
    4710         Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC );
    4711         if ( iScale == 4096 )
    4712         {
    4713           rcMv = cMvPred;
    4714         }
    4715         else
    4716         {
    4717           rcMv = cMvPred.scaleMv( iScale );
    4718         }
    4719       }
    4720 
    4721       pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
    4722       return true;
    4723     }
    4724   }
    4725   //---------------------- V3(END) --------------------//
     4656
     4657        info.m_acMvCand[info.iN++] = rcMv;
     4658        return true;
     4659      }
     4660    }
     4661  }
    47264662  return false;
    47274663}
    47284664
    4729 Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
    47304665#if NH_3D_TMVP
    4731   , Bool bMRG
    4732 #endif
    4733 )
    4734 {
    4735   UInt uiAbsPartAddr = uiPartUnitIdx;
    4736 
    4737   RefPicList  eColRefPicList;
    4738   Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale;
    4739   TComMv cColMv;
     4666Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, Int& refIdx, Bool bMRG  ) const
     4667#else
     4668Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const
     4669#endif
     4670{
     4671  const UInt absPartAddr = partUnitIdx;
    47404672
    47414673  // use coldir.
    4742   TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
    4743   TComDataCU *pColCtu = pColPic->getCtu( ctuRsAddr );
    4744   if(pColCtu->getPic()==0||pColCtu->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES)
     4674  const TComPic    * const pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
     4675  const TComDataCU * const pColCtu = pColPic->getCtu( ctuRsAddr );
     4676  if(pColCtu->getPic()==0 || pColCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES)
    47454677  {
    47464678    return false;
    47474679  }
    4748   iCurrPOC = m_pcSlice->getPOC();
    4749   iColPOC = pColCtu->getSlice()->getPOC();
    4750 
    4751   if (!pColCtu->isInter(uiAbsPartAddr))
     4680
     4681  if (!pColCtu->isInter(absPartAddr))
    47524682  {
    47534683    return false;
    47544684  }
    47554685
    4756   eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag());
    4757 
    4758   Int iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);
     4686  RefPicList eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag());
     4687  Int iColRefIdx            = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
    47594688
    47604689  if (iColRefIdx < 0 )
    47614690  {
    47624691    eColRefPicList = RefPicList(1 - eColRefPicList);
    4763     iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);
     4692    iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
    47644693
    47654694    if (iColRefIdx < 0 )
     
    47694698  }
    47704699
    4771   // Scale the vector.
    4772   iColRefPOC = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
    4773   cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
    4774 
    4775   iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
    4776 
    4777   Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm();
    4778   Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
     4700#if NH_3D_TMVP
     4701  Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
     4702#else
     4703  const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
     4704#endif
     4705  const Bool bIsColRefLongTerm  = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
    47794706
    47804707  if ( bIsCurrRefLongTerm != bIsColRefLongTerm )
     
    47844711    if(bMRG && iAlterRefIdx > 0)
    47854712    {
    4786       riRefIdx = iAlterRefIdx;
    4787       bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm();
    4788       iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
     4713      refIdx = iAlterRefIdx;
     4714      bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
    47894715      assert(bIsCurrRefLongTerm == bIsColRefLongTerm);
    47904716    }
     
    47924718    {
    47934719#endif
    4794     return false;
     4720      return false;
    47954721#if NH_3D_TMVP
    47964722    }
    47974723#endif
    47984724  }
    4799 
     4725  // Scale the vector.
     4726  const TComMv &cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr);
     4727
     4728#if NH_3D_TMVP
    48004729  if ( bIsCurrRefLongTerm || bIsColRefLongTerm )
     4730#else
     4731  if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ )
     4732#endif
    48014733  {
    48024734#if NH_3D_TMVP
    4803     Int iCurrViewId    = m_pcSlice->getViewId ();
    4804     Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewId ();
    4805     Int iColViewId     = pColCtu->getSlice()->getViewId();
    4806     Int iColRefViewId  = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewId();
    4807     iScale = 4096;
     4735    const Int iCurrViewId    = m_pcSlice->getViewId ();
     4736    const Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, refIdx)->getViewId ();
     4737    const Int iColViewId     = pColCtu->getSlice()->getViewId();
     4738    const Int iColRefViewId  = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(absPartAddr))->getViewId();
     4739    Int scale = 4096;
    48084740    if ( iCurrRefViewId != iCurrViewId && iColViewId != iColRefViewId )
    48094741    {
    4810       iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId );
    4811     }
    4812     if ( bMRG && iScale != 4096 && m_pcSlice->getIvMvScalingFlag( ) )
    4813     {
    4814       rcMv = cColMv.scaleMv( iScale );
     4742      scale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId );
     4743    }
     4744    if ( bMRG && scale != 4096 && m_pcSlice->getIvMvScalingFlag( ) )
     4745    {
     4746      rcMv = cColMv.scaleMv( scale );
    48154747    }
    48164748    else
    48174749    {
    48184750#endif
    4819     rcMv = cColMv;
     4751      rcMv = cColMv;
    48204752#if NH_3D_TMVP
    48214753    }
     
    48244756  else
    48254757  {
    4826     iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC);
    4827     if ( iScale == 4096 )
     4758    const Int currPOC    = m_pcSlice->getPOC();
     4759    const Int colPOC     = pColCtu->getSlice()->getPOC();
     4760    const Int colRefPOC  = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
     4761    const Int currRefPOC = m_pcSlice->getRefPic(eRefPicList, refIdx)->getPOC();
     4762    const Int scale      = xGetDistScaleFactor(currPOC, currRefPOC, colPOC, colRefPOC);
     4763    if ( scale == 4096 )
    48284764    {
    48294765      rcMv = cColMv;
     
    48314767    else
    48324768    {
    4833       rcMv = cColMv.scaleMv( iScale );
     4769      rcMv = cColMv.scaleMv( scale );
    48344770    }
    48354771  }
     
    48384774}
    48394775
     4776// Static member
    48404777Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC)
    48414778{
     
    48574794}
    48584795
    4859 Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter )
     4796Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) const
    48604797{
    48614798  UInt uiPartAddr;
     
    50014938 
    50024939  UInt uiMidPart, uiPartNeighbor; 
    5003   TComDataCU* pcCUNeighbor;
     4940  const TComDataCU* pcCUNeighbor;
    50044941  Bool bDepAvail = false;
    50054942  Pel *pDepth  = this->getPic()->getPicYuvRec()->getAddr(COMPONENT_Y);
     
    51335070#if NH_3D_NBDV_REF
    51345071        TComPic* picDepth = NULL;   
    5135 #if H_3D_FCO_VSP_DONBDV_E0163
     5072#if H_3D_FCO
    51365073        picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    51375074        if ( picDepth->getPicYuvRec() != NULL  ) 
     
    51615098  UInt uiIdx = 0;
    51625099  Bool        bCheckMcpDv = false;   
    5163   TComDataCU* pcTmpCU     = NULL;
     5100  const TComDataCU* pcTmpCU     = NULL;
    51645101
    51655102  //// ******* Get disparity from left block ******* /////
     5103#if NH_3D_FIX_TICKET_91
     5104    pcTmpCU = getPULeft(uiIdx, uiPartIdxLB);
     5105#else
    51665106  pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
     5107#endif
    51675108  bCheckMcpDv = true;
    51685109  if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
     
    51995140          pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ];
    52005141#if NH_3D_NBDV_REF
    5201 #if H_3D_FCO_VSP_DONBDV_E0163
     5142#if H_3D_FCO
    52025143          TComPic* picDepth  = NULL;
    52035144
     
    52385179#if NH_3D_NBDV_REF
    52395180    TComPic* picDepth = NULL;
    5240 #if H_3D_FCO_VSP_DONBDV_E0163
     5181#if H_3D_FCO
    52415182    picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    52425183    if ( picDepth->getPicYuvRec() != NULL ) 
     
    53075248
    53085249
    5309 Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
     5250Bool TComDataCU::xCheckSpatialNBDV( const TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
    53105251#if NH_3D_NBDV_REF
    53115252, Bool bDepthRefine
     
    53325273          TComPic* picDepth = NULL;
    53335274          assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());           
    5334 #if H_3D_FCO_VSP_DONBDV_E0163
     5275#if H_3D_FCO
    53355276          picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    53365277          if ( picDepth->getPicYuvRec() != NULL ) 
     
    54665407    }
    54675408
    5468 #if NH_3D_FIX_NBDV_COL
    54695409    // The picture pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx) might not be in DPB anymore
    54705410    // So don't access it directly.
    54715411    iColRefViewIdx = pColCU->getSlice()->getVPS()->getViewOrderIdx( pColCU->getSlice()->getRefLayerId( eColRefPicList, iColRefIdx ) );       
    5472 #else
    5473     iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewIndex();
    5474 #endif
    54755412
    54765413
     
    60656002  Int depthRefViewIdx = pcCU->getDvInfo(partAddr).m_aVIdxCan;
    60666003 
    6067 #if H_3D_FCO_VSP_DONBDV_E0163
     6004#if H_3D_FCO
    60686005  TComPic* pRefPicBaseDepth = 0;
    60696006  Bool     bIsCurrDepthCoded = false;
     
    61006037  pcCU->clipMv(cDv);
    61016038
    6102 #if H_3D_FCO_VSP_DONBDV_E0163
     6039#if H_3D_FCO
    61036040  if ( bIsCurrDepthCoded )
    61046041  {
Note: See TracChangeset for help on using the changeset viewer.