Index: /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp	(revision 558)
+++ /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp	(revision 559)
@@ -5256,4 +5256,77 @@
 }
 #endif 
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+Void 
+TComDataCU::getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD)
+{
+  TComSlice*    pcSlice         = getSlice ();  
+  Int iViewIndex = pDInfo->m_aVIdxCan;
+  //--- get base CU/PU and check prediction mode ---
+  TComPic*    pcBasePic   = pcSlice->getIvPic( false, iViewIndex );
+  TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
+
+  UInt          uiPartAddr;
+  Int           iWidth;
+  Int           iHeight;
+  getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
+
+  Int  iCurrPosX, iCurrPosY;
+  pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
+
+  iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
+  iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
+
+  Bool depthRefineFlag = false; 
+#if H_3D_NBDV_REF
+  depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); 
+#endif // H_3D_NBDV_REF
+
+  TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 
+
+  Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
+  Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 
+  Int         iBaseLPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) );
+  Int         iBaseLPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 
+  Int         iBaseRPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) );
+  Int         iBaseRPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 
+  Int         iBaseUPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
+  Int         iBaseUPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 )); 
+  Int         iBaseDPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
+  Int         iBaseDPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 )); 
+
+  Int         iBaseCUAddr;
+  Int         iBaseAbsPartIdx;
+  Int         iBaseLCUAddr;
+  Int         iBaseLAbsPartIdx;
+  Int         iBaseRCUAddr;
+  Int         iBaseRAbsPartIdx;
+  Int         iBaseUCUAddr;
+  Int         iBaseUAbsPartIdx;
+  Int         iBaseDCUAddr;
+  Int         iBaseDAbsPartIdx;
+  pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
+  pcBaseRec->getCUAddrAndPartIdx( iBaseLPosX , iBaseLPosY , iBaseLCUAddr, iBaseLAbsPartIdx );
+  pcBaseRec->getCUAddrAndPartIdx( iBaseRPosX , iBaseRPosY , iBaseRCUAddr, iBaseRAbsPartIdx );
+  pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx );
+  pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx );
+  TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+  TComDataCU* pcBaseLCU    = pcBasePic->getCU( iBaseLCUAddr );
+  TComDataCU* pcBaseRCU    = pcBasePic->getCU( iBaseRCUAddr );
+  TComDataCU* pcBaseUCU    = pcBasePic->getCU( iBaseUCUAddr );
+  TComDataCU* pcBaseDCU    = pcBasePic->getCU( iBaseDCUAddr );
+  bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx );
+  Int aiDepthL[5]; //depth level
+  aiDepthL[0] = pcBaseCU->getDepth(iBaseAbsPartIdx);
+  aiDepthL[1] = pcBaseLCU->getDepth(iBaseLAbsPartIdx);
+  aiDepthL[2] = pcBaseRCU->getDepth(iBaseRAbsPartIdx);
+  aiDepthL[3] = pcBaseUCU->getDepth(iBaseUAbsPartIdx);
+  aiDepthL[4] = pcBaseDCU->getDepth(iBaseDAbsPartIdx);
+  for (Int i = 0; i < 5; i++)
+  {
+    if (iIVFMaxD < aiDepthL[i])
+      iIVFMaxD = aiDepthL[i];
+  }
+}
+#endif
 #if H_3D_IV_MERGE
 Bool
Index: /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TComDataCU.h	(revision 558)
+++ /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TComDataCU.h	(revision 559)
@@ -485,4 +485,7 @@
 #endif //H_3D_NBDV_REF
 #endif
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+  Void          getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge,  Int& iIVFMaxD);
+#endif
 #if H_3D_IV_MERGE
   Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc );   
Index: /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TypeDef.h	(revision 558)
+++ /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TypeDef.h	(revision 559)
@@ -97,5 +97,5 @@
                                               // Full Pel Interpolation for Depth, HHI_FULL_PEL_DEPTH_MAP_MV_ACC
 #define SHARP_ILLUCOMP_REFINE_E0046       1
-
+#define MTK_FAST_TEXTURE_ENCODING_E0173   1   // Fast merge mode decision and early CU determination for texture component of dependent view, JCT3V-E0173
 
 #if H_3D_NBDV
Index: /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp	(revision 558)
+++ /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp	(revision 559)
@@ -481,4 +481,9 @@
   if(!bSliceEnd && !bSliceStart && bInsidePicture )
   {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+    Bool bIVFMerge = false;
+    Int  iIVFMaxD = 0;
+    Bool bFMD = false;
+#endif
     for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
     {
@@ -555,4 +560,13 @@
         }
       }
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+      if(rpcTempCU->getSlice()->getViewIndex() && !rpcTempCU->getSlice()->getIsDepth())
+      {
+        PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
+        rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); 
+        rpcTempCU->getIVNStatus( 0, &DvInfo,  bIVFMerge, iIVFMaxD);
+        rpcTempCU->setPartSizeSubParts( ePartTemp, 0, uiDepth );
+      }
+#endif
 #endif
       // do inter modes, SKIP and 2Nx2N
