Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncCu.cpp	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncCu.cpp	(revision 231)
@@ -1890,6 +1890,10 @@
 
   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
-  rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
-
+#if MERL_VSP_C0152
+  Int iVSPIndexTrue[3] = {-1, -1, -1};
+  rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue );
+#else
+  rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
+#endif
 #if FAST_DECISION_FOR_MRG_RD_COST
   Bool bestIsSkip = false;
@@ -1933,4 +1937,20 @@
           rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level
           rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level
+#if MERL_VSP_C0152
+          {
+            Int iVSPIdx = 0;
+            Int numVSPIdx;
+            numVSPIdx = 3;
+            for (Int i = 0; i < numVSPIdx; i++)
+            {
+              if (iVSPIndexTrue[i] == uiMergeCand)
+                {
+                  iVSPIdx = i+1;
+                  break;
+                }
+            }
+            rpcTempCU->setVSPIndexSubParts( iVSPIdx, 0, 0, uhDepth );
+          }
+#endif
           rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
           rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
@@ -1952,5 +1972,9 @@
 #endif
         {
+#if MERL_VSP_C0152
+            m_pcPredSearch->motionCompensationBWVSP ( rpcTempCU, m_ppcPredYuvTemp[uhDepth],  rpcTempCU->getZorderIdxInCU() );
+#else
             m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#endif
             // save pred adress
             pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth];
@@ -1962,5 +1986,9 @@
             if( bestIsSkip)
             {
+#if MERL_VSP_C0152
+              m_pcPredSearch->motionCompensationBWVSP ( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU() );
+#else
               m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#endif
               // save pred adress
               pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth];
@@ -2065,4 +2093,5 @@
   
   rpcTempCU->setPartSizeSubParts  ( ePartSize,  0, uhDepth );
+
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth );
@@ -2084,5 +2113,5 @@
   #if HHI_INTERVIEW_SKIP
 #if LG_RESTRICTEDRESPRED_M24766
-  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcResPredTmp[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG  );
+  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcResPredTmp[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG);
 #else
   m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG  );
@@ -2787,8 +2816,16 @@
       assert( rpcTempCU->getInterDir( ui ) != 0 );
       assert( rpcTempCU->getPredictionMode( ui ) != MODE_NONE );
-    }
+#if MERL_VSP_C0152
+      Int vspIdx = pcTextureCU->getVSPIndex( rpcTempCU->getZorderIdxInCU() + ui);
+      rpcTempCU->setVSPIndex( ui , vspIdx);
+#endif
+    }
+
     rpcTempCU->setPredModeSubParts( bSkipResidual ? MODE_SKIP : MODE_INTER, 0, uhDepth );
+#if MERL_VSP_C0152
+    m_pcPredSearch->motionCompensationBWVSP( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU()  );
+#else
     m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
-
+#endif
     // get Original YUV data from picture
     m_ppcOrigYuv[uhDepth]->copyFromPicYuv( rpcBestCU->getPic()->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncCu.h	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncCu.h	(revision 231)
@@ -81,5 +81,5 @@
   TComYuv**               m_ppcResPredTmp;  ///< Temporary residual prediction for each depth
 #endif
-  
+
   //  Data : encoder control
   Bool                    m_bEncodeDQP;
@@ -121,5 +121,5 @@
   /// destroy internal buffers
   Void  destroy             ();
-  
+
   /// CU analysis function
   Void  compressCU          ( TComDataCU*&  rpcCU );
Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 231)
@@ -1347,5 +1347,5 @@
     uiAbsPartIdx = 0;
   }
-  
+
 #if RWTH_SDC_DLT_B0036
   if( pcCU->getSDCFlag(uiAbsPartIdx) )
@@ -1355,5 +1355,5 @@
   }
 #endif
-  
+
   PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx );
   
Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 231)
@@ -254,5 +254,5 @@
       pcSlice->setSliceIdx(0);
       pcSlice->setViewId( m_pcEncTop->getViewId() );
-      pcSlice->setIsDepth( m_pcEncTop->getIsDepth() ); 
+      pcSlice->setIsDepth( m_pcEncTop->getIsDepth() );
 
       m_pcEncTop->getSPS()->setDisInter4x4(m_pcEncTop->getDisInter4x4());
