Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 193)
@@ -695,4 +695,16 @@
     WRITE_FLAG( 1, "base_view_flag" );   
   }
+#if VSP_N
+  if( pcSPS->getViewId() )
+  {
+    WRITE_FLAG( pcSPS->getVspPresentFlag(), "vsp_present_flag" );
+#if VSP_CFG
+    if( pcSPS->getVspPresentFlag() )
+    {
+      WRITE_FLAG( pcSPS->getVspDepthPresentFlag(), "vsp_depth_present_flag" );
+    }
+#endif
+  }
+#endif
   WRITE_FLAG( 0, "sps_extension2_flag" );
 }
@@ -707,4 +719,9 @@
 #if ENC_DEC_TRACE  
   xTraceSliceHeader (pcSlice);
+#endif
+
+#if VSP_CFG
+  Int iNumOfVspRefsL0 = 0;
+  Int iNumOfVspRefsL1 = 0;
 #endif
 
@@ -949,9 +966,42 @@
     }
 
+#if VSP_SLICE_HEADER && VSP_CFG
+    if( pcSlice->getSPS()->getViewId()!=0 
+     && pcSlice->getSliceType() != I_SLICE
+     && pcSlice->getSPS()->getVspPresentFlag()
+      )
+    {
+      if( !pcSlice->getSPS()->isDepth() || pcSlice->getSPS()->getVspDepthPresentFlag() )
+      {
+        WRITE_UVLC( pcSlice->getNumVspRefPics(), "num_vsp_ref_pics");
+        for( UInt i = 0; i < pcSlice->getNumVspRefPics(); i++ )
+        {
+          WRITE_UVLC( pcSlice->getVspRefPos( REF_PIC_LIST_0, i ), "vsp_ref_list0_pos");
+          if( pcSlice->getSliceType() == B_SLICE )
+          {
+            WRITE_UVLC( pcSlice->getVspRefPos( REF_PIC_LIST_1, i ), "vsp_ref_list1_pos");
+          }
+        }
+        iNumOfVspRefsL0 = ( (pcSlice->getSPS()->getViewId()==0 
+                         || (!pcSlice->getSPS()->getVspDepthPresentFlag() && pcSlice->getSPS()->isDepth()) 
+                         || !pcSlice->getVspFlag() 
+                         || pcSlice->getVspRefPos(REF_PIC_LIST_0, 0) == 0 ) ? 0 : 1 );
+        iNumOfVspRefsL1 = ( (pcSlice->getSPS()->getViewId()==0 
+                         || (!pcSlice->getSPS()->getVspDepthPresentFlag() && pcSlice->getSPS()->isDepth()) 
+                         || !pcSlice->getVspFlag() 
+                         || pcSlice->getVspRefPos(REF_PIC_LIST_1, 0) == 0 ) ? 0 : 1 );
+      }
+    }
+#endif
+
     // we always set num_ref_idx_active_override_flag equal to one. this might be done in a more intelligent way 
     if (!pcSlice->isIntra())
     {
       WRITE_FLAG( 1 ,                                             "num_ref_idx_active_override_flag");
+#if VSP_CFG
+      WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1 - iNumOfVspRefsL0, 3, "num_ref_idx_l0_active_minus1" );
+#else
       WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, 3, "num_ref_idx_l0_active_minus1" );
+#endif
     }
     else
@@ -961,5 +1011,9 @@
     if (pcSlice->isInterB())
     {
+#if VSP_CFG
+      WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1 - iNumOfVspRefsL1, 3, "num_ref_idx_l1_active_minus1" );
+#else
       WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, 3, "num_ref_idx_l1_active_minus1" );
+#endif
     }
     else
@@ -1050,5 +1104,9 @@
     if(pcSlice->getRefPicListCombinationFlag())
     {
+#if VSP_CFG
+      WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1 - iNumOfVspRefsL0,          "num_ref_idx lc_active_minus1");
+#else
       WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1,          "num_ref_idx lc_active_minus1");
+#endif
       
 #if H0412_REF_PIC_LIST_RESTRICTION
@@ -1180,16 +1238,19 @@
 #endif
 
+#if !VSP_CFG
 #if VSP_SLICE_HEADER
   if( pcSlice->getSPS()->getViewId()!=0 
-#if VSP_TEXT_ONLY
-      && !(pcSlice->getSPS()->isDepth()) 
-#endif
+   && pcSlice->getSPS()->getVspPresentFlag()
     )
   {
     WRITE_FLAG( pcSlice->getVspFlag()?1:0, "vsp_flag" );
 //    printf("[VSP: %d] ", pcSlice->getVspFlag()?1:0);
-  }
-#endif
-
+    if( pcSlice->getVspFlag() )
+    {
+      WRITE_FLAG( pcSlice->getVspDepthDisableFlag()?1:0 , "vsp_depth_disable_flag" );
+    }
+  }
+#endif
+#endif
 }
 
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCfg.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCfg.h	(revision 193)
@@ -67,4 +67,10 @@
   Int m_interViewRefPosL0[MAX_NUM_REF_PICS];
   Int m_interViewRefPosL1[MAX_NUM_REF_PICS];
+#if VSP_CFG
+  Int m_numVSPRefPics;
+  Int m_VSPRefPics[MAX_NUM_REF_PICS];
+  Int m_VSPRefPosL0[MAX_NUM_REF_PICS];
+  Int m_VSPRefPosL1[MAX_NUM_REF_PICS];
+#endif
  GOPEntryMvc()
   : m_POC(-1)
@@ -81,4 +87,7 @@
   , m_numRefIdc()
   , m_numInterViewRefPics()
+#if VSP_CFG
+  , m_numVSPRefPics()
+#endif
   {
     ::memset( m_referencePics, 0, sizeof(m_referencePics) );
@@ -88,4 +97,9 @@
     ::memset( m_interViewRefPosL0, 0, sizeof(m_interViewRefPosL0) );
     ::memset( m_interViewRefPosL1, 0, sizeof(m_interViewRefPosL1) );
+#if VSP_CFG
+    ::memset( m_VSPRefPics,  0, sizeof(m_VSPRefPics) );
+    ::memset( m_VSPRefPosL0, 0, sizeof(m_VSPRefPosL0) );
+    ::memset( m_VSPRefPosL1, 0, sizeof(m_VSPRefPosL1) );
+#endif
   }
 };
@@ -204,4 +218,10 @@
   Double    m_dLambdaScaleVSO;
   UInt      m_uiVSOMode;
+#if LGE_WVSO_A0119
+  Bool      m_bUseWVSO;
+  Int       m_iVSOWeight;
+  Int       m_iVSDWeight;
+  Int       m_iDWeight;
+#endif
 #endif
 #if SAIT_VSO_EST_A0033
@@ -210,4 +230,8 @@
 #endif
 
+#if VSP_SLICE_HEADER
+  Bool      m_bUseVSP;
+  Bool      m_bVSPDepthDisable;
+#endif
 
   //====== Tool list ========
@@ -266,5 +290,8 @@
   Int       m_iColumnRowInfoPresent;
   Int       m_iUniformSpacingIdr;
+#if FIX_REMOVE_TILE_DEPENDENCE
+#else
   Int       m_iTileBoundaryIndependenceIdr;
+#endif
   Int       m_iNumColumnsMinus1;
   UInt*     m_puiColumnWidth;
@@ -281,5 +308,5 @@
   Int       m_iWaveFrontSubstreams;
 
-  bool m_pictureDigestEnabled; ///< enable(1)/disable(0) md5 computation and SEI signalling
+  Bool      m_pictureDigestEnabled; ///< enable(1)/disable(0) md5 computation and SEI signalling
 
   //====== Weighted Prediction ========
@@ -309,5 +336,9 @@
 #endif
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-  Bool      m_bUseDMM;
+  Bool     m_bUseDMM;
+#endif
+
+#if OL_DEPTHLIMIT_A0044
+  Bool     m_bDepthPartitionLimiting;
 #endif
 
@@ -466,4 +497,10 @@
   Void      setAllowNegDist                 ( Bool b  )     { m_bAllowNegDist     = b; };
 #endif
+#if LGE_WVSO_A0119
+  Void      setUseWVSO                      ( Bool  b )     { m_bUseWVSO   = b; }
+  Void      setVSOWeight                    ( Int   i )     { m_iVSOWeight = i; }
+  Void      setVSDWeight                    ( Int   i )     { m_iVSDWeight = i; }
+  Void      setDWeight                      ( Int   i )     { m_iDWeight   = i; }
+#endif
 #endif
 
@@ -546,4 +583,10 @@
   Bool      getAllowNegDist                 ()      { return m_bAllowNegDist;     }
 #endif
