Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenModel.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenModel.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenModel.cpp	(revision 193)
@@ -42,4 +42,7 @@
   m_iWidth             = -1;
   m_iHeight            = -1;
+#if FIX_VSO_SETUP
+  m_iUsedHeight        = -1; 
+#endif
   m_iNumOfBaseViews    = -1;
   m_iSampledWidth      = -1;
@@ -434,16 +437,25 @@
 {
   AOT( iViewNum < 0 || iViewNum > m_iNumOfBaseViews );
+#if FIX_VSO_SETUP
+  AOF( pcPicYuvVideoData->getHeight() >= m_iUsedHeight + m_uiHorOff && pcPicYuvVideoData->getWidth() == m_iWidth );
+  AOF( pcPicYuvDepthData->getHeight() >= m_iUsedHeight + m_uiHorOff && pcPicYuvDepthData->getWidth() == m_iWidth );
+#else
   AOF( pcPicYuvVideoData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvVideoData->getWidth() == m_iWidth );
   AOF( pcPicYuvDepthData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvDepthData->getWidth() == m_iWidth );
+#endif
 
   pcPicYuvVideoData->extendPicBorder();
 
-  
-
-
+#if FIX_VSO_SETUP
+  TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvVideoData->getLumaAddr() +  m_uiHorOff        * pcPicYuvVideoData->getStride () , pcPicYuvVideoData->getStride() , m_iWidth,      m_iUsedHeight,      m_aapiCurVideoPel[ iViewNum ][0], m_aaiCurVideoStrides[iViewNum][0] );
+  TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCbAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvVideoData->getCStride() , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiCurVideoPel[ iViewNum ][1], m_aaiCurVideoStrides[iViewNum][1] );
+  TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCrAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvVideoData->getCStride() , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiCurVideoPel[ iViewNum ][2], m_aaiCurVideoStrides[iViewNum][2] );
+  TRenFilter::copy          (               pcPicYuvDepthData->getLumaAddr() +  m_uiHorOff        * pcPicYuvDepthData->getStride () , pcPicYuvDepthData->getStride(),  m_iWidth,      m_iUsedHeight,      m_apiCurDepthPel [ iViewNum],     m_aiCurDepthStrides [iViewNum]    );
+#else
   TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvVideoData->getLumaAddr() +  m_uiHorOff        * pcPicYuvVideoData->getStride () , pcPicYuvVideoData->getStride() , m_iWidth,      m_iHeight,      m_aapiCurVideoPel[ iViewNum ][0], m_aaiCurVideoStrides[iViewNum][0] );
   TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCbAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvVideoData->getCStride() , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][1], m_aaiCurVideoStrides[iViewNum][1] );
   TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCrAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvVideoData->getCStride() , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][2], m_aaiCurVideoStrides[iViewNum][2] );
   TRenFilter::copy          (               pcPicYuvDepthData->getLumaAddr() +  m_uiHorOff        * pcPicYuvDepthData->getStride () , pcPicYuvDepthData->getStride(),  m_iWidth,      m_iHeight,      m_apiCurDepthPel [ iViewNum],     m_aiCurDepthStrides [iViewNum]    );
+#endif
 
   // Used for rendering reference pic from original video data
@@ -453,4 +465,11 @@
   if ( m_abSetupVideoFromOrgForView[iViewNum] )
   {
+#if FIX_VSO_SETUP
+    AOF( pcPicYuvOrgVideoData->getHeight() >= m_iUsedHeight + m_uiHorOff && pcPicYuvOrgVideoData->getWidth() == m_iWidth );
+    pcPicYuvOrgVideoData->extendPicBorder();
+    TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvOrgVideoData->getLumaAddr() +  m_uiHorOff        * pcPicYuvOrgVideoData->getStride() , pcPicYuvOrgVideoData->getStride() , m_iWidth,      m_iUsedHeight,      m_aapiOrgVideoPel[ iViewNum ][0], m_aaiOrgVideoStrides[iViewNum][0] );
+    TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCbAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvOrgVideoData->getCStride(), pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][1], m_aaiOrgVideoStrides[iViewNum][1] );
+    TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCrAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvOrgVideoData->getCStride(), pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][2], m_aaiOrgVideoStrides[iViewNum][2] );
+#else
     AOF( pcPicYuvOrgVideoData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvOrgVideoData->getWidth() == m_iWidth );
     pcPicYuvOrgVideoData->extendPicBorder();
