Index: /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 493)
@@ -215,17 +215,18 @@
 #endif
 #if H_MV
-  in>>entry.m_numInterViewRefPics;
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
-  {
-    in>>entry.m_interViewRefs[i];
-  }
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
+  in>>entry.m_numActiveRefLayerPics;
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
+  {
+    in>>entry.m_interLayerPredLayerIdc[i];
+  }
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
   {
     in>>entry.m_interViewRefPosL[0][i];
   }
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
   {
     in>>entry.m_interViewRefPosL[1][i];
   }
+  in>>entry.m_collocatedRefLayerIdx; 
 #endif
   return in;
@@ -397,7 +398,11 @@
   ("LayerIdsInSet_%d",      m_layerIdsInSets     , std::vector<Int>(1,0), MAX_VPS_OP_SETS_PLUS1 ,"LayerIds of Layer set")  
   ("DefaultOneTargetOutputLayerFlag", m_defaultOneTargetOutputLayerFlag,  false , "Output highest layer of layer sets by default")      
-  ("OutputLayerSetIdx",     m_outputLayerSetIdx  , std::vector<Int>(1,0), "Indices of layer sets used as additional output layer sets")  
+  ("OutputLayerSetIdx",     m_outputLayerSetIdx  , std::vector<Int>(0,0), "Indices of layer sets used as additional output layer sets")  
   ("LayerIdsInAddOutputLayerSet_%d", m_layerIdsInAddOutputLayerSet      , std::vector<Int>(1,0), MAX_VPS_ADD_OUTPUT_LAYER_SETS, "LayerIds of additional output layers")  
   ("ProfileLevelTierIdx",   m_profileLevelTierIdx, std::vector<Int>(1,0), "Indices to profile level tier")
+  
+  // Layer dependencies
+  ("DirectRefLayers_%d",    m_directRefLayers    , std::vector<Int>(0,0), MAX_NUM_LAYERS, "LayerIds of direct reference layers")
+  ("DependencyTypes_%d",    m_dependencyTypes    , std::vector<Int>(0,0), MAX_NUM_LAYERS, "Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion")
 #endif
   ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
@@ -1391,4 +1396,16 @@
   }
   xConfirmPara( m_profileLevelTierIdx.size() < m_vpsNumLayerSets + m_outputLayerSetIdx.size(), "The number of Profile Level Tier indices must be equal to the number of layer set plus the number of output layer set indices" );
+
+  // Layer Dependencies  
+  for (Int i = 0; i < m_numberOfLayers; i++ )
+  {
+    xConfirmPara( (i == 0)  && m_directRefLayers[0].size() != 0, "Layer 0 shall not have reference layers." ); 
+    xConfirmPara( m_directRefLayers[i].size() == m_dependencyTypes[ i ].size() != 0, "Each reference layer shall have a reference type" ); 
+    for (Int j = 0; j < m_directRefLayers[i].size(); j++)
+    {
+      xConfirmPara( m_directRefLayers[i][j] < 0 || m_directRefLayers[i][j] >= i , "Reference layer id shall be greater than or equal to 0 and less than dependent layer id"); 
+      xConfirmPara( m_dependencyTypes[i][j] < 0 || m_dependencyTypes[i][j] >  2 , "Dependency type shall be greater than or equal to 0 and less than 3"); 
+    }        
+  }  
 #endif
   xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
