Index: branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 112)
@@ -340,4 +340,8 @@
   ("VSDWeight",                       m_iVSDWeight             , 1 					  , "SAIT Weight" )
   ("DWeight",									        m_iDWeight						    , 1						 , "SSE Weight" )
+#endif
+
+#if OL_DEPTHLIMIT
+  ("DPL",   m_bDepthPartitionLimiting           , false         , "Use DepthPartitionLimiting" )
 #endif
 
@@ -1701,4 +1705,7 @@
   printf("WVSO:%d ", m_bWVSO );
 #endif
+#if OL_DEPTHLIMIT
+  printf("DPL:%d ", m_bDepthPartitionLimiting);
+#endif
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
   printf("DMM:%d ", m_bUseDMM );
Index: branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncCfg.h	(revision 111)
+++ branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncCfg.h	(revision 112)
@@ -308,4 +308,8 @@
 #endif
 
+#if OL_DEPTHLIMIT
+  Bool      m_bDepthPartitionLimiting;
+#endif
+
   // internal member functions
   Void  xSetGlobal      ();                                   ///< set global variables
Index: branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncTop.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/App/TAppEncoder/TAppEncTop.cpp	(revision 112)
@@ -364,4 +364,7 @@
     m_acTEncTopList[iViewIdx]->setUseDMM                     ( false );
 #endif
+#if OL_DEPTHLIMIT
+	m_acTEncTopList[iViewIdx]->setUseDPL                     ( false );
+#endif
 #if HHI_MPI
     m_acTEncTopList[iViewIdx]->setUseMVI( false );
@@ -639,4 +642,7 @@
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     m_acTEncDepthTopList[iViewIdx]->setUseDMM                     ( m_bUseDMM );
+#endif
+#if OL_DEPTHLIMIT
+	m_acTEncDepthTopList[iViewIdx]->setUseDPL                      (m_bDepthPartitionLimiting);
 #endif
 #if HHI_MPI
Index: branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComDataCU.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComDataCU.cpp	(revision 112)
@@ -152,4 +152,14 @@
 #endif
 #endif
+#if OL_DEPTHLIMIT
+  //add a variable to store the partition information
+  //a 2D array in part_symbol,uidepth format
+  //initialize m_partInfo to OL_END_CU
+	for (int i=0; i < OL_PART_BUF_SIZE; i++)
+	{
+		for (int j=0; j < 2; j++)
+			m_uiPartInfo[i][j] = OL_END_CU;
+	}
+#endif
 }
 
@@ -456,4 +466,7 @@
 Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr )
 {
+#if OL_DEPTHLIMIT
+  TComDataCU* pcCU     = pcPic->getCU(iCUAddr);
+#endif
 
   m_pcPic              = pcPic;
@@ -672,4 +685,7 @@
     m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr );
   }
+#if OL_DEPTHLIMIT
+  setPartDumpFlag (pcCU->getPartDumpFlag());
+#endif
 }
 
@@ -1001,4 +1017,7 @@
   memcpy(m_uiSliceStartCU,pcCU->m_uiSliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition);
   memcpy(m_uiEntropySliceStartCU,pcCU->m_uiEntropySliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition);
+#if OL_DEPTHLIMIT
+  setPartDumpFlag (pcCU->getPartDumpFlag());
+#endif
 }
 
Index: branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComDataCU.h	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComDataCU.h	(revision 112)
@@ -237,4 +237,12 @@
   UInt*         m_uiSliceStartCU;    ///< Start CU address of current slice
   UInt*         m_uiEntropySliceStartCU; ///< Start CU address of current slice
+
+#if OL_DEPTHLIMIT 
+  //add a variable to store the partition information
+  //a 2D array in uidepth,part_symbol format
+  UInt          m_uiPartInfo[OL_PART_BUF_SIZE][2];
+  UInt          m_uiPartNum;
+  Bool	        b_dumpPartInfo;
+#endif 
   
   // -------------------------------------------------------------------------------------------------------------------
@@ -596,4 +604,16 @@
   
   Void          compressMV            ();
