Index: branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1534)
@@ -3317,34 +3317,38 @@
 
 #if REF_IDX_ME_ZEROMV
-Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
+Bool TComDataCU::checkZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
 {
   Bool checkZeroMVILR = true;
 
-  if(uhInterDir&0x1)  //list0
-  {
-    Int refIdxL0 = cMvFieldL0.getRefIdx();
-    TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_0, refIdxL0);
-
-    if(refPic->isILR(m_pcPic->getLayerId()))
-    {
-      checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
-
-      // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
-      // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
-      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() );
-    }
-  }
-  if(uhInterDir&0x2)  //list1
-  {
-    Int refIdxL1  = cMvFieldL1.getRefIdx();
-    TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_1, refIdxL1);
-
-    if(refPic->isILR(m_pcPic->getLayerId()))
-    {
-      checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
-
-      // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
-      // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
-      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() );
+  if( m_pcSlice->getVPS()->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer
+  {
+    if( uhInterDir & 0x1 )  //list0
+    {
+      Int refIdxL0 = cMvFieldL0.getRefIdx();
+      TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_0, refIdxL0);
+
+      if(refPic->isILR(m_pcPic->getLayerId()))
+      {
+        checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
+
+        // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
+        // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
+        checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() );
+      }
+    }
+
+    if( uhInterDir & 0x2 )  //list1
+    {
+      Int refIdxL1  = cMvFieldL1.getRefIdx();
+      TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_1, refIdxL1);
+
+      if(refPic->isILR(m_pcPic->getLayerId()))
+      {
+        checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
+
+        // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
+        // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
+        checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() );
+      }
     }
   }
@@ -3353,16 +3357,19 @@
 }
 
-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 TComDataCU::checkZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx)
+{
   Bool checkZeroMVILR = true;
 
-  if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_pcPic->getLayerId()))
-  {
-    AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo();
-    TComMv    cMv        = pcAMVPInfo->m_acMvCand[MvpIdx];
-    checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0);
+  if( m_pcSlice->getVPS()->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer
+  {
+    RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0;
+    assert(eRefPicList == REF_PIC_LIST_1);
+
+    if( m_pcSlice->getRefPic(eRefPicList, iRefIdx)->isILR(m_pcPic->getLayerId()) )
+    {
+      AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo();
+      TComMv    cMv        = pcAMVPInfo->m_acMvCand[MvpIdx];
+      checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0);
+    }
   }
 
Index: branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 1534)
@@ -487,6 +487,6 @@
 #endif
 #if REF_IDX_ME_ZEROMV
-  Bool          xCheckZeroMVILRMerge          ( UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
-  Bool          xCheckZeroMVILRMvdL1Zero      ( Int iRefList, Int iRefIdx, Int MvpIdx);
+  Bool          checkZeroMVILRMerge           ( UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
+  Bool          checkZeroMVILRMvdL1Zero       ( Int iRefList, Int iRefIdx, Int MvpIdx);
 #endif
   TComDataCU*   getBaseColCU                  ( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** posScalingFactor, Bool motionMapping = false );
Index: branches/SHM-dev/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1534)
@@ -585,5 +585,10 @@
       // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
       assert( pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getPic()->getLayerIdx(), refPic->getLayerIdx() ) );
-
+#if VIEW_SCALABILITY 
+      if( pcCU->getSlice()->getSPS()->getInterViewMvVertConstraintFlag() )
+      {
+        assert( cMv.getVer()<= (56<<2) );
+      }
+#endif
 #if REF_IDX_ME_ZEROMV
       // It is a requirement of bitstream conformance that the variables mvLX[ 0 ] and mvLX[ 1 ] shall be equal to 0 if the value of refIdxLX corresponds to an inter-layer reference picture.
Index: branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1534)
@@ -567,4 +567,43 @@
 
 #if SVC_EXTENSION