@@ -458,10 +477,16 @@
     TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCbAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvOrgVideoData->getCStride(), pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][1], m_aaiOrgVideoStrides[iViewNum][1] );
     TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCrAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvOrgVideoData->getCStride(), pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][2], m_aaiOrgVideoStrides[iViewNum][2] );
+#endif
   }
 
   if ( m_abSetupDepthFromOrgForView[iViewNum] )
   {
+#if FIX_VSO_SETUP
+    AOF( pcPicYuvOrgDepthData->getHeight() >= m_iUsedHeight + m_uiHorOff && pcPicYuvOrgDepthData->getWidth() == m_iWidth );
+    TRenFilter::copy          (               pcPicYuvOrgDepthData->getLumaAddr() +  m_uiHorOff        * pcPicYuvOrgDepthData->getStride() , pcPicYuvOrgDepthData->getStride(),  m_iWidth,     m_iUsedHeight,      m_apiOrgDepthPel [ iViewNum],     m_aiOrgDepthStrides [iViewNum]    );
+#else
     AOF( pcPicYuvOrgDepthData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvOrgDepthData->getWidth() == m_iWidth );
     TRenFilter::copy          (               pcPicYuvOrgDepthData->getLumaAddr() +  m_uiHorOff        * pcPicYuvOrgDepthData->getStride() , pcPicYuvOrgDepthData->getStride(),  m_iWidth,     m_iHeight,      m_apiOrgDepthPel [ iViewNum],     m_aiOrgDepthStrides [iViewNum]    );
+#endif
   }
 }
@@ -471,4 +496,8 @@
 {
   AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels );
+
+#if FIX_VSO_SETUP
+  m_apcRenModels[iModelNum]->setupPart( m_uiHorOff, m_iUsedHeight );
+#endif
 
   // Switch model  to original data for setup if given to render reference
@@ -476,5 +505,4 @@
   for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ )
   {
-
     Bool bSetupFromOrgVideo = m_abSetupVideoFromOrgForView[iBaseViewIdx];
     Bool bSetupFromOrgDepth = m_abSetupDepthFromOrgForView[iBaseViewIdx];
@@ -492,5 +520,9 @@
   }
 
+#if FIX_VSO_SETUP
+  m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false );
+#else
   m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false, m_uiHorOff );
+#endif
 
   // Setup to Org
@@ -513,5 +545,9 @@
 
     // setup keeping reference rendered from original data
+#if FIX_VSO_SETUP
+    m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true );
+#else
     m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true, m_uiHorOff);
+#endif
   }
 }
@@ -543,9 +579,19 @@
 
 
-Void  
+#if FIX_VSO_SETUP
+Void
+TRenModel::setupPart ( UInt uiHorOff, Int iUsedHeight )
+{
+  AOT( iUsedHeight > m_iHeight );     
+  m_uiHorOff    = uiHorOff; 
+  m_iUsedHeight = iUsedHeight; 
+}
+#else
+Void
 TRenModel::setHorOffset     ( UInt uiHorOff )
 {
-    m_uiHorOff = uiHorOff; 
-}
+  m_uiHorOff = uiHorOff; 
+}
+#endif
 
 #if LGE_VSO_EARLY_SKIP_A0093
@@ -560,5 +606,10 @@
 
   AOT( iWidth  + iStartPosX > m_iWidth  );
+#if FIX_VSO_SETUP
+  AOT( iHeight + iStartPosY > m_iUsedHeight );
+#else
   AOT( iHeight + iStartPosY > m_iHeight );
+#endif
+
   AOT( iStartPosX < 0);
   AOT( iStartPosY < 0);
@@ -593,5 +644,9 @@
 
   iWidth  = min(iWidth , m_iWidth  - iStartPosX );
+#if FIX_VSO_SETUP
+  iHeight = min(iHeight, m_iUsedHeight - iStartPosY );
+#else
   iHeight = min(iHeight, m_iHeight - iStartPosY );