+
+#if OL_DEPTHLIMIT
+	Void        resetPartInfo  () {m_uiPartNum = 0;};
+	Void        incrementPartInfo () {m_uiPartNum ++;};
+	Void        updatePartInfo(UInt uiSymbol, UInt uiDepth) {m_uiPartInfo[m_uiPartNum][0] = uiSymbol; m_uiPartInfo
+[m_uiPartNum][1] = uiDepth;};
+	UInt*       readPartInfo() {return (UInt*)m_uiPartInfo;};
+//	UInt		getPartNumIdx() {return m_uiPartNum;}; //added this to get the index
+//flag to signal to start dumping
+	Void		setPartDumpFlag(bool flag)	{b_dumpPartInfo = flag;};
+	Bool		getPartDumpFlag()	{return b_dumpPartInfo;};
+#endif
   
   // -------------------------------------------------------------------------------------------------------------------
Index: branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComSlice.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComSlice.cpp	(revision 112)
@@ -1441,4 +1441,7 @@
 , m_bUseDMM                   (false)
 #endif
+#if OL_DEPTHLIMIT
+, m_bDepthPartitionLimiting   (false)
+#endif
 {
   // AMVP parameter
Index: branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComSlice.h	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibCommon/TComSlice.h	(revision 112)
@@ -354,4 +354,8 @@
 #endif
 
+#if OL_DEPTHLIMIT
+  Bool m_bDepthPartitionLimiting;
+#endif
+
 #if DEPTH_MAP_GENERATION
   UInt  m_uiPredDepthMapGeneration;
@@ -619,4 +623,9 @@
 #endif
 
+#if OL_DEPTHLIMIT
+  Void setUseDPL(Bool b) {m_bDepthPartitionLimiting = b; }
+  Bool getUseDPL()       {return m_bDepthPartitionLimiting;}
+#endif
+
   Void initMultiviewSPS      ( UInt uiViewId, Int iViewOrderIdx = 0, UInt uiCamParPrecision = 0, Bool bCamParSlice = false, Int** aaiScale = 0, Int** aaiOffset = 0 );
   Void initMultiviewSPSDepth ( UInt uiViewId, Int iViewOrderIdx );
Index: branches/HTM-4.0-Orange/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibCommon/TypeDef.h	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibCommon/TypeDef.h	(revision 112)
@@ -42,4 +42,11 @@
 //! \{
 
+#define OL_DEPTHLIMIT 1  //JCT2-A0044
+#if OL_DEPTHLIMIT
+#define OL_DO_NOT_LIMIT_INTRA_SLICES_PART 1 //Turn this on to not perform depth limiting for I-SLICES.
+#define OL_END_CU MAX_INT //Default for initialising the partition information buffer
+#define OL_PART_BUF_SIZE 86 //maximum number of possible partition bits in a CU
+#endif
+
 #define FIXES                             1
 #define POZNAN_CABAC_INIT_FLAG_FIX        1
@@ -94,5 +101,5 @@
 #define SAIT_VSO_EST_A0033                1 // JCT2-A0033 modification 3
 #define LGE_VSO_EARLY_SKIP_A0093          1 // JCT2-A0093 modification 4
-#define LGE_WVSO_A0119                    1 // JCT2-A0119 Depth Metric with a weighted depth fidelity term
+#define LGE_WVSO_A0119                    0 // JCT2-A0119 Depth Metric with a weighted depth fidelity term
 
 #define HHI_INTERVIEW_SKIP                1
Index: branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncCfg.h	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncCfg.h	(revision 112)
@@ -318,4 +318,8 @@
 #endif
 
+#if OL_DEPTHLIMIT
+  Bool      m_bDepthPartitionLimiting;
+#endif
+
   Int      m_iViewOrderIdx;
 
@@ -817,4 +821,9 @@
 #endif
 
+#if OL_DEPTHLIMIT
+  Void setUseDPL(Bool b) {m_bDepthPartitionLimiting = b; }
+  Bool getUseDPL()       {return m_bDepthPartitionLimiting;}
+#endif
+
   Void      setViewOrderIdx       ( Int   i )      { m_iViewOrderIdx          = i; }
   Void      setCamParPrecision              ( UInt  u )      { m_uiCamParPrecision      = u; }
Index: branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncCu.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncCu.cpp	(revision 112)
@@ -451,4 +451,36 @@
   TComPic* pcPic = rpcBestCU->getPic();
 
+#if OL_DEPTHLIMIT
+  TComSPS *sps = pcPic->getSlice(0)->getSPS();
+  TComPic *pcTexture;
+  TComDataCU *pcTextureCU;
+  static UInt* texPartInfo;
+  static UInt uiTexPartIndex;
+  static Bool depthMapDetect =  false;
+  UInt uiPrevTexPartIndex; //kat debug
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  static Bool bIntraSliceDetect = false;
+#endif
+  Bool bTry2NxN = false;
+  Bool bTryNx2N = false;
+  if(uiDepth == 0)
+  {
+	pcTexture = rpcBestCU->getSlice()->getTexturePic();
+	if(pcTexture != NULL) //depth map being encoded
+	{
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+		bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType()==I_SLICE);
+#endif
+		pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() );
+		texPartInfo = pcTextureCU -> readPartInfo();
+		uiTexPartIndex = 0;
+		depthMapDetect = true;
+	}
+	else
+	{
+		depthMapDetect = false;
+	}
+  }
+#endif
   // get Original YUV data from picture
   m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
