Index: trunk/source/Lib/TLibEncoder/SyntaxElementWriter.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/SyntaxElementWriter.cpp	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/SyntaxElementWriter.cpp	(revision 1396)
@@ -128,5 +128,5 @@
 
 #if NH_MV_ENC_DEC_TRAC
-Void  SyntaxElementWriter::xWriteStringTr( UChar* value, UInt length, const Char *pSymbolName)
+Void  SyntaxElementWriter::xWriteStringTr( UChar* value, UInt length, const TChar *pSymbolName)
 {
   xWriteString(value, length);
Index: trunk/source/Lib/TLibEncoder/SyntaxElementWriter.h
===================================================================
--- trunk/source/Lib/TLibEncoder/SyntaxElementWriter.h	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/SyntaxElementWriter.h	(revision 1396)
@@ -96,5 +96,5 @@
   Void  xWriteFlagTr          ( UInt value,               const TChar *pSymbolName);
 #if NH_MV
-  Void  xWriteStringTr        ( UChar* value, UInt length, const Char *pSymbolName);
+  Void  xWriteStringTr        ( UChar* value, UInt length, const TChar *pSymbolName);
 #endif
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1396)
@@ -69,4 +69,5 @@
   fprintf( g_hTrace, "=========== Slice ===========\n");
 }
+#endif
 
 Void  xTraceAccessUnitDelimiter ()
@@ -75,5 +76,4 @@
 }
 
-#endif
 #endif
 
@@ -1428,5 +1428,9 @@
     for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ )
     {  
+#if NH_3D_FIX_TICKET_114
+      if( j > 0  &&  dpbSize->getSubLayerFlagInfoPresentFlag( i )  )  
+#else
       if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
+#endif
       {
         WRITE_FLAG( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ? 1 : 0 , "sub_layer_dpb_info_present_flag" );
Index: trunk/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 1396)
@@ -46,6 +46,9 @@
 #include "TLibCommon/TComSlice.h"
 #include <assert.h>
+
+#if NH_3D
+#include "TAppCommon/TAppComCamPara.h"
+#endif
 #if NH_3D_VSO
-#include "TAppCommon/TAppComCamPara.h"
 #include "TLibRenderer/TRenModSetupStrParser.h"
 #endif
@@ -458,5 +461,5 @@
 #endif 
 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   Bool      m_isDepth;
   Bool      m_isAuxDepth; 
@@ -464,5 +467,7 @@
   //====== Camera Parameters ======
   TAppComCamPara* m_cameraParameters; 
+#endif
   
+#if NH_3D_VSO
   //====== View Synthesis Optimization ======
   TRenModSetupStrParser* m_renderModelParameters; 
@@ -504,7 +509,9 @@
   , m_viewId(-1)
   , m_viewIndex(-1)
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   , m_isDepth(false)
   , m_isAuxDepth(false)
+#endif
+#if NH_3D_VSO
   , m_bUseVSO(false)
 #endif
@@ -555,5 +562,5 @@
   Void      setViewIndex                     ( Int viewIndex  )   { m_viewIndex  = viewIndex;  }
   Int       getViewIndex                     ()                   { return m_viewIndex;    }
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   Void      setIsDepth                       ( Bool isDepth )   { m_isDepth = isDepth; }
   Bool      getIsDepth                       ()                 { return m_isDepth; }
@@ -1157,5 +1164,5 @@
   UInt      getSummaryVerboseness( ) const                           { return m_summaryVerboseness; }
 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   // Only flags that are not in the SPS3dExtension should go here. 
   /// 3D Tools 
@@ -1163,5 +1170,7 @@
  //==== CAMERA PARAMETERS  ==========
   Void      setCameraParameters             ( TAppComCamPara* c) { m_cameraParameters   = c; }
- //==== VSO  ==========
+#endif
+#if NH_3D_VSO
+  //==== VSO  ==========
   Void      setRenderModelParameters ( TRenModSetupStrParser* c ) { m_renderModelParameters = c; }
   Bool      getUseVSO                       ()              { return m_bUseVSO;     }
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1396)
@@ -1199,5 +1199,5 @@
       rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
 #if NH_3D_VSO // M8
-    if ( m_pcRdCost->getUseVSO() )    
+    if ( m_pcRdCost->getUseLambdaScaleVSO() )    
     {
       rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );    
@@ -1340,5 +1340,5 @@
       }
 #if NH_3D_VSO // M10