+#if VIEW_SCALABILITY 
+  std::vector<TComPic*> refPicSetInterLayer0;
+  std::vector<TComPic*> refPicSetInterLayer1;
+  const TComVPS* cVPS=getVPS();
+
+  Int viewIdCurrLayerId  = cVPS->getViewIdVal(cVPS->getViewIndex(m_layerId) );
+  Int viewId0            = cVPS->getViewIdVal( 0 );
+  for( i=0; i< m_activeNumILRRefIdx ;i++)
+  {
+      Int refLayerIdc = m_interLayerPredLayerIdc[i];       
+      Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx());
+      if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
+      {
+          Int viewIdRefPicLayerIdi = cVPS->getViewIdVal( ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx() );
+          Bool refPicSet0Flag =
+              ( ( viewIdCurrLayerId <=  viewId0  &&  viewIdCurrLayerId <=  viewIdRefPicLayerIdi )  ||
+              ( viewIdCurrLayerId >=  viewId0  &&  viewIdCurrLayerId >=  viewIdRefPicLayerIdi ) );
+
+          if ( refPicSet0Flag )
+          {
+              refPicSetInterLayer0.push_back( ilpPic[refLayerIdc] );
+          }
+          else
+          {
+              refPicSetInterLayer1.push_back( ilpPic[refLayerIdc] );
+          }
+
+      }
+  }
+ 
+
+  if( m_layerId > 0 )
+  {
+      for( i = 0; i < refPicSetInterLayer0.size() && cIdx < numPicTotalCurr; cIdx ++, i ++)      
+      {
+          rpsCurrList0[cIdx] = refPicSetInterLayer0[i];
+      }
+  }
+#else
     // initial reference picture list construction
     if( m_layerId > 0 )
@@ -584,4 +623,5 @@
       }
     }
+#endif
 #endif //SVC_EXTENSION
 
@@ -594,5 +634,15 @@
     rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
   }
+#if VIEW_SCALABILITY
+  if( m_layerId > 0 )
+  {
+      for( i = 0; i < refPicSetInterLayer1.size(); cIdx++, i++ )      
+      {
+          rpsCurrList0[cIdx] = refPicSetInterLayer1[i];
+      }
+  }
+#else
   assert(cIdx == numPicTotalCurr);
+#endif
 
   if (m_eSliceType==B_SLICE)
@@ -603,4 +653,13 @@
       rpsCurrList1[cIdx] = RefPicSetStCurr1[i];
     }
+#if VIEW_SCALABILITY 
+    if( m_layerId > 0 )
+    {
+        for( i = 0; i < refPicSetInterLayer1.size(); cIdx ++, i ++)      
+        {
+            rpsCurrList1[cIdx] = refPicSetInterLayer1[i];
+        }
+    }
+#endif
     for ( i=0; i<NumPicStCurr0; i++, cIdx++)
     {
@@ -612,4 +671,13 @@
     }    
 
+#if VIEW_SCALABILITY 
+    if( m_layerId > 0 )
+    {
+      for( i = 0; i < refPicSetInterLayer0.size(); cIdx ++, i ++)
+      {
+        rpsCurrList1[cIdx] = refPicSetInterLayer0[i];
+      }
+    }
+#else
 #if SVC_EXTENSION
     if( m_layerId > 0 )
@@ -630,6 +698,6 @@
     }
 #endif //SVC_EXTENSION
-
     assert(cIdx == numPicTotalCurr);
+#endif
   }
 
@@ -643,5 +711,9 @@
 
 #if SVC_EXTENSION
+#if VIEW_SCALABILITY 
+    m_bIsUsedAsLongTerm[REF_PIC_LIST_0][rIdx] = (cIdx<NumPicStCurr0 || (cIdx>=NumPicStCurr0+refPicSetInterLayer0.size() && cIdx<NumPicStCurr0+refPicSetInterLayer0.size()+NumPicStCurr1)) ? false : true;
+#else
     m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPicStCurr0 && cIdx < NumPicStCurr0 + m_activeNumILRRefIdx ) || ( cIdx >= NumPicStCurr0 + NumPicStCurr1 + m_activeNumILRRefIdx );