@@ -570,5 +584,9 @@
           rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
 #endif
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP );//by Competition for inter_2Nx2N
+#else
           xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );  rpcTempCU->initEstData( uiDepth, iQP );//by Competition for inter_2Nx2N
+#endif
         }
         // SKIP
@@ -577,4 +595,7 @@
 #endif
         xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+        bFMD = bIVFMerge && rpcBestCU->isSkipped(0);
+#endif
         rpcTempCU->initEstData( uiDepth, iQP );
 
@@ -598,5 +619,9 @@
             rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
 #endif
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP );
+#else
             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );  rpcTempCU->initEstData( uiDepth, iQP );
+#endif
             if(m_pcEncCfg->getUseCbfFastMode())
             {
@@ -677,5 +702,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFMD  );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN   );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
               }
@@ -690,5 +719,9 @@
             )
           {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N, bFMD  );
+#else
             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N  );
+#endif
             rpcTempCU->initEstData( uiDepth, iQP );
             if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N )
@@ -703,5 +736,9 @@
             )
           {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+            xCheckRDCostInter      ( rpcBestCU, rpcTempCU, SIZE_2NxN, bFMD  );
+#else
             xCheckRDCostInter      ( rpcBestCU, rpcTempCU, SIZE_2NxN  );
+#endif
             rpcTempCU->initEstData( uiDepth, iQP );
             if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN)
@@ -735,5 +772,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
                 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
@@ -748,5 +789,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
                 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
@@ -765,5 +810,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD, true );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
                 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
@@ -778,5 +827,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD, true );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
                 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
@@ -797,5 +850,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
                 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
@@ -810,5 +867,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
               }
@@ -823,5 +884,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD, true );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
                 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
@@ -836,5 +901,9 @@
                 )
               {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD, true );
+#else
                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true );
+#endif
                 rpcTempCU->initEstData( uiDepth, iQP );
               }
@@ -868,5 +937,8 @@
 #endif
         }
-
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+        if(!bFMD)
+        {
+#endif
         // do normal intra modes
 #if H_3D_DIM_ENC
@@ -924,4 +996,7 @@
           }
         }
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+        }
+#endif
         if (isAddLowestQP && (iQP == lowestQP))
         {
@@ -966,4 +1041,10 @@
       bSubBranch = true;
     }
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+    if(rpcBestCU->getSlice()->getViewIndex() && !rpcBestCU->getSlice()->getIsDepth() && (uiDepth >=iIVFMaxD) && rpcBestCU->isSkipped(0))
+    {
+      bSubBranch = false;
+    }
+#endif
   }
   else if(!(bSliceEnd && bInsidePicture))
@@ -1786,9 +1867,17 @@
 
 #if AMP_MRG
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bFMD, Bool bUseMRG)
+#else
 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG)
+#endif
 #else
 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize )
 #endif
 {
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+  if(!(bFMD && (ePartSize == SIZE_2Nx2N)))  //have  motion estimation or merge check
+  {
+#endif
   UChar uhDepth = rpcTempCU->getDepth( 0 );
 #if H_3D_ARP
@@ -1864,5 +1953,9 @@
 #if AMP_MRG
   rpcTempCU->setMergeAMP (true);
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bFMD, false, bUseMRG );
+#else
   m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG );
+#endif
 #else  
   m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
@@ -1930,4 +2023,7 @@
   }
 #endif
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+  }
+#endif
 }
 
Index: /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncCu.h	(revision 558)
+++ /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncCu.h	(revision 559)
@@ -145,5 +145,9 @@
 
 #if AMP_MRG
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize,  Bool bFMD, Bool bUseMRG = false  ) ;
+#else
   Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG = false  );
+#endif
 #else
   Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
Index: /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 558)
+++ /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 559)
@@ -3654,5 +3654,9 @@
  */
 #if AMP_MRG
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bFMD, Bool bUseRes, Bool bUseMRG )
+#else
 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
+#endif
 #else
 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes )
@@ -3762,6 +3766,9 @@
 #if AMP_MRG
     Bool bTestNormalMC = true;
-    
+#if  MTK_FAST_TEXTURE_ENCODING_E0173
+    if (bFMD||( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 ))
+#else            
     if ( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 )
+#endif
     {
       bTestNormalMC = false;
Index: /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncSearch.h	(revision 558)
+++ /branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibEncoder/TEncSearch.h	(revision 559)
@@ -196,4 +196,7 @@
                                   TComYuv*&   rpcResiYuv,
                                   TComYuv*&   rpcRecoYuv,
+#if MTK_FAST_TEXTURE_ENCODING_E0173
+                                  Bool        bFMD,
+#endif
                                   Bool        bUseRes = false
 #if AMP_MRG