+#endif
 
   AOT( iStartPosX < 0);
@@ -629,5 +684,9 @@
 TRenModel::getSynthVideo( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuv )
 {
+#if FIX_VSO_SETUP
+  m_apcRenModels[iModelNum]->getSynthVideo(iViewNum, pcPicYuv );
+#else
   m_apcRenModels[iModelNum]->getSynthVideo(iViewNum, pcPicYuv, m_uiHorOff );
+#endif
 }
 
@@ -635,5 +694,5 @@
 TRenModel::getSynthDepth( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuv )
 {
-#if HHI_VSO_SPEEDUP_A0033
+#if HHI_VSO_SPEEDUP_A0033 && !FIX_VSO_SETUP
   m_apcRenModels[iModelNum]->getSynthDepth(iViewNum, pcPicYuv, m_uiHorOff );
 #else
@@ -646,8 +705,16 @@
 {
   TComPicYuv cPicYuvSynth;
+#if FIX_VSO_SETUP
+  cPicYuvSynth.create( m_iWidth, m_iUsedHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
+#else
   cPicYuvSynth.create( m_iWidth, m_iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
+#endif
 
   TComPicYuv cPicYuvTempRef;
+#if FIX_VSO_SETUP
+  cPicYuvTempRef.create( m_iWidth, m_iUsedHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
+#else
   cPicYuvTempRef.create( m_iWidth, m_iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
+#endif
 
   Int64 iSSEY = 0;
@@ -657,4 +724,12 @@
   for (Int iCurModel = 0; iCurModel < m_iNumOfCurRenModels; iCurModel++)
   {
+#if FIX_VSO_SETUP
+    m_apcCurRenModels[iCurModel]->getSynthVideo( m_aiCurPosInModels[iCurModel], &cPicYuvSynth );    
+    m_apcCurRenModels[iCurModel]->getRefVideo  ( m_aiCurPosInModels[iCurModel], &cPicYuvTempRef   );
+
+    iSSEY += TRenFilter::SSE( cPicYuvSynth.getLumaAddr(), cPicYuvSynth.getStride(),  m_iWidth,      m_iUsedHeight     , cPicYuvTempRef.getLumaAddr(), cPicYuvTempRef.getStride() );
+    iSSEU += TRenFilter::SSE( cPicYuvSynth.getCbAddr()  , cPicYuvSynth.getCStride(), m_iWidth >> 1, m_iUsedHeight >> 1, cPicYuvTempRef.getCbAddr()  , cPicYuvTempRef.getCStride());
+    iSSEV += TRenFilter::SSE( cPicYuvSynth.getCrAddr()  , cPicYuvSynth.getCStride(), m_iWidth >> 1, m_iUsedHeight >> 1, cPicYuvTempRef.getCrAddr()  , cPicYuvTempRef.getCStride());
+#else
     m_apcCurRenModels[iCurModel]->getSynthVideo( m_aiCurPosInModels[iCurModel], &cPicYuvSynth, 0 );
     TComPicYuv* pcPicYuvRef = &cPicYuvTempRef;
@@ -664,4 +739,5 @@
     iSSEU += TRenFilter::SSE( cPicYuvSynth.getCbAddr()  , cPicYuvSynth.getCStride(), m_iWidth >> 1, m_iHeight >> 1, pcPicYuvRef->getCbAddr()  , pcPicYuvRef->getCStride());
     iSSEV += TRenFilter::SSE( cPicYuvSynth.getCrAddr()  , cPicYuvSynth.getCStride(), m_iWidth >> 1, m_iHeight >> 1, pcPicYuvRef->getCrAddr()  , pcPicYuvRef->getCStride());
+#endif
   }
 
@@ -700,3 +776,2 @@
   }
 }
-
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenModel.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenModel.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenModel.h	(revision 193)
@@ -62,8 +62,12 @@
 
   // Set horizontal offset
+#if FIX_VSO_SETUP
+  Void  setupPart        ( UInt uiHorOff, Int iUsedHeight );
+#else
   Void  setHorOffset     ( UInt uiHorOff );
+#endif
 
   // Set Mode
-  Void  setErrorMode     ( Int iView, Int iContent, int iPlane );
+  Void  setErrorMode     ( Int iView, Int iContent, Int iPlane );
 
   // Get Distortion, set Data
@@ -100,4 +104,8 @@
   Int m_iSampledWidth;
   Int m_iPad;
+#if FIX_VSO_SETUP
+  Int m_iUsedHeight;   // height currently used in buffer, whereas m_iHeight is the total height of the buffer
+#endif
+
 
   Int m_iNumOfBaseViews;
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenSingleModel.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 193)
@@ -44,4 +44,8 @@
   m_iHeight = -1;
   m_iStride = -1;
+#if FIX_VSO_SETUP
+  m_iUsedHeight = -1; 
+  m_iHorOffset  = -1; 
+#endif
   m_iMode   = -1;
   m_iPad    = PICYUV_PAD;
@@ -90,5 +94,5 @@
 {
 #ifdef LGE_VSO_EARLY_SKIP_A0093
-  if (m_pbHorSkip) 
+  if ( m_pbHorSkip ) 
   {
     delete[] m_pbHorSkip;
@@ -99,5 +103,19 @@
   if ( m_pcInputSamples [0] ) delete[] m_pcInputSamples [0];
   if ( m_pcInputSamples [1] ) delete[] m_pcInputSamples [1];
+
+#if FIX_MEM_LEAKS
+  if ( m_pcOutputSamples    ) delete[] m_pcOutputSamples   ;
+#else
   if ( m_pcOutputSamples    ) delete   m_pcOutputSamples   ;
+#endif
+
+#if FIX_MEM_LEAKS
+  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 ) );
+  if ( m_aapiRefVideoPel[1] ) delete[] ( m_aapiRefVideoPel[1] - ( m_aiRefVideoStrides[1] * m_iPad + m_iPad ) );
+  if ( m_aapiRefVideoPel[2] ) delete[] ( m_aapiRefVideoPel[2] - ( m_aiRefVideoStrides[2] * m_iPad + m_iPad ) );
+#endif
 }
 
@@ -179,5 +197,9 @@
   Int iOffsetX = ( iViewPos == VIEWPOS_RIGHT ) ? 1 : 0;
 
+#if FIX_VSO_SETUP
+  for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )
+#else
   for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
+#endif
   {
     if ( iViewPos == VIEWPOS_RIGHT )
@@ -223,7 +245,21 @@
 
 }
-
-template <BlenMod iBM, Bool bBitInc> Void
+#if FIX_VSO_SETUP
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::setupPart ( UInt uiHorOffset,       Int iUsedHeight )
+{
+  AOT( iUsedHeight > m_iHeight );   
+
+  m_iUsedHeight =       iUsedHeight; 
+  m_iHorOffset  = (Int) uiHorOffset;
+}
+#endif
+
+template <BlenMod iBM, Bool bBitInc> Void
+#if FIX_VSO_SETUP
+TRenSingleModelC<iBM,bBitInc>::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference )
+#else
 TRenSingleModelC<iBM,bBitInc>::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOff )
+#endif
 {
   AOT( !m_bUseOrgRef && pcOrgVideo );
@@ -239,7 +275,13 @@
   if ( pcOrgVideo && !bKeepReference )
   {
+#if FIX_VSO_SETUP
+    TRenFilter::copy(             pcOrgVideo->getLumaAddr() +  m_iHorOffset       * pcOrgVideo->getStride() , pcOrgVideo->getStride() , m_iWidth,      m_iUsedHeight,      m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
+    TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCbAddr()   + (m_iHorOffset >> 1) * pcOrgVideo->getCStride(), pcOrgVideo->getCStride(), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
+    TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCrAddr()   + (m_iHorOffset >> 1) * pcOrgVideo->getCStride(), pcOrgVideo->getCStride(), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);    
+#else
     TRenFilter::copy(             pcOrgVideo->getLumaAddr() +  uiHorOff       * pcOrgVideo->getStride() , pcOrgVideo->getStride() , m_iWidth,      m_iHeight,      m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
     TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCbAddr()   + (uiHorOff >> 1) * pcOrgVideo->getCStride(), pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
     TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCrAddr()   + (uiHorOff >> 1) * pcOrgVideo->getCStride(), pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);    
+#endif
     xSetStructRefView();
   }
@@ -248,5 +290,35 @@
   xResetStructError();
   xInitSampleStructs();
-
+#if FIX_VSO_SETUP
+  switch ( m_iMode )
+  {  
+  case 0:   
+#if LGE_VSO_EARLY_SKIP_A0093
+    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] );
+#endif   
+    break;
+  case 1:    
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    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] );
+#endif
+    break;
+  case 2:
+    TRenFilter::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight );
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    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);
+#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] );
+#endif
+    break;
+  default:
+    AOT(true);
+  }
+#else
   switch ( m_iMode )
   {  
@@ -278,4 +350,5 @@
     AOT(true);
   }
