Index: trunk/source/Lib/TAppCommon/TAppComCamPara.cpp
===================================================================
--- trunk/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 1387)
+++ trunk/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 1396)
@@ -49,5 +49,5 @@
 #include <functional>
 #include <string>
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
 
 
Index: trunk/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/CommonDef.h	(revision 1387)
+++ trunk/source/Lib/TLibCommon/CommonDef.h	(revision 1396)
@@ -442,5 +442,5 @@
 #endif
 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
 //PICYUV
 #define PICYUV_PAD         16
@@ -456,14 +456,11 @@
 #define REN_UNUSED_PEL     0
 #define REN_IS_HOLE        0
-#if NH_3D_VSO
 #define ENC_INTERNAL_BIT_DEPTH  REN_BIT_DEPTH // consider making this a variable
-#endif
-
-
+#endif // end of NH_3D_VSO
+#if NH_3D
 // CAMERA PARAMETERS
 #define LOG2_DISP_PREC_LUT           2           ///< log2 of disparity precision used in integer disparity LUTs
 #define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
-
-#endif // end of NH_3D
+#endif
 //! \}
 
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1396)
@@ -5101,9 +5101,5 @@
 
   //// ******* Get disparity from left block ******* /////
-#if NH_3D_FIX_TICKET_91
     pcTmpCU = getPULeft(uiIdx, uiPartIdxLB);
-#else
-  pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
-#endif
   bCheckMcpDv = true; 
   if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
Index: trunk/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 1396)
@@ -49,4 +49,7 @@
 #include "TComRdCost.h"
 #include "TComPattern.h"
+#if NH_3D
+#include "TComYuv.h"
+#endif
 
 //! \ingroup TLibCommon
Index: trunk/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 1396)
@@ -60,5 +60,5 @@
 , m_viewId                                (0)
 , m_bPicOutputFlag                        (false)
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
 , m_viewIndex                             (0)
 , m_isDepth                               (false)
@@ -989,5 +989,5 @@
 }
 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
 TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int auxId, Int poc, Bool recon )
 {  
Index: trunk/source/Lib/TLibCommon/TComPic.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.h	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComPic.h	(revision 1396)
@@ -154,5 +154,5 @@
   TComDecodedRps        m_decodedRps;
 #endif
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   Int                   m_viewIndex;
   Bool                  m_isDepth;
@@ -311,5 +311,5 @@
    Void          print( Int outputLevel );
 
-#if NH_3D_VSO
+#if NH_3D_VSO ||  NH_3D
    Void          setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
    Int           getViewIndex          () const           { return m_viewIndex;     }
@@ -404,5 +404,5 @@
   TComList<TComSubDpb*>       m_subDpbs; 
   Bool                        m_printPicOutput; 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   const TComVPS*              m_vps; 
 #endif
@@ -448,6 +448,9 @@
   Void                   print(); 
 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   Void                   setVPS                        ( const TComVPS* vps ) { m_vps = vps;  }; 
+#endif
+
+#if NH_3D || NH_3D_VSO
   TComPic*               getPic                        ( Int viewIndex, Bool depthFlag, Int auxId, Int poc );
   TComPicYuv*            getPicYuv                     ( Int viewIndex, Bool depthFlag, Int auxId, Int poc, Bool recon );
Index: trunk/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1396)
@@ -252,8 +252,10 @@
       rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
     }
+#if NH_3D_VSO
     else if( eDFunc >= DF_VSD && eDFunc <= DF_VSD16N )
     {
       rcDistParam.DistFunc = TComRdCost::xGetMaskedVSD;
     }
+#endif
     else if( eDFunc >= DF_SAD12 && eDFunc <= DF_SADS48 )
     {
@@ -626,5 +628,5 @@
 }
 
-
+#if NH_3D_VSO
 UInt TComRdCost::xGetMaskedVSD( DistParam* pcDtParam )
 {
@@ -660,4 +662,5 @@
   return ( uiSum );
 }
+#endif
 #endif
 // --------------------------------------------------------------------------------------------------------------------
Index: trunk/source/Lib/TLibCommon/TComRom.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.h	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComRom.h	(revision 1396)
@@ -150,10 +150,4 @@
 // ====================================================================================================================
 extern       SChar   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
-#if NH_MV
-// Change later
-#ifndef ENC_DEC_TRACE
-#define ENC_DEC_TRACE 0
-#endif
-#endif
 #if ENC_DEC_TRACE
 extern FILE*  g_hTrace;
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 1396)
@@ -118,5 +118,5 @@
 , m_viewId                        (0)
 , m_viewIndex                     (0)
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
 , m_isDepth                       (false)
 #endif
@@ -1923,7 +1923,4 @@
   for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++)
   {
-#if !NH_3D_FIX_TICKET_107
-    m_layerSetIdxForOlsMinus1[i]  = -1; 
-#endif
     for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++)
     {
@@ -2184,5 +2181,5 @@
 }
 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
 Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag, Int auxId ) const
 {
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 1396)
@@ -1384,5 +1384,5 @@
   /// VPS EXTENSION 2 SYNTAX ELEMENTS
   Int     getDepthId                   ( Int layerIdInNuh)             const    { return getScalabilityId( getLayerIdInVps(layerIdInNuh), DEPTH_ID ); }
-#if NH_3D_VSO                                                             
+#if NH_3D_VSO || NH_3D
   Bool    getVpsDepthFlag              ( Int layerIdInNuh)             const    { return (getDepthId( layerIdInNuh ) > 0);  }
   Int     getLayerIdInNuh              ( Int viewIndex, Bool depthFlag, Int auxId ) const;   
@@ -2701,5 +2701,5 @@
   Int        m_viewId;
   Int        m_viewIndex; 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   Bool       m_isDepth;
 #endif
@@ -3168,5 +3168,5 @@
 #endif                        
 #endif
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
   Void                        setIsDepth            ( Bool isDepth )                 { m_isDepth = isDepth;                                          }
   Bool                        getIsDepth            () const                         { return m_isDepth;                                             }
Index: trunk/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComYuv.cpp	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TComYuv.cpp	(revision 1396)
@@ -487,4 +487,5 @@
   }
 }
+#endif
 
 #if NH_3D_ARP
@@ -676,5 +677,4 @@
 }
 #endif
-#endif
 
 //! \}
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 1387)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 1396)
@@ -65,6 +65,11 @@
 #if NH_MV
 // Recent bug fixes
-#define NH_3D_FIX_TICKET_107                     1 // Clean up. 
-#define NH_3D_FIX_TICKET_91                      1 // NBDV availability in case of tiles.
+#define RM_INIT_FIX                      1
+#define RM_FIX_SETUP                     1
+#define NH_MV_FIX_VERT_MV_REST                         1
+
+#define NH_3D_FIX_INTRA_SDC_VSO_OFF              1
+#define NH_3D_FIX_TICKET_114                     1  //Mismatch between text and software on DPB size syntax
+#define NH_3D_FIX_LEAK                           1
 // Things that needs to be fixed also in the Specification ...
 #define NH_MV_FIX_NO_REF_PICS_CHECK               1 // !!SPEC!!
@@ -349,7 +354,13 @@
 #endif
 // This can be enabled by the makefile
-#if !NH_MV
 #ifndef ENC_DEC_TRACE
 #define ENC_DEC_TRACE                                     0
+#endif
+
+#if NH_MV
+#if ENC_DEC_TRACE
+#define GT_DEBUG   1
+#else
+#define GT_DEBUG   0
 #endif
 #endif
@@ -510,4 +521,6 @@
 #define       RDO_DIST_MAX     MAX_UINT
 #endif
+#else
+#define       RDO_DIST_MAX     MAX_UINT
 #endif
 // ====================================================================================================================
@@ -1000,4 +1013,14 @@
   BLEND_GEN   =  3
 };
+
+  enum SetMod
+  {
+    GET_FULL   = 0,
+    SET_FULL   = 1,
+    GET_SIMP   = 2,
+    SET_SIMP   = 3    
+  };
+
+  
 enum
 {
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1387)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1396)
@@ -2135,5 +2135,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
       {
         READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize.setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 );
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1387)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1396)
@@ -1063,5 +1063,5 @@
     m_pcPic->setLayerId( nalu.m_nuhLayerId );
     m_pcPic->setViewId ( getViewId() );
-#if NH_3D
+#if NH_3D || NH_3D_VSO
     m_pcPic->setViewIndex( getViewIndex() );
     m_pcPic->setIsDepth  ( getIsDepth  () );
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 1387)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 1396)
@@ -247,5 +247,5 @@
   Int                     m_layerId;
   Int                     m_viewId;
-#if NH_3D                 
+#if NH_3D || NH_3D_VSO
   Int                     m_viewIndex; 
   Bool                    m_isDepth;
Index: trunk/source/Lib/TLibEncoder/SyntaxElementWriter.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/SyntaxElementWriter.cpp	(revision 1387)
+++ 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 1387)
+++ 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 1387)
+++ 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 1387)
+++ 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 1387)
+++ 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 1387)
+++ 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 1387)
+++ 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 1387)
+++ 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 1387)
+++ 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 );
   }
 }
Index: trunk/source/Lib/TLibRenderer/TRenFilter.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenFilter.cpp	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenFilter.cpp	(revision 1396)
@@ -36,5 +36,5 @@
 #include "TRenFilter.h"
 #include "TRenInterpFilter.h"
-#if NH_3D_VSO
+#if NH_3D_VSO  || NH_3D
 
 ///// COMMON /////
Index: trunk/source/Lib/TLibRenderer/TRenFilter.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenFilter.h	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenFilter.h	(revision 1396)
@@ -39,5 +39,5 @@
 #include "TRenImage.h"
 #include "TRenInterpFilter.h"
-#if NH_3D_VSO
+#if NH_3D_VSO  || NH_3D
 
 typedef Int (TRenInterpFilter<REN_BIT_DEPTH>::*FpChromaIntFilt) ( Pel*, Int );
Index: trunk/source/Lib/TLibRenderer/TRenImage.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenImage.h	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenImage.h	(revision 1396)
@@ -39,5 +39,5 @@
 #include "../TLibCommon/TComPicYuv.h"
 #include "TRenImagePlane.h"
-#if NH_3D_VSO
+#if NH_3D_VSO  || NH_3D
 
 
Index: trunk/source/Lib/TLibRenderer/TRenImagePlane.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenImagePlane.cpp	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenImagePlane.cpp	(revision 1396)
@@ -36,5 +36,5 @@
 #include "TRenFilter.h"
 #include <string.h>
-#if NH_3D_VSO
+#if NH_3D_VSO  || NH_3D
 
 /////// TRenImagePlane ///////
Index: trunk/source/Lib/TLibRenderer/TRenImagePlane.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenImagePlane.h	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenImagePlane.h	(revision 1396)
@@ -39,5 +39,5 @@
 #include "../TLibCommon/TComPicYuv.h"
 
-#if NH_3D_VSO
+#if NH_3D_VSO  || NH_3D
 #define PelImagePlane     TRenImagePlane<Pel>
 #define DoubleImagePlane  TRenImagePlane<Double>
Index: trunk/source/Lib/TLibRenderer/TRenInterpFilter.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenInterpFilter.cpp	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenInterpFilter.cpp	(revision 1396)
@@ -39,5 +39,5 @@
 
 #include "TRenInterpFilter.h"
-#if NH_3D_VSO
+#if NH_3D_VSO  || NH_3D
 
 // ====================================================================================================================
Index: trunk/source/Lib/TLibRenderer/TRenInterpFilter.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenInterpFilter.h	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenInterpFilter.h	(revision 1396)
@@ -44,5 +44,5 @@
 #include "TLibCommon/CommonDef.h"
 #include "assert.h"
-#if NH_3D_VSO
+#if NH_3D_VSO  || NH_3D
 
 // ====================================================================================================================
Index: trunk/source/Lib/TLibRenderer/TRenModel.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenModel.cpp	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenModel.cpp	(revision 1396)
@@ -216,9 +216,11 @@
 Void
 #if H_3D_VSO_EARLY_SKIP
-TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bEarlySkip )
+TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bLimOutput, Bool bEarlySkip )
 #else
-TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin )
-#endif
-{
+TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bLimOutput )
+#endif
+{
+  m_bLimOutput          = bLimOutput; 
+
   m_iNumOfBaseViews     = iNumOfBaseViews;
   m_iNumOfRenModels     = iNumOfModels;
@@ -416,7 +418,17 @@
 
 #if H_3D_VSO_EARLY_SKIP
-  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, iBlendMode, m_bEarlySkip );
+#if RM_INIT_FIX
+  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, ( iMode != 2 )  ? BLEND_NONE : iBlendMode , m_bLimOutput, m_bEarlySkip );
 #else
-  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, iBlendMode );
+  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, iBlendMode, m_bLimOutput, m_bEarlySkip );
+#endif
+
+#else
+
+#if RM_INIT_FIX
+  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, ( iMode != 2 )  ? BLEND_NONE : iBlendMode, m_bLimOutput );
+#else
+  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, iBlendMode, m_bLimOutput );
+#endif
 #endif
 
@@ -470,5 +482,5 @@
 
 Void
-TRenModel::setSingleModel( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView )
+TRenModel::setSingleModel( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView, Int iEncViewSIdx)
 {
   AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels );
@@ -486,5 +498,4 @@
     if ( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID )
     {
-      bAnyRefFromOrg = true;
       m_apcRenModels[iModelNum]->setLRView( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum],
         ( bSetupFromOrgVideo ? m_aapiOrgVideoPel   : m_aapiCurVideoPel   ) [iBaseViewIdx],
@@ -495,10 +506,9 @@
   }
 
