Index: branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TypeDef.h	(revision 459)
+++ branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TypeDef.h	(revision 460)
@@ -105,8 +105,11 @@
 ///// ***** DEPTH INTRA MODES *********
 #if H_3D_DIM
-#define H_3D_DIM_DMM                   1 // Depth Modeling Modes
-#define H_3D_DIM_RBC                   1 // Region Boundary Chain mode
-#define H_3D_DIM_SDC                   0 // Simplified Depth Coding method
-#define H_3D_DIM_DLT                   0 // Depth Lookup Table
+#define H_3D_DIM_DMM                      1   // Depth Modeling Modes
+#define H_3D_DIM_RBC                      1   // Region Boundary Chain mode
+#define H_3D_DIM_SDC                      0   // Simplified Depth Coding method
+#define H_3D_DIM_DLT                      0   // Depth Lookup Table
+#define H_3D_DIM_ENC                      1   // Depth Intra encoder optimizations, includes:
+                                              // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
+                                              // LG_ZEROINTRADEPTHRESI_A0087
 #endif
 
Index: branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncCu.cpp	(revision 459)
+++ branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncCu.cpp	(revision 460)
@@ -517,4 +517,11 @@
       m_LCUPredictionSAD += m_temporalSAD;
       m_addSADDepth = uiDepth;
+    }
+#endif
+
+#if H_3D_DIM_ENC
+    if( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() )
+    {
+      earlyDetectionSkipMode = false;
     }
 #endif
@@ -682,5 +689,9 @@
 
         // do normal intra modes
+#if H_3D_DIM_ENC
+        if ( !bEarlySkip || ( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() ) )
+#else
         if ( !bEarlySkip )
+#endif
         {
           // speedup for inter frames
@@ -688,5 +699,9 @@
             rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
             rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
-            rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
+              rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     
+#if H_3D_DIM_ENC
+            || ( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() )
+#endif
+            ) // avoid very complex intra if it is unlikely
           {
             xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
Index: branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 459)
+++ branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 460)
@@ -1013,5 +1013,9 @@
                                 UInt&       ruiDist,
 #endif
-                                Int        default0Save1Load2 )
+                                Int        default0Save1Load2 
+#if H_3D_DIM_ENC
+                                , Bool       zeroResi
+#endif
+                                )
 {
   UInt    uiLumaPredMode    = pcCU     ->getLumaIntraDir     ( uiAbsPartIdx );
@@ -1099,4 +1103,13 @@
     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
     {
+#if H_3D_DIM_ENC
+      if( zeroResi )
+      {
+        memset( pResi, 0, sizeof( Pel ) * uiWidth );
+        pResi += uiStride;
+      }
+      else
+      {
+#endif
       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
       {
@@ -1106,4 +1119,7 @@
       pResi += uiStride;
       pPred += uiStride;
+#if H_3D_DIM_ENC
+      }
+#endif
     }
   }
@@ -1404,5 +1420,9 @@
                                 Bool         bCheckFirst,
 #endif
-                                Double&      dRDCost )
+                                Double&      dRDCost 
+#if H_3D_DIM_ENC
+                                , Bool        zeroResi
+#endif
+                                )
 {
   UInt    uiFullDepth   = pcCU->getDepth( 0 ) +  uiTrDepth;
@@ -1514,5 +1534,9 @@
         }
         //----- code luma block with given intra prediction mode and store Cbf-----
+#if H_3D_DIM_ENC
+        xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, singleDistYTmp, default0Save1Load2, zeroResi );
+#else
         xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, singleDistYTmp,default0Save1Load2); 
+#endif
         singleCbfYTmp = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth );
         //----- code chroma blocks with given intra prediction mode and store Cbf-----
@@ -2744,4 +2768,8 @@
     for( UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ )
     {
+#if H_3D_DIM_ENC
+      for( UInt testZeroResi = 0; testZeroResi <= ((pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->isIRAP()) ? 1 : 0 ); testZeroResi++ )
+      {
+#endif
       // set luma prediction mode
       UInt uiOrgMode = uiRdModeList[uiMode];
@@ -2770,7 +2798,15 @@
 #endif
 #if HHI_RQT_INTRA_SPEEDUP
+#if H_3D_DIM_ENC
+      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost, (testZeroResi != 0) );
+#else
       xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost );
+#endif
+#else
+#if H_3D_DIM_ENC
+      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost, (testZeroResi != 0) );
 #else
       xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost );
+#endif
 #endif
       
@@ -2803,4 +2839,7 @@
         uiSecondBestMode  = uiOrgMode;
         dSecondBestPUCost = dPUCost;
+      }
+#endif
+#if H_3D_DIM_ENC
       }
 #endif
@@ -6761,5 +6800,5 @@
       if( m_pcRdCost->getUseVSO() )
       {
-        if( m_pcRdCost->getUseEstimatedVSD() )
+        if( m_pcRdCost->getUseEstimatedVSD() ) //PM: use VSO instead of VSD here?
         {
           uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
Index: branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSearch.h	(revision 459)
+++ branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSearch.h	(revision 460)
@@ -261,5 +261,9 @@
                                     UInt&        ruiDist,
 #endif
-                                    Int         default0Save1Load2 = 0);
+                                    Int         default0Save1Load2 = 0
+#if H_3D_DIM_ENC
+                                  , Bool          zeroResi = false
+#endif
+                                    );
   Void  xIntraCodingChromaBlk     ( TComDataCU*  pcCU,
                                     UInt         uiTrDepth,
@@ -288,5 +292,9 @@
                                    Bool         bCheckFirst,
 #endif
-                                   Double&      dRDCost );
+                                   Double&      dRDCost
+#if H_3D_DIM_ENC
+                                   , Bool          zeroResi = false
+#endif
+                                   );
   
   Void  xSetIntraResultQT         ( TComDataCU*  pcCU,