@@ -1544,5 +1561,5 @@
   for( Int i = 0; i < MAX_GOP; i++ )
   {
-    if( m_GOPListMvc[0][i].m_numInterViewRefPics != 0 )
+    if( m_GOPListMvc[0][i].m_numActiveRefLayerPics != 0 )
     {
       printf( "\nError: Frame%d inter_layer refs not available in layer 0\n", i );
@@ -1560,10 +1577,10 @@
       for( Int i = 0; i < MAX_GOP+1; i++ )
       {
-        for( Int j = 0; j < m_GOPListMvc[k][i].m_numInterViewRefPics; j++ )
+        for( Int j = 0; j < m_GOPListMvc[k][i].m_numActiveRefLayerPics; j++ )
         {
-          Int iAbsViewId = m_GOPListMvc[k][i].m_interViewRefs[j] + k;
-          if( iAbsViewId < 0 || iAbsViewId >= k )
+          Int ilPredLayerIdc = m_directRefLayers[k][m_GOPListMvc[k][i].m_interLayerPredLayerIdc[j]];
+          if( ilPredLayerIdc < 0 || ilPredLayerIdc >= m_directRefLayers[k].size() )
           {
-            printf( "\nError: inter-layer ref pic %d is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefs[j], i, k );
+            printf( "\nError: inter-layer ref idc %d is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interLayerPredLayerIdc[j], i, k );
             bErrorIvpEnhV = true;
           }
@@ -1615,5 +1632,5 @@
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics != 0 )
+          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics != 0 )
           {
             printf( "\nError: inter-layer prediction not possible for FrameI_l%d with slice type I, #IL_ref_pics must be 0\n", k );
@@ -1621,12 +1638,12 @@
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics )
+          if( m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics )
           {
-            m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics;
+            m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics;
           }
 
           if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'P' )
           {
-            if( m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
+            if( m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics < 1 )
             {
               printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type P\n", k );
@@ -1635,5 +1652,5 @@
             else
             {
-              for( Int j = 0; j < m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics; j++ )
+              for( Int j = 0; j < m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics; j++ )
               {
                 if( m_GOPListMvc[k][MAX_GOP].m_interViewRefPosL[1][j] != -1 )
@@ -1646,5 +1663,5 @@
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
+          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics < 1 )
           {
             printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type B\n", k );
Index: /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 493)
@@ -87,13 +87,16 @@
   std::vector<Int>       m_dimensionIdLen;                    ///< Length of scalability dimension s 
 
-  // layer sets 
+  // layer sets   
   Int                    m_vpsNumLayerSets;                   ///< Number of layer sets
-  std::vector< std::vector<Int> > m_layerIdsInSets;           ///< LayerIds of Layer set
+  std::vector< std::vector<Int> > m_layerIdsInSets;           ///< LayerIds in vps of layer set 
   Bool                   m_defaultOneTargetOutputLayerFlag;   ///< Output highest layer of layer sets by default
-  Int                    numAddOuputLayerSets;              ///< Number of additional output layer sets
+  Int                    numAddOuputLayerSets;                ///< Number of additional output layer sets
   std::vector<Int>       m_outputLayerSetIdx;                 ///< Indices of layer sets used as additional output layer sets  
-  std::vector< std::vector<Int> > m_layerIdsInAddOutputLayerSet; ///< LayerIds of additional output layers  
+  std::vector< std::vector<Int> > m_layerIdsInAddOutputLayerSet; ///< LayerIds in vps of additional output layers
   std::vector<Int>       m_profileLevelTierIdx;               ///< Indices of of profile level tier
-
+  
+  // Dependencies
+  std::vector<std::vector<Int>> m_directRefLayers;             ///< LayerIds of direct reference layers
+  std::vector<std::vector<Int>> m_dependencyTypes;             ///< Dependency types of direct reference layers
 #endif
   Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
Index: /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 493)
@@ -118,5 +118,5 @@
   xSetLayerIds             ( vps );   
   xSetDimensionIdAndLength ( vps );
-  xSetDirectDependencyFlags( vps );
+  xSetDependencies( vps );
   xSetLayerSets            ( vps ); 
 #if H_3D
@@ -985,26 +985,63 @@
 }
 
-Void TAppEncTop::xSetDirectDependencyFlags( TComVPS& vps )
-{
-  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
-  {
-    if( m_GOPListMvc[layer][MAX_GOP].m_POC == -1 )
-    {
-      continue;
-    }
-    for( Int i = 0; i < getGOPSize()+1; i++ ) 
-    {
-      GOPEntry ge = ( i < getGOPSize() ) ? m_GOPListMvc[layer][i] : m_GOPListMvc[layer][MAX_GOP];
-      for( Int j = 0; j < ge.m_numInterViewRefPics; j++ )
-      {
-        Int interLayerRef = layer + ge.m_interViewRefs[j];
-        vps.setDirectDependencyFlag( layer, interLayerRef, true );
-      }
-    }
-  }
-
-  vps.checkVPSExtensionSyntax(); 
-  vps.setRefLayers();
-}
+Void TAppEncTop::xSetDependencies( TComVPS& vps )
+{
+  // Direct dependency flags + dependency types
+  for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ )
+  {
+    for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ )
+    {
+      vps.setDirectDependencyFlag( depLayer, refLayer, false); 
+      vps.setDirectDependencyType( depLayer, refLayer,    0 ); 
+    }
+  } 
+  for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ )
+  {
+    Int numRefLayers = m_directRefLayers[depLayer].size(); 
+    assert(  numRefLayers == m_dependencyTypes[depLayer].size() ); 
+    for( Int i = 0; i < numRefLayers; i++ )
+    {
+      Int refLayer = m_directRefLayers[depLayer][i]; 
+      vps.setDirectDependencyFlag( depLayer, refLayer, true); 
+      vps.setDirectDependencyType( depLayer, refLayer,m_dependencyTypes[depLayer][i]); 
+    }
+  }
+
+  // Max temporal id for inter layer reference pictures
+  for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++)
+  {  
+    Int maxTid = -1; 
+    for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers; currLayerIdInVps++)
+    {
+      for( Int i = 0; i < getGOPSize(); i++ ) 
+      {        
+        GOPEntry ge =  m_GOPListMvc[currLayerIdInVps][i];
+        
+        for (Int j = 0; j < ge.m_numRefPicsActive; j++)
+        {        
+          if ( m_directRefLayers[ currLayerIdInVps ][ ge.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps )
+          {
+            maxTid = std::max( maxTid, ge.m_temporalId ); 
+          }
+        }
+      }            
+    }
+    vps.setMaxTidIlRefPicPlus1( refLayerIdInVps, maxTid + 1 );
+  }
+
+  // Max one active ref layer flag
+  Bool maxOneActiveRefLayerFlag = true;  
+  for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; currLayerIdInVps++)
+  {
+    for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) 
+    {        
+      GOPEntry ge =  m_GOPListMvc[currLayerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
+      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numRefPicsActive <= 1); 
+    }            
+  }
+
+  vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag );
+  vps.setRefLayers(); 
+}; 
 
 Void TAppEncTop::xSetLayerIds( TComVPS& vps )