+#endif
 #else
     m_bIsUsedAsLongTerm[REF_PIC_LIST_0][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 );
@@ -660,5 +732,9 @@
       assert(cIdx >= 0 && cIdx < numPicTotalCurr);
       m_apcRefPicList[REF_PIC_LIST_1][rIdx] = rpsCurrList1[ cIdx ];
+#if VIEW_SCALABILITY 
+      m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = (cIdx<NumPicStCurr1 || (cIdx>=NumPicStCurr1+refPicSetInterLayer1.size() && cIdx<NumPicStCurr1+refPicSetInterLayer1.size()+NumPicStCurr0)) ? false : true;
+#else
       m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 );
+#endif
     }
   }
@@ -699,4 +775,46 @@
   return numRpsCurrTempList;
 }
+
+#if VIEW_SCALABILITY 
+Int TComSlice::getNumRpsInterLayerX(Int li, TComPic** ilpPic)
+{
+  assert(li==0 || li==1);
+
+  Int viewIdCurrLayerId  = m_pcVPS->getViewIdVal(m_pcVPS->getViewIndex(m_layerId) );
+  Int viewId0            = m_pcVPS->getViewIdVal( 0 );
+  Int numInterLayer0 = 0;
+  Int numInterLayer1 = 0;
+
+  for( Int i=0; i < m_activeNumILRRefIdx; i++ )
+  {
+    Int refLayerIdc = m_interLayerPredLayerIdc[i];       
+    Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx());
+
+    if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
+    {
+      Int viewIdRefPicLayerIdi = m_pcVPS->getViewIdVal( ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx() );
+      Bool refPicSet0Flag = ( ( viewIdCurrLayerId <= viewId0 && viewIdCurrLayerId <= viewIdRefPicLayerIdi ) || ( viewIdCurrLayerId >= viewId0 && viewIdCurrLayerId >= viewIdRefPicLayerIdi ) );
+
+      if( refPicSet0Flag )
+      {
+        numInterLayer0++;
+      }
+      else
+      {
+        numInterLayer1++;
+      }
+    }
+  }
+
+  if( li==0 )
+  {
+    return numInterLayer0;
+  }
+  else
+  {
+    return numInterLayer1;
+  }
+}
+#endif
 
 Void TComSlice::initEqualRef()
@@ -3477,5 +3595,9 @@
 }
 
+#if VIEW_SCALABILITY
+Void TComSlice::setRefPicListModificationSvc( TComPic** ilpPic )
+#else
 Void TComSlice::setRefPicListModificationSvc()
+#endif
 {
   if( !m_pcPPS->getListsModificationPresentFlag()) 
@@ -3491,7 +3613,5 @@
   TComRefPicListModification* refPicListModification = &m_RefPicListModification;
   Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList();  // total number of ref pics in listTemp0 including inter-layer ref pics
-#if SVC_EXTENSION
-  Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList();  // number of negative temporal ref pics 
-#endif
+  Int numberOfPocBeforeCurr = getNumNegativeRpsCurrTempList();  // number of negative temporal ref pics 
 
   assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0);
@@ -3499,14 +3619,39 @@
 
   //set L0 inter-layer reference picture modification
-#if SVC_EXTENSION
-  Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
-
-  if( m_activeNumILRRefIdx > 1 )
-  {
-    hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
-  }
-#else
-  Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true;
-#endif
+#if VIEW_SCALABILITY
+  Int numberOfPocAfterCurr = 0;
+  Int numberOfInterLayer0 = 0;
+  Int numberOfInterLayer1 = 0;
+#endif
+
+  Bool hasModification = false;
+
+  if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer
+  {
+    hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
+
+    if( m_activeNumILRRefIdx > 1 )
+    {
+      hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
+    }
+  }
+#if VIEW_SCALABILITY
+  else if( m_pcVPS->getScalabilityMask( VIEW_ORDER_INDEX ) ) //multi-view
+  {
+    numberOfPocAfterCurr = getNumfPositiveRpsCurrTempList();
+    numberOfInterLayer0 = getNumRpsInterLayerX(0, ilpPic);
+    numberOfInterLayer1 = getNumRpsInterLayerX(1, ilpPic);
+
+    if( (numberOfInterLayer1 > 0 && m_aiNumRefIdx[REF_PIC_LIST_0] < numberOfRpsCurrTempList) || (numberOfInterLayer1 == 0 && m_aiNumRefIdx[REF_PIC_LIST_0] < numberOfPocBeforeCurr + numberOfInterLayer0 ) )
+    {
+      hasModification = true;
+    }
+    else
+    {
+      hasModification = false;
+    }
+  }  
+#endif
+
   hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 );
   refPicListModification->setRefPicListModificationFlagL0(hasModification);
