Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 355)
@@ -55,5 +55,9 @@
 #define CHECK_ADD_YET(pcCURef,uiIdx,vspIdx) && !( (pcCURef)->getVSPIndex(uiIdx) == vspIdx && bVspMvZeroDone[vspIdx-1] )
 
-inline Void TComDataCU::xInheritVspMode( TComDataCU* pcCURef, UInt uiIdx, Bool* bVspMvZeroDone, Int iCount, Int* iVSPIndexTrue, TComMvField* pcMvFieldNeighbours, DisInfo* pDInfo )
+inline Void TComDataCU::xInheritVspMode( TComDataCU* pcCURef, UInt uiIdx, Bool* bVspMvZeroDone, Int iCount, Int* iVSPIndexTrue, TComMvField* pcMvFieldNeighbours, DisInfo* pDInfo
+#if QC_BVSP_CleanUP_D0191
+  , UChar *puhInterDirNeighbours
+#endif
+)
 {
   Int vspIdx = (Int) pcCURef->getVSPIndex(uiIdx);
@@ -69,4 +73,7 @@
     if (vspIdx < 4)
     {
+#if QC_BVSP_CleanUP_D0191
+      puhInterDirNeighbours[ iCount] = 1;
+#endif
       pcMvFieldNeighbours[ iCount<<1].setMvField ( pDInfo->m_acMvCand[0],  NOT_VALID );
       if ( pcCURef->getSlice()->isInterB() )
@@ -102,4 +109,7 @@
             (getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 0 ? 1 : 2));
           puhInterDirNeighbours[iCount] = iInterDir; // The direction information does not matter
+#if QC_BVSP_CleanUP_D0191
+         puhInterDirNeighbours[iCount] = 1;
+#endif
           // get Mv using checked disparity vector
           if (vspIdx < 4) // spatial
@@ -3666,5 +3676,5 @@
         }
       }
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 && !QC_BVSP_CleanUP_D0191
       xInheritVspMode( pcTextureCU, uiPartIdxCenter, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
 #endif
@@ -3800,5 +3810,9 @@
 #endif
 #if MERL_VSP_C0152
-        xInheritVspMode( pcCULeft, uiLeftPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
+        xInheritVspMode( pcCULeft, uiLeftPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo
+#if QC_BVSP_CleanUP_D0191
+        ,puhInterDirNeighbours
+#endif
+        ) ;
 #endif
         if ( mrgCandIdx == iCount )
@@ -3873,5 +3887,9 @@
 #endif
 #if MERL_VSP_C0152
-     xInheritVspMode( pcCUAbove, uiAbovePartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
+     xInheritVspMode( pcCUAbove, uiAbovePartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo
+#if QC_BVSP_CleanUP_D0191
+        ,puhInterDirNeighbours
+#endif
+        ) ;
 #endif
     if ( mrgCandIdx == iCount )
@@ -3922,5 +3940,9 @@
 #endif
 #if MERL_VSP_C0152
-    xInheritVspMode( pcCUAboveRight, uiAboveRightPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
+    xInheritVspMode( pcCUAboveRight, uiAboveRightPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo
+ #if QC_BVSP_CleanUP_D0191
+        ,puhInterDirNeighbours
+#endif
+        ) ;
 #endif
     if ( mrgCandIdx == iCount )
@@ -4018,5 +4040,9 @@
 #endif
 #if MERL_VSP_C0152
-     xInheritVspMode( pcCULeftBottom, uiLeftBottomPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
+     xInheritVspMode( pcCULeftBottom, uiLeftBottomPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo
+#if QC_BVSP_CleanUP_D0191
+        ,puhInterDirNeighbours
+#endif
+        ) ;
 #endif
     if ( mrgCandIdx == iCount )
@@ -4073,5 +4099,9 @@
 #endif
 #if MERL_VSP_C0152
-     xInheritVspMode( pcCUAboveLeft, uiAboveLeftPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo ) ;
+     xInheritVspMode( pcCUAboveLeft, uiAboveLeftPartIdx, bVspMvZeroDone, iCount, iVSPIndexTrue, pcMvFieldNeighbours, &cDisInfo
+#if QC_BVSP_CleanUP_D0191
+        ,puhInterDirNeighbours
+#endif 
+        ) ;
 #endif
       if ( mrgCandIdx == iCount )
@@ -4408,5 +4438,5 @@
   {
     if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) 
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
      && !pcCorner->getVSPIndex( uiCornerPUIdx )
 #endif
@@ -4447,5 +4477,5 @@
   {
     if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) 
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
      && !pcCorner->getVSPIndex( uiCornerPUIdx )
 #endif
@@ -4593,5 +4623,5 @@
     pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
   if(! pcTmpCU->getVSPIndex(uiIdx))
 #endif
@@ -4618,5 +4648,5 @@
 
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
   if(! pcTmpCU->getVSPIndex(uiIdx))
 #endif
@@ -4643,5 +4673,5 @@
       pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true);
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
   if(! pcTmpCU->getVSPIndex(uiIdx))
 #endif
@@ -4667,5 +4697,5 @@
       pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false);
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
   if(! pcTmpCU->getVSPIndex(uiIdx))
 #endif
@@ -4694,5 +4724,5 @@
     assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
   if(! pcTmpCU->getVSPIndex(uiIdx))
 #endif
@@ -4902,9 +4932,10 @@
   Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth();
   Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight();
-
+#if !QC_BVSP_CleanUP_D0191
   Int depthPosX = Clip3(0,   iPictureWidth - iBlkWidth,  iBlkX + (mv->getHor()>>2));
   Int depthPosY = Clip3(0,   iPictureHeight- iBlkHeight,  iBlkY + (mv->getVer()>>2));
 
   Pel *pDepthPel   = pcBaseViewDepthPicYuv->getLumaAddr() + depthPosX + depthPosY * depStride;
+#endif
   Pel  maxDepthVal = 0;
 
@@ -4931,4 +4962,5 @@
     }
   }
+#if !QC_BVSP_CleanUP_D0191
   else
   {
@@ -4943,4 +4975,5 @@
     }
   }