@@ -1046,6 +1083,6 @@
     }
     for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++)
-    {
-      vps.setLayerIdIncludedFlag( true, lsIdx, m_layerIdsInSets[lsIdx][i] ); 
+    {       
+      vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) ); 
     } 
   }
Index: /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.h	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.h	(revision 493)
@@ -118,5 +118,5 @@
   Void xSetLayerIds               ( TComVPS& vps );  
   Void xSetDimensionIdAndLength   ( TComVPS& vps );
-  Void xSetDirectDependencyFlags  ( TComVPS& vps );
+  Void xSetDependencies           ( TComVPS& vps );
   Void xSetLayerSets( TComVPS& vps );
   Int  xGetMax( std::vector<Int>& vec);
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 493)
@@ -871,5 +871,5 @@
 #endif
 #if H_MV
-    ,m_tileBoundariesAlignedFlag(false)
+    ,m_tileBoundariesAlignedFlag(true)
 #endif
   {}
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 493)
@@ -1054,6 +1054,4 @@
     }
 
-    pcSlice->setActiveMotionPredRefLayers( );
-
     if( vps->getNumSamplePredRefLayers( layerIdInVps ) > 0  &&  pcSlice->getNumActiveRefLayerPics() > 0 )
     {
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCfg.h	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCfg.h	(revision 493)
@@ -74,7 +74,8 @@
   Int m_refIdc[MAX_NUM_REF_PICS+1];
 #if H_MV
-  Int m_numInterViewRefPics;
-  Int m_interViewRefs    [MAX_NUM_REF_PICS];
-  Int m_interViewRefPosL[2][MAX_NUM_REF_PICS];  
+  Int m_numActiveRefLayerPics;
+  Int m_interLayerPredLayerIdc [MAX_NUM_REF_PICS];
+  Int m_interViewRefPosL[2]    [MAX_NUM_REF_PICS];  
+  Int m_collocatedRefLayerIdx; 
 #endif
   GOPEntry()
@@ -93,5 +94,6 @@
   , m_numRefIdc(0)
 #if H_MV
-  , m_numInterViewRefPics(0)
+  , m_numActiveRefLayerPics(0)
+  , m_collocatedRefLayerIdx(-1)
 #endif
   {
@@ -100,5 +102,5 @@
     ::memset( m_refIdc,        0, sizeof(m_refIdc) );
 #if H_MV
-    ::memset( m_interViewRefs,   0, sizeof(m_interViewRefs) );
+    ::memset( m_interLayerPredLayerIdc,   0, sizeof(m_interLayerPredLayerIdc) );
     ::memset( m_interViewRefPosL[0], -1, sizeof(m_interViewRefPosL[0]) );
     ::memset( m_interViewRefPosL[1], -1, sizeof(m_interViewRefPosL[1]) );
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 493)
@@ -655,8 +655,54 @@
     refPicListModification->setRefPicListModificationFlagL1(0);
 #if H_MV
+
+    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 )
+    {
+      pcSlice->setDiscardableFlag           ( false );     
+    }    
+
+    TComVPS*           vps = pcSlice->getVPS(); 
+    Int       layerIdInVps = vps    ->getLayerIdInVps( getLayerId()); 
+    Int numDirectRefLayers = vps    ->getNumDirectRefLayers( layerIdInVps ); 
+    GOPEntry gopEntry      = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid );     
+    
+    if ( getLayerId() > 0 && numDirectRefLayers > 0 )
+    {         
+      pcSlice->setInterLayerPredEnabledFlag ( gopEntry.m_numActiveRefLayerPics > 0 );     
+      if ( pcSlice->getInterLayerPredEnabledFlag() && numDirectRefLayers > 1 )
+      {
+        if ( !vps->getMaxOneActiveRefLayerFlag() )
+        {    
+          pcSlice->setNumInterLayerRefPicsMinus1( gopEntry.m_numActiveRefLayerPics - 1 ); 
+        }
+        for (Int i = 0; i < gopEntry.m_numActiveRefLayerPics; i++ )
+        {
+          pcSlice->setInterLayerPredLayerIdc( i, gopEntry.m_interLayerPredLayerIdc[ i ] ); 
+        }
+      }
+    }
+    assert( pcSlice->getNumActiveRefLayerPics() == gopEntry.m_numActiveRefLayerPics ); 
+    
+    if ( vps->getNumSamplePredRefLayers( layerIdInVps ) > 0 && pcSlice->getNumActiveRefLayerPics() > 0)
+    {
+      pcSlice->setInterLayerSamplePredOnlyFlag( gopEntry.m_numRefPics == 0 ); 
+    }    
+
     pcSlice->createAndApplyIvReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer ); 