@@ -592,4 +624,78 @@
 
       rpcTempCU->initEstData( uiDepth, iQP );
+
+#if OL_DEPTHLIMIT
+  //logic for setting bTrySplit using the partition information that is stored of the texture colocated CU
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL())
+#else
+  if(depthMapDetect && sps->getUseDPL()) //depth map being encoded
+#endif
+  {
+	assert(uiDepth == (UInt)texPartInfo[uiTexPartIndex+1]);
+	if((UInt)texPartInfo[uiTexPartIndex+0] == 1) //NxN modes
+	{
+		bTrySplit = true;
+		bTryNx2N = true;
+		bTry2NxN = true;
+		uiPrevTexPartIndex = uiTexPartIndex; //kat debug
+		uiTexPartIndex += 2;
+	}
+	else if((UInt)texPartInfo[uiTexPartIndex+0] == 0) //2Nx2N modes
+	{
+		UInt uiTexdepth;
+		UInt temp_uiTexPartIndex;
+		bTrySplit = false;
+		//scan ahead till next depth
+		uiTexdepth = (UInt)texPartInfo[uiTexPartIndex+1];
+		uiPrevTexPartIndex = uiTexPartIndex; //kat debug
+		uiTexPartIndex+=2;
+		temp_uiTexPartIndex = uiTexPartIndex; //store in case to rewind
+		//temp_uiTexPartIndex+=2;
+					while(uiTexdepth != (UInt)texPartInfo[uiTexPartIndex+1] && uiTexdepth != 0)
+					{
+						if((UInt)texPartInfo[uiTexPartIndex+1] < uiTexdepth)
+						{
+							break;
+						}
+						uiTexPartIndex+=2;
+						
+						if((UInt)texPartInfo[uiTexPartIndex+1] == OL_END_CU)
+						{
+							uiTexPartIndex = temp_uiTexPartIndex;
+							uiTexdepth++;
+							if(uiTexdepth >= g_uiMaxCUDepth)
+							{
+								//uiTexPartIndex-=2;
+								break;
+							}
+						}
+					}
+	}
+	else if((UInt)texPartInfo[uiTexPartIndex+0] == OL_END_CU)
+	{
+		bTrySplit = false;
+		bTryNx2N = false;
+		bTry2NxN = false;
+	}
+	else if((UInt)texPartInfo[uiTexPartIndex+0] == 2) //2NxN case
+	{
+		bTrySplit = false;
+		bTryNx2N = false;
+		bTry2NxN = true;
+		uiPrevTexPartIndex = uiTexPartIndex; //kat debug
+		uiTexPartIndex += 2;
+	}
+	else if((UInt)texPartInfo[uiTexPartIndex+0] == 3) //Nx2N case
+	{
+		bTrySplit = false;
+		bTryNx2N = true;
+		bTry2NxN = false;
+		uiPrevTexPartIndex = uiTexPartIndex; //kat debug
+		uiTexPartIndex += 2;
+	}
+  }
+#endif
+
 
       // do inter modes, SKIP and 2Nx2N