@@ -340,11 +340,11 @@
       pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
 #else
-
-    Bool bNalRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR)) && (pcSlice->getSPS()->getViewId())  ? 1: 0;
-    pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
-    pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
-#endif
-    TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
-    refPicListModification->setRefPicListModificationFlagL0( false );
+      Bool bNalRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR)) && (pcSlice->getSPS()->getViewId())  ? 1: 0;
+      pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
+      pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
+#endif
+      
+      TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
+      refPicListModification->setRefPicListModificationFlagL0( false );
 #if !H0137_0138_LIST_MODIFICATION
       refPicListModification->setNumberOfRefPicListModificationsL0(0);
Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 231)
@@ -1277,4 +1277,10 @@
       xWriteUnaryMaxSymbol( iRefFrame - 1, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 );
     }
+#if MERL_VSP_C0152
+    else if (iRefFrame < 0) // NOT_VALID
+    {
+      assert(0);
+    }
+#endif
   }
   else
@@ -1288,4 +1294,10 @@
       xWriteUnaryMaxSymbol( iRefFrame - 1, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 );
     }
+#if MERL_VSP_C0152
+    else if (iRefFrame < 0) // NOT_VALID
+    {
+      assert(0);
+    }
+#endif
   }
   return;
Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 231)
@@ -696,5 +696,6 @@
 UInt TEncSearch::xPatternRefinement( TComPattern* pcPatternKey,
                                     TComMv baseRefMv,
-                                    Int iFrac, TComMv& rcMvFrac )
+                                    Int iFrac, TComMv& rcMvFrac
+                                   )
 {
   UInt  uiDist;
@@ -1688,5 +1689,5 @@
   // reconstruct residual based on mask + DC residuals
   Pel apDCResiValues[2];
-  Pel apDCRecoValues[2];
+  //Pel apDCRecoValues[2];
   for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
   {
@@ -1695,5 +1696,5 @@
     Pel   pRecoValue  = GetIdx2DepthValue( pPredIdx + pResiIdx );
     
-    apDCRecoValues[uiSegment]  = pRecoValue;
+    //apDCRecoValues[uiSegment]  = pRecoValue;
     apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
   }
@@ -2897,11 +2898,14 @@
 Void TEncSearch::xGetInterPredictionError( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiErr, Bool bHadamard )
 {
+#if !MERL_VSP_C0152
   motionCompensation( pcCU, &m_tmpYuvPred, REF_PIC_LIST_X, iPartIdx );
-
+#endif
   UInt uiAbsPartIdx = 0;
   Int iWidth = 0;
   Int iHeight = 0;
   pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight );
-
+#if MERL_VSP_C0152
+  motionCompensationBWVSP( pcCU, &m_tmpYuvPred,  pcCU->getZorderIdxInCU(), REF_PIC_LIST_X, iPartIdx );
+#endif
   DistParam cDistParam;
 
@@ -2943,5 +2947,9 @@
 #else
 #if LG_RESTRICTEDRESPRED_M24766
+#if MERL_VSP_C0152
+Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* rpcResiPredYuv, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost, Int* iVSPIndexTrue )
+#else
 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* rpcResiPredYuv, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost )
+#endif
 #else
 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost )
@@ -2988,6 +2996,11 @@
   }
 #else
+#if MERL_VSP_C0152
+  pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, uiDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue );
+#else
   pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, uiDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
 #endif
+#endif
+
 
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -3009,4 +3022,20 @@
       pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
       pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
+#if MERL_VSP_C0152
+      {
+        Int iVSPIdx = 0;
+        Int numVSPIdx;
+        numVSPIdx = 3;
+        for (Int i = 0; i < numVSPIdx; i++)
+        {
+          if (iVSPIndexTrue[i] == uiMergeCand)
+            {
+              iVSPIdx = i+1;
+              break;
+            }
+        }
+        pcCU->setVSPIndexSubParts( iVSPIdx, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+      }
+#endif
 #if LG_RESTRICTEDRESPRED_M24766
       Int iAddResiShift;
@@ -3081,5 +3110,5 @@
 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* rpcResiPredYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
 #else
-Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
+Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG)
 #endif
 #else
