Index: branches/SHM-upgrade/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/SHM-upgrade/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 961)
+++ branches/SHM-upgrade/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 962)
@@ -167,5 +167,7 @@
   m_tgtLayerId = nLayerNum - 1;
   assert( m_tgtLayerId >= 0 );
-  assert( m_tgtLayerId < MAX_LAYERS );
+#if !FIX_CONF_MODE
+  assert( m_tgtLayerId < MAX_LAYERS );  // If this is wrong, it should be caught by asserts in other locations.
+#endif
 #if O0137_MAX_LAYERID
   assert( m_tgtLayerId < MAX_NUM_LAYER_IDS );
@@ -192,5 +194,9 @@
 
     // Decoded layer YUV files
+#if FIX_CONF_MODE
+    for(Int layer= 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++ )
+#else
     for(UInt layer=0; layer<= m_tgtLayerId; layer++)
+#endif
     {
       sprintf(fileNameSuffix, "%s-L%d.yuv", m_confPrefix.c_str(), layer);  // olsIdx is the target output layer set index.
@@ -203,7 +209,12 @@
   this->getCommonDecoderParams()->setTargetLayerId    ( m_tgtLayerId );
 #endif
+#if FIX_CONF_MODE
+  for(Int layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++ )
+  {
+#else
   for(UInt layer=0; layer<= m_tgtLayerId; layer++)
   {
     assert( layer < MAX_LAYERS );
+#endif
     m_pchReconFile[layer] = cfg_ReconFile[layer].empty() ? NULL : strdup(cfg_ReconFile[layer].c_str());
   }
Index: branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.cpp	(revision 961)
+++ branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.cpp	(revision 962)
@@ -88,5 +88,9 @@
   }
 #if SVC_EXTENSION
+#if FIX_CONF_MODE
+  for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++ )
+#else
   for( Int i = 0; i <= m_tgtLayerId; i++ )
