Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1005)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1029)
@@ -41,4 +41,5 @@
 #include "TAppDecCfg.h"
 #include "TAppCommon/program_options_lite.h"
+#include "TLibCommon/TComChromaFormat.h"
 #if SVC_EXTENSION
 #include <cassert>
@@ -83,9 +84,12 @@
 
   string cfg_TargetDecLayerIdSetFile;
+  string outputColourSpaceConvert;
 
   po::Options opts;
   opts.addOptions()
-  ("help", do_help, false, "this help text")
-  ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream input file name")
+
+
+  ("help",                      do_help,                               false,      "this help text")
+  ("BitstreamFile,b",           cfg_BitstreamFile,                     string(""), "bitstream input file name")
 #if SVC_EXTENSION
   ("ReconFileL%d,-o%d",   cfg_ReconFile,   string(""), MAX_LAYERS, "Layer %d reconstructed YUV output file name\n"
@@ -98,12 +102,4 @@
 #endif
 #endif
-#else
-  ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
-                                                     "YUV writing is skipped if omitted")
-#endif
-  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
-  ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)")
-  ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)")
-#if SVC_EXTENSION
 #if FIX_CONF_MODE
   ("LayerNum,-ls", nLayerNum, MAX_NUM_LAYER_IDS, "Number of layers to be decoded.")
@@ -118,12 +114,24 @@
   ("ConformanceMetadataPrefix,-confPrefix", cfg_confPrefix, string(""), "Prefix for the file name of the conformance data. Default name - 'decodedBitstream'")
 #endif
