Index: branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 426)
+++ branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 427)
@@ -1069,5 +1069,18 @@
 #endif 
 #if N0147_IRAP_ALIGN_FLAG    
-    vps->setCrossLayerIrapAlignFlag(maxDirectRefLayers == 0 ? false : true); 
+    vps->setCrossLayerIrapAlignFlag(true); 
+    for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
+    {
+      for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
+      {
+        if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
+        {          
+          if(m_acTEncTop[layerCtr].getIntraPeriod() !=  m_acTEncTop[refLayerCtr].getIntraPeriod())
+          {
+            vps->setCrossLayerIrapAlignFlag(false); 
+          }
+        }
+      }
+    }   
 #endif 
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
Index: branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 426)
+++ branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 427)
@@ -1083,5 +1083,5 @@
   }
 
-  for( Int i = 0; i < vps->getNumViews(); i++ )
+  for(  i = 0; i < vps->getNumViews(); i++ )
   {
     READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode );
@@ -1553,16 +1553,16 @@
   {
 #if POC_RESET_FLAG
-    Int i = 0; 
-    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > i)
+    Int iBits = 0; 
+    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits)
     {
       READ_FLAG(uiCode, "poc_reset_flag");      rpcSlice->setPocResetFlag( uiCode ? true : false );
-      i++;
-    }
-    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > i)
+      iBits++;
+    }
+    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits)
     {
       READ_FLAG(uiCode, "discardable_flag"); // ignored
-      i++;
-    }
-    for (; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
+      iBits++;
+    }
+    for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++)
     {
       READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored
Index: branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 426)
+++ branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 427)
@@ -880,5 +880,5 @@
   }
 
-  for( Int i = 0; i < vps->getNumViews(); i++ )
+  for(  i = 0; i < vps->getNumViews(); i++ )
   {
     WRITE_CODE( vps->getViewIdVal( i ), vps->getViewIdLenMinus1( ) + 1, "view_id_val[i]" );
@@ -1220,17 +1220,17 @@
 
 #if POC_RESET_FLAG
-    Int i = 0;
-    if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > i )
+    Int iBits = 0;
+    if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits )
     {
       WRITE_FLAG( pcSlice->getPocResetFlag(), "poc_reset_flag" );
-      i++;
-    }
-    if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > i )
+      iBits++;
+    }
+    if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits )
     {
       assert(!!"discardable_flag");
       WRITE_FLAG(pcSlice->getDiscardableFlag(), "discardable_flag");
-      i++;
-    }
-    for ( ; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
+      iBits++;
+    }
+    for ( ; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++)
     {
       assert(!!"slice_reserved_undetermined_flag[]");
Index: branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 426)
+++ branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 427)
@@ -777,5 +777,5 @@
           TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic();
           TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() );
-          if( picLayer0->getSlice(0)->isIRAP() && picLayer0)
+          if(picLayer0)
           {
             pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType());