+#if LGE_WVSO_A0119
+  Bool      getUseWVSO                      ()      { return m_bUseWVSO;     }
+  Int       getVSOWeight                    ()      { return m_iVSOWeight;    }
+  Int       getVSDWeight                    ()      { return m_iVSDWeight;    }
+  Int       getDWeight                      ()      { return m_iDWeight;    }
+#endif
 #endif
 
@@ -571,4 +614,9 @@
 #if HHI_VSO
   Void      setUseVSO                       ( Bool  b )     { m_bUseVSO     = b; }
+#endif
+
+#if VSP_SLICE_HEADER
+  Void      setUseVSP                       ( Bool  b )     { m_bUseVSP     = b; }
+  Void      setVSPDepthDisable              ( Bool  b )     { m_bVSPDepthDisable = b; }
 #endif
 
@@ -623,4 +671,9 @@
 #endif
 
+#if VSP_SLICE_HEADER
+  Bool      getUseVSP                       ()      { return m_bUseVSP; }
+  Bool      getVSPDepthDisable              ()      { return m_bVSPDepthDisable; }
+#endif
+
   Bool      getUseFastEnc                   ()      { return m_bUseFastEnc; }
   Bool      getUseEarlyCU                   ()      { return m_bUseEarlyCU; }
@@ -657,12 +710,12 @@
   Void  setSliceGranularity            ( Int  i )      { m_iSliceGranularity = i;       }
   Int   getSliceGranularity            ()              { return m_iSliceGranularity;    }
-  Void      setLFCrossSliceBoundaryFlag     ( Bool   bValue  )    { m_bLFCrossSliceBoundaryFlag = bValue; }
-  Bool      getLFCrossSliceBoundaryFlag     ()                    { return m_bLFCrossSliceBoundaryFlag;   }
+  Void  setLFCrossSliceBoundaryFlag    ( Bool   bValue  )    { m_bLFCrossSliceBoundaryFlag = bValue; }
+  Bool  getLFCrossSliceBoundaryFlag    ()                    { return m_bLFCrossSliceBoundaryFlag;   }
 
 #if HHI_MPI
-  Void      setUseMVI                  (Bool bVal)     {m_bUseMVI = bVal;}
-#endif
-  Void      setUseSAO                  (Bool bVal)     {m_bUseSAO = bVal;}
-  Bool      getUseSAO                  ()              {return m_bUseSAO;}
+  Void  setUseMVI                      ( Bool bVal )   {m_bUseMVI = bVal;}
+#endif
+  Void  setUseSAO                      ( Bool bVal )   {m_bUseSAO = bVal;}
+  Bool  getUseSAO                      ()              {return m_bUseSAO;}
 #if SAO_UNIT_INTERLEAVING
   Void  setMaxNumOffsetsPerPic                   (Int iVal)            { m_maxNumOffsetsPerPic = iVal; }
@@ -795,6 +848,11 @@
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-  Void setUseDMM( Bool b) { m_bUseDMM = b;    }
-  Bool getUseDMM()        { return m_bUseDMM; }
+  Void      setUseDMM( Bool b) { m_bUseDMM = b;    }
+  Bool      getUseDMM()        { return m_bUseDMM; }
+#endif
+
+#if OL_DEPTHLIMIT_A0044
+  Void      setUseDPL(Bool b) {m_bDepthPartitionLimiting = b; }
+  Bool      getUseDPL()       {return m_bDepthPartitionLimiting;}
 #endif
 
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 193)
@@ -451,8 +451,38 @@
   TComPic* pcPic = rpcBestCU->getPic();
 
+#if OL_DEPTHLIMIT_A0044
+  TComSPS *sps = pcPic->getSlice(0)->getSPS();
+  TComPic *pcTexture;
+  TComDataCU * pcTextureCU;
+  Bool  depthMapDetect =  false;
+  //UInt         uiPrevTexPartIndex = 0;
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+  Bool bIntraSliceDetect = false;
+#endif
+  Bool bTry2NxN = false;
+  Bool bTryNx2N = false;
+    pcTexture = rpcBestCU->getSlice()->getTexturePic();
+    if(pcTexture != NULL) //depth map being encoded
+    {
+    depthMapDetect = true;
+#if OL_DO_NOT_LIMIT_INTRA_SLICES_PART
+      bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType()==I_SLICE);
+#endif
+    if(uiDepth == 0)
+    {
+      pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() );
+      pcTexture->setPartInfo(pcTextureCU->readPartInfo());
+      pcTexture->setTexPartIndex(0); 
+    }
+    }
+    else
+    {
+      depthMapDetect = false;
+    }
+#endif
   // get Original YUV data from picture
   m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
 #if FORCE_REF_VSP
-  //Bool bWholeCUCanBeSynthesized = false;
+  Bool bWholeCUCanBeSynthesized = false;
   //Bool bOneSubCUCanNotBeSynthesied = false;
   Bool bSubCUCanBeSynthesized[4];
@@ -476,5 +506,5 @@
     if(iSubCUCanBeSynthesizedCnt == 4)
     {
-      //bWholeCUCanBeSynthesized = true;
+      bWholeCUCanBeSynthesized = true;
     }
     //else if(iSubCUCanBeSynthesizedCnt == 3)
@@ -488,5 +518,5 @@
   // variables for fast encoder decision
   Bool    bEarlySkip  = false;
-  Bool    bTrySplit    = true;
+  Bool    bTrySplit   = true;
   Double  fRD_Skip    = MAX_DOUBLE;
 
@@ -499,5 +529,5 @@
   Bool    bTrySplitDQP  = true;
 
-  static  Double  afCost[ MAX_CU_DEPTH ];
+  static  Double  afCost [ MAX_CU_DEPTH ];
   static  Int      aiNum [ MAX_CU_DEPTH ];
 
@@ -581,5 +611,5 @@
       isAddLowestQP = true; 
       iMinQP = iMinQP - 1;
-       
+
     }
 #endif
@@ -624,4 +654,78 @@
 
       rpcTempCU->initEstData( uiDepth, iQP );
+
+#if OL_DEPTHLIMIT_A0044
+      //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 == pcTexture->accessPartInfo(1));
+        if(pcTexture->accessPartInfo(0) == 1) //NxN modes
+        {
+          bTrySplit = true;
+          bTryNx2N = true;
+          bTry2NxN = true;
+          //uiPrevTexPartIndex = pcTexture->getTexPartIndex(); 
+          pcTexture->incrementTexPartIndex(); 
+        }
+        else if(pcTexture->accessPartInfo(0) == 0) //2Nx2N modes
+        {
+          UInt uiTexdepth;
+          UInt temp_uiTexPartIndex;
+          bTrySplit = false;
+
+          //scan ahead till next depth
+          uiTexdepth = pcTexture->accessPartInfo(1);
+          //uiPrevTexPartIndex = pcTexture->getTexPartIndex(); 
+          pcTexture->incrementTexPartIndex();
+          temp_uiTexPartIndex = pcTexture->getTexPartIndex(); //store in case to rewind
+
+          while(uiTexdepth != pcTexture->accessPartInfo(1) && uiTexdepth != 0)
+          {
+            if(pcTexture->accessPartInfo(1) < uiTexdepth)
+            {
+              break;
+            }
+            pcTexture->incrementTexPartIndex(); 
+
+            if(pcTexture->accessPartInfo(1) == OL_END_CU)
+            {
+              pcTexture->setTexPartIndex(temp_uiTexPartIndex); 
+              uiTexdepth++;
+              if(uiTexdepth >= g_uiMaxCUDepth)
+              {      
+                break;
+              }
+            }
+          }
+        }
+        else if(pcTexture->accessPartInfo(0) == OL_END_CU)
+        {
+          bTrySplit = false;
+          bTryNx2N = false;
+          bTry2NxN = false;
+        }
+        else if(pcTexture->accessPartInfo(0) == 2) //2NxN case
+        {
+          bTrySplit = false;
+          bTryNx2N = false;
+          bTry2NxN = true;
+          //uiPrevTexPartIndex = pcTexture->getTexPartIndex();  
+          pcTexture->incrementTexPartIndex(); ;
+        }
+        else if(pcTexture->accessPartInfo(0) == 3) //Nx2N case
+        {
+          bTrySplit = false;
+          bTryNx2N = true;
+          bTry2NxN = false;
+          //uiPrevTexPartIndex = pcTexture->getTexPartIndex();  
+          pcTexture->incrementTexPartIndex(); ;
+        }
+      }
+#endif
+
 
       // do inter modes, SKIP and 2Nx2N
@@ -648,63 +752,96 @@
 #endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