-#endif 
-  ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
-  ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n"
-                                              "\t1: check hash in SEI messages if available in the bitstream\n"
-                                              "\t0: ignore SEI message")
-  ("SEIpictureDigest", m_decodedPictureHashSEIEnabled, 1, "deprecated alias for SEIDecodedPictureHash")
-  ("TarDecLayerIdSetFile,l", cfg_TargetDecLayerIdSetFile, string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
-  ("RespectDefDispWindow,w", m_respectDefDispWindow, 0, "Only output content inside the default display window\n")
+#else
+  ("ReconFile,o",               cfg_ReconFile,                         string(""), "reconstructed YUV output file name\n"
+                                                                                   "YUV writing is skipped if omitted")
+#endif
+
+  ("SkipFrames,s",              m_iSkipFrame,                          0,          "number of frames to skip before random access")
+  ("OutputBitDepth,d",          m_outputBitDepth[CHANNEL_TYPE_LUMA],   0,          "bit depth of YUV output luma component (default: use 0 for native depth)")
+  ("OutputBitDepthC,d",         m_outputBitDepth[CHANNEL_TYPE_CHROMA], 0,          "bit depth of YUV output chroma component (default: use 0 for native depth)")
+  ("OutputColourSpaceConvert",  outputColourSpaceConvert,              string(""), "Colour space conversion to apply to input 444 video. Permitted values are (empty string=UNCHANGED) " + getListOfColourSpaceConverts(false))
+  ("MaxTemporalLayer,t",        m_iMaxTemporalLayer,                   -1,         "Maximum Temporal Layer to be decoded. -1 to decode all layers")
+  ("SEIDecodedPictureHash",     m_decodedPictureHashSEIEnabled,        1,          "Control handling of decoded picture hash SEI messages\n"
+                                                                                   "\t1: check hash in SEI messages if available in the bitstream\n"
+                                                                                   "\t0: ignore SEI message")
+  ("SEIpictureDigest",          m_decodedPictureHashSEIEnabled,        1,          "deprecated alias for SEIDecodedPictureHash")
+  ("SEINoDisplay",              m_decodedNoDisplaySEIEnabled,          true,       "Control handling of decoded no display SEI messages")
+  ("TarDecLayerIdSetFile,l",    cfg_TargetDecLayerIdSetFile,           string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
+  ("RespectDefDispWindow,w",    m_respectDefDispWindow,                0,          "Only output content inside the default display window\n")
+#if O0043_BEST_EFFORT_DECODING
+  ("ForceDecodeBitDepth",       m_forceDecodeBitDepth,                 0U,         "Force the decoder to operate at a particular bit-depth (best effort decoding)")
+#endif
 #if Q0074_COLOUR_REMAPPING_SEI
   ("SEIColourRemappingInfo", m_colourRemapSEIEnabled, false, "Control handling of Colour Remapping Information SEI messages\n"
@@ -132,4 +140,5 @@
 #endif
   ;
+
   po::setDefaults(opts);
   const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
@@ -143,4 +152,11 @@
   {
     po::doHelp(cout, opts);
+    return false;
+  }
+
+  m_outputColourSpaceConvert = stringToInputColourSpaceConvert(outputColourSpaceConvert, false);
+  if (m_outputColourSpaceConvert>=NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS)
+  {
+    fprintf(stderr, "Bad output colour space conversion string\n");
     return false;
   }
@@ -157,5 +173,5 @@
   assert( m_tgtLayerId < MAX_NUM_LAYER_IDS );
 #endif
-#if OUTPUT_LAYER_SET_INDEX  
+#if OUTPUT_LAYER_SET_INDEX
 #if CONFORMANCE_BITSTREAM_MODE
   if( m_confModeFlag )
@@ -179,5 +195,5 @@
     // Decoded layer YUV files
 #if FIX_CONF_MODE
-    for(Int layer= 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++ )
+    for(Int layer= 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++ )
 #else
     for(UInt layer=0; layer<= m_tgtLayerId; layer++)
@@ -190,9 +206,9 @@
   }
 #endif
-  this->getCommonDecoderParams()->setTargetOutputLayerSetIdx( olsIdx       );
-  this->getCommonDecoderParams()->setTargetLayerId    ( m_tgtLayerId );
+  m_commonDecoderParams.setTargetOutputLayerSetIdx( olsIdx );
+  m_commonDecoderParams.setTargetLayerId( m_tgtLayerId );
 #endif
 #if FIX_CONF_MODE
-  for(Int layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++ )
+  for(Int layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++ )
   {
 #else
@@ -212,5 +228,5 @@
   if (!m_pchBitstreamFile)
   {
-    fprintf(stderr, "No input file specifed, aborting\n");
+    fprintf(stderr, "No input file specified, aborting\n");
     return false;
   }
@@ -240,5 +256,5 @@
         if ( layerIdParsed < 0 || layerIdParsed >= MAX_NUM_LAYER_IDS )
         {
-          fprintf(stderr, "Warning! Parsed LayerId %d is not withing allowed range [0,%d]. Ignoring this value.\n", layerIdParsed, MAX_NUM_LAYER_IDS-1 );
+          fprintf(stderr, "Warning! Parsed LayerId %d is not within allowed range [0,%d]. Ignoring this value.\n", layerIdParsed, MAX_NUM_LAYER_IDS-1 );
         }
         else
@@ -250,5 +266,5 @@
       fclose (targetDecLayerIdSetFile);
 #if !R0235_SMALLEST_LAYER_ID  // LayerId=0 is not required anymore in some cases
-      if (m_targetDecLayerIdSet.size() > 0 && !isLayerIdZeroIncluded)
+      if ( m_targetDecLayerIdSet.size() > 0 && !isLayerIdZeroIncluded )
       {
         fprintf(stderr, "TargetDecLayerIdSet must contain LayerId=0, aborting" );
Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 1005)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 1029)
@@ -57,16 +57,17 @@
 {
 protected:
-  Char*         m_pchBitstreamFile;                   ///< input bitstream file name
+  Char*         m_pchBitstreamFile;                     ///< input bitstream file name
 #if SVC_EXTENSION
   Char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
 #else
-  Char*         m_pchReconFile;                       ///< output reconstruction file name
+  Char*         m_pchReconFile;                         ///< output reconstruction file name
 #endif
-  Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
-  Int           m_outputBitDepthY;                     ///< bit depth used for writing output (luma)
-  Int           m_outputBitDepthC;                     ///< bit depth used for writing output (chroma)t
+  Int           m_iSkipFrame;                           ///< counter for frames prior to the random access point to skip
+  Int           m_outputBitDepth[MAX_NUM_CHANNEL_TYPE]; ///< bit depth used for writing output
+  InputColourSpaceConversion m_outputColourSpaceConvert;
 
   Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
   Int           m_decodedPictureHashSEIEnabled;       ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
+  Bool          m_decodedNoDisplaySEIEnabled;         ///< Enable(true)/disable(false) writing only pictures that get displayed based on the no display SEI message
 #if Q0074_COLOUR_REMAPPING_SEI
   Bool          m_colourRemapSEIEnabled;              ///< Enable the Colour Remapping Information SEI message if available (remapping decoded pictures)
@@ -85,5 +86,9 @@
 
   std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
-  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window 
+  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
+#if O0043_BEST_EFFORT_DECODING
+  UInt          m_forceDecodeBitDepth;                ///< if non-zero, force the bit depth at the decoder (best effort decoding)
+#endif
+  std::string   m_outputDecodedSEIMessagesFilename;   ///< filename to output decoded SEI messages to. If '-', then use stdout. If empty, do not output details.
 #if OUTPUT_LAYER_SET_INDEX
   CommonDecoderParams             m_commonDecoderParams;
@@ -91,7 +96,7 @@
 #if CONFORMANCE_BITSTREAM_MODE
   Bool          m_confModeFlag;
-  std::string m_confPrefix;
-  std::string m_metadataFileName;
-  Bool m_metadataFileRefresh;
+  std::string   m_confPrefix;
+  std::string   m_metadataFileName;
+  Bool          m_metadataFileRefresh;
   std::string   m_decodedYuvLayerFileName[63];
   Bool          m_decodedYuvLayerRefresh[63];
@@ -102,11 +107,11 @@
   : m_pchBitstreamFile(NULL)
 #if !SVC_EXTENSION
-  , m_pchReconFile(NULL) 
+  , m_pchReconFile(NULL)
 #endif
   , m_iSkipFrame(0)
-  , m_outputBitDepthY(0)
-  , m_outputBitDepthC(0)
+  , m_outputColourSpaceConvert(IPCOLOURSPACE_UNCHANGED)
   , m_iMaxTemporalLayer(-1)
   , m_decodedPictureHashSEIEnabled(0)
+  , m_decodedNoDisplaySEIEnabled(false)
 #if Q0074_COLOUR_REMAPPING_SEI
   , m_colourRemapSEIEnabled(0)
@@ -120,7 +125,14 @@
 #endif
   , m_respectDefDispWindow(0)
-  {}
+#if O0043_BEST_EFFORT_DECODING
+  , m_forceDecodeBitDepth(0)
+#endif
+  {
+    for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
+      m_outputBitDepth[channelTypeIndex] = 0;
+  }
+
   virtual ~TAppDecCfg() {}
-  
+
   Bool  parseCfg        ( Int argc, Char* argv[] );   ///< initialize option class from configuration
 #if OUTPUT_LAYER_SET_INDEX
Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1005)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1029)
@@ -41,10 +41,16 @@
 #include <fcntl.h>
 #include <assert.h>
-#include <iostream>
+
 #include "TAppDecTop.h"
 #include "TLibDecoder/AnnexBread.h"
 #include "TLibDecoder/NALread.h"
+#if RExt__DECODER_DEBUG_BIT_STATISTICS
+#include "TLibCommon/TComCodingStatistics.h"
+#endif
+#if CONFORMANCE_BITSTREAM_MODE
 #include "TLibCommon/TComPicYuv.h"
 #include "libmd5/MD5.h"
+#endif
+
 //! \ingroup TAppDecoder
 //! \{
@@ -83,5 +89,5 @@
 #if SVC_EXTENSION
 #if FIX_CONF_MODE
-  for(Int i = 0; i <= MAX_VPS_LAYER_ID_PLUS1-1; i++ )
+  for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++ )
 #else
   for( Int i = 0; i <= m_tgtLayerId; i++ )