@@ -3185,4 +3214,5 @@
     for (Int iNumRef=0; iNumRef < MAX_NUM_REF; iNumRef++) uiCostTempL0[iNumRef] = MAX_UINT;
     UInt          uiBitsTempL0[MAX_NUM_REF];
+
 #if LG_RESTRICTEDRESPRED_M24766
     Int iPUResiPredShift[4] = {0, 0, 0, 0};
@@ -3191,5 +3221,8 @@
     
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
-    
+#if MERL_VSP_C0152
+    //reset the VSP flag to be 0
+    pcCU->setVSPIndexSubParts( 0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr) );
+#endif
 #if AMP_MRG
     Bool bTestNormalMC = true;
@@ -3206,4 +3239,5 @@
       Bool bLastResiFlag = false;
 #endif
+
     //  Uni-directional prediction
     for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
@@ -3545,5 +3579,5 @@
             xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
           }
-          
+
           if ( uiCostTemp < uiCostBi )
           {
@@ -3793,5 +3827,7 @@
       TComMvField cMRGMvField[2];
       UInt uiMRGIndex = 0;
-
+#if MERL_VSP_C0152
+      Int iVSPIndexTrue[3] = {-1, -1, -1};
+#endif
       UInt uiMEInterDir = 0;
       TComMvField cMEMvField[2];
@@ -3844,5 +3880,9 @@
 #else
 #if LG_RESTRICTEDRESPRED_M24766
+#if MERL_VSP_C0152
+      xMergeEstimation( pcCU, pcOrgYuv, rpcResiPredYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost,  iVSPIndexTrue );
+#else
       xMergeEstimation( pcCU, pcOrgYuv, rpcResiPredYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost );
+#endif
 #else
       xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost );
@@ -3854,4 +3894,20 @@
         pcCU->setMergeFlagSubParts ( true,          uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         pcCU->setMergeIndexSubParts( uiMRGIndex,    uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+#if MERL_VSP_C0152
+        {
+          Int iVSPIdx = 0;
+          Int numVSPIdx;
+          numVSPIdx = 3;
+          for (Int i = 0; i < numVSPIdx; i++)
+          {
+            if (iVSPIndexTrue[i] == uiMRGIndex)
+              {
+                iVSPIdx = i+1;
+                break;
+              }
+          }
+          pcCU->setVSPIndexSubParts( iVSPIdx, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+        }
+#endif
         pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         {
@@ -3873,4 +3929,7 @@
         pcCU->setMergeFlagSubParts( false,        uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+#if MERL_VSP_C0152
+        pcCU->setVSPIndexSubParts ( 0 ,           uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+#endif
         {
           pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
@@ -3881,6 +3940,9 @@
 
     //  MC
+#if MERL_VSP_C0152
+    motionCompensationBWVSP ( pcCU, rpcPredYuv, pcCU->getZorderIdxInCU(), REF_PIC_LIST_X, iPartIdx);
+#else
     motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
-    
+#endif
   } //  end of for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ )
 
@@ -4338,4 +4400,5 @@
   m_pcRdCost->setMultiviewReg( 0 );
 #endif
+
   setWpScalingDistParam( pcCU, iRefIdxPred, eRefPicList );
   //  Do integer search
@@ -4351,4 +4414,5 @@
   
   m_pcRdCost->getMotionCost( 1, 0 );
+
 #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
   if( ! pcCU->getSlice()->getIsDepth() )
@@ -4378,5 +4442,5 @@
     ruiCost += m_pcRdCost->getCost( uiMvBits );
 #endif
-  
+
   ruiBits      += uiMvBits;
   ruiCost       = (UInt)( floor( fWeight * ( (Double)ruiCost - (Double)m_pcRdCost->getCost( uiMvBits ) ) ) + (Double)m_pcRdCost->getCost( ruiBits ) );
@@ -4723,5 +4787,5 @@
   rcMvQter = *pcMvInt;   rcMvQter <<= 1;    // for mv-cost
   rcMvQter += rcMvHalf;  rcMvQter <<= 1;
-  ruiCost = xPatternRefinement( pcPatternKey, baseRefMv, 1, rcMvQter );
+  ruiCost = xPatternRefinement( pcPatternKey, baseRefMv, 1, rcMvQter);
 }
 
@@ -4758,5 +4822,5 @@
 #endif
   //  No residual coding : SKIP mode
-  if ( ePredMode == MODE_SKIP && bSkipRes )
+  if ( (ePredMode == MODE_SKIP && bSkipRes) )
   {
     rpcYuvResi->clear();
Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSearch.h	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSearch.h	(revision 231)
@@ -152,5 +152,5 @@
   UInt  xPatternRefinement( TComPattern* pcPatternKey,
                            TComMv baseRefMv,
-                           Int iFrac, TComMv& rcMvFrac );
+                           Int iFrac, TComMv& rcMvFrac);
   
   typedef struct
@@ -513,4 +513,7 @@
                                     Int& numValidMergeCand
 #endif
+#if MERL_VSP_C0152
+                                  , Int* iVSPIndexTrue
+#endif
                                    );
   // -------------------------------------------------------------------------------------------------------------------
@@ -579,6 +582,5 @@
                                     TComMv&       rcMvQter,
                                     UInt&         ruiCost 
-                                   ,Bool biPred
-                                   );
+                                   ,Bool biPred);
   
   Void xExtDIFUpSamplingH( TComPattern* pcPattern, Bool biPred  );
Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 231)
@@ -811,4 +811,12 @@
       m_pcBufferLowLatSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);  //init. state
   }