-        rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-        // SKIP
-#if HHI_INTERVIEW_SKIP
-        xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, bFullyRenderedSec );
-#else
-        xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU );
-#endif
-        rpcTempCU->initEstData( uiDepth, iQP );
-
-        // fast encoder decision for early skip
-        if ( m_pcEncCfg->getUseFastEnc() )
+          rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+          // SKIP
+#if HHI_INTERVIEW_SKIP
+          xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, bFullyRenderedSec );
+#else
+          xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU );
+#endif
+          rpcTempCU->initEstData( uiDepth, iQP );
+
+          // fast encoder decision for early skip
+          if ( m_pcEncCfg->getUseFastEnc() )
+          {
+            Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];
+            if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] )
+            {
+              bEarlySkip = true;
+              bTrySplit  = false;
+            }
+          }
+
+          // 2Nx2N, NxN
+          if ( !bEarlySkip )
+          {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFullyRenderedSec );
+
+#else
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
+#endif
+            rpcTempCU->initEstData( uiDepth, iQP );
+            if(m_pcEncCfg->getUseCbfFastMode())
+            {
+              doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+            }
+
+#if FORCE_REF_VSP==1
+#if VSP_CFG
+            if( rpcBestCU->getSlice()->getSPS()->getVspDepthPresentFlag() || !rpcBestCU->getSlice()->getSPS()->isDepth() )
+#else
+            if( !rpcBestCU->getSlice()->getVspDepthDisableFlag() || !rpcBestCU->getSlice()->getSPS()->isDepth() )
+#endif
+            if( bWholeCUCanBeSynthesized )
+            {
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFullyRenderedSec, false, true ); // VSP
+#else
+              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
+#endif
+              rpcTempCU->initEstData( uiDepth, iQP );
+            }
+#else
+            if( bWholeCUCanBeSynthesized ) // To avoid compiling warning
+            {
+            }
+#endif
+          }
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+        } // uiResPrdId
+#endif
+      } // != I_SLICE
+
+#if OL_DEPTHLIMIT_A0044
+#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() )
         {
-          Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];
-          if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] )
+          if(iQP == iBaseQP)
           {
-            bEarlySkip = true;
-            bTrySplit  = false;
+            bTrySplitDQP = bTrySplit;
           }
         }
-
-        // 2Nx2N, NxN
-        if ( !bEarlySkip )
+        else
         {
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-          rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFullyRenderedSec );
-
-#else
-            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
-#endif
-          rpcTempCU->initEstData( uiDepth, iQP );
-          if(m_pcEncCfg->getUseCbfFastMode())
-          {
-            doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
-          }
-
-#if FORCE_REF_VSP==1
-#if VSP_TEXT_ONLY
-          if( !rpcBestCU->getSlice()->getSPS()->isDepth() )
-#endif
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFullyRenderedSec, false, true ); // VSP
-#else
-            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
-#endif
-            rpcTempCU->initEstData( uiDepth, iQP );
-#endif
+          bTrySplitDQP = bTrySplit;
         }
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-        } // uiResPrdId
-#endif
-      } // != I_SLICE
-
+      }
+#else
 
       if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() )
@@ -719,4 +856,5 @@
         bTrySplitDQP = bTrySplit;
       }
+#endif
 #if LOSSLESS_CODING
       if (isAddLowestQP && (iQP == lowestQP))
@@ -760,255 +898,537 @@
           Bool bResPredFlag  = ( uiResPrdId > 0 );
 #endif
-        // 2Nx2N, NxN
-        if ( !bEarlySkip )
-        {
-
-        if(!( rpcBestCU->getSlice()->getSPS()->getDisInter4x4()  && (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) ))
-        {
-          if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu)
+          // 2Nx2N, NxN
+          if ( !bEarlySkip )
           {
-#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 );
-          }
-        }
-        }
-
-        { // 2NxN, Nx2N
-          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 )
+
+            if(!( rpcBestCU->getSlice()->getSPS()->getDisInter4x4()  && (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) ))
             {
-              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_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;
-            }
-          }
-        }
-
-#if 1
-        //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N)
-        if( pcPic->getSlice(0)->getSPS()->getAMPAcc(uiDepth) )
-        {
-#if AMP_ENC_SPEEDUP        
-          Bool bTestAMP_Hor = false, bTestAMP_Ver = false;
-
-#if AMP_MRG
-          Bool bTestMergeAMP_Hor = false, bTestMergeAMP_Ver = false;
-
-          deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver, bTestMergeAMP_Hor, bTestMergeAMP_Ver);
-#else
-          deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver);
-#endif
-
-          //! Do horizontal AMP
-          if ( bTestAMP_Hor )
-          {
-            if(doNotBlockPu)
-            {
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec );
-#else
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
-#endif
-              rpcTempCU->initEstData( uiDepth, iQP );
-              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
+              if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu)
               {
-                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 );
-#else
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
-#endif
-              rpcTempCU->initEstData( uiDepth, iQP );
-              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
-              {
-                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+#if OL_DEPTHLIMIT_A0044 //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
+                {
+                  if (bTrySplit)
+                  {
+#endif
+#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 );
+#if OL_DEPTHLIMIT_A0044
+                  }//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
               }
             }
           }
-#if AMP_MRG
-          else if ( bTestMergeAMP_Hor ) 
-          {
-            if(doNotBlockPu)
+
+          { // 2NxN, Nx2N
+#if OL_DEPTHLIMIT_A0044 //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
             {
-#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 )
+              if (bTryNx2N)
               {
-                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+#endif
+                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;
+                  }
+                }
+#if OL_DEPTHLIMIT_A0044
+              }//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;
+                }
               }
             }
-            if(doNotBlockPu)
+#endif
+
+#if OL_DEPTHLIMIT_A0044 //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
             {
-#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 )
+              if (bTry2NxN)
               {
-                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+#endif
+                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;
+                  }
+                }
+#if OL_DEPTHLIMIT_A0044
+              }//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
           }
-#endif
-
-          //! Do horizontal AMP
-          if ( bTestAMP_Ver )
+
+#if 1
+          //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N)
+          if( pcPic->getSlice(0)->getSPS()->getAMPAcc(uiDepth) )
           {
-            if(doNotBlockPu)
+#if AMP_ENC_SPEEDUP        
+            Bool bTestAMP_Hor = false, bTestAMP_Ver = false;
+
+#if AMP_MRG
+            Bool bTestMergeAMP_Hor = false, bTestMergeAMP_Ver = false;
+
+            deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver, bTestMergeAMP_Hor, bTestMergeAMP_Ver);
+#else
+            deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver);
+#endif
+
+            //! Do horizontal AMP
+            if ( bTestAMP_Hor )
             {
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec );
-#else
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
-#endif
-              rpcTempCU->initEstData( uiDepth, iQP );
-              if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
+#if OL_DEPTHLIMIT_A0044 //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
               {
-                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+                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 );
+#else
+                    xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
+#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 );
+#else
+                    xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
+#endif
+                    rpcTempCU->initEstData( uiDepth, iQP );
+                    if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
+                    {
+                      doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+                    }
+                  }
+#if OL_DEPTHLIMIT_A0044
+                }//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 );
+#else
+                  xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
+#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 );
+#else
+                  xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
+#endif
+                  rpcTempCU->initEstData( uiDepth, iQP );
+                  if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
+                  {
+                    doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+                  }
+                }
               }
+#endif
             }
-            if(doNotBlockPu)
+#if AMP_MRG
+            else if ( bTestMergeAMP_Hor ) 
             {
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec );
-#else
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
-#endif
-              rpcTempCU->initEstData( uiDepth, iQP );
+#if OL_DEPTHLIMIT_A0044 //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
+              {
+                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_A0044
+                }//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_A0044 //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
+              {
+                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 );
+#else
+                    xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
+#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 );
+#else
+                    xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
+#endif
+                    rpcTempCU->initEstData( uiDepth, iQP );
+                  }
+#if OL_DEPTHLIMIT_A0044
+                }//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 );
+#else
+                  xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
+#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 );
+#else
+                  xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
+#endif
+                  rpcTempCU->initEstData( uiDepth, iQP );
+                }
+              }
+#endif
+            }
 #if AMP_MRG