@@ -137,7 +143,17 @@
   InputByteStream bytestream(bitstreamFile);
 
+  if (!m_outputDecodedSEIMessagesFilename.empty() && m_outputDecodedSEIMessagesFilename!="-")
+  {
+    m_seiMessageFileStream.open(m_outputDecodedSEIMessagesFilename.c_str(), std::ios::out);
+    if (!m_seiMessageFileStream.is_open() || !m_seiMessageFileStream.good())
+    {
+      fprintf(stderr, "\nUnable to open file `%s' for writing decoded SEI messages\n", m_outputDecodedSEIMessagesFilename.c_str());
+      exit(EXIT_FAILURE);
+    }
+  }
+
   // create & initialize internal classes
   xCreateDecLib();
-  xInitDecLib  ();
+  xInitDecLib  ();  
 
   // main decoder loop
@@ -147,5 +163,5 @@
 
 #if FIX_CONF_MODE
-  for(UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
 #else
   for(UInt layer=0; layer<=m_tgtLayerId; layer++)
@@ -177,5 +193,10 @@
      * requires the TDecTop::decode() method to be called again with the same
      * nal unit. */
+#if RExt__DECODER_DEBUG_BIT_STATISTICS
+    TComCodingStatistics::TComCodingStatisticsData backupStats(TComCodingStatistics::GetStatistics());
+    streampos location = bitstreamFile.tellg() - streampos(bytestream.GetNumBufferedBytes());
+#else
     streampos location = bitstreamFile.tellg();
+#endif
     AnnexBStats stats = AnnexBStats();
 
@@ -183,7 +204,9 @@
     InputNALUnit nalu;
     byteStreamNALUnit(bytestream, nalUnit, stats);
+
     // call actual decoding function
     Bool bNewPicture = false;
     Bool bNewPOC = false;
+
     if (nalUnit.empty())
     {
@@ -221,6 +244,12 @@
            * [1] except for the first NAL unit in the file
            *     (but bNewPicture doesn't happen then) */
+#if RExt__DECODER_DEBUG_BIT_STATISTICS
+          bitstreamFile.seekg(location);
+          bytestream.reset();
+          TComCodingStatistics::SetStatistics(backupStats);
+#else
           bitstreamFile.seekg(location-streamoff(3));
           bytestream.reset();
+#endif
         }
 #if POC_RESET_IDC_DECODER
@@ -232,4 +261,7 @@
           bitstreamFile.seekg(location);
           bytestream.reset();
+#if RExt__DECODER_DEBUG_BIT_STATISTICS
+          TComCodingStatistics::SetStatistics(backupStats);
+#endif
         }
 #endif
@@ -238,13 +270,15 @@
 
 #if POC_RESET_IDC_DECODER
-    if ((bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() == 3) || (m_acTDecTop[nalu.m_layerId].getParseIdc() == 0) || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS)
-#else
-    if (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS)
+    if ( ( (bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() == 3) || m_acTDecTop[nalu.m_layerId].getParseIdc() == 0 || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) && 
+        !m_acTDecTop[nalu.m_layerId].getFirstSliceInSequence() )
+#else
+    if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) &&
+        !m_acTDecTop[nalu.m_layerId].getFirstSliceInSequence() )
 #endif
     {
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
       //Bug fix: The bit depth was not set correctly for each layer when doing DBF
-      g_bitDepthY = g_bitDepthYLayer[curLayerId];
-      g_bitDepthC = g_bitDepthCLayer[curLayerId];
+      g_bitDepth[CHANNEL_TYPE_LUMA]   = g_bitDepthLayer[CHANNEL_TYPE_LUMA][curLayerId];
+      g_bitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][curLayerId];
 #endif
       if (!loopFiltered[curLayerId] || bitstreamFile)