-  m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false );
-
-  // Setup to Org
-  if ( bAnyRefFromOrg )
-  {
-    // Restore old values
+  // Render
+#if !RM_FIX_SETUP
+  m_apcRenModels[iModelNum]->setupLutAndRef(  pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, bAnyRefFromOrg );
+
+  // Setup with actual data  
     for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ )
     {
@@ -514,8 +524,68 @@
       }
     }
-
-    // setup keeping reference rendered from original data
-    m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true );
-  }
+  // Render initial state
+  AOT( m_bLimOutput && m_aaeBaseViewPosInModel[ iEncViewSIdx ][iModelNum] == VIEWPOS_INVALID );
+  m_apcRenModels[iModelNum]->setupInitialState( m_bLimOutput ? m_aaeBaseViewPosInModel[ iEncViewSIdx ][iModelNum] : VIEWPOS_INVALID );  
+
+#else
+  m_apcRenModels[iModelNum]->setupLut(  ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft );
+  
+  // Copy yuv to reference if given.
+  AOT( pcPicYuvRefView != NULL && bAnyRefFromOrg );
+  
+  if (pcPicYuvRefView )
+  {
+    m_apcRenModels[iModelNum]->setupRefView( pcPicYuvRefView );
+  }
+
+  m_apcRenModels[iModelNum]->renderAll( ); 
+
+  // pcPicYuvRefView != NULL &&  bAnyRefFromOrg --> invalid combination
+  // pcPicYuvRefView != NULL && !bAnyRefFromOrg --> distortion correct; reference view correct; current view correct
+  // pcPicYuvRefView == NULL &&  bAnyRefFromOrg --> distortion TBD    ; reference view TBD    ; current view TBD
+  // pcPicYuvRefView == NULL && !bAnyRefFromOrg --> distortion TBD    ; reference view TBD    ; current view correct
+
+  if ( pcPicYuvRefView == NULL )
+  {
+    // Update reference view
+    m_apcRenModels[iModelNum]->setStructSynthViewAsRefView();  
+
+    // pcPicYuvRefView != NULL &&  bAnyRefFromOrg --> invalid combination
+    // pcPicYuvRefView != NULL && !bAnyRefFromOrg --> distortion correct; reference view correct; current view correct
+    // pcPicYuvRefView == NULL &&  bAnyRefFromOrg --> distortion TBD    ; reference view correct; current view TBD
+    // pcPicYuvRefView == NULL && !bAnyRefFromOrg --> distortion TBD    ; reference view correct; current view correct
+
+    if ( bAnyRefFromOrg )
+    {    
+      // Update current view and distortion 
+      for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ )
+      {
+        if ( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID )
+        {
+          m_apcRenModels[iModelNum]->setLRView(
+            m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum],
+            m_aapiCurVideoPel      [iBaseViewIdx],
+            m_aaiCurVideoStrides   [iBaseViewIdx],
+            m_apiCurDepthPel       [iBaseViewIdx],
+            m_aiCurDepthStrides    [iBaseViewIdx]
+          );
+        }
+      }
+      m_apcRenModels[iModelNum]->renderAll( );
+    }
+    else
+    {
+      // Update to distortion
+      m_apcRenModels[iModelNum]->resetStructError();
+    }
+  }      
+
+  if ( m_bLimOutput )
+  {
+    AOT( m_aaeBaseViewPosInModel[ iEncViewSIdx ][iModelNum] == VIEWPOS_INVALID );
+    Int curViewPosInModel = m_aaeBaseViewPosInModel[ iEncViewSIdx ][iModelNum];    
+    m_apcRenModels[iModelNum]->setLimOutStruct( (curViewPosInModel == VIEWPOS_RIGHT)  ? VIEWPOS_LEFT : VIEWPOS_RIGHT );
+  }  
+#endif
 }
 
@@ -549,5 +619,5 @@
 TRenModel::setupPart ( UInt uiHorOff, Int iUsedHeight )
 {
-  AOT( iUsedHeight > m_iHeight );     
+//  AOT( iUsedHeight > m_iHeight );     
   m_uiHorOff    = uiHorOff; 
   m_iUsedHeight = iUsedHeight; 
@@ -589,6 +659,5 @@
     }
   }
-
-  return ( iDist + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels;
+  return m_iNumOfCurRenModels > 0 ? ( iDist + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels : 0;
 }
 
Index: trunk/source/Lib/TLibRenderer/TRenModel.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenModel.h	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenModel.h	(revision 1396)
@@ -53,7 +53,7 @@
   // Creation
 #if H_3D_VSO_EARLY_SKIP
-  Void  create           ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bEarlySkip );
+  Void  create           ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bLimOutput, Bool bEarlySkip );
 #else
-  Void  create           ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin );
+  Void  create           ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bLimOutput );
 #endif
   Void  createSingleModel( Int iBaseViewNum, Int iContent, Int iModelNum, Int iLeftViewNum, Int iRightViewNum, Bool bUseOrgRef, Int iBlendMode );
@@ -61,5 +61,5 @@
   // Set new Frame
   Void  setBaseView      ( Int iViewNum, TComPicYuv* pcPicYuvVideoData, TComPicYuv* pcPicYuvDepthData, TComPicYuv* pcPicYuvOrgVideoData, TComPicYuv* pcPicYuvOrgDepthData  );
-  Void  setSingleModel   ( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView );
+  Void  setSingleModel   ( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView, Int curViewIdx = VIEWPOS_INVALID );
 
   // Set horizontal offset
@@ -96,4 +96,5 @@
   Bool   m_bEarlySkip; 
 #endif
+  Bool   m_bLimOutput; 
 
   /// Size of Video and Depth
Index: trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 1396)
@@ -56,5 +56,5 @@
 
   m_pcOutputSamples      = NULL; 
-  m_pcOutputSamplesRow   = NULL;   
+  m_pcOutputSamplesRow   = NULL; 
   m_iOutputSamplesStride = -1; 
 
@@ -106,6 +106,6 @@
   if ( m_pcOutputSamples    ) delete[] m_pcOutputSamples   ;
 
-  if ( m_piInvZLUTLeft  ) delete[] m_piInvZLUTLeft ;
-  if ( m_piInvZLUTRight ) delete[] m_piInvZLUTRight;
+  if ( m_piInvZLUTLeft      ) delete[] m_piInvZLUTLeft ;
+  if ( m_piInvZLUTRight     ) delete[] m_piInvZLUTRight;
 
   if ( m_aapiRefVideoPel[0] ) delete[] ( m_aapiRefVideoPel[0] - ( m_aiRefVideoStrides[0] * m_iPad + m_iPad ) );
@@ -116,10 +116,11 @@
 template <BlenMod iBM, Bool bBitInc> Void
 #if H_3D_VSO_EARLY_SKIP
-TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip )
-#else
-TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode )
-#endif
-
-{
+TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bLimOutput, Bool bEarlySkip )
+#else
+TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bLimOutput )
+#endif
+
+{
+  m_bLimOutput = bLimOutput; 
 #if H_3D_VSO_EARLY_SKIP
   m_pbHorSkip     = new Bool [MAX_CU_SIZE];
@@ -127,6 +128,5 @@
 #endif
 
-  AOF( iBlendMode == iBM ); 
-
+  AOF( ( iBlendMode == iBM ) || ( iBM == BLEND_NONE ) ); 
   m_iMode = iMode;
 
@@ -171,5 +171,6 @@
   m_pcInputSamples[1]     = new RenModelInPels[m_iInputSamplesStride*m_iHeight];
 
-  m_pcOutputSamples       = new RenModelOutPels[m_iOutputSamplesStride*m_iHeight];  
+  m_pcOutputSamples       = new RenModelOutPels   [m_iOutputSamplesStride*m_iHeight];
+  m_pcLimOutputSamples    = m_bLimOutput ? new RenModelLimOutPels[m_iOutputSamplesStride*m_iHeight] : NULL;
 }
 
@@ -244,8 +245,54 @@
 }
 