+#endif
 
   // Get Rendered View as Reference
@@ -340,5 +413,9 @@
 #endif  
 
+#if FIX_VSO_SETUP
+  for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )
+#else
   for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
+#endif
   {
     for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
@@ -393,5 +470,9 @@
 #endif
 
+#if FIX_VSO_SETUP
+  for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )
+#else
   for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
+#endif
   {
     for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
@@ -536,4 +617,36 @@
 }
 
+#if FIX_VSO_SETUP
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::getSynthVideo( Int iViewPos, TComPicYuv* pcPicYuv )
+{  
+  AOT( pcPicYuv->getWidth() != m_iWidth );
+  AOT( pcPicYuv->getHeight() < m_iUsedHeight + m_iHorOffset );
+
+#if HHI_VSO_COLOR_PLANES
+  Pel RenModelOutPels::* piText[3] = { NULL, NULL, NULL };
+  xGetSampleStrTextPtrs(iViewPos, piText[0], piText[1], piText[2]); 
+
+  // Temp image for chroma down sampling
+  PelImage cTempImage( m_iWidth, m_iUsedHeight, 3, 0);
+
+  Int  aiStrides[3]; 
+  Pel* apiData  [3]; 
+
+  cTempImage.getDataAndStrides( apiData, aiStrides ); 
+
+  for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ )
+  {
+    xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iUsedHeight);
+  }  
+  xCopy2PicYuv( apiData, aiStrides, pcPicYuv );
+#else
+  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( 128 << g_uiBitIncrement );   
+#endif  
+}
+#else
 template <BlenMod iBM, Bool bBitInc> Void
 TRenSingleModelC<iBM,bBitInc>::getSynthVideo( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset )
@@ -548,4 +661,5 @@
   // Temp image for chroma down sampling
   PelImage cTempImage( m_iWidth, m_iHeight, 3, 0);
+
   Int  aiStrides[3]; 
   Pel* apiData  [3]; 
@@ -557,5 +671,4 @@
     xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iHeight);
   }  
-
   xCopy2PicYuv( apiData, aiStrides, pcPicYuv, uiHorOffset );
 #else
@@ -566,11 +679,25 @@
 #endif  
 }
-
-
+#endif
+
+#if FIX_VSO_SETUP
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::getSynthDepth( Int iViewPos, TComPicYuv* pcPicYuv )
+{  
+  AOT( iViewPos != 0 && iViewPos != 1); 
+  AOT( pcPicYuv->getWidth()  != m_iWidth  );
+  AOT( pcPicYuv->getHeight() < m_iUsedHeight + m_iHorOffset );
+
+  Pel RenModelOutPels::* piD = 0;
+  xGetSampleStrDepthPtrs(iViewPos, piD); 
+  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piD, pcPicYuv->getLumaAddr() + pcPicYuv->getStride() * m_iHorOffset, pcPicYuv->getStride(), m_iWidth, m_iUsedHeight );
+  pcPicYuv->setChromaTo( 128 << g_uiBitIncrement );   
+}
+
+#else
 template <BlenMod iBM, Bool bBitInc> Void
 TRenSingleModelC<iBM,bBitInc>::getSynthDepth( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOff )
 {  
   AOT( iViewPos != 0 && iViewPos != 1); 
-
   AOT( pcPicYuv->getWidth()  != m_iWidth  );
   AOT( pcPicYuv->getHeight() > m_iHeight + uiHorOff );
@@ -581,5 +708,39 @@
   pcPicYuv->setChromaTo( 128 << g_uiBitIncrement );   
 }