@@ -256,4 +290,13 @@
       m_acTDecTop[curLayerId].earlyPicMarking(m_iMaxTemporalLayer, m_targetDecLayerIdSet);
 #endif
+      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
+      {
+        m_acTDecTop[nalu.m_layerId].setFirstSliceInSequence(true);
+      }
+    }
+    else if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) &&
+              m_acTDecTop[nalu.m_layerId].getFirstSliceInSequence () ) 
+    {
+      m_acTDecTop[nalu.m_layerId].setFirstSliceInPicture (true);
     }
 
@@ -269,8 +312,9 @@
       if ( m_pchReconFile[curLayerId] && !openedReconFile[curLayerId] )
       {
-        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
-        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
-
-        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
+        for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
+        {
+          if (m_outputBitDepth[channelType] == 0) m_outputBitDepth[channelType] = g_bitDepth[channelType];
+        }
+        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
 
         openedReconFile[curLayerId] = true;
@@ -362,5 +406,5 @@
 
 #if FIX_CONF_MODE
-  for(UInt layer = layerIdmin; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+  for(UInt layer = layerIdmin; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
 #else
   for(UInt layer = layerIdmin; layer <= m_tgtLayerId; layer++)
@@ -390,4 +434,14 @@
 
   InputByteStream bytestream(bitstreamFile);
+
+  if (!m_outputDecodedSEIMessagesFilename.empty() && m_outputDecodedSEIMessagesFilename!="-")
+  {
+    m_seiMessageFileStream.open(m_outputDecodedSEIMessagesFilename.c_str(), std::ios::out);
+    if (!m_seiMessageFileStream.is_open() || !m_seiMessageFileStream.good())
+    {
+      fprintf(stderr, "\nUnable to open file `%s' for writing decoded SEI messages\n", m_outputDecodedSEIMessagesFilename.c_str());
+      exit(EXIT_FAILURE);
+    }
+  }
 
   // create & initialize internal classes
@@ -406,5 +460,10 @@
      * requires the TDecTop::decode() method to be called again with the same
      * nal unit. */
+#if RExt__DECODER_DEBUG_BIT_STATISTICS
+    TComCodingStatistics::TComCodingStatisticsData backupStats(TComCodingStatistics::GetStatistics());
+    streampos location = bitstreamFile.tellg() - streampos(bytestream.GetNumBufferedBytes());
+#else
     streampos location = bitstreamFile.tellg();
+#endif
     AnnexBStats stats = AnnexBStats();
 
@@ -429,6 +488,6 @@
       if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
       {
-          bNewPicture = false;
-        }
+        bNewPicture = false;
+      }
       else
       {
@@ -441,10 +500,18 @@
            * [1] except for the first NAL unit in the file
            *     (but bNewPicture doesn't happen then) */
+#if RExt__DECODER_DEBUG_BIT_STATISTICS
+          bitstreamFile.seekg(location);
+          bytestream.reset();
+          TComCodingStatistics::SetStatistics(backupStats);
+#else
           bitstreamFile.seekg(location-streamoff(3));
           bytestream.reset();
-        }
-      }
-    }
-    if (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS)
+#endif
+        }
+      }
+    }
+
+    if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) &&
+        !m_cTDecTop.getFirstSliceInSequence () )
     {
       if (!loopFiltered || bitstreamFile)
@@ -453,13 +520,14 @@
       }
       loopFiltered = (nalu.m_nalUnitType == NAL_UNIT_EOS);