@@ -3526,5 +3671,5 @@
       }
     }
-    else
+    else if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer
     {
       // number of ILRPs included into the reference picture list with the list modification
@@ -3533,5 +3678,4 @@
       for(Int i = includeNumILRP; i > 0; i-- )
       {
-#if SVC_EXTENSION
         if( numberOfPocBeforeCurr >= m_aiNumRefIdx[REF_PIC_LIST_0] )
         {
@@ -3547,13 +3691,65 @@
           }
         }
-#else
-        refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i);
-#endif
-      }
-    }
+      }
+    }
+#if VIEW_SCALABILITY
+    else if( m_pcVPS->getScalabilityMask( VIEW_ORDER_INDEX ) ) //multi-view
+    {
+      Int includeNumILRP = m_activeNumILRRefIdx;
+      Int iNumILRP = includeNumILRP;
+
+      if( numberOfInterLayer1 > 0 )
+      {
+        if( m_aiNumRefIdx[REF_PIC_LIST_0] < numberOfPocBeforeCurr + m_activeNumILRRefIdx )
+        {
+          for( Int i = 0; i < numberOfInterLayer0 && iNumILRP > 0; i++, iNumILRP-- )
+          {
+            refPicListModification->setRefPicSetIdxL0( m_aiNumRefIdx[REF_PIC_LIST_0] - includeNumILRP + i, numberOfPocBeforeCurr + i );
+          }
+
+          for( Int i = 0; i < numberOfInterLayer1 && iNumILRP > 0; i++, iNumILRP-- )
+          {
+            refPicListModification->setRefPicSetIdxL0( m_aiNumRefIdx[REF_PIC_LIST_0] - includeNumILRP +numberOfInterLayer0+ i, numberOfRpsCurrTempList-  numberOfInterLayer1 + i );
+          }
+        }
+        else
+        {
+          iNumILRP -= numberOfInterLayer0;
+
+          for( Int i = numberOfInterLayer1; i >0 && iNumILRP > 0; i--, iNumILRP-- )
+          {
+            refPicListModification->setRefPicSetIdxL0( m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i );
+          }
+        }
+      }
+      else
+      {
+        for( Int i = numberOfInterLayer0; i >0 && iNumILRP >0 ; i--, iNumILRP-- )
+        {
+          refPicListModification->setRefPicSetIdxL0( m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + numberOfInterLayer0 - i );
+        }
+      }
+    }
+#endif
   }
 
   //set L1 inter-layer reference picture modification
-  hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true;
+  if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer
+  {
+    hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true;
+  }
+#if VIEW_SCALABILITY
+  else if( m_pcVPS->getScalabilityMask( VIEW_ORDER_INDEX ) ) //multi-view
+  {
+    if( (numberOfInterLayer0 > 0 && m_aiNumRefIdx[REF_PIC_LIST_1] < numberOfRpsCurrTempList) || (numberOfInterLayer0 == 0 && m_aiNumRefIdx[REF_PIC_LIST_1] < numberOfPocAfterCurr + numberOfInterLayer1) )
+    {
+      hasModification = true;
+    }
+    else
+    {
+      hasModification = false;
+    }
+  }
+#endif
   hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 );
 
@@ -3573,5 +3769,5 @@
       }
     }
