Index: trunk/source/Lib/TAppCommon/TAppComCamPara.cpp
===================================================================
--- trunk/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 81)
+++ trunk/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 100)
@@ -654,4 +654,7 @@
 }
 
+#if SAIT_VSO_EST_A0033
+Double g_dDispCoeff;
+#endif
 
 Bool
@@ -685,4 +688,21 @@
     iTargetViewNum = (Int) uiTargetView;
   }
+
+#if SAIT_VSO_EST_A0033
+  // This part should be modified later.
+  {
+    Double dFL1, dCS1, dCP1, dZN1, dZF1; 
+    Bool   bInterpolated;
+    Double dPos[3];
+    xGetGeometryData( m_aiBaseViews[0], uiFrame, dFL1, dPos[0], dCS1, bInterpolated );
+    xGetGeometryData( m_aiBaseViews[1], uiFrame, dFL1, dPos[1], dCS1, bInterpolated );
+
+    xGetGeometryData( iSourceViewNum, uiFrame, dFL1, dCP1, dCS1, bInterpolated );
+    xGetZNearZFar   ( iSourceViewNum, uiFrame, dZN1, dZF1 );
+
+    Double dBaseLine = dPos[0] - dPos[1]; //Max(Max(dPos[0],dPos[1]),dPos[2]) - Min(Min(dPos[0],dPos[1]),dPos[2]);
+    g_dDispCoeff = fabs( dFL1 * ( dBaseLine / 2.0 ) / 255.0 * ( 1.0/dZN1 - 1.0/dZF1 ) );
+  }
+#endif
 
   xGetGeometryData( iSourceViewNum, uiFrame, dFocalLengthSource, dPositionSource, dIntersectionSource, bInterpolatedSource );
Index: trunk/source/Lib/TAppCommon/TAppComCamPara.h
===================================================================
--- trunk/source/Lib/TAppCommon/TAppComCamPara.h	(revision 81)
+++ trunk/source/Lib/TAppCommon/TAppComCamPara.h	(revision 100)
@@ -69,6 +69,6 @@
   // view lists
   std::vector<Int>    m_aiViewsInCfgFile;                     ///< views for which parameters are specified in cfg file (from left to right)
-  std::vector<Int>    m_aiSynthViews;	                        ///< View numbers of External ViewReferences
-  std::vector<Int>    m_aiRelSynthViewsNum;	              ///< Relative view numbers of External ViewReferences
+  std::vector<Int>    m_aiSynthViews;                         ///< View numbers of External ViewReferences
+  std::vector<Int>    m_aiRelSynthViewsNum;                   ///< Relative view numbers of External ViewReferences
   std::vector<Int>    m_aiBaseViews;                          ///< View numbers of Base View References (in coding order)
   std::vector<Int>    m_aiSortedBaseViews;                    ///< View numbers of Base View References (from left to right)
@@ -92,14 +92,14 @@
 
   // scale and offset parameters
-  Double***           m_adBaseViewShiftParameter;							///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1
-  Int64 ***           m_aiBaseViewShiftParameter;   					///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1 		/* do we need 64 bit? */
-  Double***           m_adSynthViewShiftParameter;					  ///< ShiftParameters between BaseViews and ERViews e.g. [2][1][0] shift scale from base view 2 to er view 1;
-  Int64 ***           m_aiSynthViewShiftParameter;			     	///< ShiftParameters between BaseViews and ERViews e.g. [2][1][0] shift scale from base view 2 to er view 1;		/* do we need 64 bit? */
+  Double***           m_adBaseViewShiftParameter;             ///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1
+  Int64 ***           m_aiBaseViewShiftParameter;             ///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1     /* do we need 64 bit? */
+  Double***           m_adSynthViewShiftParameter;            ///< ShiftParameters between BaseViews and ERViews e.g. [2][1][0] shift scale from base view 2 to er view 1;
+  Int64 ***           m_aiSynthViewShiftParameter;            ///< ShiftParameters between BaseViews and ERViews e.g. [2][1][0] shift scale from base view 2 to er view 1;    /* do we need 64 bit? */
 
   // look-up tables
-  Double****          m_adBaseViewShiftLUT;										///< Disparity LUT
-  Int****             m_aiBaseViewShiftLUT;									  ///< Disparity LUT
-  Double****          m_adSynthViewShiftLUT;									///< Disparity LUT
-  Int****             m_aiSynthViewShiftLUT;									///< Disparity LUT
+  Double****          m_adBaseViewShiftLUT;                    ///< Disparity LUT
+  Int****             m_aiBaseViewShiftLUT;                    ///< Disparity LUT
+  Double****          m_adSynthViewShiftLUT;                   ///< Disparity LUT
+  Int****             m_aiSynthViewShiftLUT;                   ///< Disparity LUT
 
 
Index: trunk/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/CommonDef.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/CommonDef.h	(revision 100)
@@ -58,5 +58,5 @@
 
 #define HM_VERSION        "6.1"
-#define NV_VERSION        "3.1rc1"                 ///< Current software version
+#define NV_VERSION        "4.0rc1"                 ///< Current software version
 
 // ====================================================================================================================
@@ -130,4 +130,5 @@
 #if ( HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED )
 #define DEPTH_MAP_GENERATION        1
+#define PDM_REMOVE_DEPENDENCE       1      //bug-fix for DMDV JCT2-A0095
 #else
 #define DEPTH_MAP_GENERATION        0
@@ -138,5 +139,5 @@
 #define PDM_NO_INTER_UPDATE               1         // no update for inter (but not inter-view) predicted blocks
 #define PDM_MERGE_POS                     0         // position of pdm in merge list (0..4)
-#if SAIT_IMPROV_MOTION_PRED_M24829
+#if SAIT_IMPROV_MOTION_PRED_M24829&!QC_MULTI_DIS_CAN
 #define PDM_AMVP_POS                      0         // position of pdm in amvp list  (0..3)
 #else
@@ -170,5 +171,5 @@
 #define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
 
-#define LOG2_DISP_PREC_LUT   				2		  		///< log2 of disparity precision used in integer disparity LUTs
+#define LOG2_DISP_PREC_LUT           2          ///< log2 of disparity precision used in integer disparity LUTs
 
 // ====================================================================================================================
@@ -400,4 +401,8 @@
 #define Clip3( MinVal, MaxVal, a)   ( ((a)<(MinVal)) ? (MinVal) : (((a)>(MaxVal)) ? (MaxVal) :(a)) )  ///< general min/max clip
 #define RemoveBitIncrement(x)       ( (x + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
+
+#if SAIT_VSO_EST_A0033
+#define ROUND(a)  (((a) < 0)? (int)((a) - 0.5) : (int)((a) + 0.5))
+#endif
 
 // ====================================================================================================================
@@ -495,5 +500,5 @@
   NAL_UNIT_UNSPECIFIED_24,
 #if VIDYO_VPS_INTEGRATION
-	NAL_UNIT_VPS,
+  NAL_UNIT_VPS,
 #else
   NAL_UNIT_UNSPECIFIED_25,
Index: trunk/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- trunk/source/Lib/TLibCommon/ContextTables.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/ContextTables.h	(revision 100)
@@ -152,4 +152,11 @@
 #endif
 
+#if LGE_EDGE_INTRA
+#define NUM_EDGE_INTRA_CTX            1
+#if LGE_EDGE_INTRA_DELTA_DC
+#define NUM_EDGE_INTRA_DELTA_DC_CTX   2 // one for Delta_DC flag, another for Delta_DC value
+#endif
+#endif
+
 // ====================================================================================================================
 // Tables
@@ -1272,9 +1279,41 @@
   }
 };
+
+#if LGE_EDGE_INTRA
+static const Short
+INIT_EDGE_INTRA[3][NUM_EDGE_INTRA_CTX] =
+{
+  {
+    CNU
+  },
+  {
+    CNU
+  },
+  {
+    CNU
+  }
+};
+
+#if LGE_EDGE_INTRA_DELTA_DC
+static const Short
+INIT_EDGE_INTRA_DELTA_DC[3][NUM_EDGE_INTRA_DELTA_DC_CTX] =
+{
+  {
+    CNU, CNU
+  },
+  {
+    CNU, CNU
+  },
+  {
+    CNU, CNU
+  }
+};
+#endif
+#endif
+
 #endif
 
 //! \}
 
-
-#endif
-
+#endif
+
Index: trunk/source/Lib/TLibCommon/NAL.h
===================================================================
--- trunk/source/Lib/TLibCommon/NAL.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/NAL.h	(revision 100)
@@ -52,5 +52,5 @@
 #endif
 #if VIDYO_VPS_INTEGRATION
-	unsigned    m_layerId;
+  unsigned    m_layerId;
   unsigned    m_temporalId;  ///< temporal_id
 #else
@@ -100,5 +100,5 @@
     m_isDepth     = isDepth;
 #else
-		m_layerId = layerId;
+    m_layerId = layerId;
 #endif
     m_temporalId  = temporalID;
@@ -124,5 +124,5 @@
     m_isDepth     = isDepth;
 #else
-		m_layerId = layerId;
+    m_layerId = layerId;
 #endif
     m_temporalId  = temporalID;
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 100)
@@ -141,4 +141,15 @@
   m_pbResPredFlag      = NULL;
 #endif
+#if LGE_EDGE_INTRA
+  m_pucEdgeCode         = NULL;
+  m_pucEdgeNumber       = NULL;
+  m_pucEdgeStartPos     = NULL;
+  m_pbEdgeLeftFirst     = NULL;
+  m_pbEdgePartition     = NULL;
+#if LGE_EDGE_INTRA_DELTA_DC
+  m_piEdgeDeltaDC0      = NULL;
+  m_piEdgeDeltaDC1      = NULL;
+#endif
+#endif
 }
 
@@ -259,4 +270,15 @@
     m_piContourPredTexDeltaDC2 = (Int* )xMalloc(Int,  uiNumPartition);
 #endif
+#if LGE_EDGE_INTRA
+    m_pucEdgeCode       = (UChar*)xMalloc(UChar, uiNumPartition * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4);
+    m_pucEdgeNumber     = (UChar*)xMalloc(UChar, uiNumPartition);
+    m_pucEdgeStartPos   = (UChar*)xMalloc(UChar, uiNumPartition);
+    m_pbEdgeLeftFirst   = (Bool*) xMalloc(Bool,  uiNumPartition);
+    m_pbEdgePartition   = (Bool*) xMalloc(Bool,  uiNumPartition * 16);
+#if LGE_EDGE_INTRA_DELTA_DC
+    m_piEdgeDeltaDC0    = (Int* ) xMalloc(Int,   uiNumPartition);
+    m_piEdgeDeltaDC1    = (Int* ) xMalloc(Int,   uiNumPartition);
+#endif
+#endif
   }
   else
@@ -359,4 +381,15 @@
     if ( m_piContourPredTexDeltaDC2 ) { xFree(m_piContourPredTexDeltaDC2); m_piContourPredTexDeltaDC2 = NULL; }
 #endif    
+#if LGE_EDGE_INTRA
+  if ( m_pbEdgeLeftFirst  ) { xFree(m_pbEdgeLeftFirst);   m_pbEdgeLeftFirst = NULL; }
+  if ( m_pucEdgeStartPos  ) { xFree(m_pucEdgeStartPos);   m_pucEdgeStartPos = NULL; }
+  if ( m_pucEdgeNumber    ) { xFree(m_pucEdgeNumber);     m_pucEdgeNumber   = NULL; }
+  if ( m_pucEdgeCode      ) { xFree(m_pucEdgeCode);       m_pucEdgeCode     = NULL; }
+  if ( m_pbEdgePartition    ) { xFree(m_pbEdgePartition); m_pbEdgePartition = NULL; }
+#if LGE_EDGE_INTRA_DELTA_DC
+  if ( m_piEdgeDeltaDC0     ) { xFree(m_piEdgeDeltaDC0);  m_piEdgeDeltaDC0  = NULL; }
+  if ( m_piEdgeDeltaDC1     ) { xFree(m_piEdgeDeltaDC1);  m_piEdgeDeltaDC1  = NULL; }
+#endif
+#endif
     m_acCUMvField[0].destroy();
     m_acCUMvField[1].destroy();
@@ -1093,4 +1126,18 @@
   m_piContourPredTexDeltaDC2 = pcCU->getContourPredTexDeltaDC2() + uiPart;   
 #endif
+#if LGE_EDGE_INTRA
+  if( pcCU->getSlice()->getSPS()->isDepth() )
+  {
+    m_pucEdgeCode         = pcCU->getEdgeCode( uiPart );
+    m_pucEdgeNumber       = pcCU->getEdgeNumber() + uiPart;
+    m_pucEdgeStartPos     = pcCU->getEdgeStartPos() + uiPart;
+    m_pbEdgeLeftFirst     = pcCU->getEdgeLeftFirst() + uiPart;
+    m_pbEdgePartition     = pcCU->getEdgePartition( uiPart );
+#if LGE_EDGE_INTRA_DELTA_DC
+    m_piEdgeDeltaDC0      = pcCU->getEdgeDeltaDC0() + uiPart;
+    m_piEdgeDeltaDC1      = pcCU->getEdgeDeltaDC1() + uiPart;
+#endif
+  }
+#endif
 }
 
@@ -1250,4 +1297,20 @@
   memcpy( m_piContourPredTexDeltaDC2 + uiOffset, pcCU->getContourPredTexDeltaDC2(), sizeof( Int  ) * uiNumPartition );
 #endif
+
+#if LGE_EDGE_INTRA
+  if( getSlice()->getSPS()->isDepth() )
+  {
+    memcpy( getEdgeCode( uiOffset ), pcCU->getEdgeCode(0), iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
+    memcpy( getEdgeNumber() + uiOffset, pcCU->getEdgeNumber(), iSizeInUchar );
+    memcpy( getEdgeStartPos() + uiOffset, pcCU->getEdgeStartPos(), iSizeInUchar );
+    memcpy( getEdgeLeftFirst() + uiOffset, pcCU->getEdgeLeftFirst(), iSizeInBool );
+    memcpy( getEdgePartition( uiOffset ), pcCU->getEdgePartition(0), iSizeInBool * 16 );
+#if LGE_EDGE_INTRA_DELTA_DC
+    memcpy( getEdgeDeltaDC0() + uiOffset, pcCU->getEdgeDeltaDC0(), sizeof( Int  ) * uiNumPartition );
+    memcpy( getEdgeDeltaDC1() + uiOffset, pcCU->getEdgeDeltaDC1(), sizeof( Int  ) * uiNumPartition );
+#endif
+  }
+#endif
+
 #if HHI_MPI
   memcpy( m_piTextureModeDepth + uiOffset, pcCU->getTextureModeDepth(), sizeof( Int ) * uiNumPartition );
@@ -1352,4 +1415,20 @@
   memcpy( rpcCU->getContourPredTexDeltaDC2() + m_uiAbsIdxInLCU, m_piContourPredTexDeltaDC2, sizeof( Int  ) * m_uiNumPartition );
 #endif
+
+#if LGE_EDGE_INTRA
+  if( rpcCU->getSlice()->getSPS()->isDepth() )
+  {
+    memcpy( rpcCU->getEdgeCode( m_uiAbsIdxInLCU ),        m_pucEdgeCode,    iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
+    memcpy( rpcCU->getEdgeNumber()    + m_uiAbsIdxInLCU,  m_pucEdgeNumber,  iSizeInUchar );
+    memcpy( rpcCU->getEdgeStartPos()  + m_uiAbsIdxInLCU,  m_pucEdgeStartPos,iSizeInUchar );
+    memcpy( rpcCU->getEdgeLeftFirst() + m_uiAbsIdxInLCU,  m_pbEdgeLeftFirst,iSizeInBool );
+    memcpy( rpcCU->getEdgePartition( m_uiAbsIdxInLCU ),   m_pbEdgePartition,iSizeInBool * 16 );
+#if LGE_EDGE_INTRA_DELTA_DC
+    memcpy( rpcCU->getEdgeDeltaDC0() + m_uiAbsIdxInLCU,   m_piEdgeDeltaDC0, sizeof( Int  ) * m_uiNumPartition );
+    memcpy( rpcCU->getEdgeDeltaDC1() + m_uiAbsIdxInLCU,   m_piEdgeDeltaDC1, sizeof( Int  ) * m_uiNumPartition );
+#endif
+  }
+#endif
+
 #if HHI_MPI
   memcpy( rpcCU->getTextureModeDepth() + m_uiAbsIdxInLCU, m_piTextureModeDepth, sizeof( Int ) * m_uiNumPartition );
@@ -1455,4 +1534,20 @@
   memcpy( rpcCU->getContourPredTexDeltaDC2() + uiPartOffset, m_piContourPredTexDeltaDC2, sizeof( Int  ) * uiQNumPart );
 #endif
+
+#if LGE_EDGE_INTRA
+  if( rpcCU->getSlice()->getSPS()->isDepth() )
+  {
+    memcpy( rpcCU->getEdgeCode( uiPartOffset ),       m_pucEdgeCode,    iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
+    memcpy( rpcCU->getEdgeNumber()    + uiPartOffset, m_pucEdgeNumber,  iSizeInUchar );
+    memcpy( rpcCU->getEdgeStartPos()  + uiPartOffset, m_pucEdgeStartPos,iSizeInUchar );
+    memcpy( rpcCU->getEdgeLeftFirst() + uiPartOffset, m_pbEdgeLeftFirst,iSizeInBool );
+    memcpy( rpcCU->getEdgePartition( uiPartOffset ),  m_pbEdgePartition,iSizeInBool * 16 );
+#if LGE_EDGE_INTRA_DELTA_DC
+    memcpy( rpcCU->getEdgeDeltaDC0() + uiPartOffset,  m_piEdgeDeltaDC0, sizeof( Int  ) * uiQNumPart  );
+    memcpy( rpcCU->getEdgeDeltaDC1() + uiPartOffset,  m_piEdgeDeltaDC1, sizeof( Int  ) * uiQNumPart  );
+#endif
+  }
+#endif
+
 #if HHI_MPI
   memcpy( rpcCU->getTextureModeDepth() + uiPartOffset, m_piTextureModeDepth, sizeof( Int ) * uiQNumPart  );
@@ -2332,4 +2427,7 @@
   mapDMMtoIntraMode( iLeftIntraDir );
 #endif
+#if LGE_EDGE_INTRA
+  mapEdgeIntratoDC( iLeftIntraDir );
+#endif
   
   // Get intra direction of above PU
@@ -2343,4 +2441,7 @@
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
   mapDMMtoIntraMode( iAboveIntraDir );
+#endif
+#if LGE_EDGE_INTRA
+  mapEdgeIntratoDC( iAboveIntraDir );
 #endif
   
@@ -2426,4 +2527,12 @@
   return uiPredNum;
 }
+
+#if LGE_EDGE_INTRA
+UInt TComDataCU::getCtxEdgeIntra( UInt uiAbsPartIdx )
+{
+  UInt        uiCtx = 0;
+  return uiCtx;
+}
+#endif
 
 UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth )
@@ -2886,47 +2995,43 @@
 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU)
 {
-	UInt uiNumPartition  = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;
-	UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0;
-
-	switch ( m_pePartSize[uiTmpAbsPartIdx] )
-	{
-	case SIZE_2NxN:
-		riWidth = getWidth(uiTmpAbsPartIdx);      riHeight = getHeight(uiTmpAbsPartIdx) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1;
-		break;
-	case SIZE_Nx2N:
-		riWidth = getWidth(uiTmpAbsPartIdx) >> 1; riHeight = getHeight(uiTmpAbsPartIdx);      ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2;
-		break;
-	case SIZE_NxN:
-		riWidth = getWidth(uiTmpAbsPartIdx) >> 1; riHeight = getHeight(uiTmpAbsPartIdx) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx;
-		break;
-	case SIZE_2NxnU:
-		riWidth     = getWidth(uiTmpAbsPartIdx);
-		riHeight    = ( uiPartIdx == 0 ) ?  getHeight(uiTmpAbsPartIdx) >> 2 : ( getHeight(uiTmpAbsPartIdx) >> 2 ) + ( getHeight(uiTmpAbsPartIdx) >> 1 );
-		ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3;
-		break;
-	case SIZE_2NxnD:
-		riWidth     = getWidth(uiTmpAbsPartIdx);
-		riHeight    = ( uiPartIdx == 0 ) ?  ( getHeight(uiTmpAbsPartIdx) >> 2 ) + ( getHeight(uiTmpAbsPartIdx) >> 1 ) : getHeight(uiTmpAbsPartIdx) >> 2;
-		ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3);
-		break;
-	case SIZE_nLx2N:
-		riWidth     = ( uiPartIdx == 0 ) ? getWidth(uiTmpAbsPartIdx) >> 2 : ( getWidth(uiTmpAbsPartIdx) >> 2 ) + ( getWidth(uiTmpAbsPartIdx) >> 1 );
-		riHeight    = getHeight(uiTmpAbsPartIdx);
-		ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4;
-		break;
-	case SIZE_nRx2N:
-		riWidth     = ( uiPartIdx == 0 ) ? ( getWidth(uiTmpAbsPartIdx) >> 2 ) + ( getWidth(uiTmpAbsPartIdx) >> 1 ) : getWidth(uiTmpAbsPartIdx) >> 2;
-		riHeight    = getHeight(uiTmpAbsPartIdx);
-		ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4);
-		break;
-	default:
-#if HHI_FIX
+  UInt uiNumPartition  = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;
+  UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0;
+
+  switch ( m_pePartSize[uiTmpAbsPartIdx] )
+  {
+  case SIZE_2NxN:
+    riWidth = getWidth(uiTmpAbsPartIdx);      riHeight = getHeight(uiTmpAbsPartIdx) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1;
+    break;
+  case SIZE_Nx2N:
+    riWidth = getWidth(uiTmpAbsPartIdx) >> 1; riHeight = getHeight(uiTmpAbsPartIdx);      ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2;
+    break;
+  case SIZE_NxN:
+    riWidth = getWidth(uiTmpAbsPartIdx) >> 1; riHeight = getHeight(uiTmpAbsPartIdx) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx;
+    break;
+  case SIZE_2NxnU:
+    riWidth     = getWidth(uiTmpAbsPartIdx);
+    riHeight    = ( uiPartIdx == 0 ) ?  getHeight(uiTmpAbsPartIdx) >> 2 : ( getHeight(uiTmpAbsPartIdx) >> 2 ) + ( getHeight(uiTmpAbsPartIdx) >> 1 );
+    ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3;
+    break;
+  case SIZE_2NxnD:
+    riWidth     = getWidth(uiTmpAbsPartIdx);
+    riHeight    = ( uiPartIdx == 0 ) ?  ( getHeight(uiTmpAbsPartIdx) >> 2 ) + ( getHeight(uiTmpAbsPartIdx) >> 1 ) : getHeight(uiTmpAbsPartIdx) >> 2;
+    ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3);
+    break;
+  case SIZE_nLx2N:
+    riWidth     = ( uiPartIdx == 0 ) ? getWidth(uiTmpAbsPartIdx) >> 2 : ( getWidth(uiTmpAbsPartIdx) >> 2 ) + ( getWidth(uiTmpAbsPartIdx) >> 1 );
+    riHeight    = getHeight(uiTmpAbsPartIdx);
+    ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4;
+    break;
+  case SIZE_nRx2N:
+    riWidth     = ( uiPartIdx == 0 ) ? ( getWidth(uiTmpAbsPartIdx) >> 2 ) + ( getWidth(uiTmpAbsPartIdx) >> 1 ) : getWidth(uiTmpAbsPartIdx) >> 2;
+    riHeight    = getHeight(uiTmpAbsPartIdx);
+    ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4);
+    break;
+  default:
     assert ( m_pePartSize[uiTmpAbsPartIdx ] == SIZE_2Nx2N ); 
-#else
-		assert ( m_pePartSize[0] == SIZE_2Nx2N );
-#endif
-		riWidth = getWidth(uiTmpAbsPartIdx);      riHeight = getHeight(uiTmpAbsPartIdx);      ruiPartAddr = 0;
-		break;
-	}
+    riWidth = getWidth(uiTmpAbsPartIdx);      riHeight = getHeight(uiTmpAbsPartIdx);      ruiPartAddr = 0;
+    break;
+  }
 }
 #else
@@ -2975,66 +3080,66 @@
 Int TComDataCU::getResiPredMode(UInt uiPartAddr)
 {
-	Int iAddResiShift = -1;
-
-	for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++)
-	{
-		RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
-		Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr);
-		if(iBestRefIdx >= 0 && getSlice()->getViewId() == getSlice()->getRefViewId(eRefList, iBestRefIdx))
-			iAddResiShift++;
-	}
-
-	return iAddResiShift;
+  Int iAddResiShift = -1;
+
+  for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++)
+  {
+    RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
+    Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr);
+    if(iBestRefIdx >= 0 && getSlice()->getViewId() == getSlice()->getRefViewId(eRefList, iBestRefIdx))
+      iAddResiShift++;
+  }
+
+  return iAddResiShift;
 }
 
 Void TComDataCU::getPUResiPredShift(Int *iPUResiPredShift, UInt uiAbsPartIndex)
 {
-	UInt uiPartSize = getPartitionSize(uiAbsPartIndex);
-	UInt uiPartAddr;
-	Int iWidth, iHeight;
-	Int iAddResiShift;
-
-	if(uiPartSize == SIZE_2Nx2N)
-	{
-		iAddResiShift = getResiPredMode(uiAbsPartIndex);
-		for(UInt i = 0; i < 4; i++)
-			iPUResiPredShift[i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiAbsPartIndex) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
-		return;
-	}
-
-	if(uiPartSize == SIZE_2NxN || uiPartSize == SIZE_2NxnU || uiPartSize == SIZE_2NxnD)
-	{
-		for(UInt i = 0; i < 2; i++)
-		{
-			getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
-			uiPartAddr += uiAbsPartIndex;
-			iAddResiShift = getResiPredMode(uiPartAddr);
-			iPUResiPredShift[2*i] = iPUResiPredShift[2*i+1] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
-		}
-		return;
-	}
-
-	if(uiPartSize == SIZE_Nx2N || uiPartSize == SIZE_nLx2N || uiPartSize == SIZE_nRx2N)
-	{
-		for(UInt i = 0; i < 2; i++)
-		{
-			getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
-			uiPartAddr += uiAbsPartIndex;
-			iAddResiShift = getResiPredMode(uiPartAddr);
-			iPUResiPredShift[i] = iPUResiPredShift[2+i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
-		}
-		return;
-	}
-
-	if(uiPartSize == SIZE_NxN)
-	{
-		for(UInt i = 0; i < 4; i++)
-		{
-			getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
-			uiPartAddr += uiAbsPartIndex;
-			iAddResiShift = getResiPredMode(uiPartAddr);
-			iPUResiPredShift[i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
-		}
-	}
+  UInt uiPartSize = getPartitionSize(uiAbsPartIndex);
+  UInt uiPartAddr;
+  Int iWidth, iHeight;
+  Int iAddResiShift;
+
+  if(uiPartSize == SIZE_2Nx2N)
+  {
+    iAddResiShift = getResiPredMode(uiAbsPartIndex);
+    for(UInt i = 0; i < 4; i++)
+      iPUResiPredShift[i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiAbsPartIndex) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
+    return;
+  }
+
+  if(uiPartSize == SIZE_2NxN || uiPartSize == SIZE_2NxnU || uiPartSize == SIZE_2NxnD)
+  {
+    for(UInt i = 0; i < 2; i++)
+    {
+      getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
+      uiPartAddr += uiAbsPartIndex;
+      iAddResiShift = getResiPredMode(uiPartAddr);
+      iPUResiPredShift[2*i] = iPUResiPredShift[2*i+1] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
+    }
+    return;
+  }
+
+  if(uiPartSize == SIZE_Nx2N || uiPartSize == SIZE_nLx2N || uiPartSize == SIZE_nRx2N)
+  {
+    for(UInt i = 0; i < 2; i++)
+    {
+      getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
+      uiPartAddr += uiAbsPartIndex;
+      iAddResiShift = getResiPredMode(uiPartAddr);
+      iPUResiPredShift[i] = iPUResiPredShift[2+i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
+    }
+    return;
+  }
+
+  if(uiPartSize == SIZE_NxN)
+  {
+    for(UInt i = 0; i < 4; i++)
+    {
+      getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
+      uiPartAddr += uiAbsPartIndex;
+      iAddResiShift = getResiPredMode(uiPartAddr);
+      iPUResiPredShift[i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
+    }
+  }
 
 }
@@ -3358,5 +3463,31 @@
   TComMv  acPdmMv       [2];
   Int     aiPdmRefIdx   [2] = {-1, -1};
+
+#if LGE_DVMCP
+  acPdmMv[0].m_bDvMcp = acPdmMv[1].m_bDvMcp = false; 
+#endif
+
+#if QC_MULTI_DIS_CAN
+  DisInfo cDisInfo;
+  cDisInfo.iN = 0;
+  if(!bNoPdmMerge)
+  {
+#if LGE_DVMCP
+    getDisMvpCand2(uiPUIdx, uiAbsPartIdx, &cDisInfo, true );
+#else
+    getDisMvpCand (uiPUIdx, uiAbsPartIdx, &cDisInfo );
+#endif
+  }
+  if(cDisInfo.iN==0)
+  {
+    cDisInfo.iN = 1;
+    cDisInfo.m_acMvCand[0].setHor(0);
+    cDisInfo.m_acMvCand[0].setVer(0);
+    cDisInfo.m_aVIdxCan[0] = 0;
+  }
+  Int     iPdmInterDir      = cDisInfo.iN==0? 0:getPdmMergeCandidateDisCan ( uiPUIdx, aiPdmRefIdx, acPdmMv, &cDisInfo  );
+#else
   Int     iPdmInterDir      = getPdmMergeCandidate( uiPUIdx, aiPdmRefIdx, acPdmMv );
+#endif
 
   if( iPdmInterDir && !bNoPdmMerge && PDM_MERGE_POS == 0 )
@@ -3413,4 +3544,8 @@
       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if LGE_DVMCP
+    pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
+    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -3485,4 +3620,8 @@
       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if LGE_DVMCP
+    pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
+    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -3552,4 +3691,8 @@
       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if LGE_DVMCP
+    pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
+    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -3616,4 +3759,8 @@
       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if LGE_DVMCP
+    pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
+    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -3689,4 +3836,8 @@
         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
       }
+#if LGE_DVMCP
+      pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
+#endif
 #if SIMP_MRG_PRUN
       if ( mrgCandIdx == iCount )
@@ -3805,4 +3956,8 @@
         puhInterDirNeighbours[uiArrayAddr] = 1;
       }
+#if LGE_DVMCP
+      pcMvFieldNeighbours[uiArrayAddr<<1    ].getMv().m_bDvMcp = false;
+      pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv().m_bDvMcp = false;
+#endif
 #if SIMP_MRG_PRUN
       if ( mrgCandIdx == iCount )
@@ -4274,4 +4429,732 @@
   return m_pcSlice->getSPS()->getAMVPMode(m_puhDepth[uiIdx]);
 }
+#if QC_MULTI_DIS_CAN
+/** construct a list of disparity motion vectors from the neighbouring PUs **/
+Void TComDataCU::getDisMvpCand ( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo )
+{
+  PartSize eCUMode = getPartitionSize( uiPartAddr );
+  TComDataCU* pcTmpCU = NULL;
+  pDInfo->iN = 0;
+
+  RefPicList eRefPicList = REF_PIC_LIST_0 ;
+  //-- Get Spatial MV
+  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
+  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
+
+  deriveLeftRightTopIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
+  deriveLeftBottomIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLB );
+
+  UInt uiIdx = 0;
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+    pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
+#else
+    pcTmpCU = getPULeft(uiIdx, uiPartIdxLB);
+#endif
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
+  {
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+           clipMv(cMvPred);
+           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+           return;
+        }
+      }
+    }
+  }
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+      pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
+#else
+    pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT);
+#endif
+
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
+  {
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+           clipMv(cMvPred);
+           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+           return;
+        }
+      }
+    }
+  }
+
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+      pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true);
+#else
+      pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, true, true);
+#endif
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
+  {
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+           clipMv(cMvPred);
+           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+           return;
+        }
+      }
+    }
+  }
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+      pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false);
+#else
+      pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB);
+#endif
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
+  {
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+           clipMv(cMvPred);
+           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+           return;
+        }
+      }
+    }
+  }
+
+  // Above predictor search
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+      pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true, false, true);
+    assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
+#else
+      pcTmpCU = getPUAboveLeft(uiIdx, uiPartIdxLT, true, true, true);
+#endif
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
+  {
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+           clipMv(cMvPred);
+           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+           return;
+        }
+      }
+    }
+  }
+  //Get temporal MV
+  TComMv cColMv;
+  Int iTargetViewIdx = 0;
+  Int iTStartViewIdx = 0;
+  UInt uiPartIdxRB, uiBRIdx;
+  Int uiViewIdxCurr= getSlice()->getViewId();
+
+  UInt uiAbsPartAddr;
+  int uiLCUIdx = getAddr();
+  Int uiLCUnew = uiLCUIdx;
+  eCUMode = getPartitionSize( 0 );
+  deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB );  
+  uiBRIdx = uiPartIdxLT;
+  UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
+  if ( (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) &&(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ))  // image boundary check
+  {
+    if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU 
+      ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
+    {
+      uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
+    }
+    else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
+    {
+      uiBRIdx = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
+      uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU();
+    }
+    else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
+    {
+      uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
+      uiLCUnew = uiLCUIdx + 1;
+    }
+    else //is the right bottom corner of LCU                       
+    {
+      uiBRIdx = 0;
+      uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU() + 1;
+    }
+  }
+
+  Int MaxRef = getSlice()->getNumRefIdx(RefPicList(0));
+  UInt uiNumPartInCUHeight = m_pcPic->getNumPartInHeight();
+  UInt uiPUVert = (UInt)((Int)g_auiZscanToRaster[uiPartIdxLB]/(Int)(uiNumPartInCUWidth)-(Int)g_auiZscanToRaster[uiPartIdxLT]/(Int)(uiNumPartInCUWidth));
+  UInt uiPUHorStart  = g_auiZscanToRaster[uiPartIdxLT];
+  UInt uiPUHorEnd    = g_auiZscanToRaster[uiPartIdxRT];
+  for( Int i= 0; i< getSlice()->getNumRefIdx(RefPicList(0)); i ++)
+  {
+    getSlice()->getRefPic( RefPicList(0), i)->setCandPicCheckedFlag(0);
+  }
+  for( Int i= 0; i< getSlice()->getNumRefIdx(RefPicList(1)); i ++)
+  {
+    getSlice()->getRefPic( RefPicList(1), i)->setCandPicCheckedFlag(0);
+  }
+  {
+    //check the col-located picture
+    eRefPicList = RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0);
+#if COLLOCATED_REF_IDX
+    Int lpRef = getSlice()->getColRefIdx();
+#else
+    Int lpRef = 0;
+#endif
+    if( m_pcSlice->getViewId() == getSlice()->getRefPic( eRefPicList, lpRef)->getViewId() ) 
+    {
+      if (uiViewIdxCurr > 1)  
+      {
+        if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
+        {
+          clipMv(cColMv);
+          pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+          pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+          return ;
+        }
+      }
+      for(UInt uiLoopVert = 0; uiLoopVert <= uiPUVert; uiLoopVert+=4)
+        for( uiIdx = uiPUHorStart; uiIdx <= uiPUHorEnd; uiIdx +=4 )
+        {
+          uiAbsPartAddr = g_auiRasterToZscan[uiIdx+uiNumPartInCUWidth*uiLoopVert];
+          if ( uiLCUIdx >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetViewIdx, iTStartViewIdx ) ) 
+          {
+            clipMv(cColMv);
+            pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+            pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+            return ;
+          }
+        }
+        for(UInt uiIdx_y = 0; uiIdx_y <uiNumPartInCUHeight; uiIdx_y +=4 )
+          for(UInt uiIdx_X = 0; uiIdx_X <uiNumPartInCUWidth; uiIdx_X +=4 )
+          {
+            uiIdx = uiIdx_X + uiIdx_y * uiNumPartInCUWidth;
+            uiAbsPartAddr = g_auiRasterToZscan[uiIdx];
+            if ( uiLCUIdx >= 0 && xGetColDisMV( eRefPicList,  lpRef, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetViewIdx, iTStartViewIdx ) ) 
+            {
+              clipMv(cColMv);
+              pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+              pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+              return ;
+            }
+          }
+          if (uiViewIdxCurr == 1)  
+          {
+            if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) ) 
+            {
+              clipMv(cColMv);
+              pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+              pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+              return ;
+            }
+          }
+    }
+    getSlice()->getRefPic( eRefPicList, lpRef)->setCandPicCheckedFlag(1);
+  }
+  {
+    //check the remaining reference pictures in list0 and list1
+    if(getSlice()->isInterB())
+    {
+      if(getSlice()->getNumRefIdx(RefPicList(0))< getSlice()->getNumRefIdx(RefPicList(1)))
+        MaxRef = getSlice()->getNumRefIdx(RefPicList(1));
+    }
+    for(Int lpRef = 0; lpRef < MaxRef; lpRef++)
+    {
+      for(Int lpNr = 0; lpNr < (getSlice()->isInterB() ? 2: 1); lpNr ++)
+      {
+        eRefPicList = RefPicList(0);
+        if(getSlice()->isInterB())
+          eRefPicList = RefPicList(lpNr==0 ? (getSlice()->getColDir()): (1-getSlice()->getColDir()));
+        if(getSlice()->getRefPic( eRefPicList, lpRef)->getCandPicCheckedFlag())
+          continue;
+        
+        if(lpRef >= getSlice()->getNumRefIdx(eRefPicList)||(m_pcSlice->getViewId() != getSlice()->getRefPic( eRefPicList, lpRef)->getViewId()))
+          continue;
+        if (uiViewIdxCurr > 1 ) 
+        {
+          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
+          {
+          clipMv(cColMv);
+          pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+          pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+          return ;
+          }
+        }
+        for(UInt uiLoopVert = 0; uiLoopVert <= uiPUVert; uiLoopVert += 4)
+          for( uiIdx = uiPUHorStart; uiIdx <= uiPUHorEnd; uiIdx += 4 )
+          {
+            uiAbsPartAddr = g_auiRasterToZscan[uiIdx+uiNumPartInCUWidth*uiLoopVert];
+            if ( uiLCUIdx >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetViewIdx, iTStartViewIdx ) ) 
+            {
+              clipMv(cColMv);
+              pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+              pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+              return ;
+            }
+          }
+        for(UInt uiIdx_y = 0; uiIdx_y <uiNumPartInCUHeight; uiIdx_y += 4 )
+          for(UInt uiIdx_X = 0; uiIdx_X <uiNumPartInCUWidth; uiIdx_X += 4 )
+          {
+            uiIdx = uiIdx_X + uiIdx_y * uiNumPartInCUWidth;
+            uiAbsPartAddr = g_auiRasterToZscan[uiIdx];
+            if ( uiLCUIdx >= 0 && xGetColDisMV( eRefPicList,  lpRef, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetViewIdx, iTStartViewIdx ) ) 
+            {
+              clipMv(cColMv);
+              pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+              pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+              return ;
+            }
+          }
+        if (uiViewIdxCurr == 1 ) 
+        {
+          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
+          {
+            clipMv(cColMv);
+            pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+            pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+            return ;
+          }
+        }
+        getSlice()->getRefPic( eRefPicList, lpRef)->setCandPicCheckedFlag(1);
+      }//reference lists
+    }//reference indices
+  }//remaining pictures
+}
+
+#if LGE_DVMCP
+Void TComDataCU::getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo, Bool bMerge, RefPicList eRefPicList0, Int iRefIdx0 )
+{
+  PartSize eCUMode = getPartitionSize( uiPartAddr );
+  TComDataCU* pcTmpCU = NULL;
+  TComDataCU* pcCULeft = NULL;
+  pDInfo->iN = 0;
+
+  RefPicList eRefPicList = REF_PIC_LIST_0 ;
+  //-- Get Spatial MV
+  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
+  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
+
+  Int   aiDvMcpDvCand[2][7] = {{0,},    {0,}}; // dummy, 5 spatial + 1 temporal, DV-MCP ÁÖº¯ ºí·°¿¡¼­ »ç¿ëµÈ DV¸¦ ÀúÀå
+  Bool  abDvMcpFlag  [2][7] = {{false,},{false,}}; 
+  //Int   aiRefPOC     [2][7] = {{-1,},{-1}}; // debug
+  TComMv cTmpMvPred, cMv;
+  Bool  bTmpIsSkipped = false;
+  Bool  bDvMcpIsFound = false;
+
+  deriveLeftRightTopIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
+  deriveLeftBottomIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLB );
+
+  UInt uiIdx = 0;
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+  pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
+#else
+  pcTmpCU = getPULeft(uiIdx, uiPartIdxLB);
+#endif
+
+  pcCULeft = pcTmpCU;
+  UInt uiLeftPartIdx = uiIdx;
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
+  {
+    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId()) // DCP
+        {
+          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          clipMv(cMvPred);
+          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+          return;
+        }
+        else // MCP 
+        {
+          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
+          {
+            aiDvMcpDvCand[iList][DVFROM_LEFT] = cTmpMvPred.m_iDvMcpDispX;
+            abDvMcpFlag  [iList][DVFROM_LEFT] = true; 
+            bDvMcpIsFound = true;
+          }
+        }
+      }
+    }
+  }
+
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+  pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
+#else
+  pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT);
+#endif
+
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
+  {
+    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          clipMv(cMvPred);
+          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+          return;
+        }
+        else // MCP 
+        {
+          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          if( cTmpMvPred.m_bDvMcp  && bTmpIsSkipped )
+          {
+            aiDvMcpDvCand[iList][DVFROM_ABOVE] = cTmpMvPred.m_iDvMcpDispX;
+            abDvMcpFlag  [iList][DVFROM_ABOVE] = true; 
+            bDvMcpIsFound = true;
+          }
+        }
+      }
+    }
+  }
+
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+  pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true);
+#else
+  pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, true, true);
+#endif
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
+  {
+    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          clipMv(cMvPred);
+          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+          return;
+        }
+        else  // MCP 
+        {
+          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
+          {
+            aiDvMcpDvCand[iList][DVFROM_ABOVERIGHT] = cTmpMvPred.m_iDvMcpDispX;
+            abDvMcpFlag  [iList][DVFROM_ABOVERIGHT] = true; 
+            bDvMcpIsFound = true;
+          }
+        }
+      }
+    }
+  }
+
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+  pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false);
+#else
+  pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB);
+#endif
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
+  {
+    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          clipMv(cMvPred);
+          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+          return;
+        }
+        else // MCP 
+        {
+          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
+          {
+            aiDvMcpDvCand[iList][DVFROM_LEFTBELOW] = cTmpMvPred.m_iDvMcpDispX;
+            abDvMcpFlag  [iList][DVFROM_LEFTBELOW] = true; 
+            bDvMcpIsFound = true;
+          }
+        }
+      }
+    }
+  }
+
+  // Above predictor search
+#if MVP_AT_ENTROPYSLICE_BOUNDARY
+  pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true, false, true);
+  assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
+#else
+  pcTmpCU = getPUAboveLeft(uiIdx, uiPartIdxLT, true, true, true);
+#endif
+  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
+  {
+    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      eRefPicList = RefPicList(iList);
+      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+        if (refViewIdx!= m_pcSlice->getViewId())
+        {
+          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          clipMv(cMvPred);
+          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
+          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
+          return;
+        }
+        else // MCP 
+        {
+          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
+          {
+            aiDvMcpDvCand[iList][DVFROM_ABOVELEFT] = cTmpMvPred.m_iDvMcpDispX;
+            abDvMcpFlag  [iList][DVFROM_ABOVELEFT] = true; 
+            bDvMcpIsFound = true;
+          }
+        }
+      }
+    }
+  }
+
+  // copied from getInterMergeCand()
+  if ( getSlice()->getPPS()->getEnableTMVPFlag() )
+  {
+    UInt uiPUIdx = uiPartIdx;
+    UInt uiAbsPartAddr = uiPartAddr;
+
+    // col [2]
+    Int iRefIdxSkip[2] = {-1, -1};
+    if( !bMerge )
+    {
+      iRefIdxSkip[ eRefPicList0 ] = iRefIdx0;
+    }
+    else
+    {
+      for (Int i=0; i<2; i++)
+      {
+        RefPicList  eRefPicList1 = ( i==1 ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
+#if SET_MERGE_TMVP_REFIDX
+        Int iRefIdxTmp;
+        if ( uiPUIdx != 0 )
+        {
+          iRefIdxTmp = 0;
+        }
+        else
+        {    
+          iRefIdxTmp = (pcCULeft != NULL) ? pcCULeft->getCUMvField(eRefPicList1)->getRefIdx(uiLeftPartIdx) : -1;
+        }
+#else      
+        Int iRefIdxTmp = (pcCULeft != NULL) ? pcCULeft->getCUMvField(eRefPicList1)->getRefIdx(uiLeftPartIdx) : -1;
+#endif
+        iRefIdxSkip[i] = (iRefIdxTmp != -1) ? iRefIdxTmp : 0;
+      }
+    }
+
+    //>> MTK colocated-RightBottom
+    UInt uiPartIdxRB;
+    Int uiLCUIdx = getAddr();
+    eCUMode = getPartitionSize( 0 );
+
+    deriveRightBottomIdx( eCUMode, uiPUIdx, uiPartIdxRB );  
+
+    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
+    //UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
+
+    TComMv cColMv;
+    Int iRefIdx;
+
+    if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
+    {
+      uiLCUIdx = -1;
+    }
+    else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
+    {
+      uiLCUIdx = -1;
+    }
+    else
+    {
+      if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU 
+        ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
+        uiLCUIdx = getAddr();
+      }
+      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
+        uiLCUIdx = -1 ; 
+      }
+      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
+        uiLCUIdx = getAddr() + 1;
+      }
+      else //is the right bottom corner of LCU                       
+      {
+        uiAbsPartAddr = 0;
+        uiLCUIdx = -1 ; 
+      }
+    }
+
+    Bool bExistMV = false;
+    UInt uiPartIdxCenter;
+    UInt uiCurLCUIdx = getAddr();
+    xDeriveCenterIdx( eCUMode, uiPUIdx, uiPartIdxCenter );
+
+    Int iTargetView, iStartView; 
+    if( !bMerge ) // AMVP
+    {
+      bExistMV = uiLCUIdx >= 0 && xGetColDisMV( eRefPicList0, iRefIdx0, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView );
+      if( bExistMV == false )
+      {
+        bExistMV = xGetColDisMV( eRefPicList0, iRefIdx0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iTargetView, iStartView );
+      }
+      if( bExistMV ) // DV is found
+      {
+        if( cColMv.m_bDvMcp == false ) //=> DCP, if true => DV-MCP
+        {
+          clipMv(cColMv);
+          pDInfo->m_acMvCand[ pDInfo->iN] = cColMv; 
+          pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView;
+          return;
+        }
+        else // DV-MCP
+        {
+          aiDvMcpDvCand[eRefPicList0][DVFROM_COL] = cColMv.getHor(); 
+          abDvMcpFlag  [eRefPicList0][DVFROM_COL] = true; 
+          bDvMcpIsFound = true;
+        }
+      }
+    }
+    else // MERGE
+    {
+      iRefIdx = iRefIdxSkip[0];
+      bExistMV = uiLCUIdx >= 0 && xGetColDisMV( REF_PIC_LIST_0, iRefIdx, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView );
+      if( bExistMV == false )
+      {
+        bExistMV = xGetColDisMV( REF_PIC_LIST_0, iRefIdx, uiCurLCUIdx, uiPartIdxCenter,  cColMv, iTargetView, iStartView );
+      }
+      if( bExistMV )
+      {
+        if( cColMv.m_bDvMcp == false ) // DCP
+        {
+          clipMv(cColMv);
+          pDInfo->m_acMvCand[ pDInfo->iN] = cColMv; 
+          pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView;
+          return;
+        }
+        else { // // DV-MCP
+          aiDvMcpDvCand[0][DVFROM_COL] = cColMv.getHor(); 
+          abDvMcpFlag  [0][DVFROM_COL] = true; 
+          bDvMcpIsFound = true;
+        }; 
+
+        if ( getSlice()->isInterB() )
+        {       
+          iRefIdx = iRefIdxSkip[1];
+          bExistMV = uiLCUIdx >= 0 && xGetColDisMV( REF_PIC_LIST_1, iRefIdx, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView );
+          if( bExistMV == false )
+          {
+            bExistMV = xGetColDisMV( REF_PIC_LIST_1, iRefIdx, uiCurLCUIdx, uiPartIdxCenter,  cColMv, iTargetView, iStartView );
+          }
+          if( bExistMV )
+          {
+            if( cColMv.m_bDvMcp == false ) // DCP
+            {
+              clipMv(cColMv);
+              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv; 
+              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView;
+              return;
+            }
+            else // DV-MCP
+            {
+              aiDvMcpDvCand[1][DVFROM_COL] = cColMv.getHor(); 
+              abDvMcpFlag  [1][DVFROM_COL] = true; 
+              bDvMcpIsFound = true;
+            }; 
+          }
+        }
+      }
+    }
+  } // if TMVP Flag
+
+  if( bDvMcpIsFound ) // skip dvmcp
+  {
+    for( Int i=1 ; i<7 ; i++ ) // 5 spatial + 1 temporal
+    {
+      for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+      {
+        if( abDvMcpFlag[iList][i]==true )
+        {
+          TComMv dv( aiDvMcpDvCand[iList][ i ], 0 );
+          clipMv( dv );
+          pDInfo->m_acMvCand[ pDInfo->iN  ] = dv;
+          pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; 
+          return;
+        }
+
+      }
+    }
+  }
+
+  return;
+
+}
+#endif
+
+#endif
 
 /** Constructs a list of candidates for AMVP
@@ -4295,9 +5178,32 @@
   }
   
+#if QC_MULTI_DIS_CAN
+  DisInfo cDisInfo;
+  cDisInfo.iN = 0;
+  if(m_pcSlice->getSPS()->getViewId() && m_pcSlice->getSPS()->getMultiviewMvPredMode())
+  {
+#if LGE_DVMCP
+    getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false, eRefPicList, iRefIdx );
+#else
+    getDisMvpCand (uiPartIdx, uiPartAddr, &cDisInfo );
+#endif
+  }
+  if(cDisInfo.iN==0)
+  {
+    cDisInfo.iN = 1;
+    cDisInfo.m_acMvCand[0].setHor(0);
+    cDisInfo.m_acMvCand[0].setVer(0);
+    cDisInfo.m_aVIdxCan[0] = 0;
+  }
+#endif 
 #if HHI_INTER_VIEW_MOTION_PRED
 #if ( PDM_AMVP_POS == 0 )
   // get inter-view mv predictor (at position 0)
   TComMv  cPdmMvPred;
+#if QC_MULTI_DIS_CAN
+  if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
+#else
   if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
+#endif
   {
     clipMv( cPdmMvPred );
@@ -4354,5 +5260,9 @@
   // get inter-view mv predictor (at position 1)
   TComMv  cPdmMvPred;
+#if QC_MULTI_DIS_CAN
+  if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
+#else
   if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
+#endif
   {
     clipMv( cPdmMvPred );
@@ -4402,5 +5312,9 @@
   // get inter-view mv predictor (at position 2)
   TComMv  cPdmMvPred;
+#if QC_MULTI_DIS_CAN
+  if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
+#else
   if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
+#endif
   {
     clipMv( cPdmMvPred );
@@ -4418,4 +5332,27 @@
     }
   }
+#if  QC_MULTI_DIS_CAN
+  if ( getSlice()->getViewId()!=0 && pInfo->iN == 3 )
+  {
+    if ( pInfo->m_acMvCand[ 1 ] == pInfo->m_acMvCand[ 2 ] )
+    {
+      pInfo->iN = 2;
+      if( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] )
+        pInfo->iN = 1;
+    }
+    else
+    {
+      if( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] )
+      {
+        pInfo->m_acMvCand[1 ] = pInfo->m_acMvCand[ 2 ];
+        pInfo->iN = 2;
+      }
+      else if (pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 2 ])
+      {
+         pInfo->iN = 2;
+      }
+    }
+  }
+#endif
 #endif
 
@@ -4488,5 +5425,9 @@
   // get inter-view mv predictor (at position 3)
   TComMv  cPdmMvPred;
+#if QC_MULTI_DIS_CAN
+  if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
+#else
   if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
+#endif
   {
     clipMv( cPdmMvPred );
@@ -4674,5 +5615,7 @@
   {
     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-    
+#if LGE_DVMCP
+    cMvPred.m_bDvMcp = false;
+#endif 
     pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
     return true;
@@ -4709,4 +5652,7 @@
     {
       TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
+#if LGE_DVMCP
+      cMvPred.m_bDvMcp = false;
+#endif
       pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
       return true;
@@ -4840,5 +5786,4 @@
   Int iNeibRefPOC;
 
-#if HHI_FIX
   if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 )
   {
@@ -4849,5 +5794,7 @@
     {
       TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
-
+#if LGE_DVMCP
+      cMvPred.m_bDvMcp = false;
+#endif
       clipMv(cMvPred);
       pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
@@ -4855,5 +5802,5 @@
     }
   }
-#endif
+
   //---------------  V1 (END) ------------------//
   if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0)
@@ -4877,4 +5824,7 @@
       rcMv = cMvPred.scaleMv( iScale );
     }
+#if LGE_DVMCP
+    rcMv.m_bDvMcp = false;
+#endif
     pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
     return true;
@@ -4901,4 +5851,7 @@
       rcMv = cMvPred.scaleMv( iScale );
     }
+#if LGE_DVMCP
+    rcMv.m_bDvMcp = false;
+#endif
     pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
     return true;
@@ -4908,4 +5861,95 @@
 }
 
+#if QC_MULTI_DIS_CAN
+Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx )
+{
+#if LGE_DVMCP
+  Int  iDvMcpDispX[2] = {-1,};
+  Bool bDvMcpFlag [2] = { false, }; 
+  Int iCurrViewIdx = m_pcSlice->getViewId();
+#endif
+
+  UInt uiAbsPartAddr = uiPartUnitIdx;
+
+  RefPicList  eColRefPicList = REF_PIC_LIST_0;
+  Int iColViewIdx, iColRefViewIdx;
+  TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
+  TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
+  iColViewIdx = pColCU->getSlice()->getViewId();
+
+
+  if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiAbsPartAddr))
+  {
+    return false;
+  }
+#if LGE_DVMCP
+  Bool bColIsSkipped = pColCU->isSkipped( uiAbsPartAddr );
+#endif
+  for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++) 
+  {
+    if(pColCU->getSlice()->isInterB())
+    {
+      if(ilist == 0 )
+        eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(1-getSlice()->getColDir());
+      else
+        eColRefPicList = getSlice()->getCheckLDC() ? (eRefPicList== REF_PIC_LIST_0? REF_PIC_LIST_1:REF_PIC_LIST_0 ): RefPicList(getSlice()->getColDir());
+    }
+
+    Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr);
+
+    if (iColRefIdx < 0)
+    {
+      continue;
+    }
+
+    iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewId();
+
+    if ( iColViewIdx    == iColRefViewIdx ) // temporal vector
+    {
+#if LGE_DVMCP
+      if( iColViewIdx >0 )
+      {
+        TComMv tmpMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
+        if( tmpMv.m_bDvMcp && bColIsSkipped ) // DV-MCP SKIP
+        {
+          iDvMcpDispX[ilist] = tmpMv.m_iDvMcpDispX; 
+          bDvMcpFlag [ilist] = true; 
+          iTargetViewIdx  = 0; //iColRefViewIdx ;
+          iStartViewIdx   = 0; //iCurrViewIdx; //iColViewIdx   ;
+        }
+      }
+#endif
+      continue;
+    }
+    else 
+    {
+      rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
+#if LGE_DVMCP
+      rcMv.m_bDvMcp = false;
+#endif
+      iTargetViewIdx  = iColRefViewIdx ;
+      iStartViewIdx   = iColViewIdx   ;
+      return true;    
+    }
+  }
+
+#if LGE_DVMCP
+  for( Int ilist=0 ; ilist<2 ; ilist++ )
+  {
+    if( bDvMcpFlag[ilist] )
+    {
+      rcMv.setHor( iDvMcpDispX[ilist] ); 
+      rcMv.setVer( 0 );
+      rcMv.m_bDvMcp = true;
+      iTargetViewIdx  = 0; //iColRefViewIdx ;
+      iStartViewIdx   = iCurrViewIdx; //iColViewIdx   ;
+      return true;
+    }
+  }
+#endif
+
+  return false;
+}
+#endif 
 /** 
  * \param eRefPicList
@@ -4984,9 +6028,5 @@
   iColRefViewOrderIdx = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewOrderIdx();
 #else
-#if HHI_FIX
   if( pColCU->getSlice()->getRefViewId( eColRefPicList, iColRefIdx ) != pColCU->getSlice()->getViewId() )
-#else
-  if( pColCU->getSlice()->getRefViewId( eColRefPicList, iColRefIdx ) != m_pcSlice->getRefPic( eRefPicList, riRefIdx )->getViewId() )
-#endif
   {
     return false;
@@ -5004,8 +6044,7 @@
   else if((iColPOC == iColRefPOC)&&(iCurrPOC == iCurrRefPOC))
     iScale = xGetDistScaleFactor(iCurrViewOrderIdx, iCurrRefViewOrderIdx, iColViewOrderIdx, iColRefViewOrderIdx);
-#if HHI_FIX //GT: fix reported by Sony
   else
     return false; 
-#endif
+
 #else
   iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC);
@@ -5951,4 +6990,5 @@
 // -------------------------------------------------------------------------------------------------------------------
 #if HHI_INTER_VIEW_MOTION_PRED
+#if !QC_MULTI_DIS_CAN
 Int
 TComDataCU::getPdmMergeCandidate( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv )
@@ -5967,4 +7007,22 @@
   return pcDepthMapGenerator->getPdmMvPred( this, uiPartIdx, eRefPicList, iRefIdx, rcMv, bMerge );
 }
+#else
+Int
+TComDataCU::getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo )
+{
+  TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator();
+  ROFRS( pcDepthMapGenerator, 0 );
+  return pcDepthMapGenerator->getPdmMergeCandidate( this, uiPartIdx, paiPdmRefIdx, pacPdmMv, pDInfo );
+}
+Bool
+TComDataCU::getPdmMvPredDisCan( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge )
+{
+  TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator();
+  ROFRS( pcDepthMapGenerator, false );
+  if (pDInfo->iN > 0 && pcDepthMapGenerator->getDisCanPdmMvPred(this, uiPartIdx, eRefPicList, iRefIdx, rcMv, pDInfo, bMerge )) //bug fix li
+    return true;
+  return false;
+}
+#endif
 
 
@@ -5988,4 +7046,30 @@
   TComResidualGenerator*  pcResidualGenerator = m_pcSlice->getSPS()->getResidualGenerator();
   ROFRS( pcResidualGenerator, false );
+#if QC_MULTI_DIS_CAN
+  DisInfo cDisInfo;
+  cDisInfo.iN = 0;
+  PartSize m_peSaved =  getPartitionSize( 0 );
+  m_pePartSize[0] =  SIZE_2Nx2N;
+#if LGE_DVMCP
+  getDisMvpCand2( 0, 0,  &cDisInfo, true );
+#else
+  getDisMvpCand        ( 0, 0,  &cDisInfo );
+#endif
+  if( cDisInfo.iN == 0)
+  {
+    m_pePartSize[0] = m_peSaved;
+    return false;
+  }
+  else
+  {
+    Bool bAvailable = pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv, cDisInfo.m_acMvCand[0].getHor() 
+#if QC_SIMPLIFIEDIVRP_M24938
+      , bRecon 
+#endif
+      );
+    m_pePartSize[0] = m_peSaved;
+    return bAvailable;
+  }
+#else
   return pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv 
 #if QC_SIMPLIFIEDIVRP_M24938
@@ -5993,5 +7077,629 @@
 #endif
     );
-}
+#endif
+}
+#endif
+
+#if LGE_EDGE_INTRA
+Void TComDataCU::reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion )
+{
+  Int iWidth;
+  Int iHeight;
+  if( uiDepth == 0 )
+  {
+    iWidth = 64;
+    iHeight = 64;
+  }
+  else if( uiDepth == 1 )
+  {
+    iWidth = 32;
+    iHeight = 32;
+  }
+  else if( uiDepth == 2 )
+  {
+    iWidth = 16;
+    iHeight = 16;
+  }
+  else if( uiDepth == 3 )
+  {
+    iWidth = 8;
+    iHeight = 8;
+  }
+  else // uiDepth == 4
+  {
+    iWidth = 4;
+    iHeight = 4;
+  }
+
+  Int iPtr = 0;
+  Int iX, iY;
+  Int iDir = -1;
+  Int iDiffX = 0, iDiffY = 0;
+
+  // 1. Edge Code -> Vert & Horz Edges
+  Bool*  pbEdge = (Bool*) xMalloc( Bool, 4 * iWidth * iHeight );
+
+  for( UInt ui = 0; ui < 4 * iWidth * iHeight; ui++ )
+    pbEdge  [ ui ] = false;
+
+  // Direction : left(0), right(1), top(2), bottom(3), left-top(4), right-top(5), left-bottom(6), right-bottom(7)
+  // Code      : 0deg(0), 45deg(1), -45deg(2), 90deg(3), -90deg(4), 135deg(5), -135deg(6)
+  const UChar tableDir[8][7] = { { 0, 6, 4, 3, 2, 7, 5 },
+  { 1, 5, 7, 2, 3, 4, 6 },
+  { 2, 4, 5, 0, 1, 6, 7 },
+  { 3, 7, 6, 1, 0, 5, 4 },
+  { 4, 0, 2, 6, 5, 3, 1 },
+  { 5, 2, 1, 4, 7, 0, 3 },
+  { 6, 3, 0, 7, 4, 1, 2 },
+  { 7, 1, 3, 5, 6, 2, 0 }};
+
+  UChar ucCode = pucEdgeCode[iPtr++];
+
+  if( !bLeft )
+  {
+    iX = ucStartPos;
+    iY = 0;
+
+    switch(ucCode)
+    {
+    case 0: // bottom
+      iDir = 3;
+      if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+      break;
+    case 2: // left-bottom
+      iDir = 6;
+      if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+      break;
+    case 1: // right-bottom
+      iDir = 7;
+      if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+      break;
+    case 4: // left
+      iDir = 0;
+      assert(false);
+      break;
+    case 3: // right
+      iDir = 1;
+      if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+      break;
+    }
+  }
+  else
+  {
+    iX = 0;
+    iY = ucStartPos;
+
+    switch(ucCode)
+    {
+    case 0: // right
+      iDir = 1;
+      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+      break;
+    case 1: // right-top
+      iDir = 5;
+      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+      if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+      break;
+    case 2: // right-bottom
+      iDir = 7;
+      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+      break;
+    case 3: // top
+      iDir = 2;
+      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+      if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+      break;
+    case 4: // bottom
+      iDir = 3;
+      assert(false);
+      break;
+    }
+  }
+
+  switch( iDir )
+  {
+  case 0: // left
+    iDiffX = -1;
+    iDiffY = 0;
+    break;
+  case 1: // right
+    iDiffX = +1;
+    iDiffY = 0;
+    break;
+  case 2: // top
+    iDiffX = 0;
+    iDiffY = -1;
+    break;
+  case 3: // bottom
+    iDiffX = 0;
+    iDiffY = +1;
+    break;
+  case 4: // left-top
+    iDiffX = -1;
+    iDiffY = -1;
+    break;
+  case 5: // right-top
+    iDiffX = +1;
+    iDiffY = -1;
+    break;
+  case 6: // left-bottom
+    iDiffX = -1;
+    iDiffY = +1;
+    break;
+  case 7: // right-bottom
+    iDiffX = +1;
+    iDiffY = +1;
+    break;
+  }
+
+  iX += iDiffX;
+  iY += iDiffY;
+
+  while( iPtr < ucNumEdge )
+  {
+    ucCode = pucEdgeCode[iPtr++];
+
+    Int iNewDir = tableDir[iDir][ucCode];
+
+    switch( iNewDir )
+    {
+    case 0: // left
+      iDiffX = -1;
+      iDiffY = 0;
+      break;
+    case 1: // right
+      iDiffX = +1;
+      iDiffY = 0;
+      break;
+    case 2: // top
+      iDiffX = 0;
+      iDiffY = -1;
+      break;
+    case 3: // bottom
+      iDiffX = 0;
+      iDiffY = +1;
+      break;
+    case 4: // left-top
+      iDiffX = -1;
+      iDiffY = -1;
+      break;
+    case 5: // right-top
+      iDiffX = +1;
+      iDiffY = -1;
+      break;
+    case 6: // left-bottom
+      iDiffX = -1;
+      iDiffY = +1;
+      break;
+    case 7: // right-bottom
+      iDiffX = +1;
+      iDiffY = +1;
+      break;
+    }
+
+    switch( iDir )
+    {
+    case 0: // left
+      switch( ucCode )
+      {
+      case 0:
+      case 2:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        break;
+      case 1:
+      case 3:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 4:
+      case 6:
+        // no
+        break;
+      case 5:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      }
+      break;
+    case 1: // right
+      switch( ucCode )
+      {
+      case 0:
+      case 2:
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        break;
+      case 1:
+      case 3:
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 4:
+      case 6:
+        // no
+        break;
+      case 5:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      }
+      break;
+    case 2: // top
+      switch( ucCode )
+      {
+      case 0:
+      case 2:
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 1:
+      case 3:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 4:
+      case 6:
+        // no
+        break;
+      case 5:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      }
+      break;
+    case 3: // bottom
+      switch( ucCode )
+      {
+      case 0:
+      case 2:
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 1:
+      case 3:
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        break;
+      case 4:
+      case 6:
+        // no
+        break;
+      case 5:
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        break;
+      }
+      break;
+    case 4: // left-top
+      switch( ucCode )
+      {
+      case 0:
+      case 1:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 2:
+      case 4:
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 3:
+      case 5:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 6:
+        // no
+        break;
+      }
+      break;
+    case 5: // right-top
+      switch( ucCode )
+      {
+      case 0:
+      case 1:
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 2:
+      case 4:
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        break;
+      case 3:
+      case 5:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 6:
+        // no
+        break;
+      }
+      break;
+    case 6: // left-bottom
+      switch( ucCode )
+      {
+      case 0:
+      case 1:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 2:
+      case 4:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        break;
+      case 3:
+      case 5:
+        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        break;
+      case 6:
+        // no
+        break;
+      }
+      break;
+    case 7: // right-bottom
+      switch( ucCode )
+      {
+      case 0:
+      case 1:
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 2:
+      case 4:
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        break;
+      case 3:
+      case 5:
+        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
+        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
+        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
+        break;
+      case 6:
+        // no
+        break;
+      }
+      break;
+    }
+
+    assert( iX >= 0 && iX <= iWidth );
+    assert( iY >= 0 && iY <= iHeight );
+
+    iX += iDiffX;
+    iY += iDiffY;
+    iDir = iNewDir;
+  }
+
+  // finalize edge chain
+  if( iX == iWidth-1 )
+  {
+    if( iY == 0 )
+    {
+      if( iDir == 1 )
+      {
+        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
+      }
+      else if( iDir == 5 )
+      {
+        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
+      }
+      else
+      {
+        assert(false);
+      }
+    }
+    else if( iY == iHeight-1 )
+    {
+      if( iDir == 3 )
+      {
+        pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
+      }
+      else if( iDir == 7 )
+      {
+        pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
+      }
+      else
+      {
+        assert(false);
+      }
+    }
+    else
+    {
+      if( iDir == 1 )
+      {
+        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
+      }
+      else if( iDir == 3 )
+      {
+        pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
+        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
+      }
+      else if( iDir == 5 )
+      {
+        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
+      }
+      else if( iDir == 7 )
+      {
+        pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
+        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
+      }
+      else
+      {
+        assert(false);
+      }
+    }
+  }
+  else if( iX == 0 )
+  {
+    if( iY == 0 )
+    {
+      if( iDir == 2 )
+      {
+        pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
+      }
+      else if( iDir == 4 )
+      {
+        pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
+      }
+      else
+      {
+        assert(false);
+      }
+    }
+    else if( iY == iHeight-1 )
+    {
+      if( iDir == 0 )
+      {
+        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
+      }
+      else if( iDir == 6 )
+      {
+        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
+      }
+      else
+      {
+        assert(false);
+      }
+    }
+    else
+    {
+      if( iDir == 0 )
+      {
+        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
+      }
+      else if( iDir == 2 )
+      {
+        pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
+        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
+      }
+      else if( iDir == 4 )
+      {
+        pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
+        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
+      }
+      else if( iDir == 6 )
+      {
+        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
+      }
+      else
+      {
+        assert(false);
+      }
+    }
+  }
+  else if( iY == 0 )
+  {
+    if( iDir == 1 )
+    {
+      pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
+      pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
+    }
+    else if( iDir == 2 )
+    {
+      pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
+    }
+    else if( iDir == 4 )
+    {
+      pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
+    }
+    else if( iDir == 5 )
+    {
+      pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
+      pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
+    }
+    else
+    {
+      assert(false);
+    }
+  }
+  else if( iY == iHeight-1 )
+  {
+    if( iDir == 0 )
+    {
+      pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
+      pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
+    }
+    else if( iDir == 3 )
+    {
+      pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
+    }
+    else if( iDir == 6 )
+    {
+      pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
+      pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
+    }
+    else if( iDir == 7 )
+    {
+      pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
+    }
+    else
+    {
+      assert(false);
+    }
+  }
+  else
+  {
+    printf("xPredIntraEdge: wrong termination\n");
+    assert(false);
+  }
+
+  // Reconstruct Region from Chain Code
+  Bool* pbVisit  = (Bool*) xMalloc( Bool, iWidth * iHeight );
+  Int*  piStack  = (Int* ) xMalloc( Int,  iWidth * iHeight );
+
+  for( UInt ui = 0; ui < iWidth * iHeight; ui++ )
+  {
+    pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next)
+    pbVisit [ ui ] = false;
+  }
+
+  iPtr = 0;
+  piStack[iPtr++] = (0 << 8) | (0);
+  pbRegion[ 0 ] = false;
+
+  while(iPtr > 0)
+  {
+    Int iTmp = piStack[--iPtr];
+    Int iX1, iY1;
+    iX1 = iTmp & 0xff;
+    iY1 = (iTmp >> 8) & 0xff;
+
+    pbVisit[ iX1 + iY1 * iWidth ] = true;
+
+    assert( iX1 >= 0 && iX1 < iWidth );
+    assert( iY1 >= 0 && iY1 < iHeight );
+
+    if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] )
+    {
+      piStack[iPtr++] = (iY1 << 8) | (iX1 - 1);
+      pbRegion[ iX1 - 1 + iY1 * iWidth ] = false;
+    }
+    if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] )
+    {
+      piStack[iPtr++] = (iY1 << 8) | (iX1 + 1);
+      pbRegion[ iX1 + 1 + iY1 * iWidth ] = false;
+    }
+    if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] )
+    {
+      piStack[iPtr++] = ((iY1 - 1) << 8) | iX1;
+      pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false;
+    }
+    if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] )
+    {
+      piStack[iPtr++] = ((iY1 + 1) << 8) | iX1;
+      pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false;
+    }
+  }
+
+  xFree( pbEdge );
+  xFree( pbVisit );
+  xFree( piStack );
+}
+
 #endif
 
Index: trunk/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 100)
@@ -214,4 +214,16 @@
 #endif
 
+#if LGE_EDGE_INTRA
+  UChar*        m_pucEdgeCode;          ///< array of edge code
+  UChar*        m_pucEdgeNumber;        ///< total number of edge
+  UChar*        m_pucEdgeStartPos;      ///< starting point position
+  Bool*         m_pbEdgeLeftFirst;      ///< true if edge should be checked in left boundary first
+  Bool*         m_pbEdgePartition;      ///< true if it belongs to region 1, otherwise, region 0
+#if LGE_EDGE_INTRA_DELTA_DC
+  Int*          m_piEdgeDeltaDC0;
+  Int*          m_piEdgeDeltaDC1;
+#endif
+#endif
+
   // -------------------------------------------------------------------------------------------------------------------
   // misc. variables
@@ -256,4 +268,7 @@
   Void          deriveRightBottomIdx        ( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxRB );
   Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx );
+#if QC_MULTI_DIS_CAN
+  Bool          xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
+#endif 
   
 #if !AMVP_PRUNING_SIMPLIFICATION
@@ -503,6 +518,16 @@
 
 #if HHI_INTER_VIEW_MOTION_PRED
+#if !QC_MULTI_DIS_CAN
   Int           getPdmMergeCandidate( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv );
   Bool          getPdmMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge = false );
+#else
+  Bool          getPdmMvPredDisCan( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge = false );
+  Int           getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo );
+  Void          getDisMvpCand        ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo );
+#if LGE_DVMCP
+  Void          getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo, Bool bMerge=false, RefPicList eRefPicList=REF_PIC_LIST_X, Int iRefIdx=-1 );
+#endif
+
+#endif
   Bool          getIViewOrgDepthMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv );
 #endif
@@ -659,4 +684,9 @@
   UInt          getEntropySliceStartCU  ( UInt pos )                  { return m_uiEntropySliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
   UInt&         getTotalBins            ()                            { return m_uiTotalBins;                                                                                                  }
+
+#if LGE_EDGE_INTRA
+  UInt          getCtxEdgeIntra ( UInt uiAbsPartIdx );
+#endif
+
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for RD cost storage
@@ -734,4 +764,28 @@
   Void  setContourPredTexDeltaDC2SubParts ( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
+
+#if LGE_EDGE_INTRA
+  UChar*        getEdgeCode( UInt uiIdx )                 { return &m_pucEdgeCode[uiIdx * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4]; }
+  UChar*        getEdgeNumber( )                          { return m_pucEdgeNumber;           }
+  UChar         getEdgeNumber( UInt uiIdx )               { return m_pucEdgeNumber[uiIdx];    }
+  Void          setEdgeNumber( UInt uiIdx, UChar val )    { m_pucEdgeNumber[uiIdx] = val;     }
+  UChar*        getEdgeStartPos( )                        { return m_pucEdgeStartPos;         }
+  UChar         getEdgeStartPos( UInt uiIdx )             { return m_pucEdgeStartPos[uiIdx];  }
+  Void          setEdgeStartPos( UInt uiIdx, UChar val )  { m_pucEdgeStartPos[uiIdx] = val;   }
+  Bool*         getEdgeLeftFirst( )                       { return m_pbEdgeLeftFirst;         }
+  Bool          getEdgeLeftFirst( UInt uiIdx )            { return m_pbEdgeLeftFirst[uiIdx];  }
+  Void          setEdgeLeftFirst( UInt uiIdx, Bool val )  { m_pbEdgeLeftFirst[uiIdx] = val;   }
+  Bool*         getEdgePartition( UInt uiIdx )              { return &m_pbEdgePartition[uiIdx * 16]; }
+  Void          reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion );
+
+#if LGE_EDGE_INTRA_DELTA_DC
+  Int*          getEdgeDeltaDC0( )                          { return m_piEdgeDeltaDC0; }
+  Int*          getEdgeDeltaDC1( )                          { return m_piEdgeDeltaDC1; }
+  Int           getEdgeDeltaDC0( UInt uiIdx )               { return m_piEdgeDeltaDC0[uiIdx]; }
+  Int           getEdgeDeltaDC1( UInt uiIdx )               { return m_piEdgeDeltaDC1[uiIdx]; }
+  Void          setEdgeDeltaDC0( UInt uiIdx, Int val )      { m_piEdgeDeltaDC0[uiIdx] = val;  }
+  Void          setEdgeDeltaDC1( UInt uiIdx, Int val )      { m_piEdgeDeltaDC1[uiIdx] = val;  }
+#endif
+#endif
 };
 
Index: trunk/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 100)
@@ -78,4 +78,5 @@
   m_uiSubSampExpX       = uiSubSampExpX;
   m_uiSubSampExpY       = uiSubSampExpY;
+#if !QC_MULTI_DIS_CAN
   m_ppcYuv              = new TComYuv*    [ m_uiMaxDepth ];
   m_ppcCU               = new TComDataCU* [ m_uiMaxDepth ];
@@ -91,4 +92,5 @@
   m_cTmpPic.create( uiPicWidth >> m_uiSubSampExpX, uiPicHeight >> m_uiSubSampExpY, uiMaxCUWidth >> m_uiSubSampExpX, uiMaxCUHeight >> m_uiSubSampExpY, uiMaxCUDepth );
   xSetChroma( &m_cTmpPic, ( 1 << uiOrgBitDepth ) >> 1 );
+#endif
   m_bCreated    = true;
 }
@@ -100,4 +102,5 @@
   {
     m_bCreated    = false;
+#if !QC_MULTI_DIS_CAN
     for( UInt uiDepth = 0; uiDepth < m_uiMaxDepth; uiDepth++ )
     {
@@ -114,4 +117,5 @@
     delete [] m_ppcCU;  m_ppcCU  = 0;
     m_cTmpPic.destroy();
+#endif
     m_uiMaxDepth          = 0;
     m_uiOrgDepthBitDepth  = 0;
@@ -163,5 +167,7 @@
   m_bPDMAvailable = false;
   m_uiCurrViewId  = pcPic->getSPS()->getViewId();
-
+#if PDM_REMOVE_DEPENDENCE
+  pcPic->setStoredPDMforV2(0);
+#endif
   // update SPS list and AU pic list and set depth map generator in SPS
 #if VIDYO_VPS_INTEGRATION
@@ -218,6 +224,10 @@
   if( m_uiCurrViewId )
   {
+#if PDM_REMOVE_DEPENDENCE
+    UInt      uiBaseVId   = m_auiBaseIdList[0];
+#else
     Bool      bCheckVId1  = ( m_uiCurrViewId > 1 && m_auiBaseIdList[0] == 0 );
     UInt      uiBaseVId   = ( bCheckVId1 ? 1 : m_auiBaseIdList[0] );
+#endif
     TComPic*  pcBasePic   = m_pcAUPicAccess->getPic( uiBaseVId );
     SliceType eSliceType  = pcBasePic->getCurrSlice()->getSliceType();
@@ -367,5 +377,5 @@
 }
 
-
+#if !QC_MULTI_DIS_CAN
 Bool
 TComDepthMapGenerator::predictDepthMap( TComPic* pcPic )
@@ -398,4 +408,7 @@
         pcBasePic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_pcSPSAccess->getPdm()), PDM_SUB_SAMP_EXP_Y(m_pcSPSAccess->getPdm()) );
         xClearDepthMap( pcBasePic );
+#if PDM_REMOVE_DEPENDENCE
+        xClearDepthMap( pcBasePic, PDM_UNDEFINED_DEPTH, 1 );
+#endif
       }
 #if PDM_OUTPUT_PRED_DEPTH_MAP
@@ -442,4 +455,7 @@
   {
     xClearDepthMap( pcPic );
+#if PDM_REMOVE_DEPENDENCE
+    xClearDepthMap( pcPic, PDM_UNDEFINED_DEPTH, 1 );
+#endif
   }
   return bUndefined;
@@ -463,4 +479,14 @@
 
   // predict depth map using current coding symbols
+#if PDM_REMOVE_DEPENDENCE
+  pcPic->setStoredPDMforV2(0);
+  xPredictDepthMap( pcPic );
+  if(m_uiCurrViewId==0)
+  {
+    pcPic->setStoredPDMforV2(1);
+    xPredictDepthMap( pcPic );
+    pcPic->setStoredPDMforV2(0);
+  }
+#else
   xPredictDepthMap( pcPic );
 #if PDM_OUTPUT_PRED_DEPTH_MAP
@@ -469,4 +495,5 @@
     dumpDepthMap( pcPic, acFilenameBase );
   }
+#endif
 #endif
 
@@ -481,4 +508,15 @@
 #endif
   }
+#if PDM_REMOVE_DEPENDENCE
+  if( m_uiCurrViewId == 2 )
+  {
+    TComPic* pcBasePic = m_pcAUPicAccess->getPic( 0 );
+    AOF( pcBasePic );
+    xConvertDepthMapCurr2Ref( pcBasePic, pcPic );
+#if PDM_OUTPUT_PRED_DEPTH_MAP
+    dumpDepthMap( pcBasePic, acFilenameBase );
+#endif
+  }
+#endif
 }
 
@@ -501,4 +539,8 @@
   Int         iSrcStride  = pcPicYuv->getStride   ();
   Int         iDstStride  = m_cTmpPic.getStride   ();
+#if PDM_REMOVE_DEPENDENCE
+  if(pcPic->getStoredPDMforV2())
+     pcPicYuv    = pcPic->getPredDepthMapTemp();
+#endif
   Pel*        pSrcSamples = pcPicYuv->getLumaAddr ( 0 );
   Pel*        pDstSamples = m_cTmpPic.getLumaAddr ( 0 );
@@ -520,5 +562,5 @@
   m_cTmpPic.dump( acFilename, ( pcPic->getPOC() != 0 )  );
 }
-
+#endif
 
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -563,7 +605,155 @@
 
 #if HHI_INTER_VIEW_MOTION_PRED
+#if QC_MULTI_DIS_CAN
+Int
+TComDepthMapGenerator::getPdmMergeCandidate( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo )
+#else
 Int
 TComDepthMapGenerator::getPdmMergeCandidate( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv )
-{
+#endif 
+{
+#if MTK_INTERVIEW_MERGE_A0049
+  AOF  ( m_bCreated && m_bInit );
+
+#if !QC_MULTI_DIS_CAN
+  ROFRS( m_bPDMAvailable, 0 );
+#endif
+
+  TComSlice*    pcSlice     = pcCU->getSlice ();
+  TComSPS*      pcSPS       = pcSlice->getSPS();
+  AOF  ( pcSPS->getViewId() == m_uiCurrViewId );
+  Bool          bPdmMerge   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE );
+  ROTRS( !bPdmMerge, 0 );
+
+  Bool abPdmAvailable[2] = {false,false};
+
+  Int iValid = 0;
+  Int iViewId = 0;
+  for( UInt uiBId = 0; uiBId < m_uiCurrViewId && iValid==0; uiBId++ )
+  {
+    UInt        uiBaseId    = m_auiBaseIdList[ uiBId ];
+    TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( uiBaseId );
+    for( Int iRefListId = 0; iRefListId < 2 && iValid==0; iRefListId++ )
+    {
+      RefPicList  eRefPicListTest = RefPicList( iRefListId );
+      Int         iNumRefPics = pcSlice->getNumRefIdx( eRefPicListTest ) ;
+      for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ )
+      { 
+        if(pcBasePic->getPOC() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getPOC() 
+          && pcBasePic->getViewId() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getViewId())
+        {
+          iValid=1;
+          iViewId = uiBaseId;
+          break;
+        }
+      }
+    }
+  }
+  if (iValid == 0)
+    return 0;
+
+  //--- get base CU/PU and check prediction mode ---
+  TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( iViewId );
+  TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
+
+#if QC_MULTI_DIS_CAN
+  Int  iCurrPosX, iCurrPosY;
+  UInt          uiPartAddr;
+  Int           iWidth;
+  Int           iHeight;
+
+  pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
+  pcBaseRec->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
+  iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
+  iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
+
+  Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (pDInfo->m_acMvCand[0].getHor() + 2 ) >> 2 ) );
+  Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (pDInfo->m_acMvCand[0].getVer() + 2 ) >> 2 )); 
+  Int         iBaseCUAddr;
+  Int         iBaseAbsPartIdx;
+  pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
+#else
+  Int  iPrdDepth, iCurrPosX, iCurrPosY;
+  Bool bAvailable  = xGetPredDepth( pcCU, uiPartIdx, iPrdDepth, &iCurrPosX, &iCurrPosY );
+  AOF( bAvailable );
+  TComPicYuv* pcBasePdm   = pcBasePic->getPredDepthMap();
+  Int         iDisparity  = xGetDisparityFromVirtDepth( iViewId, iPrdDepth );
+  Int         iShiftX     = m_uiSubSampExpX + 2;
+  Int         iAddX       = ( 1 << iShiftX ) >> 1;
+  Int         iBasePosX   = Clip3( 0, pcBasePdm->getWidth () - 1, iCurrPosX + ( ( iDisparity + iAddX ) >> iShiftX ) );
+  Int         iBasePosY   = Clip3( 0, pcBasePdm->getHeight() - 1, iCurrPosY                               );
+  Int         iBaseCUAddr;
+  Int         iBaseAbsPartIdx;
+  pcBaseRec->getCUAddrAndPartIdx( iBasePosX<< m_uiSubSampExpX , iBasePosY<< m_uiSubSampExpY , iBaseCUAddr, iBaseAbsPartIdx );
+#endif 
+
+  TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+
+  if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTER || pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_SKIP )
+  {
+    for( UInt uiBaseRefListId = 0; uiBaseRefListId < 2; uiBaseRefListId++ )
+    {
+      RefPicList  eBaseRefPicList = RefPicList( uiBaseRefListId );
+      TComMvField cBaseMvField;
+      pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
+      Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
+
+      if (iBaseRefIdx >= 0)
+      {
+        Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
+        if (iBaseRefPOC != pcSlice->getPOC())    
+        {
+          for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eBaseRefPicList ); iPdmRefIdx++)
+          {
+            if (iBaseRefPOC == pcSlice->getRefPOC(eBaseRefPicList, iPdmRefIdx))
+            {
+              abPdmAvailable[ uiBaseRefListId ] = true;
+              paiPdmRefIdx  [ uiBaseRefListId ] = iPdmRefIdx;
+              TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
+#if LGE_DVMCP
+              cMv.m_bDvMcp = true;
+              cMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor();
+#endif
+              pcCU->clipMv( cMv );
+              pacPdmMv      [ uiBaseRefListId ] = cMv;
+              break;
+            }
+          }
+        }
+      }
+    }
+  }
+  Int iPdmInterDir = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 );
+
+  if (iPdmInterDir == 0)
+  {
+    for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
+    {
+      RefPicList  eRefPicList       = RefPicList( iRefListId );
+      Int         iNumRefPics       = pcSlice->getNumRefIdx( eRefPicList );
+      for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
+{
+        if( pcSlice->getRefPOC( eRefPicList, iPdmRefIdx ) == pcSlice->getPOC())
+        {
+          abPdmAvailable[ iRefListId ] = true;
+          paiPdmRefIdx  [ iRefListId ] = iPdmRefIdx;
+#if QC_MULTI_DIS_CAN
+          TComMv cMv = pDInfo->m_acMvCand[0]; 
+          cMv.setVer(0);
+#else
+          TComMv cMv(iDisparity, 0);
+#endif
+          pcCU->clipMv( cMv );
+          pacPdmMv      [ iRefListId ] = cMv;
+          break;
+        }
+      }
+    }
+    iPdmInterDir = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 ) ;
+  }
+
+  return iPdmInterDir;
+
+#else
   Int  iMaxNumInterPics  = 1;
   Int  iMaxNumAllPics    = 2;
@@ -580,5 +770,9 @@
       if( pcCU->getSlice()->getRefPOC( eRefPicList, iPdmRefIdx ) != pcCU->getSlice()->getPOC() )
       {
+#if QC_MULTI_DIS_CAN
+        if( getDisCanPdmMvPred (pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, pDInfo, true ) )       
+#else 
         if( getPdmMvPred( pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, true ) )
+#endif
         {
           pcCU->clipMv( cMv );
@@ -602,5 +796,9 @@
       for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
       {
+#if QC_MULTI_DIS_CAN
+        if ( getDisCanPdmMvPred (pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, pDInfo, true ) ) 
+#else 
         if( getPdmMvPred( pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, true ) )
+#endif
         {
           pcCU->clipMv( cMv );
@@ -615,7 +813,97 @@
   }
   return iPdmInterDir;
-}
-
-
+#endif
+}
+
+#if QC_MULTI_DIS_CAN
+Bool
+TComDepthMapGenerator::getDisCanPdmMvPred    ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge )
+{
+#if LGE_DVMCP
+  rcMv.m_bDvMcp = false;
+#endif
+  AOF  ( m_bCreated && m_bInit );
+  AOF  ( iRefIdx >= 0 );
+  AOF  ( pcCU );
+  //ROFRS( m_bPDMAvailable, false );
+  TComSlice*    pcSlice     = pcCU->getSlice ();
+  TComSPS*      pcSPS       = pcSlice->getSPS();
+  AOF  ( pcSPS->getViewId() == m_uiCurrViewId );
+  TComPic*      pcRefPic    = pcSlice->getRefPic( eRefPicList, iRefIdx );
+  UInt          uiRefViewId = pcRefPic->getSPS()->getViewId();
+  Int           iRefPoc     = pcRefPic->getPOC();
+  Bool          bInterview  = ( uiRefViewId < m_uiCurrViewId );
+  AOT(  bInterview && iRefPoc != pcSlice->getPOC() );
+  AOT( !bInterview && iRefPoc == pcSlice->getPOC() );
+  Bool          bPdmIView   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_IVIEW ) == PDM_USE_FOR_IVIEW );
+  Bool          bPdmInter   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_INTER ) == PDM_USE_FOR_INTER );
+  Bool          bPdmMerge   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE );
+  ROTRS( ( bInterview && !bMerge ) && !bPdmIView, false );
+  ROTRS( (!bInterview && !bMerge ) && !bPdmInter, false );
+  ROTRS(                  bMerge   && !bPdmMerge, false );
+  Int  iCurrPosX, iCurrPosY;
+  TComMv cDisMv;
+
+  if( bInterview )
+  {
+    rcMv = pDInfo->m_acMvCand[0]; 
+    rcMv.setVer(0);
+    return      true;
+  }
+  for( UInt uiBId = 0; uiBId < m_uiCurrViewId; uiBId++ )
+  {
+    UInt        uiBaseId    = uiBId;  //m_auiBaseIdList[ uiBId ];
+
+    if (m_uiCurrViewId >1 && uiBaseId ==1 ) 
+      continue;
+
+    TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( uiBaseId );
+    TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
+    UInt          uiPartAddr;
+    Int           iWidth;
+    Int           iHeight;
+
+    pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
+    pcBaseRec->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
+    iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
+    iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
+    Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (pDInfo->m_acMvCand[0].getHor() + 2 ) >> 2 ) );
+    Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (pDInfo->m_acMvCand[0].getVer() + 2 ) >> 2 ));  
+    Int         iBaseCUAddr;
+    Int         iBaseAbsPartIdx;
+    pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
+    TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+    if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_INTER && pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_SKIP )
+    {
+      continue;
+    }
+    for( UInt uiBaseRefListId = 0; uiBaseRefListId < 2; uiBaseRefListId++ )
+    {
+      RefPicList  eBaseRefPicList = RefPicList( uiBaseRefListId );
+      TComMvField cBaseMvField;
+      pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
+      Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
+      Int         iBaseRefPoc     = ( iBaseRefIdx >= 0 ? pcBaseCU->getSlice()->getRefPic( eBaseRefPicList, iBaseRefIdx )->getPOC() : -(1<<30) );
+      if( iBaseRefIdx >= 0 && iBaseRefPoc == iRefPoc )
+      {
+        rcMv.set( cBaseMvField.getHor(), cBaseMvField.getVer() );
+#if LGE_DVMCP
+        // save disparity vector when a merge candidate for IVMP is set as DV-MCP
+        if( bMerge ) 
+        {
+          rcMv.m_bDvMcp = true;
+          rcMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor(); 
+        }
+        else { // AMVP ?
+          rcMv.m_bDvMcp = false;
+        }
+#endif
+        return true;
+      }
+    }
+  }
+  return false;
+}
+#else
 Bool  
 TComDepthMapGenerator::getPdmMvPred( TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge )
@@ -664,4 +952,8 @@
     //--- get base CU/PU and check prediction mode ---
     UInt        uiBaseId    = m_auiBaseIdList[ uiBId ];
+#if PDM_REMOVE_DEPENDENCE
+    if( uiBaseId != 0)
+      continue;
+#endif
     TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( uiBaseId );
     TComPicYuv* pcBasePdm   = pcBasePic->getPredDepthMap();
@@ -697,4 +989,5 @@
   return false;
 }
+#endif
 
 
@@ -744,5 +1037,5 @@
 
 
-
+#if !QC_MULTI_DIS_CAN
 /*=======================================================*
  *=====                                             =====*
@@ -760,6 +1053,12 @@
   AOF( pcRef->getPredDepthMap()->getWidth () == pcCur->getPredDepthMap()->getWidth () );
   AOF( pcRef->getPredDepthMap()->getHeight() == pcCur->getPredDepthMap()->getHeight() );
-
+#if PDM_REMOVE_DEPENDENCE
+  if( pcCur->getViewId() == 1)
+    xClearDepthMap( pcRef );
+  else if (pcCur->getViewId() == 2)
+    xClearDepthMap( pcRef, PDM_UNDEFINED_DEPTH, 1 );
+#else
   xClearDepthMap( pcRef );
+#endif
   TComPicYuv* pcCurDepthMap =  pcCur->getPredDepthMap    ();
   TComPicYuv* pcRefDepthMap =  pcRef->getPredDepthMap    ();
@@ -771,4 +1070,11 @@
   Pel*        pRefSamples   =  pcRefDepthMap->getLumaAddr( 0 );
   Int         iRefViewIdx   =  pcRef->getViewId();
+#if PDM_REMOVE_DEPENDENCE
+  if( pcCur->getViewId() == 2)
+  {
+    pcRefDepthMap =  pcRef->getPredDepthMapTemp();
+    pRefSamples   =  pcRefDepthMap->getLumaAddr( 0 );
+  }
+#endif 
   Int         iShiftX       = m_uiSubSampExpX + 2;
   Int         iAddX         = ( 1 << iShiftX ) >> 1;
@@ -799,5 +1105,15 @@
   AOF( pcCur->getSPS()->getViewId()  > pcRef->getSPS()->getViewId() );
   AOF( pcCur->getPredDepthMap() );
+#if PDM_REMOVE_DEPENDENCE
+  if(pcCur->getViewId() == 1)
+  {
+    AOF( pcRef->getPredDepthMap() );
+  }else
+  {
+    AOF( pcRef->getPredDepthMapTemp() );
+  }
+#else
   AOF( pcRef->getPredDepthMap() );
+#endif
   AOF( pcRef->getPredDepthMap()->getWidth () == pcCur->getPredDepthMap()->getWidth () );
   AOF( pcRef->getPredDepthMap()->getHeight() == pcCur->getPredDepthMap()->getHeight() );
@@ -805,4 +1121,8 @@
   xClearDepthMap( pcCur );
   TComPicYuv* pcRefDepthMap =  pcRef->getPredDepthMap    ();
+#if PDM_REMOVE_DEPENDENCE
+  if(pcCur->getViewId() == 2)
+    pcRefDepthMap =  pcRef->getPredDepthMapTemp        ();
+#endif
   TComPicYuv* pcCurDepthMap =  pcCur->getPredDepthMap    ();
   Int         iWidth        =  pcRefDepthMap->getWidth   ();
@@ -844,6 +1164,15 @@
   }
   Bool    bUndefined = xFillDepthMapHoles( pcPic );
+#if PDM_REMOVE_DEPENDENCE
+  if(pcPic->getStoredPDMforV2() == 1){
+  pcPic->getPredDepthMapTemp()->setBorderExtension( false );
+  pcPic->getPredDepthMapTemp()->extendPicBorder   ();
+  }else{
+#endif
   pcPic->getPredDepthMap()->setBorderExtension( false );
   pcPic->getPredDepthMap()->extendPicBorder   ();
+#if PDM_REMOVE_DEPENDENCE
+  }
+#endif
   return  bUndefined;
 }
@@ -855,4 +1184,8 @@
   Bool        bUndefined  = false;      
   TComPicYuv* pcDepthMap  = pcPic->getPredDepthMap  ();
+#if PDM_REMOVE_DEPENDENCE
+  if(pcPic->getViewId()==0 && pcPic->getStoredPDMforV2()==1)
+    pcDepthMap  = pcPic->getPredDepthMapTemp  ();
+#endif
   Int         iWidth      = pcDepthMap->getWidth    ();
   Int         iHeight     = pcDepthMap->getHeight   ();
@@ -888,5 +1221,5 @@
         {
           bUndefined = true;
-		  break;
+          break;
         }
         iX = iE - 1;
@@ -913,5 +1246,10 @@
 
 Void
-TComDepthMapGenerator::xClearDepthMap( TComPic* pcPic, Int iVal )
+TComDepthMapGenerator::xClearDepthMap( TComPic* pcPic, Int iVal 
+#if PDM_REMOVE_DEPENDENCE
+,
+Int forFirstNonBaseView
+#endif
+)
 {
   TComPicYuv* pcDepthMap  = pcPic->getPredDepthMap  ();
@@ -920,4 +1258,11 @@
   Int         iStride     = pcDepthMap->getStride   ();
   Pel*        pDMSamples  = pcDepthMap->getLumaAddr ( 0 );
+#if PDM_REMOVE_DEPENDENCE
+  if( forFirstNonBaseView == 1)
+  {
+    pcDepthMap  = pcPic->getPredDepthMapTemp  ();
+    pDMSamples  = pcDepthMap->getLumaAddr ( 0 );
+  }
+#endif
   for( Int iY = 0; iY < iHeight; iY++, pDMSamples += iStride )
   {
@@ -989,4 +1334,8 @@
   TComYuv*    pcSubDM   = m_ppcYuv[ uiDepth ];
   TComPicYuv* pcPicDM   = pcCU->getPic()->getPredDepthMap();
+#if PDM_REMOVE_DEPENDENCE
+  if( pcCU->getPic()->getStoredPDMforV2() == 1)
+    pcPicDM   = pcCU->getPic()->getPredDepthMapTemp();
+#endif
   UInt        uiCUAddr  = pcCU->getAddr();
   pcSubCU->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
@@ -1075,4 +1424,8 @@
     UInt  uiZOrderIdx     = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
     Pel*  pPicDepthMap    = pcCU->getPic()->getPredDepthMap()->getLumaAddr( pcCU->getAddr(), uiZOrderIdx );
+#if PDM_REMOVE_DEPENDENCE
+    if(pcCU->getPic()->getStoredPDMforV2()==1)
+      pPicDepthMap    = pcCU->getPic()->getPredDepthMapTemp()->getLumaAddr( pcCU->getAddr(), uiZOrderIdx );
+#endif
     Int   iPicStride      = pcCU->getPic()->getPredDepthMap()->getStride  ();
     for( UInt uiY = 0; uiY < uiHeight; uiY++, pDepthMap += uiStride, pPicDepthMap += iPicStride )
@@ -1511,4 +1864,5 @@
   return        true;
 }
+#endif
 
 #endif // DEPTH_MAP_GENERATION
Index: trunk/source/Lib/TLibCommon/TComDepthMapGenerator.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 100)
@@ -136,7 +136,9 @@
 
   Void  initViewComponent     ( TComPic*      pcPic );
+#if !QC_MULTI_DIS_CAN
   Bool  predictDepthMap       ( TComPic*      pcPic );
   Void  updateDepthMap        ( TComPic*      pcPic );
   Void  dumpDepthMap          ( TComPic*      pcPic, char* pFilenameBase );
+#endif
 
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -149,6 +151,12 @@
   Int   getDisparity          ( TComPic*      pcPic, Int iPosX, Int iPosY, UInt uiRefViewId );
 #if HHI_INTER_VIEW_MOTION_PRED
+#if QC_MULTI_DIS_CAN
+  Int   getPdmMergeCandidate ( TComDataCU*   pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo );
+  Bool  getPdmMvPredDisCan    ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge );
+  Bool  getDisCanPdmMvPred    ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge );
+#else
   Int   getPdmMergeCandidate  ( TComDataCU*   pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv );
   Bool  getPdmMvPred          ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge );
+#endif
   Bool  getIViewOrgDepthMvPred( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv );
 #endif
@@ -163,9 +171,15 @@
 private:
   // picture operations
+#if !QC_MULTI_DIS_CAN
   Bool  xConvertDepthMapCurr2Ref  ( TComPic*    pcRef, TComPic* pcCur );
   Bool  xConvertDepthMapRef2Curr  ( TComPic*    pcCur, TComPic* pcRef );
   Bool  xPredictDepthMap          ( TComPic*    pcPic );
   Bool  xFillDepthMapHoles        ( TComPic*    pcPic );
-  Void  xClearDepthMap            ( TComPic*    pcPic, Int      iVal  = PDM_UNDEFINED_DEPTH );
+  Void  xClearDepthMap            ( TComPic*    pcPic, Int      iVal  = PDM_UNDEFINED_DEPTH
+#if PDM_REMOVE_DEPENDENCE
+  ,
+  Int forFirstNonBaseView = 0
+#endif
+  );
   Void  xSetChroma                ( TComPicYuv* pcPic, Int      iVal  );
 
@@ -182,5 +196,5 @@
   Void  xInterPUDepthMapPrediction( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx );                      // PU inter prediction
   Bool  xGetPredDepth             ( TComDataCU* pcCU, UInt uiPartIdx, Int& riPrdDepth, Int* piPosX = 0, Int* piPosY = 0 );
-
+#endif
   // conversion functions
   Int   xGetVirtDepthFromDisparity( UInt uiBaseId, Int iDisparity )
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 100)
@@ -59,4 +59,12 @@
 
 // ====================================================================================================================
+#if QC_MULTI_DIS_CAN
+typedef struct _DisCand
+{
+  TComMv m_acMvCand[ DIS_CANS ];            ///< array of motion vector predictor candidates
+  Int    m_aVIdxCan[ DIS_CANS ];            ///< array of motion vector predictor candidates
+  Int    iN;                                ///< number of motion vector predictor candidates
+} DisInfo;
+#endif 
 // Class definition
 // ====================================================================================================================
Index: trunk/source/Lib/TLibCommon/TComMv.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComMv.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComMv.h	(revision 100)
@@ -57,4 +57,9 @@
 public:
   
+#if LGE_DVMCP
+  Bool  m_bDvMcp;       // is dv-mcp ?
+  Int   m_iDvMcpDispX;  // disparity for dv-mcp
+#endif
+
   // ------------------------------------------------------------------------------------------------------------------
   // constructors
@@ -64,4 +69,8 @@
   m_iHor(0),
   m_iVer(0)
+#if LGE_DVMCP
+  , m_bDvMcp(false)
+  , m_iDvMcpDispX(0)
+#endif
   {
   }
@@ -70,4 +79,8 @@
   m_iHor(iHor),
   m_iVer(iVer)
+#if LGE_DVMCP
+  , m_bDvMcp(false)
+  , m_iDvMcpDispX(0)
+#endif
   {
   }
Index: trunk/source/Lib/TLibCommon/TComPattern.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPattern.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComPattern.cpp	(revision 100)
@@ -675,4 +675,7 @@
 {
   Int* piSrc;
+#if LGE_EDGE_INTRA
+  mapEdgeIntratoDC( uiDirMode );
+#endif
   assert(log2BlkSize >= 2 && log2BlkSize < 7);
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
Index: trunk/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 100)
@@ -55,4 +55,7 @@
 #if DEPTH_MAP_GENERATION
   m_pcPredDepthMap    = NULL;
+#if PDM_REMOVE_DEPENDENCE
+  m_pcPredDepthMap_temp    = NULL;
+#endif
 #endif
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -136,4 +139,12 @@
     m_pcPredDepthMap = NULL;
   }
+#if PDM_REMOVE_DEPENDENCE
+  if( m_pcPredDepthMap_temp )         //  estimated depth map
+  {
+    m_pcPredDepthMap_temp->destroy();
+    delete m_pcPredDepthMap_temp;
+    m_pcPredDepthMap_temp = NULL;
+  }                     
+#endif
 #endif
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -179,4 +190,8 @@
   m_pcPredDepthMap    = new TComPicYuv;
   m_pcPredDepthMap    ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth );
+#if PDM_REMOVE_DEPENDENCE
+  m_pcPredDepthMap_temp    = new TComPicYuv;
+  m_pcPredDepthMap_temp    ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth );
+#endif
 }
 #endif
@@ -224,4 +239,12 @@
     m_pcPredDepthMap = NULL;
   }
+#if PDM_REMOVE_DEPENDENCE
+  if(m_pcPredDepthMap_temp)
+  {
+    m_pcPredDepthMap_temp->destroy();
+    delete m_pcPredDepthMap_temp;
+    m_pcPredDepthMap_temp = NULL;
+  }
+#endif
 }
 #endif
Index: trunk/source/Lib/TLibCommon/TComPic.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComPic.h	(revision 100)
@@ -67,8 +67,19 @@
 #if DEPTH_MAP_GENERATION
   TComPicYuv*           m_pcPredDepthMap;         //  estimated depth map
+#if PDM_REMOVE_DEPENDENCE
+  TComPicYuv*           m_pcPredDepthMap_temp;         //  estimated depth map
+  Bool                  m_bPDMV2;                       
+#endif
+#endif
+
+#if LG_ZEROINTRADEPTHRESI_M26039
+  Int                   m_uiIntraPeriod;
 #endif
 
 #if HHI_INTER_VIEW_MOTION_PRED
   TComPicYuv*           m_pcOrgDepthMap;          //  original depth map
+#if QC_MULTI_DIS_CAN
+  Bool          m_checked;
+#endif
 #endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -123,8 +134,12 @@
   TComVPS*      getVPS()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getVPS();  }
 #endif
+#if LG_ZEROINTRADEPTHRESI_M26039
+  Int           getIntraPeriod()                           { return  m_uiIntraPeriod; }
+  Void          setIntraPeriod(Int uiIntraPeriod)          { m_uiIntraPeriod = uiIntraPeriod; }
+#endif
   TComSPS*      getSPS()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getSPS();  }
   Int           getPOC()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getPOC();  }
   Int           getViewId()           { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getViewId(); }
-  TComDataCU*&  getCU( UInt uiCUAddr )  { return  m_apcPicSym->getCU( uiCUAddr ); }
+  TComDataCU*&  getCU( UInt uiCUAddr ){ return  m_apcPicSym->getCU( uiCUAddr ); }
   
   TComPicYuv*   getPicYuvOrg()        { return  m_apcPicYuv[0]; }
@@ -136,8 +151,17 @@
 #if DEPTH_MAP_GENERATION
   TComPicYuv*   getPredDepthMap()     { return  m_pcPredDepthMap; }
-#endif
-
+#if PDM_REMOVE_DEPENDENCE
+  TComPicYuv*   getPredDepthMapTemp()           { return  m_pcPredDepthMap_temp; }
+  Void          setStoredPDMforV2  (Bool flag)  { m_bPDMV2 = flag;}
+  Bool          getStoredPDMforV2  ()           { return m_bPDMV2;}
+#endif
+
+#endif
 #if HHI_INTER_VIEW_MOTION_PRED
   TComPicYuv*   getOrgDepthMap()      { return  m_pcOrgDepthMap; }
+#if QC_MULTI_DIS_CAN
+  Void          setCandPicCheckedFlag (Bool bchecked)   { m_checked = bchecked; }
+  Bool          getCandPicCheckedFlag ()                { return m_checked;}
+#endif
 #endif
 
Index: trunk/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 100)
@@ -46,4 +46,8 @@
 // ====================================================================================================================
 
+#if LGE_EDGE_INTRA
+#define MAX_DISTANCE_EDGEINTRA 255
+#endif
+
 TComPrediction::TComPrediction()
 : m_pLumaRecBuffer(0)
@@ -419,4 +423,185 @@
 }
 
+#if LGE_EDGE_INTRA
+Void TComPrediction::predIntraLumaEdge ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta )
+{
+  Pel *piDst = piPred;
+  Int *piSrc;
+  Int iSrcStride = ( iWidth<<1 ) + 1;
+  Int iDstStride = uiStride;
+
+  piSrc = pcTComPattern->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt );
+
+  xPredIntraEdge ( pcCU, uiAbsPartIdx, iWidth, iHeight, piSrc, iSrcStride, piDst, iDstStride
+#if LGE_EDGE_INTRA_DELTA_DC
+    , bDelta
+#endif
+    );
+}
+
+Pel  TComPrediction::xGetNearestNeighbor( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion )
+{
+  Bool bLeft = (x < y) ? true : false;
+  Bool bFound = false;
+  Int  iFoundX = -1, iFoundY = -1;
+  Int  cResult = 0;
+
+  UChar* piTopDistance = new UChar[iWidth];
+  UChar* piLeftDistance = new UChar[iHeight];
+
+  for( Int i = 0; i < iWidth; i++ )
+  {
+    int Abs = x > i ? x - i : i - x;
+    piTopDistance[ i ] = y + Abs;
+
+    Abs = y > i ? y - i : i - y;
+    piLeftDistance[ i ] = x + Abs;
+  }
+
+  for( Int dist = 0; dist < MAX_DISTANCE_EDGEINTRA && !bFound; dist++ )
+  {
+    if( !bLeft )
+    {
+      for( Int i = 0; i < iWidth; i++ )
+      {
+        if( piTopDistance[ i ] == dist )
+        {
+          if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] )
+          {
+            iFoundX = i;
+            iFoundY = 0;
+            bFound = true;
+          }
+        }
+      }
+      for( Int i = 0; i < iHeight; i++ )
+      {
+        if( piLeftDistance[ i ] == dist )
+        {
+          if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] )
+          {
+            iFoundX = 0;
+            iFoundY = i;
+            bFound = true;
+          }
+        }
+      }
+    }
+    else
+    {
+      for( Int i = 0; i < iHeight; i++ )
+      {
+        if( piLeftDistance[ i ] == dist )
+        {
+          if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] )
+          {
+            iFoundX = 0;
+            iFoundY = i;
+            bFound = true;
+          }
+        }
+      }
+      for( Int i = 0; i < iWidth; i++ )
+      {
+        if( piTopDistance[ i ] == dist )
+        {
+          if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] )
+          {
+            iFoundX = i;
+            iFoundY = 0;
+            bFound = true;
+          }
+        }
+      }
+    }
+  }
+
+  if( iFoundY == 0 )
+  {
+    cResult = pSrc[ iFoundX + 1 ];
+  }
+  else // iFoundX == 0
+  {
+    cResult = pSrc[ (iFoundY + 1) * srcStride ];
+  }
+
+  delete[] piTopDistance;  piTopDistance = NULL;
+  delete[] piLeftDistance; piLeftDistance = NULL;
+
+  assert( bFound );
+
+  return cResult;
+}
+
+Void TComPrediction::xPredIntraEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta )
+{
+  Pel* pDst = rpDst;
+  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
+
+  // Do prediction
+  {
+    //UInt uiSum0 = 0, uiSum1 = 0;
+    Int iSum0 = 0, iSum1 = 0;
+    //UInt uiMean0, uiMean1;
+    Int iMean0, iMean1;
+    //UInt uiCount0 = 0, uiCount1 = 0;
+    Int iCount0 = 0, iCount1 = 0;
+    for( UInt ui = 0; ui < iWidth; ui++ )
+    {
+      if( pbRegion[ ui ] == false )
+      {
+        iSum0 += (pSrc[ ui + 1 ]);
+        iCount0++;
+      }
+      else
+      {
+        iSum1 += (pSrc[ ui + 1 ]);
+        iCount1++;
+      }
+    }
+    for( UInt ui = 0; ui < iHeight; ui++ ) // (0,0) recount (to avoid division)
+    {
+      if( pbRegion[ ui * iWidth ] == false )
+      {
+        iSum0 += (pSrc[ (ui + 1) * srcStride ]);
+        iCount0++;
+      }
+      else
+      {
+        iSum1 += (pSrc[ (ui + 1) * srcStride ]);
+        iCount1++;
+      }
+    }
+    if( iCount0 == 0 )
+      assert(false);
+    if( iCount1 == 0 )
+      assert(false);
+    iMean0 = iSum0 / iCount0; // TODO : integer op.
+    iMean1 = iSum1 / iCount1;
+#if LGE_EDGE_INTRA_DELTA_DC
+    if( bDelta ) 
+    {
+      Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx );
+      Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx );
+      xDeltaDCQuantScaleUp( pcCU, iDeltaDC0 );
+      xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
+      iMean0 = Clip( iMean0 + iDeltaDC0 );
+      iMean1 = Clip( iMean1 + iDeltaDC1 );
+    }
+#endif
+    for( UInt ui = 0; ui < iHeight; ui++ )
+    {
+      for( UInt uii = 0; uii < iWidth; uii++ )
+      {
+        if( pbRegion[ uii + ui * iWidth ] == false )
+          pDst[ uii + ui * dstStride ] = iMean0;
+        else
+          pDst[ uii + ui * dstStride ] = iMean1;
+      }
+    }
+  }
+}
+#endif
+
 #if DEPTH_MAP_GENERATION
 Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
@@ -569,5 +754,11 @@
   {
     UInt uiRShift = 0;
-    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 );
+#if PDM_REMOVE_DEPENDENCE
+    if( pcCU->getPic()->getStoredPDMforV2() == 1 )
+      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMapTemp(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 );
+    else
+#endif
+      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 );
+
     return;
   }
Index: trunk/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 100)
@@ -125,4 +125,9 @@
 #endif
 
+#if LGE_EDGE_INTRA
+  Pel  xGetNearestNeighbor  ( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion );
+  Void xPredIntraEdge       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta = false );
+#endif
+
 public:
   TComPrediction();
@@ -170,4 +175,7 @@
   Bool  getWedgePatternIdx      ( WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe );
 #endif
+#if LGE_EDGE_INTRA
+  Void predIntraLumaEdge          ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta = false );
+#endif
 
   // simplified intra pred for "virtual" depth maps
Index: trunk/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComRdCost.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComRdCost.cpp	(revision 100)
@@ -45,4 +45,8 @@
 //! \{
 
+#if SAIT_VSO_EST_A0033
+Double TComRdCost::m_dDisparityCoeff = 1.0;
+#endif
+
 TComRdCost::TComRdCost()
 {
@@ -232,4 +236,14 @@
   m_afpDistortFunc[28] = TComRdCost::xGetHADs;
   
+#if SAIT_VSO_EST_A0033
+  m_afpDistortFunc[29]  = TComRdCost::xGetVSD;
+  m_afpDistortFunc[30]  = TComRdCost::xGetVSD4;
+  m_afpDistortFunc[31]  = TComRdCost::xGetVSD8;
+  m_afpDistortFunc[32]  = TComRdCost::xGetVSD16;
+  m_afpDistortFunc[33]  = TComRdCost::xGetVSD32;
+  m_afpDistortFunc[34]  = TComRdCost::xGetVSD64;
+  m_afpDistortFunc[35]  = TComRdCost::xGetVSD16N;
+#endif
+
 #if !FIX203
   m_puiComponentCostOriginP = NULL;
@@ -248,4 +262,7 @@
   m_uiNumberRefPics         = 0;
   m_bUseVSO                 = false;
+#if SAIT_VSO_EST_A0033
+  m_bUseEstimatedVSD        = false; 
+#endif
   m_uiVSOMode               = 0; 
   m_fpDistortFuncVSO        = NULL; 
@@ -273,23 +290,20 @@
     
     m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ];
-#if HHI_FIX
     m_puiMultiviewRegCostHorOrgP  = new UInt[ 4 * iSubPelSearchLimit ];
     m_puiMultiviewRegCostVerOrgP  = new UInt[ 4 * iSubPelSearchLimit ];
-#endif
+
     iSubPelSearchLimit *= 2;
     
     m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit;
-#if HHI_FIX
+
     m_puiMultiviewRegCostHor = m_puiMultiviewRegCostHorOrgP + iSubPelSearchLimit;
     m_puiMultiviewRegCostVer = m_puiMultiviewRegCostVerOrgP + iSubPelSearchLimit;
-#endif
+
     
     for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++)
     {
       m_puiComponentCost[n] = xGetComponentBits( n );
-#if HHI_FIX
       m_puiMultiviewRegCostHor[n] = xGetComponentBits( n );  // first version
       m_puiMultiviewRegCostVer[n] = xGetComponentBits( n );  // first version
-#endif
     }
   }
@@ -303,5 +317,5 @@
     m_puiComponentCostOriginP = NULL;
   }
-#if HHI_FIX
+
   if( m_puiMultiviewRegCostHorOrgP )
     {
@@ -314,5 +328,4 @@
     m_puiMultiviewRegCostVerOrgP = NULL;
   }
-#endif
 }
 #endif
@@ -565,4 +578,27 @@
 }
 
+
+#if SAIT_VSO_EST_A0033
+UInt TComRdCost::getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piVirRec, Pel* piVirOrg, Int iVirStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )
+{
+  AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) );
+
+  DistParam cDtParam;
+  setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam );
+  cDtParam.pOrg       = piOrg;
+  cDtParam.pCur       = piCur;
+  cDtParam.pVirRec    = piVirRec;
+  cDtParam.pVirOrg    = piVirOrg;
+  cDtParam.iStrideVir = iVirStride;
+  cDtParam.iStrideOrg = iOrgStride;
+  cDtParam.iStrideCur = iCurStride;
+  cDtParam.iStep      = 1;
+
+  cDtParam.bApplyWeight = false;
+  cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
+
+  return cDtParam.DistFunc( &cDtParam );
+}
+#endif
 
 
@@ -2026,4 +2062,235 @@
 #endif
 
+
+#if SAIT_VSO_EST_A0033
+UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y )
+{
+  Double dD;
+  Int iTemp;
+
+  dD = ( (Double) ( dDM >> g_uiBitIncrement ) ) * m_dDisparityCoeff;
+
+  iTemp = (Int) ROUND( 0.5 * fabs(dD) * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
+
+  return (UInt) ( (iTemp*iTemp)>>1 );
+}
+
+UInt TComRdCost::xGetVSD( DistParam* pcDtParam )
+{
+  Pel* piOrg    = pcDtParam->pOrg;
+  Pel* piCur    = pcDtParam->pCur;
+  Pel* piVirRec = pcDtParam->pVirRec;
+  Pel* piVirOrg = pcDtParam->pVirOrg;
+  Int  iRows    = pcDtParam->iRows;
+  Int  iCols    = pcDtParam->iCols;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideVir = pcDtParam->iStrideVir;
+
+  UInt uiSum = 0;
+  UInt uiShift = g_uiBitIncrement<<1;
+
+  Int dDM;
+
+  for ( Int y = 0 ; y < iRows ; y++ )
+  {
+    for (Int x = 0; x < iCols; x++ )
+    {
+      dDM = (Int) ( piOrg[x  ] - piCur[x  ] );
+      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur; 
+  }
+
+  return ( uiSum );
+}
+
+UInt TComRdCost::xGetVSD4( DistParam* pcDtParam )
+{
+  Pel* piOrg   = pcDtParam->pOrg;
+  Pel* piCur   = pcDtParam->pCur;
+  Pel* piVirRec = pcDtParam->pVirRec;
+  Pel* piVirOrg = pcDtParam->pVirOrg;
+  Int  iRows   = pcDtParam->iRows;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideVir = pcDtParam->iStrideVir;
+
+  UInt uiSum = 0;
+  UInt uiShift = g_uiBitIncrement<<1;
+
+  Int dDM;
+
+  for ( Int y = 0 ; y < iRows ; y++ )
+  {
+    dDM = (Int) ( piOrg[0] - piCur[0] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 0, y ) ) >> uiShift;
+    dDM = (Int) ( piOrg[1] - piCur[1] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 1, y ) ) >> uiShift;
+    dDM = (Int) ( piOrg[2] - piCur[2] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 2, y ) ) >> uiShift;
+    dDM = (Int) ( piOrg[3] - piCur[3] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 3, y ) ) >> uiShift;
+
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+
+  return ( uiSum );
+}
+
+UInt TComRdCost::xGetVSD8( DistParam* pcDtParam )
+{
+  Pel* piOrg   = pcDtParam->pOrg;
+  Pel* piCur   = pcDtParam->pCur;
+  Pel* piVirRec = pcDtParam->pVirRec;
+  Pel* piVirOrg = pcDtParam->pVirOrg;
+  Int  iRows   = pcDtParam->iRows;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideVir = pcDtParam->iStrideVir;
+
+  UInt uiSum = 0;
+  UInt uiShift = g_uiBitIncrement<<1;
+
+  Int dDM;
+
+  for ( Int y = 0 ; y < iRows ; y++ )
+  {
+    for (Int x = 0; x < 8; x++ )
+    {
+      dDM = (Int) ( piOrg[x] - piCur[x] );
+      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+
+  return ( uiSum );
+}
+
+UInt TComRdCost::xGetVSD16( DistParam* pcDtParam )
+{
+  Pel* piOrg   = pcDtParam->pOrg;
+  Pel* piCur   = pcDtParam->pCur;
+  Pel* piVirRec = pcDtParam->pVirRec;
+  Pel* piVirOrg = pcDtParam->pVirOrg;
+  Int  iRows   = pcDtParam->iRows;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideVir = pcDtParam->iStrideVir;
+
+  UInt uiSum = 0;
+  UInt uiShift = g_uiBitIncrement<<1;
+
+  Int dDM;
+
+  for ( Int y = 0 ; y < iRows ; y++ )
+  {
+    for (Int x = 0; x < 16; x++ )
+    {
+      dDM = (Int) ( piOrg[x] - piCur[x] );
+      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+
+  return ( uiSum );
+}
+
+UInt TComRdCost::xGetVSD16N( DistParam* pcDtParam )
+{
+  Pel* piOrg   = pcDtParam->pOrg;
+  Pel* piCur   = pcDtParam->pCur;
+  Pel* piVirRec = pcDtParam->pVirRec;
+  Pel* piVirOrg = pcDtParam->pVirOrg;
+  Int  iRows   = pcDtParam->iRows;
+  Int  iCols   = pcDtParam->iCols;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideVir = pcDtParam->iStrideVir;
+
+  UInt uiSum = 0;
+  UInt uiShift = g_uiBitIncrement<<1;
+
+  Int dDM;
+
+  for ( Int y = 0 ; y < iRows ; y++ )
+  {
+    for (Int x = 0; x < iCols; x+=16 )
+    {
+      for ( Int k = 0 ; k < 16 ; k++ )
+      {
+        dDM = (Int) ( piOrg[x+k] - piCur[x+k] );
+        uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x+k, y ) >> uiShift;
+      }
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+
+  return ( uiSum );
+}
+
+UInt TComRdCost::xGetVSD32( DistParam* pcDtParam )
+{
+  Pel* piOrg   = pcDtParam->pOrg;
+  Pel* piCur   = pcDtParam->pCur;
+  Pel* piVirRec = pcDtParam->pVirRec;
+  Pel* piVirOrg = pcDtParam->pVirOrg;
+  Int  iRows   = pcDtParam->iRows;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideVir = pcDtParam->iStrideVir;
+
+  UInt uiSum = 0;
+  UInt uiShift = g_uiBitIncrement<<1;
+
+  Int dDM;
+
+  for ( Int y = 0 ; y < iRows ; y++ )
+  {
+    for (Int x = 0; x < 32 ; x++ )
+    {
+      dDM = (Int) ( piOrg[x] - piCur[x] );
+      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+
+  return ( uiSum );
+}
+
+UInt TComRdCost::xGetVSD64( DistParam* pcDtParam )
+{
+  Pel* piOrg      = pcDtParam->pOrg;
+  Pel* piCur      = pcDtParam->pCur;
+  Pel* piVirRec   = pcDtParam->pVirRec;
+  Pel* piVirOrg   = pcDtParam->pVirOrg;
+  Int  iRows      = pcDtParam->iRows;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideVir = pcDtParam->iStrideVir;
+
+  UInt uiSum = 0;
+  UInt uiShift = g_uiBitIncrement<<1;
+
+  Int dDM;
+
+  for ( Int y = 0 ; y < iRows ; y++ )
+  {
+    for (Int x = 0; x < 64; x++ )
+    {
+      dDM = (Int) ( piOrg[x] - piCur[x] );
+      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+
+  return ( uiSum );
+}
+
+#endif
+
 // --------------------------------------------------------------------------------------------------------------------
 // HADAMARD with step (used in fractional search)
@@ -2668,5 +2935,9 @@
 { 
   AOT(bSAD); 
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur, piOrg, iOrgStride);  
+#else
   RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur );  
+#endif
 
   RMDist iDistMin = (RMDist) RDO_DIST_MIN; 
Index: trunk/source/Lib/TLibCommon/TComRdCost.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComRdCost.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComRdCost.h	(revision 100)
@@ -80,4 +80,9 @@
   Int   iStrideOrg;
   Int   iStrideCur;
+#if SAIT_VSO_EST_A0033
+  Pel*  pVirRec;
+  Pel*  pVirOrg;
+  Int   iStrideVir;
+#endif
   Int   iRows;
   Int   iCols;
@@ -105,4 +110,9 @@
     pOrg = NULL;
     pCur = NULL;
+#if SAIT_VSO_EST_A0033
+    pVirRec = NULL;
+    pVirOrg = NULL;;
+    iStrideVir = 0;
+#endif
     iStrideOrg = 0;
     iStrideCur = 0;
@@ -145,4 +155,7 @@
   UInt                    m_uiLambdaMotionSSE;
   Double                  m_dFrameLambda;
+#if SAIT_VSO_EST_A0033
+  static Double           m_dDisparityCoeff;
+#endif
   
 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
@@ -192,4 +205,9 @@
   Void    setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; }
   
+#if SAIT_VSO_EST_A0033
+  Void    setDisparityCoeff( Double dDisparityCoeff ) { m_dDisparityCoeff = dDisparityCoeff; }
+  Double  getDisparityCoeff()                         { return m_dDisparityCoeff; }
+#endif
+
 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
   Void   setLambdaScale  ( Double dLambdaScale) { m_dLambdaScale = dLambdaScale; }
@@ -222,7 +240,6 @@
 { 
      m_uiCost = (bSad ? m_uiLambdaMotionSAD + iAdd : m_uiLambdaMotionSSE + iAdd); 
-#if HHI_FIX
     m_uiLambdaMVReg = ( bSad ? m_uiLambdaMVRegSAD         : m_uiLambdaMVRegSSE         );
-#endif
+
    }
   Void    setPredictor( TComMv& rcMv )
@@ -301,4 +318,14 @@
   static UInt xGetSAD16N        ( DistParam* pcDtParam );
   
+#if SAIT_VSO_EST_A0033
+  static UInt xGetVSD           ( DistParam* pcDtParam );
+  static UInt xGetVSD4          ( DistParam* pcDtParam );
+  static UInt xGetVSD8          ( DistParam* pcDtParam );
+  static UInt xGetVSD16         ( DistParam* pcDtParam );
+  static UInt xGetVSD32         ( DistParam* pcDtParam );
+  static UInt xGetVSD64         ( DistParam* pcDtParam );
+  static UInt xGetVSD16N        ( DistParam* pcDtParam );
+#endif
+
 #if AMP_SAD
   static UInt xGetSAD12         ( DistParam* pcDtParam );
@@ -329,4 +356,9 @@
 #endif
   
+#if SAIT_VSO_EST_A0033
+  UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piVirRec, Pel* piVirOrg, Int iVirStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_VSD );
+  static UInt getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y );
+#endif
+
 #if HHI_VSO
 private:
@@ -340,4 +372,9 @@
   Bool                    m_bAllowNegDist;
 #endif
+#if SAIT_VSO_EST_A0033
+  TComPicYuv *            m_pcVideoRecPicYuv;
+  TComPicYuv *            m_pcDepthPicYuv;
+  Bool                    m_bUseEstimatedVSD; 
+#endif
 
   Bool                    m_bUseVSO;
@@ -357,4 +394,13 @@
   Void    setUseVSO ( Bool bIn )         { m_bUseVSO = bIn; };
   Bool    getUseVSO ( )                  { return m_bUseVSO;};
+#if SAIT_VSO_EST_A0033
+  Bool    getUseEstimatedVSD( )           { return m_bUseEstimatedVSD; };
+  Void    setUseEstimatedVSD( Bool bIn )  { m_bUseEstimatedVSD = bIn; };
+
+  TComPicYuv* getVideoRecPicYuv ()                               { return m_pcVideoRecPicYuv; };
+  Void        setVideoRecPicYuv ( TComPicYuv* pcVideoRecPicYuv ) { m_pcVideoRecPicYuv = pcVideoRecPicYuv; };
+  TComPicYuv* getDepthPicYuv    ()                               { return m_pcDepthPicYuv; };
+  Void        setDepthPicYuv    ( TComPicYuv* pcDepthPicYuv )    { m_pcDepthPicYuv = pcDepthPicYuv; };
+#endif
 
   Bool    getUseRenModel ( )             { return (m_bUseVSO && m_uiVSOMode == 4); };
Index: trunk/source/Lib/TLibCommon/TComResidualGenerator.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 100)
@@ -219,5 +219,12 @@
 }
 
-
+#if QC_MULTI_DIS_CAN
+Bool
+TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv, Int iDisp
+#if QC_SIMPLIFIEDIVRP_M24938
+  , Bool bRecon
+#endif
+ ) 
+#else
 Bool
 TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv 
@@ -226,4 +233,5 @@
 #endif
   )
+#endif
 {
   AOF(  pcCU );
@@ -235,4 +243,11 @@
   iBlkHeight  = pcCU->getHeight ( 0 );
   pcCU->getPic()->getPicYuvRec()->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iXPos, iYPos );
+#if QC_MULTI_DIS_CAN
+  return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, iDisp 
+#if QC_SIMPLIFIEDIVRP_M24938
+    , bRecon
+#endif
+  );
+#else
   return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv 
 #if QC_SIMPLIFIEDIVRP_M24938
@@ -240,6 +255,15 @@
 #endif
     );
+#endif
 }
   
+#if QC_MULTI_DIS_CAN
+Bool
+TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp 
+#if QC_SIMPLIFIEDIVRP_M24938
+  , Bool bRecon
+#endif
+)
+#else
 Bool
 TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv 
@@ -248,4 +272,5 @@
 #endif
   )
+#endif
 {
   UInt  uiBaseViewId  = m_pcDepthMapGenerator->getBaseViewId( 0 );
@@ -258,4 +283,11 @@
   UInt uiXPosInRefView = uiXPos , uiYPosInRefView = uiYPos;
 #endif
+#if QC_MULTI_DIS_CAN
+  xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, iDisp
+#if QC_SIMPLIFIEDIVRP_M24938
+    , &uiXPosInRefView , &uiYPosInRefView , bRecon
+#endif  
+  );
+#else
   xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv 
 #if QC_SIMPLIFIEDIVRP_M24938
@@ -263,5 +295,5 @@
 #endif
     );
-
+#endif
 #if QC_SIMPLIFIEDIVRP_M24938
   return xIsNonZeroByCBF( uiBaseViewId , uiXPosInRefView , uiYPosInRefView , uiBlkWidth , uiBlkHeight );
@@ -423,6 +455,6 @@
     AOF( bOK );
 #if LG_RESTRICTEDRESPRED_M24766
-	pcCU->getPUResiPredShift(iPUPredResiShift, 0);
-	pcCUResidual->add(iPUPredResiShift, pcCU->getPartitionSize(0), m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
+    pcCU->getPUResiPredShift(iPUPredResiShift, 0);
+    pcCUResidual->add(iPUPredResiShift, pcCU->getPartitionSize(0), m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
 #else
     pcCUResidual->add( m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
@@ -485,5 +517,12 @@
 
 
-
+#if QC_MULTI_DIS_CAN
+Void  
+TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp 
+#if QC_SIMPLIFIEDIVRP_M24938
+  , UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon
+#endif
+)
+#else
 Void  
 TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv 
@@ -492,4 +531,5 @@
 #endif
   )
+#endif
 {
   //===== set and check some basic variables =====
@@ -508,8 +548,11 @@
 
   //===== get disparity =====
+#if QC_MULTI_DIS_CAN
+  Int iDisparity = iDisp;
+#else
   Int           iMidPosX    = Int( uiXPos + ( ( uiBlkWidth  - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpX();
   Int           iMidPosY    = Int( uiYPos + ( ( uiBlkHeight - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpY();
   Int           iDisparity  = m_pcDepthMapGenerator->getDisparity( pcPic, iMidPosX, iMidPosY, uiBaseViewId );
-
+#endif
   //===== compensate luma =====
   Int           iYWidth     = Int( uiBlkWidth  );
Index: trunk/source/Lib/TLibCommon/TComResidualGenerator.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComResidualGenerator.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComResidualGenerator.h	(revision 100)
@@ -69,4 +69,16 @@
   Void  setRecResidualPic     ( TComPic*      pcPic );
 
+#if QC_MULTI_DIS_CAN
+  Bool  getResidualSamples    ( TComDataCU*   pcCU,  UInt uiPUIdx, TComYuv* pcYuv, Int iDisp 
+#if QC_SIMPLIFIEDIVRP_M24938
+    , Bool bRecon
+#endif
+);
+  Bool  getResidualSamples    ( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv , Int iDisp 
+#if QC_SIMPLIFIEDIVRP_M24938
+    , Bool bRecon
+#endif  
+  );
+#else
   Bool  getResidualSamples    ( TComDataCU*   pcCU,  UInt uiPUIdx, TComYuv* pcYuv 
 #if QC_SIMPLIFIEDIVRP_M24938
@@ -79,4 +91,5 @@
 #endif
     );
+#endif
 
 private:
@@ -87,5 +100,11 @@
   Void  xClearIntViewResidual ( TComDataCU*   pcCU,  TComYuv* pcCUResidual, UInt uiPartIdx    );
   Void  xClearResidual        (                      TComYuv* pcCUResidual, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight );
-
+#if QC_MULTI_DIS_CAN
+  Void  xSetPredResidualBlock ( TComPic*      pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp 
+#if QC_SIMPLIFIEDIVRP_M24938
+    , UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon
+#endif
+  );
+#else
   Void  xSetPredResidualBlock ( TComPic*      pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv 
 #if QC_SIMPLIFIEDIVRP_M24938
@@ -93,4 +112,5 @@
 #endif
     );
+#endif
   Bool  xIsNonZero            ( TComYuv*      pcYuv, UInt uiBlkWidth, UInt uiBlkHeight );
 #if QC_SIMPLIFIEDIVRP_M24938
Index: trunk/source/Lib/TLibCommon/TComRom.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComRom.h	(revision 100)
@@ -206,4 +206,10 @@
 #endif
 
+#if LGE_EDGE_INTRA
+__inline Void mapEdgeIntratoDC( UChar& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
+__inline Void mapEdgeIntratoDC(  UInt& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
+__inline Void mapEdgeIntratoDC(   Int& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
+#endif
+
 // ==========================================
 // Mode-Dependent DST Matrices
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 100)
@@ -1335,6 +1335,6 @@
 TComVPS::~TComVPS()
 {
-	
-	
+  
+  
 }
 
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 100)
@@ -151,9 +151,9 @@
 private:
   Int         m_VPSId;
-	UInt				m_uiMaxTLayers;
-	UInt				m_uiMaxLayers;
-	Bool				m_bTemporalIdNestingFlag;
-
-	UInt        m_uiExtensionType;
+  UInt        m_uiMaxTLayers;
+  UInt        m_uiMaxLayers;
+  Bool        m_bTemporalIdNestingFlag;
+
+  UInt        m_uiExtensionType;
   
   Bool        m_bDependentFlag[MAX_LAYER_NUM];
@@ -170,16 +170,16 @@
   TComVPS();
   virtual ~TComVPS();
-	
+  
   Int     getVPSId       ()                   { return m_VPSId;          }
   Void    setVPSId       (Int i)              { m_VPSId = i;             }
-	
+  
   UInt    getMaxTLayers  ()                   { return m_uiMaxTLayers;   }
   Void    setMaxTLayers  (UInt t)             { m_uiMaxTLayers = t; }
     
   UInt    getMaxLayers   ()                   { return m_uiMaxLayers;   }
-	Void    setMaxLayers   (UInt l)             { m_uiMaxLayers = l; }
-	
+  Void    setMaxLayers   (UInt l)             { m_uiMaxLayers = l; }
+  
   Bool    getTemporalNestingFlag   ()         { return m_uiMaxLayers;   }
-	Void    setTemporalNestingFlag   (UInt t)   { m_bTemporalIdNestingFlag = t; }
+  Void    setTemporalNestingFlag   (UInt t)   { m_bTemporalIdNestingFlag = t; }
   
   Void    setExtensionType(UInt v)                     { m_uiExtensionType = v;    }
@@ -219,5 +219,5 @@
 private:
 #if VIDYO_VPS_INTEGRATION
-	Int					m_VPSId;
+  Int          m_VPSId;
 #endif
   Int         m_SPSId;
@@ -379,5 +379,5 @@
   virtual ~TComSPS();
 #if VIDYO_VPS_INTEGRATION
-	Int  getVPSId       ()         { return m_VPSId;          }
+  Int  getVPSId       ()         { return m_VPSId;          }
   Void setVPSId       (Int i)    { m_VPSId = i;             }
 #endif
Index: trunk/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComYuv.cpp	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComYuv.cpp	(revision 100)
@@ -396,6 +396,6 @@
 TComYuv::add(Int *iPUResiPredShift, PartSize uhPartitionSize,  TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract )
 {
-	addLuma   (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth,    iHeight,    bSubtract );
-	addChroma (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract );
+  addLuma   (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth,    iHeight,    bSubtract );
+  addChroma (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract );
 }
 #else
@@ -412,24 +412,24 @@
 TComYuv::getPUXYOffset(PartSize uhPartitionSize, Int iWidth, Int iHeight, Int &iXOffset, Int &iYOffset)
 {
-	switch(uhPartitionSize)
-	{	  
-	case SIZE_2NxN:
-		iXOffset = iWidth;      iYOffset = iHeight >> 1;   break;
-	case SIZE_2NxnU:
-		iXOffset = iWidth;      iYOffset = iHeight >> 2;   break;
-	case SIZE_2NxnD: 
-		iXOffset = iWidth;      iYOffset = (iHeight >> 1) + (iHeight >> 2);   break;
-	case SIZE_Nx2N:
-		iXOffset = iWidth >> 1; iYOffset = iHeight; break;
-	case SIZE_nLx2N:
-		iXOffset = iWidth >> 2; iYOffset = iHeight; break;
-	case SIZE_nRx2N:
-		iXOffset = (iWidth >> 1) + (iWidth >> 2); iYOffset = iHeight; break;
-	case SIZE_NxN:
-		iXOffset = iWidth >> 1; iYOffset = iHeight >> 1;  break;
-	default:
-		assert(uhPartitionSize == SIZE_2Nx2N);
-		iXOffset = iWidth; 	  iYOffset = iHeight;	  break;
-	}
+  switch(uhPartitionSize)
+  {    
+  case SIZE_2NxN:
+    iXOffset = iWidth;      iYOffset = iHeight >> 1;   break;
+  case SIZE_2NxnU:
+    iXOffset = iWidth;      iYOffset = iHeight >> 2;   break;
+  case SIZE_2NxnD: 
+    iXOffset = iWidth;      iYOffset = (iHeight >> 1) + (iHeight >> 2);   break;
+  case SIZE_Nx2N:
+    iXOffset = iWidth >> 1; iYOffset = iHeight; break;
+  case SIZE_nLx2N:
+    iXOffset = iWidth >> 2; iYOffset = iHeight; break;
+  case SIZE_nRx2N:
+    iXOffset = (iWidth >> 1) + (iWidth >> 2); iYOffset = iHeight; break;
+  case SIZE_NxN:
+    iXOffset = iWidth >> 1; iYOffset = iHeight >> 1;  break;
+  default:
+    assert(uhPartitionSize == SIZE_2Nx2N);
+    iXOffset = iWidth;     iYOffset = iHeight;    break;
+  }
 }
 #endif
@@ -456,38 +456,38 @@
   for( Int iY = 0; iY < iYOffset; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride )
   {
-	  if(iPUResiPredShift[0] >= 0)
-	  {
-		  for( Int iX = 0; iX < iXOffset; iX++ )
-		  {
-			  pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[0]);
-		  }
-	  }
-
-	  if(iPUResiPredShift[1] >= 0)
-	  {
-		  for( Int iX = iXOffset; iX < iWidth; iX++ )
-		  {
-			  pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[1]);
-		  }
-	  }
+    if(iPUResiPredShift[0] >= 0)
+    {
+      for( Int iX = 0; iX < iXOffset; iX++ )
+      {
+        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[0]);
+      }
+    }
+
+    if(iPUResiPredShift[1] >= 0)
+    {
+      for( Int iX = iXOffset; iX < iWidth; iX++ )
+      {
+        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[1]);
+      }
+    }
   }
 
   for( Int iY = iYOffset; iY < iHeight; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride )
   {
-	  if(iPUResiPredShift[2] >= 0)
-	  {
-		  for( Int iX = 0; iX < iXOffset; iX++ )
-		  {
-			  pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[2]);
-		  }
-	  }
-
-	  if(iPUResiPredShift[3] >= 0)
-	  {
-		  for( Int iX = iXOffset; iX < iWidth; iX++ )
-		  {
-			  pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[3]);
-		  }
-	  }
+    if(iPUResiPredShift[2] >= 0)
+    {
+      for( Int iX = 0; iX < iXOffset; iX++ )
+      {
+        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[2]);
+      }
+    }
+
+    if(iPUResiPredShift[3] >= 0)
+    {
+      for( Int iX = iXOffset; iX < iWidth; iX++ )
+      {
+        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[3]);
+      }
+    }
   }
 #else
@@ -524,45 +524,45 @@
 
   for( Int iY = 0; iY < iYOffset; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride,
-	  pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
-  {
-	  if(iPUResiPredShift[0] >= 0)
-	  {
-		  for( Int iX = 0; iX < iXOffset; iX++ )
-		  {
-			  pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[0]);
-			  pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[0]);
-		  }
-	  }
-
-	  if(iPUResiPredShift[1] >= 0)
-	  {
-		  for( Int iX = iXOffset; iX < iWidth; iX++ )
-		  {
-			  pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[1]);
-			  pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[1]);
-		  }
-	  }
+    pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
+  {
+    if(iPUResiPredShift[0] >= 0)
+    {
+      for( Int iX = 0; iX < iXOffset; iX++ )
+      {
+        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[0]);
+        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[0]);
+      }
+    }
+
+    if(iPUResiPredShift[1] >= 0)
+    {
+      for( Int iX = iXOffset; iX < iWidth; iX++ )
+      {
+        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[1]);
+        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[1]);
+      }
+    }
   }
 
   for( Int iY = iYOffset; iY < iHeight; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride,
-	  pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
-  {
-	  if(iPUResiPredShift[2] >= 0)
-	  {
-		  for( Int iX = 0; iX < iXOffset; iX++ )
-		  {
-			  pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[2]);
-			  pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[2]);
-		  }
-	  }
-
-	  if(iPUResiPredShift[3] >= 0)
-	  {
-		  for( Int iX = iXOffset; iX < iWidth; iX++ )
-		  {
-			  pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[3]);
-			  pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[3]);
-		  }
-	  }
+    pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
+  {
+    if(iPUResiPredShift[2] >= 0)
+    {
+      for( Int iX = 0; iX < iXOffset; iX++ )
+      {
+        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[2]);
+        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[2]);
+      }
+    }
+
+    if(iPUResiPredShift[3] >= 0)
+    {
+      for( Int iX = iXOffset; iX < iWidth; iX++ )
+      {
+        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[3]);
+        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[3]);
+      }
+    }
   }
 #else
@@ -679,6 +679,6 @@
 Void TComYuv::subtract(Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
 {
-	subtractLuma  (iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize    );
-	subtractChroma(iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize>>1 );
+  subtractLuma  (iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize    );
+  subtractChroma(iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize>>1 );
 }
 #else
@@ -713,44 +713,44 @@
   for ( y = uiPartSize-1; y >= iYOffset; y-- )
   {
-	  if(iPUResiPredShift[3] >= 0)
-	  {
-		  for ( x = uiPartSize-1; x >= iXOffset; x-- )
-		  {
-			  pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
-		  }
-	  }
-
-	  if(iPUResiPredShift[2] >= 0)
-	  {
-		  for ( x = iXOffset-1; x >= 0; x-- )
-		  {
-			  pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
-		  }
-	  }
-	  pSrc0 += iSrc0Stride;
-	  pSrc1 += iSrc1Stride;
-	  pDst  += iDstStride;
+    if(iPUResiPredShift[3] >= 0)
+    {
+      for ( x = uiPartSize-1; x >= iXOffset; x-- )
+      {
+        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
+      }
+    }
+
+    if(iPUResiPredShift[2] >= 0)
+    {
+      for ( x = iXOffset-1; x >= 0; x-- )
+      {
+        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
+      }
+    }
+    pSrc0 += iSrc0Stride;
+    pSrc1 += iSrc1Stride;
+    pDst  += iDstStride;
   }
 
   for ( y = iYOffset-1; y >= 0; y-- )
   {
-	  if(iPUResiPredShift[1] >= 0)
-	  {
-		  for ( x = uiPartSize-1; x >= iXOffset; x-- )
-		  {
-			  pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
-		  }
-	  }
-
-	  if(iPUResiPredShift[0] >= 0)
-	  {
-		  for ( x = iXOffset-1; x >= 0; x-- )
-		  {
-			  pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
-		  }
-	  }
-	  pSrc0 += iSrc0Stride;
-	  pSrc1 += iSrc1Stride;
-	  pDst  += iDstStride;
+    if(iPUResiPredShift[1] >= 0)
+    {
+      for ( x = uiPartSize-1; x >= iXOffset; x-- )
+      {
+        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
+      }
+    }
+
+    if(iPUResiPredShift[0] >= 0)
+    {
+      for ( x = iXOffset-1; x >= 0; x-- )
+      {
+        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
+      }
+    }
+    pSrc0 += iSrc0Stride;
+    pSrc1 += iSrc1Stride;
+    pDst  += iDstStride;
   }
 
@@ -794,54 +794,54 @@
   for ( y = uiPartSize-1; y >= iYOffset; y-- )
   {
-	  if(iPUResiPredShift[3] >= 0)
-	  {
-		  for ( x = uiPartSize-1; x >= iXOffset; x-- )
-		  {
-			  pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[3]);
-			  pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[3]);
-		  }
-	  }
-
-	  if(iPUResiPredShift[2] >= 0)
-	  {
-		  for ( x = iXOffset-1; x >= 0; x-- )
-		  {
-			  pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[2]);
-			  pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[2]);
-		  }
-	  }
-	  pSrcU0 += iSrc0Stride;
-	  pSrcU1 += iSrc1Stride;
-	  pSrcV0 += iSrc0Stride;
-	  pSrcV1 += iSrc1Stride;
-	  pDstU  += iDstStride;
-	  pDstV  += iDstStride;
+    if(iPUResiPredShift[3] >= 0)
+    {
+      for ( x = uiPartSize-1; x >= iXOffset; x-- )
+      {
+        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[3]);
+        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[3]);
+      }
+    }
+
+    if(iPUResiPredShift[2] >= 0)
+    {
+      for ( x = iXOffset-1; x >= 0; x-- )
+      {
+        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[2]);
+        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[2]);
+      }
+    }
+    pSrcU0 += iSrc0Stride;
+    pSrcU1 += iSrc1Stride;
+    pSrcV0 += iSrc0Stride;
+    pSrcV1 += iSrc1Stride;
+    pDstU  += iDstStride;
+    pDstV  += iDstStride;
   }
 
   for ( y = iYOffset-1; y >= 0; y-- )
   {
-	  if(iPUResiPredShift[1] >= 0)
-	  {
-		  for ( x = uiPartSize-1; x >= iXOffset; x-- )
-		  {
-			  pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[1]);
-			  pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[1]);
-		  }
-	  }
-
-	  if(iPUResiPredShift[0] >= 0)
-	  {
-		  for ( x = iXOffset-1; x >= 0; x-- )
-		  {
-			  pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[0]);
-			  pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[0]);
-		  }
-	  }
-	  pSrcU0 += iSrc0Stride;
-	  pSrcU1 += iSrc1Stride;
-	  pSrcV0 += iSrc0Stride;
-	  pSrcV1 += iSrc1Stride;
-	  pDstU  += iDstStride;
-	  pDstV  += iDstStride;
+    if(iPUResiPredShift[1] >= 0)
+    {
+      for ( x = uiPartSize-1; x >= iXOffset; x-- )
+      {
+        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[1]);
+        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[1]);
+      }
+    }
+
+    if(iPUResiPredShift[0] >= 0)
+    {
+      for ( x = iXOffset-1; x >= 0; x-- )
+      {
+        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[0]);
+        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[0]);
+      }
+    }
+    pSrcU0 += iSrc0Stride;
+    pSrcU1 += iSrc1Stride;
+    pSrcV0 += iSrc0Stride;
+    pSrcV1 += iSrc1Stride;
+    pDstU  += iDstStride;
+    pDstV  += iDstStride;
   }
 #else
Index: trunk/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComYuv.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TComYuv.h	(revision 100)
@@ -167,5 +167,5 @@
   Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight );
 #if LG_RESTRICTEDRESPRED_M24766
-  void	  getPUXYOffset     (PartSize uhPartitionSize, Int iWidth, Int iHeight, Int &iXOffset, Int &iYOffset);
+  Void    getPUXYOffset     (PartSize uhPartitionSize, Int iWidth, Int iHeight, Int &iXOffset, Int &iYOffset);
   Void    add               (Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract = false );
   Void    addLuma           (Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract );
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 81)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 100)
@@ -42,21 +42,57 @@
 //! \{
 
+#define FIXES                           1
+#define LGE_EDGE_INTRA                  1       //JCT2-A0070
+#if LGE_EDGE_INTRA
+#define LGE_EDGE_INTRA_MIN_SIZE         4
+#define LGE_EDGE_INTRA_MAX_SIZE        32
+#define LGE_EDGE_INTRA_THRESHOLD       20
+#define LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 8
+#define LGE_EDGE_INTRA_DELTA_DC         1 
+#define LGE_EDGE_INTRA_PIXEL_DIFFERENCE 1
+#endif
+
+#define LG_ZEROINTRADEPTHRESI_M26039      1  //JCT2-A0087
+
 #define SONY_COLPIC_AVAILABILITY          1
 
 #define HHI_INTER_VIEW_MOTION_PRED        1   // inter-view motion parameter prediction
 #define HHI_INTER_VIEW_RESIDUAL_PRED      1   // inter-view residual prediction
-#define HHI_FIX                           1   // inter-view prediction and other fixes
+#define QC_MULTI_DIS_CAN                  1         // JCT2-A0097
+#if QC_MULTI_DIS_CAN
+    #define DIS_CANS                      1
+#endif
+
+#define MTK_INTERVIEW_MERGE_A0049         1 //  JCT2-A0049 second part
+
+#define LGE_DVMCP                         1 //  JCT2-A0126     
+#if LGE_DVMCP
+#define DVFROM_LEFTBELOW                  1
+#define DVFROM_LEFT                       2
+#define DVFROM_ABOVERIGHT                 3
+#define DVFROM_ABOVE                      4
+#define DVFROM_ABOVELEFT                  5
+#define DVFROM_COL                        6
+#endif
+
 
 #define HHI_VSO                           1
-#define HHI_VSO_LS_TABLE                  1
+#define HHI_VSO_LS_TABLE                  1 // m23714
 #define HHI_VSO_DIST_INT                  1
 #define HHI_VSO_SYNTH_DIST_OUT            0
 #define HHI_VSO_COLOR_PLANES              1
+#define HHI_VSO_SPEEDUP_A033              1 // JCT2-A0033 modification 1 (changes classes directly related the renderer model 
+                                            // to are not covered by this define, since nearly the entire class has been changed)
+#define HHI_VSO_RM_ASSERTIONS             0 // output VSO assertions
+#define HHI_VSO_SET_OPTIM                 1 // remove unnecessary updates (works only with HHI_VSO_FIX 1 properly)
+#define SAIT_VSO_EST_A0033                1 // JCT2-A0033 modification 3
+#define LGE_VSO_EARLY_SKIP_A0093          1 // JCT2-A0093 modification 4
+
 
 #define HHI_INTERVIEW_SKIP                1
 #define HHI_INTERVIEW_SKIP_LAMBDA_SCALE   1
 
-#define HHI_DMM_WEDGE_INTRA 1   // depth model modes independent on texture (explicit and intra-predicted Wedgelet prediction)
-#define HHI_DMM_PRED_TEX    1   // depth model modes dependent on texture (inter-component Wedgelet and Contour prediction )
+#define HHI_DMM_WEDGE_INTRA               1   // depth model modes independent on texture (explicit and intra-predicted Wedgelet prediction)
+#define HHI_DMM_PRED_TEX                  1   // depth model modes dependent on texture (inter-component Wedgelet and Contour prediction )
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
@@ -224,5 +260,13 @@
 #define LOG2_SCAN_SET_SIZE                4
 
+#if LGE_EDGE_INTRA
+#if LGE_EDGE_INTRA_DELTA_DC
+#define FAST_UDI_MAX_RDMODE_NUM               37          ///< maximum number of RD comparison in fast-UDI estimation loop
+#else
+#define FAST_UDI_MAX_RDMODE_NUM               36          ///< maximum number of RD comparison in fast-UDI estimation loop
+#endif
+#else
 #define FAST_UDI_MAX_RDMODE_NUM               35          ///< maximum number of RD comparison in fast-UDI estimation loop
+#endif
 
 #define ZERO_MVD_EST                          0           ///< Zero Mvd Estimation in normal mode
@@ -263,4 +307,13 @@
 #define NUM_DMM_MODE 4
 #endif
+
+#if LGE_EDGE_INTRA
+#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
+#define EDGE_INTRA_IDX  (NUM_INTRA_MODE+NUM_DMM_MODE)
+#endif // HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
+#if LGE_EDGE_INTRA_DELTA_DC
+#define EDGE_INTRA_DELTA_IDX          (EDGE_INTRA_IDX+1)
+#endif
+#endif // LGE_EDGE_INTRA
 
 #define IBDI_DISTORTION                0           ///< enable/disable SSE modification when IBDI is used (JCTVC-D152)
@@ -647,4 +700,16 @@
 };
 
+#if HHI_VSO_SPEEDUP_A033
+
+enum BlenMod
+{
+    BLEND_NONE  = -1,
+    BLEND_AVRG  = 0,
+    BLEND_LEFT  = 1,
+    BLEND_RIGHT = 2,
+    BLEND_GEN   =  3
+};
+#endif
+
 /// supported prediction type
 enum PredMode
@@ -712,4 +777,15 @@
   DF_HADS16N  = 28,     ///< 16NxM HAD with step
 
+#if SAIT_VSO_EST_A0033
+  DF_VSD      = 29,      ///< general size VSD
+  DF_VSD4     = 30,      ///<   4xM VSD
+  DF_VSD8     = 31,      ///<   8xM VSD
+  DF_VSD16    = 32,      ///<  16xM VSD
+  DF_VSD32    = 33,      ///<  32xM VSD
+  DF_VSD64    = 34,      ///<  64xM VSD
+  DF_VSD16N   = 35,      ///< 16NxM VSD
+#endif
+
+
 #if AMP_SAD
   DF_SAD12    = 43,
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 81)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 100)
@@ -1891,9 +1891,5 @@
       rpcSlice->setPOC( iPOCmsb+iPOClsb );
 
-#if HHI_FIX
       if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && rpcSlice->getPOC() == 0 )
-#else
-      if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV ) 
-#endif
       {
         TComReferencePictureSet* rps = rpcSlice->getLocalRPS();
Index: trunk/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 81)
+++ trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 100)
@@ -643,7 +643,7 @@
     AOF( bOK );
 #if LG_RESTRICTEDRESPRED_M24766
-	Int iPUResiPredShift[4];
-	pcCU->getPUResiPredShift(iPUResiPredShift, 0);
-	m_ppcYuvReco[uiDepth]->add(iPUResiPredShift, pcCU->getPartitionSize(0), m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
+    Int iPUResiPredShift[4];
+    pcCU->getPUResiPredShift(iPUResiPredShift, 0);
+    m_ppcYuvReco[uiDepth]->add(iPUResiPredShift, pcCU->getPartitionSize(0), m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
 #else
     m_ppcYuvReco[uiDepth]->add( m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
@@ -705,4 +705,15 @@
                                      m_pcPrediction->getPredicBufHeight (),
                                      bAboveAvail, bLeftAvail );
+#if LGE_EDGE_INTRA
+  if( uiLumaPredMode >= EDGE_INTRA_IDX )
+  {
+    m_pcPrediction->predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride
+#if LGE_EDGE_INTRA_DELTA_DC
+      , uiLumaPredMode == EDGE_INTRA_DELTA_IDX
+#endif
+      );
+  } 
+  else
+#endif
   
   //===== get prediction signal =====
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 81)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 100)
@@ -109,7 +109,7 @@
   {
 #if LG_RESTRICTEDRESPRED_M24766
-	  Int iPUResiPredShift[4];
-	  pcCU->getPUResiPredShift(iPUResiPredShift, uiAbsPartIdx);
-	  if(iPUResiPredShift[0] >= 0 || iPUResiPredShift[1] >= 0  || iPUResiPredShift[2] >= 0  || iPUResiPredShift[3] >= 0 )
+    Int iPUResiPredShift[4];
+    pcCU->getPUResiPredShift(iPUResiPredShift, uiAbsPartIdx);
+    if(iPUResiPredShift[0] >= 0 || iPUResiPredShift[1] >= 0  || iPUResiPredShift[2] >= 0  || iPUResiPredShift[3] >= 0 )
 #endif
     m_pcEntropyDecoderIf->parseResPredFlag( pcCU, bResPredFlag, uiAbsPartIdx, uiDepth );
Index: trunk/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 81)
+++ trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 100)
@@ -303,5 +303,7 @@
     {
       m_pcDepthMapGenerator->initViewComponent( rpcPic );
+#if !QC_MULTI_DIS_CAN
       m_pcDepthMapGenerator->predictDepthMap  ( rpcPic );
+#endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
       m_pcResidualGenerator->initViewComponent( rpcPic );
@@ -339,6 +341,8 @@
 #endif
 #if DEPTH_MAP_GENERATION
+#if !QC_MULTI_DIS_CAN
     // update virtual depth map
     m_pcDepthMapGenerator->updateDepthMap( rpcPic );
+#endif
 #endif
     // deblocking filter
Index: trunk/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 81)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 100)
@@ -98,4 +98,10 @@
 , m_cDmmDataSCModel           ( 1,             1,               NUM_DMM_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
+#if LGE_EDGE_INTRA
+, m_cEdgeIntraSCModel         ( 1,             1,               NUM_EDGE_INTRA_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
+#if LGE_EDGE_INTRA_DELTA_DC
+, m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#endif
 {
   assert( m_numContextModels <= MAX_NUM_CTX_MOD );
@@ -182,4 +188,10 @@
 
   m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
+#if LGE_EDGE_INTRA
+  m_cEdgeIntraSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_EDGE_INTRA );
+#if LGE_EDGE_INTRA_DELTA_DC
+  m_cEdgeIntraDeltaDCSCModel.initBuffer  ( sliceType, qp, (UChar*)INIT_EDGE_INTRA_DELTA_DC );
+#endif
+#endif
   m_uiLastDQpNonZero  = 0;
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
@@ -815,5 +827,5 @@
   {
     UInt uiDMMode;
-  
+
 #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
     m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode  = uiSymbol;
@@ -847,69 +859,141 @@
 #endif
 #if !LOGI_INTRA_NAME_3MPM
-  Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
-#endif
-  
+    Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
+#endif
+
+#if LGE_EDGE_INTRA
+    Bool bCodeEdgeIntra = false;
+    if( pcCU->getSlice()->getSPS()->isDepth() )
+    {
+      UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0);
+      if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE )
+        bCodeEdgeIntra = true;
+    }
+#endif
+
 #if LOGI_INTRA_NAME_3MPM
-  Int uiPreds[3] = {-1, -1, -1};
-#else
-  Int uiPreds[2] = {-1, -1};
-#endif
-  Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds);  
- 
-  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
- 
-  if ( uiSymbol )
-  {
-    m_pcTDecBinIf->decodeBinEP( uiSymbol );
+    Int uiPreds[3] = {-1, -1, -1};
+#else
+    Int uiPreds[2] = {-1, -1};
+#endif
+    Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds);  
+#if LGE_EDGE_INTRA
+    UInt uiCheckBit = 0;
+#endif
+
+    m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
+
+    if ( uiSymbol )
+    {
+      m_pcTDecBinIf->decodeBinEP( uiSymbol );
 #if LOGI_INTRA_NAME_3MPM
-    if (uiSymbol)
-    {
-      m_pcTDecBinIf->decodeBinEP( uiSymbol );
-      uiSymbol++;
-    }
-#endif
-    intraPredMode = uiPreds[uiSymbol];
-  }
-  else
-  {
-    intraPredMode = 0;
-    
+      if (uiSymbol)
+      {
+        m_pcTDecBinIf->decodeBinEP( uiSymbol );
+        uiSymbol++;
+      }
+#endif
+      intraPredMode = uiPreds[uiSymbol];
+    }
+    else
+    {
+      intraPredMode = 0;
+
 #if LOGI_INTRA_NAME_3MPM
-   
-    m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 );
-    intraPredMode = uiSymbol;
-    
-   //postponed sorting of MPMs (only in remaining branch)
-    if (uiPreds[0] > uiPreds[1])
-    { 
-      std::swap(uiPreds[0], uiPreds[1]); 
-    }
-    if (uiPreds[0] > uiPreds[2])
-    {
-      std::swap(uiPreds[0], uiPreds[2]);
-    }
-    if (uiPreds[1] > uiPreds[2])
-    {
-      std::swap(uiPreds[1], uiPreds[2]);
-    }
-#else
-    m_pcTDecBinIf->decodeBinsEP( uiSymbol, g_aucIntraModeBitsAng[iIntraIdx] - 1 );
-    intraPredMode = uiSymbol;
-    
-    if ( intraPredMode == 31 )
-    {
-      m_pcTDecBinIf->decodeBinEP( uiSymbol );
-      intraPredMode += uiSymbol;      
-    }
-#endif
-    for ( Int i = 0; i < uiPredNum; i++ )
-    {
-      intraPredMode += ( intraPredMode >= uiPreds[i] );
-    }
-  }
+
+      m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 );
+#if LGE_EDGE_INTRA
+      if (bCodeEdgeIntra)
+      {
+        if (uiSymbol==31)
+        {
+          m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1);
+          if (uiCheckBit)
+            uiSymbol = EDGE_INTRA_IDX;
+        }
+      }
+#endif
+      intraPredMode = uiSymbol;
+
+      //postponed sorting of MPMs (only in remaining branch)
+      if (uiPreds[0] > uiPreds[1])
+      { 
+        std::swap(uiPreds[0], uiPreds[1]); 
+      }
+      if (uiPreds[0] > uiPreds[2])
+      {
+        std::swap(uiPreds[0], uiPreds[2]);
+      }
+      if (uiPreds[1] > uiPreds[2])
+      {
+        std::swap(uiPreds[1], uiPreds[2]);
+      }
+#else
+      m_pcTDecBinIf->decodeBinsEP( uiSymbol, g_aucIntraModeBitsAng[iIntraIdx] - 1 );
+      intraPredMode = uiSymbol;
+
+      if ( intraPredMode == 31 )
+      {
+        m_pcTDecBinIf->decodeBinEP( uiSymbol );
+        intraPredMode += uiSymbol;      
+      }
+#endif
+#if LGE_EDGE_INTRA
+      if ( intraPredMode != EDGE_INTRA_IDX)
+      {
+#endif
+        for ( Int i = 0; i < uiPredNum; i++ )
+        {
+          intraPredMode += ( intraPredMode >= uiPreds[i] );
+        }
+#if LGE_EDGE_INTRA
+      }
+#endif
+    }
+
+#if LGE_EDGE_INTRA
+    if( intraPredMode == EDGE_INTRA_IDX )
+    {
+      xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth );
+#if LGE_EDGE_INTRA_DELTA_DC
+      m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) );
+      if( uiSymbol )
+      {
+        intraPredMode = EDGE_INTRA_DELTA_IDX;
+        Int iDeltaDC0;
+        Int iDeltaDC1;
+
+        xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
+        if( iDeltaDC0 != 0 )
+        {
+          UInt uiSign;
+          m_pcTDecBinIf->decodeBinEP( uiSign );
+          if ( uiSign )
+          {
+            iDeltaDC0 = -iDeltaDC0;
+          }
+        }
+        xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
+        if( iDeltaDC1 != 0 )
+        {
+          UInt uiSign;
+          m_pcTDecBinIf->decodeBinEP( uiSign );
+          if ( uiSign )
+          {
+            iDeltaDC1 = -iDeltaDC1;
+          }
+        }
+
+        pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 );
+        pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 );
+      }
+#endif
+    }
+#endif
+
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
   }
 #endif
-  
+
   pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth );
 }
@@ -2012,5 +2096,5 @@
 #endif
 
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC)
 Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel  )
 {
@@ -2270,3 +2354,102 @@
 }
 #endif
+
+#if LGE_EDGE_INTRA
+Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  UInt uiSymbol = 0;
+
+  // 1. Top(0) or Left(1)
+  UChar ucLeft;
+  m_pcTDecBinIf->decodeBinEP( uiSymbol );
+  ucLeft = uiSymbol;
+
+  // 2. Start position (lowest bit first)
+  UChar ucStart = 0;
+  for( UInt ui = 0; ui < 6 - uiDepth; ui++ )
+  {
+    m_pcTDecBinIf->decodeBinEP( uiSymbol );
+    ucStart |= (uiSymbol << ui);
+  }
+
+  // 3. Number of edges
+  UChar ucMax = 0;
+  for( UInt ui = 0; ui < 7 - uiDepth; ui++ )
+  {
+    m_pcTDecBinIf->decodeBinEP( uiSymbol );
+    ucMax |= (uiSymbol << ui);
+  }
+  ucMax++; // +1
+
+  // 4. Edges
+  UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
+  UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx );
+  for( Int iPtr = 0; iPtr < ucMax; iPtr++ )
+  {
+    UChar ucEdge = 0;
+    UInt  uiReorderEdge = 0;
+    // Left-friendly direction
+    // 0 (   0deg) => 0
+    // 1 (  45deg) => 10
+    // 2 ( -45deg) => 110
+    // 3 (  90deg) => 1110
+    // 4 ( -90deg) => 11110
+    // 5 ( 135deg) => 111110
+    // 6 (-135deg) => 111111
+    // Right-friendly direction
+    // 0 (   0deg) => 0
+    // 1 ( -45deg) => 10
+    // 2 (  45deg) => 110
+    // 3 ( -90deg) => 1110
+    // 4 (  90deg) => 11110
+    // 5 (-135deg) => 111110
+    // 6 ( 135deg) => 111111
+    // refer to a paper "An efficient chain code with Huffman coding"
+    for( UInt ui = 0; ui < 6; ui++ )
+    {
+      m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
+      ucEdge <<= 1;
+      ucEdge |= uiSymbol;
+      if( uiSymbol == 0 )
+        break;
+    }
+
+    switch( ucEdge )
+    {
+    case 0 :  // "0"
+      uiReorderEdge = 0;
+      break;
+    case 2 :  // "10"
+      uiReorderEdge = 1;
+      break;
+    case 6 :  // "110"
+      uiReorderEdge = 2;
+      break;
+    case 14 : // "1110"
+      uiReorderEdge = 3;
+      break;
+    case 30 : // "11110"
+      uiReorderEdge = 4;
+      break;
+    case 62 : // "111110"
+      uiReorderEdge = 5;
+      break;
+    case 63 : // "111111"
+      uiReorderEdge = 6;
+      break;
+    default :
+      printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge);
+      assert(false);
+      break;
+    }
+    pucSymbolList[iPtr] = uiReorderEdge;
+  }
+  /////////////////////
+  // Edge Reconstruction
+  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
+  pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion );
+  xFree( pucSymbolList );
+}
+#endif
+
 //! \}
Index: trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 81)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 100)
@@ -146,4 +146,8 @@
 #endif
   
+#if LGE_EDGE_INTRA
+  Void xParseEdgeIntraInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#endif
+  
 private:
   TComInputBitstream* m_pcBitstream;
@@ -253,4 +257,10 @@
   ContextModel3DBuffer m_cDmmDataSCModel;
 #endif
+#if LGE_EDGE_INTRA
+  ContextModel3DBuffer m_cEdgeIntraSCModel;
+#if LGE_EDGE_INTRA_DELTA_DC
+  ContextModel3DBuffer m_cEdgeIntraDeltaDCSCModel;
+#endif
+#endif
 };
 
Index: trunk/source/Lib/TLibDecoder/TDecSlice.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSlice.h	(revision 81)
+++ trunk/source/Lib/TLibDecoder/TDecSlice.h	(revision 100)
@@ -107,5 +107,5 @@
   ParameterSetMap<TComAPS> m_apsBuffer; 
 #if VIDYO_VPS_INTEGRATION
-	ParameterSetMap<TComVPS> m_vpsBuffer;
+  ParameterSetMap<TComVPS> m_vpsBuffer;
 #endif
 };
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 81)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 100)
@@ -176,11 +176,11 @@
   Void executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame,  Int& iPOCLastDisplay);
 
-  Void setViewId(Int viewId)					{ m_viewId = viewId;}
-  Int  getViewId()								       { return m_viewId  ;}
+  Void setViewId(Int viewId)      { m_viewId = viewId;}
+  Int  getViewId()                { return m_viewId  ;}
   Void setIsDepth( Bool isDepth ) { m_isDepth = isDepth; }
 
 #if SONY_COLPIC_AVAILABILITY
-  Void setViewOrderIdx(Int i)					{ m_iViewOrderIdx = i ;}
-  Int  getViewOrderIdx()							{ return m_iViewOrderIdx ; }
+  Void setViewOrderIdx(Int i)     { m_iViewOrderIdx = i ;}
+  Int  getViewOrderIdx()          { return m_iViewOrderIdx ; }
 #endif
 
@@ -209,5 +209,5 @@
 #endif
 #if VIDYO_VPS_INTEGRATION
-	Void      xDecodeVPS();
+  Void      xDecodeVPS();
 #endif
   Void      xDecodeSPS();
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 100)
@@ -378,5 +378,5 @@
 Void TEncCavlc::codeVPS( TComVPS* pcVPS )
 {
-	WRITE_CODE( pcVPS->getMaxTLayers() - 1,     3,        "max_temporal_layers_minus1" );
+  WRITE_CODE( pcVPS->getMaxTLayers() - 1,     3,        "max_temporal_layers_minus1" );
   WRITE_CODE( pcVPS->getMaxLayers() - 1,      5,        "max_layers_minus1" );
   WRITE_FLAG( pcVPS->getTemporalNestingFlag() - 1,      "temporal_id_nesting_flag" );
@@ -775,5 +775,4 @@
     {
       WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
-#if HHI_FIX
       if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV )
       {
@@ -848,7 +847,4 @@
       }
       if( pcSlice->getPOC() != 0 )
-#else
-      if( pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV )
-#endif
       {
         TComReferencePictureSet* rps = pcSlice->getRPS();
Index: trunk/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 100)
@@ -205,4 +205,9 @@
   UInt      m_uiVSOMode;
 #endif
+#if SAIT_VSO_EST_A0033
+  Bool      m_bUseEstimatedVSD; 
+  Double    m_dDispCoeff;
+#endif
+
 
   //====== Tool list ========
@@ -568,4 +573,9 @@
 #endif
 
+#if SAIT_VSO_EST_A0033
+  Void      setUseEstimatedVSD              ( Bool  b )     { m_bUseEstimatedVSD = b; }
+  Void      setDispCoeff                    ( Double  d )   { m_dDispCoeff  = d; }
+#endif
+
   Void      setUseFastEnc                   ( Bool  b )     { m_bUseFastEnc = b; }
   Void      setUseEarlyCU                   ( Bool  b )     { m_bUseEarlyCU = b; }
@@ -608,4 +618,9 @@
   Bool      getUseVSO                       ()      { return m_bUseVSO;     }
 #endif
+#if SAIT_VSO_EST_A0033
+  Bool      getUseEstimatedVSD              ()      { return m_bUseEstimatedVSD; }
+  Double    getDispCoeff                    ()      { return m_dDispCoeff;    }
+#endif
+
   Bool      getUseFastEnc                   ()      { return m_bUseFastEnc; }
   Bool      getUseEarlyCU                   ()      { return m_bUseEarlyCU; }
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 100)
@@ -1156,5 +1156,4 @@
       if( m_pcRdCost->getUseRenModel() )
       {
-#if HHI_FIX
         UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth ( );
         UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight( );
@@ -1162,11 +1161,4 @@
         UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
         m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-        UInt  uiWidth     = m_ppcBestCU[uiDepth]->getWidth ( 0 );
-        UInt  uiHeight    = m_ppcBestCU[uiDepth]->getHeight( 0 );
-        Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 );
-        UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
-        m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
       }
 #endif
@@ -1212,7 +1204,8 @@
 
 #if HHI_VSO
+#if HHI_VSO_SET_OPTIM 
+#else 
           if( m_pcRdCost->getUseRenModel() ) // necessary ??
           {
-#if HHI_FIX
             UInt  uiWidth     = m_ppcRecoYuvBest[uhNextDepth]->getWidth   (  );
             UInt  uiHeight    = m_ppcRecoYuvBest[uhNextDepth]->getHeight  (   );
@@ -1220,12 +1213,6 @@
             UInt  uiSrcStride = m_ppcRecoYuvBest[uhNextDepth]->getStride  (   );
             m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-            UInt  uiWidth     = pcSubBestPartCU->getWidth ( 0 );
-            UInt  uiHeight    = pcSubBestPartCU->getHeight( 0 );
-            Pel*  piSrc       = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getLumaAddr( 0 );
-            UInt  uiSrcStride = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getStride();
-            m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
-          }
+          }
+#endif
 #endif
         }
@@ -1369,5 +1356,4 @@
   if( m_pcRdCost->getUseRenModel() )
   {
-#if HHI_FIX
       UInt  uiWidth     = m_ppcRecoYuvBest[uiDepth]->getWidth   ( );
       UInt  uiHeight    = m_ppcRecoYuvBest[uiDepth]->getHeight  ( );
@@ -1375,11 +1361,4 @@
       UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride  ( );
       m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-    UInt  uiWidth     = rpcBestCU->getWidth ( 0 );
-    UInt  uiHeight    = rpcBestCU->getHeight( 0 );
-    Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
-    UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride();
-    m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
   }
 #endif
@@ -1747,5 +1726,4 @@
   if( m_pcRdCost->getUseRenModel() )
   {
-#if HHI_FIX
     UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
     UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
@@ -1753,11 +1731,4 @@
     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-    UInt  uiWidth     = rpcTempCU->getWidth ( 0 );
-    UInt  uiHeight    = rpcTempCU->getHeight( 0 );
-    Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
-    UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
-    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
   }
 #endif
@@ -1851,5 +1822,4 @@
           if( m_pcRdCost->getUseRenModel() )
           { //Reset
-#if HHI_FIX
             UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
             UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
@@ -1857,11 +1827,4 @@
             UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
             m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-            UInt  uiWidth     = rpcTempCU->getWidth ( 0 );
-            UInt  uiHeight    = rpcTempCU->getHeight( 0 );
-            Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
-            UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
-            m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
           }
 #endif
@@ -1927,5 +1890,4 @@
   if( m_pcRdCost->getUseRenModel() )
   {
-#if HHI_FIX
     UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
     UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
@@ -1933,11 +1895,4 @@
     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-    UInt  uiWidth     = rpcTempCU->getWidth ( 0 );
-    UInt  uiHeight    = rpcTempCU->getHeight( 0 );
-    Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
-    UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
-    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
   }
 #endif  
@@ -2046,5 +2001,4 @@
   if( m_pcRdCost->getUseRenModel() )
   {
-#if HHI_FIX
     UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ();
     UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ();
@@ -2052,11 +2006,4 @@
     UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ();
     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-    UInt  uiWidth     = rpcTempCU->getWidth ( 0 );
-    UInt  uiHeight    = rpcTempCU->getHeight( 0 );
-    Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr( );
-    UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
-    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
   }
 #endif
@@ -2557,5 +2504,4 @@
   if( m_pcRdCost->getUseRenModel() && !bRecursiveCall)
   {
-#if HHI_FIX
     UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth   ();
     UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight  ();
@@ -2563,11 +2509,4 @@
     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride  ();
     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-    UInt  uiWidth     = m_ppcTempCU [uhDepth]->getWidth ( 0 );
-    UInt  uiHeight    = m_ppcTempCU [uhDepth]->getHeight( 0 );
-    Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( 0 );
-    UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
-    m_pcRdCost->setRenModelData( m_ppcTempCU[uhDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
   }
 #endif
@@ -2717,5 +2656,4 @@
   if( !bSplit && bRecursiveCall && m_pcRdCost->getUseRenModel() )
   {
-#if HHI_FIX
     UInt  uiWidth     = m_ppcRecoYuvBest[uhDepth]->getWidth   (   );
     UInt  uiHeight    = m_ppcRecoYuvBest[uhDepth]->getHeight  (   );
@@ -2723,11 +2661,4 @@
     Pel*  piSrc       = m_ppcRecoYuvBest[uhDepth]->getLumaAddr( 0 );
     m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#else
-    UInt  uiWidth     = rpcBestCU->getWidth ( 0 );
-    UInt  uiHeight    = rpcBestCU->getHeight( 0 );
-    Pel*  piSrc       = m_ppcRecoYuvBest[uhDepth]->getLumaAddr( 0 );
-    UInt  uiSrcStride = m_ppcRecoYuvBest[uhDepth]->getStride();
-    m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-#endif
   }
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 100)
@@ -77,7 +77,7 @@
 
 #if VIDYO_VPS_INTEGRATION
-	virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
-#endif
-	
+  virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
+#endif
+
 #if HHI_MPI
   virtual Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth )                       = 0;
@@ -234,5 +234,5 @@
 public:
 #if VIDYO_VPS_INTEGRATION
-	Void encodeVPS               ( TComVPS* pcVPS);
+  Void encodeVPS               ( TComVPS* pcVPS);
 #endif
   // SPS
Index: trunk/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 100)
@@ -436,4 +436,7 @@
   Bool bUseVSO = m_pcEncTop->getUseVSO();
   m_pcRdCost->setUseVSO( bUseVSO );
+#if SAIT_VSO_EST_A0033
+  m_pcRdCost->setUseEstimatedVSD( m_pcEncTop->getUseEstimatedVSD() );
+#endif
 
   if ( bUseVSO )
@@ -445,4 +448,6 @@
 #endif
 
+#if HHI_VSO_SPEEDUP_A033
+#else
     if ( iVSOMode == 4 )
     {
@@ -453,4 +458,12 @@
       AOT(true); 
     }
+#endif
+
+#if SAIT_VSO_EST_A0033
+    m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->xGetPicYuvFromViewTemp( pcSlice->getViewId(), pcSlice->getPOC(), false, true ) );
+    m_pcRdCost->setDepthPicYuv   ( m_pcEncTop->getEncTop()->xGetPicYuvFromViewTemp( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) );
+#endif
+
+
   }
 #endif
@@ -691,5 +704,7 @@
       // init view component and predict virtual depth map
       m_pcDepthMapGenerator->initViewComponent( pcPic );
+#if !QC_MULTI_DIS_CAN
       m_pcDepthMapGenerator->predictDepthMap  ( pcPic );
+#endif
 #endif
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -758,6 +773,8 @@
 #endif
 #if DEPTH_MAP_GENERATION
+#if !QC_MULTI_DIS_CAN
       // update virtual depth map
       m_pcDepthMapGenerator->updateDepthMap( pcPic );
+#endif
 #endif
 
@@ -2475,18 +2492,18 @@
     if( hasModification )
     {
-	    Int temporalRefIdx = 0;
-	    for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++ )
-	    {
-	      if( tempListEntryL0[i] >= 0 ) 
-	      {
-	        refPicListModification->setRefPicSetIdxL0( i, tempListEntryL0[i] );
-	      }
-	      else
-	      {
-	        refPicListModification->setRefPicSetIdxL0( i, temporalRefIdx );
-	        temporalRefIdx++;
-	      }
-	    }
-	  }
+      Int temporalRefIdx = 0;
+      for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++ )
+      {
+        if( tempListEntryL0[i] >= 0 ) 
+        {
+          refPicListModification->setRefPicSetIdxL0( i, tempListEntryL0[i] );
+        }
+        else
+        {
+          refPicListModification->setRefPicSetIdxL0( i, temporalRefIdx );
+          temporalRefIdx++;
+        }
+      }
+    }
     else
     {
@@ -2520,17 +2537,17 @@
     if( hasModification )
     {
-	    Int temporalRefIdx = 0;
-	    for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++ )
-	    {
-	      if( tempListEntryL1[i] >= 0 ) 
-	      {
-	        refPicListModification->setRefPicSetIdxL1( i, tempListEntryL1[i] );
-	      }
-	      else
-	      {
-	        refPicListModification->setRefPicSetIdxL1( i, temporalRefIdx );
-	        temporalRefIdx++;
-	      }
-	    }
+      Int temporalRefIdx = 0;
+      for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++ )
+      {
+        if( tempListEntryL1[i] >= 0 ) 
+        {
+          refPicListModification->setRefPicSetIdxL1( i, tempListEntryL1[i] );
+        }
+        else
+        {
+          refPicListModification->setRefPicSetIdxL1( i, temporalRefIdx );
+          temporalRefIdx++;
+        }
+      }
     } 
     else
Index: trunk/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.h	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.h	(revision 100)
@@ -137,4 +137,7 @@
   
   Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits );
+#if HHI_VSO_SPEEDUP_A033
+  TEncTop* getEncTop() { return m_pcEncTop; }
+#endif
   
   TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
Index: trunk/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 100)
@@ -106,4 +106,10 @@
 , m_cDmmDataSCModel           ( 1,             1,               NUM_DMM_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
+#if LGE_EDGE_INTRA
+, m_cEdgeIntraSCModel         ( 1,             1,               NUM_EDGE_INTRA_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
+#if LGE_EDGE_INTRA_DELTA_DC
+, m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#endif
 {
   assert( m_numContextModels <= MAX_NUM_CTX_MOD );
@@ -181,4 +187,10 @@
   m_cDmmDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_DATA );
 #endif
+#if LGE_EDGE_INTRA
+  m_cEdgeIntraSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA );
+#if LGE_EDGE_INTRA_DELTA_DC
+  m_cEdgeIntraDeltaDCSCModel.initBuffer  ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA_DELTA_DC );
+#endif
+#endif
 
   // new structure
@@ -345,5 +357,5 @@
 Void TEncSbac::codeVPS( TComVPS* pcVPS )
 {
-	assert (0);
+  assert (0);
   return;
 }
@@ -828,4 +840,79 @@
   DTRACE_CABAC_T( "\n" )
 }
+
+#if LGE_EDGE_INTRA
+Void TEncSbac::xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx )
+{
+  UInt   uiDepth        = pcCU->getDepth( uiPartIdx ) + (pcCU->getPartitionSize( uiPartIdx ) == SIZE_NxN ? 1 : 0);
+  UInt   uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiPartIdx );
+  UChar* pucSymbolList  = pcCU->getEdgeCode( uiPartIdx );
+  UChar  ucEdgeNumber   = pcCU->getEdgeNumber( uiPartIdx );
+  Bool   bLeft          = pcCU->getEdgeLeftFirst( uiPartIdx );
+  UChar  ucStart        = pcCU->getEdgeStartPos( uiPartIdx );
+  UInt   uiSymbol;
+
+  // 1. Top(0) or Left(1)
+  uiSymbol = (bLeft == false) ? 0 : 1;
+  m_pcBinIf->encodeBinEP( uiSymbol );
+
+  // 2. Start position (lowest bit first)
+  uiSymbol = ucStart;
+  for( UInt ui = 6; ui > uiDepth; ui-- ) // 64(0)->6, 32(1)->5, 16(2)->4, 8(3)->3, 4(4)->2
+  {
+    m_pcBinIf->encodeBinEP( uiSymbol & 0x1 );
+    uiSymbol >>= 1;
+  }
+
+  // 3. Number of edges
+  uiSymbol = ucEdgeNumber > 0 ? ucEdgeNumber - 1 : 0;
+  for( UInt ui = 7; ui > uiDepth; ui-- ) // 64(0)->7, 32(1)->6, 16(2)->5, 8(3)->4, 4(4)->3
+  {
+    m_pcBinIf->encodeBinEP( uiSymbol & 0x1 );
+    uiSymbol >>= 1;
+  }
+
+  if(uiSymbol != 0)
+  {
+    printf(" ucEdgeNumber %d at depth %d\n",ucEdgeNumber, uiDepth);
+    assert(false);
+  }
+
+  // 4. Edges
+  for( Int iPtr2 = 0; iPtr2 < ucEdgeNumber; iPtr2++ )
+  {
+    UInt uiReorderSymbol = pucSymbolList[iPtr2];
+
+    //printf ("Ptr = %d, Symbol = %d\n", iPtr2, uiSymbol);
+
+    // Left-friendly direction (Top start)
+    // 0 (   0deg) => 0
+    // 1 (  45deg) => 10
+    // 2 ( -45deg) => 110
+    // 3 (  90deg) => 1110
+    // 4 ( -90deg) => 11110
+    // 5 ( 135deg) => 111110
+    // 6 (-135deg) => 111111
+    // Right-friendly direction (Left start)
+    // 0 (   0deg) => 0
+    // 2 ( -45deg) => 10
+    // 1 (  45deg) => 110
+    // 4 ( -90deg) => 1110
+    // 3 (  90deg) => 11110
+    // 6 (-135deg) => 111110
+    // 5 ( 135deg) => 111111
+
+    // refer to a paper "An efficient chain code with Huffman coding"
+
+    for( UInt ui = 0; ui < uiReorderSymbol; ui++ )
+    {
+      m_pcBinIf->encodeBin( 1, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
+    }
+
+    if( uiReorderSymbol != 6 )
+      m_pcBinIf->encodeBin( 0, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
+  }
+}
+#endif
+
 Void TEncSbac::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
@@ -835,7 +922,15 @@
   if( pcCU->getSlice()->getSPS()->getUseDMM() && pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE )
   {
+#if LGE_EDGE_INTRA
+    m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX, m_cDmmFlagSCModel.get(0, 0, 0) );
+#else
     m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE, m_cDmmFlagSCModel.get(0, 0, 0) );
-  }
+#endif
+  }
+#if LGE_EDGE_INTRA
+  if( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX )
+#else
   if( uiDir >= NUM_INTRA_MODE )
+#endif
   {
     assert( pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE );
@@ -870,8 +965,47 @@
   }
   else
+#if LGE_EDGE_INTRA
+    if ( uiDir >= EDGE_INTRA_IDX)
+    {
+      m_pcBinIf->encodeBin( 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) );
+      m_pcBinIf->encodeBinsEP( 63, 6 );
+      xCodeEdgeIntraInfo( pcCU, uiAbsPartIdx );
+#if LGE_EDGE_INTRA_DELTA_DC
+      m_pcBinIf->encodeBin( (uiDir == EDGE_INTRA_DELTA_IDX), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) );
+      if( uiDir == EDGE_INTRA_DELTA_IDX )
+      {
+        Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx );
+        Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx );
+
+        xWriteExGolombLevel( UInt( abs( iDeltaDC0 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
+        if ( iDeltaDC0 != 0 )
+        {
+          UInt uiSign = iDeltaDC0 > 0 ? 0 : 1;
+          m_pcBinIf->encodeBinEP( uiSign );
+        }
+        xWriteExGolombLevel( UInt( abs( iDeltaDC1 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
+        if ( iDeltaDC1 != 0 )
+        {
+          UInt uiSign = iDeltaDC1 > 0 ? 0 : 1;
+          m_pcBinIf->encodeBinEP( uiSign );
+        }
+      }
+#endif
+    }
+    else
+#endif // LGE_EDGE_INTRA
   {
 #endif
 #if !LOGI_INTRA_NAME_3MPM
   Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
+#endif
+#if LGE_EDGE_INTRA
+  Bool bCodeEdgeIntra = false;
+  if( pcCU->getSlice()->getSPS()->isDepth() )
+  {
+    UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0);
+    if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE )
+      bCodeEdgeIntra = true;
+  }
 #endif
   
@@ -932,4 +1066,8 @@
 #if LOGI_INTRA_NAME_3MPM
     m_pcBinIf->encodeBinsEP( uiDir, 5 );
+#if LGE_EDGE_INTRA
+  if (bCodeEdgeIntra)
+    if (uiDir == 31) m_pcBinIf->encodeBinsEP(0,1);
+#endif
 #else
     if ( uiDir < 31 )
@@ -2270,5 +2408,5 @@
 }
 
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC)
 Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel  )
 {
Index: trunk/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 100)
@@ -101,5 +101,5 @@
   Void  codeVPS                 ( TComVPS* pcVPS );
 #endif
-	
+  
 #if HHI_MPI
   Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth );
@@ -174,4 +174,7 @@
   Void  xCodeWedgePredTexDeltaInfo  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void  xCodeContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx );
+#endif
+#if LGE_EDGE_INTRA
+  Void  xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx );
 #endif
 
@@ -307,4 +310,10 @@
   ContextModel3DBuffer m_cDmmDataSCModel;
 #endif
+#if LGE_EDGE_INTRA
+  ContextModel3DBuffer m_cEdgeIntraSCModel;
+#if LGE_EDGE_INTRA_DELTA_DC
+  ContextModel3DBuffer m_cEdgeIntraDeltaDCSCModel;
+#endif
+#endif
 };
 
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 100)
@@ -304,5 +304,5 @@
   // motion cost
   uiSad += m_pcRdCost->getCost( iSearchX, iSearchY );
-#if HHI_FIX  
+
   // regularization cost
   if( m_pcRdCost->useMultiviewReg() )
@@ -310,5 +310,4 @@
     uiSad += m_pcRdCost->getMultiviewRegCost( iSearchX, iSearchY );
   }
-#endif
   if( uiSad < rcStruct.uiBestSad )
   {
@@ -957,5 +956,9 @@
                                 TComYuv*    pcPredYuv, 
                                 TComYuv*    pcResiYuv, 
-                                Dist&       ruiDist )
+                                Dist&       ruiDist 
+#if LG_ZEROINTRADEPTHRESI_M26039
+                                ,Bool        bZeroResi
+#endif
+                                )
 {
   UInt    uiLumaPredMode    = pcCU     ->getLumaIntraDir     ( uiAbsPartIdx );
@@ -989,4 +992,21 @@
   pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
   
+#if LGE_EDGE_INTRA
+  if( uiLumaPredMode >= EDGE_INTRA_IDX )
+  {
+#if LGE_EDGE_INTRA_DELTA_DC
+    if( uiLumaPredMode == EDGE_INTRA_DELTA_IDX )
+      xAssignEdgeIntraDeltaDCs( pcCU, uiAbsPartIdx, piOrg, uiStride, piPred, uiWidth, uiHeight );
+#endif
+
+    predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride
+#if LGE_EDGE_INTRA_DELTA_DC
+     , uiLumaPredMode == EDGE_INTRA_DELTA_IDX
+#endif
+    );
+  }
+  else
+#endif
+  
   //===== get prediction signal =====
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
@@ -1020,4 +1040,16 @@
     }
   }
+#if LG_ZEROINTRADEPTHRESI_M26039
+  if(bZeroResi)
+  {
+    Pel* pResi = piResi;
+
+    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
+    {
+      memset( pResi, 0, sizeof( Pel ) * uiWidth );
+      pResi += uiStride;
+    }
+  }
+#endif
   
   //===== transform and quantization =====
@@ -1311,5 +1343,9 @@
                                 Bool         bCheckFirst,
 #endif
-                                Double&      dRDCost )
+                                Double&      dRDCost 
+#if LG_ZEROINTRADEPTHRESI_M26039
+                               ,Bool         bZeroResi
+#endif
+                              )
 {
   UInt    uiFullDepth   = pcCU->getDepth( 0 ) +  uiTrDepth;
@@ -1326,4 +1362,10 @@
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
   if( pcCU->getLumaIntraDir( uiAbsPartIdx ) >= NUM_INTRA_MODE )
+  {
+    bCheckSplit = false;
+  }
+#endif
+#if LGE_EDGE_INTRA
+  if( pcCU->getLumaIntraDir( uiAbsPartIdx ) >= EDGE_INTRA_IDX )
   {
     bCheckSplit = false;
@@ -1346,5 +1388,9 @@
     //----- code luma block with given intra prediction mode and store Cbf-----
     dSingleCost   = 0.0;
+#if LG_ZEROINTRADEPTHRESI_M26039
+    xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY, bZeroResi ); 
+#else
     xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY ); 
+#endif
     if( bCheckSplit )
     {
@@ -1808,4 +1854,19 @@
     Int numModesForFullRD = g_aucIntraModeNumFast[ uiWidthBit ];
     
+#if LGE_EDGE_INTRA
+  Bool bTestEdgeIntra = false;
+  if ( m_pcEncCfg->isDepthCoder() && uiWidth >= LGE_EDGE_INTRA_MIN_SIZE && uiWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiWidth == uiHeight )
+  {
+    bTestEdgeIntra = true;
+
+    Bool bEdgeExist;
+
+    bEdgeExist = xEdgePartition( pcCU, uiPartOffset, pcCU->getPartitionSize(0) == SIZE_NxN );
+
+    if( !bEdgeExist )
+      bTestEdgeIntra = false;
+  }
+#endif
+    
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     Bool bTestDmm = ( m_pcEncCfg->getUseDMM() );
@@ -1828,42 +1889,58 @@
 
         predIntraLumaAng( pcCU->getPattern(), uiMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
-        
+
         // use hadamard transform here
-      Dist uiSad;
+        Dist uiSad;
 #if HHI_VSO
-      if ( m_pcRdCost->getUseVSO() )
-      {
-        Bool bSad = !m_pcRdCost->getUseRenModel();
-        uiSad = m_pcRdCost->getDistVS(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, bSad, 0 );
-      }
-      else
-#endif
-      {
-        uiSad = (Dist) m_pcRdCost->calcHAD( piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
-      }
-        
+        if ( m_pcRdCost->getUseVSO() )
+        {
+#if SAIT_VSO_EST_A0033
+          if ( m_pcRdCost->getUseEstimatedVSD() )
+          {          
+            TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
+            TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
+
+            uiSad = (Dist) ( m_pcRdCost->getDistPart( piPred, uiStride, piOrg, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset), pcVirRec->getStride(), uiWidth, uiHeight ) );
+          }
+          else
+#endif
+          {          
+            Bool bSad = !m_pcRdCost->getUseRenModel();
+            uiSad = m_pcRdCost->getDistVS(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, bSad, 0 );
+          }
+
+        }
+        else
+#endif
+        {
+          uiSad = (Dist) m_pcRdCost->calcHAD( piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
+        }
+
         UInt   iModeBits = xModeBitsIntra( pcCU, uiMode, uiPU, uiPartOffset, uiDepth, uiInitTrDepth );
 
-      Double dLambda;
+        Double dLambda;
 #if HHI_VSO
-      if ( m_pcRdCost->getUseLambdaScaleVSO() )
-      {
-        dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO();
-        //GT: Sad is SSE for VSO4
-      }
-      else
-      {
+        if ( m_pcRdCost->getUseLambdaScaleVSO() )
+        {
+          dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO();
+          //GT: Sad is SSE for VSO4
+        }
+        else
+        {
+          dLambda = m_pcRdCost->getSqrtLambda();
+        }
+#else
         dLambda = m_pcRdCost->getSqrtLambda();
-      }
-#else
-      dLambda = m_pcRdCost->getSqrtLambda();
-#endif
-
-      Double cost = (Double)uiSad + (Double)iModeBits *  dLambda;
-        
+#endif
+
+        Double cost = (Double)uiSad + (Double)iModeBits *  dLambda;
+
         CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
         if( bTestDmm ) bTestDmm = uiSad ? true : false;
+#endif
+#if LGE_EDGE_INTRA
+        if ( bTestEdgeIntra ) bTestEdgeIntra = uiSad ? true : false;
 #endif
       }
@@ -1974,4 +2051,13 @@
     }
 #endif
+#if LGE_EDGE_INTRA
+  if( bTestEdgeIntra )
+  {
+    uiRdModeList[ numModesForFullRD++ ] = EDGE_INTRA_IDX;
+#if LGE_EDGE_INTRA_DELTA_DC
+    uiRdModeList[ numModesForFullRD++ ] = EDGE_INTRA_DELTA_IDX;
+#endif
+  }
+#endif
 
     //===== check modes (using r-d costs) =====
@@ -1987,9 +2073,19 @@
     for( UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ )
     {
+#if LG_ZEROINTRADEPTHRESI_M26039
+    Bool bAllowZeroResi = pcCU->getSlice()->getIsDepth() && (pcCU->getSlice()->getPOC()%pcCU->getPic()->getIntraPeriod());// && (uiMode < NUM_INTRA_MODE);
+    for(UInt uiCnt = 0; uiCnt < (bAllowZeroResi ? 2 : 1); uiCnt++)
+    {
+      Bool bZeroResi = uiCnt ? true : false;
+#endif
       // set luma prediction mode
       UInt uiOrgMode = uiRdModeList[uiMode];
-      
+
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-      if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) )
+      if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) 
+#if LGE_EDGE_INTRA
+        && uiOrgMode < EDGE_INTRA_IDX
+#endif
+        )
       {
         continue;
@@ -2020,5 +2116,9 @@
 
 #if HHI_RQT_INTRA_SPEEDUP
+#if LG_ZEROINTRADEPTHRESI_M26039
+      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost, bZeroResi );
+#else
       xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost );
+#endif
 #else
       xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost );
@@ -2052,4 +2152,7 @@
         dSecondBestPUCost = dPUCost;
       }
+#endif
+#if LG_ZEROINTRADEPTHRESI_M26039
+    }
 #endif
     } // Mode loop
@@ -2579,31 +2682,31 @@
       pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
 #if LG_RESTRICTEDRESPRED_M24766
-	  Int iAddResiShift;
-	  UInt uiPartAddr;
-	  Int iRoiWidth, iRoiHeight;
-
-	  pcCU->getPartIndexAndSize( iPUIdx, uiPartAddr, iRoiWidth, iRoiHeight );
-	  iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
-	  iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1 - iAddResiShift : -1);
-
-	  if( pcCU->getResPredFlag( 0 ))
-	  { // subtract residual prediction from original in motion search
-		  if(iLastAddResiShift != iAddResiShift)
-		  {
-			  //add subtracted residual last time
-			  if(iLastAddResiShift >= 0)
-			  {
-				  iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
-				  pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
-			  }
-			  //subtract residual
-			  if(iAddResiShift >= 0)
-			  {
-				  iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift;
-				  pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
-			  }
-			  iLastAddResiShift = iAddResiShift;
-		  }
-	  }
+      Int iAddResiShift;
+      UInt uiPartAddr;
+      Int iRoiWidth, iRoiHeight;
+
+      pcCU->getPartIndexAndSize( iPUIdx, uiPartAddr, iRoiWidth, iRoiHeight );
+      iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
+      iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1 - iAddResiShift : -1);
+
+      if( pcCU->getResPredFlag( 0 ))
+      { // subtract residual prediction from original in motion search
+        if(iLastAddResiShift != iAddResiShift)
+        {
+          //add subtracted residual last time
+          if(iLastAddResiShift >= 0)
+          {
+            iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
+            pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
+          }
+          //subtract residual
+          if(iAddResiShift >= 0)
+          {
+            iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift;
+            pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
+          }
+          iLastAddResiShift = iAddResiShift;
+        }
+      }
 #endif
       xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
@@ -2631,6 +2734,6 @@
   if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0)
   {
-	  iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
-	  pcYuvOrg->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
+    iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
+    pcYuvOrg->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
   }
 #endif
@@ -2755,5 +2858,5 @@
     UInt          uiBitsTempL0[MAX_NUM_REF];
 #if LG_RESTRICTEDRESPRED_M24766
-	Int iPUResiPredShift[4] = {0, 0, 0, 0};
+    Int iPUResiPredShift[4] = {0, 0, 0, 0};
 #endif
     xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
@@ -2773,5 +2876,5 @@
 #endif
 #if LG_RESTRICTEDRESPRED_M24766
-		Bool bLastResiFlag = false;
+      Bool bLastResiFlag = false;
 #endif
     //  Uni-directional prediction
@@ -2783,19 +2886,19 @@
       {
 #if LG_RESTRICTEDRESPRED_M24766
-		  if( pcCU->getResPredFlag( 0 ))
-		  {
-			  if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
-			  { // subtract residual prediction from original in motion search
-				  if(!bLastResiFlag)
-					  pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
-				  bLastResiFlag = true;
-			  }
-			  else
-			  {
-				  if(bLastResiFlag)
-					  pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
-				  bLastResiFlag = false;
-			  }
-		  }
+        if( pcCU->getResPredFlag( 0 ))
+        {
+          if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
+          { // subtract residual prediction from original in motion search
+            if(!bLastResiFlag)
+              pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
+            bLastResiFlag = true;
+          }
+          else
+          {
+            if(bLastResiFlag)
+              pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
+            bLastResiFlag = false;
+          }
+        }
 #endif
         uiBitsTemp = uiMbBits[iRefList];
@@ -2963,8 +3066,8 @@
     }
 #if LG_RESTRICTEDRESPRED_M24766
-	if( pcCU->getResPredFlag( 0 ) && bLastResiFlag)
-	{ // subtract residual prediction from original in motion search
-		pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
-	}
+    if( pcCU->getResPredFlag( 0 ) && bLastResiFlag)
+    { // subtract residual prediction from original in motion search
+      pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
+    }
 #endif
     //  Bi-directional prediction
@@ -2972,5 +3075,5 @@
     {
 #if LG_RESTRICTEDRESPRED_M24766
-		Int iLastAddResiShift = -1000;
+      Int iLastAddResiShift = -1000;
 #endif
       cMvBi[0] = cMv[0];            cMvBi[1] = cMv[1];
@@ -3077,33 +3180,33 @@
 #endif
 #if LG_RESTRICTEDRESPRED_M24766
-		  Int iAddResiShift = -1, iPredFrom = 0;
-		  Int iBestRefIdx = pcCU->getCUMvField(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
-
-		  iPredFrom = iBestRefIdx >= 0 ? 3 : 1;
-		  if(iBestRefIdx >= 0 && pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx))
-			  iAddResiShift++;
-		  if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
-			  iAddResiShift++;
-		  iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || iPredFrom != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
-
-		  if( pcCU->getResPredFlag( 0 ) )
-		  {
-			  if(iLastAddResiShift != iAddResiShift)
-			  {
-				  //add substracted residual last time
-				  if(iLastAddResiShift >= 0 )
-				  {
-					  iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
-					  pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
-				  }
-				  //substract residual
-				  if(iAddResiShift >= 0)
-				  {
-					  iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift;
-					  pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
-				  }
-				  iLastAddResiShift = iAddResiShift;
-			  }
-		  }
+          Int iAddResiShift = -1, iPredFrom = 0;
+          Int iBestRefIdx = pcCU->getCUMvField(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
+
+          iPredFrom = iBestRefIdx >= 0 ? 3 : 1;
+          if(iBestRefIdx >= 0 && pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx))
+            iAddResiShift++;
+          if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
+            iAddResiShift++;
+          iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || iPredFrom != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
+
+          if( pcCU->getResPredFlag( 0 ) )
+          {
+            if(iLastAddResiShift != iAddResiShift)
+            {
+              //add substracted residual last time
+              if(iLastAddResiShift >= 0 )
+              {
+                iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
+                pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
+              }
+              //substract residual
+              if(iAddResiShift >= 0)
+              {
+                iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift;
+                pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
+              }
+              iLastAddResiShift = iAddResiShift;
+            }
+          }
 #endif
           // call ME
@@ -3162,9 +3265,9 @@
       } // for loop-iter
 #if LG_RESTRICTEDRESPRED_M24766
-	  if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0)
-	  {
-		  iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
-		  pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
-	  }
+      if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0)
+      {
+        iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
+        pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
+      }
 #endif
     } // if (B_SLICE)
@@ -3375,19 +3478,19 @@
       {
 #if LG_RESTRICTEDRESPRED_M24766
-		  Int iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
-		  iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = \
-			  (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3)? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
-		  if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
-		  {
-			  pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true);
-		  }
+        Int iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
+        iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = \
+          (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3)? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
+        if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
+        {
+          pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true);
+        }
 #endif
         xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiMEError, m_pcEncCfg->getUseHADME() );
         uiMECost = uiMEError + m_pcRdCost->getCost( uiMEBits );
 #if LG_RESTRICTEDRESPRED_M24766
-		if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
-		{
-			pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
-		}
+        if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
+        {
+          pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
+        }
 #endif
       }
@@ -3871,9 +3974,5 @@
   else
   {
-#if HHI_FIX
     rcMv = ( m_pcRdCost->useMultiviewReg() ? m_pcRdCost->getMultiviewOrgMvPred() : *pcMvPred );
-#else
-    rcMv = *pcMvPred;
-#endif
     xPatternSearchFast  ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
   }
@@ -3977,5 +4076,4 @@
       uiSad += m_pcRdCost->getCost( x, y );
       
-#if HHI_FIX 
       // regularization cost
       if( m_pcRdCost->useMultiviewReg() )
@@ -3983,5 +4081,4 @@
         uiSad += m_pcRdCost->getMultiviewRegCost( x, y );
       }
-#endif
 
       if ( uiSad < uiSadBest )
@@ -4281,6 +4378,6 @@
     {
 #if LG_RESTRICTEDRESPRED_M24766
-		pcCU->getPUResiPredShift(iPUResiPredShift, 0);
-		rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd, uiWidth, uiHeight );
+      pcCU->getPUResiPredShift(iPUResiPredShift, 0);
+      rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd, uiWidth, uiHeight );
 #else
       rpcYuvRec->add( rpcYuvResPrd, uiWidth, uiHeight );
@@ -4294,5 +4391,5 @@
     {
       uiDistortion = m_pcRdCost->getDistVS( pcCU, 0, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight     , false, 0 );
-	}
+    }
     else    
     {
@@ -4349,7 +4446,12 @@
     pcCU->setTrIdxSubParts( 0, 0, pcCU->getDepth(0) );
     
+
 #if HHI_VSO // necessary? 
     // set Model
+#if SAIT_VSO_EST_A0033
+    if( !m_pcRdCost->getUseEstimatedVSD()&& m_pcRdCost->getUseRenModel() )
+#else
     if( m_pcRdCost->getUseRenModel() )
+#endif
     {
       Pel*  piSrc       = rpcYuvRec->getLumaAddr();
@@ -4395,6 +4497,6 @@
   {
 #if LG_RESTRICTEDRESPRED_M24766
-	  iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
-	  rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), pcYuvOrg, pcYuvPred, 0, uiWidth );
+    iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
+    rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), pcYuvOrg, pcYuvPred, 0, uiWidth );
 #else
   rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth );
@@ -4405,6 +4507,6 @@
     {
 #if LG_RESTRICTEDRESPRED_M24766
-		pcCU->getPUResiPredShift(iPUResiPredShift, 0);
-		rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResi, rpcYuvResPrd, 0, uiWidth );
+      pcCU->getPUResiPredShift(iPUResiPredShift, 0);
+      rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResi, rpcYuvResPrd, 0, uiWidth );
 #else
       rpcYuvResi->subtract( rpcYuvResi, rpcYuvResPrd, 0, uiWidth );
@@ -4579,7 +4681,11 @@
     }
 
+
 #if HHI_VSO
-    // GT: reset Model, only fordQP necessary??
+#if SAIT_VSO_EST_A0033    
+    if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
+#else
     if( m_pcRdCost->getUseRenModel() )
+#endif
     {
       Pel*  piSrc       = pcYuvOrg->getLumaAddr();
@@ -4624,7 +4730,7 @@
     pcYuvPred->copyToPartYuv( rpcYuvRec, 0 );
 #if LG_RESTRICTEDRESPRED_M24766
-	pcCU->getPUResiPredShift(iPUResiPredShift, 0);
-	rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd,   uiWidth, uiHeight );
-	iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
+    pcCU->getPUResiPredShift(iPUResiPredShift, 0);
+    rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd,   uiWidth, uiHeight );
+    iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
     rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResiBest, uiWidth, uiHeight );
 #else
@@ -4685,6 +4791,11 @@
 
   // set Model
+
 #if HHI_VSO // necessary??
+#if SAIT_VSO_EST_A0033    
+  if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
+#else
   if( m_pcRdCost->getUseRenModel() )
+#endif
   {
     Pel*  piSrc       = rpcYuvRec->getLumaAddr();
@@ -4693,5 +4804,4 @@
 }
 #endif
-
 }
 
@@ -4869,5 +4979,16 @@
     if ( m_pcRdCost->getUseVSO() )
     {
-      uiDistY = m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, pcPred->getLumaAddr( uiAbsPartIdx ), pcPred->getStride(), pcOrg->getLumaAddr( uiAbsPartIdx), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); // initialized with zero residual distortion
+#if SAIT_VSO_EST_A0033
+      if( m_pcRdCost->getUseEstimatedVSD() )
+      {
+        TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
+        TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
+        uiDistY = m_pcRdCost->getDistPart( m_pTempPel, 1<< uiLog2TrSize, pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPartIdx), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPartIdx), pcVirRec->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize );
+      }
+      else
+#endif
+      {      
+        uiDistY = m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, pcPred->getLumaAddr( uiAbsPartIdx ), pcPred->getStride(), pcOrg->getLumaAddr( uiAbsPartIdx), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); // initialized with zero residual distortion
+      }
     }
     else
@@ -4880,5 +5001,4 @@
 #endif
     }
-
 
     if ( puiZeroDist )
@@ -4909,9 +5029,18 @@
       if ( m_pcRdCost->getUseVSO() )
       {
-        static int iCount = 1; 
-        iCount++; 
-        m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize  );
-        uiNonzeroDistY = m_pcRdCost->getDistVS( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(),
-                                                pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize,   1<< uiLog2TrSize, false, 0 );
+#if SAIT_VSO_EST_A0033
+        if ( m_pcRdCost->getUseEstimatedVSD() )
+        {          
+          TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
+          TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
+          uiNonzeroDistY = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( uiAbsPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), pcVirRec->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiAbsPartIdx ), pcVirOrg->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiAbsPartIdx ), pcVirRec->getStride(), 1<< uiLog2TrSize,    1<< uiLog2TrSize );
+        }
+        else
+#endif
+        {        
+          m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize  );
+          uiNonzeroDistY = m_pcRdCost->getDistVS( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(),
+                                                  pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize,   1<< uiLog2TrSize, false, 0 );
+        }
       }
       else
@@ -5307,6 +5436,11 @@
   }
 
+
 #if HHI_VSO
+#if SAIT_VSO_EST_A0033
+  if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
+#else
   if ( m_pcRdCost->getUseRenModel() ) //Only done if not split ( see return above )
+#endif
   {
     UInt  uiWidth     = 1<< uiLog2TrSize;
@@ -5977,6 +6111,20 @@
 
         assignWedgeDCs2Pred( pcWedgelet, piPredic, uiStride, iTestDC1, iTestDC2 );
-
-        Dist uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride,  piOrig, uiStride, uiWidth, uiHeight, false, 0 );
+        
+        Dist uiActDist = RDO_DIST_MAX;
+#if SAIT_VSO_EST_A0033
+        if ( m_pcRdCost->getUseEstimatedVSD() )
+        {          
+          TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
+          TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
+          uiActDist = m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight );
+        }
+        else       
+#else
+        {        
+          uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride,  piOrig, uiStride, uiWidth, uiHeight, false, 0 );
+        }
+#endif
+
         if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
         {
@@ -6078,5 +6226,16 @@
     if( m_pcRdCost->getUseVSO() )
     {
-      uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
+#if SAIT_VSO_EST_A0033
+      if ( m_pcRdCost->getUseEstimatedVSD() )
+      {          
+        TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
+        TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
+        uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight );
+      }
+      else
+#endif
+      {      
+        uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
+      }
     }
     else
@@ -6133,5 +6292,16 @@
     if( m_pcRdCost->getUseVSO() )
     {
-      uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
+#if SAIT_VSO_EST_A0033
+      if ( m_pcRdCost->getUseEstimatedVSD() )
+      {          
+        TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
+        TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
+        uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPtIdx), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPtIdx), pcVirRec->getStride(), uiWidth, uiHeight );
+      }
+      else
+#endif
+      {      
+        uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
+      }
     }
     else
@@ -6207,3 +6377,1113 @@
 }
 #endif
+
+#if LGE_EDGE_INTRA
+Bool TEncSearch::xCheckTerminatedEdge( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight )
+{
+  if( (iY % 2) == 0 ) // vertical edge
+  {
+    Bool bTopConnected = false;
+    Bool bBottomConnected = false;
+
+    if( iY != 0 )
+    {
+      if( pbEdge[ iX + (iY - 2) * 2 * iWidth ] )
+        bTopConnected = true;
+      if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] )
+        bTopConnected = true;
+      if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] )
+        bTopConnected = true;
+    }
+    else
+    {
+      bTopConnected = true;
+    }
+
+
+    if( iY != 2 * iHeight - 2 )
+    {
+      if( pbEdge[ iX + (iY + 2) * 2 * iWidth ] )
+        bBottomConnected = true;
+      if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] )
+        bBottomConnected = true;
+      if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] )
+        bBottomConnected = true;
+    }
+    else
+    {
+      bBottomConnected = true;
+    }
+
+
+    if( bTopConnected && bBottomConnected )
+    {
+      return true;
+    }
+    else
+    {
+      return false;
+    }
+  }
+  else
+  {
+    Bool bLeftConnected = false;
+    Bool bRightConnected = false;
+
+    if( iX != 0 )
+    {
+      if( pbEdge[ (iX - 2) + iY * 2 * iWidth ] )
+        bLeftConnected = true;
+      if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] )
+        bLeftConnected = true;
+      if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] )
+        bLeftConnected = true;
+    }
+    else
+    {
+      bLeftConnected = true;
+    }
+
+    if( iX != 2 * iWidth - 2 )
+    {
+      if( pbEdge[ (iX + 2) + iY * 2 * iWidth ] )
+        bRightConnected = true;
+      if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] )
+        bRightConnected = true;
+      if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] )
+        bRightConnected = true;
+    }
+    else
+    {
+      bRightConnected = true;
+    }
+
+
+    if( bLeftConnected && bRightConnected )
+    {
+      return true;
+    }
+    else
+    {
+      return false;
+    }
+  }
+}
+
+#if LGE_EDGE_INTRA_PIXEL_DIFFERENCE
+Bool TEncSearch::xEdgePartition( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 )
+{
+  Pel* pcOrgY   = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr());
+  UInt uiStride = pcCU->getPic()->getPicYuvOrg()->getStride();
+  Int iWidth    = pcCU->getWidth(uiPartIdx) >> (bPU4x4 ? 1 : 0);
+  Int iHeight   = pcCU->getHeight(uiPartIdx) >> (bPU4x4 ? 1 : 0);
+  Bool* pbEdge  = (Bool*) xMalloc( Bool, iWidth * iHeight * 4 );
+
+  {
+    UInt uiOffsetX = 0;
+    UInt uiOffsetY = 0;
+    UInt uiAbsPartIdx = pcCU->getZorderIdxInCU() + uiPartIdx;
+
+    uiOffsetX =  (uiAbsPartIdx & 0x1) |
+      ((uiAbsPartIdx & 0x4)  >> 1) |
+      ((uiAbsPartIdx & 0x10) >> 2) |
+      ((uiAbsPartIdx & 0x40) >> 3);
+    uiOffsetY = ((uiAbsPartIdx & 0x2)  >> 1) |
+      ((uiAbsPartIdx & 0x8)  >> 2) |
+      ((uiAbsPartIdx & 0x20) >> 3) |
+      ((uiAbsPartIdx & 0x80) >> 4);
+    uiOffsetX *= 4;
+    uiOffsetY *= 4;
+    pcOrgY += (uiOffsetX + uiOffsetY * uiStride);
+
+  }
+
+  Short* psDiffX = new Short[ iWidth * iHeight ];
+  Short* psDiffY = new Short[ iWidth * iHeight ];
+  Bool*  pbEdgeX = new Bool [ iWidth * iHeight ];
+  Bool*  pbEdgeY = new Bool [ iWidth * iHeight ];
+
+  // Find Horizontal Gradient & Edge Detection ((x+1, y) - (x,y))
+  for( Int y=0; y<iHeight; y++ )
+  {
+    Short* psDiffXPtr = &psDiffX[ y * iHeight ];
+    Bool*  pbEdgeXPtr = &pbEdgeX[ y * iHeight ];
+    for(Int x=0; x<iWidth-1; x++ )
+    {
+      *psDiffXPtr = pcOrgY[ x+1 + y*uiStride ] - pcOrgY[ x + y*uiStride ];
+      if(*psDiffXPtr >= LGE_EDGE_INTRA_THRESHOLD || *psDiffXPtr <= (-1)*LGE_EDGE_INTRA_THRESHOLD)
+      {
+        *pbEdgeXPtr = true;
+      }
+      else
+      {
+        *pbEdgeXPtr = false;
+      }
+
+      psDiffXPtr++;
+      pbEdgeXPtr++;
+    }
+  }
+
+  // Find Vertical Gradient & Edge Detection((x,y+1) - (x,y))
+  for( Int y=0; y<iHeight-1; y++ )
+  {
+    Short* psDiffYPtr = &psDiffY[ y * iHeight ];
+    Bool*  pbEdgeYPtr = &pbEdgeY[ y * iHeight ];
+    for(Int x=0; x<iWidth; x++ )
+    {
+      *psDiffYPtr = pcOrgY[ x + (y+1)*uiStride ] - pcOrgY [ x + y*uiStride ];
+      if(*psDiffYPtr >= LGE_EDGE_INTRA_THRESHOLD || *psDiffYPtr <= (-1)*LGE_EDGE_INTRA_THRESHOLD)
+      {
+        *pbEdgeYPtr = true;
+      }
+      else
+      {
+        *pbEdgeYPtr = false;
+      }
+
+      psDiffYPtr++;
+      pbEdgeYPtr++;
+    }
+  }
+
+  // Eliminate local maximum
+  for( Int y=0; y<iHeight; y++ )
+  {
+    Short* psDiffXPtr = &psDiffX[ y * iHeight ];
+    Bool*  pbEdgeXPtr = &pbEdgeX[ y * iHeight ];
+    for( Int x=0; x<iWidth-1; x++ )
+    {
+      UShort usAbs0=0, usAbs1=0, usAbs2=0;  // 0 : left, 1 : current, 2 : right
+
+      if( x > 0 && *(pbEdgeXPtr-1) == true )
+      {
+        if( *(psDiffXPtr-1) >= 0)
+        {
+          usAbs0 = *(psDiffXPtr-1);
+
+        }
+        else
+        {
+          usAbs0 = (-1) * *(psDiffXPtr-1);
+        }
+      }
+      if( *pbEdgeXPtr == true )
+      {
+        if( *(psDiffXPtr) >= 0)
+        {
+          usAbs1 = *(psDiffXPtr);
+        }
+        else
+        {
+          usAbs1 = (-1) * *(psDiffXPtr);
+        }
+      }
+      if( x < iWidth-2 && *(pbEdgeXPtr+1) == true )
+      {
+        if( *(psDiffXPtr+1) >= 0)
+        {
+          usAbs2 = *(psDiffXPtr+1);
+          //bSign2 = true;
+        }
+        else
+        {
+          usAbs2 = (-1) * *(psDiffXPtr+1);
+        }
+      }
+
+      if( x == 0 )
+      {
+        if( usAbs1 < usAbs2 )
+        {
+          *pbEdgeXPtr = false;
+        }
+      }
+      else if( x == iWidth-2 )
+      {
+        if( usAbs1 <= usAbs0 )
+          *pbEdgeXPtr = false;
+      }
+      else
+      {
+        if( usAbs2 > usAbs0 )
+        {
+          if( usAbs1 < usAbs2 )
+            *pbEdgeXPtr = false;
+        }
+        else
+        {
+          if( usAbs1 <= usAbs0 )
+            *pbEdgeXPtr = false;
+        }
+      }
+
+      psDiffXPtr++;
+      pbEdgeXPtr++;
+    }
+  }
+
+  for( Int y=0; y<iHeight-1; y++ )
+  {
+    Short* psDiffYPtr = &psDiffY[ y * iWidth ];
+    Bool*  pbEdgeYPtr = &pbEdgeY[ y * iWidth ];
+    for( Int x=0; x<iWidth; x++ )
+    {
+      UShort usAbs0=0, usAbs1=0, usAbs2=0;  // 0 : upper, 1 : current, 2 : bottom
+      if( y > 0 && *(pbEdgeYPtr-iWidth) == true )
+      {
+        if( *(psDiffYPtr-iWidth) >= 0)
+        {
+          usAbs0 = *(psDiffYPtr-iWidth);
+        }
+        else
+        {
+          usAbs0 = (-1) * *(psDiffYPtr-iWidth);          
+        }
+      }
+      if( *pbEdgeYPtr == true )
+      {
+        if( *(psDiffYPtr) >= 0)
+        {
+          usAbs1 = *(psDiffYPtr);
+        }
+        else
+        {
+          usAbs1 = (-1) * *(psDiffYPtr);
+        }
+      }
+      if( y < iHeight-2 && *(pbEdgeYPtr+iWidth) == true )
+      {
+        if( *(psDiffYPtr+iWidth) >= 0)
+        {
+          usAbs2 = *(psDiffYPtr+iWidth);          
+        }
+        else
+        {
+          usAbs2 = (-1) * *(psDiffYPtr+iWidth);
+        }
+      }
+
+      if( y == 0 )
+      {
+        if( usAbs1 < usAbs2 )
+          *pbEdgeYPtr = false;
+      }
+      else if( y == iHeight-2 )
+      {
+        if( usAbs1 <= usAbs0 )
+          *pbEdgeYPtr = false;
+      }
+      else
+      {
+        if( usAbs2 > usAbs0 )
+        {
+          if( usAbs1 < usAbs2 )
+            *pbEdgeYPtr = false;
+        }
+        else
+        {
+          if( usAbs1 <= usAbs0 )
+            *pbEdgeYPtr = false;
+        }
+      }
+
+      psDiffYPtr++;
+      pbEdgeYPtr++;
+    }
+  }
+
+  // Edge Merging
+  for( Int i=0; i< 4 * iWidth * iHeight; i++ )
+    pbEdge[ i ] = false;
+  /// Even Line (0,2,4,6,...) => Vertical Edge
+  for( Int i=0; i<iHeight; i++)
+  {
+    for( Int j=0; j<iWidth-1; j++)
+    {
+      pbEdge[ (2 * j + 1) + (2 * i) * 2 * iWidth ] = pbEdgeX[ j + i * iHeight ];
+    }
+  }
+  /// Odd Line (1,3,5,7,...) => Horizontal Edge
+  for( Int i=0; i<iHeight-1; i++)
+  {
+    for( Int j=0; j<iWidth; j++)
+    {
+      pbEdge[ (2 * j) + (2 * i + 1) * 2 * iWidth ] = pbEdgeY[ j + i * iHeight ]; 
+    }
+  }
+
+  // Intersection Filling
+  /// Vertical Edge between Horizontal Edges
+  for( Int i = 1; i < 2 * iHeight - 3; i += 2)
+  {
+    for( Int j = 0; j < 2 * iWidth - 1; j += 2)
+    {
+      if( pbEdge[ j + i * 2 * iWidth ] )
+      {
+        if( j != 0 && pbEdge[ (j - 2) + ((i + 2) * 2 * iWidth) ] )
+        {
+          if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j - 1) + ((i + 3) * 2 * iWidth) ] )
+            pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] = true;
+        }
+        if( j != 2 * iWidth - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] )
+        {
+          if( !pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 1) + ((i + 3) * 2 * iWidth) ] )
+            pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true;
+        }
+      }
+    }
+  }
+  /// Horizontal Edge between Vertical Edges
+  for( Int j = 1; j < 2 * iWidth - 3; j += 2)
+  {
+    for( Int i = 0; i < 2 * iHeight - 1; i += 2)
+    {
+      if( pbEdge[ j + i * 2 * iWidth ] )
+      {
+        if( i != 0 && pbEdge[ (j + 2) + ((i - 2) * 2 * iWidth) ] )
+        {
+          if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i - 1) * 2 * iWidth) ] )
+            pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] = true;
+        }
+        if( i != 2 * iHeight - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] )
+        {
+          if( !pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i + 1) * 2 * iWidth) ] )
+            pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true;
+        }
+      }
+    }
+  }
+
+  // Static Pruning Unnecessary Edges
+  /// Step1. Stack push the unconnected edges
+  UShort* pusUnconnectedEdgeStack = new UShort[ 4 * iWidth * iHeight ]; // approximate size calculation
+  Int iUnconnectedEdgeStackPtr = 0;
+  //// Vertical Edges
+  for( Int i = 0; i < 2 * iHeight - 1; i += 2 )
+  {
+    for( Int j = 1; j < 2 * iWidth - 2; j += 2 )
+    {
+      if( pbEdge[ j + i * 2 * iWidth ] )
+      {
+        if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) )
+        {
+          pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j);
+          iUnconnectedEdgeStackPtr++;
+        }
+      }
+    }
+  }
+
+  //// Horizontal Edges
+  for( Int i = 1; i < 2 * iHeight - 2; i += 2 )
+  {
+    for( Int j = 0; j < 2 * iWidth - 1; j += 2 )
+    {
+      if( pbEdge[ j + i * 2 * iWidth ] )
+      {
+        if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) )
+        {
+          pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j);
+          iUnconnectedEdgeStackPtr++;
+        }
+      }
+    }
+  }
+
+  /// Step2. Remove the edges from the stack and push the new unconnected edges
+  //// (This step may contain duplicated edges already in the stack)
+  //// (But it doesn't cause any functional problems)
+  while( iUnconnectedEdgeStackPtr != 0 )
+  {
+    iUnconnectedEdgeStackPtr--;
+    Int iX = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] & 0xff;
+    Int iY = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] >> 8;
+
+    pbEdge[ iX + iY * 2 * iWidth ] = false;
+
+    if( iY % 2 == 1 && iX > 0 && pbEdge[ iX - 2 + iY * 2 * iWidth ] &&
+      !xCheckTerminatedEdge( pbEdge, iX - 2, iY, iWidth, iHeight ) ) // left
+    {
+      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX - 2);
+      iUnconnectedEdgeStackPtr++;
+    }
+    if( iY % 2 == 1 && iX < 2 * iWidth - 2 && pbEdge[ iX + 2 + iY * 2 * iWidth ] &&
+      !xCheckTerminatedEdge( pbEdge, iX + 2, iY, iWidth, iHeight ) ) // right
+    {
+      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX + 2);
+      iUnconnectedEdgeStackPtr++;
+    }
+    if( iY % 2 == 0 && iY > 0 && pbEdge[ iX + (iY - 2) * 2 * iWidth ] &&
+      !xCheckTerminatedEdge( pbEdge, iX, iY - 2, iWidth, iHeight ) ) // top
+    {
+      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 2) << 8) | (iX + 0);
+      iUnconnectedEdgeStackPtr++;
+    }
+    if( iY % 2 == 0 && iY < 2 * iHeight - 2 && pbEdge[ iX + (iY + 2) * 2 * iWidth ] &&
+      !xCheckTerminatedEdge( pbEdge, iX, iY + 2, iWidth, iHeight ) ) // bottom
+    {
+      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 2) << 8) | (iX + 0);
+      iUnconnectedEdgeStackPtr++;
+    }
+    if( iX > 0 && iY > 0 && pbEdge[ iX - 1 + (iY - 1) * 2 * iWidth ] &&
+      !xCheckTerminatedEdge( pbEdge, iX - 1, iY - 1, iWidth, iHeight ) ) // left-top
+    {
+      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX - 1);
+      iUnconnectedEdgeStackPtr++;
+    }
+    if( iX < 2 * iWidth - 1 && iY > 0 && pbEdge[ iX + 1 + (iY - 1) * 2 * iWidth ] &&
+      !xCheckTerminatedEdge( pbEdge, iX + 1, iY - 1, iWidth, iHeight ) ) // right-top
+    {
+      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX + 1);
+      iUnconnectedEdgeStackPtr++;
+    }
+    if( iX > 0 && iY < 2 * iHeight - 1 && pbEdge[ iX - 1 + (iY + 1) * 2 * iWidth ] &&
+      !xCheckTerminatedEdge( pbEdge, iX - 1, iY + 1, iWidth, iHeight ) ) // left-bottom
+    {
+      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX - 1);
+      iUnconnectedEdgeStackPtr++;
+    }
+    if( iX < 2 * iWidth - 1 && iY < 2 * iHeight - 1 && pbEdge[ iX + 1 + (iY + 1) * 2 * iWidth ] &&
+      !xCheckTerminatedEdge( pbEdge, iX + 1, iY + 1, iWidth, iHeight ) ) // right-bottom
+    {
+      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX + 1);
+      iUnconnectedEdgeStackPtr++;
+    }
+  }
+
+
+  // Region Generation ( edge -> region )
+  Bool* pbRegion = pcCU->getEdgePartition( uiPartIdx );
+  Bool* pbVisit  = new Bool[ iWidth * iHeight ];
+
+  for( UInt ui = 0; ui < iWidth * iHeight; ui++ )
+  {
+    pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next)
+    pbVisit [ ui ] = false;
+  }
+
+  Int* piStack = new Int[ iWidth * iHeight ];
+
+  Int iPtr = 0;
+
+  piStack[iPtr++] = (0 << 8) | (0);
+  pbRegion[ 0 ] = false;
+
+  while(iPtr > 0)
+  {
+    Int iTmp = piStack[--iPtr];
+    Int iX1, iY1;
+    iX1 = iTmp & 0xff;
+    iY1 = (iTmp >> 8) & 0xff;
+
+    pbVisit[ iX1 + iY1 * iWidth ] = true;
+
+    assert( iX1 >= 0 && iX1 < iWidth );
+    assert( iY1 >= 0 && iY1 < iHeight );
+
+    if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] )
+    {
+      piStack[iPtr++] = (iY1 << 8) | (iX1 - 1);
+      pbRegion[ iX1 - 1 + iY1 * iWidth ] = false;
+    }
+    if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] )
+    {
+      piStack[iPtr++] = (iY1 << 8) | (iX1 + 1);
+      pbRegion[ iX1 + 1 + iY1 * iWidth ] = false;
+    }
+    if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] )
+    {
+      piStack[iPtr++] = ((iY1 - 1) << 8) | iX1;
+      pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false;
+    }
+    if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] )
+    {
+      piStack[iPtr++] = ((iY1 + 1) << 8) | iX1;
+      pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false;
+    }
+  }
+
+  ///////////
+  iPtr = 0;
+  for( Int i = 0; i < iWidth * iHeight; i++ )
+    pbVisit[ i ] = false;
+  piStack[ iPtr++ ] = (0 << 8) | (0); // initial seed
+  while( iPtr > 0 && iPtr < iWidth * iHeight )
+  {
+    Int iX;
+    Int iY;
+    iPtr--;
+    iX = piStack[ iPtr ] & 0xff;
+    iY = piStack[ iPtr ] >> 8;
+    pbVisit[ iY * iWidth + iX ] = true;
+
+    if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] )
+    {
+      piStack[ iPtr++ ] = ((iY - 1) << 8) | iX;
+    }
+    if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] )
+    {
+      piStack[ iPtr++ ] = ((iY + 1) << 8) | iX;
+    }
+    if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] )
+    {
+      piStack[ iPtr++ ] = (iY << 8) | (iX - 1);
+    }
+    if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] )
+    {
+      piStack[ iPtr++ ] = (iY << 8) | (iX + 1);
+    }
+  }
+  assert( iPtr == 0 || iPtr == iWidth * iHeight );
+
+  Bool bBipartition;
+  if( iPtr == iWidth * iHeight )
+  {
+    bBipartition = false; // single partition
+  }
+  else
+  {
+    for( Int i = 0; i < iWidth * iHeight; i++ )
+    {
+      if( !pbVisit[ i ] )
+      {
+        piStack[ iPtr++ ] = (( i / iWidth ) << 8) | ( i % iWidth );
+        pbVisit[ i ] = true;
+        break;
+      }
+    }
+    while( iPtr > 0 )
+    {
+      Int iX;
+      Int iY;
+      iPtr--;
+      iX = piStack[ iPtr ] & 0xff;
+      iY = piStack[ iPtr ] >> 8;
+      pbVisit[ iY * iWidth + iX ] = true;
+
+      if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] )
+      {
+        piStack[ iPtr++ ] = ((iY - 1) << 8) | iX;
+      }
+      if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] )
+      {
+        piStack[ iPtr++ ] = ((iY + 1) << 8) | iX;
+      }
+      if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] )
+      {
+        piStack[ iPtr++ ] = (iY << 8) | (iX - 1);
+      }
+      if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] )
+      {
+        piStack[ iPtr++ ] = (iY << 8) | (iX + 1);
+      }
+    }
+    bBipartition = true;
+    for( Int i = 0; i < iWidth * iHeight; i++ )
+    {
+      if( !pbVisit[ i ] )
+      {
+        bBipartition = false;
+        break;
+      }
+    }
+  }
+
+  xFree( pbEdge );
+  delete[] pbEdgeX; pbEdgeX = NULL;
+  delete[] pbEdgeY; pbEdgeY = NULL;
+  delete[] psDiffX; psDiffX = NULL;
+  delete[] psDiffY; psDiffY = NULL;
+  delete[] pusUnconnectedEdgeStack; pusUnconnectedEdgeStack = NULL;
+  delete[] pbVisit; pbVisit = NULL;
+  delete[] piStack; piStack = NULL;
+
+  Bool bCheckPossibleChain;
+
+  if( bBipartition )
+    bCheckPossibleChain = xConstructChainCode( pcCU, uiPartIdx, bPU4x4 );
+  else
+    bCheckPossibleChain = false;
+
+  return bCheckPossibleChain;
+}
+
+#endif
+
+Bool TEncSearch::xConstructChainCode( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 )
+{
+  UInt   uiWidth    = pcCU->getWidth( uiPartIdx ) >> (bPU4x4 ? 1 : 0);
+  UInt   uiHeight   = pcCU->getHeight( uiPartIdx ) >> (bPU4x4 ? 1 : 0);
+  Bool*  pbEdge     = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 );
+  Bool*  pbVisit    = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 );
+  UInt   uiMaxEdge  = uiWidth * (LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 / 4);
+  Bool*  pbRegion   = pcCU->getEdgePartition( uiPartIdx );
+  UChar* piEdgeCode = pcCU->getEdgeCode( uiPartIdx );
+  Bool   bStartLeft = false;
+  Bool   bPossible  = false;
+  Bool   bFinish    = false;
+  Int    iStartPosition = -1;
+  Int    iPtr = 0;
+  Int    iDir = -1, iNextDir = -1;
+  Int    iArrow = -1, iNextArrow = -1;
+  Int    iX = -1, iY = -1;
+  Int    iDiffX = 0, iDiffY = 0;
+  UChar  iCode = 255;
+  UInt   uiWidth2 = uiWidth * 2;
+
+  for( Int i = 0; i < uiWidth * uiHeight * 4; i++ )
+    pbEdge[ i ] = false;
+
+  for( Int i = 0; i < uiHeight; i++ )
+  {
+    for( Int j = 0; j < uiWidth - 1; j++ )
+    {
+      if( pbRegion[ i * uiWidth + j ] != pbRegion[ i * uiWidth + j + 1 ] )
+        pbEdge[ i * uiWidth * 4 + j * 2 + 1 ] = true;
+    }
+  }
+
+  for( Int i = 0; i < uiHeight - 1; i++ )
+  {
+    for( Int j = 0; j < uiWidth; j++ )
+    {
+      if( pbRegion[ (i + 0) * uiWidth + j ] != pbRegion[ (i + 1) * uiWidth + j ] )
+        pbEdge[ (2 * i + 1) * 2 * uiWidth + j * 2 ] = true;
+    }
+  }
+
+  for( Int i = 1; i < uiWidth2 - 2; i+=2 )
+  {
+    if(pbEdge[ i ])
+    {
+      bPossible  = true;
+      bStartLeft = false;
+      iStartPosition = iX = i;
+      iY = 0;
+      iDir = 3;
+      iArrow = 3;
+      break;
+    }
+  }
+
+  if( !bPossible )
+  {
+    for( Int i = 1; i < uiWidth2 - 2; i+=2 )
+    {
+      if(pbEdge[ i * uiWidth2 ])
+      {
+        bPossible  = true;
+        bStartLeft = true;
+        iX = 0;
+        iStartPosition = iY = i;
+        iDir = 1;
+        iArrow = 1;
+        break;
+      }
+    }
+  }
+
+  if( bPossible )
+  {
+    for( Int i = 0; i < 4 * uiWidth * uiHeight; i++ )
+      pbVisit[ i ] = false;
+
+    while( !bFinish )
+    {
+      Bool bArrowSkip = false;
+      pbVisit[ iX + iY * uiWidth2 ] = true;
+
+      switch( iDir )
+      {
+      case 0: // left
+        if( iX > 0 && !pbVisit[ (iX - 2) + iY * uiWidth2 ] && pbEdge[ (iX - 2) + iY * uiWidth2 ] ) // left
+        {
+          iDiffX = -2;
+          iDiffY =  0;
+          iNextDir = 0;
+          iNextArrow = 0;
+        }
+        else if( iX > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // top
+        {
+          iDiffX = -1;
+          iDiffY = -1;
+          iNextDir = 2;
+          iNextArrow = 4;
+        }
+        else if( iX > 0 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // bottom
+        {
+          iDiffX = -1;
+          iDiffY = +1;
+          iNextDir = 3;
+          iNextArrow = iArrow;
+          if( !(iPtr == 0 && iX == uiWidth2 - 2 && iY == uiHeight * 2 - 3) )
+            bArrowSkip = true;
+          else
+            iNextArrow = 3;
+        }
+        else if( iX == 0 )
+        {
+          iDiffX = 0;
+          iDiffY = 0;
+          iNextDir = iDir;
+          iNextArrow = iArrow;
+          bFinish = true;
+          continue;
+        }
+        else
+        {
+          iPtr = 0; // edge loop or unwanted case
+          bFinish = true;
+          //continue;
+          assert(false);
+        }
+        break;
+      case 1: // right
+        if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 2) + iY * uiWidth2 ] && pbEdge[ (iX + 2) + iY * uiWidth2 ] ) // right
+        {
+          iDiffX = +2;
+          iDiffY =  0;
+          iNextDir = 1;
+          iNextArrow = 1;
+        }
+        else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // top
+        {
+          iDiffX = +1;
+          iDiffY = -1;
+          iNextDir = 2;
+          iNextArrow = iArrow;
+          if( !(iPtr == 0 && iX == 0 && iY == 1) )
+            bArrowSkip = true;
+          else
+            iNextArrow = 2;
+        }
+        else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // bottom
+        {
+          iDiffX = +1;
+          iDiffY = +1;
+          iNextDir = 3;
+          iNextArrow = 7;
+        }
+        else if( iX == uiWidth2 - 2 )
+        {
+          iDiffX = 0;
+          iDiffY = 0;
+          iNextDir = iDir;
+          iNextArrow = iArrow;
+          bFinish = true;
+          continue;
+        }
+        else
+        {
+          iPtr = 0; // edge loop or unwanted case
+          bFinish = true;
+          //continue;
+          assert(false);
+        }
+        break;
+      case 2: // top
+        if( iY > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // left
+        {
+          iDiffX = -1;
+          iDiffY = -1;
+          iNextDir = 0;
+          iNextArrow = iArrow;
+          if( !(iPtr == 0 && iX == 1 && iY == uiHeight * 2 - 2) )
+            bArrowSkip = true;
+          else
+            iNextArrow = 0;
+        }
+        else if( iY > 0 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // right
+        {
+          iDiffX = +1;
+          iDiffY = -1;
+          iNextDir = 1;
+          iNextArrow = 5;
+        }
+        else if( iY > 0 && !pbVisit[ iX + (iY - 2) * uiWidth2 ] && pbEdge[ iX + (iY - 2) * uiWidth2 ] ) // top
+        {
+          iDiffX =  0;
+          iDiffY = -2;
+          iNextDir = 2;
+          iNextArrow = 2;
+        }
+        else if( iY == 0 )
+        {
+          iDiffX = 0;
+          iDiffY = 0;
+          iNextDir = iDir;
+          iNextArrow = iArrow;
+          bFinish = true;
+          continue;
+        }
+        else
+        {
+          iPtr = 0; // edge loop or unwanted case
+          bFinish = true;
+          //continue;
+          assert(false);
+        }
+        break;
+      case 3: // bottom
+        if( iY < uiWidth2 - 2 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // left
+        {
+          iDiffX = -1;
+          iDiffY = +1;
+          iNextDir = 0;
+          iNextArrow = 6;
+        }
+        else if( iY < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // right
+        {
+          iDiffX = +1;
+          iDiffY = +1;
+          iNextDir = 1;
+          iNextArrow = iArrow;
+          if( !(iPtr == 0 && iX == uiWidth * 2 - 3 && iY == 0) )
+            bArrowSkip = true;
+          else
+            iNextArrow = 1;
+        }
+        else if( iY < uiWidth2 - 2 && !pbVisit[ iX + (iY + 2) * uiWidth2 ] && pbEdge[ iX + (iY + 2) * uiWidth2 ] ) // bottom
+        {
+          iDiffX =  0;
+          iDiffY = +2;
+          iNextDir = 3;
+          iNextArrow = 3;
+        }
+        else if( iY == uiWidth2 - 2 )
+        {
+          iDiffX = 0;
+          iDiffY = 0;
+          iNextDir = iDir;
+          iNextArrow = iArrow;
+          bFinish = true;
+          continue;
+        }
+        else
+        {
+          iPtr = 0; // edge loop or unwanted case
+          bFinish = true;
+          //continue;
+          assert(false);
+        }
+        break;
+      }
+
+      const UChar tableCode[8][8] = { { 0, -1, 4, 3, 2, 6, 1, 5 }, // iArrow(current direction), iNextArrow(next direction)
+      { -1, 0, 3, 4, 5, 1, 6, 2 },
+      { 3, 4, 0, -1, 1, 2, 5, 6 },
+      { 4, 3, -1, 0, 6, 5, 2, 1 },
+      { 1, 6, 2, 5, 0, 4, 3, -1 },
+      { 5, 2, 1, 6, 3, 0, -1, 4 },
+      { 2, 5, 6, 1, 4, -1, 0, 3 },
+      { 6, 1, 5, 2, -1, 3, 4, 0 } };
+
+      iCode = tableCode[iArrow][iNextArrow];
+
+      if(iPtr >= uiMaxEdge)
+      {
+        iPtr = 0; // over the maximum number of edge
+        bPossible = false;
+        break;
+      }
+
+      if( !bArrowSkip )
+      {
+        piEdgeCode[iPtr++] = iCode; // first edge coding
+        //printf("xEdgeCoding: (%d,%d)->(%d,%d) code %d\n",iX,iY, iX+iDiffX, iY+iDiffY, iCode);
+      }
+
+      iX += iDiffX;
+      iY += iDiffY;
+      iDir = iNextDir;
+      iArrow = iNextArrow;
+    }
+  }
+
+  pcCU->setEdgeLeftFirst( uiPartIdx, bStartLeft );
+  pcCU->setEdgeStartPos ( uiPartIdx, bStartLeft ? (iStartPosition - 1) >> 1 : (iStartPosition + 1) >> 1);
+  pcCU->setEdgeNumber   ( uiPartIdx, iPtr );
+
+  xFree( pbEdge );
+  xFree( pbVisit );
+
+  return (iPtr != 0);
+}
+
+#if LGE_EDGE_INTRA_DELTA_DC
+Void TEncSearch::xAssignEdgeIntraDeltaDCs( TComDataCU*   pcCU,
+                                          UInt          uiAbsPartIdx,
+                                          Pel*          piOrig,
+                                          UInt          uiStride,
+                                          Pel*          piPredic,
+                                          UInt          uiWidth,
+                                          UInt          uiHeight )
+{
+  Int iDC0 = 0;
+  Int iDC1 = 0;
+  Int iPredDC0 = 0;
+  Int iPredDC1 = 0;
+  Int iDeltaDC0 = 0;
+  Int iDeltaDC1 = 0;
+
+  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
+
+  Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt );
+  Int iMaskStride = ( uiWidth<<1 ) + 1;
+
+  // DC Calculation
+  {
+    UInt uiSum0 = 0;
+    UInt uiSum1 = 0;
+    UInt uiCount0 = 0;
+    UInt uiCount1 = 0;
+
+    Pel* piTemp = piOrig;
+    for( UInt ui = 0; ui < uiHeight; ui++ )
+    {
+      for( UInt uii = 0; uii < uiWidth; uii++ )
+      {
+        if( pbRegion[ ui * uiWidth + uii ] == false )
+        {
+          uiSum0 += (piTemp[ uii ]);
+          uiCount0++;
+        }
+        else
+        {
+          uiSum1 += (piTemp[ uii ]);
+          uiCount1++;
+        }
+      }
+      piTemp += uiStride;
+    }
+    if( uiCount0 == 0 )
+      assert(false);
+    if( uiCount1 == 0 )
+      assert(false);
+    iDC0 = uiSum0 / uiCount0; // TODO : integer op.
+    iDC1 = uiSum1 / uiCount1;
+  }
+
+  // PredDC Calculation
+  {
+    UInt uiSum0 = 0;
+    UInt uiSum1 = 0;
+    UInt uiCount0 = 0;
+    UInt uiCount1 = 0;
+
+    for( UInt ui = 0; ui < uiWidth; ui++ )
+    {
+      if( pbRegion[ ui ] == false )
+      {
+        uiSum0 += (piMask[ ui + 1 ]);
+        uiCount0++;
+      }
+      else
+      {
+        uiSum1 += (piMask[ ui + 1 ]);
+        uiCount1++;
+      }
+    }
+    for( UInt ui = 0; ui < uiHeight; ui++ ) // (0,0) recount (to avoid division)
+    {
+      if( pbRegion[ ui * uiWidth ] == false )
+      {
+        uiSum0 += (piMask[ (ui + 1) * iMaskStride ]);
+        uiCount0++;
+      }
+      else
+      {
+        uiSum1 += (piMask[ (ui + 1) * iMaskStride ]);
+        uiCount1++;
+      }
+    }
+    if( uiCount0 == 0 )
+      assert(false);
+    if( uiCount1 == 0 )
+      assert(false);
+    iPredDC0 = uiSum0 / uiCount0; // TODO : integer op.
+    iPredDC1 = uiSum1 / uiCount1;
+  }
+
+  iDeltaDC0 = iDC0 - iPredDC0;
+  iDeltaDC1 = iDC1 - iPredDC1;
+
+#if HHI_VSO
+  if( m_pcRdCost->getUseVSO() )
+  {
+    Int iFullDeltaDC0 = iDeltaDC0;
+    Int iFullDeltaDC1 = iDeltaDC1;
+
+    xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC0 );
+    xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC1 );
+
+    Dist  uiBestDist     = RDO_DIST_MAX;
+    UInt  uiBestQStepDC0 = 0;
+    UInt  uiBestQStepDC1 = 0;
+
+    UInt uiDeltaDC0Max = abs(iFullDeltaDC0);
+    UInt uiDeltaDC1Max = abs(iFullDeltaDC1);
+
+    //VSO Level delta DC check range extension
+    uiDeltaDC0Max += (uiDeltaDC0Max>>1);
+    uiDeltaDC1Max += (uiDeltaDC1Max>>1);
+
+    for( UInt uiQStepDC0 = 1; uiQStepDC0 <= uiDeltaDC0Max; uiQStepDC0++  )
+    {
+      Int iLevelDeltaDC0 = (Int)(uiQStepDC0) * (Int)(( iFullDeltaDC0 < 0 ) ? -1 : 1);
+      xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC0 );
+
+      Int iTestDC0 = Clip( iPredDC0 + iLevelDeltaDC0 );
+      for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++  )
+      {
+        Int iLevelDeltaDC1 = (Int)(uiQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1);
+        xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC1 );
+
+        Int iTestDC1 = Clip( iPredDC1 + iLevelDeltaDC1 );
+
+        Pel* piTemp = piPredic;
+        for( UInt ui = 0; ui < uiHeight; ui++ )
+        {
+          for( UInt uii = 0; uii < uiWidth; uii++ )
+          {
+            if( pbRegion[ ui * uiWidth + uii ] == false )
+            {
+              piTemp[ uii ] = iTestDC0;
+            }
+            else
+            {
+              piTemp[ uii ] = iTestDC1;
+            }
+          }
+          piTemp += uiStride;
+        }
+
+        Dist uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride,  piOrig, uiStride, uiWidth, uiHeight, false, 0 );
+        if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
+        {
+          uiBestDist     = uiActDist;
+          uiBestQStepDC0 = uiQStepDC0;
+          uiBestQStepDC1 = uiQStepDC1;
+        }
+      }
+    }
+
+    iFullDeltaDC0 = (Int)(uiBestQStepDC0) * (Int)(( iFullDeltaDC0 < 0 ) ? -1 : 1);
+    iFullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1);
+    xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC0 );
+    xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC1 );
+    iDeltaDC0 = iFullDeltaDC0;
+    iDeltaDC1 = iFullDeltaDC1;
+  }
+#endif
+
+  xDeltaDCQuantScaleDown( pcCU, iDeltaDC0 );
+  xDeltaDCQuantScaleDown( pcCU, iDeltaDC1 );
+
+  pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 );
+  pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 );
+}
+#endif
+#endif
+
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 100)
@@ -189,5 +189,5 @@
                                   TComYuv*    pcOrgYuv,
 #if LG_RESTRICTEDRESPRED_M24766
-								  TComYuv*     rpcResiPredYuv,
+                                  TComYuv*    rpcResiPredYuv,
 #endif
                                   TComYuv*&   rpcPredYuv,
@@ -259,5 +259,9 @@
                                     TComYuv*     pcPredYuv, 
                                     TComYuv*     pcResiYuv, 
-                                    Dist&        ruiDist );
+                                    Dist&        ruiDist 
+#if LG_ZEROINTRADEPTHRESI_M26039
+                                   ,Bool        bZeroResi = false
+#endif
+                                   );
   Void  xIntraCodingChromaBlk     ( TComDataCU*  pcCU,
                                     UInt         uiTrDepth,
@@ -278,7 +282,11 @@
                                     Dist&        ruiDistC,
 #if HHI_RQT_INTRA_SPEEDUP
-                                   Bool         bCheckFirst,
-#endif
-                                   Double&      dRDCost );
+                                    Bool         bCheckFirst,
+#endif
+                                    Double&      dRDCost 
+#if LG_ZEROINTRADEPTHRESI_M26039
+                                   ,Bool         bZeroResi = false
+#endif
+                                  );
   
   Void  xSetIntraResultQT         ( TComDataCU*  pcCU,
@@ -321,4 +329,14 @@
                                     Bool           bLeftAvail );
 #endif
+
+#if LGE_EDGE_INTRA
+  Bool  xEdgePartition       ( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 );
+  Bool  xCheckTerminatedEdge ( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight );
+  Bool  xConstructChainCode  ( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 );
+#if LGE_EDGE_INTRA_DELTA_DC
+  Void  xAssignEdgeIntraDeltaDCs( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piOrig, UInt uiStride, Pel* piPredic, UInt uiWidth, UInt uiHeight );
+#endif
+#endif
+
 #if HHI_DMM_WEDGE_INTRA
   Void findWedgeFullMinDist       ( TComDataCU*    pcCU, 
@@ -444,5 +462,5 @@
                                     TComYuv*        pcYuvOrg,
 #if LG_RESTRICTEDRESPRED_M24766
-									TComYuv*        rpcResiPredYuv, 
+                                    TComYuv*        rpcResiPredYuv, 
 #endif
                                     Int             iPartIdx,
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 100)
@@ -38,5 +38,11 @@
 #include "TEncTop.h"
 #include "TEncSlice.h"
+#if HHI_VSO_SPEEDUP_A033
+#include "../../App/TAppEncoder/TAppEncTop.h"
+#endif
 #include <math.h>
+#if SAIT_VSO_EST_A0033
+extern Double g_dDispCoeff;
+#endif
 
 //! \ingroup TLibEncoder
@@ -627,4 +633,7 @@
   TComSlice* pcSlice            = rpcPic->getSlice(getSliceIdx());
   xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false );
+#if LG_ZEROINTRADEPTHRESI_M26039
+  rpcPic->setIntraPeriod(this->m_pcCfg->getIntraPeriod());
+#endif
   
   // initialize cost values
@@ -702,4 +711,29 @@
   m_pcEntropyCoder->setMaxAlfCtrlDepth(0); //unnecessary
   
+#if SAIT_VSO_EST_A0033
+ if( m_pcCfg->getUseVSO() )
+ {
+   m_pcRdCost->setDisparityCoeff( g_dDispCoeff );  // Temp. code!!!
+   //printf( "Disp Coeff : %3.4f \n", m_pcRdCost->getDisparityCoeff() );
+
+   Int frameWidth = m_pcCfg->getSourceWidth();
+   Pel* pVideoRec = m_pcRdCost->getVideoRecPicYuv()->getLumaAddr();
+   Int iVideoRecStride = m_pcRdCost->getVideoRecPicYuv()->getStride();
+
+   Pel* pDepthOrg = m_pcRdCost->getDepthPicYuv()->getLumaAddr();
+   Int iDepthOrgStride = m_pcRdCost->getDepthPicYuv()->getStride();
+
+   for( Int y = 0 ; y < m_pcCfg->getSourceHeight() ; y++ )
+   {
+     pVideoRec[-4] = pVideoRec[-3] = pVideoRec[-2] = pVideoRec[-1] = pVideoRec[0];
+     pVideoRec[frameWidth+3] = pVideoRec[frameWidth+2] = pVideoRec[frameWidth+1] = pVideoRec[frameWidth] = pVideoRec[frameWidth-1];
+     pDepthOrg[-4] = pDepthOrg[-3] = pDepthOrg[-2] = pDepthOrg[-1] = pDepthOrg[0];
+     pDepthOrg[frameWidth+3] = pDepthOrg[frameWidth+2] = pDepthOrg[frameWidth+1] = pDepthOrg[frameWidth] = pDepthOrg[frameWidth-1];
+
+     pVideoRec += iVideoRecStride;
+     pDepthOrg += iDepthOrgStride;
+   }
+ }
+#endif
   TEncTop* pcEncTop = (TEncTop*) m_pcCfg;
   TEncSbac**** ppppcRDSbacCoders    = pcEncTop->getRDSbacCoders();
@@ -753,4 +787,8 @@
   UInt uiTileLCUX     = 0;
 
+#if HHI_VSO_SPEEDUP_A033
+  Int iLastPosY = -1;
+#endif
+
   // for every CU in slice
   UInt uiEncCUOrder;
@@ -763,4 +801,21 @@
     TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
     pcCU->initCU( rpcPic, uiCUAddr );
+
+#if HHI_VSO_SPEEDUP_A033
+    if ( m_pcRdCost->getUseRenModel() )
+    {
+      // updated renderer model if necessary
+      Int iCurPosX;
+      Int iCurPosY; 
+      pcCU->getPosInPic(0, iCurPosX, iCurPosY );
+      if ( iCurPosY != iLastPosY )
+      {
+        iLastPosY = iCurPosY; 
+        
+        m_pcGOPEncoder->getEncTop()->getEncTop()->setupRenModel( rpcPic->getCurrSlice()->getPOC() , rpcPic->getCurrSlice()->getSPS()->getViewId(), rpcPic->getCurrSlice()->getSPS()->isDepth() ? 1 : 0, iCurPosY );
+      }
+    }    
+#endif
+
 
     // inherit from TR if necessary, select substream to use.
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 81)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 100)
@@ -597,4 +597,7 @@
   // mark it should be extended
   rpcPic->getPicYuvRec()->setBorderExtension(false);
+#if FIXES
+  rpcPic->getPicYuvOrg()->setBorderExtension(false); 
+#endif
 }
 
@@ -981,9 +984,5 @@
 Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic )
 {
-#if HHI_FIX
   if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 )
-#else
-  if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV )
-#endif
   {
     TComReferencePictureSet* rps = slice->getLocalRPS();
Index: trunk/source/Lib/TLibExtractor/TExtrTop.cpp
===================================================================
--- trunk/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 81)
+++ trunk/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 100)
@@ -56,5 +56,5 @@
 {
 #if VIDYO_VPS_INTEGRATION
-	//extraction now has to be done using layer_id
+  //extraction now has to be done using layer_id
   UInt uiLayerId = nalu.m_layerId;
 #else
Index: trunk/source/Lib/TLibRenderer/TRenImage.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenImage.cpp	(revision 81)
+++ trunk/source/Lib/TLibRenderer/TRenImage.cpp	(revision 100)
@@ -106,4 +106,27 @@
 }
 
+#if HHI_VSO_SPEEDUP_A033
+template<typename T>
+Void TRenImage<T>::getDataAndStrides( T** pptData, Int* piStrides )
+{
+  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++ )
+  {
+    piStrides[uiCurPlane] = m_apcPlanes[uiCurPlane]->getStride   ();
+    pptData  [uiCurPlane] = m_apcPlanes[uiCurPlane]->getPlaneData();
+  }
+}
+
+
+template<typename T>
+Void TRenImage<T>::getWidthAndHeight( Int* ppiWidths, Int* ppiHeights )
+{
+  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++ )
+  {
+    ppiWidths [uiCurPlane] = m_apcPlanes[uiCurPlane]->getWidth ();
+    ppiHeights[uiCurPlane] = m_apcPlanes[uiCurPlane]->getHeight();
+  }
+}
+#endif
+
 template<typename T>
 Void TRenImage<T>::allocatePlanes( UInt uiWidth, UInt uiHeight, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes )
Index: trunk/source/Lib/TLibRenderer/TRenImage.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenImage.h	(revision 81)
+++ trunk/source/Lib/TLibRenderer/TRenImage.h	(revision 100)
@@ -69,4 +69,9 @@
   TRenImagePlane<T>** getPlanes() const;
 
+#if HHI_VSO_SPEEDUP_A033
+  Void getDataAndStrides( T**    pptData, Int*  piStrides );
+  Void getWidthAndHeight( Int*  piWidths, Int*  piHeights );
+#endif
+
   UInt getNumberOfPlanes()  const;
   UInt getNumberOfQuaterPlanes() const;
Index: trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp	(revision 81)
+++ trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp	(revision 100)
@@ -357,14 +357,14 @@
   {
   case 'E':
-    iBlendMode = -1;
+    iBlendMode = BLEND_NONE;
     break;
   case 'I':
-    iBlendMode = 0;
+    iBlendMode = BLEND_AVRG;
     break;
   case 'L':
-    iBlendMode = 1;
+    iBlendMode = BLEND_LEFT;
     break;
   case 'R':
-    iBlendMode = 2;
+    iBlendMode = BLEND_RIGHT;
     break;
   default:
Index: trunk/source/Lib/TLibRenderer/TRenModel.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenModel.cpp	(revision 81)
+++ trunk/source/Lib/TLibRenderer/TRenModel.cpp	(revision 100)
@@ -32,6 +32,4 @@
  */
 
-
-
 #include "TRenImage.h"
 #include "TRenFilter.h"
@@ -48,4 +46,8 @@
   m_iShiftPrec         =  0;
   m_iHoleMargin        =  1;
+  m_uiHorOff           = -1;
+#if LGE_VSO_EARLY_SKIP_A0093
+  m_bEarlySkip         = false; 
+#endif
 
   // Current Error Type ///
@@ -211,5 +213,9 @@
 
 Void
+#if LGE_VSO_EARLY_SKIP_A0093
+TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bEarlySkip )
+#else
 TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin )
+#endif
 {
   m_iNumOfBaseViews     = iNumOfBaseViews;
@@ -219,4 +225,8 @@
   m_iShiftPrec          = iShiftPrec;
   m_iHoleMargin         = iHoleMargin;
+#if LGE_VSO_EARLY_SKIP_A0093
+  m_bEarlySkip          = bEarlySkip; 
+#endif
+
 
 // LUTs for sub pel shifting
@@ -231,5 +241,5 @@
 
   TRenFilter::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[0], 0 );
-  TRenFilter::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[1], -1);
+  TRenFilter::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[1], 0 );
 
   m_iSampledWidth       = iWidth << m_iShiftPrec;
@@ -268,5 +278,5 @@
   for (Int iModelNum = 0; iModelNum < m_iNumOfRenModels; iModelNum++)
   {
-    m_apcRenModels         [iModelNum] = new TRenSingleModel();
+    m_apcRenModels         [iModelNum] = NULL;
   }
 
@@ -339,6 +349,5 @@
 
   AOT( iMode == -1);
-  AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels );
-  AOF( m_apcRenModels[iModelNum] );
+  AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels );  
   AOT( iLeftViewNum  < -1 || iLeftViewNum  > m_iNumOfBaseViews );
   AOT( iRightViewNum < -1 || iRightViewNum > m_iNumOfBaseViews );
@@ -348,5 +357,65 @@
   AOT( iBlendMode < -1 || iBlendMode > 2 );
 
+  Bool bBitInc = (g_uiBitIncrement != 0);
+
+  AOT( m_apcRenModels[iModelNum] );
+
+  if ( bBitInc )
+  { 
+    if ( iMode != 2 ) 
+    { // No Blending
+      m_apcRenModels[iModelNum]   = new TRenSingleModelC<BLEND_NONE, true>; 
+    }
+    else
+    {
+      switch ( iBlendMode )
+      {
+      case BLEND_AVRG: // average
+        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_AVRG, true>;       
+        break;
+      case BLEND_LEFT: // left  view is main view
+        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_LEFT, true>;       
+        break;
+      case BLEND_RIGHT: // right view is main view
+        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_RIGHT, true>;       
+        break;
+      default: 
+        AOT(true);
+        break;
+      }    
+    }
+  }
+  else
+  {
+    if ( iMode != 2 ) 
+    { // No Blending
+      m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_NONE, false>; 
+    }
+    else
+    {
+      switch ( iBlendMode )
+      {
+      case BLEND_AVRG: // average
+        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_AVRG, false>;       
+        break;
+      case BLEND_LEFT: // left  view is main view
+        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_LEFT, false>;       
+        break;
+      case BLEND_RIGHT: // right view is main view
+        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_RIGHT, false>;       
+        break;
+      default: 
+        AOT(true);
+        break;
+      }    
+    }
+  }
+
+
+#if LGE_VSO_EARLY_SKIP_A0093
+  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, iBlendMode, m_bEarlySkip );
+#else
   m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, iBlendMode );
+#endif
 
   if ( iLeftViewNum != -1 )
@@ -361,17 +430,20 @@
 }
 
-
 Void
 TRenModel::setBaseView( Int iViewNum, TComPicYuv* pcPicYuvVideoData, TComPicYuv* pcPicYuvDepthData, TComPicYuv* pcPicYuvOrgVideoData, TComPicYuv* pcPicYuvOrgDepthData )
 {
   AOT( iViewNum < 0 || iViewNum > m_iNumOfBaseViews );
-  AOF( pcPicYuvVideoData->getHeight() == m_iHeight || pcPicYuvVideoData->getWidth() == m_iWidth );
-  AOF( pcPicYuvDepthData->getHeight() == m_iHeight || pcPicYuvDepthData->getWidth() == m_iWidth );
+  AOF( pcPicYuvVideoData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvVideoData->getWidth() == m_iWidth );
+  AOF( pcPicYuvDepthData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvDepthData->getWidth() == m_iWidth );
 
   pcPicYuvVideoData->extendPicBorder();
-  TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvVideoData->getLumaAddr(), pcPicYuvVideoData->getStride() , m_iWidth,      m_iHeight,      m_aapiCurVideoPel[ iViewNum ][0], m_aaiCurVideoStrides[iViewNum][0] );
-  TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCbAddr()  , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][1], m_aaiCurVideoStrides[iViewNum][1] );
-  TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCrAddr()  , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][2], m_aaiCurVideoStrides[iViewNum][2] );
-  TRenFilter::copy          (               pcPicYuvDepthData->getLumaAddr(), pcPicYuvDepthData->getStride(),   m_iWidth,     m_iHeight,      m_apiCurDepthPel [ iViewNum],     m_aiCurDepthStrides [iViewNum]    );
+
+  
+
+
+  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]    );
 
   // Used for rendering reference pic from original video data
@@ -381,15 +453,15 @@
   if ( m_abSetupVideoFromOrgForView[iViewNum] )
   {
-    AOF( pcPicYuvOrgVideoData->getHeight() == m_iHeight || pcPicYuvOrgVideoData->getWidth() == m_iWidth );
+    AOF( pcPicYuvOrgVideoData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvOrgVideoData->getWidth() == m_iWidth );
     pcPicYuvOrgVideoData->extendPicBorder();
-    TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvOrgVideoData->getLumaAddr(), pcPicYuvOrgVideoData->getStride() , m_iWidth,      m_iHeight,      m_aapiOrgVideoPel[ iViewNum ][0], m_aaiOrgVideoStrides[iViewNum][0] );
-    TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCbAddr()  , pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][1], m_aaiOrgVideoStrides[iViewNum][1] );
-    TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCrAddr()  , pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][2], m_aaiOrgVideoStrides[iViewNum][2] );
+    TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvOrgVideoData->getLumaAddr() +  m_uiHorOff        * pcPicYuvOrgVideoData->getStride() , pcPicYuvOrgVideoData->getStride() , m_iWidth,      m_iHeight,      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_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] );
   }
 
   if ( m_abSetupDepthFromOrgForView[iViewNum] )
   {
-    AOF( pcPicYuvOrgDepthData->getHeight() == m_iHeight || pcPicYuvOrgDepthData->getWidth() == m_iWidth );
-    TRenFilter::copy          (               pcPicYuvOrgDepthData->getLumaAddr(), pcPicYuvOrgDepthData->getStride(),  m_iWidth,     m_iHeight,      m_apiOrgDepthPel [ iViewNum],     m_aiOrgDepthStrides [iViewNum]    );
+    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]    );
   }
 }
@@ -404,8 +476,10 @@
   for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ )
   {
+
     Bool bSetupFromOrgVideo = m_abSetupVideoFromOrgForView[iBaseViewIdx];
     Bool bSetupFromOrgDepth = m_abSetupDepthFromOrgForView[iBaseViewIdx];
-
-    if ( ( bSetupFromOrgVideo || bSetupFromOrgDepth ) && m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID )
+    bAnyRefFromOrg          = bAnyRefFromOrg || bSetupFromOrgVideo || bSetupFromOrgDepth;
+
+    if ( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID )
     {
       bAnyRefFromOrg = true;
@@ -418,5 +492,5 @@
   }
 
-  m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false );
+  m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false, m_uiHorOff );
 
   // Setup to Org
@@ -438,6 +512,6 @@
     }
 
-    // setup keeping reference from original data
-    m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true );
+    // setup keeping reference rendered from original data
+    m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true, m_uiHorOff);
   }
 }
@@ -468,7 +542,21 @@
 }
 
+
+Void  
+TRenModel::setHorOffset     ( UInt uiHorOff )
+{
+    m_uiHorOff = uiHorOff; 
+}
+
+#if LGE_VSO_EARLY_SKIP_A0093
+RMDist
+TRenModel::getDist( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData, Int iOrgStride)
+#else
 RMDist
 TRenModel::getDist( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
-{
+#endif
+{
+  iStartPosY -= m_uiHorOff; 
+
   AOT( iWidth  + iStartPosX > m_iWidth  );
   AOT( iHeight + iStartPosY > m_iHeight );
@@ -484,5 +572,9 @@
     if (m_iCurrentContent == 1)
     {
+#if LGE_VSO_EARLY_SKIP_A0093
+      iDist +=  m_apcCurRenModels[iModelNum]->getDistDepth  ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY,  iWidth,  iHeight,  iStride,  piNewData , piOrgData, iOrgStride);
+#else
       iDist +=  m_apcCurRenModels[iModelNum]->getDistDepth  ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY,  iWidth,  iHeight,  iStride,  piNewData );
+#endif
     }
     else
@@ -498,4 +590,6 @@
 TRenModel::setData( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
 {
+  iStartPosY -= m_uiHorOff; 
+
   iWidth  = min(iWidth , m_iWidth  - iStartPosX );
   iHeight = min(iHeight, m_iHeight - iStartPosY );
@@ -510,6 +604,10 @@
     if (m_iCurrentContent == 1)
     {
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+      Int iTargetStride = m_aiCurDepthStrides[ m_iCurrentView ];
+      m_apcCurRenModels[iModelNum]->setDepth  ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,m_apiCurDepthPel[ m_iCurrentView ] + iStartPosY * iTargetStride + iStartPosX ,iTargetStride );
+#else
       m_apcCurRenModels[iModelNum]->setDepth  ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );
-
+#endif
     }
     else
@@ -519,4 +617,5 @@
   }
 
+#ifdef LGE_VSO_EARLY_SKIP_A0093
   if (m_iCurrentContent == 1)
   {
@@ -524,37 +623,22 @@
     TRenFilter::copy( piNewData, iStride, iWidth, iHeight,  m_apiCurDepthPel[ m_iCurrentView ] + iStartPosY * iTargetStride + iStartPosX, iTargetStride );
   }
-  else
-  {
-    Int iTargetStride = m_aaiCurVideoStrides[ m_iCurrentView ][m_iCurrentPlane];
-    TRenFilter::copy( piNewData, iStride, iWidth, iHeight,  m_aapiCurVideoPel[ m_iCurrentView ][m_iCurrentPlane] + iStartPosY * iTargetStride + iStartPosX, iTargetStride);
-  }
-}
-
-Void
-TRenModel::getSynthVideo( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthVideo )
-{
-  Pel** ppiSynthVideoPel = NULL;
-  Pel*  ppiSynthDepthPel = NULL;
-  Int   iStride          = -1;
-  Int   aiStrides[3];
-
-  m_apcRenModels[iModelNum]->getSynthView(iViewNum, ppiSynthVideoPel, ppiSynthDepthPel, iStride );
-
-  aiStrides[0] = iStride; aiStrides[1] = iStride; aiStrides[2] = iStride;
-  xCopy2PicYuv( ppiSynthVideoPel, aiStrides, rpcPicYuvSynthVideo  );
-}
-
-Void
-TRenModel::getSynthDepth( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthDepth )
-{
-  Pel** ppiSynthVideoPel = NULL;
-  Pel*  piSynthDepthPel  = NULL;
-  Int   iStride          = -1;
-
-  m_apcRenModels[iModelNum]->getSynthView(iViewNum, ppiSynthVideoPel, piSynthDepthPel, iStride );
-  TRenFilter::copy( piSynthDepthPel, iStride, m_iWidth, m_iHeight, rpcPicYuvSynthDepth->getLumaAddr(), rpcPicYuvSynthDepth->getStride() );
-  rpcPicYuvSynthDepth->setChromaTo( 128 << g_uiBitIncrement );
-}
-
+#endif
+}
+
+Void
+TRenModel::getSynthVideo( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuv )
+{
+  m_apcRenModels[iModelNum]->getSynthVideo(iViewNum, pcPicYuv, m_uiHorOff );
+}
+
+Void
+TRenModel::getSynthDepth( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuv )
+{
+#if HHI_VSO_SPEEDUP_A033
+  m_apcRenModels[iModelNum]->getSynthDepth(iViewNum, pcPicYuv, m_uiHorOff );
+#else
+  m_apcRenModels[iModelNum]->getSynthDepth(iViewNum, pcPicYuv );
+#endif
+}
 
 Void
@@ -573,28 +657,7 @@
   for (Int iCurModel = 0; iCurModel < m_iNumOfCurRenModels; iCurModel++)
   {
-    Pel** ppiSynthVideoPel = NULL;
-    Pel*  ppiSynthDepthPel = NULL;
-    Pel** ppiRefVideoPel   = NULL;
-    Int   iSynStride       = -1;
-    Int*  piRefStrides     = NULL;
-    Int   aiSynStrides[3];
-
-    m_apcCurRenModels[iCurModel]->getSynthView( m_aiCurPosInModels[iCurModel], ppiSynthVideoPel, ppiSynthDepthPel, iSynStride );
-    aiSynStrides[0] = iSynStride; aiSynStrides[1] = iSynStride; aiSynStrides[2] = iSynStride;
-    xCopy2PicYuv( ppiSynthVideoPel, aiSynStrides,  &cPicYuvSynth );
-
-    TComPicYuv* pcPicYuvOrgRef;
-    TComPicYuv* pcPicYuvRef;
-    m_apcCurRenModels[iCurModel]->getRefView  ( pcPicYuvOrgRef, ppiRefVideoPel, piRefStrides );
-
-    if (!pcPicYuvOrgRef )
-    {
-      xCopy2PicYuv( ppiRefVideoPel, piRefStrides,  &cPicYuvTempRef);
-      pcPicYuvRef = &cPicYuvTempRef;
-    }
-    else
-    {
-      pcPicYuvRef = pcPicYuvOrgRef;
-    }
+    m_apcCurRenModels[iCurModel]->getSynthVideo( m_aiCurPosInModels[iCurModel], &cPicYuvSynth, 0 );
+    TComPicYuv* pcPicYuvRef = &cPicYuvTempRef;
+    m_apcCurRenModels[iCurModel]->getRefVideo  ( m_aiCurPosInModels[iCurModel], pcPicYuvRef  , 0 );
 
     iSSEY += TRenFilter::SSE( cPicYuvSynth.getLumaAddr(), cPicYuvSynth.getStride(),  m_iWidth,      m_iHeight     , pcPicYuvRef->getLumaAddr(), pcPicYuvRef->getStride() );
@@ -620,6 +683,4 @@
   m_aaeBaseViewPosInModel[iBaseViewNum][iModelNum] = iViewPos;
 
-  m_apcRenModels[iModelNum]->setLRView( iViewPos, m_aapiCurVideoPel[iBaseViewNum], m_aaiCurVideoStrides[iBaseViewNum], m_apiCurDepthPel[iBaseViewNum], m_aiCurDepthStrides [iBaseViewNum] );
-
   if (bAdd)
   {
@@ -639,10 +700,2 @@
   }
 }
-
-Void
-TRenModel::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget )
-{
-  TRenFilter::copy            ( ppiSrcVideoPel[0], piStrides[0], m_iWidth, m_iHeight, rpcPicYuvTarget->getLumaAddr(), rpcPicYuvTarget->getStride() );
-  TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[1], piStrides[1], m_iWidth, m_iHeight, rpcPicYuvTarget->getCbAddr  (), rpcPicYuvTarget->getCStride() );
-  TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iHeight, rpcPicYuvTarget->getCrAddr  (), rpcPicYuvTarget->getCStride() );
-}
Index: trunk/source/Lib/TLibRenderer/TRenModel.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenModel.h	(revision 81)
+++ trunk/source/Lib/TLibRenderer/TRenModel.h	(revision 100)
@@ -50,5 +50,9 @@
 
   // Creation
+#if LGE_VSO_EARLY_SKIP_A0093
+  Void  create           ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bEarlySkip );
+#else
   Void  create           ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin );
+#endif
   Void  createSingleModel( Int iBaseViewNum, Int iContent, Int iModelNum, Int iLeftViewNum, Int iRightViewNum, Bool bUseOrgRef, Int iBlendMode );
 
@@ -57,14 +61,22 @@
   Void  setSingleModel   ( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView );
 
+  // Set horizontal offset
+  Void  setHorOffset     ( UInt uiHorOff );
+
   // Set Mode
   Void  setErrorMode     ( Int iView, Int iContent, int iPlane );
 
   // Get Distortion, set Data
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  Int64 getDist          ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData, Int iOrgStride);
+#else
   Int64 getDist          ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData  );
+#endif
   Void  setData          ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData  );
 
   // Get Rendered View
-  Void  getSynthVideo    ( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthVideo );
-  Void  getSynthDepth    ( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthDepth );
+
+  Void  getSynthVideo    ( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuvSynthVideo );
+  Void  getSynthDepth    ( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuvSynthDepth );
 
   // Get Total Distortion
@@ -74,5 +86,4 @@
   // helpers
   Void xSetLRViewAndAddModel( Int iModelNum, Int iBaseViewNum, Int iContent, Int iViewPos, Bool bAdd );
-  Void xCopy2PicYuv ( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget );
 
   // Settings
@@ -80,4 +91,7 @@
   Int**  m_aaaiSubPelShiftLut[2];
   Int    m_iHoleMargin;
+#if LGE_VSO_EARLY_SKIP_A0093
+  Bool   m_bEarlySkip; 
+#endif
 
   /// Size of Video and Depth
@@ -88,4 +102,9 @@
 
   Int m_iNumOfBaseViews;
+
+#if HHI_VSO_SPEEDUP_A033                 
+  // Horizontal Offset in input data
+  UInt m_uiHorOff;          
+#endif
 
   /// Current Error Type ///
Index: trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 81)
+++ trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 100)
@@ -32,5 +32,4 @@
  */
 
-
 #include "TRenImage.h"
 #include "TRenFilter.h"
@@ -38,5 +37,6 @@
 
 ////////////// TRENSINGLE MODEL ///////////////
-TRenSingleModel::TRenSingleModel()
+template <BlenMod iBM, Bool bBitInc>
+TRenSingleModelC<iBM,bBitInc>::TRenSingleModelC()
 :  m_iDistShift ( g_uiBitIncrement << 1 )
 {
@@ -50,80 +50,73 @@
 
   m_pcPicYuvRef          = NULL;
+
+  m_pcOutputSamples      = NULL; 
+  m_pcOutputSamplesRow   = NULL;   
+  m_iOutputSamplesStride = -1; 
+
+  m_ppiCurLUT            = NULL;
+  m_piInvZLUTLeft        = NULL;
+  m_piInvZLUTRight       = NULL;
+
   m_aapiRefVideoPel[0]   = NULL;
   m_aapiRefVideoPel[1]   = NULL;
   m_aapiRefVideoPel[2]   = NULL;
 
-
   m_aiRefVideoStrides[0] = -1;
   m_aiRefVideoStrides[1] = -1;
   m_aiRefVideoStrides[2] = -1;
 
+
   for (UInt uiViewNum = 0 ; uiViewNum < 2; uiViewNum++)
   {
     // LUT
     m_appiShiftLut[uiViewNum] = NULL;
+
+    m_pcInputSamples[uiViewNum] = NULL; 
+    m_iInputSamplesStride       = -1; 
+
     m_ppiCurLUT               = NULL;
     m_piInvZLUTLeft           = NULL;
     m_piInvZLUTRight          = NULL;
-
-    // Cur Data
-    m_apiBaseDepthPel      [uiViewNum] = NULL;
-    m_aiBaseDepthStrides   [uiViewNum] = -1;
-
-    // State Data
-    m_apbOccluded          [uiViewNum] = NULL;
-    m_apiFilled            [uiViewNum] = NULL;
-
-    // Cur Data
-    m_aapiBaseVideoPel     [uiViewNum] = NULL;
-    m_aaiBaseVideoStrides  [uiViewNum] = NULL;
-  };
-
-  m_piError                            = NULL;
-
-  for (UInt uiViewNum = 0 ; uiViewNum < 3; uiViewNum++)
-  {
-    m_apiSynthDepthPel[uiViewNum] = NULL;
-    for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
-    {
-      // Rendered Data
-      m_aapiSynthVideoPel[uiViewNum][uiPlaneNum] = NULL;
-    }
-  }
-}
-
-TRenSingleModel::~TRenSingleModel()
-{
-  if ( m_apbOccluded[0] ) delete[] m_apbOccluded[0];
-  if ( m_apbOccluded[1] ) delete[] m_apbOccluded[1];
-
-  if ( m_apiFilled  [0] ) delete[] m_apiFilled  [0];
-  if ( m_apiFilled  [1] ) delete[] m_apiFilled  [1];
-
-  if ( m_piError        ) delete[] m_piError      ;
-
-
-  for (UInt uiViewNum = 0 ; uiViewNum < 3; uiViewNum++)
-  {
-    for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
-    {
-      if ( m_aapiSynthVideoPel[uiViewNum] && m_aapiSynthVideoPel[uiViewNum][uiPlaneNum] ) delete[] m_aapiSynthVideoPel[uiViewNum][uiPlaneNum];
-    }
-    if ( m_apiSynthDepthPel[uiViewNum] ) delete[] m_apiSynthDepthPel[uiViewNum];
-  }
-
-  delete[] (m_aapiRefVideoPel[0] - m_iPad * m_aiRefVideoStrides[0] - m_iPad );
-  delete[] (m_aapiRefVideoPel[1] - m_iPad * m_aiRefVideoStrides[1] - m_iPad );
-  delete[] (m_aapiRefVideoPel[2] - m_iPad * m_aiRefVideoStrides[2] - m_iPad );
-
-  if ( m_piInvZLUTLeft  ) delete[] m_piInvZLUTLeft;
-  if ( m_piInvZLUTRight ) delete[] m_piInvZLUTRight;
-}
-
-Void
-TRenSingleModel::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode )
-{
-  m_iBlendMode = iBlendMode;
+  }
+
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  m_pbHorSkip = NULL;
+#endif
+}
+
+template <BlenMod iBM, Bool bBitInc>
+TRenSingleModelC<iBM,bBitInc>::~TRenSingleModelC()
+{
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  if (m_pbHorSkip) 
+  {
+    delete[] m_pbHorSkip;
+    m_pbHorSkip = NULL;
+  }
+#endif
+
+  if ( m_pcInputSamples [0] ) delete[] m_pcInputSamples [0];
+  if ( m_pcInputSamples [1] ) delete[] m_pcInputSamples [1];
+  if ( m_pcOutputSamples    ) delete   m_pcOutputSamples   ;
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+#if LGE_VSO_EARLY_SKIP_A0093
+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
+
+{
+#if LGE_VSO_EARLY_SKIP_A0093
+  m_pbHorSkip     = new Bool [MAX_CU_SIZE];
+  m_bEarlySkip    = bEarlySkip; 
+#endif
+
+  AOF( iBlendMode == iBM ); 
+
   m_iMode = iMode;
+
   m_iWidth  = iWidth;
   m_iHeight = iHeight;
@@ -160,62 +153,81 @@
   m_aapiRefVideoPel  [2] += m_aiRefVideoStrides[2] * m_iPad + m_iPad;
 
-  m_piError               = new Int [m_iStride*m_iHeight];
-
-  // Create Buffers
-  if ( (m_iMode == 0) || (m_iMode == 2 ) )
-  {
-    m_apbOccluded        [0]  = new Bool[m_iStride*m_iHeight];
-    m_apiFilled          [0]  = new Pel [m_iStride*m_iHeight];
-
-    for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
-    {
-      m_aapiSynthVideoPel[0][uiPlaneNum] = new Pel[m_iStride*m_iHeight];
-    }
-  }
-
-  if ( (m_iMode == 1) || (m_iMode == 2 ) )
-  {
-    m_apbOccluded        [1]  = new Bool[m_iStride*m_iHeight];
-    m_apiFilled          [1]  = new Pel [m_iStride*m_iHeight];
-
-    for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
-    {
-      m_aapiSynthVideoPel[1][uiPlaneNum] = new Pel[m_iStride*m_iHeight];
-    }
-  }
-
-  if ( m_iMode == 2 )
-  {
-    m_apiSynthDepthPel[0] = new Pel[m_iStride*m_iHeight];
-    m_apiSynthDepthPel[1] = new Pel[m_iStride*m_iHeight];
-    m_apiSynthDepthPel[2] = new Pel[m_iStride*m_iHeight];
-
-    for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
-    {
-      m_aapiSynthVideoPel[2][uiPlaneNum] = new Pel[m_iStride*m_iHeight];
-    }
-  }
-}
-
-Void
-TRenSingleModel::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride )
+  m_iInputSamplesStride  = m_iWidth+1;
+  m_iOutputSamplesStride = m_iWidth;
+
+  m_pcInputSamples[0]     = new RenModelInPels[m_iInputSamplesStride*m_iHeight];
+  m_pcInputSamples[1]     = new RenModelInPels[m_iInputSamplesStride*m_iHeight];
+
+  m_pcOutputSamples       = new RenModelOutPels[m_iOutputSamplesStride*m_iHeight];  
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride )
 {
   AOF(( iViewPos == 0) || (iViewPos == 1) );
+
+  RenModelInPels* pcCurInputSampleRow = m_pcInputSamples[iViewPos];
+  
+  Pel* piDRow = piCurDepthPel;
+  Pel* piYRow = apiCurVideoPel[0];
+#if HHI_VSO_COLOR_PLANES
+  Pel* piURow = apiCurVideoPel[1];
+  Pel* piVRow = apiCurVideoPel[2];
+#endif  
+
+
+  Int iOffsetX = ( iViewPos == VIEWPOS_RIGHT ) ? 1 : 0;
+
+  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
+  {
+    if ( iViewPos == VIEWPOS_RIGHT )
+    {
+      Int iSubPosX = (1 << m_iShiftPrec); 
+      pcCurInputSampleRow[0].aiY[iSubPosX] = piYRow[0];
+#if HHI_VSO_COLOR_PLANES 
+      pcCurInputSampleRow[0].aiU[iSubPosX] = piURow[0];
+      pcCurInputSampleRow[0].aiV[iSubPosX] = piVRow[0];
+#endif
+    }
+
+    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
+    {
+      pcCurInputSampleRow[iPosX].iD = piDRow[iPosX];
+
+      for (Int iSubPosX = 0; iSubPosX < (1 << m_iShiftPrec)+1; iSubPosX++ )
+      { 
+        Int iShift = (iPosX << m_iShiftPrec) + iSubPosX;
+        pcCurInputSampleRow[iPosX+iOffsetX].aiY[iSubPosX] = piYRow[iShift];
+#if HHI_VSO_COLOR_PLANES 
+        pcCurInputSampleRow[iPosX+iOffsetX].aiU[iSubPosX] = piURow[iShift];
+        pcCurInputSampleRow[iPosX+iOffsetX].aiV[iSubPosX] = piVRow[iShift];
+#endif
+      }
+    } 
+
+    pcCurInputSampleRow += m_iInputSamplesStride; 
+
+    piDRow += iCurDepthStride;
+    piYRow += aiCurVideoStride[0];
+#if HHI_VSO_COLOR_PLANES
+    piURow += aiCurVideoStride[1];
+    piVRow += aiCurVideoStride[2];
+#endif
+  }
+
+  
   m_aapiBaseVideoPel      [iViewPos] = apiCurVideoPel;
   m_aaiBaseVideoStrides   [iViewPos] = aiCurVideoStride;
   m_apiBaseDepthPel       [iViewPos] = piCurDepthPel;
   m_aiBaseDepthStrides    [iViewPos] = iCurDepthStride;
-}
-
-Void
-TRenSingleModel::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference )
+
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOff )
 {
   AOT( !m_bUseOrgRef && pcOrgVideo );
   AOT( (ppiShiftLutLeft  == NULL) && (m_iMode == 0 || m_iMode == 2) );
   AOT( (ppiShiftLutRight == NULL) && (m_iMode == 1 || m_iMode == 2) );
-#if HHI_FIX
-#else
-  AOT( pcOrgVideo != NULL && bKeepReference );
-#endif
 
   m_appiShiftLut[0] = ppiShiftLutLeft;
@@ -225,35 +237,41 @@
   m_pcPicYuvRef = pcOrgVideo;
 
-#if HHI_FIX
   if ( pcOrgVideo && !bKeepReference )
-#else
-  if ( pcOrgVideo )
-#endif
-  {
-    TRenFilter::copy(             pcOrgVideo->getLumaAddr(), pcOrgVideo->getStride() , m_iWidth,      m_iHeight,      m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
-    TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCbAddr()  , pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
-    TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCrAddr()  , pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);
+  {
+    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]);    
+    xSetStructRefView();
   }
 
   // Initial Rendering
-  xSetInts( m_piError                       , m_iStride, m_iWidth, m_iHeight, 0 );
+  xResetStructError();
+  xInitSampleStructs();
 
   switch ( m_iMode )
-  {
-  case 0:
-    xInitView( VIEWPOS_LEFT );
-    xRenderL( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0], true );
+  {  
+  case 0:   
+#if LGE_VSO_EARLY_SKIP_A0093
+    xRenderL<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false );
+#else
+    xRenderL<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
+#endif   
     break;
-  case 1:
-    xInitView( VIEWPOS_RIGHT );
-    xRenderR( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1], true );
+  case 1:    
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    xRenderR<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
+#else
+    xRenderR<true>( 0, 0, m_iWidth, m_iHeight, 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 );
-    xInitView( VIEWPOS_LEFT   );
-    xInitView( VIEWPOS_RIGHT  );
-    xInitView( VIEWPOS_MERGED );
-    xRenderL( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0], true );
-    xRenderR( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1], true );
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    xRenderL<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false);
+    xRenderR<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
+#else      
+    xRenderL<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
+    xRenderR<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
+#endif
     break;
   default:
@@ -264,66 +282,338 @@
   if ( !pcOrgVideo && !bKeepReference )
   {
-    xSetInts        ( m_piError                       , m_iStride, m_iWidth, m_iHeight, 0 );
-      TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][0], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
-      TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][1], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
-      TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][2], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);
-  }
-}
-
-RMDist
-TRenSingleModel::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
-{
-  RMDist iSSE = 0;
-  switch (iViewPos )
+    xResetStructError();
+    xSetStructSynthViewAsRefView();
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+#if HHI_VSO_COLOR_PLANES
+TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY, Pel RenModelOutPels::*& rpiSrcU, Pel RenModelOutPels::*& rpiSrcV )
+#else
+TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY )
+#endif
+{
+  switch ( iViewNum )
   {
   case 0:
-    iSSE = xRenderL( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, false );
+    rpiSrcY = &RenModelOutPels::iYLeft;
+#if HHI_VSO_COLOR_PLANES  
+    rpiSrcU = &RenModelOutPels::iULeft;
+    rpiSrcV = &RenModelOutPels::iVLeft;
+#endif
     break;
   case 1:
-    iSSE = xRenderR( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, false );
+    rpiSrcY = &RenModelOutPels::iYRight;
+#if HHI_VSO_COLOR_PLANES  
+    rpiSrcU = &RenModelOutPels::iURight;
+    rpiSrcV = &RenModelOutPels::iVRight;
+#endif
+    break;
+  case 2:
+    rpiSrcY = &RenModelOutPels::iYBlended;
+#if HHI_VSO_COLOR_PLANES  
+    rpiSrcU = &RenModelOutPels::iUBlended;
+    rpiSrcV = &RenModelOutPels::iVBlended;
+#endif
+    break;
+  }
+}
+
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD )
+{
+  AOT(iViewNum != 0 && iViewNum != 1);  
+  rpiSrcD = (iViewNum == 1) ? &RenModelOutPels::iDRight : &RenModelOutPels::iDLeft; 
+}
+
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xSetStructRefView( )
+{
+  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
+  
+  Pel* piYRow = m_aapiRefVideoPel[0];
+#if HHI_VSO_COLOR_PLANES
+  Pel* piURow = m_aapiRefVideoPel[1];
+  Pel* piVRow = m_aapiRefVideoPel[2];
+#endif  
+
+  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
+  {
+    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
+    {      
+      pcCurOutSampleRow[iPosX].iYRef = piYRow[iPosX];
+#if HHI_VSO_COLOR_PLANES
+      pcCurOutSampleRow[iPosX].iURef = piURow[iPosX];
+      pcCurOutSampleRow[iPosX].iVRef = piVRow[iPosX];
+#endif
+    } 
+
+    pcCurOutSampleRow += m_iOutputSamplesStride; 
+    
+    piYRow += m_aiRefVideoStrides[0];
+#if HHI_VSO_COLOR_PLANES
+    piURow += m_aiRefVideoStrides[1];
+    piVRow += m_aiRefVideoStrides[2];
+#endif
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xResetStructError( )
+{
+  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
+
+  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
+  {
+    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
+    {      
+      pcCurOutSampleRow[iPosX].iError = 0;
+    } 
+    pcCurOutSampleRow += m_iOutputSamplesStride; 
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xSetStructSynthViewAsRefView( )
+{
+  AOT( m_iMode < 0 || m_iMode > 2);
+
+  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
+
+  Pel RenModelOutPels::* piSrcY = NULL;
+
+#if HHI_VSO_COLOR_PLANES  
+  Pel RenModelOutPels::* piSrcU = NULL;
+  Pel RenModelOutPels::* piSrcV = NULL;
+  xGetSampleStrTextPtrs( m_iMode, piSrcY, piSrcU, piSrcV );
+#else
+  xGetSampleStrTextPtrs( m_iMode, piSrcY );
+#endif
+
+  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
+  {
+    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
+    {      
+      pcCurOutSampleRow[iPosX].iYRef = pcCurOutSampleRow[iPosX].*piSrcY;
+#if HHI_VSO_COLOR_PLANES
+      pcCurOutSampleRow[iPosX].iURef = pcCurOutSampleRow[iPosX].*piSrcU;
+      pcCurOutSampleRow[iPosX].iVRef = pcCurOutSampleRow[iPosX].*piSrcV;
+#endif
+    } 
+    pcCurOutSampleRow += m_iOutputSamplesStride; 
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xInitSampleStructs()
+{
+  RenModelOutPels* pcOutSampleRow      = m_pcOutputSamples;
+  RenModelInPels * pcLeftInSampleRow   = m_pcInputSamples[0];
+  RenModelInPels * pcRightInSampleRow  = m_pcInputSamples[1];
+
+
+  for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
+  {
+    for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
+    {
+      //// Output Samples
+      pcOutSampleRow[iPosX].iFilledLeft   = REN_IS_HOLE;
+      pcOutSampleRow[iPosX].iFilledRight  = REN_IS_HOLE;
+
+      pcOutSampleRow[iPosX].iDLeft        = 0;
+      pcOutSampleRow[iPosX].iDRight       = 0;
+      pcOutSampleRow[iPosX].iDBlended     = 0;      
+                                     
+      // Y Planes                    
+      pcOutSampleRow[iPosX].iYLeft        = 0;
+      pcOutSampleRow[iPosX].iYRight       = 0;
+      pcOutSampleRow[iPosX].iYBlended     = 0;
+#if HHI_VSO_COLOR_PLANES             
+      // U Planes                    
+      pcOutSampleRow[iPosX].iULeft        = 128 << g_uiBitIncrement;
+      pcOutSampleRow[iPosX].iURight       = 128 << g_uiBitIncrement;
+      pcOutSampleRow[iPosX].iUBlended     = 128 << g_uiBitIncrement;
+                                     
+      // V Planes                    
+      pcOutSampleRow[iPosX].iVLeft        = 128 << g_uiBitIncrement;
+      pcOutSampleRow[iPosX].iVRight       = 128 << g_uiBitIncrement;
+      pcOutSampleRow[iPosX].iVBlended     = 128 << g_uiBitIncrement;
+#endif
+      //// Input Samples
+      pcLeftInSampleRow [iPosX].bOccluded = false;
+      pcRightInSampleRow[iPosX].bOccluded = false;
+    }
+
+    pcOutSampleRow     += m_iOutputSamplesStride;
+    pcLeftInSampleRow  += m_iInputSamplesStride;
+    pcRightInSampleRow += m_iInputSamplesStride;
+  }  
+}
+
+
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+template <BlenMod iBM, Bool bBitInc> RMDist
+TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData , Pel * piOrgData, Int iOrgStride )
+#else
+template <BlenMod iBM, Bool bBitInc> RMDist
+TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
+#endif
+{
+  RMDist iSSE = 0;
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  Bool   bEarlySkip;
+#endif
+  switch ( iViewPos )
+  {
+  case 0:
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
+    if( !bEarlySkip )
+    {
+      iSSE = xRenderL<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
+    }    
+#else
+    iSSE = xRenderL<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
+#endif
+    break;
+  case 1:
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
+    if( !bEarlySkip )
+    {
+      iSSE = xRenderR<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
+    }    
+#else
+    iSSE = xRenderR<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
+#endif
     break;
   default:
     assert(0);
   }
+
   return iSSE;
 }
-
-Void
-TRenSingleModel::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
-{
-  switch (iViewPos )
-  {
-    case 0:
-      xRenderL( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, true );
-      break;
-    case 1:
-      xRenderR( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, true );
-      break;
-    default:
-      assert(0);
-  }
-}
-
-
-Void
-TRenSingleModel::getSynthView( Int iViewPos, Pel**& rppiRenVideoPel, Pel*& rpiRenDepthPel, Int& riStride )
-{
-  rppiRenVideoPel = m_aapiSynthVideoPel[iViewPos];
-  rpiRenDepthPel  = m_apiSynthDepthPel [iViewPos];
-  riStride = m_iStride;
-}
-
-
-Void
-TRenSingleModel::getRefView( TComPicYuv*& rpcPicYuvRefView, Pel**& rppiRefVideoPel, Int*& raiStrides )
-{
-  rpcPicYuvRefView = m_pcPicYuvRef;
-  rppiRefVideoPel  = m_aapiRefVideoPel;
-  raiStrides       = m_aiRefVideoStrides;
-}
-
-
-RMDist
-TRenSingleModel::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel* piOrgData, Int iOrgStride )
+#else
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
+#endif
+{
+#ifdef  LGE_VSO_EARLY_SKIP_A0093
+  Bool bEarlySkip;
+#endif
+  switch ( iViewPos )
+  {
+  case 0:
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
+    if( !bEarlySkip )
+    {
+      xRenderL<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
+    }    
+#else
+    xRenderL<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
+#endif     
+    break;
+  case 1:
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
+    if( !bEarlySkip )
+    {
+      xRenderR<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true ); 
+    }    
+#else
+    xRenderR<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
+#endif     
+    break;
+  default:
+    assert(0);
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::getSynthVideo( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset )
+{  
+  AOT( pcPicYuv->getWidth() != m_iWidth );
+  AOT( pcPicYuv->getHeight() > m_iHeight + uiHorOffset );
+
+#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_iHeight, 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_iHeight);
+  }  
+
+  xCopy2PicYuv( apiData, aiStrides, pcPicYuv, uiHorOffset );
+#else
+  Pel RenModelOutPels::* piY;
+  xGetSampleStrTextPtrs(iViewPos, piY); 
+  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piY, pcPicYuv->getLumaAddr() + uiHorOffset * pcPicYuv->getStride(), pcPicYuv->getStride(), m_iWidth, m_iHeight );
+  pcPicYuv->setChromaTo( 128 << g_uiBitIncrement );   
+#endif  
+}
+
+
+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 );
+
+  Pel RenModelOutPels::* piD = 0;
+  xGetSampleStrDepthPtrs(iViewPos, piD); 
+  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piD, pcPicYuv->getLumaAddr() + pcPicYuv->getStride() * uiHorOff, pcPicYuv->getStride(), m_iWidth, m_iHeight );
+  pcPicYuv->setChromaTo( 128 << g_uiBitIncrement );   
+}
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset )
+{  
+  AOT( pcPicYuv->getWidth()  != m_iWidth  );
+  AOT( pcPicYuv->getHeight() >  m_iHeight + uiHorOffset);
+
+#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_iHeight, 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_iHeight);
+  }  
+
+  xCopy2PicYuv( apiData, aiStrides, pcPicYuv, uiHorOffset );
+#else
+  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, &RenModelOutPels::iYRef, pcPicYuv->getLumaAddr() *  pcPicYuv->getStride() + uiHorOffset, pcPicYuv->getStride(), m_iWidth, m_iHeight );
+  pcPicYuv->setChromaTo( 128 << g_uiBitIncrement );   
+#endif  
+}
+
+
+template <BlenMod iBM, Bool bBitInc> RMDist
+TRenSingleModelC<iBM,bBitInc>::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
 {
   AOF(false);
@@ -331,6 +621,6 @@
 }
 
-Void
-TRenSingleModel::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
 {
   AOF(false);
@@ -339,83 +629,33 @@
 
 
-__inline Void
-TRenSingleModel::xSetViewRow( Int iPosY )
-{
-  m_aapiBaseVideoPelRow     [m_iCurViewPos][0] = m_aapiBaseVideoPel   [m_iCurViewPos]  [0] + m_aaiBaseVideoStrides [ m_iCurViewPos ][0] * iPosY;
-  m_aapiBaseVideoPelRow     [m_iCurViewPos][1] = m_aapiBaseVideoPel   [m_iCurViewPos]  [1] + m_aaiBaseVideoStrides [ m_iCurViewPos ][1] * iPosY;
-  m_aapiBaseVideoPelRow     [m_iCurViewPos][2] = m_aapiBaseVideoPel   [m_iCurViewPos]  [2] + m_aaiBaseVideoStrides [ m_iCurViewPos ][2] * iPosY;
-
-  m_apiBaseDepthPelRow      [m_iCurViewPos]    = m_apiBaseDepthPel    [m_iCurViewPos]      + m_aiBaseDepthStrides  [ m_iCurViewPos]     * iPosY;
-  m_apbOccludedRow          [m_iCurViewPos]    = m_apbOccluded        [m_iCurViewPos]      + m_iStride                                  * iPosY;
-  m_apiFilledRow            [m_iCurViewPos]    = m_apiFilled          [m_iCurViewPos]      + m_iStride                                  * iPosY;
-  m_apiErrorRow                                = m_piError                                 + m_iStride                                  * iPosY;
-
-  m_aapiSynthVideoPelRow    [m_iCurViewPos][0] = m_aapiSynthVideoPel  [m_iCurViewPos]  [0] + m_iStride                                  * iPosY;
-  m_aapiSynthVideoPelRow    [m_iCurViewPos][1] = m_aapiSynthVideoPel  [m_iCurViewPos]  [1] + m_iStride                                  * iPosY;
-  m_aapiSynthVideoPelRow    [m_iCurViewPos][2] = m_aapiSynthVideoPel  [m_iCurViewPos]  [2] + m_iStride                                  * iPosY;
-
-  m_aapiRefVideoPelRow                     [0] = m_aapiRefVideoPel                     [0] + m_aiRefVideoStrides                    [0] * iPosY;
-  m_aapiRefVideoPelRow                     [1] = m_aapiRefVideoPel                     [1] + m_aiRefVideoStrides                    [1] * iPosY;
-  m_aapiRefVideoPelRow                     [2] = m_aapiRefVideoPel                     [2] + m_aiRefVideoStrides                    [2] * iPosY;
-
-  if (m_iMode == 2)
-  {
-    m_apiSynthDepthPelRow [m_iCurViewPos ]     = m_apiSynthDepthPel   [m_iCurViewPos]      + m_iStride                                  * iPosY;
-    m_aapiSynthVideoPelRow[m_iOtherViewPos][0] = m_aapiSynthVideoPel  [m_iOtherViewPos][0] + m_iStride                                  * iPosY;
-    m_aapiSynthVideoPelRow[m_iOtherViewPos][1] = m_aapiSynthVideoPel  [m_iOtherViewPos][1] + m_iStride                                  * iPosY;
-    m_aapiSynthVideoPelRow[m_iOtherViewPos][2] = m_aapiSynthVideoPel  [m_iOtherViewPos][2] + m_iStride                                  * iPosY;
-
-    m_apiFilledRow        [m_iOtherViewPos]    = m_apiFilled          [m_iOtherViewPos]    + m_iStride                                  * iPosY;
-    m_apiSynthDepthPelRow [m_iOtherViewPos]    = m_apiSynthDepthPel   [m_iOtherViewPos]    + m_iStride                                  * iPosY;
-
-    m_aapiSynthVideoPelRow[2              ][0] = m_aapiSynthVideoPel[2]                [0] + m_iStride                                  * iPosY;
-    m_aapiSynthVideoPelRow[2              ][1] = m_aapiSynthVideoPel[2]                [1] + m_iStride                                  * iPosY;
-    m_aapiSynthVideoPelRow[2              ][2] = m_aapiSynthVideoPel[2]                [2] + m_iStride                                  * iPosY;
-  }
-}
-
-__inline Void
-TRenSingleModel::xIncViewRow( )
-{
-  m_aapiBaseVideoPelRow     [m_iCurViewPos][0] += m_aaiBaseVideoStrides [ m_iCurViewPos ][0];
-  m_aapiBaseVideoPelRow     [m_iCurViewPos][1] += m_aaiBaseVideoStrides [ m_iCurViewPos ][1];
-  m_aapiBaseVideoPelRow     [m_iCurViewPos][2] += m_aaiBaseVideoStrides [ m_iCurViewPos ][2];
-
-  m_apiBaseDepthPelRow      [m_iCurViewPos]    += m_aiBaseDepthStrides  [ m_iCurViewPos]    ;
-  m_apbOccludedRow          [m_iCurViewPos]    += m_iStride                                 ;
-  m_apiFilledRow            [m_iCurViewPos]    += m_iStride                                 ;
-  m_apiErrorRow                                += m_iStride                                 ;
-
-  m_aapiSynthVideoPelRow    [m_iCurViewPos][0] += m_iStride                                 ;
-  m_aapiSynthVideoPelRow    [m_iCurViewPos][1] += m_iStride                                 ;
-  m_aapiSynthVideoPelRow    [m_iCurViewPos][2] += m_iStride                                 ;
-
-  m_aapiRefVideoPelRow                     [0] += m_aiRefVideoStrides                    [0];
-  m_aapiRefVideoPelRow                     [1] += m_aiRefVideoStrides                    [1];
-  m_aapiRefVideoPelRow                     [2] += m_aiRefVideoStrides                    [2];
-
-  if (m_iMode == 2)
-  {
-    m_apiSynthDepthPelRow [m_iCurViewPos ]     += m_iStride                                 ;    // This is correct!
-
-    m_aapiSynthVideoPelRow[m_iOtherViewPos][0] += m_iStride                                 ;
-    m_aapiSynthVideoPelRow[m_iOtherViewPos][1] += m_iStride                                 ;
-    m_aapiSynthVideoPelRow[m_iOtherViewPos][2] += m_iStride                                 ;
-
-    m_apiFilledRow        [m_iOtherViewPos]    += m_iStride                                 ;
-    m_apiSynthDepthPelRow [m_iOtherViewPos]    += m_iStride                                 ;
-
-    m_aapiSynthVideoPelRow[2              ][0] += m_iStride                                 ;
-    m_aapiSynthVideoPelRow[2              ][1] += m_iStride                                 ;
-    m_aapiSynthVideoPelRow[2              ][2] += m_iStride                                 ;
-  }
-}
-
-__inline RMDist
-TRenSingleModel::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bAdd )
-{
-  m_bSet             = bAdd;
-  m_iCurViewPos      = 0;
-  m_iOtherViewPos    = 1;
+template <BlenMod iBM, Bool bBitInc> __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
+TRenSingleModelC<iBM,bBitInc>::xIncViewRow( )
+{
+  m_pcInputSamplesRow[0] += m_iInputSamplesStride ;
+  m_pcInputSamplesRow[1] += m_iInputSamplesStride ;
+  m_pcOutputSamplesRow   += m_iOutputSamplesStride;  
+}
+#if LGE_VSO_EARLY_SKIP_A0093
+template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist 
+TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, 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, Pel* piNewData)
+#endif
+{
+  const Int iCurViewPos   = 0;
+  const Int iOtherViewPos = 1;
+
+  m_iCurViewPos   = iCurViewPos  ; 
+  m_iOtherViewPos = iOtherViewPos;
 
   m_piNewDepthData   = piNewData;
@@ -426,8 +666,6 @@
     return 0;
 
-  //TODO: Specialize to left and right; setData and getDist
-
   // Get Data
-  m_ppiCurLUT      = m_appiShiftLut   [m_iCurViewPos];
+  m_ppiCurLUT      = m_appiShiftLut   [iCurViewPos];
 
   xSetViewRow      ( iStartPosY);
@@ -441,4 +679,15 @@
   for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
   {
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    if( m_bEarlySkip && bFast )
+    {
+      if ( m_pbHorSkip[iPosY-iStartPosY] )
+      {
+        xIncViewRow();
+        m_piNewDepthData += iStride;
+        continue;
+      }
+    }
+#endif
     m_bInOcclusion = false;
 
@@ -454,8 +703,15 @@
       m_iLastOccludedSPos   = iCurSPos + 1;
       m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos );
-      xExtrapolateMarginL  ( iCurSPos, iEndChangePos, iError );
-      iMinChangedSPos       = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
+      xExtrapolateMarginL<bSet>  ( iCurSPos, iEndChangePos, iError );
+
+      iMinChangedSPos       = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( Max(m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]);
       iLastSPos             = iCurSPos;
       m_iLastDepth          = m_iCurDepth;
+
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD = m_piNewDepthData[iPosXinNewData];
+      }
+
       iPosXinNewData--;
       iEndChangePos--;
@@ -464,5 +720,5 @@
     {
       iLastSPos    = xShift(iEndChangePos+1);
-      m_iLastDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos+1];
+      m_iLastDepth = m_pcInputSamplesRow [iCurViewPos][iEndChangePos+1].iD;
       xInitRenderPartL( iEndChangePos, iLastSPos );
     }
@@ -473,10 +729,17 @@
     {
       // Get minimal changed sample position
-      iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
+
+      iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( Max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]);
       Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
       m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
-      xRenderRangeL(iCurSPos, iLastSPos, iCurPosX, iError );
+      xRenderRangeL<bSet>(iCurSPos, iLastSPos, iCurPosX, iError );
       iLastSPos       = iCurSPos;
       m_iLastDepth    = m_iCurDepth;
+
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];
+      }
+
       iPosXinNewData--;
     }
@@ -486,6 +749,7 @@
     {
       Int iCurSPos = xShift(iCurPosX);
-      m_iCurDepth  = m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX];
-      xRenderRangeL( iCurSPos, iLastSPos, iCurPosX, iError );
+
+      m_iCurDepth  = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
+      xRenderRangeL<bSet>( iCurSPos, iLastSPos, iCurPosX, iError );
 
       if ( iCurSPos < iMinChangedSPos )
@@ -499,4 +763,5 @@
     }
 
+
     xIncViewRow();
     m_piNewDepthData += iStride;
@@ -505,11 +770,18 @@
 }
 
-
-__inline RMDist
-TRenSingleModel::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bAdd )
-{
-  m_bSet             = bAdd;
-  m_iCurViewPos      = 1;
-  m_iOtherViewPos    = 0;
+#ifdef  LGE_VSO_EARLY_SKIP_A0093
+template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist
+TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, 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, Pel* piNewData )
+#endif
+{
+
+  const Int iCurViewPos   = 1;
+  const Int iOtherViewPos = 0;
+
+  m_iCurViewPos      = iCurViewPos;
+  m_iOtherViewPos    = iOtherViewPos;
 
   m_piNewDepthData   = piNewData;
@@ -521,6 +793,5 @@
 
   // Get Data
-  m_ppiCurLUT      = m_appiShiftLut   [m_iCurViewPos];
-
+  m_ppiCurLUT      = m_appiShiftLut   [iCurViewPos];
   xSetViewRow      ( iStartPosY);
 
@@ -534,4 +805,16 @@
   for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
   {
+
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+    if( m_bEarlySkip && bFast )
+    {
+      if ( m_pbHorSkip[iPosY-iStartPosY] )
+      {
+        xIncViewRow();
+        m_piNewDepthData += iStride;
+        continue;
+      }
+    }
+#endif
     m_bInOcclusion = false;
 
@@ -547,8 +830,15 @@
       m_iLastOccludedSPos   = iCurSPos - 1;
       m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos );
-      xExtrapolateMarginR     ( iCurSPos, iStartChangePos, iError );
-      iMaxChangedSPos       = max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
+      xExtrapolateMarginR<bSet>     ( iCurSPos, iStartChangePos, iError );
+
+      iMaxChangedSPos       = Max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( 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++;
@@ -557,5 +847,6 @@
     {
       iLastSPos   = xShift(iStartChangePos-1);
-      m_iLastDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos-1];
+
+      m_iLastDepth = m_pcInputSamplesRow[iCurViewPos][iStartChangePos-1].iD;
       xInitRenderPartR( iStartChangePos, iLastSPos );
     }
@@ -566,10 +857,17 @@
     {
       // Get minimal changed sample position
-      iMaxChangedSPos = max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
+
+      iMaxChangedSPos = Max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( Max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]);
       Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
       m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
-      xRenderRangeR(iCurSPos, iLastSPos, iCurPosX, iError );
+      xRenderRangeR<bSet>(iCurSPos, iLastSPos, iCurPosX, iError );
       iLastSPos      = iCurSPos;
       m_iLastDepth    = m_iCurDepth;
+
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];
+      }
+
       iPosXinNewData++;
     }
@@ -579,6 +877,7 @@
     {
       Int iCurSPos = xShift(iCurPosX);
-      m_iCurDepth  = m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX];
-      xRenderRangeR( iCurSPos, iLastSPos, iCurPosX, iError );
+
+      m_iCurDepth  = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
+      xRenderRangeR<bSet>( iCurSPos, iLastSPos, iCurPosX, iError );
 
       if ( iCurSPos > iMaxChangedSPos )
@@ -590,4 +889,5 @@
       m_iLastDepth = m_iCurDepth;
     }
+
     xIncViewRow();
     m_piNewDepthData += iStride;
@@ -597,14 +897,18 @@
 
 
-__inline Void
-TRenSingleModel::xInitRenderPartL(  Int iEndChangePos, Int iLastSPos )
-{
+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_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] ) )
+
+  if ( ( iCurPosX + 1 < m_iWidth ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded ) )
   {
     iCurPosX++;
-    while ( (iCurPosX + 1 < m_iWidth) &&  (m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] )  )
+
+    while ( (iCurPosX + 1 < m_iWidth) &&  (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded  )  )
+
       iCurPosX++;
 
@@ -630,14 +934,16 @@
 };
 
-__inline Void
-TRenSingleModel::xInitRenderPartR(  Int iStartChangePos, Int 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_apbOccludedRow[m_iCurViewPos][ iCurPosX - 1] ) )
+  if ( ( iCurPosX - 1 > -1 ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded  ) )
   {
     iCurPosX--;
-    while ( (iCurPosX - 1 > -1 ) &&  (m_apbOccludedRow[m_iCurViewPos][ iCurPosX - 1] )  )
+
+    while ( (iCurPosX - 1 > -1 ) &&  (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded  )  )
       iCurPosX--;
 
@@ -663,6 +969,6 @@
 
 
-__inline Void
-TRenSingleModel::xRenderShiftedRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
+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 );
@@ -672,5 +978,5 @@
   if ( iDeltaSPos > m_iGapTolerance )
   {
-    xFillHoleL( iCurSPos, iLastSPos, iCurPos, riError );
+    xFillHoleL<bSet>( iCurSPos, iLastSPos, iCurPos, riError );
   }
   else
@@ -679,31 +985,29 @@
       return;
 
-    AOT( iDeltaSPos    > m_iGapTolerance );
+    RM_AOT( iDeltaSPos    > m_iGapTolerance );
 
     m_iThisDepth = m_iCurDepth;
-    for (Int iFillSPos = max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ )
+    for (Int iFillSPos = Max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ )
     {
       Int iDeltaCurSPos  = (iFillSPos << m_iShiftPrec) - iCurSPos;
 
-      AOT( iDeltaCurSPos > iDeltaSPos );
-      AOT( iDeltaCurSPos < 0 );
-      AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
-
-      Int iSourcePos = (iCurPos  << m_iShiftPrec) +  m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos];   // GT:  = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos;
-      xSetShiftedPel( iSourcePos, iFillSPos, REN_IS_FILLED, riError );
+      RM_AOT( iDeltaCurSPos > iDeltaSPos );
+      RM_AOT( iDeltaCurSPos < 0 );
+      RM_AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
+
+      xSetShiftedPelL<bSet>( iCurPos, m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );
     }
   };
 }
 
-__inline Void
-TRenSingleModel::xRenderShiftedRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& 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 );
-  //assert( iRightSPos < m_iWidth );
 
   Int iDeltaSPos = iCurSPos - iLastSPos;
   if ( iDeltaSPos > m_iGapTolerance )
   {
-    xFillHoleR( iCurSPos, iLastSPos, iCurPos, riError );
+    xFillHoleR<bSet>( iCurSPos, iLastSPos, iCurPos, riError );
   }
   else
@@ -713,16 +1017,14 @@
 
     m_iThisDepth = m_iCurDepth;
-    AOT( iDeltaSPos    > m_iGapTolerance );
+    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;
 
-      AOT( iDeltaCurSPos > iDeltaSPos );
-      AOT( iDeltaCurSPos < 0 );
-      AOT( m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
-
-      Int iSourcePos = (iCurPos  << m_iShiftPrec) +  m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos];   // GT:  = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos;
-
-      xSetShiftedPel( iSourcePos, iFillSPos, REN_IS_FILLED, riError );
+      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 );
     }
   };
@@ -731,7 +1033,8 @@
 
 
-__inline Void
-TRenSingleModel::xRenderRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& 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 )
   {
@@ -744,5 +1047,6 @@
       {
         m_iThisDepth = m_iLastDepth;
-        xSetShiftedPel( (iCurPos+1) << m_iShiftPrec, iRightSPosFP, REN_IS_FILLED, riError );
+
+        xSetShiftedPelL<bSet>( iCurPos+1, 0, iRightSPosFP, REN_IS_FILLED, riError );
       }
       m_iLastOccludedSPosFP = iRightSPosFP;
@@ -750,17 +1054,17 @@
       m_bInOcclusion = true;
 
-      if ( m_bSet )
-      {
-        m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true;
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = true;
       }
     }
     else
     {
-      if ( m_bSet )
-      {
-        m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false;
-      }
-
-      xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, riError );
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = false;
+      }
+
+      xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
     }
   }
@@ -770,24 +1074,25 @@
     {
       m_bInOcclusion = false;
-      if ( m_bSet )
-      {
-        m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false;
-      }
-
-      xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, riError );
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = false;
+      }
+
+      xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
     }
     else
     {
-      if ( m_bSet )
-      {
-        m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true;
-      }
-    }
-  }
-}
-
-__inline Void
-TRenSingleModel::xRenderRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
-{
+      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 )
@@ -801,5 +1106,5 @@
       {
         m_iThisDepth = m_iLastDepth;
-        xSetShiftedPel( (iCurPos-1) << m_iShiftPrec, iLeftSPosFP, REN_IS_FILLED, riError );
+        xSetShiftedPelR<bSet>( iCurPos-1,1 << m_iShiftPrec , iLeftSPosFP, REN_IS_FILLED, riError );
       }
       m_iLastOccludedSPosFP = iLeftSPosFP;
@@ -807,17 +1112,17 @@
       m_bInOcclusion = true;
 
-      if ( m_bSet )
-      {
-        m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true;
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = true;
       }
     }
     else
     {
-      if ( m_bSet )
-      {
-        m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false;
-      }
-
-      xRenderShiftedRangeR(iCurSPos, iLastSPos, iCurPos, riError );
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = false;
+      }
+
+      xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
     }
   }
@@ -827,23 +1132,23 @@
     {
       m_bInOcclusion = false;
-      if ( m_bSet )
-      {
-        m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false;
-      }
-
-      xRenderShiftedRangeR(iCurSPos, iLastSPos, iCurPos, riError );
+      if ( bSet )
+      {
+        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = false;
+      }
+
+      xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
     }
     else
     {
-      if ( m_bSet )
-      {
-        m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true;
-      }
-    }
-  }
-}
-
-__inline Void
-TRenSingleModel::xFillHoleL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
+      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 )
 {
   if (iLastSPos < 0)
@@ -861,5 +1166,5 @@
     {
       m_iThisDepth = m_iCurDepth;
-      xSetShiftedPel     ( iStartFillPos << m_iShiftPrec, iStartFillSPosFP, REN_IS_FILLED, riError );
+      xSetShiftedPelL<bSet>    ( iStartFillPos, 0, iStartFillSPosFP, REN_IS_FILLED, riError );
     }
   }
@@ -870,12 +1175,12 @@
 
   m_iThisDepth = m_iLastDepth;
-  for (Int iFillSPos = max(iStartFillSPosFP+1,0); iFillSPos <= min(xRangeRightL( iLastSPos ), m_iLastOccludedSPosFP-1 ); iFillSPos++ )
-  {
-    xSetShiftedPel( iLastPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
-  }
-}
-
-__inline Void
-TRenSingleModel::xFillHoleR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
+  for (Int iFillSPos = 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)
@@ -893,5 +1198,5 @@
     {
       m_iThisDepth = m_iCurDepth;
-      xSetShiftedPel( iEndFillPos << m_iShiftPrec, iStartFillSPosFP, REN_IS_FILLED, riError );
+      xSetShiftedPelR<bSet>( iEndFillPos, 1 << m_iShiftPrec , iStartFillSPosFP, REN_IS_FILLED, riError );
     }
   }
@@ -904,30 +1209,30 @@
   for (Int iFillSPos = max(xRangeLeftR( iLastSPos ), m_iLastOccludedSPosFP+1); iFillSPos <= min(iStartFillSPosFP,m_iWidth)-1 ; iFillSPos++ )
   {
-    xSetShiftedPel( iLastPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
-  }
-}
-
-__inline Void
-TRenSingleModel::xExtrapolateMarginL(Int iCurSPos, Int iCurPos, RMDist& riError )
+    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 = max(0,xRangeLeftL(iCurSPos));
+  Int iSPosFullPel = Max(0,xRangeLeftL(iCurSPos));
 
   m_iThisDepth = m_iCurDepth;
   if (iSPosFullPel < m_iWidth)
   {
-    xSetShiftedPel( iCurPos << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError );
+    xSetShiftedPelL<bSet>( iCurPos, 0, iSPosFullPel, REN_IS_FILLED, riError );
   }
 
   for (Int iFillSPos = iSPosFullPel +1; iFillSPos < m_iWidth; iFillSPos++ )
   {
-    xSetShiftedPel( iCurPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
-  }
-}
-
-__inline Void
-TRenSingleModel::xExtrapolateMarginR(Int iCurSPos, Int iCurPos, RMDist& riError )
+    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 )
@@ -939,34 +1244,34 @@
   if (iSPosFullPel > -1)
   {
-    xSetShiftedPel( iCurPos << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError );
+    xSetShiftedPelR<bSet>( iCurPos, 1 << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError );
   }
 
   for (Int iFillSPos = iSPosFullPel -1; iFillSPos > -1; iFillSPos-- )
   {
-    xSetShiftedPel( iCurPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
-  }
-}
-
-
-__inline Int
-TRenSingleModel::xShiftNewData( Int iPosX, Int iPosInNewData )
-{
-  AOT( iPosInNewData <               0 );
-  AOF( iPosInNewData < m_iNewDataWidth );
-
-  return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_piNewDepthData[iPosInNewData] )];
-}
-
-__inline Int
-TRenSingleModel::xShift( Int iPosX )
-{
- AOT( iPosX <        0);
- AOF( iPosX < m_iWidth);
- return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_apiBaseDepthPelRow[m_iCurViewPos][iPosX] )];
-}
-
-
-__inline Int
-TRenSingleModel::xShift( Int iPos, Int iPosInNewData )
+    xSetShiftedPelR<bSet>( iCurPos , 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> __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>::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
+TRenSingleModelC<iBM,bBitInc>::xShift( Int iPos, Int iPosInNewData )
 {
   if ( (iPosInNewData >= 0) && (iPosInNewData < m_iNewDataWidth) )
@@ -980,6 +1285,6 @@
 }
 
-__inline Int
-TRenSingleModel::xRangeLeftL( Int iPos )
+template <BlenMod iBM, Bool bBitInc> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRangeLeftL( Int iPos )
 {
   return  ( iPos +  (1 << m_iShiftPrec) - 1) >> m_iShiftPrec;
@@ -987,6 +1292,6 @@
 
 
-__inline Int
-TRenSingleModel::xRangeLeftR( Int iPos )
+template <BlenMod iBM, Bool bBitInc> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRangeLeftR( Int iPos )
 {
 
@@ -995,12 +1300,12 @@
 
 
-__inline Int
-TRenSingleModel::xRangeRightL( Int iPos )
+template <BlenMod iBM, Bool bBitInc> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRangeRightL( Int iPos )
 {
   return xRangeLeftL(iPos) - 1;
 }
 
-__inline Int
-TRenSingleModel::xRangeRightR( Int iPos )
+template <BlenMod iBM, Bool bBitInc> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRangeRightR( Int iPos )
 {
   return iPos >> m_iShiftPrec;
@@ -1008,12 +1313,12 @@
 
 
-__inline Int
-TRenSingleModel::xRoundL( Int iPos )
+template <BlenMod iBM, Bool bBitInc> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRoundL( Int iPos )
 {
   return  (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec;
 }
 
-__inline Int
-TRenSingleModel::xRoundR( Int iPos )
+template <BlenMod iBM, Bool bBitInc> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xRoundR( Int iPos )
 {
   return  (m_iShiftPrec == 0) ? iPos : xRoundL(iPos - 1);
@@ -1021,6 +1326,6 @@
 
 
-Void
-TRenSingleModel::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal )
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal )
 {
   for (Int iYPos = 0; iYPos < iHeight; iYPos++)
@@ -1034,6 +1339,6 @@
 }
 
-Void
-TRenSingleModel::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal )
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal )
 {
   for (Int iYPos = 0; iYPos < iHeight; iYPos++)
@@ -1048,6 +1353,6 @@
 
 
-Void
-TRenSingleModel::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal )
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal )
 {
   for (Int iYPos = 0; iYPos < iHeight; iYPos++)
@@ -1061,81 +1366,68 @@
 }
 
-Void
-TRenSingleModel::xInitView( Int iViewPos )
-{
-  AOT( iViewPos == VIEWPOS_MERGED && ( m_iMode == 0 || m_iMode == 1 ) );
-
-  xSetPels( m_aapiSynthVideoPel[iViewPos][0], m_iStride, m_iWidth, m_iHeight, 0 );
-  xSetPels( m_aapiSynthVideoPel[iViewPos][1], m_iStride, m_iWidth, m_iHeight, 128 << g_uiBitIncrement );
-  xSetPels( m_aapiSynthVideoPel[iViewPos][2], m_iStride, m_iWidth, m_iHeight, 128 << g_uiBitIncrement );
-
-  if ( iViewPos != VIEWPOS_MERGED)
-  {
-    xSetBools( m_apbOccluded     [iViewPos],  m_iStride, m_iWidth, m_iHeight, false );
-    xSetPels ( m_apiFilled       [iViewPos],  m_iStride, m_iWidth, m_iHeight, REN_IS_HOLE);
-    if ( m_iMode == 2 )
-    {
-      xSetPels( m_apiSynthDepthPel [iViewPos],  m_iStride, m_iWidth, m_iHeight, 0);
-    }
-  }
-}
-
-__inline Void
-TRenSingleModel::xSetShiftedPel(Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
-{
-  AOT( iSourcePos < 0         );
-  AOT( iSourcePos >= m_iSampledWidth );
-
-  AOT( iTargetSPos < 0         );
-  AOT( iTargetSPos >= m_iWidth );
-//  AOT(  m_apiFilledRow[m_iViewPos][iTargetSPos] != REN_IS_HOLE);
-
-  if ( m_iMode == 2)
-  {
-    xSetShiftedPelBlend(iSourcePos, iTargetSPos, iFilled, riError );
-    return;
-  }
-
-  if ( m_bSet )
-  {
-    m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][0][iSourcePos];
-#if HHI_VSO_COLOR_PLANES
-    m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][1][iSourcePos];
-    m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][2][iSourcePos];
-#endif
-    m_apiFilledRow        [m_iCurViewPos]   [iTargetSPos] = iFilled;
-    Int iDiffY = m_aapiRefVideoPelRow    [0][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos];
-#if HHI_VSO_COLOR_PLANES
-    Int iDiffU = m_aapiRefVideoPelRow    [1][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos];
-    Int iDiffV = m_aapiRefVideoPelRow    [2][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos];
-    m_apiErrorRow                           [iTargetSPos] = xGetDist( iDiffY, iDiffU, iDiffV);
-#else
-    m_apiErrorRow                           [iTargetSPos] = xGetDist(iDiffY);
-#endif
+template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
+TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelL(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) );
+  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
   {
-    Int iSDOld   = m_apiErrorRow            [iTargetSPos];
-    Int iDiffY   = m_aapiRefVideoPelRow  [0][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][0][iSourcePos];
-#if HHI_VSO_COLOR_PLANES
-    Int iDiffU   = m_aapiRefVideoPelRow  [1][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][1][iSourcePos];
-    Int iDiffV   = m_aapiRefVideoPelRow  [2][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][2][iSourcePos];
-    riError     += ( xGetDist(iDiffY,iDiffU,iDiffV) - iSDOld  );
-#else
-    riError     +=  ( xGetDist( iDiffY ) - iSDOld );
-#endif
-  }
-}
-
-__inline Void
-TRenSingleModel::xSetShiftedPelBlend( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
-{
-  AOT( iSourcePos < 0         );
-  AOT( iSourcePos >= m_iSampledWidth );
-
-  AOT( iTargetSPos < 0         );
-  AOT( iTargetSPos >= m_iWidth );
-  //  AOT(  m_apiFilledRow[m_iViewPos][iTargetSPos] != REN_IS_HOLE);
-
+    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 HHI_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 );    
+#endif    
+    
+  }
+  else
+  { 
+#if HHI_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 HHI_VSO_COLOR_PLANES
@@ -1144,116 +1436,248 @@
 #endif
 
-
-  if (m_iCurViewPos == 0)
-  {
-    xGetBlendedValue (
-      m_aapiBaseVideoPelRow                                    [0][0][iSourcePos ]  ,
-      m_aapiSynthVideoPelRow                                   [1][0][iTargetSPos]  ,
-#if HHI_VSO_COLOR_PLANES
-      m_aapiBaseVideoPelRow                                    [0][1][iSourcePos ]  ,
-      m_aapiSynthVideoPelRow                                   [1][1][iTargetSPos]  ,
-      m_aapiBaseVideoPelRow                                    [0][2][iSourcePos ]  ,
-      m_aapiSynthVideoPelRow                                   [1][2][iTargetSPos]  ,
-#endif
-      m_piInvZLUTLeft [RemoveBitIncrement(m_iThisDepth)                            ],
-      m_piInvZLUTRight[RemoveBitIncrement(m_apiSynthDepthPelRow[1]   [iTargetSPos])],
-      iFilled,
-      m_apiFilledRow                                           [1]   [iTargetSPos]  ,
-      piBlendedValueY
+  xGetBlendedValue (
+    pcInSample ->aiY[iSubSourcePos],
+    pcOutSample->iYRight,    
+#if HHI_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 HHI_VSO_COLOR_PLANES
     , piBlendedValueU,
-      piBlendedValueV
+    piBlendedValueV
 #endif
     );
+
+  if ( bSet )
+  {    
+    // Set values
+    pcOutSample->iDLeft      = m_iThisDepth;
+    pcOutSample->iYLeft      = pcInSample ->aiY[iSubSourcePos];
+    pcOutSample->iYBlended   = piBlendedValueY;    
+#if HHI_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 HHI_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
   {
-    xGetBlendedValue (
-      m_aapiSynthVideoPelRow                                   [0][0][iTargetSPos],
-      m_aapiBaseVideoPelRow                                    [1][0][iSourcePos ],
-#if HHI_VSO_COLOR_PLANES
-      m_aapiSynthVideoPelRow                                   [0][1][iTargetSPos],
-      m_aapiBaseVideoPelRow                                    [1][1][iSourcePos ],
-      m_aapiSynthVideoPelRow                                   [0][2][iTargetSPos],
-      m_aapiBaseVideoPelRow                                    [1][2][iSourcePos ],
-#endif
-      m_piInvZLUTLeft [RemoveBitIncrement(m_apiSynthDepthPelRow[0]   [iTargetSPos])],
-      m_piInvZLUTRight[RemoveBitIncrement(m_iThisDepth)                            ],
-      m_apiFilledRow                                           [0]   [iTargetSPos],
-      iFilled                                                                     ,
-      piBlendedValueY
+    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
+#if HHI_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 HHI_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 HHI_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 HHI_VSO_COLOR_PLANES
+  Pel piBlendedValueU;
+  Pel piBlendedValueV;
+#endif
+
+  xGetBlendedValue (
+    pcOutSample->iYLeft, 
+    pcInSample ->aiY[iSubSourcePos],        
+#if HHI_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 HHI_VSO_COLOR_PLANES
     , piBlendedValueU,
-      piBlendedValueV
+    piBlendedValueV
 #endif
     );
-  }
-
-  if ( m_bSet )
-  {
-    m_apiSynthDepthPelRow [m_iCurViewPos]   [iTargetSPos] = m_iThisDepth;
-    m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][0][iSourcePos];
-    m_aapiSynthVideoPelRow[2            ][0][iTargetSPos] = piBlendedValueY;
-#if HHI_VSO_COLOR_PLANES
-    m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][1][iSourcePos];
-    m_aapiSynthVideoPelRow[2            ][1][iTargetSPos] = piBlendedValueU;
-    m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][2][iSourcePos];
-    m_aapiSynthVideoPelRow[2            ][2][iTargetSPos] = piBlendedValueV;
-#endif
-    m_apiFilledRow        [m_iCurViewPos]   [iTargetSPos] = iFilled;
-
-    Int iDiffY = m_aapiRefVideoPelRow    [0][iTargetSPos] - piBlendedValueY;
-#if HHI_VSO_COLOR_PLANES
-    Int iDiffU = m_aapiRefVideoPelRow    [1][iTargetSPos] - piBlendedValueU;
-    Int iDiffV = m_aapiRefVideoPelRow    [2][iTargetSPos] - piBlendedValueV;
-    m_apiErrorRow                           [iTargetSPos] = xGetDist(iDiffY, iDiffU, iDiffV );
-#else
-    m_apiErrorRow                           [iTargetSPos] = xGetDist(iDiffY);
+
+  if ( bSet )
+  {    
+    // Set values
+    pcOutSample->iDRight     = m_iThisDepth;
+    pcOutSample->iYRight     = pcInSample ->aiY[iSubSourcePos];
+    pcOutSample->iYBlended   = piBlendedValueY;    
+#if HHI_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 HHI_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 iSDOld   = m_apiErrorRow            [iTargetSPos];
-    Int iDiffY = m_aapiRefVideoPelRow    [0][iTargetSPos] - piBlendedValueY;
-#if HHI_VSO_COLOR_PLANES
-    Int iDiffU = m_aapiRefVideoPelRow    [1][iTargetSPos] - piBlendedValueU;
-    Int iDiffV = m_aapiRefVideoPelRow    [2][iTargetSPos] - piBlendedValueV;
-    riError   += ( xGetDist( iDiffY, iDiffU, iDiffV ) - iSDOld );
-#else
-    riError   += ( xGetDist( iDiffY )- iSDOld  );
-#endif
-  }
-}
-
-
-__inline Int
-TRenSingleModel::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV )
-{
-  return (          ((iDiffY * iDiffY) >> m_iDistShift)
-             +  ((( ((iDiffU * iDiffU) >> m_iDistShift)
-                   +((iDiffV * iDiffV) >> m_iDistShift)
+    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
+#if HHI_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> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV )
+{
+
+  if ( !bBitInc )
+  {
+    return (          (iDiffY * iDiffY )
+               +  ((( (iDiffU * iDiffU )
+                     +(iDiffV * iDiffV )
+                    )
+                   ) >> 2
                   )
-                 ) >> 2
-                )
-         );
-}
-
-__inline Int
-TRenSingleModel::xGetDist( Int iDiffY )
-{
-  return ((iDiffY * iDiffY) >> m_iDistShift);
-}
-
-#if HHI_VSO_COLOR_PLANES
-__inline Void
-TRenSingleModel::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
-Void
-TRenSingleModel::xGetBlendedValue( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
-#endif
-{
-  if (m_iBlendMode != 0 )
-  {
-    if (m_iBlendMode == 1 )
+           );
+  }
+  else
+  {
+    return (          ((iDiffY * iDiffY) >> m_iDistShift)
+               +  ((( ((iDiffU * iDiffU) >> m_iDistShift)
+                     +((iDiffV * iDiffV) >> m_iDistShift)
+                    )
+                   ) >> 2
+                  )
+           );
+  
+  }
+}
+
+template <BlenMod iBM, Bool bBitInc> __inline Int
+TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY )
+{
+  if ( !bBitInc )
+  {
+    return (iDiffY * iDiffY);
+  }
+  else
+  {
+    return ((iDiffY * iDiffY) >> m_iDistShift);
+  }
+
+}
+
+
+#if HHI_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
+{
+
+  RM_AOT( iBM != BLEND_AVRG && iBM != BLEND_LEFT && iBM != BLEND_RIGHT );
+
+  if (iBM != BLEND_AVRG )
+  {
+    if (iBM == BLEND_LEFT )
     {
 #if HHI_VSO_COLOR_PLANES
@@ -1299,5 +1723,4 @@
       else
       {
-#if HHI_FIX
         riY = xBlend( iYL, iYR, m_iBlendDistWeight );
 #if HHI_VSO_COLOR_PLANES    
@@ -1305,11 +1728,4 @@
         riV = xBlend( iVL, iVR, m_iBlendDistWeight );
 #endif
-#else
-        riY = xBlend( iYR, iYL, m_iBlendDistWeight );
-#if HHI_VSO_COLOR_PLANES
-        riU = xBlend( iUR, iUL, m_iBlendDistWeight );
-        riV = xBlend( iVR, iVL, m_iBlendDistWeight );
-#endif
-#endif
       }
     }
@@ -1369,15 +1785,14 @@
     }
   }
-
-}
-
-__inline Void
-#if HHI_VSO_COLOR_PLANES
-TRenSingleModel::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
-TRenSingleModel::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
-#endif
-{
-  if      ( iFilledL == REN_IS_FILLED ||  iFilledR == REN_IS_HOLE )
+}
+
+template <BlenMod iBM, Bool bBitInc> __inline Void
+#if HHI_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
+{
+  if ( iFilledL == REN_IS_FILLED ||  iFilledR == REN_IS_HOLE )
   {
     riY = iYL;
@@ -1405,9 +1820,9 @@
 }
 
-__inline Void
-#if HHI_VSO_COLOR_PLANES
-TRenSingleModel::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
-TRenSingleModel::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
+template <BlenMod iBM, Bool bBitInc> __inline Void
+#if HHI_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
 {
@@ -1438,7 +1853,92 @@
 }
 
-__inline Pel
-TRenSingleModel::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 )
+template <BlenMod iBM, Bool bBitInc> __inline Pel
+TRenSingleModelC<iBM,bBitInc>::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 )
 {
   return pVal1  +  (Pel) (  ( (Int) ( pVal2 - pVal1) * iWeightVal2 + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );
 }
+
+template <BlenMod iBM, Bool bBitInc> Void
+TRenSingleModelC<iBM,bBitInc>::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget, UInt uiHorOffset )
+{
+  TRenFilter::copy            ( ppiSrcVideoPel[0], piStrides[0], m_iWidth, m_iHeight, rpcPicYuvTarget->getLumaAddr() +  uiHorOffset       * rpcPicYuvTarget->getStride() , rpcPicYuvTarget->getStride () );
+  TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[1], piStrides[1], m_iWidth, m_iHeight, rpcPicYuvTarget->getCbAddr  () + (uiHorOffset >> 1) * rpcPicYuvTarget->getCStride(), rpcPicYuvTarget->getCStride() );
+  TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iHeight, rpcPicYuvTarget->getCrAddr  () + (uiHorOffset >> 1) * rpcPicYuvTarget->getCStride(), rpcPicYuvTarget->getCStride() );
+}
+
+template class TRenSingleModelC<BLEND_NONE ,true>;
+template class TRenSingleModelC<BLEND_AVRG ,true>;
+template class TRenSingleModelC<BLEND_LEFT ,true>;
+template class TRenSingleModelC<BLEND_RIGHT,true>;
+
+template class TRenSingleModelC<BLEND_NONE ,false>;
+template class TRenSingleModelC<BLEND_AVRG ,false>;
+template class TRenSingleModelC<BLEND_LEFT ,false>;
+template class TRenSingleModelC<BLEND_RIGHT,false>;
+
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+template <BlenMod iBM, Bool bBitInc> 
+__inline Bool
+TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData,Pel* piOrgData, Int iOrgStride)
+{
+  RM_AOF( m_bEarlySkip ); 
+  const Int iCurViewPos = 0;
+  Int** ppiCurLUT       = m_appiShiftLut   [ iCurViewPos ];
+  
+  Bool bNoDiff          = true;   
+  
+  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 iDispartyOrg  = abs(ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])]);
+
+      if( iDispartyOrg != iDisparityRec)
+      {
+        m_pbHorSkip[iPosY] = false;
+        bNoDiff            = false;
+        break;
+      }
+    }
+    piNewData += iStride;
+    piOrgData += iOrgStride;
+  }
+  return bNoDiff;
+}
+
+template <BlenMod iBM, Bool bBitInc> 
+__inline Bool
+TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData,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
Index: trunk/source/Lib/TLibRenderer/TRenSingleModel.h
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 81)
+++ trunk/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 100)
@@ -55,31 +55,135 @@
 
 
+#if HHI_VSO_RM_ASSERTIONS
+#define RM_AOT( exp ) AOT ( exp )
+#define RM_AOF( exp ) AOF ( exp )
+#else
+#define RM_AOT( exp ) ((void)0)
+#define RM_AOF( exp ) ((void)0)
+#endif
+
+#define RenModRemoveBitInc( exp ) bBitInc ? ( RemoveBitIncrement( exp ) ) : ( exp ) 
+
 class TRenSingleModel
 {
+public: 
+#if LGE_VSO_EARLY_SKIP_A0093
+  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   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOffset ) = 0;
+
+  // Set Data
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  virtual Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel* piOrgData, Int iOrgStride )  = 0;
+#else
+  virtual Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )  = 0;
+#endif
+  virtual Void   setVideo  ( Int iViewPos,     Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) = 0;
+
+  // Get Distortion
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  virtual RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData , Int iOrgStride)=0;
+#else
+  virtual RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) = 0;
+#endif
+  virtual RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) = 0;
+
+  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;
+};
+
+template < BlenMod iBM, Bool bBitInc >
+class TRenSingleModelC : public TRenSingleModel
+{
+  struct RenModelInPels
+  {
+    // video
+    Pel aiY[5]    ; // y-value
+#if HHI_VSO_COLOR_PLANES
+    Pel aiU[5]    ; // u-value
+    Pel aiV[5]    ; // v-value
+#endif
+    // depth
+    Pel iD        ; // depth
+
+    // state
+    Bool bOccluded; // Occluded
+  };
+
+  struct RenModelOutPels
+  {
+    // video
+    Pel iYLeft    ; 
+    Pel iYRight   ; 
+    Pel iYBlended ; 
+#if HHI_VSO_COLOR_PLANES
+    Pel iULeft    ; 
+    Pel iURight   ; 
+    Pel iUBlended ; 
+    Pel iVLeft    ; 
+    Pel iVRight   ; 
+    Pel iVBlended ; 
+#endif
+    // depth
+    Pel iDLeft    ;
+    Pel iDRight   ; 
+    Pel iDBlended ; 
+
+    // state
+    Int iFilledLeft ; 
+    Int iFilledRight; 
+
+    // error
+    Int  iError   ;
+
+    // reference
+    Pel iYRef    ; 
+#if HHI_VSO_COLOR_PLANES
+    Pel iURef    ; 
+    Pel iVRef    ; 
+#endif        
+  };
+
+
 
 public:
-  TRenSingleModel();
-  ~TRenSingleModel();
+  TRenSingleModelC();
+  ~TRenSingleModelC();
 
   // Create Model
+#if LGE_VSO_EARLY_SKIP_A0093
+  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   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference );
-
-  // Set Data
+  Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOffset );
+
+#if LGE_VSO_EARLY_SKIP_A0093
+  Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel* piOrgData, Int iOrgStride );
+#else
   Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
+#endif
   Void   setVideo  ( Int iViewPos,     Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
 
   // Get Distortion
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData , Int iOrgStride);
+#else
   RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
+#endif
   RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
 
-  // Get Rendered Data
-  Void   getSynthView( Int iViewPos, Pel**& rppiRenVideoPel, Pel*& rpiRenDepthPel, Int& riStride );
-
-  // Get Reference Data
-  Void   getRefView  ( TComPicYuv*& rpcPicYuvRefView, Pel**& rppiRefVideoPel, Int*& raiStrides );
+  Void   getSynthVideo  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset );  
+  Void   getSynthDepth  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  );
+  Void   getRefVideo    ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  );
 
 private:
@@ -90,27 +194,34 @@
   /////  Rendering /////
   // Left to Right
-  __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bSet);
-  __inline Void   xInitRenderPartL    ( Int iEndChangePos, Int iLastSPos  );
-  __inline Void   xRenderRangeL       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  __inline Void   xRenderShiftedRangeL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  __inline Void   xFillHoleL          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  __inline Void   xExtrapolateMarginL ( Int iCurSPos,                Int iCurPos, RMDist& riError );
-  __inline Int    xRangeLeftL         ( Int iPos );
-  __inline Int    xRangeRightL        ( Int iPos );
-  __inline Int    xRoundL             ( Int iPos );
+#ifdef 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 );
+  template<Bool bSet> __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bFast );
+  template<Bool bSet> __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bFast );
+#else
+  template<Bool bSet> __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
+  template<Bool bSet> __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, 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 RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bSet );
-  __inline Void   xInitRenderPartR    ( Int iStartChangePos, Int iLastSPos );
-  __inline Void   xRenderShiftedRangeR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  __inline Void   xRenderRangeR       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  __inline Void   xFillHoleR          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
-  __inline Void   xExtrapolateMarginR ( Int iCurSPos,                Int iCurPos, RMDist& riError );
-  __inline Int    xRangeLeftR         ( Int iPos );
-  __inline Int    xRangeRightR        ( Int iPos );
-  __inline Int    xRoundR             ( Int iPos );
+                      __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
-  __inline Void   xSetShiftedPelBlend ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
+  template<Bool bSet> __inline Void   xSetShiftedPelBlend ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
 
 #if HHI_VSO_COLOR_PLANES
@@ -125,6 +236,13 @@
   __inline Pel    xBlend              ( Pel pVal1, Pel pVal2, Int iWeightVal2 );
 
-// General
-  __inline Void   xSetShiftedPel     ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
+  // 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 );
@@ -134,8 +252,49 @@
 
   // Utilities
-  __inline Void   xInitView  ( Int iViewPos );
   __inline Void   xSetPels   ( Pel*  piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );
   __inline Void   xSetBools  ( Bool* pbSource    , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal );
   __inline Void   xSetInts   ( Int*  piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal );
+
+#if HHI_VSO_COLOR_PLANES
+  Void            xGetSampleStrTextPtrs ( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY, Pel RenModelOutPels::*& rpiSrcU, Pel RenModelOutPels::*& rpiSrcV );
+#else  
+  Void            xGetSampleStrTextPtrs ( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY );
+#endif 
+  Void            xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD );
+       
+  Void            xSetStructRefView            ();
+  Void            xResetStructError            ();
+  Void            xInitSampleStructs           ();
+  Void            xSetStructSynthViewAsRefView ();
+  Void            xCopy2PicYuv                ( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget, UInt uiHorOffset );
+
+
+  template< typename S, typename T> 
+  Void   xCopyFromSampleStruct ( S* ptSource , Int iSourceStride, T S::* ptSourceElement, T* ptTarget, Int iTargetStride, Int iWidth, Int iHeight )
+  {
+    for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
+    {
+      for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
+      {
+        ptTarget[iPosX] = ptSource[iPosX].*ptSourceElement;
+      }
+      ptSource += iSourceStride;
+      ptTarget += iTargetStride;
+    }    
+  }  
+
+  template< typename S, typename T> 
+  Void   xCopyToSampleStruct ( T* ptSource , Int iSourceStride, S* ptTarget, Int iTargetStride, T S::* ptSourceElement, Int iWidth, Int iHeight )
+  {
+    for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
+    {
+      for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
+      {
+        ptTarget[iPosX] = ptSource[iPosX].*ptSourceElement;
+      }
+      ptSource += iSourceStride;
+      ptTarget += iTargetStride;
+    }    
+  }   
 
 private:
@@ -151,4 +310,7 @@
   Int   m_iSampledStride;
 
+  RenModelInPels* m_pcInputSamples[2];
+  Int                  m_iInputSamplesStride;
+
   // Base
   Pel** m_aapiBaseVideoPel     [2]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
@@ -157,4 +319,5 @@
   Pel*  m_apiBaseDepthPel      [2]; // Dim1: ViewPosition
   Int   m_aiBaseDepthStrides   [2]; // Dim1: ViewPosition
+
 
   // LUT
@@ -170,13 +333,11 @@
   //// Reference Data  ////
   TComPicYuv* m_pcPicYuvRef       ;    // Reference PIcYuv
+
+  //// Output Samples
+  RenModelOutPels* m_pcOutputSamples;
+  Int                   m_iOutputSamplesStride;
+
   Pel*  m_aapiRefVideoPel      [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
   Int   m_aiRefVideoStrides    [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
-
-  // Renderer State
-  Int*  m_piError                 ;
-  Pel*  m_apiFilled            [2];    // Dim1: ViewPosition
-  Bool* m_apbOccluded          [2];    // Dim1: ViewPosition
-  Pel*  m_aapiSynthVideoPel    [3][3]; // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
-  Pel*  m_apiSynthDepthPel     [3];    // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
 
   // Rendering State
@@ -185,5 +346,4 @@
   Int   m_iLastOccludedSPosFP;         // Position of last topmost shifted position in FullPels
 
-  Bool  m_bSet;                        // Set Data, or get Error
   Int   m_iCurViewPos;                 // Current View Position 0: Left, 1: Right
   Int   m_iOtherViewPos;               // Other View Position 0: Left, 1: Right
@@ -201,5 +361,7 @@
   Int   m_iShiftPrec;
   Int   m_iHoleMargin;
-  Int   m_iBlendMode;
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  Bool  m_bEarlySkip; 
+#endif
 
   // Derived settings
@@ -209,17 +371,15 @@
 
   //// Current Pointers ////
-  Pel*  m_aapiBaseVideoPelRow  [2][3]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
-  Pel*  m_apiBaseDepthPelRow   [2];    // Dim1: ViewPosition
-  Bool* m_apbOccludedRow       [2];    // Dim1: ViewPosition
-  Pel*  m_apiFilledRow         [2];    // Dim1: ViewPosition
-  Int*  m_apiErrorRow             ;
-
-  Pel*  m_aapiRefVideoPelRow   [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
-  Pel*  m_aapiSynthVideoPelRow [3][3]; // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
-  Pel*  m_apiSynthDepthPelRow  [3];    // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged
-
+
+  RenModelInPels*  m_pcInputSamplesRow [2];
+  RenModelOutPels* m_pcOutputSamplesRow;
 
   //// MISC ////
   const Int m_iDistShift;                  // Shift in Distortion computation
+
+  //// Early Skip 
+#ifdef LGE_VSO_EARLY_SKIP_A0093
+  Bool* m_pbHorSkip;
+#endif
 };
 
Index: trunk/source/Lib/TLibRenderer/TRenTop.cpp
===================================================================
--- trunk/source/Lib/TLibRenderer/TRenTop.cpp	(revision 81)
+++ trunk/source/Lib/TLibRenderer/TRenTop.cpp	(revision 100)
@@ -1013,5 +1013,4 @@
           if ((iPrevShiftedPos + (iStep >> 1) ) > iPrevShiftedPosCeiled )
           {
-#if HHI_FIX
             if ( !((iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)))
             {
@@ -1026,20 +1025,4 @@
             iInterPolPos++;
           }          
-#else
-          if ( (iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth))
-          {
-            // skip Interpolation if Interpolation position is outside frame
-            iPrevShiftedPos = iShiftedPos;
-            continue;
-          };
-
-          for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)
-          {
-              apcOutputData[uiCurPlane][iInterPolPos]  = apcInputData[uiCurPlane][iPosX - iStep];
-          }
-          pcFilledData[iInterPolPos]  = REN_IS_FILLED;
-            iInterPolPos++;
-        }
-#endif
 
           // Fill Disocclusion
@@ -1064,5 +1047,4 @@
         {
           iInterPolPos = iShiftedPosFloor >> m_iRelShiftLUTPrec;
-#if HHI_FIX
           if ( !((iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)))
           {        
@@ -1074,19 +1056,4 @@
             pcFilledData[iInterPolPos]  = REN_IS_FILLED;
           }
-#else
-          if ( (iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth))
-          {
-            // skip Interpolation if Interpolation position is outside frame
-            iPrevShiftedPos = iShiftedPos;
-            continue;
-          };
-
-          for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)
-          {
-            apcOutputData[uiCurPlane][iInterPolPos]  = apcInputData[uiCurPlane][iPosX ];
-          }
-
-          pcFilledData[iInterPolPos]  = REN_IS_FILLED;
-#endif
         }
       }
@@ -1959,5 +1926,5 @@
           for( Int iCurPosX = 0; iCurPosX < 4; iCurPosX++)
           {
-            iSAD += abs( pcVideoLastDataBlk[iCurPosX] - pcVideoCurDataBlk[iCurPosX] );	 //SAD
+            iSAD += abs( pcVideoLastDataBlk[iCurPosX] - pcVideoCurDataBlk[iCurPosX] );   //SAD
           }
           pcVideoLastDataBlk += iVideoLastStride;
