Index: branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 295)
+++ branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 296)
@@ -843,4 +843,7 @@
   ("ConstantPicRateIdc",           cfg_constantPicRateIdc,            string(""), "List of constant picture rate IDCs; include non-negative number even if corresponding flag is 0")
 #endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  ("AdaptiveResolutionChange",     m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)")
+#endif
   ;
   
@@ -2137,4 +2140,11 @@
   }
 #endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  if (m_adaptiveResolutionChange > 0)
+  {
+    xConfirmPara(m_numLayers != 2, "Adaptive resolution change works with 2 layers only");
+    xConfirmPara(m_acLayerCfg[1].m_iIntraPeriod == 0 || (m_adaptiveResolutionChange % m_acLayerCfg[1].m_iIntraPeriod) != 0, "Adaptive resolution change must happen at enhancement layer RAP picture");
+  }
+#endif
 #undef xConfirmPara
   if (check_failed)
@@ -2175,4 +2185,7 @@
   printf("Multiview                     : %d\n", m_scalabilityMask[0] );
   printf("Scalable                      : %d\n", m_scalabilityMask[1] );
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  printf("Adaptive Resolution Change    : %d\n", m_adaptiveResolutionChange );
+#endif
   for(UInt layer=0; layer<m_numLayers; layer++)
   {
Index: branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 295)
+++ branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 296)
@@ -369,4 +369,7 @@
   Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
 #endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  Int       m_adaptiveResolutionChange;                       ///< Indicate adaptive resolution change frame
+#endif
 public:
   TAppEncCfg();
Index: branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 295)
+++ branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 296)
@@ -515,4 +515,7 @@
     }
 #endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+    m_acTEncTop[layer].setAdaptiveResolutionChange( m_adaptiveResolutionChange );
+#endif
   }
 }
@@ -1031,4 +1034,7 @@
     vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); 
 #endif 
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false);
+#endif
 #else
   m_cTEncTop.init();
@@ -1150,4 +1156,19 @@
 #endif
 
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+    if (m_adaptiveResolutionChange)
+    {
+      for(UInt layer = 0; layer < m_numLayers; layer++)
+      {
+        TComList<TComPicYuv*>::iterator iterPicYuvRec;
+        for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++)
+        {
+          TComPicYuv* recPic = *(iterPicYuvRec);
+          recPic->setReconstructed(false);
+        }
+      }
+    }
+#endif
+
     // loop through frames in one GOP 
     for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ )
@@ -1416,5 +1437,9 @@
   {
     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+    if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed())
+#else
     if (!m_acLayerCfg[layer].getReconFile().empty())
+#endif
     {
       m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), 
@@ -1430,5 +1455,9 @@
   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
 
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ )
+#else
   for ( i = 0; i < iNumEncoded; i++ )
+#endif
   {
     const AccessUnit& au = *(iterBitstream++);
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPicYuv.h	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPicYuv.h	(revision 296)
@@ -92,4 +92,8 @@
 #endif
 
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  Bool    m_isReconstructed;
+#endif
+
   Bool  m_bIsBorderExtended;
   
@@ -174,5 +178,10 @@
   //  Dump picture
   Void  dump (Char* pFileName, Bool bAdd = false);
-  
+
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  Void  setReconstructed(Bool x) { m_isReconstructed = x;    }
+  Bool  isReconstructed()        { return m_isReconstructed; }
+#endif
+
   // Set border extension flag
   Void  setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 296)
@@ -572,5 +572,9 @@
 #if ILR_RESTR
   Int numInterLayerRPSPics = 0;
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
+#else
   if( m_layerId > 0 )
+#endif
   {
     for( i=0; i < m_pcVPS->getNumDirectRefLayers( m_layerId ); i++ )
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 296)
@@ -567,4 +567,7 @@
   UInt       m_maxSublayerForIlpPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
 #endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  Bool       m_singleLayerForNonIrapFlag;
+#endif
 public:
   TComVPS();
@@ -730,4 +733,8 @@
   Bool   getMaxSublayerForIlpPlus1(Int layerId)                     { return m_maxSublayerForIlpPlus1[layerId];                   }
   Void   setMaxSublayerForIlpPlus1(Int layerId, UInt maxSublayer)   { m_maxSublayerForIlpPlus1[layerId] = maxSublayer;            }
+#endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  Bool   getSingleLayerForNonIrapFlag()                             { return m_singleLayerForNonIrapFlag; }
+  Void   setSingleLayerForNonIrapFlag(Bool x)                       { m_singleLayerForNonIrapFlag = x;    }
 #endif
 };
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 296)
@@ -62,4 +62,5 @@
 #define VPS_SPLIT_FLAG                   1      ///< M0163: Do not signal dimension_id and the last dimension_id_len_minus1, when splitting_flag is equal to 1. 
 #define M0457_PREDICTION_INDICATIONS     1
+#define M0040_ADAPTIVE_RESOLUTION_CHANGE 1
 #endif
 
Index: branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 296)
@@ -1158,4 +1158,7 @@
   }
 #endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false);
+#endif
 }
 #endif