-template <BlenMod iBM, Bool bBitInc> Void
-TRenSingleModelC<iBM,bBitInc>::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference )
-{
+
+#if !RM_FIX_SETUP
+template <BlenMod iBM, Bool bBitInc> Void
+  TRenSingleModelC<iBM,bBitInc>::setupInitialState( Int curViewPosInModel )
+{
+  xRenderAll( );
+
+  if ( m_bLimOutput )
+  {
+    AOT( curViewPosInModel == VIEWPOS_INVALID )
+    xSetLimOutStruct( (curViewPosInModel == VIEWPOS_RIGHT)  ? VIEWPOS_LEFT : VIEWPOS_RIGHT );
+  }
+}
+#endif
+
+#if RM_FIX_SETUP
+template <BlenMod iBM, Bool bBitInc> Void
+  TRenSingleModelC<iBM,bBitInc>::setupRefView      ( TComPicYuv* pcOrgVideo )
+{
+  m_pcPicYuvRef = pcOrgVideo;
+  // Use provided ref view reference
+  
+  TRenFilter<REN_BIT_DEPTH>::copy(             pcOrgVideo->getAddr( COMPONENT_Y  ) +  m_iHorOffset       * pcOrgVideo->getStride( COMPONENT_Y  ), pcOrgVideo->getStride( COMPONENT_Y  ), m_iWidth,      m_iUsedHeight,      m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
+  switch ( pcOrgVideo->getChromaFormat() )
+  {
+  case CHROMA_420:
+    TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp(0, pcOrgVideo->getAddr( COMPONENT_Cb ) + (m_iHorOffset >> 1) * pcOrgVideo->getStride( COMPONENT_Cb ), pcOrgVideo->getStride( COMPONENT_Cb ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
+    TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp(0, pcOrgVideo->getAddr( COMPONENT_Cr ) + (m_iHorOffset >> 1) * pcOrgVideo->getStride( COMPONENT_Cr ), pcOrgVideo->getStride( COMPONENT_Cr ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);
+    break;
+  case CHROMA_444:
+    TRenFilter<REN_BIT_DEPTH>::copy(             pcOrgVideo->getAddr( COMPONENT_Cb  ) +  m_iHorOffset       * pcOrgVideo->getStride( COMPONENT_Cb  ), pcOrgVideo->getStride( COMPONENT_Cb  ), m_iWidth,      m_iUsedHeight,      m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
+    TRenFilter<REN_BIT_DEPTH>::copy(             pcOrgVideo->getAddr( COMPONENT_Cr  ) +  m_iHorOffset       * pcOrgVideo->getStride( COMPONENT_Cr  ), pcOrgVideo->getStride( COMPONENT_Cr  ), m_iWidth,      m_iUsedHeight,      m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);
+    break;
+  default:
+    break; 
+  }
+  xSetStructRefView();
+}
+
+
+template <BlenMod iBM, Bool bBitInc> Void
+  TRenSingleModelC<iBM,bBitInc>::setupLut( Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft )
+#else
+template <BlenMod iBM, Bool bBitInc> Void
+  TRenSingleModelC<iBM,bBitInc>::setupLutAndRef( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bRenderRef )
+#endif
+{
+#if !RM_FIX_SETUP
   AOT( !m_bUseOrgRef && pcOrgVideo );
+#endif
   AOT( (ppiShiftLutLeft  == NULL) && (m_iMode == 0 || m_iMode == 2) );
   AOT( (ppiShiftLutRight == NULL) && (m_iMode == 1 || m_iMode == 2) );
@@ -254,10 +301,17 @@
   m_appiShiftLut[1] = ppiShiftLutRight;
 
+
+  if ( m_iMode == 2 )
+  {
+    TRenFilter<REN_BIT_DEPTH>::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight );
+  }
+
+#if !RM_FIX_SETUP
   // Copy Reference
   m_pcPicYuvRef = pcOrgVideo;
 
-  if ( pcOrgVideo && !bKeepReference )
-  {
-    assert( pcOrgVideo->getChromaFormat() != CHROMA_420 );     
+  if ( pcOrgVideo )
+  {
+    assert( pcOrgVideo->getChromaFormat() == CHROMA_420 );     
 
     TRenFilter<REN_BIT_DEPTH>::copy(             pcOrgVideo->getAddr( COMPONENT_Y  ) +  m_iHorOffset       * pcOrgVideo->getStride( COMPONENT_Y  ), pcOrgVideo->getStride( COMPONENT_Y  ), m_iWidth,      m_iUsedHeight,      m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
@@ -266,7 +320,28 @@
     xSetStructRefView();
   }
-
+  else
+  {
+    if ( bRenderRef )
+    {    
+      xRenderAll( ); 
+      xSetStructSynthViewAsRefView();
+    }
+  }
+#endif
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+#if RM_FIX_SETUP
+TRenSingleModelC<iBM,bBitInc>::renderAll( )
+#else
+TRenSingleModelC<iBM,bBitInc>::xRenderAll( )
+#endif
+{
   // Initial Rendering
+#if RM_FIX_SETUP
+  resetStructError();
+#else
   xResetStructError();
+#endif
   xInitSampleStructs();
   switch ( m_iMode )
@@ -274,24 +349,23 @@
   case 0:   
 #if H_3D_VSO_EARLY_SKIP
-    xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false );
-#else
-    xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
+    xRender<true, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false );
+#else
+    xRender<true, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
 #endif   
     break;
   case 1:    
 #if H_3D_VSO_EARLY_SKIP
-    xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
-#else
-    xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
+    xRender<false, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
+#else
+    xRender<false, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
 #endif
     break;
   case 2:
-    TRenFilter<REN_BIT_DEPTH>::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight );
-#if H_3D_VSO_EARLY_SKIP
-    xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false);
-    xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
+#if H_3D_VSO_EARLY_SKIP
+    xRender<true , SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false);
+    xRender<false, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
 #else      
-    xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
-    xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
+    xRender<true,  SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
+    xRender<false, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
 #endif
     break;
@@ -299,11 +373,4 @@
     AOT(true);
   }
-
-  // Get Rendered View as Reference
-  if ( !pcOrgVideo && !bKeepReference )
-  {
-    xResetStructError();
-    xSetStructSynthViewAsRefView();
-  }
 }
 
@@ -317,4 +384,12 @@
   switch ( iViewNum )
   {
+
+  case -1:  
+    rpiSrcY = &RenModelOutPels::iYRef;
+#if H_3D_VSO_COLOR_PLANES  
+    rpiSrcU = &RenModelOutPels::iURef;
+    rpiSrcV = &RenModelOutPels::iVRef;
+#endif
+    break;
   case 0:
     rpiSrcY = &RenModelOutPels::iYLeft;
@@ -349,4 +424,11 @@
 }
 
+template <BlenMod iBM, Bool bBitInc> Void
+  TRenSingleModelC<iBM,bBitInc>::xGetSampleStrFilledPtrs( Int iViewNum, Int RenModelOutPels::*& rpiSrcFilled )
+{
+  AOT(iViewNum != 0 && iViewNum != 1);  
+  rpiSrcFilled = (iViewNum == 1) ? &RenModelOutPels::iFilledRight : &RenModelOutPels::iFilledLeft; 
+}
+
 
 template <BlenMod iBM, Bool bBitInc> Void
@@ -383,5 +465,9 @@
 
 template <BlenMod iBM, Bool bBitInc> Void
+#if RM_FIX_SETUP
+TRenSingleModelC<iBM,bBitInc>::resetStructError( )
+#else
 TRenSingleModelC<iBM,bBitInc>::xResetStructError( )
+#endif
 {
   RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
@@ -398,5 +484,62 @@
 
 template <BlenMod iBM, Bool bBitInc> Void
+#if RM_FIX_SETUP
+  TRenSingleModelC<iBM,bBitInc>::setLimOutStruct(Int iSourceViewPos )
+#else
+  TRenSingleModelC<iBM,bBitInc>::xSetLimOutStruct(Int iSourceViewPos )
+#endif
+{  
+  RM_AOF( m_bLimOutput ); 
+  RM_AOT( iSourceViewPos < 0 || iSourceViewPos > 1);
+
+  RenModelOutPels*    pcCurOutSampleRow    = m_pcOutputSamples;
+  RenModelLimOutPels* pcCurLimOutSampleRow = m_pcLimOutputSamples;
+
+  Int RenModelOutPels::* piFilled = NULL;
+  xGetSampleStrFilledPtrs( iSourceViewPos, piFilled );
+  
+  Pel RenModelOutPels::* piDepth  = NULL;
+  xGetSampleStrDepthPtrs ( iSourceViewPos, piDepth  );
+
+  Pel RenModelOutPels::* piSrcY = NULL;
+  
+#if H_3D_VSO_COLOR_PLANES  
+  Pel RenModelOutPels::* piSrcU = NULL;  
+  Pel RenModelOutPels::* piSrcV = NULL;
+  xGetSampleStrTextPtrs  ( iSourceViewPos, piSrcY, piSrcU, piSrcV );
+#else
+  xGetSampleStrTextPtrs  ( iSourceViewPos, piSrcY );
+#endif
+  
+  for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )
+  {
+    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
+    {      
+      pcCurLimOutSampleRow[iPosX].iYOther      = pcCurOutSampleRow[iPosX].*piSrcY;
+      pcCurLimOutSampleRow[iPosX].iYRef        = pcCurOutSampleRow[iPosX].iYRef;
+
+#if H_3D_VSO_COLOR_PLANES      
+      pcCurLimOutSampleRow[iPosX].iUOther      = pcCurOutSampleRow[iPosX].*piSrcU;
+      pcCurLimOutSampleRow[iPosX].iURef        = pcCurOutSampleRow[iPosX].iURef;
+
+      pcCurLimOutSampleRow[iPosX].iVOther      = pcCurOutSampleRow[iPosX].*piSrcV;      
+      pcCurLimOutSampleRow[iPosX].iVRef        = pcCurOutSampleRow[iPosX].iVRef;
+#endif
+      pcCurLimOutSampleRow[iPosX].iDOther      = pcCurOutSampleRow[iPosX].*piDepth;      
+      pcCurLimOutSampleRow[iPosX].iFilledOther = pcCurOutSampleRow[iPosX].*piFilled;      
+      pcCurLimOutSampleRow[iPosX].iError       = pcCurOutSampleRow[iPosX].iError;      
+
+    } 
+    pcCurOutSampleRow    += m_iOutputSamplesStride; 
+    pcCurLimOutSampleRow += m_iOutputSamplesStride; 
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+#if RM_FIX_SETUP
+TRenSingleModelC<iBM,bBitInc>::setStructSynthViewAsRefView( )
+#else
 TRenSingleModelC<iBM,bBitInc>::xSetStructSynthViewAsRefView( )
+#endif
 {
   AOT( m_iMode < 0 || m_iMode > 2);
@@ -447,4 +590,5 @@
       pcOutSampleRow[iPosX].iDRight       = 0;
       pcOutSampleRow[iPosX].iDBlended     = 0;      
+      pcOutSampleRow[iPosX].iError        = 0; 
                                      
       // Y Planes                    
@@ -463,7 +607,7 @@
       pcOutSampleRow[iPosX].iVBlended     = 1 << (REN_BIT_DEPTH  - 1);
 #endif
-      //// Input Samples
-      pcLeftInSampleRow [iPosX].bOccluded = false;
-      pcRightInSampleRow[iPosX].bOccluded = false;
+  //// Input Samples
+      pcLeftInSampleRow [iPosX].aiOccludedPos = MAX_INT;
+      pcRightInSampleRow[iPosX].aiOccludedPos = MIN_INT;
     }
 
@@ -491,22 +635,22 @@
   case 0:
 #if H_3D_VSO_EARLY_SKIP
-    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
+    bEarlySkip = m_bEarlySkip ? xDetectEarlySkip<true>(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
     if( !bEarlySkip )
     {
-      iSSE = xRenderL<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
+      iSSE = xRender<true, GET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
     }    
 #else
-    iSSE = xRenderL<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
+    iSSE = xRender<true, GET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
 #endif
     break;
   case 1:
 #if H_3D_VSO_EARLY_SKIP
-    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
+    bEarlySkip = m_bEarlySkip ? xDetectEarlySkip<false>(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
     if( !bEarlySkip )
     {
-      iSSE = xRenderR<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
+      iSSE = xRender<false, GET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
     }    
 #else
-    iSSE = xRenderR<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
+    iSSE = xRender<false, GET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
 #endif
     break;
@@ -525,5 +669,5 @@
 #endif
 {
-#ifdef  H_3D_VSO_EARLY_SKIP
+#if  H_3D_VSO_EARLY_SKIP
   Bool bEarlySkip;
 #endif
@@ -532,22 +676,22 @@
   case 0:
 #if H_3D_VSO_EARLY_SKIP
-    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
+    bEarlySkip = m_bEarlySkip ? xDetectEarlySkip<true>(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
     if( !bEarlySkip )
     {
-      xRenderL<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
+      xRender<true, SET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
     }    
 #else
-    xRenderL<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
+    xRender<true, SET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
 #endif     
     break;
   case 1:
 #if H_3D_VSO_EARLY_SKIP
-    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
+    bEarlySkip = m_bEarlySkip ? xDetectEarlySkip<false>(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
     if( !bEarlySkip )
     {
-      xRenderR<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true ); 
+      xRender<false, SET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true ); 
     }    
 #else
-    xRenderR<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
+    xRender<false, SET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
 #endif     
     break;
@@ -585,6 +729,6 @@
   Pel RenModelOutPels::* piY;
   xGetSampleStrTextPtrs(iViewPos, piY); 
-  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piY, pcPicYuv->getLumaAddr() + m_iHorOffset * pcPicYuv->getStride(), pcPicYuv->getStride(), m_iWidth, m_iUsedHeight );
-  pcPicYuv->setChromaTo( 1 << (g_bitDepthC - 1) );   
+  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piY, pcPicYuv->getAddr(COMPONENT_Y) + m_iHorOffset * pcPicYuv->getStride(COMPONENT_Y), pcPicYuv->getStride(COMPONENT_Y), m_iWidth, m_iUsedHeight );
+  pcPicYuv->setChromaTo( 1 << (REN_BIT_DEPTH - 1) );   
 #endif  
 }
@@ -633,6 +777,6 @@
   xCopy2PicYuv( apiData, aiStrides, pcPicYuv );
 #else
-  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, &RenModelOutPels::iYRef, pcPicYuv->getLumaAddr() *  pcPicYuv->getStride() + m_iHorOffset, pcPicYuv->getStride(), m_iWidth, m_iUsedHeight );
-  pcPicYuv->setChromaTo( 1 << ( g_bitDepthC - 1 ) );   
+  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, &RenModelOutPels::iYRef, pcPicYuv->getAddr(COMPONENT_Y), pcPicYuv->getStride(COMPONENT_Y), m_iWidth, m_iUsedHeight );
+  pcPicYuv->setChromaTo( 1 << ( REN_BIT_DEPTH - 1 ) );   
 #endif  
 }
@@ -653,26 +797,40 @@
 
 
-template <BlenMod iBM, Bool bBitInc> __inline Void
+template <BlenMod iBM, Bool bBitInc> template<SetMod bSM> __inline Void
 TRenSingleModelC<iBM,bBitInc>::xSetViewRow( Int iPosY )
 {
   m_pcInputSamplesRow[0] = m_pcInputSamples[0] + m_iInputSamplesStride  * iPosY;
   m_pcInputSamplesRow[1] = m_pcInputSamples[1] + m_iInputSamplesStride  * iPosY;
-  m_pcOutputSamplesRow   = m_pcOutputSamples   + m_iOutputSamplesStride * iPosY;  
-
-}
-
-template <BlenMod iBM, Bool bBitInc> __inline Void
+  if (bSM == SET_FULL || bSM == GET_FULL )
+  {  
+    m_pcOutputSamplesRow   = m_pcOutputSamples   + m_iOutputSamplesStride * iPosY;  
+  }
+  else
+  {
+    m_pcLimOutputSamplesRow   = m_pcLimOutputSamples  + m_iOutputSamplesStride * iPosY;  
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> template<SetMod bSM> __inline Void
 TRenSingleModelC<iBM,bBitInc>::xIncViewRow( )
 {
   m_pcInputSamplesRow[0] += m_iInputSamplesStride ;
   m_pcInputSamplesRow[1] += m_iInputSamplesStride ;
-  m_pcOutputSamplesRow   += m_iOutputSamplesStride;  
-}
-#if H_3D_VSO_EARLY_SKIP
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist 
-TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast)
-#else
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist 
-TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData)
+  
+  if (bSM == SET_FULL || bSM == GET_FULL )
+  {  
+    m_pcOutputSamplesRow   += m_iOutputSamplesStride;
+  }
+  else
+  {
+    m_pcLimOutputSamplesRow   += m_iOutputSamplesStride;
+  }
+}
+#if H_3D_VSO_EARLY_SKIP
+template <BlenMod iBM, Bool bBitInc> template<SetMod bSM> __inline RMDist 
+TRenSingleModelC<iBM,bBitInc>::xGetSSE( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast)
+#else
+template <BlenMod iBM, Bool bBitInc> template<SetMod bSM> __inline RMDist 
+TRenSingleModelC<iBM,bBitInc>::xGetSSE( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData)
 #endif
 {
@@ -680,6 +838,44 @@
   const Int iOtherViewPos = 1;
 
-  m_iCurViewPos   = iCurViewPos  ; 
-  m_iOtherViewPos = iOtherViewPos;
+  m_piNewDepthData   = piNewData;  
+  m_iNewDataWidth    = iWidth;     
+  m_iStartChangePosX = iStartPosX; 
+
+  if ((iWidth == 0) || (iHeight == 0))
+    return 0;
+
+  xSetViewRow<bSM>      ( iStartPosY);
+
+  // Init Start
+  RMDist iError = 0;     
+  Int iStartChangePos = m_iStartChangePosX; 
+  Int iEndChangePos   = m_iStartChangePosX + iWidth - 1;
+
+  for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
+  {    
+    Int iPosXinNewData        = iWidth - 1;                       
+    for ( Int iCurPosX = iEndChangePos; iCurPosX >= iStartChangePos; iCurPosX-- )
+    {
+      Int iCurDepth   = m_piNewDepthData[iPosXinNewData];
+      Int iOldDepth   = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD; 
+      Int iDiff = (iCurDepth - iOldDepth);
+      iError += iDiff * iDiff;
+      iPosXinNewData--; 
+    }
+    xIncViewRow<bSM>();
+    m_piNewDepthData += iStride;
+  }
+  return iError;
+}
+
+#if H_3D_VSO_EARLY_SKIP
+template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline RMDist 
+TRenSingleModelC<iBM,bBitInc>::xRender( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast)
+#else
+template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline RMDist 
+TRenSingleModelC<iBM,bBitInc>::xRender( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData)
+#endif
+{
+  const Int iCurViewPos   = bL ? 0 : 1;
 
   m_piNewDepthData   = piNewData;
@@ -688,9 +884,11 @@
 
   if ((iWidth == 0) || (iHeight == 0))
+  {
     return 0;
+  }
 
   // Get Data
   m_ppiCurLUT      = m_appiShiftLut   [iCurViewPos];
-  xSetViewRow      ( iStartPosY);
+  xSetViewRow<bSM>( iStartPosY);
 
   // Init Start
@@ -698,5 +896,5 @@
   Int   iStartChangePos;
 
-  iStartChangePos = m_iStartChangePosX;
+  iStartChangePos = m_iStartChangePosX + ( bL ? 0  : (iWidth - 1));
 
   for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
@@ -707,5 +905,5 @@
       if ( m_pbHorSkip[iPosY-iStartPosY] )
       {
-        xIncViewRow();
+        xIncViewRow<bSM>();
         m_piNewDepthData += iStride;
         continue;
@@ -716,70 +914,75 @@
 
     Int iLastSPos;
-    Int iEndChangePos         = m_iStartChangePosX + iWidth - 1;
-    Int iPosXinNewData        = iWidth - 1;
-    Int iMinChangedSPos       = m_iSampledWidth;
-
-    if ( iEndChangePos == ( m_iWidth -1 )) // Special processing for rightmost depth sample
+    Int iEndChangePos         = m_iStartChangePosX + ( bL ? (iWidth - 1) : 0 ) ;
+
+    Int iEndChangePosInSubPel = iEndChangePos << m_iShiftPrec;
+    Int iPosXinNewData        = bL ? iWidth - 1 : 0; 
+    Int iMinChangedSPos       = bL ? m_iSampledWidth : -1;
+    if ( iEndChangePos == xWidthMinus1<bL>() )
     {
       m_iCurDepth           = m_piNewDepthData[iPosXinNewData];
-      Int iCurSPos          = xShiftNewData(iEndChangePos, iPosXinNewData);
-      m_iLastOccludedSPos   = iCurSPos + 1;
-      m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos );
-      xExtrapolateMarginL<bSet>  ( iCurSPos, iEndChangePos, iError );
-
-      iMinChangedSPos       = std::min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]);
-      iLastSPos             = iCurSPos;
-      m_iLastDepth          = m_iCurDepth;
-
-      if ( bSet )
+      Int iCurSPos          = xShiftDept(iEndChangePosInSubPel, m_iCurDepth );
+
+      m_curRangeStart       = xRangeLeft<bL>( iCurSPos );
+      xExtrapolateMargin<bL, bSM>  ( iCurSPos, iEndChangePos, iError );
+
+      Int iOldDepth          = m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD;
+      iMinChangedSPos        = xMin<Int, bL>( ( iOldDepth <= m_iCurDepth ) ? iCurSPos : xShiftDept(iEndChangePosInSubPel, iOldDepth ), iMinChangedSPos);
+      iLastSPos           = iCurSPos;
+      m_lastRangeStart    = m_curRangeStart;
+      m_iLastDepth        = m_iCurDepth;
+      m_iLastOccludedSPos = iLastSPos;
+
+      if ( bSM == SET_FULL || bSM == SET_SIMP )
       {
         m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD = m_piNewDepthData[iPosXinNewData];
       }
 
