Index: /branches/SHM-5.1-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 624)
+++ /branches/SHM-5.1-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 625)
@@ -256,4 +256,10 @@
 #if ALIGNED_BUMPING
       Bool outputPicturesFlag = true;  
+#if NO_OUTPUT_OF_PRIOR_PICS
+      if( m_acTDecTop[nalu.m_layerId].getNoOutputOfPriorPicsFlags() )
+      {
+        outputPicturesFlag = false;
+      }
+#endif
 
       if (nalu.m_nalUnitType == NAL_UNIT_EOS) // End of sequence
@@ -263,5 +269,9 @@
       if( bNewPicture ) // New picture, slice header parsed but picture not decoded
       {
+#if NO_OUTPUT_OF_PRIOR_PICS
+        if( 
+#else
         if ( bNewPOC &&
+#endif
            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
@@ -1041,5 +1051,4 @@
       conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
   }
-        
   // update POC of display order
   pocLastDisplay = pic->getPOC();
Index: /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 624)
+++ /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 625)
@@ -111,4 +111,9 @@
 , m_bCrossLayerBLAFlag            ( false )
 #endif
+#if NO_OUTPUT_OF_PRIOR_PICS
+, m_noOutputOfPriorPicsFlag       ( false )
+, m_noRaslOutputFlag              ( false )
+, m_handleCraAsBlaFlag            ( false )
+#endif
 #endif //SVC_EXTENSION
 {
@@ -194,4 +199,16 @@
       || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA;
 }