-
+#endif
+
+#if FIX_VSO_SETUP
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv )
+{  
+  AOT( pcPicYuv->getWidth()  != m_iWidth  );
+  AOT( pcPicYuv->getHeight() <  m_iUsedHeight + m_iHorOffset);
+
+#if HHI_VSO_COLOR_PLANES
+  Pel RenModelOutPels::* piText[3];
+  piText[0] = &RenModelOutPels::iYRef;
+  piText[1] = &RenModelOutPels::iURef;
+  piText[2] = &RenModelOutPels::iVRef;
+
+  // Temp image for chroma down sampling
+
+  PelImage cTempImage( m_iWidth, m_iUsedHeight, 3, 0);
+  Int  aiStrides[3]; 
+  Pel* apiData  [3]; 
+
+  cTempImage.getDataAndStrides( apiData, aiStrides ); 
+
+  for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ )
+  {
+    xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iUsedHeight);
+  }  
+
+  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( 128 << g_uiBitIncrement );   
+#endif  
+}
+#else
 template <BlenMod iBM, Bool bBitInc> Void
 TRenSingleModelC<iBM,bBitInc>::getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset )
@@ -595,4 +756,5 @@
 
   // Temp image for chroma down sampling
+
   PelImage cTempImage( m_iWidth, m_iHeight, 3, 0);
   Int  aiStrides[3]; 
@@ -604,5 +766,5 @@
   {
     xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iHeight);
-  }  
+  } 
 
   xCopy2PicYuv( apiData, aiStrides, pcPicYuv, uiHorOffset );
@@ -612,5 +774,5 @@
 #endif  
 }
-
+#endif
 
 template <BlenMod iBM, Bool bBitInc> RMDist
@@ -668,5 +830,4 @@
   // Get Data
   m_ppiCurLUT      = m_appiShiftLut   [iCurViewPos];
-
   xSetViewRow      ( iStartPosY);
 
@@ -756,5 +917,5 @@
       {
           break;
-        }
+      }
 
       iCurPosX--;
@@ -802,8 +963,6 @@
   iEndChangePos = m_iStartChangePosX + iWidth - 1;
 
-
   for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
   {
-
 #ifdef LGE_VSO_EARLY_SKIP_A0093
     if( m_bEarlySkip && bFast )
@@ -1859,4 +2018,13 @@
 }
 
+#if FIX_VSO_SETUP
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget )
+{
+  TRenFilter::copy            ( ppiSrcVideoPel[0], piStrides[0], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getLumaAddr() +  m_iHorOffset       * rpcPicYuvTarget->getStride() , rpcPicYuvTarget->getStride () );
+  TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[1], piStrides[1], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getCbAddr  () + (m_iHorOffset >> 1) * rpcPicYuvTarget->getCStride(), rpcPicYuvTarget->getCStride() );
+  TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getCrAddr  () + (m_iHorOffset >> 1) * rpcPicYuvTarget->getCStride(), rpcPicYuvTarget->getCStride() );
+}
+#else
 template <BlenMod iBM, Bool bBitInc> Void
 TRenSingleModelC<iBM,bBitInc>::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget, UInt uiHorOffset )
@@ -1866,4 +2034,5 @@
   TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iHeight, rpcPicYuvTarget->getCrAddr  () + (uiHorOffset >> 1) * rpcPicYuvTarget->getCStride(), rpcPicYuvTarget->getCStride() );
 }
+#endif
 
 template class TRenSingleModelC<BLEND_NONE ,true>;
@@ -1943,3 +2112,2 @@
 }
 #endif
-
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenSingleModel.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 193)
@@ -80,5 +80,10 @@
   // Set Frame dependent data
   virtual Void   setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride ) = 0;
+#if FIX_VSO_SETUP
+  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;
+#else
   virtual Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOffset ) = 0;
+#endif
 
   // Set Data
@@ -98,7 +103,13 @@
   virtual RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) = 0;
 