-          else if ( bTestMergeAMP_Ver )
-          {
-            if(doNotBlockPu)
+            else if ( bTestMergeAMP_Ver )
             {
-#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 )
+#if OL_DEPTHLIMIT_A0044 //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
               {
-                doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
+                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_A0044
+                }//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
             }
-            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
-
-#else
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec );
-#else
-          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
-#endif
-          rpcTempCU->initEstData( uiDepth, iQP );
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec );
-#else
-          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
-#endif
-          rpcTempCU->initEstData( uiDepth, iQP );
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec );
-#else
-          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
-#endif
-          rpcTempCU->initEstData( uiDepth, iQP );
-#if HHI_INTER_VIEW_RESIDUAL_PRED
-              rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
-#endif
-#if HHI_INTERVIEW_SKIP
-              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec );
-#else
-          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
-#endif
-          rpcTempCU->initEstData( uiDepth, iQP );
-
-#endif
-        } //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N)
+#endif
+
+#else
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec );
+#else
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
+#endif
+            rpcTempCU->initEstData( uiDepth, iQP );
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec );
+#else
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
+#endif
+            rpcTempCU->initEstData( uiDepth, iQP );
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec );
+#else
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
+#endif
+            rpcTempCU->initEstData( uiDepth, iQP );
+#if HHI_INTER_VIEW_RESIDUAL_PRED
+            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
+#endif
+#if HHI_INTERVIEW_SKIP
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec );
+#else
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
+#endif
+            rpcTempCU->initEstData( uiDepth, iQP );
+
+#endif
+          } //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N)
 #endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -1026,8 +1446,8 @@
         // speedup for inter frames
 #if HHI_INTERVIEW_SKIP
-      if( ( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
-               rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
-               rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
-               rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 ) && !bFullyRenderedSec ) // avoid very complex intra if it is unlikely
+        if( ( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
+          rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
+          rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
+          rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 ) && !bFullyRenderedSec ) // avoid very complex intra if it is unlikely
 #else
         if( rpcBestCU->getSlice()->getSliceType() == I_SLICE || 
@@ -1041,9 +1461,32 @@
           if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
           {
-            if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
+#if OL_DEPTHLIMIT_A0044 //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
             {
-              xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
-              rpcTempCU->initEstData( uiDepth, iQP );
+              if (bTrySplit)
+              {
+
+#endif
+                if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
+                {
+                  xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
+                  rpcTempCU->initEstData( uiDepth, iQP );
+                }
+#if OL_DEPTHLIMIT_A0044
+              }//bTrySplit
+            }//depthMapDetect
+            else
+            {
+              if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
+              {
+                xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
+                rpcTempCU->initEstData( uiDepth, iQP );
+              }
             }
+#endif
           }
         }
@@ -1101,5 +1544,5 @@
 #endif
     {
-    rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );
+      rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );
     }
 
@@ -1125,5 +1568,5 @@
     }
 #if HHI_INTERVIEW_SKIP
-  rpcBestCU->setRenderableSubParts(bFullyRenderedSec,0,rpcBestCU->getDepth( 0 )) ;
+    rpcBestCU->setRenderableSubParts(bFullyRenderedSec,0,rpcBestCU->getDepth( 0 )) ;
 #endif
   }
@@ -1189,8 +1632,8 @@
   {
 #if LOSSLESS_CODING
-      if (isAddLowestQP && (iQP == iMinQP))
-      {
-        iQP = lowestQP;
-      }
+    if (isAddLowestQP && (iQP == iMinQP))
+    {
+      iQP = lowestQP;
+    }
 #endif
     rpcTempCU->initEstData( uiDepth, iQP );
@@ -1301,5 +1744,5 @@
 #endif
       {           
-      rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
       }
 
@@ -1344,5 +1787,5 @@
 #endif
           {
-          rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+            rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
           }
 #endif
@@ -1393,8 +1836,8 @@
     }                                                                                  // with sub partitioned prediction.
 #if LOSSLESS_CODING
-      if (isAddLowestQP && (iQP == lowestQP))
-      {
-        iQP = iMinQP;
-      }
+    if (isAddLowestQP && (iQP == lowestQP))
+    {
+      iQP = iMinQP;
+    }
 #endif
   } // SPLIT- QP Loop
@@ -1403,9 +1846,9 @@
   if( m_pcRdCost->getUseRenModel() )
   {
-      UInt  uiWidth     = m_ppcRecoYuvBest[uiDepth]->getWidth   ( );
-      UInt  uiHeight    = m_ppcRecoYuvBest[uiDepth]->getHeight  ( );
-      Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
-      UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride  ( );
-      m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+    UInt  uiWidth     = m_ppcRecoYuvBest[uiDepth]->getWidth   ( );
+    UInt  uiHeight    = m_ppcRecoYuvBest[uiDepth]->getHeight  ( );
+    Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
+    UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride  ( );
+    m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
   }
 #endif