-      iPosXinNewData--;
-      iEndChangePos--;
+      xDec<Int, bL>(iPosXinNewData);
+      xDec<Int, bL>(iEndChangePos);
     }
     else
     {
-      iLastSPos    = xShift(iEndChangePos+1);
-      m_iLastDepth = m_pcInputSamplesRow [iCurViewPos][iEndChangePos+1].iD;
-      xInitRenderPartL( iEndChangePos, iLastSPos );
+      m_iLastDepth = m_pcInputSamplesRow [iCurViewPos][xPlus<Int,bL>(iEndChangePos,1)].iD;
+      iLastSPos    = xShiftDept(xPlus<Int,bL>(iEndChangePosInSubPel, ( 1 << m_iShiftPrec ) ), m_iLastDepth );
+      xInitRenderPart<bL>( iEndChangePos, iLastSPos );
     }
 
     //// RENDER NEW DATA
     Int iCurPosX;
-    for ( iCurPosX = iEndChangePos; iCurPosX >= iStartChangePos; iCurPosX-- )
-    {
-      // Get minimal changed sample position
-
-      iMinChangedSPos = std::min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]);
-      Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
-      m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
-      xRenderRangeL<bSet>(iCurSPos, iLastSPos, iCurPosX, iError );
+    for ( iCurPosX = iEndChangePos; xGeQ<Int,bL>(iCurPosX,iStartChangePos); xDec<Int,bL>(iCurPosX))
+    {
+      Int iCurPosXInSubPel = iCurPosX << m_iShiftPrec;
+      m_iCurDepth     = m_piNewDepthData[iPosXinNewData]        ;
+      Int iCurSPos    = xShiftDept(iCurPosXInSubPel,m_iCurDepth);  
+
+      Int iOldDepth   = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
+      iMinChangedSPos = xMin<Int,bL>( ( iOldDepth <= m_iCurDepth ) ? iCurSPos : xShiftDept(iCurPosXInSubPel, iOldDepth ), iMinChangedSPos);
+
+      xRenderRange<bL,bSM>(iCurSPos, iLastSPos, iCurPosX, iError );
       iLastSPos       = iCurSPos;
       m_iLastDepth    = m_iCurDepth;
 
-      if ( bSet )
+      if ( bSM == SET_FULL || bSM == SET_SIMP )
       {
         m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];
       }
-
-      iPosXinNewData--;
+      xDec<Int,bL>(iPosXinNewData);
     }
 
     //// RE-RENDER DATA LEFT TO NEW DATA
-    while ( iCurPosX >= 0 )
-    {
-      Int iCurSPos = xShift(iCurPosX);
-
+
+    while ( xGeQ<Int,bL>(iCurPosX, xZero<bL>() ) )
+    {
+      Int iCurPosXInSubPel = iCurPosX << m_iShiftPrec;
       m_iCurDepth  = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
-      xRenderRangeL<bSet>( iCurSPos, iLastSPos, iCurPosX, iError );
-
-      if ( iCurSPos < iMinChangedSPos )
+      Int iCurSPos = xShiftDept(iCurPosXInSubPel,m_iCurDepth);      
+      xRenderRange<bL,bSM>( iCurSPos, iLastSPos, iCurPosX, iError );
+      if ( xLess<Int,bL>(iCurSPos,iMinChangedSPos) )
       {
-          break;
+        break;
       }
 
-      iCurPosX--;
+      xDec<Int,bL>(iCurPosX);
       iLastSPos    = iCurSPos;
       m_iLastDepth = m_iCurDepth;
@@ -787,5 +990,7 @@
 
 
-    xIncViewRow();
+
+
+    xIncViewRow<bSM>();
     m_piNewDepthData += iStride;
   }
@@ -793,223 +998,47 @@
 }
 
-#ifdef  H_3D_VSO_EARLY_SKIP
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist
-TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData , Bool bFast)
-#else
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist
-TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )
-#endif
-{
-
-  const Int iCurViewPos   = 1;
-  const Int iOtherViewPos = 0;
-
-  m_iCurViewPos      = iCurViewPos;
-  m_iOtherViewPos    = iOtherViewPos;
-
-  m_piNewDepthData   = piNewData;
-  m_iNewDataWidth    = iWidth;
-  m_iStartChangePosX = iStartPosX;
-
-  if ((iWidth == 0) || (iHeight == 0))
-    return 0;
-
-  // Get Data
-  m_ppiCurLUT      = m_appiShiftLut   [iCurViewPos];
-  xSetViewRow      ( iStartPosY);
-
-  // Init Start
-  RMDist iError = 0;
-  Int   iEndChangePos;
-
-  iEndChangePos = m_iStartChangePosX + iWidth - 1;
-
-  for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
-  {
-#if H_3D_VSO_EARLY_SKIP
-    if( m_bEarlySkip && bFast )
-    {
-      if ( m_pbHorSkip[iPosY-iStartPosY] )
-      {
-        xIncViewRow();
-        m_piNewDepthData += iStride;
-        continue;
-      }
-    }
-#endif
-    m_bInOcclusion = false;
-
-    Int iLastSPos;
-    Int iStartChangePos       = m_iStartChangePosX;
-    Int iPosXinNewData        = 0;
-    Int iMaxChangedSPos = -1;
-
-    if ( iStartChangePos == 0 ) // Special processing for leftmost depth sample
-    {
-      m_iCurDepth           = m_piNewDepthData[iPosXinNewData];
-      Int iCurSPos          = xShiftNewData(iStartChangePos, iPosXinNewData);
-      m_iLastOccludedSPos   = iCurSPos - 1;
-      m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos );
-      xExtrapolateMarginR<bSet>     ( iCurSPos, iStartChangePos, iError );
-
-      iMaxChangedSPos       = std::max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iStartChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]);
-      iLastSPos             = iCurSPos;
-      m_iLastDepth          = m_iCurDepth;
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][iStartChangePos].iD = m_piNewDepthData[iPosXinNewData];
-      }
-
-
-      iPosXinNewData++;
-      iStartChangePos++;
-    }
-    else
-    {
-      iLastSPos   = xShift(iStartChangePos-1);
-
-      m_iLastDepth = m_pcInputSamplesRow[iCurViewPos][iStartChangePos-1].iD;
-      xInitRenderPartR( iStartChangePos, iLastSPos );
-    }
-
-    //// RENDER NEW DATA
-    Int iCurPosX;
-    for ( iCurPosX = iStartChangePos; iCurPosX <= iEndChangePos; iCurPosX++ )
-    {
-      // Get minimal changed sample position
-
-      iMaxChangedSPos = std::max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]);
-      Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
-      m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
-      xRenderRangeR<bSet>(iCurSPos, iLastSPos, iCurPosX, iError );
-      iLastSPos      = iCurSPos;
-      m_iLastDepth    = m_iCurDepth;
-
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];
-      }
-
-      iPosXinNewData++;
-    }
-
-    //// RE-RENDER DATA LEFT TO NEW DATA
-    while ( iCurPosX < m_iWidth )
-    {
-      Int iCurSPos = xShift(iCurPosX);
-
-      m_iCurDepth  = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
-      xRenderRangeR<bSet>( iCurSPos, iLastSPos, iCurPosX, iError );
-
-      if ( iCurSPos > iMaxChangedSPos )
-      {
-          break;
-        }
-      iCurPosX++;
-      iLastSPos    = iCurSPos;
-      m_iLastDepth = m_iCurDepth;
-    }
-
-    xIncViewRow();
-    m_piNewDepthData += iStride;
-  }
-  return iError;
-}
-
-
-template <BlenMod iBM, Bool bBitInc> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xInitRenderPartL(  Int iEndChangePos, Int iLastSPos )
-{
-  const Int iCurViewPos = 0; 
-  // GET MINIMAL OCCLUDED SAMPLE POSITION
-  Int iCurPosX           = iEndChangePos;
-
-
-  if ( ( iCurPosX + 1 < m_iWidth ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded ) )
-  {
-    iCurPosX++;
-
-    while ( (iCurPosX + 1 < m_iWidth) &&  (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded  )  )
-
-      iCurPosX++;
-
-    if ( iCurPosX + 1 < m_iWidth )
-    {
-      iCurPosX++;
-      m_iLastOccludedSPos = xShift(iCurPosX);
-    }
-    else
-    {
-      m_iLastOccludedSPos = xShift(iCurPosX) + 1;
-    }
-
-    m_iLastOccludedSPosFP = xRoundL( m_iLastOccludedSPos );
+template <BlenMod iBM, Bool bBitInc> template<Bool bL> __inline Void
+TRenSingleModelC<iBM,bBitInc>::xInitRenderPart(  Int iEndChangePos, Int iLastSPos )
+{
+  const Int iCurViewPos = bL ? 0 : 1;   
+  m_iLastOccludedSPos = m_pcInputSamplesRow[iCurViewPos][ xPlus<Int,bL>(iEndChangePos,1) ].aiOccludedPos;  
+  m_bInOcclusion      = xGeQ<Int,bL>( iLastSPos, m_iLastOccludedSPos ); 
+
+  if( m_bInOcclusion )
+  {
+    m_lastRangeStart = xRound<bL>( m_iLastOccludedSPos );  
   }
   else
   {
-    m_iLastOccludedSPos   = iLastSPos+1;
-    m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos );
-  }
-
-  m_bInOcclusion = iLastSPos >= m_iLastOccludedSPos;
+    m_iLastOccludedSPos = iLastSPos; 
+    m_lastRangeStart = xRangeLeft<bL>( iLastSPos );  
+  }
 };
 