+#if FIX_VSO_SETUP
+  virtual Void   getSynthVideo  ( Int iViewPos, TComPicYuv* pcPicYuv ) = 0;  
+  virtual Void   getSynthDepth  ( Int iViewPos, TComPicYuv* pcPicYuv ) = 0;
+  virtual Void   getRefVideo    ( Int iViewPos, TComPicYuv* pcPicYuv ) = 0;
+#else
   virtual Void   getSynthVideo  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  ) = 0;  
   virtual Void   getSynthDepth  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  ) = 0;
   virtual Void   getRefVideo    ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  ) = 0;
+#endif
 };
 
@@ -170,5 +181,10 @@
   // Set Frame dependent data
   Void   setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride );
+#if FIX_VSO_SETUP
+  Void   setupPart ( UInt uiHorOffset,       Int uiUsedHeight );
+  Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference );
+#else
   Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOffset );
+#endif
 
 #if LGE_VSO_EARLY_SKIP_A0093
@@ -187,7 +203,13 @@
   RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
 
+#if FIX_VSO_SETUP
+  Void   getSynthVideo  ( Int iViewPos, TComPicYuv* pcPicYuv );  
+  Void   getSynthDepth  ( Int iViewPos, TComPicYuv* pcPicYuv );
+  Void   getRefVideo    ( Int iViewPos, TComPicYuv* pcPicYuv );
+#else
   Void   getSynthVideo  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset );  
   Void   getSynthDepth  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  );
   Void   getRefVideo    ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  );
+#endif
 
 private:
@@ -198,5 +220,5 @@
   /////  Rendering /////
   // Left to Right
-#ifdef LGE_VSO_EARLY_SKIP_A0093
+#if LGE_VSO_EARLY_SKIP_A0093
                       __inline Bool   xDetectEarlySkipL   ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData,Pel* piOrgData, Int iOrgStride );
                       __inline Bool   xDetectEarlySkipR   ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData,Pel* piOrgData, Int iOrgStride );
@@ -234,5 +256,5 @@
   __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   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 );
@@ -241,9 +263,9 @@
 
   // General
-  template<Bool bSet> __inline Void xSetShiftedPelL       (Int iSourcePos,                  Int iSubSourcePos, Int iTargetSPos,                   Pel iFilled, RMDist& riError );
+  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 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 );
@@ -271,11 +293,19 @@
   Void            xInitSampleStructs           ();
   Void            xSetStructSynthViewAsRefView ();
+#if FIX_VSO_SETUP
+  Void            xCopy2PicYuv                ( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget );
+#else
   Void            xCopy2PicYuv                ( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget, UInt uiHorOffset );
-
+#endif
 
   template< typename S, typename T> 
   Void   xCopyFromSampleStruct ( S* ptSource , Int iSourceStride, T S::* ptSourceElement, T* ptTarget, Int iTargetStride, Int iWidth, Int iHeight )
   {
+#if FIX_VSO_SETUP
+    AOT( iWidth != m_iWidth ); 
+    for (Int iPosY = 0; iPosY < iHeight; iPosY++)
+#else
     for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
+#endif
     {
       for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
@@ -291,5 +321,10 @@
   Void   xCopyToSampleStruct ( T* ptSource , Int iSourceStride, S* ptTarget, Int iTargetStride, T S::* ptSourceElement, Int iWidth, Int iHeight )
   {
+#if FIX_VSO_SETUP
+    AOT( iWidth != m_iWidth ); 
+    for (Int iPosY = 0; iPosY < iHeight; iPosY++)
+#else
     for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
+#endif
     {
       for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
@@ -309,11 +344,18 @@
   Int   m_iStride;
   Int   m_iPad;
+#if FIX_VSO_SETUP
+  Int   m_iUsedHeight;
+  Int   m_iHorOffset; 
+#endif
 
   Int   m_iSampledWidth;
+#if FIX_VSO_SETUP
+#else
   Int   m_iSampledHeight;
+#endif
   Int   m_iSampledStride;
 
   RenModelInPels* m_pcInputSamples[2];
-  Int                  m_iInputSamplesStride;
+  Int             m_iInputSamplesStride;
 
   // Base