-      if ( m_pcRdCost->getUseVSO() )
+      if ( m_pcRdCost->getUseLambdaScaleVSO() )
       {
         rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
@@ -2974,5 +2974,5 @@
   rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
 #if NH_3D_VSO // M44
-  if ( m_pcRdCost->getUseVSO() )
+  if ( m_pcRdCost->getUseLambdaScaleVSO() )
   {
     rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
@@ -3047,5 +3047,5 @@
       pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
 #if NH_3D_VSO // M45
-      if ( m_pcRdCost->getUseVSO() )      
+      if ( m_pcRdCost->getUseLambdaScaleVSO() )      
       {
         pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( pcCU->getTotalBits(), pcCU->getTotalDistortion() );      
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1396)
@@ -1647,5 +1647,5 @@
           UInt uiSingleBits = xGetIntraBitsQT( rTu, true, false, false );
 #if NH_3D_VSO // M NEW 
-          if ( m_pcRdCost->getUseRenModel() )
+          if ( m_pcRdCost->getUseLambdaScaleVSO() )
           {
             singleCostTmp     = m_pcRdCost->calcRdCostVSO( uiSingleBits, singleDistTmpLuma );
@@ -1887,5 +1887,9 @@
 
 #if NH_3D_DIS
-Void TEncSearch::xIntraCodingDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, UInt uiPredMode )
+#if NH_3D_VSO
+Void TEncSearch::xIntraCodingDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist&       ruiDist, Double& dRDCost, UInt uiPredMode )
+#else
+Void TEncSearch::xIntraCodingDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Distortion& ruiDist, Double& dRDCost, UInt uiPredMode )
+#endif
 {
   UInt    uiWidth           = pcCU     ->getWidth   ( 0 );
@@ -1982,5 +1986,11 @@
 #endif
 #if NH_3D_SDC_INTRA
-Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi  )
+#if NH_3D_VSO
+Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist&       ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi  )
+#else
+Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Distortion& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi  )
+#endif
+
+
 {
   UInt uiWidth        = pcCU->getWidth ( 0 );
@@ -2215,5 +2225,9 @@
 #endif
   {
+#if NH_3D_FIX_INTRA_SDC_VSO_OFF
+    ruiDist = m_pcRdCost->getDistPart( bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, COMPONENT_Y );
+#else
     ruiDist = m_pcRdCost->getDistPart( bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, COMPONENT_Y, DF_SAD );
+#endif
   }
 
@@ -2743,5 +2757,5 @@
   Pel* piOrg         = pcOrgYuv ->getAddr(COMPONENT_Y, 0, uiWidth );
   UInt uiStride      = pcPredYuv->getStride(COMPONENT_Y);
-#endif
+
   Dist   uiDist = 0;
   Double dCost   = 0.0;
@@ -2749,4 +2763,11 @@
   Double  dBestCost   = MAX_DOUBLE;
   UInt     uiBestDISType = 0;
+#else
+  Distortion   uiDist = 0;
+  Double       dCost   = 0.0;
+  Distortion   uiBestDist = 0;
+  Double       dBestCost   = MAX_DOUBLE;
+  UInt         uiBestDISType = 0;
+#endif
 
   for( UInt uiPredMode = 0; uiPredMode < 4 ; uiPredMode++ )
@@ -5232,4 +5253,13 @@
   {
     rcMv = *pcMvPred;
+#if NH_MV_FIX_VERT_MV_REST
+    if ( m_vertRestriction )
+    {
+      if (rcMv.getVer() > cMvSrchRngRB.getVer()<<2)
+      {
+        rcMv.setVer(cMvSrchRngRB.getVer()<<2);
+      }
+    }
+#endif
     const TComMv *pIntegerMv2Nx2NPred=0;
     if (pcCU->getPartitionSize(0) != SIZE_2Nx2N || pcCU->getDepth(0) != 0)
@@ -6316,5 +6346,9 @@
   }
 
-  Dist ruiDist;
+#if NH_3D_VSO
+    Dist ruiDist;
+#else
+    Distortion ruiDist;
+#endif
   Double rdCost;
 #if NH_3D_VSO // M13
@@ -6787,5 +6821,5 @@
 
 #if NH_3D_VSO // M NEW01
-               if ( m_pcRdCost->getUseRenModel() )
+               if ( m_pcRdCost->getUseLambdaScaleVSO() )
                {
                  currCompCost = m_pcRdCost->calcRdCostVSO(currCompBits, currCompDist);
@@ -6955,5 +6989,5 @@
 
 #if NH_3D_VSO
-    if ( m_pcRdCost->getUseRenModel() )
+    if ( m_pcRdCost->getUseLambdaScaleVSO() )
     {
       dSingleCost = m_pcRdCost->calcRdCostVSO( uiSingleBits, uiSingleDist );
@@ -7898,5 +7932,9 @@
 
   // coarse wedge search
-  Dist uiBestDist   = RDO_DIST_MAX;
+#if NH_3D_VSO
+  Dist       uiBestDist   = RDO_DIST_MAX;
+#else
+  Distortion uiBestDist   = RDO_DIST_MAX;
+#endif
   UInt uiBestNodeId = 0;
   for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ )
@@ -7908,6 +7946,9 @@
     assignBiSegDCs( piPred, uiPredStride, pbPattern, uiStride, refDC1, refDC2 );
 
+#if !NH_3D_VSO
+    Distortion uiActDist = RDO_DIST_MAX;
+#else
     Dist uiActDist = RDO_DIST_MAX;
-#if NH_3D_VSO
+
     if( m_pcRdCost->getUseVSO() )
     {
@@ -7935,5 +7976,9 @@
 
   // refinement
+#if NH_3D_VSO
   Dist uiBestDistRef = uiBestDist;
+#else
+  Distortion uiBestDistRef = uiBestDist;
+#endif
   UInt uiBestTabIdxRef  = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx();
   for( UInt uiRefId = 0; uiRefId < DMM_NUM_WEDGE_REFINES; uiRefId++ )
@@ -7946,6 +7991,9 @@
       xCalcBiSegDCs  ( piRef,  uiRefStride,  pbPattern, uiStride, refDC1, refDC2, (1<<(bitDepthY-1)) );
       assignBiSegDCs( piPred, uiPredStride, pbPattern, uiStride, refDC1, refDC2 );
+
+#if !NH_3D_VSO
+      Distortion uiActDist = RDO_DIST_MAX;
+#else
       Dist uiActDist = RDO_DIST_MAX;
-#if NH_3D_VSO
       if( m_pcRdCost->getUseVSO() )
       {
Index: trunk/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 1396)
@@ -343,5 +343,9 @@
   Void  xLoadIntraResultQT        ( const ComponentID compID, TComTU &rTu);
 #if NH_3D_DIS
-  Void xIntraCodingDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, UInt uiPredMode );
+#if NH_3D_VSO
+  Void xIntraCodingDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist&       ruiDist, Double& dRDCost, UInt uiPredMode );
+#else
+  Void xIntraCodingDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Distortion& ruiDist, Double& dRDCost, UInt uiPredMode );
+#endif
 #endif
 