+
+#if MERL_VSP_C0152
+  // Send Depth/Texture pointers to slice level
+  pcSlice->setBWVSPLUTParam(m_aiShiftLUT, m_iShiftPrec);
+  pcSlice->setRefPicBaseTxt(m_pPicBaseTxt);
+  pcSlice->setRefPicBaseDepth(m_pPicBaseDepth);
+#endif
+
   UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
   //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU();
@@ -1138,4 +1146,5 @@
 
   UInt uiEncCUOrder;
+
   uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());  /*for tiles, uiStartCUAddr is NOT the real raster scan address, it is actually
                                                                                               an encoding order index, so we need to convert the index (uiStartCUAddr)
Index: branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSlice.h	(revision 222)
+++ branches/HTM-5.1-dev3-MERL/source/Lib/TLibEncoder/TEncSlice.h	(revision 231)
@@ -101,4 +101,13 @@
   
   UInt                    m_uiSliceIdx;
+
+#if MERL_VSP_C0152
+  // Data temporarily stored, will be sent to TComSlice level where the data will be actually used
+  TComPic* m_pPicBaseTxt;
+  TComPic* m_pPicBaseDepth;
+  Int*     m_aiShiftLUT;
+  Int      m_iShiftPrec;
+#endif
+
 public:
   TEncSlice();
@@ -128,4 +137,13 @@
   UInt    getSliceIdx()         { return m_uiSliceIdx;                    }
   Void    setSliceIdx(UInt i)   { m_uiSliceIdx = i;                       }
+
+#if MERL_VSP_C0152
+   Void     setBWVSPLUTParam    ( Int *pShiftLUT, Int iLoG2LUTPrec ) { m_aiShiftLUT = pShiftLUT; m_iShiftPrec = 2-iLoG2LUTPrec; }
+   Void     setRefPicBaseTxt    ( TComPic*pPicTxt   ) { m_pPicBaseTxt = pPicTxt;    }
+   Void     setRefPicBaseDepth  ( TComPic*pPicDepth ) { m_pPicBaseDepth = pPicDepth;}
+   Void     getBWVSPLUTParam    ( Int*& pShiftLUT, Int& iShiftPrec ) { pShiftLUT = m_aiShiftLUT; iShiftPrec = m_iShiftPrec; }
+   TComPic* getRefPicBaseTxt    () { return m_pPicBaseTxt;   }
+   TComPic* getRefPicBaseDepth  () { return m_pPicBaseDepth; }
+#endif
 };
 