+#if NO_OUTPUT_OF_PRIOR_PICS
+Bool TComSlice::getBlaPicFlag       ()
+{
+    return  getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
+    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
+    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP;
+}
+Bool TComSlice::getCraPicFlag       ()
+{
+    return getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA;
+}
+#endif
 
 /**
Index: /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 624)
+++ /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 625)
@@ -1952,4 +1952,9 @@
   Bool        m_bCrossLayerBLAFlag;
 #endif
+#if NO_OUTPUT_OF_PRIOR_PICS
+  Bool        m_noOutputOfPriorPicsFlag;
+  Bool        m_noRaslOutputFlag;
+  Bool        m_handleCraAsBlaFlag;
+#endif
 #endif //SVC_EXTENSION
 
@@ -2038,4 +2043,8 @@
   NalUnitType getNalUnitType    () const                        { return m_eNalUnitType;        }
   Bool      getRapPicFlag       ();  
+#if NO_OUTPUT_OF_PRIOR_PICS
+  Bool      getBlaPicFlag       ();
+  Bool      getCraPicFlag       ();
+#endif
   Bool      getIdrPicFlag       ()                              { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
   Bool      isIRAP              () const                        { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23); }  
@@ -2259,4 +2268,15 @@
 
   Void setILRPic(TComPic **pcIlpPic);
+#if NO_OUTPUT_OF_PRIOR_PICS
+  Void setNoOutputOfPriorPicsFlag(const Bool x)   { m_noOutputOfPriorPicsFlag = x;    }
+  Bool getNoOutputOfPriorPicsFlag()               { return m_noOutputOfPriorPicsFlag; }
+
+  Void setNoRaslOutputFlag    ( const Bool val )   { m_noRaslOutputFlag = val;  }
+  Bool getNoRaslOutputFlag    ()                   { return m_noRaslOutputFlag; }
+
+  Void setHandleCraAsBlaFlag  ( const Bool val )   { m_handleCraAsBlaFlag = val;  }
+  Bool getHandleCraAsBlaFlag  ()                   { return m_handleCraAsBlaFlag; }
+
+#endif
 
 #endif //SVC_EXTENSION
Index: /branches/SHM-5.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 624)
+++ /branches/SHM-5.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 625)
@@ -88,4 +88,5 @@
 #define POC_RESET_FLAG                   1      ///< JCTVC-N0244: POC reset flag for  layer pictures.
 #define POC_RESET_IDC                    1      ///< JCTVC-P0041: Include poc_reset_idc and related derivation - eventually will replace POC_RESET_FLAG
+#define NO_OUTPUT_OF_PRIOR_PICS          1      ///< Use no_output_of_prior_pics_flag
 #define ALIGN_TSA_STSA_PICS              1      ///< JCTVC-N0084: Alignment of TSA and STSA pictures across AU.
 #define REPN_FORMAT_IN_VPS               1      ///< JCTVC-N0092: Signal represenation format (spatial resolution, bit depth, colour format) in the VPS
Index: /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 624)
+++ /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 625)
@@ -2049,5 +2049,9 @@
   if( rpcSlice->getRapPicFlag())
   {
+#if !NO_OUTPUT_OF_PRIOR_PICS
     READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored
+#else
+    READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  rpcSlice->setNoOutputOfPriorPicsFlag( uiCode ? true : false );
+#endif
   }
   READ_UVLC (    uiCode, "slice_pic_parameter_set_id" );  rpcSlice->setPPSId(uiCode);
Index: /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 624)
+++ /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 625)
@@ -803,6 +803,8 @@
   TComPic*&   pcPic         = m_pcPic;
 #if SVC_EXTENSION
+#if !NO_OUTPUT_OF_PRIOR_PICS
 #if NO_CLRAS_OUTPUT_FLAG
   Bool bFirstSliceInSeq;
+#endif
 #endif
   m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) );
@@ -858,4 +860,21 @@
   m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
 
+#if NO_OUTPUT_OF_PRIOR_PICS
+  // Infer the value of NoOutputOfPriorPicsFlag
+  if( m_apcSlicePilot->getRapPicFlag() )
+  {
+    if ( m_apcSlicePilot->getBlaPicFlag() || m_apcSlicePilot->getIdrPicFlag()  || 
+        (m_apcSlicePilot->getCraPicFlag() && m_bFirstSliceInSequence) ||
+        (m_apcSlicePilot->getCraPicFlag() && m_apcSlicePilot->getHandleCraAsBlaFlag()))
+    {
+      m_apcSlicePilot->setNoRaslOutputFlag( true );
+    }
+    else
+    {
+      m_apcSlicePilot->setNoRaslOutputFlag( false );
+    }
+  }
+#endif
+
   // Skip pictures due to random access
   if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
@@ -879,4 +898,57 @@
 #if SVC_EXTENSION
   bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC);
+
+#if NO_OUTPUT_OF_PRIOR_PICS
+#if NO_CLRAS_OUTPUT_FLAG
+  if (m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() )
+  {
+    if (m_bFirstSliceInSequence)
+    {
+      setNoClrasOutputFlag(true);
+    }
+    else if ( m_apcSlicePilot->getBlaPicFlag() )
+    {
+      setNoClrasOutputFlag(true);
+    }
+#if O0149_CROSS_LAYER_BLA_FLAG
+    else if (m_apcSlicePilot->getIdrPicFlag() && m_apcSlicePilot->getCrossLayerBLAFlag())
+    {
+      setNoClrasOutputFlag(true);
+    }
+#endif
+    else
+    {
+      setNoClrasOutputFlag(false);
+    }      
+  }
+  else
+  {
+    setNoClrasOutputFlag(false);
+  }
+
+  m_apcSlicePilot->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_cListPic, getNoClrasOutputFlag());
+#endif
+
+  // Derive the value of NoOutputOfPriorPicsFlag
+  if( bNewPOC || m_layerId!=m_uiPrevLayerId )   // i.e. new coded picture
+  {
+    if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getNoRaslOutputFlag() )
+    {
+      this->setNoOutputOfPriorPicsFlags( true );
+    }
+    else if( m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag() )
+    {
+      this->setNoOutputOfPriorPicsFlags( m_apcSlicePilot->getNoOutputOfPriorPicsFlag() );
+    }
+    else
+    {
+      if( this->m_ppcTDecTop[0]->getNoClrasOutputFlag() )
+      {
+        this->setNoOutputOfPriorPicsFlags( true );
+      }
+    }
+  }
+#endif
+
 #if ALIGNED_BUMPING
   if (bNewPOC || m_layerId!=m_uiPrevLayerId)
@@ -938,6 +1010,8 @@
 #endif
   }
+#if !NO_OUTPUT_OF_PRIOR_PICS
 #if NO_CLRAS_OUTPUT_FLAG
   bFirstSliceInSeq = m_bFirstSliceInSequence;
+#endif
 #endif
   m_bFirstSliceInSequence = false;
@@ -1102,4 +1176,5 @@
 #endif
 
+#if !NO_OUTPUT_OF_PRIOR_PICS
 #if NO_CLRAS_OUTPUT_FLAG
     if (m_layerId == 0 &&
@@ -1146,5 +1221,14 @@
     m_apcSlicePilot->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_cListPic, getNoClrasOutputFlag());
 #endif
-
+#else
+    if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() )
+    {
+      for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++)
+      {
+        m_ppcTDecTop[i]->setLayerInitializedFlag(false);
+        m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false);
+      }
+    }
+#endif
     // Buffer initialize for prediction.
     m_cPrediction.initTempBuff();
Index: /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 624)
+++ /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 625)
@@ -239,5 +239,10 @@
   fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
 #endif
-
+#if NO_OUTPUT_OF_PRIOR_PICS
+#if NO_CLRAS_OUTPUT_FLAG
+  Bool getNoOutputOfPriorPicsFlags()         { return m_noOutputOfPriorPicsFlags;}
+  Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
+#endif
+#endif
 protected:
   Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
@@ -266,7 +271,9 @@
   Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
   Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
+#if !NO_OUTPUT_OF_PRIOR_PICS
   Int  getNoOutputOfPriorPicsFlags()         { return m_noOutputOfPriorPicsFlags;}
   Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
 #endif
+#endif
 };// END CLASS DEFINITION TDecTop
 
Index: /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 624)
+++ /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 625)
@@ -1567,5 +1567,9 @@
   if ( pcSlice->getRapPicFlag() )
   {
+#if NO_OUTPUT_OF_PRIOR_PICS
+    WRITE_FLAG( pcSlice->getNoOutputOfPriorPicsFlag(), "no_output_of_prior_pics_flag" );
+#else
     WRITE_FLAG( 0, "no_output_of_prior_pics_flag" );
+#endif
   }
   WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" );
