Index: /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 458)
+++ /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 459)
@@ -801,4 +801,45 @@
 #endif
 
+#if MFM_ENCCONSTRAINT
+Bool TComPic::checkSameRefInfo()
+{
+  Bool bSameRefInfo = true;
+  TComSlice * pSlice0 = getSlice( 0 );
+  for( UInt uSliceID = getNumAllocatedSlice() - 1 ; bSameRefInfo && uSliceID > 0 ; uSliceID-- )
+  {
+    TComSlice * pSliceN = getSlice( uSliceID );
+    if( pSlice0->getSliceType() != pSliceN->getSliceType() )
+    {
+      bSameRefInfo = false;
+    }
+    else if( pSlice0->getSliceType() != I_SLICE )
+    {
+      Int nListNum = pSlice0->getSliceType() == B_SLICE ? 2 : 1;
+      for( Int nList = 0 ; nList < nListNum ; nList++ )
+      {
+        RefPicList eRefList = ( RefPicList )nList;
+        if( pSlice0->getNumRefIdx( eRefList ) == pSliceN->getNumRefIdx( eRefList ) )
+        {
+          for( Int refIdx = pSlice0->getNumRefIdx( eRefList ) - 1 ; refIdx >= 0 ; refIdx-- )
+          {
+            if( pSlice0->getRefPic( eRefList , refIdx ) != pSliceN->getRefPic( eRefList , refIdx ) )
+            {
+              bSameRefInfo = false;
+              break;
+            }
+          }
+        }
+        else
+        {
+          bSameRefInfo = false;
+          break;
+        }
+      }
+    }
+  }
+
+  return( bSameRefInfo );  
+}
+#endif
 
 //! \}
Index: /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.h
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.h	(revision 458)
+++ /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.h	(revision 459)
@@ -129,4 +129,7 @@
   Void          initUpsampledMvField  ();
 #endif
+#if MFM_ENCCONSTRAINT
+  Bool          checkSameRefInfo();
+#endif
 
   Bool          getUsedByCurr()             { return m_bUsedByCurr; }
Index: /branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 458)
+++ /branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 459)
@@ -45,4 +45,5 @@
 #define RANDOM_ACCESS_SEI_FIX            1
 #if SVC_EXTENSION
+#define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
 #define VPS_NUH_LAYER_ID                 1      ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0
 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
Index: /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 458)
+++ /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 459)
@@ -1253,4 +1253,15 @@
     }
 #endif
+#if MFM_ENCCONSTRAINT
+    if( pcSlice->getMFMEnabledFlag() )
+    {
+      Int nRefLayerID = pcSlice->getRefPic( pcSlice->getSliceType() == B_SLICE ? ( RefPicList )( 1 - pcSlice->getColFromL0Flag() ) : REF_PIC_LIST_0 , pcSlice->getColRefIdx() )->getLayerId();
+      if( nRefLayerID != pcSlice->getLayerId() )
+      {
+        TComPic * pColBasePic = pcSlice->getBaseColPic( nRefLayerID );
+        assert( pColBasePic->checkSameRefInfo() == true );
+      }
+    }
+#endif
 #endif
     
Index: /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 458)
+++ /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 459)
@@ -1184,5 +1184,9 @@
         for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++) 
         { 
-          if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId) ) 
+          if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId) 
+#if MFM_ENCCONSTRAINT
+            && pcSlice->getBaseColPic( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getLayerId() )->checkSameRefInfo() == true 
+#endif
+            ) 
           { 
             ColRefIdx = colIdx; 
@@ -1197,5 +1201,9 @@
           for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++) 
           { 
-            if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId) ) 
+            if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId) 
+#if MFM_ENCCONSTRAINT
+              && pcSlice->getBaseColPic( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getLayerId() )->checkSameRefInfo() == true 
+#endif
+              ) 
             { 
               ColRefIdx = colIdx; 