@@ -1608,6 +2051,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
@@ -1624,5 +2073,8 @@
 
     if( ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
+    {
       m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
+    }
+
     if( !pcCU->getSlice()->isIntra() )
     {
@@ -1631,6 +2083,8 @@
 #if FORCE_REF_VSP==1
       if( (pcCU->isSkipped( uiAbsPartIdx ) || pcCU->isVspMode( uiAbsPartIdx )) && pcCU->getSlice()->getViewId() != 0 )
-#if VSP_TEXT_ONLY
-      if( !pcCU->getSlice()->getSPS()->isDepth() )
+#if VSP_CFG
+      if( pcCU->getSlice()->getSPS()->getVspDepthPresentFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
+#else
+      if( !pcCU->getSlice()->getVspDepthDisableFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
 #endif
       {
@@ -1647,7 +2101,4 @@
       m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 );
       finishCU(pcCU,uiAbsPartIdx,uiDepth);
-#if DEBUGLOGOUT
-      m_cDebug.DebugLogOut( pcCU, uiAbsPartIdx, uiDepth );
-#endif
       xRestoreDepthWidthHeight( pcCU );
       return;
@@ -1694,4 +2145,5 @@
 #if HHI_MPI
   if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
+{
 #endif
   if( !pcCU->getSlice()->isIntra() )
@@ -1700,7 +2152,9 @@
 
 #if FORCE_REF_VSP==1
-    if( (pcCU->isSkipped( uiAbsPartIdx ) || pcCU->isVspMode( uiAbsPartIdx )) && pcCU->getSlice()->getViewId() != 0 )
-#if VSP_TEXT_ONLY
-    if( !pcCU->getSlice()->getSPS()->isDepth() )
+    if( (pcCU->isSkipped( uiAbsPartIdx ) || pcCU->isVspMode( uiAbsPartIdx )) && pcCU->getSlice()->getViewId() != 0 )]
+#if VSP_CFG
+    if( pcCU->getSlice()->getSPS()->getVspDepthPresentFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
+#else
+    if( !pcCU->getSlice()->getVspDepthDisableFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
 #endif
     {
@@ -1709,4 +2163,7 @@
 #endif
   }
+#if HHI_MPI
+}
+#endif
   
   if( pcCU->isSkipped( uiAbsPartIdx ) )
@@ -1715,4 +2172,11 @@
 #endif
   {
+#if OL_DEPTHLIMIT_A0044
+    if(pcCU->getPartDumpFlag())
+    {
+      pcCU->updatePartInfo(0,uiDepth);
+      pcCU->incrementPartInfo();
+    }
+#endif
     m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 );
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -1720,7 +2184,4 @@
 #endif
     finishCU(pcCU,uiAbsPartIdx,uiDepth);
-#if DEBUGLOGOUT
-    m_cDebug.DebugLogOut( pcCU, uiAbsPartIdx, uiDepth );
-#endif
     return;
   }
@@ -1730,7 +2191,4 @@
   {
     finishCU(pcCU,uiAbsPartIdx,uiDepth);
-#if DEBUGLOGOUT
-    m_cDebug.DebugLogOut( pcCU, uiAbsPartIdx, uiDepth );
-#endif
     return;
   }
@@ -1753,7 +2211,4 @@
       // Encode slice finish
       finishCU(pcCU,uiAbsPartIdx,uiDepth);
-#if DEBUGLOGOUT
-      m_cDebug.DebugLogOut( pcCU, uiAbsPartIdx, uiDepth );
-#endif
       return;
     }
@@ -1779,7 +2234,4 @@
   // --- write terminating bit ---
   finishCU(pcCU,uiAbsPartIdx,uiDepth);
-#if DEBUGLOGOUT
-  m_cDebug.DebugLogOut( pcCU, uiAbsPartIdx, uiDepth );
-#endif
 }
 
@@ -2613,6 +3065,9 @@
       }
 #if VSP_N
-#if !(!VSP_TEXT_ONLY && FORCE_REF_VSP==2)
-      else // inter
+#if VSP_CFG
+      else if( (!rpcTempCU->getSlice()->getSPS()->getVspDepthPresentFlag() && rpcTempCU->getSlice()->getViewId() ) || FORCE_REF_VSP!=2 ) // inter
+#else
+      else if( rpcTempCU->getSlice()->getVspDepthDisableFlag() || FORCE_REF_VSP!=2 ) // inter
+#endif
       {
         Int aiRefIdx[2] = {NOT_VALID, NOT_VALID};
@@ -2620,5 +3075,9 @@
         {
           aiRefIdx[iList] = pcTextureCU->getCUMvField( RefPicList(iList) )->getRefIdx( rpcTempCU->getZorderIdxInCU() + ui );
-          if( aiRefIdx[iList] >= 0 && pcTextureCU->getSlice()->getRefViewId( RefPicList(iList), aiRefIdx[iList] ) == NUM_VIEW_VSP )
+#if VSP_CFG
+          if( aiRefIdx[iList] >= rpcTempCU->getSlice()->getNumRefIdx( RefPicList(iList) ) )
+#else
+          if( aiRefIdx[iList] >= 0 && pcTextureCU->isVspRef( RefPicList(iList), aiRefIdx[iList] ) )
+#endif
           {
             return;
@@ -2630,5 +3089,4 @@
         //}
       }
-#endif
 #endif
     }
@@ -2830,6 +3288,8 @@
 #if FORCE_REF_VSP==1
   if( (pcCU->isSkipped( 0 ) || pcCU->isVspMode( 0 )) && pcCU->getSlice()->getViewId() != 0 )
-#if VSP_TEXT_ONLY
-  if( !pcCU->getSlice()->getSPS()->isDepth() )
+#if VSP_CFG
+  if( pcCU->getSlice()->getSPS()->getVspDepthPresentFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
+#else
+  if( !pcCU->getSlice()->getVspDepthDisableFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
 #endif
     m_pcEntropyCoder->encodeVspFlag ( pcCU, 0, true );
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCu.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncCu.h	(revision 193)
@@ -46,7 +46,4 @@
 #include "TLibCommon/TComBitCounter.h"
 #include "TLibCommon/TComDataCU.h"
-#if DEBUGLOGOUT
-#include "TLibCommon/DebugLog.h"
-#endif
 
 #include "TEncEntropy.h"
@@ -116,8 +113,4 @@
 
 public:
-#if DEBUGLOGOUT
-  DebugLog                m_cDebug;
-#endif
-
   /// copy parameters from encoder class
   Void  init                ( TEncTop* pcEncTop );
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 193)
@@ -1370,5 +1370,5 @@
 #if VSP_MV_ZERO
           Int iRefIdx = pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx(uiSubPartIdx);
-          if( !(pcCU->getSlice()->getViewId() && iRefIdx >= 0 && pcCU->getSlice()->getRefViewId( RefPicList( uiRefListIdx ), iRefIdx ) == NUM_VIEW_VSP) )
+          if( !(pcCU->getSlice()->getViewId() && iRefIdx >= 0 && pcCU->isVspRef( RefPicList( uiRefListIdx ), iRefIdx )) )
           {
 #endif
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 193)
@@ -332,15 +332,45 @@
 #endif
 
+#if VSP_SLICE_HEADER && VSP_CFG
+      pcSlice->setNumVspRefPics( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numVSPRefPics );
+      pcSlice->setVspFlag( m_pcEncTop->getUseVSP() && pcSlice->getNumVspRefPics() > 0 );
+      for( UInt i = 0; i < pcSlice->getNumVspRefPics(); i++ )
+      {
+        pcSlice->setVspRefPos( REF_PIC_LIST_0, i, m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_VSPRefPosL0[i] );
+        if( pcSlice->getSliceType() == B_SLICE )
+        {
+          pcSlice->setVspRefPos( REF_PIC_LIST_1, i, m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_VSPRefPosL1[i] );
+        }
+      }
+#endif
+
 #if VSP_N
+#if VSP_CFG
+      Int NumberOfVspRefsL0 = ( ( pcPic->getViewId()==0
+                                || (m_pcEncTop->getVSPDepthDisable() && m_pcEncTop->getIsDepth())
+#if VSP_SLICE_HEADER
+                                || !pcSlice->getVspFlag()
+#endif
+                                || pcSlice->getVspRefPos( REF_PIC_LIST_0, 0 ) == 0
+                              ) ? 0 : 1 );
+      Int NumberOfVspRefsL1 = ( ( pcPic->getViewId()==0
+                                || (m_pcEncTop->getVSPDepthDisable() && m_pcEncTop->getIsDepth())
+#if VSP_SLICE_HEADER
+                                || !pcSlice->getVspFlag()
+#endif
+                                || pcSlice->getVspRefPos( REF_PIC_LIST_1, 0 ) == 0
+                              ) ? 0 : 1 );
+      pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive + NumberOfVspRefsL0, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs() + NumberOfVspRefsL0) ) );
+      pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive + NumberOfVspRefsL1, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs() + NumberOfVspRefsL1) ) );
+#else
       Int NumberOfVspRefs = ( ( pcPic->getViewId()==0
-#if VSP_TEXT_ONLY
-                                || m_pcEncTop->getIsDepth()
-#endif
+                                || (m_pcEncTop->getVSPDepthDisable() && m_pcEncTop->getIsDepth())
 #if VSP_SLICE_HEADER
-                                || !m_pcEncTop->getUseVSP()
+                                || !pcSlice->getVspFlag()
 #endif
                               ) ? 0 : 1 );
       pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive + NumberOfVspRefs, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs() + NumberOfVspRefs) ) );
       pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive + NumberOfVspRefs, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs() + NumberOfVspRefs) ) );
+#endif
 #else
       pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
@@ -373,16 +403,31 @@
 #if VSP_N
       Bool bUseVsp = (pcPic->getViewId()!=0);
-#if VSP_TEXT_ONLY
-      if( m_pcEncTop->getIsDepth() ) bUseVsp = false;
-#endif
+      if( m_pcEncTop->getVSPDepthDisable() && m_pcEncTop->getIsDepth() ) bUseVsp = false;
 #if VSP_SLICE_HEADER
+#if VSP_CFG
+      if( !pcSlice->getVspFlag() ) bUseVsp = false;
+#else
       if( !m_pcEncTop->getUseVSP() ) bUseVsp = false;
 #endif
+#endif
+
+#if VSP_SLICE_HEADER
+      if( bUseVsp )
+#endif
+      {
+        m_pcEncTop->getVSPBuf()->getCurrSlice()->setPOC( pcPic->getPOC() );
+        m_pcEncTop->getVSPBuf()->getCurrSlice()->setViewId( pcPic->getViewId() );
+      }
+
       pcSlice->setRefPicListMvc( rcListPic, apcInterViewRefPics, bUseVsp ? m_pcEncTop->getVSPBuf() : NULL );
 #else
       pcSlice->setRefPicListMvc( rcListPic, apcInterViewRefPics );
 #endif
+
+#if !VSP_CFG
 #if VSP_SLICE_HEADER
-      pcSlice->setVspFlag( bUseVsp );
+      pcSlice->setVspFlag( m_pcEncTop->getUseVSP() );
+      pcSlice->setVspDepthDisableFlag( m_pcEncTop->getVSPDepthDisable() );
+#endif
 #endif
 
@@ -471,4 +516,5 @@
     Int iVSOMode = m_pcEncTop->getVSOMode();
     m_pcRdCost->setVSOMode( iVSOMode  );
+
 #if HHI_VSO_DIST_INT
     m_pcRdCost->setAllowNegDist( m_pcEncTop->getAllowNegDist() );
@@ -491,5 +537,8 @@
     m_pcRdCost->setDepthPicYuv   ( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) );
 #endif
-
+#if LGE_WVSO_A0119
+    Bool bUseWVSO  = m_pcEncTop->getUseWVSO();
+    m_pcRdCost->setUseWVSO( bUseWVSO );
+#endif
 
   }
@@ -1157,24 +1206,26 @@
           m_pcSbacCoder->load( &pcSbacCoders[0] );
 
-#if DEBUGLOGOUT
-        char fname[128];
-        sprintf(fname, "%sV%02d_%05d%s.csv", "Log", pcSlice->getViewId(), uiPOCCurr, pcSlice->getIsDepth() ? "depth":"text");
-        getSliceEncoder()->getCUEncoder()->m_cDebug.DebugLogFileOpen( fname );
-#endif
-
         pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength );
         if (!bEntropySlice)
         {
+#if OL_DEPTHLIMIT_A0044 //start dumping partition information
+          m_pcSliceEncoder->setPartDumpFlag(1);
+#endif
           pcSlice->setTileLocationCount ( 0 );
           m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info.
+#if OL_DEPTHLIMIT_A0044 //stop dumping partition information
+          m_pcSliceEncoder->setPartDumpFlag(0);
+#endif
         }
         else
         {
+#if OL_DEPTHLIMIT_A0044 //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 DEBUGLOGOUT
-        getSliceEncoder()->getCUEncoder()->m_cDebug.DebugLogFileClose();
-#endif
+#if OL_DEPTHLIMIT_A0044 //stop dumping partition information
+          m_pcSliceEncoder->setPartDumpFlag(0);
+#endif
+        }
 
         {
@@ -2187,4 +2238,11 @@
         printf( "V%d ", pcSlice->getRefViewId( RefPicList(iRefList), iRefIndex ) );
       }