-    else
+    else if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer
     {
       Int includeNumILRP = min(m_aiNumRefIdx[REF_PIC_LIST_1], m_activeNumILRRefIdx);
@@ -3582,4 +3778,42 @@
       }
     }
+#if VIEW_SCALABILITY
+    else if( m_pcVPS->getScalabilityMask( VIEW_ORDER_INDEX ) ) //multi-view
+    {
+      Int includeNumILRP = m_activeNumILRRefIdx;
+      Int iNumILRP=includeNumILRP;
+
+      if( numberOfInterLayer0 > 0 )
+      {
+        if( m_aiNumRefIdx[REF_PIC_LIST_1] < numberOfPocAfterCurr + m_activeNumILRRefIdx )
+        {
+          for( Int i = 0; i < numberOfInterLayer1 && iNumILRP>0; i++,iNumILRP-- )
+          {
+            refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - includeNumILRP + i, numberOfPocAfterCurr + i);
+          }
+
+          for(Int i = 0; i < numberOfInterLayer0 && iNumILRP>0; i++,iNumILRP-- )
+          {
+            refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - includeNumILRP +numberOfInterLayer1+ i, numberOfRpsCurrTempList-numberOfInterLayer0+i);
+          }
+        }
+        else
+        {
+          iNumILRP -= numberOfInterLayer1;
+          for( Int i = numberOfInterLayer0; i > 0 && iNumILRP > 0; i--,iNumILRP-- )
+          {
+            refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i);
+          }
+        }
+      }
+      else
+      {
+        for( Int i = numberOfInterLayer1; i >0 && iNumILRP>0; i--, iNumILRP-- )
+        {
+          refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfPocAfterCurr + numberOfInterLayer1 - i);
+        }
+      }
+    }
+#endif
   }
   return;
@@ -3638,4 +3872,27 @@
   }
 }
+
+#if VIEW_SCALABILITY 
+Int TComSlice::getNumfPositiveRpsCurrTempList()
+{
+  if( m_eSliceType == I_SLICE ) 
+  {
+    return 0;
+  }
+
+  Int numPocAfterCurr = 0;
+
+  for( UInt i = 0; i < m_pRPS->getNumberOfPositivePictures(); i++ )
+  {
+    if( m_pRPS->getUsed(i) )
+    {
+      numPocAfterCurr++;
+    }
+  }
+
+  return numPocAfterCurr;
+}
+#endif
+
 #endif //SVC_EXTENSION
 
Index: branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1534)
@@ -1443,4 +1443,7 @@
   Bool             m_inferScalingListFlag;
   UInt             m_scalingListRefLayerId;
+#if VIEW_SCALABILITY 
+  Bool             m_interViewMvVertConstraintFlag;
+#endif
 #endif //SVC_EXTENSION
 
@@ -1599,4 +1602,9 @@
 
   Void                   inferSPS( const UInt layerId, TComVPS* vps );
+
+#if VIEW_SCALABILITY 
+  Void                   setInterViewMvVertConstraintFlag( Bool val )                                    { m_interViewMvVertConstraintFlag = val;                               }
+  Bool                   getInterViewMvVertConstraintFlag() const                                        { return m_interViewMvVertConstraintFlag;                              }
+#endif
 #endif //SVC_EXTENSION
 };
@@ -2351,6 +2359,11 @@
   Void                        setFullPelBaseRec( UInt refLayerIdc, TComPicYuv* p)    { m_pcFullPelBaseRec[refLayerIdc] = p;                          }
   TComPicYuv*                 getFullPelBaseRec( UInt refLayerIdc)                   { return  m_pcFullPelBaseRec[refLayerIdc];                      }
-
+#if VIEW_SCALABILITY 
+  Int                         getNumRpsInterLayerX( Int li, TComPic** ilpPic );
+  Void                        setRefPicListModificationSvc( TComPic** ilpPic );
+  Int                         getNumfPositiveRpsCurrTempList();
+#else
   Void                        setRefPicListModificationSvc();