-    }
-#if !FIX_WRITING_OUTPUT
-#if SETTING_NO_OUT_PIC_PRIOR
-    if (bNewPicture && m_cTDecTop.getNoOutputPriorPicsFlag())
-    {
-      m_cTDecTop.checkNoOutputPriorPics( pcListPic );
-    }
-#endif
-#endif
+      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
+      {
+        m_cTDecTop.setFirstSliceInSequence(true);
+      }
+    }
+    else if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) &&
+              m_cTDecTop.getFirstSliceInSequence () ) 
+    {
+      m_cTDecTop.setFirstSliceInPicture (true);
+    }
 
     if( pcListPic )
@@ -467,11 +535,12 @@
       if ( m_pchReconFile && !openedReconFile )
       {
-        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
-        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
-
-        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
+        for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
+        {
+          if (m_outputBitDepth[channelType] == 0) m_outputBitDepth[channelType] = g_bitDepth[channelType];
+        }
+
+        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
         openedReconFile = true;
       }
-#if FIX_WRITING_OUTPUT
       // write reconstruction to file
       if( bNewPicture )
@@ -479,5 +548,4 @@
         xWriteOutput( pcListPic, nalu.m_temporalId );
       }
-#if SETTING_NO_OUT_PIC_PRIOR
       if ( (bNewPicture || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA) && m_cTDecTop.getNoOutputPriorPicsFlag() )
       {
@@ -485,6 +553,4 @@
         m_cTDecTop.setNoOutputPriorPicsFlag (false);
       }