@@ -660,4 +766,28 @@
       } // != I_SLICE
 
+#if OL_DEPTHLIMIT
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+	  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+	  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+	  {
+		  bTrySplitDQP = bTrySplit;
+	  }
+	  else
+	  {
+		if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() )
+		{
+			if(iQP == iBaseQP)
+			{
+				bTrySplitDQP = bTrySplit;
+			}
+		}
+		else
+		{
+			bTrySplitDQP = bTrySplit;
+		}
+	  }
+#else
 
       if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() )
@@ -672,4 +802,5 @@
         bTrySplitDQP = bTrySplit;
       }
+#endif
 #if LOSSLESS_CODING
       if (isAddLowestQP && (iQP == lowestQP))
@@ -721,4 +852,15 @@
           if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu)
           {
+#if OL_DEPTHLIMIT //add code here to select 2NxN or Nx2N or none
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+			{
+				assert(uiDepth == (UInt)texPartInfo[uiPrevTexPartIndex+1]);
+				if (bTrySplit)
+				{	
+#endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
             rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
@@ -730,9 +872,36 @@
 #endif
             rpcTempCU->initEstData( uiDepth, iQP );
-          }
+#if OL_DEPTHLIMIT
+				}//bTrySplit
+			}//depthMapDetect
+			else//do things normally
+			{
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFullyRenderedSec   );
+#else
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN   );
+#endif
+            rpcTempCU->initEstData( uiDepth, iQP );
+          }
+#endif
+          } 
         }
         }
 
         { // 2NxN, Nx2N
+#if OL_DEPTHLIMIT //add code here to select 2NxN or Nx2N or none
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+			{
+				assert(uiDepth == (UInt)texPartInfo[uiPrevTexPartIndex+1]);
+				if (bTryNx2N)
+				{	
+#endif
           if(doNotBlockPu)
           {
@@ -751,4 +920,39 @@
             }
           }
+#if OL_DEPTHLIMIT
+				}//bTryNx2N
+			}//depthMapDetect
+			else//do things normally
+			{
+          if(doNotBlockPu)
+          {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N, bFullyRenderedSec   );
+#else
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N  );
+#endif
+            rpcTempCU->initEstData( uiDepth, iQP );
+            if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N )
+            {
+              doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+            }
+          }
+			}
+#endif
+
+#if OL_DEPTHLIMIT //add code here to select 2NxN or Nx2N or none
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+			{
+				assert(uiDepth == (UInt)texPartInfo[uiPrevTexPartIndex+1]);
+				if (bTry2NxN)
+				{	
+#endif
           if(doNotBlockPu)
           {
@@ -767,4 +971,27 @@
             }
           }
+#if OL_DEPTHLIMIT
+				}//bTryNx2N
+			}//depthMapDetect
+			else//do things normally
+			{
+				 if(doNotBlockPu)
+          {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxN, bFullyRenderedSec   );
+#else
+            xCheckRDCostInter      ( rpcBestCU, rpcTempCU, SIZE_2NxN  );
+#endif
+            rpcTempCU->initEstData( uiDepth, iQP );
+            if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN)
+            {
+              doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+            }
+          }
+  }
+#endif
         }
 
@@ -787,4 +1014,15 @@
           if ( bTestAMP_Hor )
           {
+#if OL_DEPTHLIMIT //add code here to select 2NxN or Nx2N or none
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+			{
+				assert(uiDepth == (UInt)texPartInfo[uiPrevTexPartIndex+1]);
+				if (bTry2NxN)
+				{	
+#endif
             if(doNotBlockPu)
             {
@@ -819,8 +1057,9 @@
               }
             }
-          }
-#if AMP_MRG
-          else if ( bTestMergeAMP_Hor ) 
-          {
+#if OL_DEPTHLIMIT
+				}//bTry2NxN
+			}//depthMapDetect
+			else//do things normally
+			{
             if(doNotBlockPu)
             {
@@ -829,7 +1068,7 @@
 #endif
 #if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec, true );
-#else
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true );
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
 #endif
               rpcTempCU->initEstData( uiDepth, iQP );
@@ -845,7 +1084,7 @@
 #endif
 #if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec, true );
-#else
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true );
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
 #endif
               rpcTempCU->initEstData( uiDepth, iQP );
