Index: trunk/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1405)
+++ trunk/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1413)
@@ -4,5 +4,5 @@
  * granted under this license.
  *
- * Copyright (c) 2010-2016, ITU/ISO/IEC
+ * Copyright (c) 2010-2017, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -115,4 +115,7 @@
 #endif
   ("ClipOutputVideoToRec709Range",      m_bClipOutputVideoToRec709Range,  false, "If true then clip output video to the Rec. 709 Range on saving")
+#if MCTS_ENC_CHECK
+  ("TMCTSCheck",                  m_tmctsCheck,                          false,    "If enabled, the decoder checks for violations of mc_exact_sample_value_match_flag in Temporal MCTS ")
+#endif
   ;
 
Index: trunk/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecCfg.h	(revision 1405)
+++ trunk/source/App/TAppDecoder/TAppDecCfg.h	(revision 1413)
@@ -4,5 +4,5 @@
  * granted under this license.
  *
- * Copyright (c) 2010-2016, ITU/ISO/IEC
+ * Copyright (c) 2010-2017, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -78,4 +78,8 @@
   std::string   m_outputDecodedSEIMessagesFilename;   ///< filename to output decoded SEI messages to. If '-', then use stdout. If empty, do not output details.
   Bool          m_bClipOutputVideoToRec709Range;      ///< If true, clip the output video to the Rec 709 range on saving.
+#if MCTS_ENC_CHECK
+  Bool          m_tmctsCheck;
+#endif
+
 #if NH_MV
   std::vector<TChar*> m_pchReconFiles;                ///< array of output reconstruction file name create from output reconstruction file name
@@ -122,9 +126,11 @@
   , m_outputDecodedSEIMessagesFilename()
   , m_bClipOutputVideoToRec709Range(false)
+#if MCTS_ENC_CHECK
+  , m_tmctsCheck(false)
+#endif
 #if NH_MV
   , m_highestTid(-1)
   , m_targetDecLayerIdSetFileEmpty(true)
 #endif
-
   {
     for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
Index: trunk/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1405)
+++ trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1413)
@@ -4,5 +4,5 @@
  * granted under this license.
  *
- * Copyright (c) 2010-2016, ITU/ISO/IEC
+ * Copyright (c) 2010-2017, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -405,5 +405,5 @@
   // initialize global variables
   initROM();
-#if NH_3D_DMM
+#if NH_3D
   initWedgeLists();
 #endif
@@ -474,4 +474,7 @@
   m_cTDecTop.init();
   m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
+#if MCTS_ENC_CHECK
+  m_cTDecTop.setTMctsCheckEnabled(m_tmctsCheck);
+#endif
 #if O0043_BEST_EFFORT_DECODING
   m_cTDecTop.setForceDecodeBitDepth(m_forceDecodeBitDepth);
@@ -1262,4 +1265,5 @@
     m_vps->printLayerSets();
     m_vps->printPTL();
+    m_vps->printRepFormat();
   }
 }
@@ -2223,21 +2227,34 @@
   ////////////////////////////////////////////////////////////////////////////////
 