-template <BlenMod iBM, Bool bBitInc> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xInitRenderPartR(  Int iStartChangePos, Int iLastSPos )
-{
-    const Int iCurViewPos = 1; 
-  // GET MINIMAL OCCLUDED SAMPLE POSITION
-  Int iCurPosX           = iStartChangePos;
-
-  if ( ( iCurPosX - 1 > -1 ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded  ) )
-  {
-    iCurPosX--;
-
-    while ( (iCurPosX - 1 > -1 ) &&  (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded  )  )
-      iCurPosX--;
-
-    if ( iCurPosX - 1 > -1 )
-    {
-      iCurPosX--;
-      m_iLastOccludedSPos = xShift(iCurPosX);
-    }
-    else
-    {
-      m_iLastOccludedSPos = xShift(iCurPosX) - 1;
-    }
-    m_iLastOccludedSPosFP = xRoundR( m_iLastOccludedSPos );
+template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
+TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRange(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
+{
+  RM_AOF( (xGeQ<Int,bL>(iLastSPos,iCurSPos)) );
+  Int iDeltaSPos = bL ? iLastSPos - iCurSPos : iCurSPos - iLastSPos;
+
+  m_curRangeStart = xRangeLeft<bL>( iCurSPos ); 
+  if ( iDeltaSPos > m_iGapTolerance )
+  {
+    xFillHole<bL,bSM>( iCurSPos, iLastSPos, iCurPos, riError );
   }
   else
   {
-    m_iLastOccludedSPos   = iLastSPos-1;
-    m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos );
-  }
-
-  m_bInOcclusion = iLastSPos <= m_iLastOccludedSPos;
-};
-
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
-{
-  assert( iCurSPos <= iLastSPos );
-  //assert( iRightSPos < m_iWidth );
-
-  Int iDeltaSPos = iLastSPos - iCurSPos;
-  if ( iDeltaSPos > m_iGapTolerance )
-  {
-    xFillHoleL<bSet>( iCurSPos, iLastSPos, iCurPos, riError );
-  }
-  else
-  {
-    if (iLastSPos < 0 )
+    if (!xGeQ<Int,bL>(iLastSPos, bL ? 0 : ( m_iSampledWidth - 1) ))
+    {
       return;
+    }
 
     RM_AOT( iDeltaSPos    > m_iGapTolerance );
 
     m_iThisDepth = m_iCurDepth;
-    for (Int iFillSPos = std::max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ )
-    {
-      Int iDeltaCurSPos  = (iFillSPos << m_iShiftPrec) - iCurSPos;
+
+    for (Int iFillSPos = xMax<Int,bL>(xZero<bL>(), m_curRangeStart ); xLess<Int,bL>(iFillSPos,m_lastRangeStart); xInc<Int,bL>(iFillSPos))
+    {
+      Int iDeltaCurSPos  = (iFillSPos << m_iShiftPrec) - (bL ? iCurSPos : iLastSPos); 
 
       RM_AOT( iDeltaCurSPos > iDeltaSPos );
@@ -1017,281 +1046,118 @@
       RM_AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
 
-      xSetShiftedPelL<bSet>( iCurPos, m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );
+      xSetShiftedPel<bL, bSM>( iCurPos, m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );
     }
   };
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
-{
-  assert( iCurSPos >= iLastSPos );
-
-  Int iDeltaSPos = iCurSPos - iLastSPos;
-  if ( iDeltaSPos > m_iGapTolerance )
-  {
-    xFillHoleR<bSet>( iCurSPos, iLastSPos, iCurPos, riError );
+  m_lastRangeStart = m_curRangeStart; 
+}
+
+template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
+TRenSingleModelC<iBM,bBitInc>::xRenderRange(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
+{
+  const Int iCurViewPos = bL ? 0 : 1; 
+
+  if ( bSM == SET_FULL || bSM == SET_SIMP )
+  {
+    m_pcInputSamplesRow[iCurViewPos][ iCurPos ].aiOccludedPos = m_iLastOccludedSPos;
+  }
+
+  if ( xLess<Int,bL>(iCurSPos,m_iLastOccludedSPos ))
+  {
+    m_bInOcclusion      = false;
+    m_iLastOccludedSPos = iCurSPos; 
+    xRenderShiftedRange<bL,bSM>(iCurSPos, iLastSPos, iCurPos, riError );
   }
   else
   {
-    if (iLastSPos > m_iSampledWidth - 1 )
-      return;
-
-    m_iThisDepth = m_iCurDepth;
-    RM_AOT( iDeltaSPos    > m_iGapTolerance );
-    for (Int iFillSPos = max(m_iLastOccludedSPosFP+1, xRangeLeftR(iLastSPos) ); iFillSPos <= min(xRangeRightR( iCurSPos ) ,m_iWidth -1); iFillSPos++ )
-    {
-      Int iDeltaCurSPos  = (iFillSPos << m_iShiftPrec) - iLastSPos;
-
-      RM_AOT( iDeltaCurSPos > iDeltaSPos );
-      RM_AOT( iDeltaCurSPos < 0 );
-      RM_AOT( m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
-
-      xSetShiftedPelR<bSet>( iCurPos, m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );
-    }
-  };
-}
-
-
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xRenderRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
-{
-  const Int iCurViewPos = 0; 
-  if (  !m_bInOcclusion )
-  {
-    if ( iCurSPos >= iLastSPos )
-    {
-      m_iLastOccludedSPos = iLastSPos;
-
-      Int iRightSPosFP = xRoundL( iLastSPos );
-      if ( ( iRightSPosFP == xRangeRightL(iLastSPos)) && (iRightSPosFP >= 0) )
+    if ( !m_bInOcclusion )
+    {      
+      RM_AOF( (xGeQ<Int,bL>(iLastSPos, m_iLastOccludedSPos)) ); 
+      Int iRightSPosFP = xRound<bL>( iLastSPos );      
+      if ( ( iRightSPosFP == xPlus<Int,bL>(m_lastRangeStart, -1) ) && xGeQ<Int,bL>(iRightSPosFP, xZero<bL>()) )
       {
         m_iThisDepth = m_iLastDepth;
-
-        xSetShiftedPelL<bSet>( iCurPos+1, 0, iRightSPosFP, REN_IS_FILLED, riError );
+        xSetShiftedPel<bL, bSM>( xPlus<Int,bL>(iCurPos,1), bL ? 0 : (1 << m_iShiftPrec), iRightSPosFP, REN_IS_FILLED, riError );
       }
-      m_iLastOccludedSPosFP = iRightSPosFP;
-
-      m_bInOcclusion = true;
-
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = true;
-      }
-    }
-    else
-    {
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = false;
-      }
-
-      xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
-    }
-  }
-  else
-  {
-    if ( iCurSPos < m_iLastOccludedSPos )
-    {
-      m_bInOcclusion = false;
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = false;
-      }
-
-      xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
-    }
-    else
-    {
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = true;
-      }
-    }
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xRenderRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
-{
-  const Int iCurViewPos = 1; 
-  // Find out if current sample is occluded
-  if (  !m_bInOcclusion )
-  {
-    if ( iCurSPos <= iLastSPos )
-    {
-      m_iLastOccludedSPos = iLastSPos;
-
-      Int iLeftSPosFP = xRoundR( iLastSPos );
-      if ( ( iLeftSPosFP == xRangeLeftR(iLastSPos)) && (iLeftSPosFP <= m_iWidth - 1) )
-      {
-        m_iThisDepth = m_iLastDepth;
-        xSetShiftedPelR<bSet>( iCurPos-1,1 << m_iShiftPrec , iLeftSPosFP, REN_IS_FILLED, riError );
-      }
-      m_iLastOccludedSPosFP = iLeftSPosFP;
-
-      m_bInOcclusion = true;
-
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = true;
-      }
-    }
-    else
-    {
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = false;
-      }
-
-      xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
-    }
-  }
-  else
-  {
-    if ( iCurSPos > m_iLastOccludedSPos )
-    {
-      m_bInOcclusion = false;
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = false;
-      }
-
-      xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
-    }
-    else
-    {
-      if ( bSet )
-      {
-        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = true;
-      }
-    }
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xFillHoleL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
+      m_lastRangeStart = iRightSPosFP;
+      m_bInOcclusion   = true; 
+    }
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
+TRenSingleModelC<iBM,bBitInc>::xFillHole( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
 {
   if (iLastSPos < 0)
+  {
     return;
+  }
 
   Int iStartFillSPos = iCurSPos;
   Int iStartFillPos  = iCurPos;
-  Int iLastPos      = iCurPos + 1;
-
-  Int iStartFillSPosFP = xRangeLeftL(iStartFillSPos);
-
-  if (iStartFillSPosFP == xRoundL(iStartFillSPos))
-  {
-    if ((iStartFillSPosFP >= 0) && (iStartFillSPosFP < m_iLastOccludedSPosFP) )
+  Int iLastPos       = xPlus<Int,bL>( iCurPos,1);
+
+  Int iStartFillSPosFP = m_curRangeStart; 
+  if (iStartFillSPosFP == xRound<bL>(iStartFillSPos))
+  {
+    if ( xGeQ<Int,bL>(iStartFillSPosFP, xZero<bL>())  && xLess<Int,bL>(iStartFillSPosFP, m_lastRangeStart) )
     {
       m_iThisDepth = m_iCurDepth;
-      xSetShiftedPelL<bSet>    ( iStartFillPos, 0, iStartFillSPosFP, REN_IS_FILLED, riError );
+      xSetShiftedPel<bL, bSM>    ( iStartFillPos, bL ? 0 : ( 1 << m_iShiftPrec), iStartFillSPosFP, REN_IS_FILLED, riError );
     }
   }
   else
   {
-    iStartFillSPosFP--;
+    xDec<Int,bL>( iStartFillSPosFP );
   }
 
   m_iThisDepth = m_iLastDepth;
-  for (Int iFillSPos = std::max(iStartFillSPosFP+1,0); iFillSPos <= min(xRangeRightL( iLastSPos ), m_iLastOccludedSPosFP-1 ); iFillSPos++ )
-  {
-    xSetShiftedPelL<bSet>( iLastPos, 0,  iFillSPos, REN_IS_HOLE, riError );
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xFillHoleR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
-{
-  if (iLastSPos < 0)
-    return;
-
-  Int iStartFillSPos = iCurSPos;
-  Int iEndFillPos    = iCurPos;
-  Int iLastPos       = iCurPos - 1;
-
-  Int iStartFillSPosFP = xRangeRightR(iStartFillSPos);
-
-  if (iStartFillSPosFP == xRoundR(iStartFillSPos))
-  {
-    if ((iStartFillSPosFP < m_iWidth) && (iStartFillSPosFP > m_iLastOccludedSPosFP) )
-    {
-      m_iThisDepth = m_iCurDepth;
-      xSetShiftedPelR<bSet>( iEndFillPos, 1 << m_iShiftPrec , iStartFillSPosFP, REN_IS_FILLED, riError );
-    }
-  }
-  else
-  {
-    iStartFillSPosFP++;
-  }
-
-  m_iThisDepth = m_iLastDepth;
-  for (Int iFillSPos = max(xRangeLeftR( iLastSPos ), m_iLastOccludedSPosFP+1); iFillSPos <= min(iStartFillSPosFP,m_iWidth)-1 ; iFillSPos++ )
-  {
-    xSetShiftedPelR<bSet>( iLastPos, 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xExtrapolateMarginL(Int iCurSPos, Int iCurPos, RMDist& riError )
-{
-//  if (iLeftSPos < 0 )
-//    return;
-
-  Int iSPosFullPel = std::max(0,xRangeLeftL(iCurSPos));
+  for (Int iFillSPos = xMax<Int,bL>(xPlus<Int,bL>(iStartFillSPosFP,1),xZero<bL>()); xLess<Int,bL>(iFillSPos, m_lastRangeStart); xInc<Int,bL>(iFillSPos))
+  {
+    xSetShiftedPel<bL, bSM>( iLastPos, bL ? 0 : (1 << m_iShiftPrec),  iFillSPos, REN_IS_HOLE, riError );
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
+TRenSingleModelC<iBM,bBitInc>::xExtrapolateMargin(Int iCurSPos, Int iCurPos, RMDist& riError )
+{
+  Int iSPosFullPel = xMax<Int,bL>(xZero<bL>(),m_curRangeStart);
 
   m_iThisDepth = m_iCurDepth;
-  if (iSPosFullPel < m_iWidth)
-  {
-    xSetShiftedPelL<bSet>( iCurPos, 0, iSPosFullPel, REN_IS_FILLED, riError );
-  }
-
-  for (Int iFillSPos = iSPosFullPel +1; iFillSPos < m_iWidth; iFillSPos++ )
-  {
-    xSetShiftedPelL<bSet>( iCurPos, 0, iFillSPos, REN_IS_HOLE, riError );
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xExtrapolateMarginR(Int iCurSPos, Int iCurPos, RMDist& riError )
-{
-  //  if (iLeftSPos < 0 )
-  //    return;
-
-  Int iSPosFullPel = std::min(m_iWidth-1,xRangeRightR(iCurSPos));
-
-  m_iThisDepth = m_iCurDepth;
-  if (iSPosFullPel > -1)
-  {
-    xSetShiftedPelR<bSet>( iCurPos, 1 << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError );
-  }
-
-  for (Int iFillSPos = iSPosFullPel -1; iFillSPos > -1; iFillSPos-- )
-  {
-    xSetShiftedPelR<bSet>( iCurPos , 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> __inline Int
+  if ( xGeQ<Int,bL>(xWidthMinus1<bL>(), iSPosFullPel) )
+  {
+    xSetShiftedPel<bL, bSM>( iCurPos, bL ? 0 : (1 << m_iShiftPrec) , iSPosFullPel, REN_IS_FILLED, riError );
+  }
+  for (Int iFillSPos = xPlus<Int,bL>(iSPosFullPel ,1); xGeQ<Int,bL>( xWidthMinus1<bL>(), iFillSPos ); xInc<Int,bL>(iFillSPos))
+  {
+    xSetShiftedPel<bL, bSM>( iCurPos, bL ? 0 : ( 1 << m_iShiftPrec ), iFillSPos, REN_IS_HOLE, riError );
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> template <Bool bL> __inline Int
 TRenSingleModelC<iBM,bBitInc>::xShiftNewData( Int iPosX, Int iPosInNewData )
 {
   RM_AOT( iPosInNewData <               0 );
   RM_AOF( iPosInNewData < m_iNewDataWidth );
-
   return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_piNewDepthData[iPosInNewData] )];
 }
 
+
 template <BlenMod iBM, Bool bBitInc> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xShiftDept( Int iPosXinSubPel, Int iDepth )
+{
+  return (iPosXinSubPel) - m_ppiCurLUT[0][ RenModRemoveBitInc( iDepth )];
+}
+
+
+template <BlenMod iBM, Bool bBitInc> template <Bool bL> __inline Int
 TRenSingleModelC<iBM,bBitInc>::xShift( Int iPosX )
 {
  RM_AOT( iPosX <        0);
  RM_AOF( iPosX < m_iWidth);
-
- return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_pcInputSamplesRow[m_iCurViewPos][iPosX].iD )];
-}
-
-
-template <BlenMod iBM, Bool bBitInc> __inline Int
+ return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_pcInputSamplesRow[(bL ? 0 : 1)][iPosX].iD )];
+}
+
+
+template <BlenMod iBM, Bool bBitInc> template <Bool bL> __inline Int
 TRenSingleModelC<iBM,bBitInc>::xShift( Int iPos, Int iPosInNewData )
 {
@@ -1302,46 +1168,47 @@
   else
   {
-    return xShift(iPos);
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> __inline Int
-TRenSingleModelC<iBM,bBitInc>::xRangeLeftL( Int iPos )
-{
-  return  ( iPos +  (1 << m_iShiftPrec) - 1) >> m_iShiftPrec;
-}
-
-
-template <BlenMod iBM, Bool bBitInc> __inline Int
-TRenSingleModelC<iBM,bBitInc>::xRangeLeftR( Int iPos )
-{
-
-  return  xRangeRightR( iPos ) + 1;
-}
-
-
-template <BlenMod iBM, Bool bBitInc> __inline Int
-TRenSingleModelC<iBM,bBitInc>::xRangeRightL( Int iPos )
-{
-  return xRangeLeftL(iPos) - 1;
-}
-
-template <BlenMod iBM, Bool bBitInc> __inline Int
-TRenSingleModelC<iBM,bBitInc>::xRangeRightR( Int iPos )
-{
-  return iPos >> m_iShiftPrec;
-}
-
-
-template <BlenMod iBM, Bool bBitInc> __inline Int
-TRenSingleModelC<iBM,bBitInc>::xRoundL( Int iPos )
-{
-  return  (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec;
-}
-
-template <BlenMod iBM, Bool bBitInc> __inline Int
-TRenSingleModelC<iBM,bBitInc>::xRoundR( Int iPos )
-{
-  return  (m_iShiftPrec == 0) ? iPos : xRoundL(iPos - 1);
+    return xShift<bL>(iPos);
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> template<Bool bL> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRangeLeft( Int iPos )
+{
+  if ( bL )
+  {
+    return  ( iPos +  (1 << m_iShiftPrec) - 1) >> m_iShiftPrec;
+  }
+  else
+  {
+    return iPos >> m_iShiftPrec;
+  }
+}
+
+
+
+template <BlenMod iBM, Bool bBitInc> template<Bool bL> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRangeRight( Int iPos )
+{
+  if ( bL )
+  {
+    return xRangeLeft<true>(iPos)    - 1;
+  }
+  else
+  {
+    return xRangeLeft<false>( iPos ) + 1;   
+  }  
+}
+
+template <BlenMod iBM, Bool bBitInc> template<Bool bL> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRound( Int iPos )
+{
+  if( bL )
+  {  
+    return  (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec;
+  }
+  else
+  {
+    return  (m_iShiftPrec == 0) ? iPos : xRound<true>(iPos - 1);
+  }
 }
 
@@ -1387,6 +1254,6 @@
 }
 
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelL(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
+template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
+TRenSingleModelC<iBM,bBitInc>::xSetShiftedPel(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
 {
   RM_AOT( iSourcePos    <  0                   );
@@ -1395,252 +1262,110 @@
   RM_AOT( iSubSourcePos >  (1 << m_iShiftPrec) );
   RM_AOT( iTargetSPos   < 0                    );
-  RM_AOT( iTargetSPos   >= m_iWidth            );  
-
-  RenModelOutPels* pcOutSample = m_pcOutputSamplesRow              + iTargetSPos;
-  RenModelInPels * pcInSample  = m_pcInputSamplesRow[VIEWPOS_LEFT] + iSourcePos ;
-
-  if ( iBM != BLEND_NONE )
-  {
-    xSetShiftedPelBlendL<bSet>  (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);
-  }
-  else
-  {
-    xSetShiftedPelNoBlendL<bSet>(pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelNoBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )
-{
-  if ( bSet )
-  { 
-    // Filled
-    pcOutSample->iFilledLeft = iFilled;
-
-    // Yuv
-    pcOutSample->iYLeft  = pcInSample->aiY[iSubSourcePos];
-#if H_3D_VSO_COLOR_PLANES
-    pcOutSample->iULeft  = pcInSample->aiU[iSubSourcePos];
-    pcOutSample->iVLeft  = pcInSample->aiV[iSubSourcePos];
-
-    pcOutSample->iError = xGetDist( pcOutSample->iYLeft - pcOutSample->iYRef,
-                                    pcOutSample->iULeft - pcOutSample->iURef,    
-                                    pcOutSample->iVLeft - pcOutSample->iVRef
-                                  );    
-#else
-    pcOutSample->iError = xGetDist( pcOutSample->iYLeft - pcOutSample->iYRef );    
+  RM_AOT( iTargetSPos   >= m_iWidth            );
+
+  RenModelInPels * pcInSample  = m_pcInputSamplesRow[ bL ? VIEWPOS_LEFT : VIEWPOS_RIGHT ] + iSourcePos ;
+
+  Pel iY;
+  Pel iYCurNew = pcInSample->aiY[iSubSourcePos];    
+#if H_3D_VSO_COLOR_PLANES
+  Pel iU;
+  Pel iUCurNew = pcInSample->aiU[iSubSourcePos];
+  Pel iV;
+  Pel iVCurNew = pcInSample->aiV[iSubSourcePos];;
 #endif    
-    
+
+  const Bool bFullMode = ( bSM == GET_FULL || bSM == SET_FULL ); 
+
+  RenModelOutPels*    pcOutSample    = bFullMode ? ( m_pcOutputSamplesRow    + iTargetSPos ) : NULL; 
+  RenModelLimOutPels* pcLimOutSample = bFullMode ? NULL  : ( m_pcLimOutputSamplesRow + iTargetSPos ); 
+
+  if ( iBM == BLEND_NONE )
+  {
+    iY = iYCurNew; 
+#if H_3D_VSO_COLOR_PLANES
+    iU = iUCurNew; 
+    iV = iVCurNew; 
+#endif
   }
   else
   { 
-#if H_3D_VSO_COLOR_PLANES
-    riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef,
-                         pcInSample->aiU[iSubSourcePos] - pcOutSample->iURef,
-                         pcInSample->aiV[iSubSourcePos] - pcOutSample->iVRef
-                       );
-#else               
-    riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef );
-#endif
-
-    riError -= pcOutSample->iError;
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )
-{
-  Pel piBlendedValueY;
-#if H_3D_VSO_COLOR_PLANES
-  Pel piBlendedValueU;
-  Pel piBlendedValueV;
-#endif
-
-  xGetBlendedValue (
-    pcInSample ->aiY[iSubSourcePos],
-    pcOutSample->iYRight,    
-#if H_3D_VSO_COLOR_PLANES
-    pcInSample ->aiU[iSubSourcePos],
-    pcOutSample->iURight,    
-    pcInSample ->aiV[iSubSourcePos],
-    pcOutSample->iVRight,    
-#endif
-    m_piInvZLUTLeft [RenModRemoveBitInc(m_iThisDepth)        ],
-    m_piInvZLUTRight[RenModRemoveBitInc(pcOutSample->iDRight)],
-    iFilled,
-    pcOutSample->iFilledRight  ,
-    piBlendedValueY
-#if H_3D_VSO_COLOR_PLANES
-    , piBlendedValueU,
-    piBlendedValueV
-#endif
-    );
-
-  if ( bSet )
+    Pel iYOther      = bFullMode ? ( bL ? pcOutSample->iYRight : pcOutSample->iYLeft) : pcLimOutSample->iYOther; 
+#if H_3D_VSO_COLOR_PLANES
+    Pel iUOther      = bFullMode ? ( bL ? pcOutSample->iURight : pcOutSample->iULeft ) : pcLimOutSample->iUOther; 
+    Pel iVOther      = bFullMode ? ( bL ? pcOutSample->iVRight : pcOutSample->iVLeft ) : pcLimOutSample->iVOther; 
+#endif
+    Int iFilledOther = bFullMode ? ( bL ? pcOutSample->iFilledRight : pcOutSample->iFilledLeft ) : pcLimOutSample->iFilledOther; 
+    Pel iDOther      = bFullMode ? ( bL ? pcOutSample->iDRight      : pcOutSample->iDLeft      ) : pcLimOutSample->iDOther; 
+
+    xGetBlendedValue<bL, bSM>(
+      iY,
+      bL ? iYCurNew : iYOther,
+      bL ? iYOther  : iYCurNew,
+#if H_3D_VSO_COLOR_PLANES
+      iU,
+      bL ? iUCurNew  : iUOther,
+      bL ? iUOther   : iUCurNew,
+      iV,
+      bL ? iVCurNew  : iVOther,
+      bL ? iVOther   : iVCurNew,          
+#endif
+      bL ? iFilled      : iFilledOther,
+      bL ? iFilledOther : iFilled,
+      m_piInvZLUTLeft [RenModRemoveBitInc( bL ? m_iThisDepth : iDOther)],
+      m_piInvZLUTRight[RenModRemoveBitInc( bL ? iDOther      : m_iThisDepth)]
+      ); 
+  }
+
+
+  Int iDist = xGetDist( 
+    iY - ( bFullMode ? pcOutSample->iYRef : pcLimOutSample->iYRef ) 
+#if H_3D_VSO_COLOR_PLANES
+  , iU - ( bFullMode ? pcOutSample->iURef : pcLimOutSample->iURef )
+  , iV - ( bFullMode ? pcOutSample->iVRef : pcLimOutSample->iVRef )
+#endif
+  );
+
+  if ( bSM == GET_FULL || bSM == GET_SIMP )
   {    
-    // Set values
-    pcOutSample->iDLeft      = m_iThisDepth;
-    pcOutSample->iYLeft      = pcInSample ->aiY[iSubSourcePos];
-    pcOutSample->iYBlended   = piBlendedValueY;    
-#if H_3D_VSO_COLOR_PLANES  
-    pcOutSample->iULeft      = pcInSample ->aiU[iSubSourcePos];
-    pcOutSample->iUBlended   = piBlendedValueU;    
-    pcOutSample->iVLeft      = pcInSample ->aiV[iSubSourcePos];
-    pcOutSample->iVBlended   = piBlendedValueV;    
-#endif
-    pcOutSample->iFilledLeft = iFilled;
-
-    // Get Error
-    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
-#if H_3D_VSO_COLOR_PLANES
-    Int iDiffU = pcOutSample->iURef - piBlendedValueU;
-    Int iDiffV = pcOutSample->iVRef - piBlendedValueV;
-    pcOutSample->iError  = xGetDist(iDiffY, iDiffU, iDiffV );
-#else
-    pcOutSample->iError  = xGetDist(iDiffY );
-#endif
-  }
-  else
-  {
-    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
-#if H_3D_VSO_COLOR_PLANES
-    Int iDiffU = pcOutSample->iURef - piBlendedValueU;
-    Int iDiffV = pcOutSample->iVRef - piBlendedValueV;
-    riError   += ( xGetDist( iDiffY, iDiffU, iDiffV ) - pcOutSample->iError );
-
-#else
-    riError   += ( xGetDist( iDiffY ) - pcOutSample->iError  );
-#endif
-
-  }
-}
-
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelR(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
-{
-  RM_AOT( iSourcePos    <  0                     );
-  RM_AOT( iSourcePos    >= m_iWidth              );
-  RM_AOT( iSubSourcePos <  0                     );
-  RM_AOT( iSubSourcePos >= (1 << m_iShiftPrec)+1 );
-  RM_AOT( iTargetSPos   < 0                      );
-  RM_AOT( iTargetSPos   >= m_iWidth              );  
-
-  RenModelOutPels* pcOutSample = m_pcOutputSamplesRow               + iTargetSPos;
-  RenModelInPels * pcInSample  = m_pcInputSamplesRow[VIEWPOS_RIGHT] + iSourcePos ;
-
-  if ( iBM != BLEND_NONE )
-  {
-    xSetShiftedPelBlendR<bSet>   (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);
-  }
-  else
-  {
-    xSetShiftedPelNoBlendR<bSet> (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelNoBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )
-{
-  if ( bSet )
-  { 
-    // Filled
-    pcOutSample->iFilledRight = iFilled;
-
-    // Yuv
-    pcOutSample->iYRight  = pcInSample->aiY[iSubSourcePos];
-#if H_3D_VSO_COLOR_PLANES
-    pcOutSample->iURight  = pcInSample->aiU[iSubSourcePos];
-    pcOutSample->iVRight  = pcInSample->aiV[iSubSourcePos];
-
-    pcOutSample->iError = xGetDist( 
-      pcOutSample->iYRight - pcOutSample->iYRef,
-      pcOutSample->iURight - pcOutSample->iURef,    
-      pcOutSample->iVRight - pcOutSample->iVRef
-      );    
-#else
-    pcOutSample->iError = xGetDist( pcOutSample->iYRight - pcOutSample->iYRef );    
-#endif    
-
-  }
-  else
-  { 
-#if H_3D_VSO_COLOR_PLANES
-    riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef,
-      pcInSample->aiU[iSubSourcePos] - pcOutSample->iURef,
-      pcInSample->aiV[iSubSourcePos] - pcOutSample->iVRef
-      );
-#else               
-    riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef );
-#endif
-
-    riError -= pcOutSample->iError;
-  }
-}
-
-template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
-TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )
-{
-  Pel piBlendedValueY;
-#if H_3D_VSO_COLOR_PLANES
-  Pel piBlendedValueU;
-  Pel piBlendedValueV;
-#endif
-
-  xGetBlendedValue (
-    pcOutSample->iYLeft, 
-    pcInSample ->aiY[iSubSourcePos],        
-#if H_3D_VSO_COLOR_PLANES
-    pcOutSample->iULeft,    
-    pcInSample ->aiU[iSubSourcePos],
-    pcOutSample->iVLeft,    
-    pcInSample ->aiV[iSubSourcePos],
-#endif
-    m_piInvZLUTLeft  [RenModRemoveBitInc(pcOutSample->iDLeft)],
-    m_piInvZLUTRight [RenModRemoveBitInc(m_iThisDepth)       ],
-    pcOutSample->iFilledLeft,
-    iFilled,
-    piBlendedValueY
-#if H_3D_VSO_COLOR_PLANES
-    , piBlendedValueU,
-    piBlendedValueV
-#endif
-    );
-
-  if ( bSet )
-  {    
-    // Set values
-    pcOutSample->iDRight     = m_iThisDepth;
-    pcOutSample->iYRight     = pcInSample ->aiY[iSubSourcePos];
-    pcOutSample->iYBlended   = piBlendedValueY;    
-#if H_3D_VSO_COLOR_PLANES  
-    pcOutSample->iURight     = pcInSample ->aiU[iSubSourcePos];
-    pcOutSample->iUBlended   = piBlendedValueU;    
-    pcOutSample->iVRight     = pcInSample ->aiV[iSubSourcePos];
-    pcOutSample->iVBlended   = piBlendedValueV;    
-#endif
-    pcOutSample->iFilledRight = iFilled;
-
-    // Get Error
-    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
-#if H_3D_VSO_COLOR_PLANES
-    Int iDiffU = pcOutSample->iURef - piBlendedValueU;
-    Int iDiffV = pcOutSample->iVRef - piBlendedValueV;
-    pcOutSample->iError  = xGetDist(iDiffY, iDiffU, iDiffV );
-#else
-    pcOutSample->iError  = xGetDist(iDiffY );
-#endif
-  }
-  else
-  {
-    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
-#if H_3D_VSO_COLOR_PLANES
-    Int iDiffU = pcOutSample->iURef - piBlendedValueU;
-    Int iDiffV = pcOutSample->iVRef - piBlendedValueV;
-    riError   += ( xGetDist( iDiffY, iDiffU, iDiffV ) - pcOutSample->iError );
-#else
-    riError   += ( xGetDist( iDiffY ) -  pcOutSample->iError  );
-#endif
-  }
+    riError += ( iDist - ( bFullMode ? pcOutSample->iError : pcLimOutSample->iError ) );
+  }
+  else // bSM == SET_FULL
+  {
+    Int& riErrorStr = bFullMode ? pcOutSample->iError : pcLimOutSample->iError; 
+    riErrorStr      = iDist; 
+
+    if ( bFullMode )
+    {     
+      if ( iBM != BLEND_NONE )
+      {        
+        pcOutSample->iYBlended   = iY; 
+#if H_3D_VSO_COLOR_PLANES
+        pcOutSample->iUBlended   = iU; 
+        pcOutSample->iVBlended   = iV; 
+#endif
+      }
+
+      if ( bL )
+      {
+        pcOutSample->iDLeft      = m_iThisDepth; 
+        pcOutSample->iFilledLeft = iFilled; 
+        pcOutSample->iYLeft      = iYCurNew;
+#if  H_3D_VSO_COLOR_PLANES
+        pcOutSample->iULeft      = iUCurNew;
+        pcOutSample->iVLeft      = iVCurNew;
+#endif
+      }
+      else
+      {
+        pcOutSample->iDRight      = m_iThisDepth; 
+        pcOutSample->iFilledRight = iFilled; 
+        pcOutSample->iYRight      = iYCurNew;
+#if  H_3D_VSO_COLOR_PLANES
+        pcOutSample->iURight      = iUCurNew;
+        pcOutSample->iVRight      = iVCurNew;
+#endif
+      }
+    }
+  }    
 }
 
@@ -1687,13 +1412,12 @@
 
 
-#if H_3D_VSO_COLOR_PLANES
-template <BlenMod iBM, Bool bBitInc>  __inline Void
-TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
-#else
-template <BlenMod iBM, Bool bBitInc>  __inline Void
-TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
-#endif
-{
-
+
+template <BlenMod iBM, Bool bBitInc>  template< Bool bL, SetMod bSM > __inline Void
+  TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel& riY, Pel iYL,  Pel iYR,  
+#if H_3D_VSO_COLOR_PLANES
+                                                   Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR,  
+#endif
+                                                   Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  )
+{  
   RM_AOT( iBM != BLEND_AVRG && iBM != BLEND_LEFT && iBM != BLEND_RIGHT );
 
@@ -1702,17 +1426,17 @@
     if (iBM == BLEND_LEFT )
     {
-#if H_3D_VSO_COLOR_PLANES
-      xGetBlendedValueBM1(  iYL,  iYR,  iUL,  iUR,  iVL,  iVR,  iDepthL,  iDepthR,  iFilledL,  iFilledR,  riY,  riU, riV );
-#else
-      xGetBlendedValueBM1(  iYL,  iYR,  iDepthL,  iDepthR,  iFilledL,  iFilledR,  riY );
-#endif
+      xGetBlendedValueBM1<bL, bSM>( riY, iYL,  iYR,  
+#if H_3D_VSO_COLOR_PLANES
+        riU, iUL,  iUR,  riV, iVL,  iVR,  
+#endif
+        iFilledL,  iFilledR, iDepthL,  iDepthR  );
     }
     else
     {
-#if H_3D_VSO_COLOR_PLANES
-      xGetBlendedValueBM2(  iYL,  iYR,  iUL,  iUR,  iVL,  iVR,  iDepthL,  iDepthR,  iFilledL,  iFilledR,  riY,  riU, riV );
-#else
-      xGetBlendedValueBM2(  iYL,  iYR, iDepthL,  iDepthR,  iFilledL,  iFilledR,  riY );
-#endif
+      xGetBlendedValueBM2<bL, bSM>(  riY, iYL,  iYR,  
+#if H_3D_VSO_COLOR_PLANES
+        riU, iUL,  iUR,  riV, iVL,  iVR,  
+#endif
+        iFilledL,  iFilledR, iDepthL,  iDepthR );
     }
     return;
@@ -1725,22 +1449,4 @@
     if ( abs ( iDepthDifference ) <= m_iBlendZThres )
     {
-      if      ((iFilledL == REN_IS_FILLED) && ( iFilledR != REN_IS_FILLED))
-      {
-        riY = xBlend( iYL, iYR, iFilledR >> 1 );
-#if H_3D_VSO_COLOR_PLANES
-        riU = xBlend( iUL, iUR, iFilledR >> 1 );
-        riV = xBlend( iVL, iVR, iFilledR >> 1 );
-#endif
-
-      }
-      else if ((iFilledL != REN_IS_FILLED) && ( iFilledR == REN_IS_FILLED))
-      {
-        riY = xBlend( iYR, iYL, (iFilledL >> 1) );
-#if H_3D_VSO_COLOR_PLANES
-        riU = xBlend( iUR, iUL, (iFilledL >> 1) );
-        riV = xBlend( iVR, iVL, (iFilledL >> 1) );
-#endif
-      }
-      else
       {
         riY = xBlend( iYL, iYR, m_iBlendDistWeight );
@@ -1760,5 +1466,5 @@
     }
     else
-    {
+    {      
       riY = iYR;
 #if H_3D_VSO_COLOR_PLANES
@@ -1808,10 +1514,10 @@
 }
 
-template <BlenMod iBM, Bool bBitInc> __inline Void
-#if H_3D_VSO_COLOR_PLANES
-TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
-#else
-TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
-#endif
+template <BlenMod iBM, Bool bBitInc> template< Bool bL, SetMod SM > __inline Void
+TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel& riY, Pel iYL,  Pel iYR,  
+#if H_3D_VSO_COLOR_PLANES
+                                                    Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR,  
+#endif
+                                                    Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  )
 {
   if ( iFilledL == REN_IS_FILLED ||  iFilledR == REN_IS_HOLE )
@@ -1841,10 +1547,10 @@
 }
 
-template <BlenMod iBM, Bool bBitInc> __inline Void
-#if H_3D_VSO_COLOR_PLANES
-TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
-#else
-TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
-#endif
+template <BlenMod iBM, Bool bBitInc> template< Bool bL, SetMod SM > __inline Void
+  TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel& riY, Pel iYL,  Pel iYR,  
+#if H_3D_VSO_COLOR_PLANES
+                                                      Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR,  
+#endif
+                                                      Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  )
 {
   if      ( iFilledR == REN_IS_FILLED ||  iFilledL == REN_IS_HOLE )
@@ -1899,10 +1605,9 @@
 
 #if H_3D_VSO_EARLY_SKIP
-template <BlenMod iBM, Bool bBitInc> 
-__inline Bool
-TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride)
+template <BlenMod iBM, Bool bBitInc> template <Bool bL > __inline Bool
+TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkip( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride)
 {
   RM_AOF( m_bEarlySkip ); 
-  const Int iCurViewPos = 0;
+  const Int iCurViewPos = bL ? 0 : 1;
   Int** ppiCurLUT       = m_appiShiftLut   [ iCurViewPos ];
   
@@ -1930,37 +1635,4 @@
   return bNoDiff;
 }
-
-template <BlenMod iBM, Bool bBitInc> 
-__inline Bool
-TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride)
-{
-  RM_AOF( m_bEarlySkip ); 
-  Bool bNoDiff  = true;
-
-  const Int iCurViewPos = 1;
-  Int** ppiCurLUT       = m_appiShiftLut   [ iCurViewPos ];
-
-  for ( Int iPosY = 0; iPosY < iHeight; iPosY++ )
-  {
-    m_pbHorSkip[iPosY] = true;
-
-    for (Int iPosX = 0; iPosX < iWidth; iPosX++)
-    {
-      Int iDisparityRec = abs( ppiCurLUT[0][ RenModRemoveBitInc(piNewData[iPosX])] );
-      Int iDisparityOrg = abs( ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])] );
-
-      if( iDisparityRec != iDisparityOrg )
-      {
-        m_pbHorSkip[iPosY] = false;
-        bNoDiff            = false;
-        break;
-      }
-    }
-
-    piNewData += iStride;
-    piOrgData += iOrgStride;
-  }
-  return bNoDiff;
-}
 #endif
 #endif // NH_3D
Index: trunk/source/Lib/TLibRenderer/TRenSingleModel.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 1396)
@@ -70,13 +70,24 @@
   virtual ~TRenSingleModel() { }  
 #if H_3D_VSO_EARLY_SKIP
-  virtual Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip ) = 0;
-#else
-  virtual Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode ) = 0;
-#endif
-
-  // Set Frame dependent data
-  virtual Void   setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride ) = 0;
-  virtual Void   setupPart ( UInt uiHorOffset,       Int iUsedHeight ) = 0;
-  virtual Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference ) = 0;
+  virtual Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bLimOutput, Bool bEarlySkip ) = 0;
+#else
+  virtual Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bLimOutput ) = 0;
+#endif
+
+  // Setup 
+  virtual Void   setLRView         ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride ) = 0;
+  virtual Void   setupPart         ( UInt uiHorOffset,       Int iUsedHeight ) = 0;
+#if RM_FIX_SETUP
+  virtual Void   setupLut          ( Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft ) = 0;
+  virtual Void   setupRefView      ( TComPicYuv* pcOrgVideo ) = 0;
+
+  virtual Void   renderAll                   ()                     = 0;
+  virtual Void   setStructSynthViewAsRefView ()                     = 0;
+  virtual Void   resetStructError            ()                     = 0;
+  virtual Void   setLimOutStruct             ( Int iSourceViewPos ) = 0; 
+#else
+  virtual Void   setupLutAndRef    ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, Bool bRenderRef ) = 0;
+  virtual Void   setupInitialState ( Int curViewPosInModel ) = 0;
+#endif
 
   // Set Data
@@ -114,7 +125,22 @@
     // depth
     Pel iD        ; // depth
-
-    // state
-    Bool bOccluded; // Occluded
+   Int aiOccludedPos; // Occluded
+
+  };
+
+  struct RenModelLimOutPels
+  {
+    Pel iDOther;
+    Int iFilledOther; 
+    // video
+    Pel iYOther; 
+    Pel iYRef  ; 
+#if H_3D_VSO_COLOR_PLANES
+    Pel iUOther; 
+    Pel iURef  ; 
+    Pel iVOther;
+    Pel iVRef  ; 
+#endif  
+    Int iError ;
   };
 
@@ -161,27 +187,39 @@
   // Create Model
 #if H_3D_VSO_EARLY_SKIP
-  Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip  );
-#else
-  Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode );
-#endif
-
-  // Set Frame dependent data
-  Void   setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride );
-  Void   setupPart ( UInt uiHorOffset,       Int uiUsedHeight );
-  Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference );
+  Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bLimOutput, Bool bEarlySkip  );
+#else
+  Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bLimOutput );
+#endif
+
+  // Setup 
+  Void   setLRView         ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride );  
+  Void   setupPart         ( UInt uiHorOffset,       Int uiUsedHeight ); 
+#if RM_FIX_SETUP
+  Void   setupLut          (  Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft);
+  Void   setupRefView      ( TComPicYuv* pcOrgVideo );
+  
+  __inline   Void   renderAll( );
+  Void              setStructSynthViewAsRefView ();
+  Void              resetStructError            ();
+  Void              setLimOutStruct             ( Int iSourceViewPos ); 
+#else
+  Void   setupLutAndRef    ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, Bool bRenderRef );
+  Void   setupInitialState ( Int curViewPosInModel );
+#endif
+
 
 #if H_3D_VSO_EARLY_SKIP
   Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride );
-#else                                                                                                                    
+#else
   Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
-#endif                                                                                                                   
+#endif
   Void   setVideo  ( Int iViewPos,     Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
-                                                                                                                         
-  // Get Distortion                                                                                                      
-#if H_3D_VSO_EARLY_SKIP                                                                                                  
+
+  // Get Distortion
+#if H_3D_VSO_EARLY_SKIP
   RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel * piOrgData , Int iOrgStride);
-#else                                                                                                                    
+#else
   RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
-#endif                                                                                                                   
+#endif
   RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
 
@@ -191,64 +229,67 @@
 
 private:
+
+#if !RM_FIX_SETUP
+   __inline Void  xRenderAll( );
+#endif
+
+
+#if H_3D_VSO_EARLY_SKIP
+    template < Bool bL, SetMod iSM > RMDist xSetOrGet( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Pel* piOrgData, Int iOrgStride );     
+#else
+    template < Bool bL, SetMod iSM > RMDist xSetOrGet( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
+#endif
+
   // Set and inc Current Row
-  __inline Void   xSetViewRow(  Int iPosY );
-  __inline Void   xIncViewRow();
+  template< SetMod bSM  > __inline Void   xSetViewRow(  Int iPosY );
+  template< SetMod bSM  > __inline Void   xIncViewRow();
 
   /////  Rendering /////
-  // Left to Right
-#if H_3D_VSO_EARLY_SKIP
-                      __inline Bool   xDetectEarlySkipL   ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride );
-                      __inline Bool   xDetectEarlySkipR   ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride );
-  template<Bool bSet> __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast );
-  template<Bool bSet> __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast );
-#else
-  template<Bool bSet> __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
-  template<Bool bSet> __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
-#endif
-                      __inline Void   xInitRenderPartL    ( Int iEndChangePos, Int iLastSPos  );
-  template<Bool bSet> __inline Void   xRenderRangeL       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  template<Bool bSet> __inline Void   xRenderShiftedRangeL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  template<Bool bSet> __inline Void   xFillHoleL          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  template<Bool bSet> __inline Void   xExtrapolateMarginL ( Int iCurSPos,                Int iCurPos, RMDist& riError );
-                      __inline Int    xRangeLeftL         ( Int iPos );
-                      __inline Int    xRangeRightL        ( Int iPos );
-                      __inline Int    xRoundL             ( Int iPos );
-
-  // Right to Left
-                      __inline Void   xInitRenderPartR    ( Int iStartChangePos, Int iLastSPos );
-  template<Bool bSet> __inline Void   xRenderShiftedRangeR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  template<Bool bSet> __inline Void   xRenderRangeR       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  template<Bool bSet> __inline Void   xFillHoleR          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  template<Bool bSet> __inline Void   xExtrapolateMarginR ( Int iCurSPos,                Int iCurPos, RMDist& riError );
-                      __inline Int    xRangeLeftR         ( Int iPos );
-                      __inline Int    xRangeRightR        ( Int iPos );
-                      __inline Int    xRoundR             ( Int iPos );
-
-  // Blending
-  template<Bool bSet> __inline Void   xSetShiftedPelBlend ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
-
-#if H_3D_VSO_COLOR_PLANES
-  __inline Void   xGetBlendedValue    ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );
-  __inline Void   xGetBlendedValueBM1 ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );
-  __inline Void   xGetBlendedValueBM2 ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );
-#else
-  __inline Void   xGetBlendedValue    ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
-  __inline Void   xGetBlendedValueBM1 ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
-  __inline Void   xGetBlendedValueBM2 ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
+  template< typename T, Bool bL > __inline T    xPlus   ( T arg1, T arg2 ) { return bL ? (arg1 + arg2) : (arg1 - arg2); };
+  template< typename T, Bool bL > __inline T    xMin    ( T arg1, T arg2 ) { return bL ? std::min(arg1, arg2) : std::max(arg1, arg2) ;};
+  template< typename T, Bool bL > __inline T    xMax    ( T arg1, T arg2 ) { return bL ? std::max(arg1, arg2) : std::min(arg1, arg2) ;};
+  template< typename T, Bool bL > __inline Void xInc    ( T& arg1        ) { bL ? arg1++ : arg1-- ;};
+  template< typename T, Bool bL > __inline Void xDec    ( T& arg1        ) { bL ? arg1-- : arg1++ ;};
+  template< typename T, Bool bL > __inline Bool xLess   ( T arg1, T arg2 ) { return bL ? arg1 <  arg2 : arg1 >  arg2; };  
+  template< typename T, Bool bL > __inline Bool xGeQ    ( T arg1, T arg2 ) { return bL ? arg1 >= arg2 : arg1 <= arg2; };
+  template<             Bool bL > __inline Int  xZero   (                ) { return bL ? 0 : m_iWidth - 1; };
+  template<             Bool bL > __inline Int  xWidthMinus1(            ) { return bL ? m_iWidth - 1 : 0; };
+#if H_3D_VSO_EARLY_SKIP
+  template<             Bool bL > __inline Bool   xDetectEarlySkip    ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData,const Pel* piOrgData, Int iOrgStride );
+  template< Bool bL, SetMod bSM > __inline RMDist xRender             ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast );
+  template< SetMod bSM >            __inline RMDist xGetSSE             ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast );
+#else       
+  template< Bool bL, SetMod bSM  > __inline RMDist xRender             ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
+  template<          SetMod bSM  > __inline RMDist xGetSSE             ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );
+#endif                          
+  template< Bool bL              > __inline Void   xInitRenderPart    ( Int iEndChangePos, Int iLastSPos  );
+  template< Bool bL, SetMod bSM  > __inline Void   xRenderRange       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
+  template< Bool bL, SetMod bSM  > __inline Void   xRenderShiftedRange( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
+  template< Bool bL, SetMod bSM  > __inline Void   xFillHole          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
+  template< Bool bL, SetMod bSM  > __inline Void   xExtrapolateMargin ( Int iCurSPos,                Int iCurPos, RMDist& riError );
+  template< Bool bL              > __inline Int    xRangeLeft         ( Int iPos );
+  template< Bool bL              > __inline Int    xRangeRight        ( Int iPos );
+  template< Bool bL              > __inline Int    xRound             ( Int iPos );
+
+#if H_3D_VSO_COLOR_PLANES  
+  template< Bool bL, SetMod bSM > __inline Void   xGetBlendedValue    ( Pel& riY, Pel iYL,  Pel iYR, Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR, Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR );
+  template< Bool bL, SetMod bSM > __inline Void   xGetBlendedValueBM1 ( Pel& riY, Pel iYL,  Pel iYR, Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR, Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR );
+  template< Bool bL, SetMod bSM > __inline Void   xGetBlendedValueBM2 ( Pel& riY, Pel iYL,  Pel iYR, Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR, Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR );
+#else
+  template< Bool bL, SetMod bSM > __inline Void   xGetBlendedValue    ( Pel& riY, Pel iYL,  Pel iYR, Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  );
+  template< Bool bL, SetMod bSM > __inline Void   xGetBlendedValueBM1 ( Pel& riY, Pel iYL,  Pel iYR, Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  );
+  template< Bool bL, SetMod bSM > __inline Void   xGetBlendedValueBM2 ( Pel& riY, Pel iYL,  Pel iYR, Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  );
 #endif
   __inline Pel    xBlend              ( Pel pVal1, Pel pVal2, Int iWeightVal2 );
 
   // General
-  template<Bool bSet> __inline Void xSetShiftedPelL       (Int iSourcePos,             Int iSubSourcePos, Int iTargetSPos,              Pel iFilled, RMDist& riError );
-  template<Bool bSet> __inline Void xSetShiftedPelBlendL  (RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );
-  template<Bool bSet> __inline Void xSetShiftedPelNoBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );
-
-  template<Bool bSet> __inline Void xSetShiftedPelR       (Int iSourcePos,             Int iSubSourcePos, Int iTargetSPos,              Pel iFilled, RMDist& riError );
-  template<Bool bSet> __inline Void xSetShiftedPelBlendR  (RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );
-  template<Bool bSet> __inline Void xSetShiftedPelNoBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );
-
-  __inline Int    xShiftNewData      ( Int iPos, Int iPosInNewData );
-  __inline Int    xShift             ( Int iPos );
-  __inline Int    xShift             ( Int iPos, Int iPosInNewData );
+  template<Bool bL, SetMod bSM> __inline Void xSetShiftedPel       (Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
+  
+  template <Bool bL>           __inline Int  xShiftNewData        ( Int iPos, Int iPosInNewData );
+  template <Bool bL>           __inline Int  xShift               ( Int iPos );
+  template <Bool bL>           __inline Int  xShift               ( Int iPos, Int iPosInNewData );
+
+  __inline Int    xShiftDept         ( Int iPosXinSubPel, Int iDepth ); 
+
   __inline Int    xGetDist           ( Int iDiffY, Int iDiffU, Int iDiffV );
   __inline Int    xGetDist           ( Int iDiffY );
@@ -264,10 +305,18 @@
   Void            xGetSampleStrTextPtrs ( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY );
 #endif 
-  Void            xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD );
+  Void            xGetSampleStrDepthPtrs ( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD      );
+  Void            xGetSampleStrFilledPtrs( Int iViewNum, Int RenModelOutPels::*& rpiSrcFilled );
+
        
   Void            xSetStructRefView            ();