@@ -356,5 +360,9 @@
 #endif
 #if NH_3D_SDC_INTRA
-  Void xIntraCodingSDC            ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi    );
+#if NH_3D_VSO
+  Void xIntraCodingSDC            ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist      , Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi    );
+#else
+  Void xIntraCodingSDC            ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Distortion& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi    );
+#endif
   Void xCalcConstantSDC           ( Pel* ptrSrc, UInt srcStride, UInt uiSize, Pel& valDC );
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1396)
@@ -461,5 +461,5 @@
 
 #if NH_3D_VSO
-  m_pcRdCost->setUseLambdaScaleVSO  ( (m_pcCfg->getUseVSO() ||  m_pcCfg->getForceLambdaScaleVSO()) && ( m_pcCfg->getIsDepth()  | m_pcCfg->getIsAuxDepth() ) );
+  m_pcRdCost->setUseLambdaScaleVSO  ( (m_pcCfg->getUseVSO() ||  m_pcCfg->getForceLambdaScaleVSO()) && ( m_pcCfg->getIsDepth() || m_pcCfg->getIsAuxDepth() ) );
   m_pcRdCost->setLambdaVSO          ( dLambda * m_pcCfg->getLambdaScaleVSO() );
 
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1386)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1396)
@@ -91,4 +91,18 @@
 TEncTop::~TEncTop()
 {
+#if NH_3D_FIX_LEAK
+#if NH_3D_IC
+  if ( m_aICEnableCandidate != NULL )
+  {
+    delete[] m_aICEnableCandidate;
+  }
+
+  if ( m_aICEnableNum != NULL )
+  {
+    delete[] m_aICEnableNum;
+  }
+#endif
+
+#endif
 #if ENC_DEC_TRACE
   if (g_hTrace != stdout)
@@ -1652,5 +1666,5 @@
     }
 
-    rendererModel->setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
+    rendererModel->setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef, iEncViewSIdx );
   }
 }