@@ -857,8 +1096,108 @@
           }
 #endif
+          }
+#if AMP_MRG
+          else if ( bTestMergeAMP_Hor ) 
+          {
+#if OL_DEPTHLIMIT //add code here to select 2NxN or Nx2N or none
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+			{
+				assert(uiDepth == (UInt)texPartInfo[uiPrevTexPartIndex+1]);
+				if (bTry2NxN)
+				{	
+#endif
+            if(doNotBlockPu)
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec, true );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
+              {
+                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+              }
+            }
+            if(doNotBlockPu)
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec, true );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
+              {
+                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+              }
+            }
+#if OL_DEPTHLIMIT
+				}//bTry2NxN
+			}//depthMapDetect
+			else//do things normally
+			{
+            if(doNotBlockPu)
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec, true );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
+              {
+                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+              }
+            }
+            if(doNotBlockPu)
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec, true );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
+              {
+                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+              }
+            }
+
+			}
+#endif
+          }
+#endif
 
           //! Do horizontal AMP
           if ( bTestAMP_Ver )
           {
+#if OL_DEPTHLIMIT //add code here to select 2NxN or Nx2N or none
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+			{
+				assert(uiDepth == (UInt)texPartInfo[uiPrevTexPartIndex+1]);
+				if (bTryNx2N)
+				{	
+#endif
             if(doNotBlockPu)
             {
@@ -889,8 +1228,9 @@
               rpcTempCU->initEstData( uiDepth, iQP );
             }
-          }
-#if AMP_MRG
-          else if ( bTestMergeAMP_Ver )
-          {
+#if OL_DEPTHLIMIT
+				}//bTryNx2N
+			}//depthMapDetect
+			else//do things normally
+			{
             if(doNotBlockPu)
             {
@@ -899,7 +1239,7 @@
 #endif
 #if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec, true );
-#else
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true );
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
 #endif
               rpcTempCU->initEstData( uiDepth, iQP );
@@ -915,10 +1255,90 @@
 #endif
 #if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec, true );
-#else
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true );
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
 #endif
               rpcTempCU->initEstData( uiDepth, iQP );
             }
+          }
+#endif
+          }
+#if AMP_MRG
+          else if ( bTestMergeAMP_Ver )
+          {
+#if OL_DEPTHLIMIT //add code here to select 2NxN or Nx2N or none
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+			{
+				assert(uiDepth == (UInt)texPartInfo[uiPrevTexPartIndex+1]);
+				if (bTryNx2N)
+				{	
+#endif
+            if(doNotBlockPu)
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec, true );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
+              {
+                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+              }
+            }
+            if(doNotBlockPu)
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec, true );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+            }
+#if OL_DEPTHLIMIT
+				}//bTryNx2N
+			}//depthMapDetect
+			else//do things normally
+			{
+            if(doNotBlockPu)
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec, true );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
+              {
+                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+              }
+            }
+            if(doNotBlockPu)
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec, true );
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+            }
+          }
+#endif
           }
 #endif
@@ -994,4 +1414,16 @@
           if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
           {
+#if OL_DEPTHLIMIT //add code here to select or deselect NxN mode for Intra
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  if(depthMapDetect && !bIntraSliceDetect  && sps->getUseDPL())
+#else
+  if(depthMapDetect  && sps->getUseDPL()) //depth map being encoded
+#endif
+			{
+				assert(uiDepth == (UInt)texPartInfo[uiPrevTexPartIndex+1]);
+				if (bTrySplit)
+				{
+			
+#endif
             if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
             {
@@ -999,4 +1431,16 @@
               rpcTempCU->initEstData( uiDepth, iQP );
             }
+#if OL_DEPTHLIMIT
+				}//bTrySplit
+			 }//depthMapDetect
+			else
+			{
+				if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
+				{
+					xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
+					rpcTempCU->initEstData( uiDepth, iQP );
+				}
+			}
+#endif
           }
         }
@@ -1561,6 +2005,12 @@
 #if HHI_MPI
     if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) )