+#if !RM_FIX_SETUP
   Void            xResetStructError            ();
+  Void            xSetLimOutStruct             (Int iSourceViewPos ); 
+#endif
+  
   Void            xInitSampleStructs           ();
+#if !RM_FIX_SETUP
   Void            xSetStructSynthViewAsRefView ();
+#endif
   Void            xCopy2PicYuv                ( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget );
 
@@ -340,5 +389,7 @@
 
   //// Output Samples
-  RenModelOutPels* m_pcOutputSamples;
+  RenModelOutPels*      m_pcOutputSamples;
+  RenModelLimOutPels*   m_pcLimOutputSamples; 
+
   Int                   m_iOutputSamplesStride;
 
@@ -349,8 +400,8 @@
   Bool  m_bInOcclusion;                // Currently rendering in occluded area
   Int   m_iLastOccludedSPos;           // Position of last topmost shifted position
-  Int   m_iLastOccludedSPosFP;         // Position of last topmost shifted position in FullPels
-
-  Int   m_iCurViewPos;                 // Current View Position 0: Left, 1: Right
-  Int   m_iOtherViewPos;               // Other View Position 0: Left, 1: Right
+
+  Int   m_curRangeStart; 
+  Int   m_lastRangeStart;  
+
   const Pel*  m_piNewDepthData;              // Pointer to new depth data
   Int   m_iStartChangePosX;            // Start Position of new data