-#endif
-#endif
       if ( bNewPicture &&
            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
@@ -498,16 +564,9 @@
       if (nalu.m_nalUnitType == NAL_UNIT_EOS)
       {
-#if FIX_OUTPUT_EOS
         xWriteOutput( pcListPic, nalu.m_temporalId );
-#else
-        xFlushOutput( pcListPic );        
-#endif
+        m_cTDecTop.setFirstSliceInPicture (false);
       }
       // write reconstruction to file -- for additional bumping as defined in C.5.2.3
-#if FIX_WRITING_OUTPUT
       if(!bNewPicture && nalu.m_nalUnitType >= NAL_UNIT_CODED_SLICE_TRAIL_N && nalu.m_nalUnitType <= NAL_UNIT_RESERVED_VCL31)
-#else
-      if(bNewPicture)
-#endif
       {
         xWriteOutput( pcListPic, nalu.m_temporalId );
@@ -534,6 +593,7 @@
   // initialize global variables
   initROM();
+
 #if FIX_CONF_MODE
-  for(UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
 #else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
@@ -559,6 +619,7 @@
   // destroy ROM
   destroyROM();
+
 #if FIX_CONF_MODE
-  for(UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
 #else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
@@ -589,5 +650,5 @@
 #if SVC_EXTENSION
 #if FIX_CONF_MODE
-  for(UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1-1; layer++)
+  for(UInt layer = 0; layer < MAX_VPS_LAYER_ID_PLUS1; layer++)
 #else
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
@@ -605,5 +666,5 @@
 #endif
 #if OUTPUT_LAYER_SET_INDEX
-    m_acTDecTop[layer].setCommonDecoderParams( this->getCommonDecoderParams() );
+    m_acTDecTop[layer].setCommonDecoderParams( &m_commonDecoderParams );
 #endif
   }
@@ -615,5 +676,5 @@
 #endif
   {
-    m_acTDecTop[layer].setConfModeFlag ( this->getConfModeFlag() );
+    m_acTDecTop[layer].setConfModeFlag( m_confModeFlag );
   }
 #endif
@@ -621,4 +682,12 @@
   m_cTDecTop.init();
   m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
+#if O0043_BEST_EFFORT_DECODING
+  m_cTDecTop.setForceDecodeBitDepth(m_forceDecodeBitDepth);
+#endif
+  if (!m_outputDecodedSEIMessagesFilename.empty())
+  {
+    std::ostream &os=m_seiMessageFileStream.is_open() ? m_seiMessageFileStream : std::cout;
+    m_cTDecTop.setDecodedSEIMessageOutputStream(&os);
+  }
 #if Q0074_COLOUR_REMAPPING_SEI
   m_cTDecTop.setColourRemappingInfoSEIEnabled(m_colourRemapSEIEnabled);
@@ -673,5 +742,5 @@
 #endif
     {
-      numPicsNotYetDisplayed++;
+       numPicsNotYetDisplayed++;
       dpbFullness++;
     }
@@ -682,5 +751,7 @@
     iterPic++;
   }
-  iterPic   = pcListPic->begin();
+
+  iterPic = pcListPic->begin();
+
   if (numPicsNotYetDisplayed>2)
   {
@@ -720,22 +791,37 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
           const Bool isTff = pcPicTop->isTopField();
-          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
-          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
+
+          Bool display = true;
+          if( m_decodedNoDisplaySEIEnabled )
+          {
+            SEIMessages noDisplay = getSeisByType(pcPic->getSEIs(), SEI::NO_DISPLAY );
+            const SEINoDisplay *nd = ( noDisplay.size() > 0 ) ? (SEINoDisplay*) *(noDisplay.begin()) : NULL;
+            if( (nd != NULL) && nd->m_noDisplay )
+            {
+              display = false;
+            }
+          }
+
+          if (display)
+          {            
 #if REPN_FORMAT_IN_VPS
-          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
-          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
-
-          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
-            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
-            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
-            conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
-            conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset(), isTff );
-#else
-          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
-            conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
-            conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
-            conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
-            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
-#endif
+            UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
+            Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
+
+            m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+              m_outputColourSpaceConvert,
+              conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
+              conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
+              conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
+              conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
+#else
+            m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+              m_outputColourSpaceConvert,
+              conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
+              conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
+              conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
+              conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
+#endif
+          }
         }
 
@@ -748,11 +834,25 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
           const Bool isTff = pcPicTop->isTopField();
-          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
-          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
-          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
-            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
-            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
-            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
-            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
+
+          Bool display = true;
+          if( m_decodedNoDisplaySEIEnabled )
+          {
+            SEIMessages noDisplay = getSeisByType(pcPic->getSEIs(), SEI::NO_DISPLAY );
+            const SEINoDisplay *nd = ( noDisplay.size() > 0 ) ? (SEINoDisplay*) *(noDisplay.begin()) : NULL;
+            if( (nd != NULL) && nd->m_noDisplay )
+            {
+              display = false;
+            }
+          }
+
+          if (display)
+          {
+            m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+                                           m_outputColourSpaceConvert,
+                                           conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                           conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                           conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                           conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
+          }
         }
 
