Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 952)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 953)
@@ -151,5 +151,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 );
@@ -176,5 +178,9 @@
 
     // Decoded layer YUV files
+#if FIX_CONF_MODE
+    for(Int layer= 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; 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.
@@ -187,7 +193,12 @@
   this->getCommonDecoderParams()->setTargetLayerId    ( m_tgtLayerId );
 #endif
+#if FIX_CONF_MODE
+  for(Int layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; 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-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 952)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 953)
@@ -82,5 +82,9 @@
   }
 #if SVC_EXTENSION
+#if FIX_CONF_MODE
+  for(Int i = 0; i <= MAX_VPS_LAYER_ID_PLUS1-1; i++ )
+#else
   for( Int i = 0; i <= m_tgtLayerId; i++ )
+#endif
   {
     if( m_pchReconFile[i] )
@@ -142,5 +146,9 @@
   memset( loopFiltered, false, sizeof( loopFiltered ) );
 
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+#else
   for(UInt layer=0; layer<=m_tgtLayerId; layer++)
+#endif
   {
     openedReconFile[layer] = false;
@@ -353,5 +361,9 @@
   pcBLPic.destroy();
 
+#if FIX_CONF_MODE
+  for(UInt layer = layerIdmin; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+#else
   for(UInt layer = layerIdmin; layer <= m_tgtLayerId; layer++)
+#endif
 #else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
@@ -522,6 +534,9 @@
   // initialize global variables
   initROM();
-
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+#else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+#endif
   {
     // set layer ID
@@ -544,6 +559,9 @@
   // destroy ROM
   destroyROM();
-
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+#else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+#endif
   {
     if ( m_pchReconFile[layer] )
@@ -570,5 +588,9 @@
   // initialize decoder class
 #if SVC_EXTENSION
+#if FIX_CONF_MODE
+  for(UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+#else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+#endif
   {
     m_acTDecTop[layer].init();
@@ -577,5 +599,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( this->getCommonDecoderParams() );
@@ -583,7 +609,11 @@
   }
 #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++)
-  {
-    m_acTDecTop[layer].setConfModeFlag( m_confModeFlag );
+#endif
+  {
+    m_acTDecTop[layer].setConfModeFlag ( this->getConfModeFlag() );
   }
 #endif
@@ -1386,49 +1416,7 @@
         fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), digestToString(recon_digest, 16));
         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_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
-          if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
-
-          char tempFileName[256];
-          strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerIdx ).c_str());
-          m_confReconFile[layerIdx].open(tempFileName, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // 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,
-              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
+      }
+#endif
+
 
       listOfPocsInEachLayer[layerIdx].erase( it );
@@ -1448,7 +1436,59 @@
   dpbStatus.m_numAUsNotDisplayed--;    
 
+#if CONFORMANCE_BITSTREAM_MODE
+  if( this->getConfModeFlag() )
+  {
+    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_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
+        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
+
+        char tempFileName[256];
+        strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerIdx ).c_str());
+        m_confReconFile[layerIdx].open(tempFileName, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // 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,
+            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
   listOfPocs.erase( listOfPocs.begin() );
 }
+
 
 TComVPS *TAppDecTop::findDpbParametersFromVps(std::vector<Int> const &listOfPocs, std::vector<Int> const *listOfPocsInEachLayer, std::vector<Int> const *listOfPocsPositionInEachLayer, DpbStatus &maxDpbLimit)
Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h	(revision 952)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h	(revision 953)
@@ -169,5 +169,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;
