Index: /branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp	(revision 510)
+++ /branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp	(revision 511)
@@ -2654,30 +2654,31 @@
   picDepth = getSlice()->getIvPic( true, refViewIdx );
 
-  /*
+  //////////
   // Code if simply re-writing
-  if(ucVspMergePos == H_3D_VSPPOSITION && picDepth != NULL && 0 != m_pcSlice->getViewIndex() ) // VSP can be used only when depth is used as input
-  {
-    abCandIsInter[iCount] = true;
-    puhInterDirNeighbours[iCount] = 1;
-    vspFlag[iCount] = 1;
-    vspDirTrue[iCount] = 0; // TODO: Check if this is really useful!!!!
-
-    Int iRefIdxList0 = getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC() == getSlice()->getPOC() ? 0 :
-                      (getSlice()->getAlterRefIdx(REF_PIC_LIST_0) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_0));
-    pcMvFieldNeighbours[iCount<<1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList0 );
-    if (getSlice()->isInterB())
-    {
-      puhInterDirNeighbours[iCount] = xGetVspDirection(uiPUIdx);
-      Int iRefIdxList1 = getSlice()->getRefPic(REF_PIC_LIST_1, 0)->getPOC() == getSlice()->getPOC() ? 0 :
-                        (getSlice()->getAlterRefIdx(REF_PIC_LIST_1) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_1));
-      pcMvFieldNeighbours[(iCount<<1)+1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList1 );
-    }
-
-    if ( mrgCandIdx == iCount )
-      return true;
-
-    iCount++;
-  }
-  */
+//  if(ucVspMergePos == H_3D_VSPPOSITION && picDepth != NULL && 0 != m_pcSlice->getViewIndex() ) // VSP can be used only when depth is used as input
+//  {
+//    abCandIsInter[iCount] = true;
+//    puhInterDirNeighbours[iCount] = 1;
+//    vspFlag[iCount] = 1;
+//    vspDirTrue[iCount] = 0; // TODO: Check if this is really useful!!!!
+//
+//    Int iRefIdxList0 = getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC() == getSlice()->getPOC() ? 0 :
+//                      (getSlice()->getAlterRefIdx(REF_PIC_LIST_0) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_0));
+//    pcMvFieldNeighbours[iCount<<1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList0 );
+//    if (getSlice()->isInterB())
+//    {
+//      puhInterDirNeighbours[iCount] = xGetVspDirection(uiPUIdx);
+//      Int iRefIdxList1 = getSlice()->getRefPic(REF_PIC_LIST_1, 0)->getPOC() == getSlice()->getPOC() ? 0 :
+//                        (getSlice()->getAlterRefIdx(REF_PIC_LIST_1) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_1));
+//      pcMvFieldNeighbours[(iCount<<1)+1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList1 );
+//    }
+//
+//    if ( mrgCandIdx == iCount )
+//      return true;
+//
+//    iCount++;
+//  }
+  /////////////
+  
   if(ucVspMergePos == H_3D_VSP_POSITION && picDepth != NULL && 0 != m_pcSlice->getViewIndex() ) // VSP can be used only when depth is used as input
   {
@@ -2699,8 +2700,12 @@
         if (refViewIdx == viewIdxRefInList)
         {
+          Int iRefIdxList0 = getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC() == getSlice()->getPOC() ? 0 :
+                            (getSlice()->getAlterRefIdx(REF_PIC_LIST_0) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_0));
+
           refViewAvailFlag = true;
           predFlag[iRefListIdX] = 1;
           iRefListIdY = 1 - iRefListIdX;
-          pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acDoNBDV, i );
+          pcMvFieldNeighbours[iCount<<1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList0 );
+          // pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acDoNBDV, i ); // Buggy code
         }
       }
@@ -2716,7 +2721,11 @@
         if (refViewIdx != viewIdxRefInList)
         {
+          Int iRefIdxList1 = getSlice()->getRefPic(REF_PIC_LIST_1, 0)->getPOC() == getSlice()->getPOC() ? 0 :
+                            (getSlice()->getAlterRefIdx(REF_PIC_LIST_1) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_1));
+
           refViewAvailFlag = true;
           predFlag[iRefListIdY] = 1;
-          pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( pDInfo->m_acDoNBDV, i );
+          pcMvFieldNeighbours[(iCount<<1)+1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList1 );
+          //pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( pDInfo->m_acDoNBDV, i );  // Buggy code
         }
       }
Index: /branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComPrediction.cpp	(revision 510)
+++ /branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComPrediction.cpp	(revision 511)
@@ -594,5 +594,5 @@
 
   // Step 4: Do compensation
-  TComMv cMv  = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
+  TComMv cMv  = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); // cMv is the disparity vector derived from the neighbors
   pcCU->clipMv(cMv);
   Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