@@ -800,4 +900,5 @@
   {
     iterPic = pcListPic->begin();
+
     while (iterPic != pcListPic->end())
     {
@@ -813,5 +914,5 @@
       {
         // write to file
-        numPicsNotYetDisplayed--;
+         numPicsNotYetDisplayed--;
         if(pcPic->getSlice(0)->isReferenced() == false)
         {
@@ -822,11 +923,10 @@
         {
           const Window &conf = pcPic->getConformanceWindow();
-          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
-          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
+          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();          
 #if REPN_FORMAT_IN_VPS
           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
           Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
 
-          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
+          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), m_outputColourSpaceConvert,
             conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
@@ -834,5 +934,5 @@
             conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
 #else
-          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
+          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), m_outputColourSpaceConvert,
             conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
@@ -847,11 +947,13 @@
         if ( m_pchReconFile )
         {
-          const Window &conf = pcPic->getConformanceWindow();
+          const Window &conf    = pcPic->getConformanceWindow();
           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
+
           m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
-                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
-                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
-                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
-                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
+                                         m_outputColourSpaceConvert,
+                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
         }
 
@@ -921,22 +1023,20 @@
           const Window &conf = pcPicTop->getConformanceWindow();
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
-          const Bool isTff = pcPicTop->isTopField();
-          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
-          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
+          const Bool isTff = pcPicTop->isTopField();          
 #if REPN_FORMAT_IN_VPS
           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
           Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
 
-          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
+          m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), m_outputColourSpaceConvert,
             conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
             conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
-            conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset(), isTff );
-#else
-          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
+            conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
+#else
+          m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), m_outputColourSpaceConvert,
             conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
             conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
-            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
+            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
 #endif
         }
@@ -950,11 +1050,10 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
           const Bool isTff = pcPicTop->isTopField();
-          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
-          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
-          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
-            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
-            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
-            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
-            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
+          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+                                         m_outputColourSpaceConvert,
+                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
         }
 
@@ -1027,11 +1126,10 @@
         {
           const Window &conf = pcPic->getConformanceWindow();
-          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
-          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
+          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();          
 #if REPN_FORMAT_IN_VPS
           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
           Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
 
-          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
+          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), m_outputColourSpaceConvert,
             conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
@@ -1039,5 +1137,5 @@
             conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() );
 #else
-          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
+          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), m_outputColourSpaceConvert,
             conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
@@ -1052,12 +1150,13 @@
         if ( m_pchReconFile )
         {
-          const Window &conf = pcPic->getConformanceWindow();
+          const Window &conf    = pcPic->getConformanceWindow();
           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
-          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
-          m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
-            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
-            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
-            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
-            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
+
+          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
+                                         m_outputColourSpaceConvert,
+                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
         }
 
@@ -1143,5 +1242,5 @@
 #endif
     TComPicYuv* pPicCYuvRec = pic->getPicYuvRec();
-    m_acTVideoIOYuvReconFile[layerIdx].write( pPicCYuvRec,
+    m_acTVideoIOYuvReconFile[layerIdx].write( pPicCYuvRec, m_outputColourSpaceConvert,
       conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
       conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
@@ -1149,5 +1248,4 @@
       conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
   }
-
   // update POC of display order
   pocLastDisplay = pic->getPOC();
@@ -1405,7 +1503,7 @@
 #if CONFORMANCE_BITSTREAM_MODE
       FILE *fptr;
-      if( this->getConfModeFlag() )
-      {
-        if( this->getMetadataFileRefresh() )
+      if( m_confModeFlag )
+      {
+        if( m_metadataFileRefresh )
         {
           fptr = fopen( this->getMetadataFileName().c_str(), "w" );
@@ -1418,11 +1516,11 @@
         }
         this->setMetadataFileRefresh(false);
-        UChar recon_digest[3][16];
-        calcMD5(*pic->getPicYuvRec(), recon_digest);
-        fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), digestToString(recon_digest, 16));
+
+        TComDigest recon_digest;
+        Int numChar = calcMD5(*pic->getPicYuvRec(), recon_digest);
+        fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), digestToString(recon_digest, numChar).c_str());
         fclose(fptr);
       }
 #endif
-
 
       listOfPocsInEachLayer[layerIdx].erase( it );
@@ -1434,5 +1532,5 @@
   }
 #if !FIX_ALIGN_BUMPING
-#  // Update sub-DPB status
+  // Update sub-DPB status
   for( Int subDpbIdx = 0; subDpbIdx < dpbStatus.m_numSubDpbs; subDpbIdx++)
   {
@@ -1440,8 +1538,8 @@
   }
 #endif