+#endif
   {
     if( m_pchReconFile[i] )
@@ -158,5 +162,9 @@
   memset( loopFiltered, false, sizeof( loopFiltered ) );
 
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
+#else
   for(UInt layer=0; layer<=m_tgtLayerId; layer++)
+#endif
   {
     openedReconFile[layer] = false;
@@ -397,5 +405,9 @@
   pcBLPic.destroy();
 
+#if FIX_CONF_MODE
+  for(UInt layer = layerIdmin; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
+#else
   for(UInt layer = layerIdmin; layer <= m_tgtLayerId; layer++)
+#endif
 #else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
@@ -582,5 +594,9 @@
   initROM();
 
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
+#else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+#endif
   {
     // set layer ID
@@ -604,5 +620,9 @@
   destroyROM();
 
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
+#else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+#endif
   {
     if ( m_pchReconFile[layer] )
@@ -629,5 +649,9 @@
   // initialize decoder class
 #if SVC_EXTENSION
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
+#else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+#endif
   {
     m_acTDecTop[layer].init();
@@ -636,5 +660,9 @@
     m_acTDecTop[layer].setColourRemappingInfoSEIEnabled(m_colourRemapSEIEnabled);
 #endif
+#if FIX_CONF_MODE
+    m_acTDecTop[layer].setNumLayer( MAX_LAYERS );
+#else
     m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
+#endif
 #if OUTPUT_LAYER_SET_INDEX
     m_acTDecTop[layer].setCommonDecoderParams( &m_commonDecoderParams );
@@ -642,5 +670,9 @@
   }
 #if CONFORMANCE_BITSTREAM_MODE
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
+#else
   for(UInt layer = 0; layer < MAX_LAYERS; layer++)
+#endif
   {
     m_acTDecTop[layer].setConfModeFlag( m_confModeFlag );
@@ -1483,48 +1515,5 @@
         fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), digestToString(recon_digest, numChar).c_str());
         fclose(fptr);
-
-        // Output all picutres "decoded" in that layer that have POC less than the current picture
-        std::vector<TComPic> *layerBuffer = (m_acTDecTop->getLayerDec(pic->getLayerId()))->getConfListPic();
-        // Write all pictures to the file.
-        if( this->getDecodedYuvLayerRefresh(layerIdx) )
-        {
-          if (!m_outputBitDepth[CHANNEL_TYPE_LUMA]) { m_outputBitDepth[CHANNEL_TYPE_LUMA] = g_bitDepth[CHANNEL_TYPE_LUMA]; }
-          if (!m_outputBitDepth[CHANNEL_TYPE_CHROMA]) { m_outputBitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepth[CHANNEL_TYPE_CHROMA]; }
-
-          char tempFileName[256];
-          strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerIdx ).c_str());
-          m_confReconFile[layerIdx].open(tempFileName, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
-          this->setDecodedYuvLayerRefresh( layerIdx, false );
-        }
-        const Window &conf = pic->getConformanceWindow();
-        const Window &defDisp = m_respectDefDispWindow ? pic->getDefDisplayWindow() : Window();
-        Int xScal =  1, yScal = 1;
-#if REPN_FORMAT_IN_VPS
-        UInt chromaFormatIdc = pic->getSlice(0)->getChromaFormatIdc();
-        xScal = TComSPS::getWinUnitX( chromaFormatIdc );
-        yScal = TComSPS::getWinUnitY( chromaFormatIdc );
-#endif
-        std::vector<TComPic>::iterator itPic;
-        for(itPic = layerBuffer->begin(); itPic != layerBuffer->end(); itPic++)
-        {
-          TComPic checkPic = *itPic;
-          if( checkPic.getPOC() <= pic->getPOC() )
-          {
-            TComPicYuv* pPicCYuvRec = checkPic.getPicYuvRec();
-            m_confReconFile[layerIdx].write( pPicCYuvRec, m_outputColourSpaceConvert,
-              conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
-              conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
-              conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
-              conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
-            layerBuffer->erase(itPic);
-            itPic = layerBuffer->begin();  // Ensure doesn't go to infinite loop
-            if(layerBuffer->size() == 0)
-            {
-              break;
-            }
-          }
-        }
-      }
-      // Now to remove the pictures that have been output
+      }
 #endif
 
@@ -1543,5 +1532,57 @@
   }
 #endif
-  dpbStatus.m_numAUsNotDisplayed--;    
+  dpbStatus.m_numAUsNotDisplayed--;
+
+#if CONFORMANCE_BITSTREAM_MODE
+  if( m_confModeFlag )
+  {
+    for( Int dpbLayerCtr = 0; dpbLayerCtr < dpbStatus.m_numLayers; dpbLayerCtr++)
+    {
+      Int layerIdx  = dpbStatus.m_targetDecLayerIdList[dpbLayerCtr];
+      // Output all picutres "decoded" in that layer that have POC less than the current picture
+      std::vector<TComPic> *layerBuffer = (m_acTDecTop->getLayerDec(layerIdx))->getConfListPic();
+      // Write all pictures to the file.
+      if( this->getDecodedYuvLayerRefresh(layerIdx) )
+      {
+        if (!m_outputBitDepth[CHANNEL_TYPE_LUMA]) { m_outputBitDepth[CHANNEL_TYPE_LUMA] = g_bitDepth[CHANNEL_TYPE_LUMA]; }
+        if (!m_outputBitDepth[CHANNEL_TYPE_CHROMA]) { m_outputBitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepth[CHANNEL_TYPE_CHROMA]; }
+
+        char tempFileName[256];
+        strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerIdx ).c_str());
+        m_confReconFile[layerIdx].open(tempFileName, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
+        this->setDecodedYuvLayerRefresh( layerIdx, false );
+      }
+
+      std::vector<TComPic>::iterator itPic;
+      for(itPic = layerBuffer->begin(); itPic != layerBuffer->end(); itPic++)
+      {
+        TComPic checkPic = *itPic;
+        const Window &conf = checkPic.getConformanceWindow();
+        const Window &defDisp = m_respectDefDispWindow ? checkPic.getDefDisplayWindow() : Window();
+        Int xScal = 1, yScal = 1;
+  #if REPN_FORMAT_IN_VPS
+        UInt chromaFormatIdc = checkPic.getSlice(0)->getChromaFormatIdc();
+        xScal = TComSPS::getWinUnitX( chromaFormatIdc );
+        yScal = TComSPS::getWinUnitY( chromaFormatIdc );
+  #endif
+        if( checkPic.getPOC() <= pocValue )
+        {
+          TComPicYuv* pPicCYuvRec = checkPic.getPicYuvRec();
+          m_confReconFile[layerIdx].write( pPicCYuvRec, m_outputColourSpaceConvert,
+            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
+            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
+            conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
+            conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
+          layerBuffer->erase(itPic);
+          itPic = layerBuffer->begin();  // Ensure doesn't go to infinite loop
+          if(layerBuffer->size() == 0)
+          {
+            break;
+          }
+        }
+      }
+    }
+  }
+#endif
 
   // Remove the picture from the listOfPocs
Index: branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.h	(revision 961)
+++ branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.h	(revision 962)
@@ -171,5 +171,5 @@
 #if FIX_ALIGN_BUMPING
     ::memset( m_targetDecLayerIdList, 0, sizeof(m_targetDecLayerIdList) );
-    for(Int i = 0; i < MAX_LAYERS; i++)
+    for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++)
     {
       m_layerIdToSubDpbIdMap[i] = -1;
Index: branches/SHM-upgrade/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibCommon/TypeDef.h	(revision 961)
+++ branches/SHM-upgrade/source/Lib/TLibCommon/TypeDef.h	(revision 962)
@@ -48,4 +48,5 @@
 #define CONFORMANCE_BITSTREAM_MODE       1      ///< In order to generate the metadata related to conformance bitstreams
 #define FIX_CONF_MODE                    1
+#define FIX_NON_OUTPUT_LAYER             1
 #define SIGNALLING_BITRATE_PICRATE_FIX   1      ///< Fix for signalling of bitrate and picture rate info in VPS VUI to be more aligned to JCTVC-R1008
 #define INFERENCE_POC_MSB_VAL_PRESENT    1      ///< JCTVC-Q0146 -- poc_msb_val_present_flag shall be equal to 0 when slice_header_extension_length is (inferred to be ) equal to 0
Index: branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp	(revision 961)
+++ branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp	(revision 962)
@@ -132,4 +132,7 @@
   m_confModeFlag = false;
 #endif
+#if FIX_NON_OUTPUT_LAYER
+  m_isOutputLayerFlag = false;
+#endif
 }
 