-#endif
+    {
+#endif
+
     m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
+
+#if HHI_MPI
+    }
+#endif
   }
   else
@@ -1577,5 +2027,7 @@
 
     if( ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
+	{
       m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
+	}
     if( !pcCU->getSlice()->isIntra() )
     {
@@ -1631,4 +2083,5 @@
 #if HHI_MPI
   if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
+{
 #endif
   if( !pcCU->getSlice()->isIntra() )
@@ -1636,7 +2089,17 @@
     m_pcEntropyCoder->encodeSkipFlag( pcCU, uiAbsPartIdx );
   }
+#if HHI_MPI
+}
+#endif
   
   if( pcCU->isSkipped( uiAbsPartIdx ) )
   {
+#if OL_DEPTHLIMIT
+	if(pcCU->getPartDumpFlag())
+	{
+		pcCU->updatePartInfo(0,uiDepth);
+		pcCU->incrementPartInfo();
+	}
+#endif
     m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 );
 #if HHI_INTER_VIEW_RESIDUAL_PRED
Index: branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 112)
@@ -1136,10 +1136,26 @@
         if (!bEntropySlice)
         {
+#if OL_DEPTHLIMIT //start dumping partition information
+		m_pcSliceEncoder->setPartDumpFlag(1);
+//		if(!(pcPic->getSlice(0)->getSPS()->getUseDPL()))
+//		{
+//			m_pcSliceEncoder->setPartDumpFlag(0);
+//		}
+#endif
           pcSlice->setTileLocationCount ( 0 );
           m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info.
+#if OL_DEPTHLIMIT //stop dumping partition information
+		m_pcSliceEncoder->setPartDumpFlag(0);
+#endif
         }
         else
         {
+#if OL_DEPTHLIMIT //start dumping partition information
+		m_pcSliceEncoder->setPartDumpFlag(1);
+#endif
           m_pcSliceEncoder->encodeSlice(pcPic, &nalu.m_Bitstream, pcSubstreamsOut); // nalu.m_Bitstream is only used for CAVLC tile position info.
+#if OL_DEPTHLIMIT //stop dumping partition information
+		m_pcSliceEncoder->setPartDumpFlag(0);
+#endif
         }
 
Index: branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 112)
@@ -580,4 +580,7 @@
 {
   PartSize eSize         = pcCU->getPartitionSize( uiAbsPartIdx );
+#if OL_DEPTHLIMIT
+  UInt uiSymbol;
+#endif
   if ( pcCU->isIntra( uiAbsPartIdx ) )
   {
@@ -585,5 +588,20 @@
     {
       m_pcBinIf->encodeBin( eSize == SIZE_2Nx2N? 1 : 0, m_cCUPartSizeSCModel.get( 0, 0, 0 ) );
-    }
+#if OL_DEPTHLIMIT
+		if(pcCU->getPartDumpFlag())
+		{
+			uiSymbol = (UInt)(eSize == SIZE_2Nx2N? 1 : 0);
+			pcCU->updatePartInfo(uiSymbol?0:1,uiDepth); //0 for 2Nx2N and 1 for NxN
+			pcCU->incrementPartInfo();
+		}
+#endif
+    }
+#if OL_DEPTHLIMIT
+	if(pcCU->getPartDumpFlag() && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth && !pcCU->getSlice()->isIntra())
+	{
+		pcCU->updatePartInfo(0,uiDepth); //0 for 2Nx2N and 1 for NxN
+		pcCU->incrementPartInfo();
+	}
+#endif
     return;
   }
@@ -594,4 +612,14 @@
     {
       m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+#if OL_DEPTHLIMIT
+	  if(pcCU->getPartDumpFlag())
+	  {
+//		if (!pcCU->isIntra( uiAbsPartIdx ))
+		{
+			pcCU->updatePartInfo(0,uiDepth); //0 for 2Nx2N
+			pcCU->incrementPartInfo();
+		}
+	  }
+#endif
       break;
     }
@@ -623,4 +651,14 @@
         }
       }
+#if OL_DEPTHLIMIT
+	  if(pcCU->getPartDumpFlag())
+	  {
+//		if (!pcCU->isIntra( uiAbsPartIdx ))
+		{
+			pcCU->updatePartInfo(2,uiDepth); //2 for 2NxN
+			pcCU->incrementPartInfo();
+		}
+	  }
+#endif
       break;
     }
