Changeset 1413 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncSearch.cpp


Ignore:
Timestamp:
11 Jul 2018, 15:19:49 (6 years ago)
Author:
tech
Message:

Merged HTM-16.2-dev@1412

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    316316  const Pel* const  piRefSrch = rcStruct.piRefY + iSearchY * rcStruct.iYStride + iSearchX;
    317317
    318 #if NH_3D_IC
     318#if NH_3D
    319319  m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    320 #endif
    321 #if NH_3D_SDC_INTER
    322320  m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    323321#endif
     
    848846  const TComMv* pcMvRefine = (iFrac == 2 ? s_acMvRefineH : s_acMvRefineQ);
    849847
     848#if MCTS_ENC_CHECK
     849  UInt maxRefinements = 9;
     850  Int mvShift = 2;
     851
     852  // filter length of sub-sample generation filter to be considered
     853  const UInt LumaLTSampleOffset = 3;
     854  const UInt LumaRBSampleOffset = 4;
     855
     856  if (m_pcEncCfg->getTMCTSSEITileConstraint())
     857  {
     858    // if close to tile borders
     859    if ( pcPatternKey->getROIYPosX() + (baseRefMv.getHor() >> mvShift ) < pcPatternKey->getTileLeftTopPelPosX() +  LumaLTSampleOffset ||
     860         pcPatternKey->getROIYPosY() + (baseRefMv.getVer() >> mvShift ) < pcPatternKey->getTileLeftTopPelPosY() +  LumaLTSampleOffset ||
     861         pcPatternKey->getROIYPosX() + (baseRefMv.getHor() >> mvShift)  > pcPatternKey->getTileRightBottomPelPosX() - pcPatternKey->getROIYWidth() - LumaRBSampleOffset ||
     862         pcPatternKey->getROIYPosY() + (baseRefMv.getVer() >> mvShift)  > pcPatternKey->getTileRightBottomPelPosY() - pcPatternKey->getROIYHeight() - LumaRBSampleOffset 
     863       )
     864    {
     865      // only allow full pel positions to avoid filter dependency
     866      maxRefinements = 1;
     867    }
     868  } 
     869
     870  for (UInt i = 0; i < maxRefinements; i++)
     871#else
    850872  for (UInt i = 0; i < 9; i++)
     873#endif
    851874  {
    852875    TComMv cMvTest = pcMvRefine[i];
     
    868891
    869892    setDistParamComp(COMPONENT_Y);
    870 #if NH_3D_IC
     893#if NH_3D
    871894    m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    872 #endif
    873 #if NH_3D_SDC_INTER
    874895    m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    875896#endif
     
    10201041      if( !pcCU->getSlice()->isIntra() )
    10211042      {
    1022         if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
     1043        if (pcCU->getSlice()->getPPS()->getTransquantBypassEnabledFlag())
    10231044        {
    10241045          m_pcEntropyCoder->encodeCUTransquantBypassFlag( pcCU, 0, true );
    10251046        }
    10261047        m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
    1027 #if NH_3D_DIS
     1048#if NH_3D
    10281049        m_pcEntropyCoder->encodeDIS(pcCU, 0, true );
    10291050        if(!pcCU->getDISFlag(uiAbsPartIdx))
    10301051#endif
    1031         m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    1032       }
    1033 #if NH_3D_DIS
     1052          m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
     1053      }
     1054#if NH_3D
    10341055      else
    10351056      {
    10361057        m_pcEntropyCoder->encodeDIS(pcCU, 0, true );
    10371058      }
    1038 #endif
    1039 #if NH_3D_DIS
    10401059      if(!pcCU->getDISFlag(uiAbsPartIdx))
    10411060      {
    10421061#endif
    1043       m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    1044 
    1045       if (pcCU->isIntra(0) && pcCU->getPartitionSize(0) == SIZE_2Nx2N )
    1046       {
    1047         m_pcEntropyCoder->encodeIPCMInfo( pcCU, 0, true );
    1048 
    1049         if ( pcCU->getIPCMFlag (0))
    1050         {
    1051 #if NH_3D_SDC_INTRA
     1062        m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
     1063
     1064        if (pcCU->isIntra(0) && pcCU->getPartitionSize(0) == SIZE_2Nx2N )
     1065        {
     1066          m_pcEntropyCoder->encodeIPCMInfo( pcCU, 0, true );
     1067
     1068          if ( pcCU->getIPCMFlag (0))
     1069          {
     1070#if NH_3D
    10521071            m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    10531072#endif
    1054           return;
    1055         }
    1056       }
    1057 #if NH_3D_DIS
    1058     }
    1059 #endif
    1060   }
    1061 #if NH_3D_DIS
     1073            return;
     1074          }
     1075        }
     1076#if NH_3D
     1077      }
     1078#endif
     1079    }
     1080#if NH_3D
    10621081    if(!pcCU->getDISFlag(uiAbsPartIdx))
    10631082    {
    10641083#endif
    1065     // luma prediction mode
    1066     if( pcCU->getPartitionSize(0) == SIZE_2Nx2N )
    1067     {
    1068       if (uiAbsPartIdx==0)
    1069       {
    1070         m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, 0 );
    1071 #if NH_3D_SDC_INTRA
     1084      // luma prediction mode
     1085      if( pcCU->getPartitionSize(0) == SIZE_2Nx2N )
     1086      {
     1087        if (uiAbsPartIdx==0)
     1088        {
     1089          m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, 0 );
     1090#if NH_3D
    10721091          m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    1073 #if NH_3D_DMM
    10741092          if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( 0 ) ) && isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, 0 ) ) )
    10751093          {
     
    10771095          }
    10781096#endif
    1079 #endif
    1080       }
    1081     }
    1082     else
    1083     {
    1084       UInt uiQNumParts = pcCU->getTotalNumPart() >> 2;
    1085       if (uiTrDepth>0 && (uiAbsPartIdx%uiQNumParts)==0)
    1086       {
    1087         m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx );
    1088 #if NH_3D_SDC_INTRA
     1097        }
     1098      }
     1099      else
     1100      {
     1101        UInt uiQNumParts = pcCU->getTotalNumPart() >> 2;
     1102        if (uiTrDepth>0 && (uiAbsPartIdx%uiQNumParts)==0)
     1103        {
     1104          m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx );
     1105#if NH_3D
    10891106          if( uiAbsPartIdx == 0 ) 
    10901107          {
    10911108            m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    10921109          }
    1093 #if NH_3D_DMM
    10941110          if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( uiAbsPartIdx ) ) && isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ) ) )
    10951111          {
    10961112            m_pcEntropyCoder->encodeDeltaDC( pcCU, uiAbsPartIdx );
    10971113          }
    1098 #endif
    1099 #endif
    1100 #if NH_3D_DIS
    1101       }
     1114        }
    11021115#endif
    11031116      }
     
    11801193                                      DEBUG_STRING_FN_DECLARE(sDebug)
    11811194                                           ,Int         default0Save1Load2
    1182 #if NH_3D_ENC_DEPTH
     1195#if NH_3D
    11831196                                          , Bool        zeroResiFlag
    11841197#endif
     
    12531266
    12541267    //===== get prediction signal =====
    1255 #if NH_3D_DMM
     1268#if NH_3D
    12561269    if( bIsLuma && isDmmMode( uiChFinalMode ) )
    12571270    {
     
    12621275#endif
    12631276    predIntraAng( compID, uiChFinalMode, piOrg, uiStride, piPred, uiStride, rTu, bUseFilteredPredictions );
    1264 #if NH_3D_DMM
     1277#if NH_3D
    12651278    }
    12661279#endif
     
    13091322    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    13101323    {
    1311 #if NH_3D_ENC_DEPTH
     1324#if NH_3D
    13121325      if( zeroResiFlag )
    13131326      {
     
    13181331      {
    13191332#endif
    1320       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1321       {
    1322         pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
    1323       }
    1324 
    1325       pOrg  += uiStride;
    1326       pResi += uiStride;
    1327       pPred += uiStride;
    1328 #if NH_3D_ENC_DEPTH
    1329       }
    1330 #endif
    1331 
     1333        for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     1334        {
     1335          pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
     1336        }
     1337
     1338        pOrg  += uiStride;
     1339        pResi += uiStride;
     1340        pPred += uiStride;
     1341#if NH_3D
     1342      }
     1343#endif
    13321344    }
    13331345  }
     
    13531365  if( useTransformSkip ? m_pcEncCfg->getUseRDOQTS() : m_pcEncCfg->getUseRDOQ() )
    13541366  {
    1355     m_pcEntropyCoder->estimateBit( m_pcTrQuant->m_pcEstBitsSbac, uiWidth, uiHeight, chType );
     1367    COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, uiHeight, compID));
     1368    m_pcEntropyCoder->estimateBit( m_pcTrQuant->m_pcEstBitsSbac, uiWidth, uiHeight, chType, scanType );
    13561369  }
    13571370
     
    15181531                                    TComTU&     rTu
    15191532                                    DEBUG_STRING_FN_DECLARE(sDebug)
    1520 #if NH_3D_ENC_DEPTH
     1533#if NH_3D
    15211534                                  , Bool        zeroResiFlag
    15221535#endif                               
     
    15761589  }
    15771590#endif
    1578 #if NH_3D_DMM
     1591#if NH_3D
    15791592  if( isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ) ) )
    15801593  {
     
    17071720      //----- code luma/chroma block with given intra prediction mode and store Cbf-----
    17081721      dSingleCost   = 0.0;
    1709 #if NH_3D_ENC_DEPTH
     1722#if NH_3D
    17101723      xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDistLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sDebug), 0, zeroResiFlag );
    17111724#else
     
    18861899}
    18871900
    1888 #if NH_3D_DIS
     1901#if NH_3D
    18891902#if NH_3D_VSO
    18901903Void TEncSearch::xIntraCodingDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist&       ruiDist, Double& dRDCost, UInt uiPredMode )
     
    19841997    dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
    19851998}
    1986 #endif
    1987 #if NH_3D_SDC_INTRA
     1999
    19882000#if NH_3D_VSO
    19892001Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist&       ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi  )
     
    19912003Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Distortion& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi  )
    19922004#endif
    1993 
    1994 
    19952005{
    19962006  UInt uiWidth        = pcCU->getWidth ( 0 );
     
    20162026  Bool* pbMask = NULL;
    20172027  UInt uiMaskStride = 0;
    2018 #if NH_3D_DMM
     2028
    20192029  if( isDmmMode( uiLumaPredMode ) )
    20202030  {
     
    20642074  else // regular HEVC intra modes
    20652075  {
    2066 #endif
     2076
    20672077    uiNumSegments = 1;
    20682078   
     
    21252135    predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0;
    21262136    xCalcConstantSDC( piOrg, uiStride, uiWidth, apDCOrigValues[0] ); apDCOrigValues[1] = 0;
    2127 #if NH_3D_DMM 
    2128   }
    2129 #endif
     2137  }
    21302138
    21312139  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
     
    21342142    Pel pDCRec = ( !bZeroResidual ) ? apDCOrigValues[uiSegment] : apDCPredValues[uiSegment];
    21352143    // get residual (idx)
    2136 #if NH_3D_DLT
    21372144    Pel pResidualIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pDCRec ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    2138 #else
    2139     Pel pResidualIdx = pDCRec - apDCPredValues[uiSegment];
    2140 #endif
    21412145    if( !bZeroResidual )
    21422146    {
    2143 #if NH_3D_DLT
    21442147      Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    21452148      Int   pTestIdx    = pPredIdx + pResidualIdx + iSDCDeltaResi;
     
    21482151        pResidualIdx += iSDCDeltaResi;
    21492152      }
    2150 #else
    2151       pResidualIdx += iSDCDeltaResi;
    2152 #endif
    21532153    }
    21542154    // save SDC DC offset
     
    21602160  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    21612161  {
    2162 #if NH_3D_DLT
    21632162    Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    21642163    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
     
    21662165
    21672166    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
    2168 #else
    2169     apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    2170 #endif
    21712167  }
    21722168
     
    22122208  }
    22132209
    2214 #if NH_3D_DMM
    2215   if( pbMask ) { delete[] pbMask; }
    2216 #endif
     2210  if( pbMask )
     2211  {
     2212    delete[] pbMask;
     2213  }
    22172214
    22182215  //===== determine distortion ===== 
     
    22252222#endif
    22262223  {
    2227 #if NH_3D_FIX_INTRA_SDC_VSO_OFF
    22282224    ruiDist = m_pcRdCost->getDistPart( bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, COMPONENT_Y );
    2229 #else
    2230     ruiDist = m_pcRdCost->getDistPart( bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, COMPONENT_Y, DF_SAD );
    2231 #endif
    22322225  }
    22332226
     
    22382231  if( !pcCU->getSlice()->isIntra() )
    22392232  {
    2240     if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
     2233    if (pcCU->getSlice()->getPPS()->getTransquantBypassEnabledFlag())
    22412234    {
    22422235      m_pcEntropyCoder->encodeCUTransquantBypassFlag( pcCU, 0, true );
     
    27372730}
    27382731
    2739 #if NH_3D_DIS
     2732#if NH_3D
    27402733Void TEncSearch::estIntraPredDIS( TComDataCU* pcCU,
    27412734                                  TComYuv*    pcOrgYuv,
     
    27462739                                  Bool        bLumaOnly )
    27472740{
    2748 #if NH_MV
     2741
    27492742  D_PRINT_INC_INDENT(g_traceModeCheck, "estIntraPredDis");
    2750 #endif
    27512743
    27522744  UInt    uiDepth        = pcCU->getDepth(0);
     
    28282820                               Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE]
    28292821                               DEBUG_STRING_FN_DECLARE(sDebug)
    2830 #if NH_3D_ENC_DEPTH
     2822#if NH_3D
    28312823                             , Bool        bOnlyIVP
    28322824#endif
     
    29082900    assert (tuRecurseWithPU.ProcessComponentSection(COMPONENT_Y));
    29092901    initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, true DEBUG_STRING_PASS_INTO(sTemp2) );
    2910 #if NH_3D_ENC_DEPTH
     2902#if NH_3D
    29112903    if( bOnlyIVP )
    29122904    {
     
    29172909#endif
    29182910
    2919     Bool doFastSearch = (numModesForFullRD != numModesAvailable);
    2920     if (doFastSearch)
    2921     {
    2922       assert(numModesForFullRD < numModesAvailable);
    2923 
    2924       for( Int i=0; i < numModesForFullRD; i++ )
    2925       {
    2926         CandCostList[ i ] = MAX_DOUBLE;
    2927       }
    2928       CandNum = 0;
    2929 
     2911      Bool doFastSearch = (numModesForFullRD != numModesAvailable);
     2912      if (doFastSearch)
     2913      {
     2914        assert(numModesForFullRD < numModesAvailable);
     2915
     2916        for( Int i=0; i < numModesForFullRD; i++ )
     2917        {
     2918          CandCostList[ i ] = MAX_DOUBLE;
     2919        }
     2920        CandNum = 0;
     2921
     2922        const TComRectangle &puRect=tuRecurseWithPU.getRect(COMPONENT_Y);
     2923        const UInt uiAbsPartIdx=tuRecurseWithPU.GetAbsPartIdxTU();
     2924
     2925        Pel* piOrg         = pcOrgYuv ->getAddr( COMPONENT_Y, uiAbsPartIdx );
     2926        Pel* piPred        = pcPredYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
     2927        UInt uiStride      = pcPredYuv->getStride( COMPONENT_Y );
     2928        DistParam distParam;
     2929        const Bool bUseHadamard=pcCU->getCUTransquantBypass(0) == 0;
     2930        m_pcRdCost->setDistParam(distParam, sps.getBitDepth(CHANNEL_TYPE_LUMA), piOrg, uiStride, piPred, uiStride, puRect.width, puRect.height, bUseHadamard);
     2931
     2932#if NH_3D
     2933        distParam.bUseIC = false;
     2934        distParam.bUseSDCMRSAD = false;
     2935#endif
     2936        distParam.bApplyWeight = false;
     2937        for( Int modeIdx = 0; modeIdx < numModesAvailable; modeIdx++ )
     2938        {
     2939          UInt       uiMode = modeIdx;
     2940#if !NH_3D_VSO
     2941          Distortion uiSad  = 0;
     2942#endif
     2943#if NH_MV
     2944          D_PRINT_INC_INDENT(g_traceModeCheck, "preTest; uiMode " + n2s(uiMode) );
     2945#endif
     2946          const Bool bUseFilter=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
     2947
     2948          predIntraAng( COMPONENT_Y, uiMode, piOrg, uiStride, piPred, uiStride, tuRecurseWithPU, bUseFilter, TComPrediction::UseDPCMForFirstPassIntraEstimation(tuRecurseWithPU, uiMode) );
     2949#if NH_3D_VSO // M34
     2950          Dist uiSad;           
     2951          if ( m_pcRdCost->getUseVSO() )
     2952          {
     2953            if ( m_pcRdCost->getUseEstimatedVSD() )
     2954            {         
     2955              uiSad = (Dist) ( m_pcRdCost->getDistPartVSD( pcCU, uiPartOffset, distParam.bitDepth , piPred, uiStride, piOrg, uiStride, distParam.iCols, distParam.iRows, true ) );
     2956            }
     2957            else
     2958            {   
     2959              uiSad = m_pcRdCost->getDistPartVSO( pcCU, uiPartOffset, distParam.bitDepth , piPred, uiStride, piOrg, uiStride, distParam.iCols, distParam.iRows, true );
     2960            }
     2961          }
     2962          else
     2963          {
     2964            uiSad = distParam.DistFunc(&distParam);
     2965          }
     2966#else       
     2967          // use hadamard transform here
     2968          uiSad+=distParam.DistFunc(&distParam);
     2969#endif
     2970
     2971          UInt   iModeBits = 0;
     2972
     2973          // NB xModeBitsIntra will not affect the mode for chroma that may have already been pre-estimated.
     2974          iModeBits+=xModeBitsIntra( pcCU, uiMode, uiPartOffset, uiDepth, CHANNEL_TYPE_LUMA );
     2975
     2976#if NH_3D_VSO // M35
     2977          Double dLambda;
     2978          if ( m_pcRdCost->getUseLambdaScaleVSO() )
     2979          {
     2980            dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : sqrtLambdaForFirstPass;
     2981          }
     2982          else       
     2983          {
     2984            dLambda = m_pcRdCost->getSqrtLambda();       
     2985          }
     2986
     2987          Double cost      = (Double)uiSad + (Double)iModeBits * dLambda;
     2988#else
     2989          Double cost      = (Double)uiSad + (Double)iModeBits * sqrtLambdaForFirstPass;
     2990#endif
     2991
     2992#if DEBUG_INTRA_SEARCH_COSTS
     2993          std::cout << "1st pass mode " << uiMode << " SAD = " << uiSad << ", mode bits = " << iModeBits << ", cost = " << cost << "\n";
     2994#endif
     2995
     2996          CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
     2997#if NH_MV
     2998          D_DEC_INDENT( g_traceModeCheck );
     2999#endif
     3000        }
     3001
     3002        if (m_pcEncCfg->getFastUDIUseMPMEnabled())
     3003        {
     3004          Int uiPreds[NUM_MOST_PROBABLE_MODES] = {-1, -1, -1};
     3005
     3006          Int iMode = -1;
     3007          pcCU->getIntraDirPredictor( uiPartOffset, uiPreds, COMPONENT_Y, &iMode );
     3008
     3009          const Int numCand = ( iMode >= 0 ) ? iMode : Int(NUM_MOST_PROBABLE_MODES);
     3010
     3011          for( Int j=0; j < numCand; j++)
     3012          {
     3013            Bool mostProbableModeIncluded = false;
     3014            Int mostProbableMode = uiPreds[j];
     3015
     3016            for( Int i=0; i < numModesForFullRD; i++)
     3017            {
     3018              mostProbableModeIncluded |= (mostProbableMode == uiRdModeList[i]);
     3019            }
     3020            if (!mostProbableModeIncluded)
     3021            {
     3022              uiRdModeList[numModesForFullRD++] = mostProbableMode;
     3023            }
     3024          }
     3025        }
     3026      }
     3027      else
     3028      {
     3029        for( Int i=0; i < numModesForFullRD; i++)
     3030        {
     3031          uiRdModeList[i] = i;
     3032        }
     3033      }
     3034#if NH_3D
     3035    }
     3036    if( m_pcEncCfg->getIsDepth() )
     3037    {
    29303038      const TComRectangle &puRect=tuRecurseWithPU.getRect(COMPONENT_Y);
    29313039      const UInt uiAbsPartIdx=tuRecurseWithPU.GetAbsPartIdxTU();
     
    29343042      Pel* piPred        = pcPredYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
    29353043      UInt uiStride      = pcPredYuv->getStride( COMPONENT_Y );
    2936       DistParam distParam;
    2937       const Bool bUseHadamard=pcCU->getCUTransquantBypass(0) == 0;
    2938       m_pcRdCost->setDistParam(distParam, sps.getBitDepth(CHANNEL_TYPE_LUMA), piOrg, uiStride, piPred, uiStride, puRect.width, puRect.height, bUseHadamard);
    2939 
    2940 #if NH_3D
    2941       distParam.bUseIC = false;
    2942 #endif
    2943 #if NH_3D_SDC_INTER
    2944       distParam.bUseSDCMRSAD = false;
    2945 #endif
    2946       distParam.bApplyWeight = false;
    2947       for( Int modeIdx = 0; modeIdx < numModesAvailable; modeIdx++ )
    2948       {
    2949         UInt       uiMode = modeIdx;
    2950 #if !NH_3D_VSO
    2951         Distortion uiSad  = 0;
    2952 #endif
    2953 #if NH_MV
    2954         D_PRINT_INC_INDENT(g_traceModeCheck, "preTest; uiMode " + n2s(uiMode) );
    2955 #endif
    2956 
    2957         const Bool bUseFilter=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
    2958 
    2959         predIntraAng( COMPONENT_Y, uiMode, piOrg, uiStride, piPred, uiStride, tuRecurseWithPU, bUseFilter, TComPrediction::UseDPCMForFirstPassIntraEstimation(tuRecurseWithPU, uiMode) );
    2960 #if NH_3D_VSO // M34
    2961         Dist uiSad;           
    2962         if ( m_pcRdCost->getUseVSO() )
    2963         {
    2964           if ( m_pcRdCost->getUseEstimatedVSD() )
    2965           {         
    2966             uiSad = (Dist) ( m_pcRdCost->getDistPartVSD( pcCU, uiPartOffset, distParam.bitDepth , piPred, uiStride, piOrg, uiStride, distParam.iCols, distParam.iRows, true ) );
    2967           }
    2968           else
    2969           {   
    2970             uiSad = m_pcRdCost->getDistPartVSO( pcCU, uiPartOffset, distParam.bitDepth , piPred, uiStride, piOrg, uiStride, distParam.iCols, distParam.iRows, true );
    2971           }
    2972         }
    2973         else
    2974         {
    2975           uiSad = distParam.DistFunc(&distParam);
    2976         }
    2977 #else       
    2978         // use hadamard transform here
    2979         uiSad+=distParam.DistFunc(&distParam);
    2980 #endif
    2981 
    2982         UInt   iModeBits = 0;
    2983 
    2984         // NB xModeBitsIntra will not affect the mode for chroma that may have already been pre-estimated.
    2985         iModeBits+=xModeBitsIntra( pcCU, uiMode, uiPartOffset, uiDepth, CHANNEL_TYPE_LUMA );
    2986 
    2987 #if NH_3D_VSO // M35
    2988         Double dLambda;
    2989         if ( m_pcRdCost->getUseLambdaScaleVSO() )
    2990         {
    2991           dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : sqrtLambdaForFirstPass;
    2992         }
    2993         else       
    2994         {
    2995           dLambda = m_pcRdCost->getSqrtLambda();       
    2996         }
    2997 
    2998         Double cost      = (Double)uiSad + (Double)iModeBits * dLambda;
    2999 #else
    3000         Double cost      = (Double)uiSad + (Double)iModeBits * sqrtLambdaForFirstPass;
    3001 #endif
    3002 
    3003 #if DEBUG_INTRA_SEARCH_COSTS
    3004         std::cout << "1st pass mode " << uiMode << " SAD = " << uiSad << ", mode bits = " << iModeBits << ", cost = " << cost << "\n";
    3005 #endif
    3006 
    3007         CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
    3008 #if NH_MV
    3009         D_DEC_INDENT( g_traceModeCheck );
    3010 #endif
    3011       }
    3012 
    3013       if (m_pcEncCfg->getFastUDIUseMPMEnabled())
    3014       {
    3015       Int uiPreds[NUM_MOST_PROBABLE_MODES] = {-1, -1, -1};
    3016 
    3017       Int iMode = -1;
    3018       pcCU->getIntraDirPredictor( uiPartOffset, uiPreds, COMPONENT_Y, &iMode );
    3019 
    3020       const Int numCand = ( iMode >= 0 ) ? iMode : Int(NUM_MOST_PROBABLE_MODES);
    3021 
    3022       for( Int j=0; j < numCand; j++)
    3023       {
    3024         Bool mostProbableModeIncluded = false;
    3025         Int mostProbableMode = uiPreds[j];
    3026 
    3027         for( Int i=0; i < numModesForFullRD; i++)
    3028         {
    3029           mostProbableModeIncluded |= (mostProbableMode == uiRdModeList[i]);
    3030         }
    3031         if (!mostProbableModeIncluded)
    3032         {
    3033           uiRdModeList[numModesForFullRD++] = mostProbableMode;
    3034         }
    3035       }
    3036     }
    3037     }
    3038     else
    3039     {
    3040       for( Int i=0; i < numModesForFullRD; i++)
    3041       {
    3042         uiRdModeList[i] = i;
    3043       }
    3044     }
    3045 #if NH_3D_ENC_DEPTH
    3046     }
    3047 #endif
    3048 
    3049 #if NH_3D_DMM
    3050     if( m_pcEncCfg->getIsDepth() )
    3051     {
    3052       const TComRectangle &puRect=tuRecurseWithPU.getRect(COMPONENT_Y);
    3053       const UInt uiAbsPartIdx=tuRecurseWithPU.GetAbsPartIdxTU();
    3054 
    3055       Pel* piOrg         = pcOrgYuv ->getAddr( COMPONENT_Y, uiAbsPartIdx );
    3056       Pel* piPred        = pcPredYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
    3057       UInt uiStride      = pcPredYuv->getStride( COMPONENT_Y );
    30583044
    30593045      if( puRect.width >= DMM_MIN_SIZE && puRect.width <= DMM_MAX_SIZE &&  puRect.width == puRect.height &&
    3060           ((m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag()) || pcCU->getSlice()->getIntraContourFlag()) )
    3061       {
    3062 #if NH_3D_ENC_DEPTH
     3046        ((m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag()) || pcCU->getSlice()->getIntraContourFlag()) )
     3047      {
    30633048        if( bOnlyIVP )
    30643049        {
     
    30823067          if( uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold )
    30833068          {
    3084 #endif
    30853069            UInt startIdx = ( m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() ) ? 0 : 1;
    30863070            UInt endIdx   = (                             pcCU->getSlice()->getIntraContourFlag()  ) ? 1 : 0;
    30873071            for( UInt dmmType = startIdx; dmmType <= endIdx; dmmType++ )
    30883072            {
    3089 #if H_3D_FCO
    3090               if ( !(pcCU->getSlice()->getIvPic(false, pcCU->getSlice()->getViewIndex() )->getReconMark()) && (DMM4_IDX == dmmType ) ) { continue; }
    3091 #endif
    30923073              Bool* biSegPattern  = new Bool[ puRect.width*puRect.height ];
    30933074              UInt  patternStride = puRect.width;
     
    31143095                pcCU->setDmmDeltaDC( (DmmID)dmmType, 0, uiPartOffset, deltaDC1 );
    31153096                pcCU->setDmmDeltaDC( (DmmID)dmmType, 1, uiPartOffset, deltaDC2 );
    3116  
     3097
    31173098                uiRdModeList[ numModesForFullRD++ ] = (dmmType+DMM_OFFSET);
    31183099                delete[] biSegPattern;
    31193100              }
    31203101            }
    3121 #if NH_3D_ENC_DEPTH
    31223102          }
    31233103        }
    3124 #endif
    31253104      }
    31263105    }
     
    31343113    DEBUG_STRING_NEW(sPU)
    31353114    UInt       uiBestPUMode  = 0;
    3136 #if NH_3D_ENC_DEPTH
     3115#if NH_3D
    31373116    UInt    uiBestPUModeConv  = 0;
    31383117    UInt    uiSecondBestPUModeConv  = 0;
     
    31473126    Double     dBestPUCost   = MAX_DOUBLE;
    31483127
    3149 #if NH_3D_ENC_DEPTH
     3128#if NH_3D
    31503129    Double  dBestPUCostConv   = MAX_DOUBLE;
    31513130    UInt rdSDC = m_pcEncCfg->getIsDepth() ? numModesForFullRD : 0;
    3152 #endif
    3153 #if NH_3D_SDC_INTRA
    31543131    Bool    bBestUseSDC   = false;
    31553132    Pel     apBestDCOffsets[2] = {0,0};
    3156 #endif
    3157 #if NH_3D_ENC_DEPTH
    31583133    for( UInt uiMode = 0; uiMode < numModesForFullRD + rdSDC; uiMode++ )
    31593134#else
     
    31733148    {
    31743149      // set luma prediction mode
    3175 #if !NH_3D_ENC_DEPTH
     3150#if !NH_3D
    31763151      UInt uiOrgMode = uiRdModeList[uiMode];
    3177 #endif
    3178 
    3179 #if NH_3D_ENC_DEPTH
     3152#else
    31803153      UInt uiOrgMode;
    31813154      if (uiMode < numModesForFullRD)
     
    32143187      pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
    32153188
    3216 #if NH_3D_SDC_INTRA
    3217 #if NH_3D_ENC_DEPTH
     3189#if NH_3D
    32183190      Bool bTestSDC = ( ( m_pcEncCfg->getUseSDC() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() ) && pcCU->getSDCAvailable(uiPartOffset) && uiMode >= numModesForFullRD);
    3219 #else
    3220       Bool bTestSDC = ( m_pcEncCfg->getUseSDC() && pcCU->getSDCAvailable(uiPartOffset) );
    3221 #endif
    32223191
    32233192      for( UInt uiSDC=0; uiSDC<=(bTestSDC?1:0); uiSDC++ )
    32243193      {
    3225 #if NH_3D_ENC_DEPTH
    32263194        if (!uiSDC && uiMode >= numModesForFullRD) continue;
    3227 #endif
    32283195        pcCU->setSDCFlagSubParts( (uiSDC != 0), uiPartOffset, uiDepth + uiInitTrDepth );
    32293196        Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
     
    32583225            }
    32593226          }
    3260 #endif
    3261 #if NH_3D_ENC_DEPTH
    32623227          Bool zeroResiTest = (pcCU->getSlice()->getIsDepth() && !pcCU->getSlice()->isIRAP());
    3263 #if NH_3D_SDC_INTRA
    32643228          zeroResiTest = zeroResiTest || pcCU->getSDCFlag(uiPartOffset);
    32653229          if( uiSDC != 0 && iSDCDeltaResi != 0 )
     
    32673231            zeroResiTest = false;
    32683232          }
    3269 #endif
    32703233          for( UInt zeroResi = 0; zeroResi <= ( zeroResiTest ? 1 : 0 ); zeroResi++ )
    32713234          {
    32723235#endif
    3273       DEBUG_STRING_NEW(sMode)
    3274       // set context models
    3275       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    3276 
    3277       // determine residual for partition
     3236            DEBUG_STRING_NEW(sMode)
     3237              // set context models
     3238              m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
     3239
     3240            // determine residual for partition
    32783241#if NH_3D_VSO
    3279       Dist       uiPUDistY = 0;
     3242            Dist       uiPUDistY = 0;
    32803243#else
    3281       Distortion uiPUDistY = 0;
    3282 #endif
    3283       Double     dPUCost   = 0.0;
     3244            Distortion uiPUDistY = 0;
     3245#endif
     3246            Double     dPUCost   = 0.0;
    32843247#if NH_3D_VSO // M36
    3285       if( m_pcRdCost->getUseRenModel() )
    3286       {
    3287         m_pcRdCost->setRenModelData( pcCU, uiPartOffset, pcOrgYuv, &tuRecurseWithPU );
    3288       }
    3289 #endif
    3290 #if NH_3D_SDC_INTRA
     3248            if( m_pcRdCost->getUseRenModel() )
     3249            {
     3250              m_pcRdCost->setRenModelData( pcCU, uiPartOffset, pcOrgYuv, &tuRecurseWithPU );
     3251            }
     3252#endif
     3253#if NH_3D
    32913254            if( pcCU->getSDCFlag(uiPartOffset) )
    32923255            {
     
    33043267            {
    33053268#endif
    3306 
    33073269#if HHI_RQT_INTRA_SPEEDUP
    3308 #if NH_3D_ENC_DEPTH
    3309       xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, true, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode), (zeroResi != 0) );
    3310 #if NH_3D_ENC_DEPTH
     3270#if NH_3D
     3271              xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, true, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode), (zeroResi != 0) );
    33113272              if( dPUCost < dBestPUCostConv )
    33123273              {
     
    33163277                dBestPUCostConv   = dPUCost;
    33173278              }
    3318 #endif
    33193279#else
    3320       xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, true, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );
     3280              xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, true, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );
    33213281#endif
    33223282#else
    3323 #if NH_3D_ENC_DEPTH
    3324       xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode), (zeroResi != 0) );
     3283#if NH_3D
     3284              xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode), (zeroResi != 0) );
    33253285#else
    3326       xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );
    3327 #endif
    3328 #endif
    3329 #if NH_3D_SDC_INTRA
     3286              xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );
     3287#endif
     3288#endif
     3289#if NH_3D
    33303290            }
    33313291#endif
    33323292
    3333 
    33343293#if DEBUG_INTRA_SEARCH_COSTS
    3335       std::cout << "2nd pass [luma,chroma] mode [" << Int(pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiPartOffset)) << "," << Int(pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiPartOffset)) << "] cost = " << dPUCost << "\n";
    3336 #endif
    3337 
    3338       // check r-d cost
    3339       if( dPUCost < dBestPUCost )
    3340       {
    3341         DEBUG_STRING_SWAP(sPU, sMode)
     3294            std::cout << "2nd pass [luma,chroma] mode [" << Int(pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiPartOffset)) << "," << Int(pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiPartOffset)) << "] cost = " << dPUCost << "\n";
     3295#endif
     3296
     3297            // check r-d cost
     3298            if( dPUCost < dBestPUCost )
     3299            {
     3300              DEBUG_STRING_SWAP(sPU, sMode)
    33423301#if HHI_RQT_INTRA_SPEEDUP_MOD
    3343         uiSecondBestMode  = uiBestPUMode;
    3344         dSecondBestPUCost = dBestPUCost;
    3345 #endif
    3346         uiBestPUMode  = uiOrgMode;
    3347         uiBestPUDistY = uiPUDistY;
    3348         dBestPUCost   = dPUCost;
    3349 
    3350 #if NH_3D_SDC_INTRA
     3302                uiSecondBestMode  = uiBestPUMode;
     3303              dSecondBestPUCost = dBestPUCost;
     3304#endif
     3305              uiBestPUMode  = uiOrgMode;
     3306              uiBestPUDistY = uiPUDistY;
     3307              dBestPUCost   = dPUCost;
     3308
     3309#if NH_3D
    33513310              if( pcCU->getSDCFlag(uiPartOffset) )
    33523311              {
     
    33703329                bBestUseSDC = false;
    33713330#endif
     3331                xSetIntraResultLumaQT( pcRecoYuv, tuRecurseWithPU );
     3332
     3333                if (pps.getPpsRangeExtension().getCrossComponentPredictionEnabledFlag())
     3334                {
     3335                  const Int xOffset = tuRecurseWithPU.getRect( COMPONENT_Y ).x0;
     3336                  const Int yOffset = tuRecurseWithPU.getRect( COMPONENT_Y ).y0;
     3337                  for (UInt storedResidualIndex = 0; storedResidualIndex < NUMBER_OF_STORED_RESIDUAL_TYPES; storedResidualIndex++)
     3338                  {
     3339                    if (bMaintainResidual[storedResidualIndex])
     3340                    {
     3341                      xStoreCrossComponentPredictionResult(resiLuma[storedResidualIndex], resiLumaPU[storedResidualIndex], tuRecurseWithPU, xOffset, yOffset, MAX_CU_SIZE, MAX_CU_SIZE );
     3342                    }
     3343                  }
     3344                }
     3345
     3346                UInt uiQPartNum = tuRecurseWithPU.GetAbsPartIdxNumParts();
     3347
     3348                ::memcpy( m_puhQTTempTrIdx,  pcCU->getTransformIdx()       + uiPartOffset, uiQPartNum * sizeof( UChar ) );
     3349                for (UInt component = 0; component < numberValidComponents; component++)
     3350                {
     3351                  const ComponentID compID = ComponentID(component);
     3352                  ::memcpy( m_puhQTTempCbf[compID], pcCU->getCbf( compID  ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
     3353                  ::memcpy( m_puhQTTempTransformSkipFlag[compID],  pcCU->getTransformSkip(compID)  + uiPartOffset, uiQPartNum * sizeof( UChar ) );
     3354                }
     3355#if NH_3D
     3356              }
     3357#endif
     3358            }
     3359#if HHI_RQT_INTRA_SPEEDUP_MOD
     3360            else if( dPUCost < dSecondBestPUCost )
     3361            {
     3362              uiSecondBestMode  = uiOrgMode;
     3363              dSecondBestPUCost = dPUCost;
     3364            }
     3365#endif
     3366
     3367#if NH_3D
     3368          }
     3369        } // SDC residual loop
     3370      } // SDC loop
     3371#endif
     3372#if NH_MV
     3373      D_DEC_INDENT( g_traceModeCheck );
     3374#endif
     3375    } // Mode loop
     3376
     3377#if HHI_RQT_INTRA_SPEEDUP
     3378#if HHI_RQT_INTRA_SPEEDUP_MOD
     3379    for( UInt ui =0; ui < 2; ++ui )
     3380#endif
     3381    {
     3382#if HHI_RQT_INTRA_SPEEDUP_MOD
     3383      UInt uiOrgMode   = ui ? uiSecondBestMode  : uiBestPUMode;
     3384      if( uiOrgMode == MAX_UINT )
     3385      {
     3386        break;
     3387      }
     3388#else
     3389      UInt uiOrgMode = uiBestPUMode;
     3390#endif
     3391
     3392
     3393#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     3394      if (DebugOptionList::ForceLumaMode.isSet())
     3395      {
     3396        uiOrgMode = DebugOptionList::ForceLumaMode.getInt();
     3397      }
     3398#endif
     3399
     3400      pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
     3401#if NH_3D
     3402      pcCU->setSDCFlagSubParts(false, uiPartOffset, uiDepth + uiInitTrDepth);
     3403#endif
     3404
     3405      DEBUG_STRING_NEW(sModeTree)
     3406
     3407      // set context models
     3408      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
     3409
     3410      // determine residual for partition
     3411#if NH_3D_VSO
     3412      Dist       uiPUDistY = 0;
     3413#else
     3414      Distortion uiPUDistY = 0;
     3415#endif
     3416      Double     dPUCost   = 0.0;
     3417#if NH_3D_VSO // M37  //check if necessary
     3418      // reset Model
     3419      if( m_pcRdCost->getUseRenModel() )
     3420      {
     3421        m_pcRdCost->setRenModelData( pcCU, uiPartOffset, pcOrgYuv, &tuRecurseWithPU );       
     3422      }
     3423#endif
     3424
     3425      xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, false, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sModeTree));
     3426
     3427      // check r-d cost
     3428      if( dPUCost < dBestPUCost )
     3429      {
     3430        DEBUG_STRING_SWAP(sPU, sModeTree)
     3431        uiBestPUMode  = uiOrgMode;
     3432        uiBestPUDistY = uiPUDistY;
     3433        dBestPUCost   = dPUCost;
     3434#if NH_3D
     3435        bBestUseSDC   = false;
     3436#endif
     3437
     3438
    33723439        xSetIntraResultLumaQT( pcRecoYuv, tuRecurseWithPU );
    33733440
     
    33853452        }
    33863453
    3387         UInt uiQPartNum = tuRecurseWithPU.GetAbsPartIdxNumParts();
    3388 
     3454        const UInt uiQPartNum = tuRecurseWithPU.GetAbsPartIdxNumParts();
    33893455        ::memcpy( m_puhQTTempTrIdx,  pcCU->getTransformIdx()       + uiPartOffset, uiQPartNum * sizeof( UChar ) );
     3456
    33903457        for (UInt component = 0; component < numberValidComponents; component++)
    33913458        {
     
    33943461          ::memcpy( m_puhQTTempTransformSkipFlag[compID],  pcCU->getTransformSkip(compID)  + uiPartOffset, uiQPartNum * sizeof( UChar ) );
    33953462        }
    3396 #if NH_3D_SDC_INTRA
    3397         }
    3398 #endif
    3399       }
    3400 #if HHI_RQT_INTRA_SPEEDUP_MOD
    3401       else if( dPUCost < dSecondBestPUCost )
    3402       {
    3403         uiSecondBestMode  = uiOrgMode;
    3404         dSecondBestPUCost = dPUCost;
    3405       }
    3406 #endif
    3407 #if NH_3D_ENC_DEPTH
    3408           }
    3409 #endif
    3410 #if NH_3D_SDC_INTRA
    3411         } // SDC residual loop
    3412       } // SDC loop
    3413 #endif
    3414 #if NH_MV
    3415       D_DEC_INDENT( g_traceModeCheck );
    3416 #endif
    3417     } // Mode loop
    3418 
    3419 #if HHI_RQT_INTRA_SPEEDUP
    3420 #if HHI_RQT_INTRA_SPEEDUP_MOD
    3421     for( UInt ui =0; ui < 2; ++ui )
    3422 #endif
    3423     {
    3424 #if HHI_RQT_INTRA_SPEEDUP_MOD
    3425       UInt uiOrgMode   = ui ? uiSecondBestMode  : uiBestPUMode;
    3426       if( uiOrgMode == MAX_UINT )
    3427       {
    3428         break;
    3429       }
    3430 #else
    3431       UInt uiOrgMode = uiBestPUMode;
    3432 #endif
    3433 
    3434 
    3435 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
    3436       if (DebugOptionList::ForceLumaMode.isSet())
    3437       {
    3438         uiOrgMode = DebugOptionList::ForceLumaMode.getInt();
    3439       }
    3440 #endif
    3441 
    3442       pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
    3443 #if NH_3D_SDC_INTRA
    3444       pcCU->setSDCFlagSubParts(false, uiPartOffset, uiDepth + uiInitTrDepth);
    3445 #endif
    3446 
    3447       DEBUG_STRING_NEW(sModeTree)
    3448 
    3449       // set context models
    3450       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    3451 
    3452       // determine residual for partition
    3453 #if NH_3D_VSO
    3454       Dist       uiPUDistY = 0;
    3455 #else
    3456       Distortion uiPUDistY = 0;
    3457 #endif
    3458       Double     dPUCost   = 0.0;
    3459 #if NH_3D_VSO // M37  //check if necessary
    3460       // reset Model
    3461       if( m_pcRdCost->getUseRenModel() )
    3462       {
    3463         m_pcRdCost->setRenModelData( pcCU, uiPartOffset, pcOrgYuv, &tuRecurseWithPU );       
    3464       }
    3465 #endif
    3466 
    3467       xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, false, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sModeTree));
    3468 
    3469       // check r-d cost
    3470       if( dPUCost < dBestPUCost )
    3471       {
    3472         DEBUG_STRING_SWAP(sPU, sModeTree)
    3473         uiBestPUMode  = uiOrgMode;
    3474         uiBestPUDistY = uiPUDistY;
    3475         dBestPUCost   = dPUCost;
    3476 #if NH_3D_SDC_INTRA
    3477         bBestUseSDC   = false;
    3478 #endif
    3479 
    3480 
    3481         xSetIntraResultLumaQT( pcRecoYuv, tuRecurseWithPU );
    3482 
    3483         if (pps.getPpsRangeExtension().getCrossComponentPredictionEnabledFlag())
    3484         {
    3485           const Int xOffset = tuRecurseWithPU.getRect( COMPONENT_Y ).x0;
    3486           const Int yOffset = tuRecurseWithPU.getRect( COMPONENT_Y ).y0;
    3487           for (UInt storedResidualIndex = 0; storedResidualIndex < NUMBER_OF_STORED_RESIDUAL_TYPES; storedResidualIndex++)
    3488           {
    3489             if (bMaintainResidual[storedResidualIndex])
    3490             {
    3491               xStoreCrossComponentPredictionResult(resiLuma[storedResidualIndex], resiLumaPU[storedResidualIndex], tuRecurseWithPU, xOffset, yOffset, MAX_CU_SIZE, MAX_CU_SIZE );
    3492             }
    3493           }
    3494         }
    3495 
    3496         const UInt uiQPartNum = tuRecurseWithPU.GetAbsPartIdxNumParts();
    3497         ::memcpy( m_puhQTTempTrIdx,  pcCU->getTransformIdx()       + uiPartOffset, uiQPartNum * sizeof( UChar ) );
    3498 
    3499         for (UInt component = 0; component < numberValidComponents; component++)
    3500         {
    3501           const ComponentID compID = ComponentID(component);
    3502           ::memcpy( m_puhQTTempCbf[compID], pcCU->getCbf( compID  ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
    3503           ::memcpy( m_puhQTTempTransformSkipFlag[compID],  pcCU->getTransformSkip(compID)  + uiPartOffset, uiQPartNum * sizeof( UChar ) );
    3504         }
    35053463      }
    35063464    } // Mode loop
     
    35113469    //--- update overall distortion ---
    35123470    uiOverallDistY += uiBestPUDistY;
    3513 #if NH_3D_SDC_INTRA
     3471#if NH_3D
    35143472    if( bBestUseSDC )
    35153473    {
     
    35333491      ::memcpy( pcCU->getCbf( compID  ) + uiPartOffset, m_puhQTTempCbf[compID], uiQPartNum * sizeof( UChar ) );
    35343492      ::memcpy( pcCU->getTransformSkip( compID  ) + uiPartOffset, m_puhQTTempTransformSkipFlag[compID ], uiQPartNum * sizeof( UChar ) );
    3535 #if NH_3D_SDC_INTRA
     3493#if NH_3D
    35363494    }
    35373495#endif
     
    35703528    //=== update PU data ====
    35713529    pcCU->setIntraDirSubParts     ( CHANNEL_TYPE_LUMA, uiBestPUMode, uiPartOffset, uiDepth + uiInitTrDepth );
    3572 #if NH_3D_SDC_INTRA
     3530#if NH_3D
    35733531    pcCU->setSDCFlagSubParts          ( bBestUseSDC, uiPartOffset, uiDepth + uiInitTrDepth );
    35743532#endif
     
    38953853                            iWidth, iHeight, m_pcEncCfg->getUseHADME() && (pcCU->getCUTransquantBypass(iPartIdx) == 0) );
    38963854
    3897 #if NH_3D_IC
     3855#if NH_3D
    38983856  cDistParam.bUseIC = false;
    3899 #endif
    3900 #if NH_3D_SDC_INTER
    39013857  cDistParam.bUseSDCMRSAD = false;
    39023858#endif
     
    39073863//! estimation of best merge coding
    39083864Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, Distortion& ruiCost, TComMvField* cMvFieldNeighbours, UChar* uhInterDirNeighbours, Int& numValidMergeCand
    3909 #if NH_3D_VSP
    3910                                  , Int* vspFlag
    3911 #endif
    3912 #if NH_3D_SPIVMP
    3913                                  , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
     3865#if NH_3D
     3866                                 , Int* vspFlag, Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    39143867#endif
    39153868)
     
    39263879  UInt uiDepth = pcCU->getDepth( uiAbsPartIdx );
    39273880
    3928 #if NH_3D_DBBP
     3881#if NH_3D
    39293882  DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
    39303883  if( pcCU->getDBBPFlag(0) )
     
    39583911
    39593912  PartSize partSize = pcCU->getPartitionSize( 0 );
    3960 #if NH_3D_DBBP
     3913#if NH_3D
    39613914  if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && partSize != SIZE_2Nx2N && pcCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(0) == false )
    39623915#else
     
    39673920    {
    39683921      pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set
    3969 #if NH_3D_MLC
     3922#if NH_3D
    39703923      pcCU->initAvailableFlags();
     3924#if MCTS_ENC_CHECK
     3925      UInt numSpatialMergeCandidates = 0;
     3926      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, numSpatialMergeCandidates );
     3927      if (m_pcEncCfg->getTMCTSSEITileConstraint() && pcCU->isLastColumnCTUInTile())
     3928      {
     3929        numValidMergeCand = numSpatialMergeCandidates;
     3930      }
     3931#else
    39713932      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    3972       pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
    3973 #if NH_3D_SPIVMP
    3974         , pcMvFieldSP, puhInterDirSP
    3975 #endif
    3976         , numValidMergeCand
    3977         );
    3978 
    3979       pcCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
    3980 #if NH_3D_VSP
    3981         , vspFlag
    3982 #endif
    3983 #if NH_3D_SPIVMP
    3984         , pbSPIVMPFlag
    3985 #endif
    3986         , numValidMergeCand
    3987         );
     3933#endif
     3934      pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours , pcMvFieldSP, puhInterDirSP, numValidMergeCand );
     3935      pcCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours , vspFlag, pbSPIVMPFlag, numValidMergeCand );
     3936#else
     3937#if MCTS_ENC_CHECK
     3938      UInt numSpatialMergeCandidates = 0;
     3939      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, numSpatialMergeCandidates );
     3940      if (m_pcEncCfg->getTMCTSSEITileConstraint() && pcCU->isLastColumnCTUInTile())
     3941      {
     3942        numValidMergeCand = numSpatialMergeCandidates;
     3943      }
    39883944#else
    39893945      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    39903946#endif
     3947#endif
    39913948      pcCU->setPartSizeSubParts( partSize, 0, uiDepth ); // restore
    39923949    }
     
    39943951  else
    39953952  {
    3996 #if NH_3D_MLC
     3953#if NH_3D
    39973954    pcCU->initAvailableFlags();
     3955#if MCTS_ENC_CHECK
     3956    UInt numSpatialMergeCandidates = 0;
     3957    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, numSpatialMergeCandidates );
     3958    if (m_pcEncCfg->getTMCTSSEITileConstraint() && pcCU->isLastColumnCTUInTile())
     3959    {
     3960      numValidMergeCand = numSpatialMergeCandidates;
     3961    }
     3962#else
    39983963    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    3999     pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
    4000 #if NH_3D_SPIVMP
    4001       , pcMvFieldSP, puhInterDirSP
    4002 #endif
    4003       , numValidMergeCand
    4004       );
    4005 
    4006     pcCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
    4007 #if NH_3D_VSP
    4008       , vspFlag
    4009 #endif
    4010 #if NH_3D_SPIVMP
    4011       , pbSPIVMPFlag
    4012 #endif
    4013       , numValidMergeCand
    4014       );
     3964#endif
     3965    pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, pcMvFieldSP, puhInterDirSP , numValidMergeCand      );
     3966    pcCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours , vspFlag, pbSPIVMPFlag, numValidMergeCand );
     3967#else
     3968#if MCTS_ENC_CHECK
     3969    UInt numSpatialMergeCandidates = 0;
     3970    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, numSpatialMergeCandidates );
     3971    if (m_pcEncCfg->getTMCTSSEITileConstraint() && pcCU->isLastColumnCTUInTile())
     3972    {
     3973      numValidMergeCand = numSpatialMergeCandidates;
     3974    }
    40153975#else
    40163976    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    40173977#endif
     3978#endif
    40183979  }
    40193980
    40203981  xRestrictBipredMergeCand( pcCU, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    40213982
    4022 #if NH_3D_DBBP
     3983#if NH_3D
    40233984  if( pcCU->getDBBPFlag(0) )
    40243985  {
     
    40464007
    40474008    PartSize ePartSize = pcCU->getPartitionSize( 0 );
    4048 #if NH_3D_VSP
     4009#if NH_3D
    40494010    pcCU->setVSPFlagSubParts( vspFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
    4050 #endif
    4051 
    4052 #if NH_3D_SPIVMP
     4011
    40534012    pcCU->setSPIVMPFlagSubParts( pbSPIVMPFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ));
    40544013    if (pbSPIVMPFlag[uiMergeCand])
     
    40684027    }
    40694028    else
    4070 #endif
    4071 #if NH_3D_VSP
    4072 #if NH_3D_DBBP
    40734029      if ( vspFlag[uiMergeCand] && !pcCU->getDBBPFlag(0) )
    4074 #else
    4075       if ( vspFlag[uiMergeCand] )
    4076 #endif
    40774030      {
    40784031        UInt partAddr;
     
    41034056      {
    41044057#endif
    4105 
    4106     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    4107     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    4108 #if NH_3D_VSP
    4109       }
    4110 #endif
    4111 
    4112 
     4058        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
     4059        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
     4060#if NH_3D
     4061      }
     4062#endif
    41134063    xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
    41144064    uiBitsCand = uiMergeCand + 1;
     
    42334183  Distortion   biPDistTemp = std::numeric_limits<Distortion>::max();
    42344184
    4235 #if NH_3D_IV_MERGE
     4185#if NH_3D
    42364186  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    42374187  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     
    42724222
    42734223    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    4274 #if NH_3D_VSP
     4224#if NH_3D
    42754225    pcCU->setVSPFlagSubParts( 0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr) );
    42764226#endif
     
    46294579    } // end if bTestNormalMC
    46304580#endif
    4631 #if NH_3D_DBBP
     4581#if NH_3D
    46324582    // test merge mode for DBBP (2Nx2N)
    46334583    if ( pcCU->getPartitionSize( uiPartAddr ) != SIZE_2Nx2N || pcCU->getDBBPFlag(0) )
     
    46724622      Distortion uiMRGCost = std::numeric_limits<Distortion>::max();
    46734623
    4674 #if NH_3D_VSP
     4624#if NH_3D
    46754625      Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    46764626      memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
     
    46804630      pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight );
    46814631      DisInfo OriginalDvInfo = pcCU->getDvInfo(uiAbsPartIdx);
    4682 #endif
    4683 #if NH_3D_SPIVMP
     4632
    46844633      Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    46854634      memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
     
    46904639#endif
    46914640      xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand
    4692 #if NH_3D_VSP
    4693                       , vspFlag
    4694 #endif
    4695 #if NH_3D_SPIVMP
    4696                       , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
     4641#if NH_3D
     4642                      , vspFlag , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
    46974643#endif
    46984644                      );
     
    47034649        pcCU->setMergeFlagSubParts ( true,          uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    47044650        pcCU->setMergeIndexSubParts( uiMRGIndex,    uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4705 #if NH_3D_VSP
     4651#if NH_3D
    47064652        pcCU->setVSPFlagSubParts( vspFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4707 #endif
    4708 #if NH_3D_SPIVMP
    47094653        pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
    47104654        if (bSPIVMPFlag[uiMRGIndex]!=0)
     
    47284672        }
    47294673        else
    4730 #endif
    4731 #if NH_3D_VSP
    4732 #if NH_3D_DBBP
    4733         if ( vspFlag[uiMRGIndex] && !pcCU->getDBBPFlag(uiPartAddr) )
    4734 #else
    4735         if ( vspFlag[uiMRGIndex] )
    4736 #endif
    4737         {
    4738           UInt partAddrTemp;
    4739           Int vspSize;
    4740           Int width, height;
    4741           pcCU->getPartIndexAndSize( iPartIdx, partAddrTemp, width, height ); // true or pcCU->getTotalNumPart()==256
    4742           if( uiMRGInterDir & 0x01 )
     4674          if ( vspFlag[uiMRGIndex] && !pcCU->getDBBPFlag(uiPartAddr) )
    47434675          {
    4744             pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_0, cMRGMvField[0].getRefIdx(), vspSize );
    4745             pcCU->setVSPFlag( partAddrTemp, vspSize );
     4676            UInt partAddrTemp;
     4677            Int vspSize;
     4678            Int width, height;
     4679            pcCU->getPartIndexAndSize( iPartIdx, partAddrTemp, width, height ); // true or pcCU->getTotalNumPart()==256
     4680            if( uiMRGInterDir & 0x01 )
     4681            {
     4682              pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_0, cMRGMvField[0].getRefIdx(), vspSize );
     4683              pcCU->setVSPFlag( partAddrTemp, vspSize );
     4684            }
     4685            else
     4686            {
     4687              pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
     4688            }
     4689            if( uiMRGInterDir & 0x02 )
     4690            {
     4691              pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_1, cMRGMvField[1].getRefIdx(), vspSize );
     4692              pcCU->setVSPFlag( partAddrTemp, vspSize );
     4693            }
     4694            else
     4695            {
     4696              pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
     4697            }
     4698            pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    47464699          }
    47474700          else
    47484701          {
     4702#endif
     4703            pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    47494704            pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
     4705            pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
     4706#if NH_3D
    47504707          }
    4751           if( uiMRGInterDir & 0x02 )
    4752           {
    4753             pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_1, cMRGMvField[1].getRefIdx(), vspSize );
    4754             pcCU->setVSPFlag( partAddrTemp, vspSize );
    4755           }
    4756           else
    4757           {
    4758             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    4759           }
    4760           pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4761         }
    4762         else
    4763           {
    4764 #endif
    4765         pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4766         pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    4767         pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    4768 #if NH_3D_VSP
    4769           }
    4770 #endif
    4771 #if H_3D
    4772           }
    4773 #endif
    4774         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
    4775         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
    4776 
    4777         pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    4778         pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    4779         pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    4780         pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     4708#endif
     4709          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
     4710          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
     4711
     4712          pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     4713          pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     4714          pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     4715          pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    47814716      }
    47824717      else
    47834718      {
    4784 #if NH_3D_SPIVMP       
     4719#if NH_3D
    47854720        pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    47864721#endif
     
    47884723        pcCU->setMergeFlagSubParts( false,        uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    47894724        pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4790 #if NH_3D_VSP
     4725#if NH_3D
    47914726        pcCU->setVSPFlagSubParts ( 0,             uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    47924727        pcCU->setDvInfoSubParts(OriginalDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
     
    47954730        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    47964731      }
    4797 #if NH_3D_SPIVMP
     4732#if NH_3D
    47984733      delete[] pcMvFieldSP;
    47994734      delete[] puhInterDirSP;
    48004735#endif
    48014736    }
     4737
     4738#if MCTS_ENC_CHECK
     4739    if (m_pcEncCfg->getTMCTSSEITileConstraint() && (!checkTMctsMvp(pcCU, iPartIdx)))
     4740    {
     4741      pcCU->setTMctsMvpIsValid(false);
     4742      return;
     4743    }
     4744#endif
    48024745
    48034746    //  MC
     
    48344777  Int        iRoiWidth, iRoiHeight;
    48354778  Int        i;
     4779  Int        minMVPCand;
     4780  Int        maxMVPCand;
    48364781
    48374782  pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
     
    48404785  {
    48414786
    4842 #if NH_3D_DBBP
     4787#if NH_3D
    48434788    DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
    48444789    if( pcCU->getDBBPFlag(0) )
     
    48724817
    48734818    pcCU->fillMvpCand( uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pcAMVPInfo );
    4874 #if NH_3D_DBBP
     4819#if NH_3D
    48754820    if( pcCU->getDBBPFlag(0) )
    48764821    {
     
    48894834
    48904835  // initialize Mvp index & Mvp
     4836#if MCTS_ENC_CHECK
     4837  if (m_pcEncCfg->getTMCTSSEITileConstraint() && pcCU->isLastColumnCTUInTile() && (pcAMVPInfo->numSpatialMVPCandidates < pcAMVPInfo->iN))
     4838  {
     4839    iBestIdx    = (pcAMVPInfo->numSpatialMVPCandidates == 0) ? 1 : 0;
     4840    cBestMv     = pcAMVPInfo->m_acMvCand[(pcAMVPInfo->numSpatialMVPCandidates == 0) ? 1 : 0];
     4841    minMVPCand  = (pcAMVPInfo->numSpatialMVPCandidates == 0) ? 1 : 0;
     4842    maxMVPCand  = (pcAMVPInfo->numSpatialMVPCandidates == 0) ? pcAMVPInfo->iN : 1;
     4843  }
     4844  else
     4845  {
     4846    iBestIdx = 0;
     4847    cBestMv  = pcAMVPInfo->m_acMvCand[0];
     4848    minMVPCand  = 0;
     4849    maxMVPCand  = pcAMVPInfo->iN;
     4850  }
     4851#else
    48914852  iBestIdx = 0;
    48924853  cBestMv  = pcAMVPInfo->m_acMvCand[0];
     4854  minMVPCand  = 0;
     4855  maxMVPCand  = pcAMVPInfo->iN;
     4856#endif
     4857
    48934858  if (pcAMVPInfo->iN <= 1)
    48944859  {
     
    49224887  m_cYuvPredTemp.clear();
    49234888  //-- Check Minimum Cost.
    4924   for ( i = 0 ; i < pcAMVPInfo->iN; i++)
     4889  for ( i = minMVPCand ; i < maxMVPCand; i++)
    49254890  {
    49264891#if NH_MV
     
    50645029  Int iBestMvBits = iOrgMvBits;
    50655030
     5031#if MCTS_ENC_CHECK
     5032  Int minMVPCand = 0;
     5033  Int maxMVPCand = pcAMVPInfo->iN;
     5034
     5035  if (m_pcEncCfg->getTMCTSSEITileConstraint() && pcCU->isLastColumnCTUInTile())
     5036  {
     5037    minMVPCand = (pcAMVPInfo->numSpatialMVPCandidates == 0) ? 1 : 0;
     5038    maxMVPCand = (pcAMVPInfo->numSpatialMVPCandidates == 0) ? pcAMVPInfo->iN : 1;
     5039  }
     5040  for (Int iMVPIdx = minMVPCand; iMVPIdx < maxMVPCand; iMVPIdx++)
     5041#else
    50665042  for (Int iMVPIdx = 0; iMVPIdx < pcAMVPInfo->iN; iMVPIdx++)
     5043#endif
    50675044  {
    50685045    if (iMVPIdx == riMVPIdx)
     
    51145091  pcCU->clipMv( cMvCand );
    51155092
    5116 #if NH_3D_IC
     5093#if NH_3D
    51175094  Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() );
    51185095#endif
     
    51225099  {
    51235100    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA)
    5124 #if NH_3D_ARP
     5101#if NH_3D
    51255102      , false //add this for IC, otherwise, it could be removed
    51265103#endif
     
    51305107  {
    51315108    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA)
    5132 #if NH_3D_ARP
    5133       , false
    5134 #endif
    5135 #if NH_3D_IC
    5136     , bICFlag
    5137 #endif
    5138 
     5109#if NH_3D
     5110      , false, bICFlag
     5111#endif
    51395112);
    51405113  }
     
    51755148
    51765149  Int           iSrchRng      = ( bBi ? m_bipredSearchRange : m_iSearchRange );
    5177   TComPattern   tmpPattern;
    5178   TComPattern*  pcPatternKey  = &tmpPattern;
     5150  TComPattern   cPattern;
    51795151
    51805152  Double        fWeight       = 1.0;
     
    51825154  pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    51835155
    5184 #if NH_3D_IC
     5156#if NH_3D
    51855157  Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getViewIndex() );
    5186   pcPatternKey->setICFlag( bICFlag );
    5187 #endif
    5188 #if NH_3D_SDC_INTER
    5189    pcPatternKey->setSDCMRSADFlag( pcCU->getSlice()->getInterSdcFlag() );
     5158  cPattern.setICFlag( bICFlag );
     5159  cPattern.setSDCMRSADFlag( pcCU->getSlice()->getInterSdcFlag() );
    51905160#endif
    51915161
     
    52045174
    52055175  //  Search key pattern initialization
    5206   pcPatternKey->initPattern( pcYuv->getAddr  ( COMPONENT_Y, uiPartAddr ),
     5176#if MCTS_ENC_CHECK
     5177  Int roiPosX, roiPosY;
     5178  Int roiW, roiH;
     5179  pcCU->getPartPosition(iPartIdx, roiPosX, roiPosY, roiW, roiH);
     5180  assert(roiW == iRoiWidth);
     5181  assert(roiH == iRoiHeight);
     5182  cPattern.initPattern( pcYuv->getAddr(COMPONENT_Y, uiPartAddr),
     5183                        iRoiWidth,
     5184                        iRoiHeight,
     5185                        pcYuv->getStride(COMPONENT_Y),
     5186                        pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA),
     5187                        roiPosX,
     5188                        roiPosY);
     5189  xInitTileBorders(pcCU, &cPattern);
     5190#else
     5191  cPattern.initPattern( pcYuv->getAddr  ( COMPONENT_Y, uiPartAddr ),
    52075192                             iRoiWidth,
    52085193                             iRoiHeight,
    52095194                             pcYuv->getStride(COMPONENT_Y),
    52105195                             pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
    5211 
     5196#endif
    52125197  Pel*        piRefY      = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiPartAddr );
    52135198  Int         iRefStride  = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getPicYuvRec()->getStride(COMPONENT_Y);
     
    52205205  if ( bBi )
    52215206  {
     5207#if MCTS_ENC_CHECK
     5208    xSetSearchRange(pcCU, rcMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, &cPattern);
     5209#else
    52225210    xSetSearchRange   ( pcCU, rcMv   , iSrchRng, cMvSrchRngLT, cMvSrchRngRB );
     5211#endif
    52235212  }
    52245213  else
    52255214  {
     5215#if MCTS_ENC_CHECK
     5216    xSetSearchRange(pcCU, cMvPred, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, &cPattern);
     5217#else
    52265218    xSetSearchRange   ( pcCU, cMvPred, iSrchRng, cMvSrchRngLT, cMvSrchRngRB );
     5219#endif
    52275220  }
    52285221
     
    52305223
    52315224  m_pcRdCost->setPredictor  ( *pcMvPred );
    5232 #if NH_3D_INTEGER_MV_DEPTH
     5225#if NH_3D
    52335226  if( pcCU->getSlice()->getIsDepth() )
    52345227  {
     
    52395232#endif
    52405233    m_pcRdCost->setCostScale  ( 2 );   
    5241 #if NH_3D_INTEGER_MV_DEPTH
     5234#if NH_3D
    52425235  }
    52435236#endif
     
    52485241  if ( (m_motionEstimationSearchMethod==MESEARCH_FULL) || bBi )
    52495242  {
    5250     xPatternSearch      ( pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
     5243    xPatternSearch      ( &cPattern, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
    52515244  }
    52525245  else
    52535246  {
    52545247    rcMv = *pcMvPred;
    5255 #if NH_MV_FIX_VERT_MV_REST
     5248#if NH_MV
    52565249    if ( m_vertRestriction )
    52575250    {
     
    52675260      pIntegerMv2Nx2NPred = &(m_integerMv2Nx2N[eRefPicList][iRefIdxPred]);
    52685261    }
    5269     xPatternSearchFast  ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost, pIntegerMv2Nx2NPred );
     5262    xPatternSearchFast  ( pcCU, &cPattern, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost, pIntegerMv2Nx2NPred );
    52705263    if (pcCU->getPartitionSize(0) == SIZE_2Nx2N)
    52715264    {
     
    52755268
    52765269  m_pcRdCost->selectMotionLambda( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) );
    5277 #if NH_3D_INTEGER_MV_DEPTH
     5270#if NH_3D
    52785271  if( ! pcCU->getSlice()->getIsDepth() )
    52795272  {
    52805273#endif
    5281   m_pcRdCost->setCostScale ( 1 );
    5282 
    5283   const Bool bIsLosslessCoded = pcCU->getCUTransquantBypass(uiPartAddr) != 0;
    5284   xPatternSearchFracDIF( bIsLosslessCoded, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost );
    5285 
    5286   m_pcRdCost->setCostScale( 0 );
    5287   rcMv <<= 2;
    5288   rcMv += (cMvHalf <<= 1);
    5289   rcMv +=  cMvQter;
    5290 #if NH_3D_INTEGER_MV_DEPTH
     5274    m_pcRdCost->setCostScale ( 1 );
     5275
     5276    const Bool bIsLosslessCoded = pcCU->getCUTransquantBypass(uiPartAddr) != 0;
     5277    xPatternSearchFracDIF( bIsLosslessCoded, &cPattern, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost );
     5278
     5279    m_pcRdCost->setCostScale( 0 );
     5280    rcMv <<= 2;
     5281    rcMv += (cMvHalf <<= 1);
     5282    rcMv +=  cMvQter;
     5283#if NH_3D
    52915284  }
    52925285#endif
    52935286
    52945287  UInt uiMvBits = m_pcRdCost->getBitsOfVectorWithPredictor( rcMv.getHor(), rcMv.getVer() );
    5295 #if NH_3D_INTEGER_MV_DEPTH
     5288#if NH_3D
    52965289  if( pcCU->getSlice()->getIsDepth() )
    52975290  {
     
    53085301}
    53095302
     5303#if MCTS_ENC_CHECK
     5304Void TEncSearch::xInitTileBorders(const TComDataCU* const pcCU, TComPattern* pcPatternKey)
     5305{
     5306  if (m_pcEncCfg->getTMCTSSEITileConstraint())
     5307  {
     5308    UInt  tileXPosInCtus = 0;
     5309    UInt  tileYPosInCtus = 0;
     5310    UInt  tileWidthtInCtus = 0;
     5311    UInt  tileHeightInCtus = 0;
     5312
     5313    getTilePosition(pcCU, tileXPosInCtus, tileYPosInCtus, tileWidthtInCtus, tileHeightInCtus);
     5314
     5315    const Int  ctuLength = pcCU->getPic()->getPicSym()->getSPS().getMaxCUWidth();
     5316
     5317    // tile position in full pels
     5318    const Int tileLeftTopPelPosX = ctuLength * tileXPosInCtus;
     5319    const Int tileLeftTopPelPosY = ctuLength * tileYPosInCtus;
     5320    const Int tileRightBottomPelPosX = ((tileWidthtInCtus + tileXPosInCtus) * ctuLength) - 1;
     5321    const Int tileRightBottomPelPosY = ((tileHeightInCtus + tileYPosInCtus) * ctuLength) - 1;
     5322
     5323    pcPatternKey->setTileBorders (tileLeftTopPelPosX,tileLeftTopPelPosY,tileRightBottomPelPosX,tileRightBottomPelPosY);
     5324  }
     5325}
     5326#endif
    53105327
    53115328Void TEncSearch::xSetSearchRange ( const TComDataCU* const pcCU, const TComMv& cMvPred, const Int iSrchRng,
     5329#if MCTS_ENC_CHECK
     5330                                   TComMv& rcMvSrchRngLT, TComMv& rcMvSrchRngRB, const TComPattern* const pcPatternKey )
     5331#else
    53125332                                   TComMv& rcMvSrchRngLT, TComMv& rcMvSrchRngRB )
     5333#endif
    53135334{
    53145335  Int  iMvShift = 2;
    5315 #if NH_3D_INTEGER_MV_DEPTH
     5336#if NH_3D
    53165337  if( pcCU->getSlice()->getIsDepth() )
    53175338  {
     
    53225343  pcCU->clipMv( cTmpMvPred );
    53235344
     5345#if MCTS_ENC_CHECK
     5346  if (m_pcEncCfg->getTMCTSSEITileConstraint())
     5347  {
     5348    const Int lRangeXLeft = max(cTmpMvPred.getHor() - (iSrchRng << iMvShift), (pcPatternKey->getTileLeftTopPelPosX() - pcPatternKey->getROIYPosX()) << iMvShift);
     5349    const Int lRangeYTop = max(cTmpMvPred.getVer() - (iSrchRng << iMvShift), (pcPatternKey->getTileLeftTopPelPosY() - pcPatternKey->getROIYPosY()) << iMvShift);
     5350    const Int lRangeXRight = min(cTmpMvPred.getHor() + (iSrchRng << iMvShift), (pcPatternKey->getTileRightBottomPelPosX() - (pcPatternKey->getROIYPosX() + pcPatternKey->getROIYWidth())) << iMvShift);
     5351    const Int lRangeYBottom = min(cTmpMvPred.getVer() + (iSrchRng << iMvShift), (pcPatternKey->getTileRightBottomPelPosY() - (pcPatternKey->getROIYPosY() + pcPatternKey->getROIYHeight())) << iMvShift);
     5352
     5353    rcMvSrchRngLT.setHor(lRangeXLeft);
     5354    rcMvSrchRngLT.setVer(lRangeYTop);
     5355
     5356    rcMvSrchRngRB.setHor(lRangeXRight);
     5357    rcMvSrchRngRB.setVer(lRangeYBottom);
     5358  }
     5359  else
     5360  {
     5361    rcMvSrchRngLT.setHor(cTmpMvPred.getHor() - (iSrchRng << iMvShift));
     5362    rcMvSrchRngLT.setVer(cTmpMvPred.getVer() - (iSrchRng << iMvShift));
     5363
     5364    rcMvSrchRngRB.setHor( cTmpMvPred.getHor() + (iSrchRng << iMvShift));
     5365    rcMvSrchRngRB.setVer( cTmpMvPred.getVer() + (iSrchRng << iMvShift) );
     5366  }
     5367#else
    53245368  rcMvSrchRngLT.setHor( cTmpMvPred.getHor() - (iSrchRng << iMvShift) );
    53255369  rcMvSrchRngLT.setVer( cTmpMvPred.getVer() - (iSrchRng << iMvShift) );
     
    53275371  rcMvSrchRngRB.setHor( cTmpMvPred.getHor() + (iSrchRng << iMvShift) );
    53285372  rcMvSrchRngRB.setVer( cTmpMvPred.getVer() + (iSrchRng << iMvShift) );
    5329  
     5373  #endif
    53305374#if NH_MV
    53315375  if ( m_vertRestriction )
     
    53945438      m_cDistParam.bitDepth = pcPatternKey->getBitDepthY();
    53955439
    5396 #if NH_3D_IC
     5440#if NH_3D
    53975441      m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    5398 #endif
    5399 #if NH_3D_SDC_INTER
    54005442      m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    54015443#endif
     
    55005542  UInt uiSearchRange = m_iSearchRange;
    55015543  pcCU->clipMv( rcMv );
    5502 #if NH_3D_INTEGER_MV_DEPTH
     5544#if NH_3D
    55035545  if( ! pcCU->getSlice()->getIsDepth() )
    55045546#endif
     
    55255567      TComMv cMv = m_acMvPredictors[index];
    55265568      pcCU->clipMv( cMv );
    5527 #if NH_3D_INTEGER_MV_DEPTH
     5569#if NH_3D
    55285570      if( ! pcCU->getSlice()->getIsDepth() )
    55295571      {     
    55305572#endif
    55315573#if ME_ENABLE_ROUNDING_OF_MVS
    5532       cMv.divideByPowerOf2(2);
     5574        cMv.divideByPowerOf2(2);
    55335575#else
    5534       cMv >>= 2;
    5535 #endif
    5536 
    5537 #if NH_3D_INTEGER_MV_DEPTH
     5576        cMv >>= 2;
     5577#endif
     5578
     5579#if NH_3D
    55385580      }
    55395581#endif
     
    55855627    TComMv currBestMv(cStruct.iBestX, cStruct.iBestY );
    55865628    currBestMv <<= 2;
     5629#if MCTS_ENC_CHECK
     5630    xSetSearchRange(pcCU, currBestMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, pcPatternKey);
     5631#else
    55875632    xSetSearchRange( pcCU, currBestMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB );
     5633#endif
    55885634    iSrchRngHorLeft   = cMvSrchRngLT.getHor();
    55895635    iSrchRngHorRight  = cMvSrchRngRB.getHor();
     
    58755921    TComMv currBestMv(cStruct.iBestX, cStruct.iBestY );
    58765922    currBestMv <<= 2;
     5923#if MCTS_ENC_CHECK
     5924    xSetSearchRange(pcCU, currBestMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, pcPatternKey);
     5925#else
    58775926    xSetSearchRange( pcCU, currBestMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB );
     5927#endif
    58785928    iSrchRngHorLeft   = cMvSrchRngLT.getHor();
    58795929    iSrchRngHorRight  = cMvSrchRngRB.getHor();
     
    59766026                          pcPatternKey->getROIYHeight(),
    59776027                          iRefStride,
     6028#if MCTS_ENC_CHECK
     6029                          pcPatternKey->getBitDepthY(),
     6030                          pcPatternKey->getROIYPosX(),
     6031                          pcPatternKey->getROIYPosY());
     6032#else
    59786033                          pcPatternKey->getBitDepthY());
     6034#endif
     6035#if MCTS_ENC_CHECK
     6036  cPatternRoi.setTileBorders(pcPatternKey->getTileLeftTopPelPosX(), pcPatternKey->getTileLeftTopPelPosY(), pcPatternKey->getTileRightBottomPelPosX(), pcPatternKey->getTileRightBottomPelPosY());
     6037#endif
    59796038
    59806039  //  Half-pel refinement
     
    60526111    m_pcEntropyCoder->resetBits();
    60536112
    6054     if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
     6113    if (pcCU->getSlice()->getPPS()->getTransquantBypassEnabledFlag())
    60556114    {
    60566115      m_pcEntropyCoder->encodeCUTransquantBypassFlag(pcCU, 0, true);
     
    60596118    m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
    60606119    m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, true );
    6061 #if NH_3D_ARP
     6120#if NH_3D
    60626121    m_pcEntropyCoder->encodeARPW( pcCU, 0 );
    6063 #endif
    6064 #if NH_3D_IC
    60656122    m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    60666123#endif
     
    61766233  const Double zeroCost     = (pcCU->isLosslessCoded( 0 )) ? (nonZeroCost+1) : (m_pcRdCost->calcRdCost( zeroResiBits, zeroDistortion ));
    61776234#endif
    6178 #if NH_3D_SPIVMP
     6235#if NH_3D
    61796236    if ( zeroCost < nonZeroCost || pcCU->getQtRootCbf(0)==0)
    61806237#else
     
    62726329}
    62736330
    6274 #if NH_3D_SDC_INTER
     6331#if NH_3D
    62756332Void TEncSearch::encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, TComYuv* pcRec, Int uiOffest, const UInt uiDepth )
    62766333{
     
    66006657              if ((compID != COMPONENT_Cr) && ((transformSkipModeId == 1) ? m_pcEncCfg->getUseRDOQTS() : m_pcEncCfg->getUseRDOQ()))
    66016658              {
    6602                 m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, tuCompRect.width, tuCompRect.height, toChannelType(compID));
     6659                COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(pcCU->getCoefScanIdx(uiAbsPartIdx, tuCompRect.width, tuCompRect.height, compID));
     6660                m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, tuCompRect.width, tuCompRect.height, toChannelType(compID), scanType);
    66036661              }
    66046662
     
    73657423  // Reload only contexts required for coding intra mode information
    73667424  m_pcRDGoOnSbacCoder->loadIntraDirMode( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST], chType );
    7367 #if NH_3D_DMM
     7425#if NH_3D
    73687426  if( pcCU->getSlice()->getIsDepth() && isLuma(chType) )
    73697427  {
     
    74427500
    74437501    m_pcEntropyCoder->resetBits();
    7444     if(pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
     7502    if(pcCU->getSlice()->getPPS()->getTransquantBypassEnabledFlag())
    74457503    {
    74467504      m_pcEntropyCoder->encodeCUTransquantBypassFlag(pcCU, 0, true);
     
    74487506    m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
    74497507    m_pcEntropyCoder->encodeMergeIndex(pcCU, 0, true);
    7450 #if NH_3D_ARP
     7508#if NH_3D
    74517509    m_pcEntropyCoder->encodeARPW( pcCU, 0 );
    7452 #endif
    7453 #if NH_3D_IC
    74547510    m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    74557511#endif
     
    74607516    m_pcEntropyCoder->resetBits();
    74617517
    7462     if(pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
     7518    if(pcCU->getSlice()->getPPS()->getTransquantBypassEnabledFlag())
    74637519    {
    74647520      m_pcEntropyCoder->encodeCUTransquantBypassFlag(pcCU, 0, true);
     
    74667522
    74677523    m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true );
    7468 #if NH_3D_DIS
     7524#if NH_3D
    74697525    m_pcEntropyCoder->encodeDIS ( pcCU, 0, true );
    74707526#endif
     
    74727528    m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    74737529    m_pcEntropyCoder->encodePredInfo( pcCU, 0 );
    7474 #if NH_3D_SDC_INTRA
     7530#if NH_3D
    74757531    m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    7476 #endif
    7477 #if NH_3D_ARP
    74787532    m_pcEntropyCoder->encodeARPW( pcCU , 0  );
    7479 #endif
    7480 #if NH_3D_IC
    74817533    m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    7482 #endif
    7483 #if NH_3D_DBBP
    74847534    m_pcEntropyCoder->encodeDBBPFlag( pcCU, 0, true );
    74857535#endif
     
    77527802}
    77537803
    7754 #if NH_3D_DMM
     7804#if NH_3D
    77557805  // -------------------------------------------------------------------------------------------------------------------
    77567806  // Depth intra search
     
    79077957#endif
    79087958
    7909 #if NH_3D_DLT
    79107959  rDeltaDC1 = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipBD(predDC1 + rDeltaDC1, bitDepthY )) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 );
    79117960  rDeltaDC2 = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipBD(predDC2 + rDeltaDC2, bitDepthY )) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 );
    7912 #endif
    79137961}
    79147962
     
    80278075}
    80288076
    8029 #endif
    8030 #if NH_3D_SDC_INTRA
    80318077Void TEncSearch::xCalcConstantSDC( Pel* ptrSrc, UInt srcStride, UInt uiSize, Pel& valDC )
    80328078{
Note: See TracChangeset for help on using the changeset viewer.