+#endif
   Int                         getNumILRRefIdx()                                      { return  m_pcVPS->getNumDirectRefLayers( m_layerId );          }
 
Index: branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1534)
@@ -72,4 +72,6 @@
 #define NO_CLRAS_OUTPUT_FLAG             1
 
+#define VIEW_SCALABILITY                 0      ///< JCTVC-W0134: multi-view support
+
 /// scalability types
 enum ScalabilityType
@@ -87,6 +89,5 @@
 
 /// normative encoder constraints --------
-#define REF_IDX_ME_ZEROMV                1      ///< JCTVC-L0051: use zero motion for inter-layer reference picture (without fractional ME)
-
+#define REF_IDX_ME_ZEROMV                1      ///< JCTVC-L0051: use zero motion for inter-layer reference picture for scalable layer (without fractional ME)
 /// encoder settings ---------------------
 #define FAST_INTRA_SHVC                  1      ///< JCTVC-M0115: reduction number of intra modes in the EL (encoder only)
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1534)
@@ -2186,4 +2186,19 @@
     READ_CODE(32, uiCode, "reserved_zero_34bits");  READ_CODE(2, uiCode, "reserved_zero_34bits");
   }
+#if VIEW_SCALABILITY
+  else if( ptl->getProfileIdc() == Profile::MULTIVIEWMAIN )
+  {
+    READ_FLAG(    uiCode, "general_max_12bit_constraint_flag" ); assert (uiCode == 1);
+    READ_FLAG(    uiCode, "general_max_10bit_constraint_flag" ); assert (uiCode == 1);
+    READ_FLAG(    uiCode, "general_max_8bit_constraint_flag"  ); assert (uiCode == 1);
+    READ_FLAG(    uiCode, "general_max_422chroma_constraint_flag"  ); assert (uiCode == 1);
+    READ_FLAG(    uiCode, "general_max_420chroma_constraint_flag"  ); assert (uiCode == 1);
+    READ_FLAG(    uiCode, "general_max_monochrome_constraint_flag" ); assert (uiCode == 0);
+    READ_FLAG(    uiCode, "general_intra_constraint_flag"); assert (uiCode == 0);
+    READ_FLAG(    uiCode, "general_one_picture_only_constraint_flag"); assert (uiCode == 0);
+    READ_FLAG(    uiCode, "general_lower_bit_rate_constraint_flag"); assert (uiCode == 1);
+    READ_CODE(32, uiCode, "general_reserved_zero_34bits");  READ_CODE(2, uiCode, "general_reserved_zero_34bits");
+  }
+#endif
   else
   {
@@ -3556,4 +3571,11 @@
 
   READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" );
+  
+#if VIEW_SCALABILITY 
+  pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false);
+#else
+  // Vertical MV component restriction is not used in SHVC CTC
+  assert( uiCode == 0 );
+#endif
 }
 
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1534)
@@ -839,4 +839,11 @@
   // set motion mapping flag
   m_apcSlicePilot->setMFMEnabledFlag( ( m_apcSlicePilot->getNumMotionPredRefLayers() > 0 && m_apcSlicePilot->getActiveNumILRRefIdx() && !m_apcSlicePilot->isIntra() ) ? true : false );
+
+#if VIEW_SCALABILITY
+  if( vps->getViewIndex(nalu.m_nuhLayerId) == 1 && sps->getPTL()->getGeneralPTL()->getProfileIdc() == Profile::MULTIVIEWMAIN )
+  {
+    assert( sps->getInterViewMvVertConstraintFlag() == 1 );
+  }
+#endif
 #endif
 
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1534)
@@ -1445,4 +1445,19 @@
     WRITE_CODE(0, 32,  "general_reserved_zero_34bits");  WRITE_CODE(0, 2,  "general_reserved_zero_34bits");
   }