+#if VSP_CFG
+      else if( pcSlice->getViewId() == pcSlice->getRefViewId( RefPicList(iRefList), iRefIndex )
+            && pcSlice->getPOC()    == pcSlice->getRefPOC( RefPicList(iRefList), iRefIndex ) )
+      {
+        printf( "VS " );
+      }
+#endif
       else
       {
@@ -2203,4 +2261,11 @@
         printf( "V%d ", pcSlice->getRefViewId( (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIndex), pcSlice->getRefIdxFromIdxOfLC(iRefIndex) ) );
       }
+#if VSP_CFG
+      else if( pcSlice->getViewId() == pcSlice->getRefViewId( (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIndex), pcSlice->getRefIdxFromIdxOfLC(iRefIndex) )
+            && pcSlice->getPOC()    == pcSlice->getRefPOC( (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIndex), pcSlice->getRefIdxFromIdxOfLC(iRefIndex) ) )
+      {
+        printf( "VS " );
+      }
+#endif
       else
       {
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncGOP.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncGOP.h	(revision 193)
@@ -146,5 +146,4 @@
   Void freeAPS     (TComAPS* pAPS, TComSPS* pSPS);
   Void allocAPS    (TComAPS* pAPS, TComSPS* pSPS);
-
 protected:
   Void encodeAPS   (TComAPS* pcAPS, TComOutputBitstream& APSbs, TComSlice* pcSlice);            //!< encode APS syntax elements
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 193)
@@ -580,4 +580,7 @@
 {
   PartSize eSize         = pcCU->getPartitionSize( uiAbsPartIdx );
+#if OL_DEPTHLIMIT_A0044
+  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_A0044
+      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_A0044
+    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;
   }
@@ -591,12 +609,19 @@
   switch(eSize)
   {
-    case SIZE_2Nx2N:
+  case SIZE_2Nx2N:
     {
       m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+#if OL_DEPTHLIMIT_A0044
+      if(pcCU->getPartDumpFlag())
+      {
+        pcCU->updatePartInfo(0,uiDepth); //0 for 2Nx2N
+        pcCU->incrementPartInfo();
+      }
+#endif
       break;
     }
-    case SIZE_2NxN:
-    case SIZE_2NxnU:
-    case SIZE_2NxnD:
+  case SIZE_2NxN:
+  case SIZE_2NxnU:
+  case SIZE_2NxnD:
     {
       m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
@@ -623,9 +648,16 @@
         }
       }
+#if OL_DEPTHLIMIT_A0044
+      if(pcCU->getPartDumpFlag())
+      {
+        pcCU->updatePartInfo(2,uiDepth); //2 for 2NxN
+        pcCU->incrementPartInfo();
+      }
+#endif
       break;
     }
-    case SIZE_Nx2N:
-    case SIZE_nLx2N:
-    case SIZE_nRx2N:
+  case SIZE_Nx2N:
+  case SIZE_nLx2N:
+  case SIZE_nRx2N:
     {
       m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
@@ -656,7 +688,14 @@
         }
       }
+#if OL_DEPTHLIMIT_A0044
+      if(pcCU->getPartDumpFlag())
+      {
+        pcCU->updatePartInfo(3,uiDepth); //3 for Nx2N
+        pcCU->incrementPartInfo();
+      }
+#endif
       break;
     }
-    case SIZE_NxN:
+  case SIZE_NxN:
     {
       if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getSlice()->getSPS()->getDisInter4x4() && pcCU->getWidth(uiAbsPartIdx) == 8 && pcCU->getHeight(uiAbsPartIdx) == 8 ) )
@@ -665,8 +704,25 @@
         m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
         m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 2) );
+#if OL_DEPTHLIMIT_A0044
+        if(pcCU->getPartDumpFlag())
+        {
+          pcCU->updatePartInfo(1,uiDepth); //2Nx2N here since we disable NxN in Inter
+          pcCU->incrementPartInfo();         
+        }
+#endif
+      }
+      else
+      {
+#if OL_DEPTHLIMIT_A0044
+        if(pcCU->getPartDumpFlag())
+        {
+          pcCU->updatePartInfo(0,uiDepth); //2Nx2N here since we disable NxN in Inter
+          pcCU->incrementPartInfo();
+        }
+#endif
       }
       break;
     }
-    default:
+  default:
     {
       assert(0);
@@ -785,13 +841,20 @@
   uiNumCand = pcCU->getSlice()->getMaxNumMergeCand();
 #if HHI_MPI
-#if VSP_TEXT_ONLY
+#if VSP_N
   TComDataCU* pcTextCU = pcCU->getSlice()->getSPS()->getUseMVI() ? pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ) : NULL;
   Int aiRefIdxVsp[2] = { pcTextCU ? pcTextCU->getCUMvField( RefPicList(0) )->getRefIdx( uiAbsPartIdx ) : -1,
                          pcTextCU ? pcTextCU->getCUMvField( RefPicList(1) )->getRefIdx( uiAbsPartIdx ) : -1 };
-  const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE
-    && !( aiRefIdxVsp[0] >= 0 && pcTextCU->getSlice()->getRefViewId( RefPicList(0), aiRefIdxVsp[0] ) == NUM_VIEW_VSP )
-    && !( aiRefIdxVsp[1] >= 0 && pcTextCU->getSlice()->getRefViewId( RefPicList(1), aiRefIdxVsp[1] ) == NUM_VIEW_VSP );
-#else
-  const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
+#if VSP_CFG
+  const Bool bMVIAvailable = (pcCU->getSlice()->getSPS()->getVspDepthPresentFlag() || pcCU->getSlice()->getViewId()==0) 
+                                ? pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE
+                                : pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE
+                                  && !( aiRefIdxVsp[0] >= pcCU->getSlice()->getNumRefIdx( RefPicList(0) ) )
+                                  && !( aiRefIdxVsp[1] >= pcCU->getSlice()->getNumRefIdx( RefPicList(1) ) );
+#else
+  const Bool bMVIAvailable = pcCU->getSlice()->getVspDepthDisableFlag() ? pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE
+                                                                          && !( aiRefIdxVsp[0] >= 0 && pcTextCU->isVspRef( RefPicList(0), aiRefIdxVsp[0] ) )
+                                                                          && !( aiRefIdxVsp[1] >= 0 && pcTextCU->isVspRef( RefPicList(1), aiRefIdxVsp[1] ) )
+                                                                        : pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
+#endif
 #endif
   if( bMVIAvailable )
@@ -858,4 +921,14 @@
   assert( uiCtx < 3 );
   m_pcBinIf->encodeBin( uiCurrSplitFlag, m_cCUSplitFlagSCModel.get( 0, 0, uiCtx ) );
+#if OL_DEPTHLIMIT_A0044
+  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.1-VSP-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 193)
@@ -882,6 +882,8 @@
 #if FORCE_REF_VSP==1
         if( pcCU->getSlice()->getViewId() != 0 )
-#if VSP_TEXT_ONLY
-        if( !pcCU->getSlice()->getSPS()->isDepth() )
+#if VSP_CFG
+        if( pcCU->getSlice()->getSPS()->getVspDepthPresentFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
+#else
+        if( !pcCU->getSlice()->getVspDepthDisableFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
 #endif
           m_pcEntropyCoder->encodeVspFlag ( pcCU, 0, true );
@@ -1145,11 +1147,24 @@
   if ( m_pcRdCost->getUseVSO() )
   {
-    ruiDist += m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, false, 0 );
+#if LGE_WVSO_A0119
+    if ( m_pcRdCost->getUseWVSO() )
+    {    
+      Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+      Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+      Dist iD = (Dist) m_pcRdCost->getDistPart( piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight );
+      Dist iVSO = m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, false, 0 );
+      ruiDist += (iDWeight * iD + iVSOWeight * iVSO) / ( iDWeight + iVSOWeight);
+    }
+    else
+#endif
+    {
+      ruiDist += m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, false, 0 );
+    }
   }
   else
 #endif
   {
-  ruiDist += m_pcRdCost->getDistPart( piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight );
-}
+    ruiDist += m_pcRdCost->getDistPart( piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight );
+  }
 }
 
@@ -1918,4 +1933,13 @@
 
             uiSad = (Dist) ( m_pcRdCost->getDistPart( piPred, uiStride, piOrg, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset), pcVirRec->getStride(), uiWidth, uiHeight ) );
+#if LGE_WVSO_A0119
+            if ( m_pcRdCost->getUseWVSO() )
+            {    
+              Int iDWeight = m_pcRdCost->getDWeight();
+              Int iVSDWeight = m_pcRdCost->getVSDWeight();
+              Dist iD = (Dist) m_pcRdCost->calcHAD( piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
+              uiSad = (Dist) (iDWeight * iD + iVSDWeight * uiSad) / (iDWeight + iVSDWeight);
+            }
+#endif
           }
           else
