Index: /branches/SHM-1.0-dev/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /branches/SHM-1.0-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 22)
+++ /branches/SHM-1.0-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 23)
@@ -2143,4 +2143,43 @@
 #endif
 
+#if REF_IDX_ME_ZEROMV
+Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
+{
+	Bool checkZeroMVILR = true;
+
+	if(uhInterDir&0x1)  //list0
+	{
+		Int refIdxL0 = cMvFieldL0.getRefIdx();
+		if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->getIsILR())
+			checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
+	}
+	if(uhInterDir&0x2)  //list1
+	{
+		Int refIdxL1  = cMvFieldL1.getRefIdx();
+		if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->getIsILR())
+			checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
+	}
+
+	return checkZeroMVILR;
+}
+
+Bool TComDataCU::xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx)
+{
+	RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0;
+	assert(eRefPicList == REF_PIC_LIST_1);
+
+	Bool checkZeroMVILR = true;
+
+	if(getSlice()->getRefPic(eRefPicList, iRefIdx)->getIsILR())
+	{
+		AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo();
+		TComMv    cMv        = pcAMVPInfo->m_acMvCand[MvpIdx];
+		checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0);
+	}
+
+	return checkZeroMVILR;
+}
+#endif
+
 UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx )
 {
Index: /branches/SHM-1.0-dev/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- /branches/SHM-1.0-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 22)
+++ /branches/SHM-1.0-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 23)
@@ -562,5 +562,10 @@
   UInt          getCtxIntraBLFlag               ( UInt   uiAbsPartIdx                                 );
 #endif  
-  
+
+#if REF_IDX_ME_ZEROMV
+  Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
+  Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx);
+#endif
+
   UInt          getSliceStartCU         ( UInt pos )                  { return m_uiSliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                          }
   UInt          getDependentSliceStartCU  ( UInt pos )                  { return m_uiDependentSliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
Index: /branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- /branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 22)
+++ /branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 23)
@@ -1351,4 +1351,9 @@
     for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
     {
+#if REF_IDX_ME_ZEROMV
+		Bool bZeroMVILR = rpcTempCU->xCheckZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]);
+		if(bZeroMVILR)
+		{
+#endif
         if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
         {
@@ -1402,4 +1407,7 @@
     }
     }
+#if REF_IDX_ME_ZEROMV 
+	}
+#endif
    }
 
Index: /branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 22)
+++ /branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 23)
@@ -3211,4 +3211,9 @@
   for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
   {
+#if REF_IDX_ME_ZEROMV
+	  Bool bZeroMVILR = pcCU->xCheckZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]);
+	  if(bZeroMVILR)
+	  {
+#endif
       UInt uiCostCand = MAX_UINT;
       UInt uiBitsCand = 0;
@@ -3234,4 +3239,7 @@
         uiMergeIndex = uiMergeCand;
       }
+#if REF_IDX_ME_ZEROMV
+	  }
+#endif
     }
 }
@@ -3420,7 +3428,15 @@
         if(pcCU->getSlice()->getMvdL1ZeroFlag() && iRefList==1 && biPDistTemp < bestBiPDist)
         {
+#if REF_IDX_ME_ZEROMV 
+		  Bool bZeroMVILR = pcCU->xCheckZeroMVILRMvdL1Zero(iRefList, iRefIdxTemp, aaiMvpIdx[iRefList][iRefIdxTemp]);
+		  if(bZeroMVILR)
+		  {
+#endif
           bestBiPDist = biPDistTemp;
           bestBiPMvpL1 = aaiMvpIdx[iRefList][iRefIdxTemp];
           bestBiPRefIdxL1 = iRefIdxTemp;
+#if REF_IDX_ME_ZEROMV
+		  }
+#endif
         }
 