+#if VIEW_SCALABILITY
+  else if( ptl->getProfileIdc() == Profile::MULTIVIEWMAIN )
+  {
+    WRITE_FLAG(true,   "general_max_12bit_constraint_flag");
+    WRITE_FLAG(true,   "general_max_10bit_constraint_flag");
+    WRITE_FLAG(true,   "general_max_8bit_constraint_flag");
+    WRITE_FLAG(true,   "general_max_422chroma_constraint_flag");
+    WRITE_FLAG(true,   "general_max_420chroma_constraint_flag");
+    WRITE_FLAG(false,  "general_max_monochrome_constraint_flag");
+    WRITE_FLAG(false,  "general_intra_constraint_flag");
+    WRITE_FLAG(false,  "general_one_picture_only_constraint_flag");
+    WRITE_FLAG(true,   "general_lower_bit_rate_constraint_flag");
+    WRITE_CODE(0, 32,  "general_reserved_zero_34bits");  WRITE_CODE(0, 2,  "general_reserved_zero_34bits");
+  }
+#endif
   else
   {
@@ -1994,5 +2009,7 @@
 
   WRITE_CODE( vps->getViewIdLen( ), 4, "view_id_len" );
+#if !VIEW_SCALABILITY
   assert ( vps->getNumViews() >= (1<<vps->getViewIdLen()) );
+#endif
 
   if ( vps->getViewIdLen() > 0 )
@@ -2460,5 +2477,9 @@
 
   // Vertical MV component restriction is not used in SHVC CTC
+#if VIEW_SCALABILITY 
+  WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0 , "inter_view_mv_vert_constraint_flag" );
+#else
   WRITE_FLAG( 0, "inter_view_mv_vert_constraint_flag" );
+#endif
 }
 
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 1534)
@@ -399,5 +399,5 @@
 
 #if SVC_EXTENSION
-  UInt      m_layerId;   
+  UInt      m_layerId;
   UInt      m_numLayer;
   Bool      m_elRapSliceBEnabled;
@@ -483,4 +483,8 @@
   Int                                 m_TMVPConstraintsSEIEnabled;
 #endif
+
+#if VIEW_SCALABILITY
+  Bool                                m_bUseDisparitySearchRangeRestriction;
+#endif 
 #endif //SVC_EXTENSION
 
@@ -1253,4 +1257,8 @@
 #endif
 #endif