@@ -1924,4 +1948,13 @@
             Bool bSad = !m_pcRdCost->getUseRenModel();
             uiSad = m_pcRdCost->getDistVS(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, bSad, 0 );
+#if LGE_WVSO_A0119
+            if ( m_pcRdCost->getUseWVSO() )
+            {    
+              Int iDWeight = m_pcRdCost->getDWeight()*m_pcRdCost->getDWeight();
+              Int iVSDWeight = m_pcRdCost->getVSOWeight()*m_pcRdCost->getVSOWeight();
+              Dist iD = (Dist) m_pcRdCost->getDistPart( piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
+              uiSad = (Dist) (iDWeight * iD + iVSDWeight * uiSad) / (iDWeight + iVSDWeight);
+            }
+#endif
           }
 
@@ -2960,5 +2993,5 @@
       {
 #if VSP_MV_ZERO
-        bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp) == NUM_VIEW_VSP);
+        bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(eRefPicList, iRefIdxTemp));
         //if( bIsVsp && !bWholeCUCanBeSynthesized )
         //{
@@ -2969,5 +3002,9 @@
         if( pcCU->getResPredFlag( 0 ))
         {
-          if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
+          if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp)
+#if VSP_N
+          && pcCU->getSlice()->getPOC() != pcCU->getSlice()->getRefPOC(eRefPicList, iRefIdxTemp)
+#endif
+            )
           { // subtract residual prediction from original in motion search
             if(!bLastResiFlag)
@@ -3068,5 +3105,5 @@
               {
 #if VSP_MV_ZERO
-                if( pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp) == NUM_VIEW_VSP )
+                if( pcCU->getSlice()->getViewId() && pcCU->isVspRef(eRefPicList, iRefIdxTemp) )
                 {
                   cMvTemp[1][iRefIdxTemp].setZero();
@@ -3214,5 +3251,5 @@
       {
 #if VSP_MV_ZERO
-        bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(REF_PIC_LIST_1, bestBiPRefIdxL1) == NUM_VIEW_VSP);
+        bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(REF_PIC_LIST_1, bestBiPRefIdxL1));
 
         if( bIsVsp )
@@ -3314,5 +3351,5 @@
         {
 #if VSP_MV_ZERO
-          bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp) == NUM_VIEW_VSP);
+          bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(eRefPicList, iRefIdxTemp));
           //if( bIsVsp && !bWholeCUCanBeSynthesized )
           //{
@@ -3343,7 +3380,15 @@
 
           iPredFrom = iBestRefIdx >= 0 ? 3 : 1;
-          if(iBestRefIdx >= 0 && pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx))
+          if(iBestRefIdx >= 0 && pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx)
+#if VSP_N
+                              && pcCU->getSlice()->getPOC() != pcCU->getSlice()->getRefPOC(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx)
+#endif
+            )
             iAddResiShift++;
-          if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
+          if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp)
+#if VSP_N
+          && pcCU->getSlice()->getPOC() != pcCU->getSlice()->getRefPOC(eRefPicList, iRefIdxTemp)
+#endif
+            )
             iAddResiShift++;
           iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || iPredFrom != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
@@ -3420,5 +3465,5 @@
           {
 #if VSP_MV_ZERO
-            bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(REF_PIC_LIST_0, iRefIdxBi[0]) == NUM_VIEW_VSP);
+            bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(REF_PIC_LIST_0, iRefIdxBi[0]));
 
             if( !bIsVsp )
@@ -3435,5 +3480,5 @@
 #endif
 #if VSP_MV_ZERO
-              bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(REF_PIC_LIST_1, iRefIdxBi[1]) == NUM_VIEW_VSP);
+              bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(REF_PIC_LIST_1, iRefIdxBi[1]));
 
               if( !bIsVsp )
@@ -3606,5 +3651,5 @@
       
 #if VSP_MV_ZERO
-      bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(REF_PIC_LIST_0, iRefIdxBi[0]) == NUM_VIEW_VSP);
+      bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(REF_PIC_LIST_0, iRefIdxBi[0]));
       if( !bIsVsp )
       {
@@ -3614,5 +3659,5 @@
 #if VSP_MV_ZERO
       }
-      bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(REF_PIC_LIST_1, iRefIdxBi[1]) == NUM_VIEW_VSP);
+      bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(REF_PIC_LIST_1, iRefIdxBi[1]));
       if( !bIsVsp )
       {
@@ -3638,5 +3683,5 @@
       
 #if VSP_MV_ZERO
-      bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(REF_PIC_LIST_0, iRefIdx[0]) == NUM_VIEW_VSP);
+      bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(REF_PIC_LIST_0, iRefIdx[0]));
       if( !bIsVsp )
       {
@@ -3662,5 +3707,5 @@
       
 #if VSP_MV_ZERO
-      bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->getSlice()->getRefViewId(REF_PIC_LIST_1, iRefIdx[1]) == NUM_VIEW_VSP);
+      bIsVsp = (pcCU->getSlice()->getViewId() && pcCU->isVspRef(REF_PIC_LIST_1, iRefIdx[1]));
       if( !bIsVsp )
       {
@@ -4655,4 +4700,13 @@
     {
       uiDistortion = m_pcRdCost->getDistVS( pcCU, 0, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight     , false, 0 );
+#if LGE_WVSO_A0119
+      if ( m_pcRdCost->getUseWVSO() )
+      {    
+        Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+        Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+        Dist iD   = (Dist) m_pcRdCost->getDistPart( rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      );
+        uiDistortion = (iDWeight * iD + iVSOWeight * (Dist)uiDistortion) / ( iDWeight + iVSOWeight);
+      }
+#endif
     }
     else    
@@ -5014,4 +5068,13 @@
   {
     uiDistortionBest = m_pcRdCost->getDistVS  ( pcCU, 0, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight, false, 0    );
+#if LGE_WVSO_A0119
+    if ( m_pcRdCost->getUseWVSO() )
+    {    
+      Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+      Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+      Dist iD        = (Dist) m_pcRdCost->getDistPart( rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      );
+      uiDistortionBest = (iDWeight * iD + iVSOWeight * (Dist) uiDistortionBest) / ( iDWeight + iVSOWeight);
+    }
+#endif
   }
   else
@@ -5249,4 +5312,13 @@
         TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
         uiDistY = m_pcRdCost->getDistPart( m_pTempPel, 1<< uiLog2TrSize, pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPartIdx), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPartIdx), pcVirRec->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize );
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight();
+          Dist iD   = (Dist) m_pcRdCost->getDistPart( m_pTempPel, trWidth, pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth, trHeight );
+          uiDistY = (iDWeight * iD + iVSDWeight * (Dist)uiDistY) / ( iDWeight + iVSDWeight);
+        }
+#endif
       }
       else
@@ -5254,4 +5326,13 @@
       {      
         uiDistY = m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, pcPred->getLumaAddr( uiAbsPartIdx ), pcPred->getStride(), pcOrg->getLumaAddr( uiAbsPartIdx), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); // initialized with zero residual distortion
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+          Dist iD   = (Dist) m_pcRdCost->getDistPart( m_pTempPel, trWidth, pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth, trHeight );
+          uiDistY = (iDWeight * iD + iVSOWeight * (Dist)uiDistY) / ( iDWeight + iVSOWeight);
+        }
+#endif
       }
     }
@@ -5299,4 +5380,13 @@
           TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
           uiNonzeroDistY = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( uiAbsPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), pcVirRec->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiAbsPartIdx ), pcVirOrg->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiAbsPartIdx ), pcVirRec->getStride(), 1<< uiLog2TrSize,    1<< uiLog2TrSize );
+#if LGE_WVSO_A0119
+          if ( m_pcRdCost->getUseWVSO() )
+          {    
+            Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+            Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight();
+            Dist iD = (Dist) m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth,trHeight );
+            uiNonzeroDistY = (iDWeight * iD + iVSDWeight * (Dist) uiNonzeroDistY) / ( iDWeight + iVSDWeight);
+          }
+#endif
         }
         else
@@ -5306,4 +5396,13 @@
           uiNonzeroDistY = m_pcRdCost->getDistVS( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(),
                                                   pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize,   1<< uiLog2TrSize, false, 0 );
+#if LGE_WVSO_A0119
+          if ( m_pcRdCost->getUseWVSO() )
+          {    
+            Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+            Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+            Dist iD = (Dist) m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth,trHeight );
+            uiNonzeroDistY = (iDWeight * iD + iVSOWeight * (Dist) uiNonzeroDistY) / ( iDWeight + iVSOWeight);
+          }
+#endif
         }
       }