-    pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid ).m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );
-    pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid ).m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );
-    xSetRefPicListModificationsMvc( pcSlice, pocCurr, iGOPid );    
+    pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(gopEntry.m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );
+    pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(gopEntry.m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );
+    xSetRefPicListModificationsMvc( pcSlice, iGOPid );    
+
+    pcSlice->setActiveMotionPredRefLayers( );
+
+    if ( getLayerId() > 0 && pcSlice->getNumActiveMotionPredRefLayers() > 0 && pcSlice->getEnableTMVPFlag() && 
+        ( pcSlice->getSliceType() == B_SLICE || pcSlice->getSliceType() == P_SLICE ))
+    {
+      pcSlice->setAltCollocatedIndicationFlag( gopEntry.m_collocatedRefLayerIdx >= 0 );
+      if ( pcSlice->getNumActiveRefLayerPics() && pcSlice->getNumActiveMotionPredRefLayers() > 0 )
+      {
+        pcSlice->setCollocatedRefLayerIdx( gopEntry.m_collocatedRefLayerIdx );
+      }
+    }
+
 #else
     pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
@@ -2896,5 +2942,5 @@
 #endif
 #if H_MV
-Void TEncGOP::xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid )
+Void TEncGOP::xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt iGOPid )
 { 
   TComVPS* vps = pcSlice->getVPS(); 
@@ -2919,5 +2965,5 @@
     Int numModifications = 0;
     
-    for( Int k = 0; k < ge.m_numInterViewRefPics; k++ ) 
+    for( Int k = 0; k < ge.m_numActiveRefLayerPics; k++ ) 
     {
       numModifications +=  ( ge.m_interViewRefPosL[li][k] >= 0 ) ? 1 : 0; 
@@ -2931,5 +2977,5 @@
     if( (maxRefListSize > 1) && (numModifications > 0) )
     {
-      for( Int k = 0; k < ge.m_numInterViewRefPics; k++ )
+      for( Int k = 0; k < ge.m_numActiveRefLayerPics; k++ )
       {
         if( ge.m_interViewRefPosL[li][k] >= 0 )
@@ -2940,5 +2986,5 @@
           {            
             Int refLayer  = vps->getLayerIdInVps( vps->getRefLayerId( layer, idx ) );          
-            if( ( layer + ge.m_interViewRefs[ k ]) == refLayer )
+            if( ( layer + ge.m_interLayerPredLayerIdc[ k ]) == refLayer )
             {
               tempList[ targetIdx ] = orgIdx;              
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.h	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.h	(revision 493)
@@ -221,5 +221,5 @@
 #endif
 #if H_MV
-   Void  xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid );
+   Void  xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt iGOPid );
 #endif
 #if L0386_DB_METRIC
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 492)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 493)
@@ -731,4 +731,7 @@
   m_cPPS.setWPBiPred( m_useWeightedBiPred );
   m_cPPS.setOutputFlagPresentFlag( false );
+#if H_MV
+  m_cPPS.setNumExtraSliceHeaderBits( 1 ); 
+#endif
   m_cPPS.setSignHideFlag(getSignHideFlag());
 #if L0386_DB_METRIC