-  const TComDpbSize* dpbSize = m_vps->getDpbSize();
-  m_maxNumReorderPics       = dpbSize->getMaxVpsNumReorderPics      ( m_targetOptLayerSetIdx, m_highestTid );
-  m_maxLatencyIncreasePlus1 = dpbSize->getMaxVpsLatencyIncreasePlus1( m_targetOptLayerSetIdx, m_highestTid );
-  m_maxLatencyValue         = dpbSize->getVpsMaxLatencyPictures     ( m_targetOptLayerSetIdx, m_highestTid );
-
-  for(Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
-  {
-    m_maxDecPicBufferingMinus1[ i ] = MIN_INT;
-  }
-  for( Int i = 0; i <= m_vps->getMaxLayersMinus1(); i++ )
-  {
-    Int currLayerId = m_vps->getLayerIdInNuh( i );
-    for(Int layerIdx = 0 ; layerIdx < m_vps->getNumLayersInIdList( m_targetDecLayerSetIdx); layerIdx++ )
-    {
-      if( m_vps->getLayerSetLayerIdList( m_targetDecLayerSetIdx, layerIdx ) == currLayerId )
-      {
-        m_maxDecPicBufferingMinus1[currLayerId] = dpbSize->getMaxVpsDecPicBufferingMinus1( m_targetDecLayerSetIdx, layerIdx, m_highestTid );
+  // According to spec, no dbpSize values are given for OLS 0, however they are used in F.13.5.2.1. 
+  // This might be an issue of the spec. As workaround use sps for OLS 0 here.
+
+  if ( m_targetOptLayerSetIdx == 0 )
+  { 
+    m_maxNumReorderPics            = m_sps->getSpsMaxNumReorderPics      ( m_highestTid );
+    m_maxLatencyIncreasePlus1      = m_sps->getSpsMaxLatencyIncreasePlus1( m_highestTid );
+    m_maxLatencyValue              = m_sps->getSpsMaxLatencyPictures     ( m_highestTid );
+    m_maxDecPicBufferingMinus1[0]  = m_sps->getMaxDecPicBuffering        ( m_highestTid );
+  }
+  else
+  {
+    const TComDpbSize* dpbSize = m_vps->getDpbSize();
+    m_maxNumReorderPics       = dpbSize->getMaxVpsNumReorderPics      ( m_targetOptLayerSetIdx, m_highestTid );
+    m_maxLatencyIncreasePlus1 = dpbSize->getMaxVpsLatencyIncreasePlus1( m_targetOptLayerSetIdx, m_highestTid );
+    m_maxLatencyValue         = dpbSize->getVpsMaxLatencyPictures     ( m_targetOptLayerSetIdx, m_highestTid );
+
+    for(Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
+    {
+      m_maxDecPicBufferingMinus1[ i ] = MIN_INT;
+    }
+    for( Int i = 0; i <= m_vps->getMaxLayersMinus1(); i++ )
+    {
+      Int currLayerId = m_vps->getLayerIdInNuh( i );
+      for(Int layerIdx = 0 ; layerIdx < m_vps->getNumLayersInIdList( m_targetDecLayerSetIdx); layerIdx++ )
+      {
+        if( m_vps->getLayerSetLayerIdList( m_targetDecLayerSetIdx, layerIdx ) == currLayerId )
+        {
+          m_maxDecPicBufferingMinus1[currLayerId] = dpbSize->getMaxVpsDecPicBufferingMinus1( m_targetDecLayerSetIdx, layerIdx, m_highestTid );
+        }
       }
     }
@@ -2673,4 +2690,7 @@
     m_tDecTop[ decIdx ]->setLayerId( layerId );
     m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
+#if MCTS_ENC_CHECK
+    m_tDecTop[ decIdx ]->setTMctsCheckEnabled( m_tmctsCheck );
+#endif
     m_tDecTop[ decIdx ]->setDpb( &m_dpb );
     m_tDecTop[ decIdx ]->setTargetOlsIdx( m_targetOptLayerSetIdx );
@@ -2678,6 +2698,4 @@
     m_tDecTop[ decIdx ]->setPocDecrementedInDPBFlag   ( m_pocDecrementedInDpbFlag    );
     m_tDecTop[ decIdx ]->setLastPresentPocResetIdc    ( m_lastPresentPocResetIdc );
-
-
 #if O0043_BEST_EFFORT_DECODING
     m_cTDecTop[ decIdx ]->setForceDecodeBitDepth(m_forceDecodeBitDepth);
Index: trunk/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecTop.h	(revision 1405)
+++ trunk/source/App/TAppDecoder/TAppDecTop.h	(revision 1413)
@@ -4,5 +4,5 @@
  * granted under this license.
  *
- * Copyright (c) 2010-2016, ITU/ISO/IEC
+ * Copyright (c) 2010-2017, ITU/ISO/IEC
  * All rights reserved.
  *
Index: trunk/source/App/TAppDecoder/decmain.cpp
===================================================================
--- trunk/source/App/TAppDecoder/decmain.cpp	(revision 1405)
+++ trunk/source/App/TAppDecoder/decmain.cpp	(revision 1413)
@@ -4,5 +4,5 @@
  * granted under this license.
  *
- * Copyright (c) 2010-2016, ITU/ISO/IEC
+ * Copyright (c) 2010-2017, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -70,5 +70,6 @@
   Int curDecoding  = 0; 
   Double dResult = 0; 
-  do {
+  do 
+  {
     TAppDecTop  cTAppDecTop;
 #endif