@@ -6003,6 +6102,8 @@
 #if FORCE_REF_VSP==1
     if( pcCU->getSlice()->getViewId() != 0 )
-#if VSP_TEXT_ONLY
-    if( !pcCU->getSlice()->getSPS()->isDepth() )
+#if VSP_CFG
+    if( pcCU->getSlice()->getSPS()->getVspDepthPresentFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
+#else
+    if( !pcCU->getSlice()->getVspDepthDisableFlag() || !pcCU->getSlice()->getSPS()->isDepth() )
 #endif
       m_pcEntropyCoder->encodeVspFlag ( pcCU, 0, true );
@@ -6400,4 +6501,13 @@
           TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
           uiActDist = m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight );
+#if LGE_WVSO_A0119
+          if ( m_pcRdCost->getUseWVSO() )
+          {    
+            Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+            Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight();
+            Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD );
+            uiActDist = (iDWeight * iD + iVSDWeight * (Dist) uiActDist) / ( iDWeight + iVSDWeight);
+          }
+#endif // LGE_WVSO_A0119
         }
         else       
@@ -6405,4 +6515,13 @@
         {        
           uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride,  piOrig, uiStride, uiWidth, uiHeight, false, 0 );
+#if LGE_WVSO_A0119
+          if ( m_pcRdCost->getUseWVSO() )
+          {    
+            Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+            Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+            Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD );
+            uiActDist = (iDWeight * iD + iVSOWeight * (Dist) uiActDist) / ( iDWeight + iVSOWeight);
+          }
+#endif // LGE_WVSO_A0119
         }
 #else // FIX_RDO_MACRO
@@ -6413,4 +6532,13 @@
           TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
           uiActDist = m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight );
+#if LGE_WVSO_A0119
+          if ( m_pcRdCost->getUseWVSO() )
+          {    
+            Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+            Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight();
+            Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD );
+            uiActDist = (iDWeight * iD + iVSDWeight * (Dist) uiActDist) / ( iDWeight + iVSDWeight);
+          }
+#endif // LGE_WVSO_A0119
         }
         else       
@@ -6418,4 +6546,13 @@
         {        
           uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride,  piOrig, uiStride, uiWidth, uiHeight, false, 0 );
+#if LGE_WVSO_A0119
+          if ( m_pcRdCost->getUseWVSO() )
+          {    
+            Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+            Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+            Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD );
+            uiActDist = (iDWeight * iD + iVSOWeight * (Dist) uiActDist) / ( iDWeight + iVSOWeight);
+          }
+#endif // LGE_WVSO_A0119
         }
 #endif // SAIT_VSO_EST_A0033 <-- wrong #endif should be removed
@@ -6527,4 +6664,13 @@
         TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
         uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight );
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight();
+          Dist iD = (Dist) m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+          uiActDist = (iDWeight * iD + iVSDWeight * (Int) uiActDist) / ( iDWeight + iVSDWeight);
+        }
+#endif
       }
       else
@@ -6532,4 +6678,13 @@
       {      
         uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+          Dist iD = (Dist) m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+          uiActDist = (iDWeight * iD + iVSOWeight * (Int) uiActDist) / ( iDWeight + iVSOWeight);
+        }
+#endif
       }
     }
@@ -6593,4 +6748,13 @@
         TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
         uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPtIdx), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPtIdx), pcVirRec->getStride(), uiWidth, uiHeight );
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight();
+          Dist iD = (Dist) m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+          uiActDist = (iDWeight * iD + iVSDWeight * (Int) uiActDist) / ( iDWeight + iVSDWeight);
+        }
+#endif
       }
       else
@@ -6598,4 +6762,13 @@
       {      
         uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+          Dist iD = (Dist) m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+          uiActDist = (iDWeight * iD + iVSOWeight * (Int) uiActDist) / ( iDWeight + iVSOWeight);
+        }
+#endif
       }
     }
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 193)
@@ -376,5 +376,19 @@
   m_pcRdCost->setDisparityCoeff( m_pcCfg->getDispCoeff() );
 #endif
-
+#if LGE_WVSO_A0119
+  if( m_pcCfg->getUseWVSO() && m_pcCfg->isDepthCoder() )
+  {
+
+    Int iDWeight, iVSOWeight, iVSDWeight;
+    iDWeight = m_pcCfg->getDWeight();
+    iVSOWeight = m_pcCfg->getVSOWeight();
+    iVSDWeight = m_pcCfg->getVSDWeight();
+
+    m_pcRdCost->setDWeight( iDWeight );
+    m_pcRdCost->setVSOWeight( iVSOWeight );
+    m_pcRdCost->setVSDWeight( iVSDWeight );
+
+  }
+#endif
 #if RDOQ_CHROMA_LAMBDA 
 // for RDOQ
@@ -831,4 +845,8 @@
 #endif
 
+#if OL_DEPTHLIMIT_A0044 //stop dumping partition information
+    m_bDumpPartInfo = 0;
+    pcCU->setPartDumpFlag(m_bDumpPartInfo);
+#endif
 
     // inherit from TR if necessary, select substream to use.
@@ -1290,4 +1308,8 @@
 
     TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );    
+#if OL_DEPTHLIMIT_A0044
+    pcCU->setPartDumpFlag(m_bDumpPartInfo);
+    pcCU->resetPartInfo();
+#endif
 #if !REMOVE_TILE_DEPENDENCE
     if( (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr()==0) && (rpcPic->getPicSym()->getNumColumnsMinus1()!=0) )
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSlice.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncSlice.h	(revision 193)
@@ -101,4 +101,7 @@
   
   UInt                    m_uiSliceIdx;
+#if OL_DEPTHLIMIT_A0044 //flag to signal to start dumping
+  Bool                    m_bDumpPartInfo;
+#endif
 public:
   TEncSlice();
@@ -128,4 +131,7 @@
   UInt    getSliceIdx()         { return m_uiSliceIdx;                    }
   Void    setSliceIdx(UInt i)   { m_uiSliceIdx = i;                       }
+#if OL_DEPTHLIMIT_A0044 //flag to signal to start dumping
+  Void    setPartDumpFlag(Bool flag) { m_bDumpPartInfo = flag;};
+#endif
 };
 
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 193)
@@ -87,6 +87,6 @@
 #if VSP_SLICE_HEADER
   m_bUseVSP = false;
-#endif
-
+  m_bVSPDepthDisable = false;
+#endif
 }
 
@@ -198,14 +198,10 @@
   m_pcPicVSP = new TComPic;
   m_pcPicVSP->create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
-  //m_pcPicVSP->getCurrSlice()->setViewId( this->getViewId() );
-  m_pcPicVSP->getCurrSlice()->setViewId( NUM_VIEW_VSP );
   m_pcPicVSP->getCurrSlice()->setViewOrderIdx( m_iViewOrderIdx );
 
   m_pcPicAvail = new TComPic;
   m_pcPicAvail->create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
-  m_pcPicAvail->getCurrSlice()->setViewId( 99 );
   m_pcPicAvail->getCurrSlice()->setViewOrderIdx( m_iViewOrderIdx );
 #endif
-
 }
 
@@ -854,4 +850,7 @@
   m_cSPS.setUseDMM( m_bUseDMM );
 #endif
+#if OL_DEPTHLIMIT_A0044
+  m_cSPS.setUseDPL( m_bDepthPartitionLimiting );
+#endif
 #if HHI_MPI
   m_cSPS.setUseMVI( m_bUseMVI );
@@ -894,4 +893,10 @@
     }
   }
+#if VSP_N
+  m_cSPS.setVspPresentFlag( m_bUseVSP );
+#if VSP_CFG
+  m_cSPS.setVspDepthPresentFlag( m_bVSPDepthDisable ? false : true );
+#endif
+#endif
 }
 
@@ -1185,5 +1190,9 @@
 
     // # substreams is "per tile" when tiles are independent.
+#if FIX_REMOVE_TILE_DEPENDENCE
+    if ( m_iWaveFrontSynchro )
+#else
     if (m_iTileBoundaryIndependenceIdr && m_iWaveFrontSynchro)
+#endif
     {
       m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1));
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncTop.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibEncoder/TEncTop.h	(revision 193)
@@ -150,8 +150,4 @@
 #endif
 
-#if VSP_SLICE_HEADER
-  Bool                    m_bUseVSP;
-#endif
-
 protected:
   Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
@@ -251,9 +247,4 @@
 #endif
 
-#if VSP_SLICE_HEADER
-  Void                    setUseVSP   ( Bool val ) { m_bUseVSP = val; }
-  Bool                    getUseVSP             () { return m_bUseVSP; }
-#endif
-
   // -------------------------------------------------------------------------------------------------------------------
   // encoder function