+#if VIEW_SCALABILITY 
+  Void      setUseDisparitySearchRangeRestriction ( Bool b ) { m_bUseDisparitySearchRangeRestriction = b; }
+  Bool      getUseDisparitySearchRangeRestriction ()         { return  m_bUseDisparitySearchRangeRestriction; }
+#endif
 #endif //SVC_EXTENSION
 };
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1534)
@@ -1299,6 +1299,7 @@
     {
 #if REF_IDX_ME_ZEROMV
-      Bool bZeroMVILR = rpcTempCU->xCheckZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]);
-      if(bZeroMVILR)
+      Bool bZeroMVILR = rpcTempCU->checkZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]);
+
+      if( bZeroMVILR )
       {
 #endif
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1534)
@@ -2029,5 +2029,9 @@
     {
       pcSlice->setILRPic( m_pcEncTop->getIlpList() );
+#if VIEW_SCALABILITY 
+      pcSlice->setRefPicListModificationSvc(m_pcEncTop->getIlpList());
+#else
       pcSlice->setRefPicListModificationSvc();
+#endif
       pcSlice->setRefPicList( rcListPic, false, m_pcEncTop->getIlpList());
 
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1534)
@@ -2888,6 +2888,7 @@
   {
 #if REF_IDX_ME_ZEROMV
-    Bool bZeroMVILR = pcCU->xCheckZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]);
-    if(bZeroMVILR)
+    Bool bZeroMVILR = pcCU->checkZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]);
+
+    if( bZeroMVILR )
     {
 #endif
@@ -3113,6 +3114,7 @@
         {
 #if REF_IDX_ME_ZEROMV 
-          Bool bZeroMVILR = pcCU->xCheckZeroMVILRMvdL1Zero(iRefList, iRefIdxTemp, aaiMvpIdx[iRefList][iRefIdxTemp]);
-          if(bZeroMVILR)
+          Bool bZeroMVILR = pcCU->checkZeroMVILRMvdL1Zero(iRefList, iRefIdxTemp, aaiMvpIdx[iRefList][iRefIdxTemp]);
+
+          if( bZeroMVILR )
           {
 #endif
@@ -3864,5 +3866,7 @@
 
   TComMv      cMvPred = *pcMvPred;
-
+#if VIEW_SCALABILITY 
+  m_vertRestriction = m_pcEncCfg->getUseDisparitySearchRangeRestriction() && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getPOC() == pcCU->getSlice()->getPOC();
+#endif
   if ( bBi )
   {
@@ -3882,5 +3886,6 @@
   //  Do integer search
 #if REF_IDX_ME_ZEROMV
-  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getPic()->getLayerId()))  //ILR reference pic 
+  //scalable layer
+  if( pcCU->getSlice()->getVPS()->getScalabilityMask( SCALABILITY_ID ) && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getPic()->getLayerId()) )  //ILR reference pic 
   {
     rcMv.setZero();  //use Mv(0, 0) for integer ME 
@@ -3918,5 +3923,6 @@
 
 #if REF_IDX_ME_ZEROMV
-  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getPic()->getLayerId()))  //ILR reference pic
+  //scalable layer
+  if( pcCU->getSlice()->getVPS()->getScalabilityMask( SCALABILITY_ID ) && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getPic()->getLayerId()))  //ILR reference pic
   {
     xPatternSearchFracDIFMv0( pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost );
@@ -3950,4 +3956,14 @@
   rcMvSrchRngRB.setHor( cTmpMvPred.getHor() + (iSrchRng << iMvShift) );
   rcMvSrchRngRB.setVer( cTmpMvPred.getVer() + (iSrchRng << iMvShift) );
+#if VIEW_SCALABILITY
+  if( m_vertRestriction )
+  {
+    Int mvRestricted = ( 56 - 1 ) << iMvShift ; // -1 to consider subpel search
+    if( rcMvSrchRngRB.getVer() > mvRestricted )
+    {
+      rcMvSrchRngRB.setVer( mvRestricted );
+    }
+  }
+#endif
   pcCU->clipMv        ( rcMvSrchRngLT );
   pcCU->clipMv        ( rcMvSrchRngRB );
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h	(revision 1534)
@@ -120,6 +120,11 @@
   Bool            m_isInitialized;
 
-#if SVC_EXTENSION && N0383_IL_CONSTRAINED_TILE_SETS_SEI
+#if SVC_EXTENSION 
+#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
   Bool            m_disableILP;
+#endif
+#if VIEW_SCALABILITY 
+  Bool            m_vertRestriction;
+#endif 
 #endif
 
@@ -473,5 +478,6 @@
   inline  Void  setDistParamComp( ComponentID compIdx )  { m_cDistParam.compIdx = compIdx; }
 
-#if SVC_EXTENSION && REF_IDX_ME_ZEROMV
+#if SVC_EXTENSION 
+#if REF_IDX_ME_ZEROMV
   Void xPatternSearchFracDIFMv0  ( TComPattern*  pcPatternKey,
                                    Pel*          piRefY,
@@ -485,5 +491,10 @@
                                    UInt&         ruiCost     );
 #endif
-#endif //SVC_EXTENSION  
+#endif
+
+#if VIEW_SCALABILITY 
+  TComMv xCheckMVVertRestriction( TComMv mv );
+#endif
+#endif //SVC_EXTENSION
 
 };// END CLASS DEFINITION TEncSearch
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1533)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1534)
@@ -848,4 +848,14 @@
     m_cSPS.setLayerId(m_layerId);
   }
+#if VIEW_SCALABILITY 
+  if( m_bUseDisparitySearchRangeRestriction )
+  {
+    m_cSPS.setInterViewMvVertConstraintFlag( true );
+  }
+  else
+  {
+    m_cSPS.setInterViewMvVertConstraintFlag( false );
+  }
+#endif
 #endif //SVC_EXTENSION
 