@@ -656,4 +694,14 @@
         }
       }
+#if OL_DEPTHLIMIT
+	  if(pcCU->getPartDumpFlag())
+	  {
+//		if (!pcCU->isIntra( uiAbsPartIdx ))
+		{
+			pcCU->updatePartInfo(3,uiDepth); //3 for Nx2N
+			pcCU->incrementPartInfo();
+		}
+	  }
+#endif
       break;
     }
@@ -665,4 +713,27 @@
         m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
         m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 2) );
+#if OL_DEPTHLIMIT
+	  if(pcCU->getPartDumpFlag())
+	  {
+		//if (!pcCU->getSlice()->isIntra())
+		{
+			pcCU->updatePartInfo(1,uiDepth); //2Nx2N here since we disable NxN in Inter
+			pcCU->incrementPartInfo();
+		}
+	  }
+#endif
+      }
+	  else
+	  {
+#if OL_DEPTHLIMIT
+	  if(pcCU->getPartDumpFlag())
+	  {
+		//if (!pcCU->getSlice()->isIntra())
+		{
+			pcCU->updatePartInfo(0,uiDepth); //2Nx2N here since we disable NxN in Inter
+			pcCU->incrementPartInfo();
+		}
+	  }
+#endif
       }
       break;
@@ -828,4 +899,14 @@
   assert( uiCtx < 3 );
   m_pcBinIf->encodeBin( uiCurrSplitFlag, m_cCUSplitFlagSCModel.get( 0, 0, uiCtx ) );
+#if OL_DEPTHLIMIT
+  if(pcCU->getPartDumpFlag())
+  {
+	if(pcCU->getSlice()->isIntra() || (!pcCU->getSlice()->isIntra() && uiCurrSplitFlag!=0))
+	{
+	pcCU->updatePartInfo(uiCurrSplitFlag,uiDepth);
+	pcCU->incrementPartInfo();
+	}
+  }
+#endif
   DTRACE_CABAC_VL( g_nSymbolCounter++ )
   DTRACE_CABAC_T( "\tSplitFlag\n" )
Index: branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 112)
@@ -849,4 +849,8 @@
 #endif
 
+#if OL_DEPTHLIMIT //stop dumping partition information
+	b_dumpPartInfo = 0;
+	pcCU->setPartDumpFlag(b_dumpPartInfo);
+#endif
 
     // inherit from TR if necessary, select substream to use.
@@ -1308,4 +1312,8 @@
 
     TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );    
+#if OL_DEPTHLIMIT
+	pcCU->setPartDumpFlag(b_dumpPartInfo);
+	pcCU->resetPartInfo();
+#endif
 #if !REMOVE_TILE_DEPENDENCE
     if( (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr()==0) && (rpcPic->getPicSym()->getNumColumnsMinus1()!=0) )
Index: branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSlice.h	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncSlice.h	(revision 112)
@@ -101,4 +101,7 @@
   
   UInt                    m_uiSliceIdx;
+#if OL_DEPTHLIMIT //flag to signal to start dumping
+  bool					  b_dumpPartInfo;
+#endif
 public:
   TEncSlice();
@@ -128,4 +131,7 @@
   UInt    getSliceIdx()         { return m_uiSliceIdx;                    }
   Void    setSliceIdx(UInt i)   { m_uiSliceIdx = i;                       }
+#if OL_DEPTHLIMIT //flag to signal to start dumping
+  Void	  setPartDumpFlag(bool flag)	{b_dumpPartInfo = flag;};
+#endif
 };
 
Index: branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncTop.cpp	(revision 111)
+++ branches/HTM-4.0-Orange/source/Lib/TLibEncoder/TEncTop.cpp	(revision 112)
@@ -768,4 +768,7 @@
   m_cSPS.setUseDMM( m_bUseDMM );
 #endif
+#if OL_DEPTHLIMIT
+  m_cSPS.setUseDPL( m_bDepthPartitionLimiting );
+#endif
 #if HHI_MPI
   m_cSPS.setUseMVI( m_bUseMVI );