@@ -473,4 +476,11 @@
 
   m_cGopDecoder.filterPicture(pcPic);
+
+#if FIX_NON_OUTPUT_LAYER
+  if( this->getLayerDec(pcPic->getLayerId())->m_isOutputLayerFlag == false )
+  {
+    pcPic->setOutputMark( false );
+  }
+#endif
 
   TComSlice::sortPicList( m_cListPic ); // sorting for application output
@@ -2903,5 +2913,7 @@
   CommonDecoderParams* params = this->getCommonDecoderParams();
 
+#if !FIX_CONF_MODE
   assert( params->getTargetLayerId() < vps->getMaxLayers() );
+#endif
 
   if( params->getValueCheckedFlag() )
@@ -3006,4 +3018,14 @@
   Int targetLsIdx = vps->getOutputLayerSetIdx( targetOlsIdx );
   params->setTargetLayerId( vps->getLayerSetLayerIdList( targetLsIdx, vps->getNumLayersInIdList(targetLsIdx)-1 ) );
+#endif
+#if FIX_NON_OUTPUT_LAYER
+  // Check if the current layer is an output layer
+  for(Int i = 0; i < vps->getNumLayersInIdList( targetLsIdx ); i++)
+  {
+    if( vps->getOutputLayerFlag( targetOlsIdx, i ) )
+    {
+      this->getLayerDec( vps->getLayerSetLayerIdList( targetLsIdx, i ) )->m_isOutputLayerFlag = true;
+    }
+  }
 #endif
 }
Index: branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.h	(revision 961)
+++ branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.h	(revision 962)
@@ -174,4 +174,7 @@
   std::vector<TComPic>   m_confListPic;         //  Dynamic buffer for storing pictures for conformance purposes
 #endif
+#if FIX_NON_OUTPUT_LAYER
+  Bool m_isOutputLayerFlag;
+#endif
 public:
 #if POC_RESET_RESTRICTIONS