-  dpbStatus.m_numAUsNotDisplayed--;    
+  dpbStatus.m_numAUsNotDisplayed--;
 
 #if CONFORMANCE_BITSTREAM_MODE
-  if( this->getConfModeFlag() )
+  if( m_confModeFlag )
   {
     for( Int dpbLayerCtr = 0; dpbLayerCtr < dpbStatus.m_numLayers; dpbLayerCtr++)
@@ -1453,10 +1551,10 @@
       if( this->getDecodedYuvLayerRefresh(layerIdx) )
       {
-        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
-        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
+        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_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
+        m_confReconFile[layerIdx].open(tempFileName, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
         this->setDecodedYuvLayerRefresh( layerIdx, false );
       }
@@ -1468,5 +1566,5 @@
         const Window &conf = checkPic.getConformanceWindow();
         const Window &defDisp = m_respectDefDispWindow ? checkPic.getDefDisplayWindow() : Window();
-        Int xScal =  1, yScal = 1;
+        Int xScal = 1, yScal = 1;
   #if REPN_FORMAT_IN_VPS
         UInt chromaFormatIdc = checkPic.getSlice(0)->getChromaFormatIdc();
@@ -1477,5 +1575,5 @@
         {
           TComPicYuv* pPicCYuvRec = checkPic.getPicYuvRec();
-          m_confReconFile[layerIdx].write( pPicCYuvRec,
+          m_confReconFile[layerIdx].write( pPicCYuvRec, m_outputColourSpaceConvert,
             conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
@@ -1493,8 +1591,8 @@
   }
 #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 1005)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h	(revision 1029)
@@ -2,5 +2,5 @@
  * License, included below. This software may be subject to other third party
  * and contributor rights, including patent rights, and no such rights are
- * granted under this license.  
+ * granted under this license.
  *
  * Copyright (c) 2010-2014, ITU/ISO/IEC
@@ -71,22 +71,24 @@
   TVideoIOYuv                     m_cTVideoIOYuvReconFile;        ///< reconstruction YUV class
 #endif
-#if CONFORMANCE_BITSTREAM_MODE
-  TVideoIOYuv   m_confReconFile[63];        ///< decode YUV files
-#endif  
+  
   // for output control  
 #if SVC_EXTENSION
+#if CONFORMANCE_BITSTREAM_MODE
+  TVideoIOYuv                      m_confReconFile[63];        ///< decode YUV files
+#endif 
   Int                             m_aiPOCLastDisplay [MAX_LAYERS]; ///< last POC in display order
 #else
   Int                             m_iPOCLastDisplay;              ///< last POC in display order
 #endif
-  
+  std::ofstream                   m_seiMessageFileStream;         ///< Used for outputing SEI messages.  
+
 public:
   TAppDecTop();
   virtual ~TAppDecTop() {}
-  
+
   Void  create            (); ///< create internal members
   Void  destroy           (); ///< destroy internal members
   Void  decode            (); ///< main decoding function
-  
+
 protected:
   Void  xCreateDecLib     (); ///< create internal classes
Index: branches/SHM-dev/source/App/TAppDecoder/decmain.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/decmain.cpp	(revision 1005)
+++ branches/SHM-dev/source/App/TAppDecoder/decmain.cpp	(revision 1029)
@@ -44,5 +44,5 @@
 //! \{
 
-bool g_md5_mismatch = false; ///< top level flag that indicates if there has been a decoding mismatch
+Bool g_md5_mismatch = false; ///< top level flag that indicates if there has been a decoding mismatch
 
 // ====================================================================================================================
@@ -59,5 +59,5 @@
   fprintf( stdout, "SHM software: Decoder Version [%s]", NV_VERSION );
 #else
-  fprintf( stdout, "HM software: Decoder Version [%s]", NV_VERSION );
+  fprintf( stdout, "HM software: Decoder Version [%s] (including RExt)", NV_VERSION );
 #endif
   fprintf( stdout, NVM_ONOS );
@@ -77,6 +77,6 @@
 
   // starting time
-  double dResult;
-  long lBefore = clock();
+  Double dResult;
+  clock_t lBefore = clock();
 
   // call decoding function
@@ -89,5 +89,5 @@
 
   // ending time
-  dResult = (double)(clock()-lBefore) / CLOCKS_PER_SEC;
+  dResult = (Double)(clock()-lBefore) / CLOCKS_PER_SEC;
   printf("\n Total Time: %12.3f sec.\n", dResult);
 