@@ -1619,5 +1622,5 @@
       rpcSlice->setColRefLayerIdx( 0 );
       rpcSlice->setAltColIndicationFlag( false );
-      if ( sps->getLayerId() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 )
+      if ( sps->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 )
       {
         READ_FLAG( uiCode, "alt_collocated_indication_flag" );
Index: branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 296)
@@ -937,4 +937,10 @@
       pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic);
     }
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+    else if ( m_layerId > 0 )
+    {
+      pcSlice->setRefPicList( m_cListPic, false, NULL);
+    }
+#endif
 #endif
 
Index: branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 296)
@@ -879,4 +879,7 @@
   }
 #endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  WRITE_FLAG(vps->getSingleLayerForNonIrapFlag(), "single_layer_for_non_irap_flag" );
+#endif
 }
 #endif
@@ -1222,8 +1225,8 @@
     {
 #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING
-      if ( !pcSlice->getIdrPicFlag() && pcSlice->getLayerId() > 0 && pcSlice->getNumMotionPredRefLayers() > 0 )
-      {
-        WRITE_FLAG( 1, "alt_collocated_indication_flag" );
-        if (pcSlice->getNumMotionPredRefLayers() > 1)
+      if ( !pcSlice->getIdrPicFlag() && pcSlice->getLayerId() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 && pcSlice->getNumMotionPredRefLayers() > 0 )
+      {
+        WRITE_FLAG( pcSlice->getAltColIndicationFlag() ? 1 : 0, "alt_collocated_indication_flag" );
+        if (pcSlice->getAltColIndicationFlag() && pcSlice->getNumMotionPredRefLayers() > 1)
         {
           WRITE_UVLC(0, "collocated_ref_layer_idx");
Index: branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 296)
@@ -367,4 +367,7 @@
 #if REF_IDX_FRAMEWORK
   Int      m_elRapSliceBEnabled;
+#endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  Int      m_adaptiveResolutionChange;
 #endif
 
@@ -888,4 +891,8 @@
   Int       getElRapSliceTypeB()              {return m_elRapSliceBEnabled;}
 #endif
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  Void      setAdaptiveResolutionChange(Int x) { m_adaptiveResolutionChange = x;    }
+  Int       getAdaptiveResolutionChange()      { return m_adaptiveResolutionChange; }
+#endif
 };
 
Index: branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 296)
@@ -498,4 +498,12 @@
     }
 
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+    if (m_pcEncTop->getAdaptiveResolutionChange() > 0 && ((m_layerId == 1 && pocCurr < m_pcEncTop->getAdaptiveResolutionChange()) ||
+                                                          (m_layerId == 0 && pocCurr > m_pcEncTop->getAdaptiveResolutionChange())) )
+    {
+      continue;
+    }
+#endif
+
     if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     {
@@ -518,9 +526,17 @@
     m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
 #endif
+
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+    if (m_pcEncTop->getAdaptiveResolutionChange() > 0 && m_layerId == 1 && pocCurr > m_pcEncTop->getAdaptiveResolutionChange())
+    {
+      pcSlice->setActiveNumILRRefIdx(0);
+      pcSlice->setInterLayerPredEnabledFlag(false);
 #if M0457_COL_PICTURE_SIGNALING
-    pcSlice->setMFMEnabledFlag(m_pcEncTop->getMFMEnabledFlag());
-    pcSlice->setAltColIndicationFlag(m_pcEncTop->getNumMotionPredRefLayers() > 0 ? true : false);
-    pcSlice->setColRefLayerIdx(0);
-#endif
+      pcSlice->setMFMEnabledFlag(false);
+      pcSlice->setAltColIndicationFlag(false);
+#endif
+    }
+#endif
+
     pcSlice->setLastIDR(m_iLastIDR);
     pcSlice->setSliceIdx(0);
@@ -797,5 +813,5 @@
 #if REF_IDX_FRAMEWORK
 #if M0457_COL_PICTURE_SIGNALING
-    if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getAltColIndicationFlag() )
+    if ( pcSlice->getSliceType() == B_SLICE && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) )
 #else
     if( pcSlice->getSliceType() == B_SLICE )
@@ -846,5 +862,5 @@
 #if REF_IDX_MFM
 #if M0457_COL_PICTURE_SIGNALING
-      if( pcSlice->getMFMEnabledFlag() && !pcSlice->getAltColIndicationFlag() )
+      if( pcSlice->getMFMEnabledFlag() && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) )
 #else
       if( pcSlice->getSPS()->getMFMEnabledFlag() )
@@ -2260,4 +2276,8 @@
       pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut);
 
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+      pcPicYuvRecOut->setReconstructed(true);
+#endif
+
       pcPic->setReconMark   ( true );
       m_bFirst = false;
Index: branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 295)
+++ branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 296)
@@ -502,5 +502,9 @@
 #else
     rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( layerId ) );
-#endif 
+#endif
+#if M0457_COL_PICTURE_SIGNALING
+    rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[layerId]->getMFMEnabledFlag());
+    rpcSlice->setAltColIndicationFlag(rpcSlice->getMFMEnabledFlag());
+#endif
   }
 