+#endif
 
   Int iDisp = aiShiftLUT[ maxDepthVal ] << iShiftPrec;
@@ -5010,5 +5043,5 @@
         }
       }
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
       else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
       { 
@@ -5708,5 +5741,5 @@
   }
  
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152&!QC_BVSP_CleanUP_D0191
   if(pcTmpCU != NULL && pcTmpCU->getVSPIndex(uiIdx))
   {
@@ -5824,5 +5857,5 @@
   }
 
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 &!QC_BVSP_CleanUP_D0191
   if(pcTmpCU->getVSPIndex(uiIdx))
   {
@@ -5987,5 +6020,5 @@
   TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
   iColViewIdx = pColCU->getSlice()->getViewId();
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
   if( pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr) < 0)
   {
Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComDataCU.h	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComDataCU.h	(revision 355)
@@ -277,5 +277,9 @@
   inline Bool   xAddVspMergeCand      ( UChar ucVspMergePos, Int vspIdx, Bool* bVspMvZeroDone, UInt uiDepth, Bool* abCandIsInter, Int& iCount,
                                         UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, Int* iVSPIndexTrue, Int mrgCandIdx, DisInfo* pDisInfo );
-  inline Void   xInheritVspMode       ( TComDataCU* pcCURef, UInt uiIdx, Bool* bVspMvZeroDone, Int iCount, Int* iVSPIndexTrue, TComMvField* pcMvFieldNeighbours, DisInfo* pDInfo ) ;
+  inline Void   xInheritVspMode       ( TComDataCU* pcCURef, UInt uiIdx, Bool* bVspMvZeroDone, Int iCount, Int* iVSPIndexTrue, TComMvField* pcMvFieldNeighbours, DisInfo* pDInfo,
+#if QC_BVSP_CleanUP_D0191
+   UChar *puhInterDirNeighbours
+#endif
+ ) ;
 #endif
   Void          deriveRightBottomIdx        ( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxRB );
Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComLoopFilter.cpp
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComLoopFilter.cpp	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComLoopFilter.cpp	(revision 355)
@@ -428,5 +428,5 @@
   //-- Set BS for Intra MB : BS = 4 or 3
   if ( pcCUP->isIntra(uiPartP) || pcCUQ->isIntra(uiPartQ) 
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
     || pcCUP->getVSPIndex(uiPartP) || pcCUQ->getVSPIndex(uiPartQ)
 #endif
@@ -438,5 +438,5 @@
   //-- Set BS for not Intra MB : BS = 2 or 1 or 0
   if ( !pcCUP->isIntra(uiPartP) && !pcCUQ->isIntra(uiPartQ) 
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
     && !pcCUP->getVSPIndex(uiPartP) && !pcCUQ->getVSPIndex(uiPartQ)
 #endif
@@ -534,5 +534,5 @@
   }   // enf of "if( not Intra )"
   
-#if MERL_VSP_C0152
+#if MERL_VSP_C0152 & !QC_BVSP_CleanUP_D0191
   if ( pcCUP->getVSPIndex(uiPartP) || pcCUQ->getVSPIndex(uiPartQ))
   {
Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 355)
@@ -781,4 +781,5 @@
   if (vspIdx != 0)
   {
+#if !QC_BVSP_CleanUP_D0191
     if (iRefIdx >= 0)
     {
@@ -786,4 +787,5 @@
     }
     assert (iRefIdx < 0); // assert (iRefIdx == NOT_VALID);
+#endif
   }
   else
Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 355)
@@ -180,4 +180,5 @@
 #if MERL_VSP_C0152
 #define MERL_VSP_C0152_BugFix_ForNoDepthCase     1// MERL bugfix for test condition of no depth
+#define QC_BVSP_CleanUP_D0191                    1
 /*
  * Two macros are used to configure combinations of JCT3V-C0152 and JCT3V-C0131
Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp	(revision 355)
@@ -386,4 +386,11 @@
       }
       pcCU->setVSPIndexSubParts( iVSPIdx, uiAbsPartIdx, 0, uiDepth );  //Initialize the VSP, may change later in get InterMergeCandidates()
+#if QC_BVSP_CleanUP_D0191
+      if(iVSPIdx != 0)
+      {
+        Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0);
+       cMvFieldNeighbours[ 2*uiMergeIndex].setRefIdx(iIVCIdx);
+      }
+#endif
     }
 #else
Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 355)
@@ -330,4 +330,11 @@
         }
         pcCU->setVSPIndexSubParts( iVSPIdx, uiSubPartIdx, uiPartIdx, uiDepth );  //Initialize the VSP, may change later in get InterMergeCandidates()
+#if QC_BVSP_CleanUP_D0191
+       if(iVSPIdx != 0)
+       {
+         Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0);
+         cMvFieldNeighbours[ 2*uiMergeIndex].setRefIdx(iIVCIdx);
+       }
+#endif
       }
 
Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp	(revision 355)
@@ -1920,4 +1920,11 @@
             }
             rpcTempCU->setVSPIndexSubParts( iVSPIdx, 0, 0, uhDepth );
+#if QC_BVSP_CleanUP_D0191
+           if(iVSPIdx != 0)
+           {
+             Int iIVCIdx = rpcTempCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==rpcTempCU->getSlice()->getPOC() ? 0: rpcTempCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0);
+             cMvFieldNeighbours[ 2*uiMergeCand].setRefIdx(iIVCIdx);
+           }
+#endif
           }
 #endif
Index: branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 352)
+++ branches/HTM-6.2-dev1-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 355)
@@ -3002,4 +3002,11 @@
         }
         pcCU->setVSPIndexSubParts( iVSPIdx, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+#if QC_BVSP_CleanUP_D0191
+       if(iVSPIdx != 0)
+       {
+        Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0);
+        cMvFieldNeighbours[ 2*uiMergeIndex].setRefIdx(iIVCIdx);
+      }
+#endif
       }
 #endif
@@ -3724,4 +3731,11 @@
           }
           pcCU->setVSPIndexSubParts( iVSPIdx, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+#if QC_BVSP_CleanUP_D0191
+         if(iVSPIdx != 0)
+         {
+           Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0);
+           cMRGMvField[ 0].setRefIdx(iIVCIdx);
+         }
+#endif
         }
 #endif