@@ -377,9 +428,11 @@
   //// Current Pointers ////
 
-  RenModelInPels*  m_pcInputSamplesRow [2];
-  RenModelOutPels* m_pcOutputSamplesRow;
+  RenModelInPels*     m_pcInputSamplesRow [2];
+  RenModelOutPels*    m_pcOutputSamplesRow;
+  RenModelLimOutPels* m_pcLimOutputSamplesRow;
 
   //// MISC ////
-  const Int m_iDistShift;                  // Shift in Distortion computation
+  const Int m_iDistShift;            // Shift in Distortion computation
+  Bool      m_bLimOutput;            // Save distortion only
 
   //// Early Skip 
@@ -389,5 +442,5 @@
 };
 
-#endif // NH_3D
+#endif // H_3D
 #endif //__TRENSINGLEMODEL__
 
Index: trunk/source/Lib/TLibRenderer/TRenTop.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenTop.cpp	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenTop.cpp	(revision 1396)
@@ -40,5 +40,5 @@
 #include <math.h>
 #include "../TLibCommon/CommonDef.h"
-#if NH_3D_VSO
+#if NH_3D_VSO  || NH_3D
 
 
Index: trunk/source/Lib/TLibRenderer/TRenTop.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenTop.h	(revision 1387)
+++ trunk/source/Lib/TLibRenderer/TRenTop.h	(revision 1396)
@@ -39,5 +39,5 @@
 #include "../TLibCommon/TComPicYuv.h"
 
-#if NH_3D_VSO
+#if NH_3D_VSO || NH_3D
 #include <list>
 #include <vector>
