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
Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1405)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.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.
  *
@@ -46,4 +46,8 @@
 #include "TAppCommon/program_options_lite.h"
 #include "TLibEncoder/TEncRateCtrl.h"
+#if NH_MV
+#include <set>
+#endif
+
 #ifdef WIN32
 #define strdup _strdup
@@ -57,47 +61,58 @@
 
 
-
-enum ExtendedProfileName // this is used for determining profile strings, where multiple profiles map to a single profile idc with various constraint flag combinations
+#if !NH_MV
+enum UIProfileName // this is used for determining profile strings, where multiple profiles map to a single profile idc with various constraint flag combinations
 {
-  NONE = 0,
-  MAIN = 1,
-  MAIN10 = 2,
-  MAINSTILLPICTURE = 3,
-  MAINREXT = 4,
-  HIGHTHROUGHPUTREXT = 5, // Placeholder profile for development
+  UI_NONE = 0,
+  UI_MAIN = 1,
+  UI_MAIN10 = 2,
+  UI_MAIN10_STILL_PICTURE=10002,
+  UI_MAINSTILLPICTURE = 3,
+  UI_MAINREXT = 4,
+  UI_HIGHTHROUGHPUTREXT = 5,
   // The following are RExt profiles, which would map to the MAINREXT profile idc.
   // The enumeration indicates the bit-depth constraint in the bottom 2 digits
   //                           the chroma format in the next digit
-    //                           the intra constraint in the next digit
+  //                           the intra constraint in the next digit (1 for no intra constraint, 2 for intra constraint)
 //                           If it is a RExt still picture, there is a '1' for the top digit.
 #if NH_MV
-  MULTIVIEWMAIN = 6,
+  UI_MULTIVIEWMAIN     = 6,
 #if NH_3D
-  MAIN3D = 8, 
-#endif
-#endif
-  MONOCHROME_8      = 1008,
-  MONOCHROME_12     = 1012,
-  MONOCHROME_16     = 1016,
-  MAIN_12           = 1112,
-  MAIN_422_10       = 1210,
-  MAIN_422_12       = 1212,
-  MAIN_444          = 1308,
-  MAIN_444_10       = 1310,
-  MAIN_444_12       = 1312,
-  MAIN_444_16       = 1316, // non-standard profile definition, used for development purposes
-  MAIN_INTRA        = 2108,
-  MAIN_10_INTRA     = 2110,
-  MAIN_12_INTRA     = 2112,
-  MAIN_422_10_INTRA = 2210,
-  MAIN_422_12_INTRA = 2212,
-  MAIN_444_INTRA    = 2308,
-  MAIN_444_10_INTRA = 2310,
-  MAIN_444_12_INTRA = 2312,
-  MAIN_444_16_INTRA = 2316,
-  MAIN_444_STILL_PICTURE = 11308,
-  MAIN_444_16_STILL_PICTURE = 12316
+  UI_MAIN3D            = 8, 
+#endif
+#endif
+  UI_MONOCHROME_8      = 1008,
+  UI_MONOCHROME_12     = 1012,
+  UI_MONOCHROME_16     = 1016,
+  UI_MAIN_12           = 1112,
+  UI_MAIN_422_10       = 1210,
+  UI_MAIN_422_12       = 1212,
+  UI_MAIN_444          = 1308,
+  UI_MAIN_444_10       = 1310,
+  UI_MAIN_444_12       = 1312,
+  UI_MAIN_444_16       = 1316, // non-standard profile definition, used for development purposes
+  UI_MAIN_INTRA        = 2108,
+  UI_MAIN_10_INTRA     = 2110,
+  UI_MAIN_12_INTRA     = 2112,
+  UI_MAIN_422_10_INTRA = 2210,
+  UI_MAIN_422_12_INTRA = 2212,
+  UI_MAIN_444_INTRA    = 2308,
+  UI_MAIN_444_10_INTRA = 2310,
+  UI_MAIN_444_12_INTRA = 2312,
+  UI_MAIN_444_16_INTRA = 2316,
+  UI_MAIN_444_STILL_PICTURE = 11308,
+  UI_MAIN_444_16_STILL_PICTURE = 12316,
+  // The following are high throughput profiles, which would map to the HIGHTHROUGHPUTREXT profile idc.
+  // The enumeration indicates the bit-depth constraint in the bottom 2 digits
+  //                           the chroma format in the next digit
+  //                           the intra constraint in the next digit
+  //                           There is a '2' for the top digit to indicate it is high throughput profile
+  
+  UI_HIGHTHROUGHPUT_444     = 21308,
+  UI_HIGHTHROUGHPUT_444_10  = 21310,
+  UI_HIGHTHROUGHPUT_444_14  = 21314,
+  UI_HIGHTHROUGHPUT_444_16_INTRA  = 22316
 };
-
+#endif
 
 //! \ingroup TAppEncoder
@@ -112,4 +127,7 @@
 , m_snrInternalColourSpace(false)
 , m_outputInternalColourSpace(false)
+#if EXTENSION_360_VIDEO
+, m_ext360(*this)
+#endif
 {
 #if !NH_MV
@@ -208,4 +226,25 @@
 
 #if NH_MV
+
+GOPEntry* TAppEncCfg::xGetGopEntries(Int layerIdInVps)
+{
+  return m_GOPListMvc[ m_layerIdxInVpsToGopDefIdx[ layerIdInVps ] ];
+}
+
+GOPEntry* TAppEncCfg::xGetGopEntry(Int layerIdInVps, Int poc)
+{
+  GOPEntry* geFound = NULL; 
+  for( Int i = 0; i < ( getGOPSize() + 1) && geFound == NULL ; i++ ) 
+  {
+    GOPEntry* ge = &(xGetGopEntries( layerIdInVps)[ ( i < getGOPSize()  ? i : MAX_GOP ) ]);
+    if ( ge->m_POC == poc )
+    {
+      geFound = ge;       
+    }
+  }
+  assert( geFound != NULL ); 
+  return geFound;
+}
+
 Void TAppEncCfg::xParseSeiCfg()
 {
@@ -239,8 +278,10 @@
   in>>entry.m_POC;
   in>>entry.m_QPOffset;
-#if W0038_CQP_ADJ
+#if X0038_LAMBDA_FROM_QP_CAPABILITY
+  in>>entry.m_QPOffsetModelOffset;
+  in>>entry.m_QPOffsetModelScale;
+#endif
   in>>entry.m_CbQPoffset;
   in>>entry.m_CrQPoffset;
-#endif
   in>>entry.m_QPFactor;
   in>>entry.m_tcOffsetDiv2;
@@ -302,4 +343,17 @@
   }
 }
+
+#if NH_MV
+static inline std::vector<ChromaFormat> numberToChromaFormat(const IntAry1d val)
+{
+  std::vector<ChromaFormat> chromaFormats;
+  for( Int i = 0; i < val.size(); i++)
+  {
+    chromaFormats.push_back( numberToChromaFormat( val[i] ) );
+  }
+  return chromaFormats;
+}
+#endif
+
 
 static const struct MapStrToProfile
@@ -314,10 +368,17 @@
   {"main10",               Profile::MAIN10             },
   {"main-still-picture",   Profile::MAINSTILLPICTURE   },
+  {"main10-still-picture", Profile::MAIN10             },
   {"main-RExt",            Profile::MAINREXT           },
   {"high-throughput-RExt", Profile::HIGHTHROUGHPUTREXT }
 #if NH_MV
-  ,{"multiview-main"     , Profile::MULTIVIEWMAIN      },
+  ,{"multiview-main"     , Profile::MULTIVIEWMAIN      }
+#if NH_MV_ALLOW_NON_CONFORMING
+  ,{"multiview-main_NONCONFORMING", Profile::MULTIVIEWMAIN_NONCONFORMING }
 #if NH_3D
-   {"3d-main"            , Profile::MAIN3D             }
+  ,{"3d-main_NONCONFORMING"       , Profile::MAIN3D_NONCONFORMING }
+#endif
+#endif
+#if NH_3D
+   ,{"3d-main"                    , Profile::MAIN3D             }   
 #endif
 #endif
@@ -325,66 +386,84 @@
 };
 
-static const struct MapStrToExtendedProfile
+static const struct MapStrToUIProfileName
 {
   const TChar* str;
-  ExtendedProfileName value;
+  UIProfileName value;
 }
-strToExtendedProfile[] =
+strToUIProfileName[] =
 {
-    {"none",               NONE             },
-    {"main",               MAIN             },
-    {"main10",             MAIN10           },
-    {"main_still_picture",        MAINSTILLPICTURE },
-    {"main-still-picture",        MAINSTILLPICTURE },
-    {"main_RExt",                 MAINREXT         },
-    {"main-RExt",                 MAINREXT         },
-    {"main_rext",                 MAINREXT         },
-    {"main-rext",                 MAINREXT         },
-    {"high_throughput_RExt",      HIGHTHROUGHPUTREXT },
-    {"high-throughput-RExt",      HIGHTHROUGHPUTREXT },
-    {"high_throughput_rext",      HIGHTHROUGHPUTREXT },
-    {"high-throughput-rext",      HIGHTHROUGHPUTREXT },
-#if NH_MV
-    {"multiview-main"     , MULTIVIEWMAIN   },
+    {"none",                      UI_NONE             },
+    {"main",                      UI_MAIN             },
+    {"main10",                    UI_MAIN10           },
+    {"main10_still_picture",      UI_MAIN10_STILL_PICTURE },
+    {"main10-still-picture",      UI_MAIN10_STILL_PICTURE },
+    {"main_still_picture",        UI_MAINSTILLPICTURE },
+    {"main-still-picture",        UI_MAINSTILLPICTURE },
+    {"main_RExt",                 UI_MAINREXT         },
+    {"main-RExt",                 UI_MAINREXT         },
+    {"main_rext",                 UI_MAINREXT         },
+    {"main-rext",                 UI_MAINREXT         },
+    {"high_throughput_RExt",      UI_HIGHTHROUGHPUTREXT },
+    {"high-throughput-RExt",      UI_HIGHTHROUGHPUTREXT },
+    {"high_throughput_rext",      UI_HIGHTHROUGHPUTREXT },
+    {"high-throughput-rext",      UI_HIGHTHROUGHPUTREXT },
+#if NH_MV
+    {"multiview-main"     , UI_MULTIVIEWMAIN   },
 #if NH_3D
-    {"3d-main"            , MAIN3D          },
-#endif
-#endif
-    {"monochrome",         MONOCHROME_8     },
-    {"monochrome12",       MONOCHROME_12    },
-    {"monochrome16",       MONOCHROME_16    },
-    {"main12",             MAIN_12          },
-    {"main_422_10",        MAIN_422_10      },
-    {"main_422_12",        MAIN_422_12      },
-    {"main_444",           MAIN_444         },
-    {"main_444_10",        MAIN_444_10      },
-    {"main_444_12",        MAIN_444_12      },
-    {"main_444_16",        MAIN_444_16      },
-    {"main_intra",         MAIN_INTRA       },
-    {"main_10_intra",      MAIN_10_INTRA    },
-    {"main_12_intra",      MAIN_12_INTRA    },
-    {"main_422_10_intra",  MAIN_422_10_INTRA},
-    {"main_422_12_intra",  MAIN_422_12_INTRA},
-    {"main_444_intra",     MAIN_444_INTRA   },
-    {"main_444_still_picture",    MAIN_444_STILL_PICTURE },
-    {"main_444_10_intra",  MAIN_444_10_INTRA},
-    {"main_444_12_intra",  MAIN_444_12_INTRA},
-    {"main_444_16_intra",         MAIN_444_16_INTRA},
-    {"main_444_16_still_picture", MAIN_444_16_STILL_PICTURE }
+    {"3d-main"            , UI_MAIN3D          },
+#endif
+#if NH_MV_ALLOW_NON_CONFORMING
+    {"multiview-main_NONCONFORMING"     , UI_MULTIVIEWMAIN_NONCONF   },
+#if NH_3D
+    {"3d-main_NONCONFORMING"            , UI_MAIN3D_NONCONF          },
+#endif
+#endif
+#endif
+    {"monochrome",                UI_MONOCHROME_8     },
+    {"monochrome12",              UI_MONOCHROME_12    },
+    {"monochrome16",              UI_MONOCHROME_16    },
+    {"main12",                    UI_MAIN_12          },
+    {"main_422_10",               UI_MAIN_422_10      },
+    {"main_422_12",               UI_MAIN_422_12      },
+    {"main_444",                  UI_MAIN_444         },
+    {"main_444_10",               UI_MAIN_444_10      },
+    {"main_444_12",               UI_MAIN_444_12      },
+    {"main_444_16",               UI_MAIN_444_16      },
+    {"main_intra",                UI_MAIN_INTRA       },
+    {"main_10_intra",             UI_MAIN_10_INTRA    },
+    {"main_12_intra",             UI_MAIN_12_INTRA    },
+    {"main_422_10_intra",         UI_MAIN_422_10_INTRA},
+    {"main_422_12_intra",         UI_MAIN_422_12_INTRA},
+    {"main_444_intra",            UI_MAIN_444_INTRA   },
+    {"main_444_still_picture",    UI_MAIN_444_STILL_PICTURE },
+    {"main_444_10_intra",         UI_MAIN_444_10_INTRA},
+    {"main_444_12_intra",         UI_MAIN_444_12_INTRA},
+    {"main_444_16_intra",         UI_MAIN_444_16_INTRA},
+    {"main_444_16_still_picture", UI_MAIN_444_16_STILL_PICTURE },
+    {"high_throughput_444",       UI_HIGHTHROUGHPUT_444    },
+    {"high_throughput_444_10",    UI_HIGHTHROUGHPUT_444_10 },
+    {"high_throughput_444_14",    UI_HIGHTHROUGHPUT_444_14 },
+    {"high_throughput_444_16_intra", UI_HIGHTHROUGHPUT_444_16_INTRA }
 };
 
-static const ExtendedProfileName validRExtProfileNames[2/* intraConstraintFlag*/][4/* bit depth constraint 8=0, 10=1, 12=2, 16=3*/][4/*chroma format*/]=
+static const UIProfileName validRExtHighThroughPutProfileNames[2/* intraConstraintFlag*/][4/* bit depth constraint 8=0, 10=1, 12=2, 16=3*/]=
 {
-    {
-        { MONOCHROME_8,  NONE,          NONE,              MAIN_444          }, // 8-bit  inter for 400, 420, 422 and 444
-        { NONE,          NONE,          MAIN_422_10,       MAIN_444_10       }, // 10-bit inter for 400, 420, 422 and 444
-        { MONOCHROME_12, MAIN_12,       MAIN_422_12,       MAIN_444_12       }, // 12-bit inter for 400, 420, 422 and 444
-        { MONOCHROME_16, NONE,          NONE,              MAIN_444_16       }  // 16-bit inter for 400, 420, 422 and 444 (the latter is non standard used for development)
+    { UI_HIGHTHROUGHPUT_444,          UI_HIGHTHROUGHPUT_444_10,          UI_HIGHTHROUGHPUT_444_14,         UI_NONE                         }, // intraConstraintFlag 0 - 8-bit,10-bit,14-bit and 16-bit
+    { UI_NONE,                        UI_NONE,                           UI_NONE,                          UI_HIGHTHROUGHPUT_444_16_INTRA  }  // intraConstraintFlag 1 - 8-bit,10-bit,14-bit and 16-bit
+};
+
+static const UIProfileName validRExtProfileNames[2/* intraConstraintFlag*/][4/* bit depth constraint 8=0, 10=1, 12=2, 16=3*/][4/*chroma format*/]=
+{
+    {
+        { UI_MONOCHROME_8,  UI_NONE,          UI_NONE,              UI_MAIN_444          }, // 8-bit  inter for 400, 420, 422 and 444
+        { UI_NONE,          UI_NONE,          UI_MAIN_422_10,       UI_MAIN_444_10       }, // 10-bit inter for 400, 420, 422 and 444
+        { UI_MONOCHROME_12, UI_MAIN_12,       UI_MAIN_422_12,       UI_MAIN_444_12       }, // 12-bit inter for 400, 420, 422 and 444
+        { UI_MONOCHROME_16, UI_NONE,          UI_NONE,              UI_MAIN_444_16       }  // 16-bit inter for 400, 420, 422 and 444 (the latter is non standard used for development)
     },
     {
-        { NONE,          MAIN_INTRA,    NONE,              MAIN_444_INTRA    }, // 8-bit  intra for 400, 420, 422 and 444
-        { NONE,          MAIN_10_INTRA, MAIN_422_10_INTRA, MAIN_444_10_INTRA }, // 10-bit intra for 400, 420, 422 and 444
-        { NONE,          MAIN_12_INTRA, MAIN_422_12_INTRA, MAIN_444_12_INTRA }, // 12-bit intra for 400, 420, 422 and 444
-        { NONE,          NONE,          NONE,              MAIN_444_16_INTRA }  // 16-bit intra for 400, 420, 422 and 444
+        { UI_NONE,          UI_MAIN_INTRA,    UI_NONE,              UI_MAIN_444_INTRA    }, // 8-bit  intra for 400, 420, 422 and 444
+        { UI_NONE,          UI_MAIN_10_INTRA, UI_MAIN_422_10_INTRA, UI_MAIN_444_10_INTRA }, // 10-bit intra for 400, 420, 422 and 444
+        { UI_NONE,          UI_MAIN_12_INTRA, UI_MAIN_422_12_INTRA, UI_MAIN_444_12_INTRA }, // 12-bit intra for 400, 420, 422 and 444
+        { UI_NONE,          UI_NONE,          UI_NONE,              UI_MAIN_444_16_INTRA }  // 16-bit intra for 400, 420, 422 and 444
     }
 };
@@ -425,5 +504,4 @@
 };
 
-#if U0132_TARGET_BITS_SATURATION
 UInt g_uiMaxCpbSize[2][21] =
 {
@@ -432,5 +510,4 @@
   { 0, 0, 0,      0, 0, 0,       0,       0, 0,       0,        0, 0, 30000000, 50000000, 0, 100000000, 160000000, 240000000, 240000000, 480000000, 800000000 }
 };
-#endif
 
 static const struct MapStrToCostMode
@@ -481,15 +558,15 @@
   in >> str;
 
-  for (UInt i = 0; i < mapLen; i++)
-  {
-    if (str == map[i].str)
+  UInt i=0;
+  for (; i < mapLen && str!=map[i].str; i++);
+
+  if (i < mapLen)
     {
       val = map[i].value;
-      goto found;
-    }
-  }
-  /* not found */
+    }
+  else
+  {
   in.setstate(ios::failbit);
-found:
+  }
   return in;
 }
@@ -497,7 +574,7 @@
 //inline to prevent compiler warnings for "unused static function"
 
-static inline istream& operator >> (istream &in, ExtendedProfileName &profile)
+static inline istream& operator >> (istream &in, UIProfileName &profile)
 {
-  return readStrToEnum(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), in, profile);
+  return readStrToEnum(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), in, profile);
 }
 
@@ -640,4 +717,22 @@
 }
 
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+template <class T>
+static inline istream& operator >> (std::istream &in, TAppEncCfg::OptionalValue<T> &value)
+{
+  in >> std::ws;
+  if (in.eof())
+  {
+    value.bPresent=false;
+  }
+  else
+  {
+    in >> value.value;
+    value.bPresent=true;
+  }
+  return in;
+}
+#endif
+
 static Void
 automaticallySelectRExtProfile(const Bool bUsingGeneralRExtTools,
@@ -740,7 +835,24 @@
 #endif
 
+#if NH_MV
+  IntAry1d tmpInputChromaFormat;
+  IntAry1d tmpChromaFormat;
+#if NH_3D
+  IntAry1d tmpChromaFormatInit;
+  tmpChromaFormatInit.push_back(420);
+  tmpChromaFormatInit.push_back(400);
+#endif
+  IntAry2d tmpPad(2);
+
+  IntAry2d tmpInputBitDepth      (2);
+  IntAry2d tmpOutputBitDepth     (2);
+  IntAry2d tmpMSBExtendedBitDepth(2);
+  IntAry2d tmpInternalBitDepth   (2);
+
+#else
+  Int tmpInputChromaFormat;
   Int tmpChromaFormat;
-  Int tmpInputChromaFormat;
   Int tmpConstraintChromaFormat;
+#endif
   Int tmpWeightedPredictionMethod;
   Int tmpFastInterSearchMode;
@@ -751,7 +863,7 @@
   string inputColourSpaceConvert;
 #if NH_MV
-  std::vector<ExtendedProfileName> extendedProfiles;
-#else
-  ExtendedProfileName extendedProfile;
+  std::vector<UIProfileName> UIProfiles;
+#else
+  UIProfileName UIProfile;
 #endif
   Int saoOffsetBitShift[MAX_NUM_CHANNEL_TYPE];
@@ -766,4 +878,9 @@
   SMultiValueInput<Double> cfg_adIntraLambdaModifier         (0, std::numeric_limits<Double>::max(), 0, MAX_TLAYER); ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier.
 
+  const Int defaultLumaLevelTodQp_QpChangePoints[]   =  {-3,  -2,  -1,   0,   1,   2,   3,   4,   5,   6};
+  const Int defaultLumaLevelTodQp_LumaChangePoints[] =  { 0, 301, 367, 434, 501, 567, 634, 701, 767, 834};
+  SMultiValueInput<Int>  cfg_lumaLeveltoDQPMappingQP         (-MAX_QP, MAX_QP,                    0, LUMA_LEVEL_TO_DQP_LUT_MAXSIZE, defaultLumaLevelTodQp_QpChangePoints,   sizeof(defaultLumaLevelTodQp_QpChangePoints  )/sizeof(Int));
+  SMultiValueInput<Int>  cfg_lumaLeveltoDQPMappingLuma       (0, std::numeric_limits<Int>::max(), 0, LUMA_LEVEL_TO_DQP_LUT_MAXSIZE, defaultLumaLevelTodQp_LumaChangePoints, sizeof(defaultLumaLevelTodQp_LumaChangePoints)/sizeof(Int));
+  UInt lumaLevelToDeltaQPMode;
 
   const UInt defaultInputKneeCodes[3]  = { 600, 800, 900 };
@@ -842,7 +959,22 @@
   ("ProfileTierLevelIdx_%d"        , m_profileTierLevelIdx         , IntAry1d(0)  , MAX_NUM_LAYERS,                  "Indices to profile level tier for ols")
   // Layer dependencies
-  ("DirectRefLayers_%d"            , m_directRefLayers             , IntAry1d(0,0), MAX_NUM_LAYERS,                  "LayerIdx in VPS of direct reference layers")
-  ("DependencyTypes_%d"            , m_dependencyTypes             , IntAry1d(0,0), MAX_NUM_LAYERS,                  "Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion")
-#endif
+  ("DirectRefLayers_%d"            , m_directRefLayers               , IntAry1d(0,0), MAX_NUM_LAYERS,                  "LayerIdx in VPS of direct reference layers")
+  ("DependencyTypes_%d"            , m_dependencyTypes               , IntAry1d(0,0), MAX_NUM_LAYERS,                  "Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion")
+  ("ShareParameterSets"            , m_shareParameterSets            , false        ,                                  "Signal parameter sets only in the base layer.")  
+  ("LayerIdxInVpsToGopDefIdx"      , m_layerIdxInVpsToGopDefIdx      , IntAry1d(0,0),                                  "Maps the layers to the GOP definitions in the cfg-file.")
+  ("LayerIdxInVpsToRepFormatIdx"   , m_layerIdxInVpsToRepFormatIdx   , IntAry1d(0,0),                                  "Maps the layers to the vps representation formats, i.e. values of SourceWidth, SourceHeight, InternalBitDepth, ChromaFormatIDC, InputBitDepth, OutputBitDepth, MSBExtendedBitDepth, InputChromaFormat, ConfWinBottom, ConfWinTop, ConfWinRight, ConfWinLeft, VerticalPadding, HorizontalPadding." )  
+#endif
+#if NH_MV
+  ("SourceWidth,-wdt",                                m_iSourceWidths,                            IntAry1d(1,0), "Source picture width")
+  ("SourceHeight,-hgt",                               m_iSourceHeights,                           IntAry1d(1,0), "Source picture height")
+  ("InputBitDepth",                                   tmpInputBitDepth      [CHANNEL_TYPE_LUMA  ], IntAry1d(1,8), "Bit-depth of input file")
+  ("OutputBitDepth",                                  tmpOutputBitDepth     [CHANNEL_TYPE_LUMA  ], IntAry1d(1,0), "Bit-depth of output file (default:InternalBitDepth)")
+  ("MSBExtendedBitDepth",                             tmpMSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ], IntAry1d(1,0), "bit depth of luma component after addition of MSBs of value 0 (used for synthesising High Dynamic Range source material). (default:InputBitDepth)")
+  ("InternalBitDepth",                                tmpInternalBitDepth   [CHANNEL_TYPE_LUMA  ], IntAry1d(1,0), "Bit-depth the codec operates at. (default:MSBExtendedBitDepth). If different to MSBExtendedBitDepth, source data will be converted")
+  ("InputBitDepthC",                                  tmpInputBitDepth      [CHANNEL_TYPE_CHROMA], IntAry1d(1,0), "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
+  ("OutputBitDepthC",                                 tmpOutputBitDepth     [CHANNEL_TYPE_CHROMA], IntAry1d(1,0), "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
+  ("MSBExtendedBitDepthC",                            tmpMSBExtendedBitDepth[CHANNEL_TYPE_CHROMA], IntAry1d(1,0), "As per MSBExtendedBitDepth but for chroma component. (default:MSBExtendedBitDepth)")
+  ("InternalBitDepthC",                               tmpInternalBitDepth   [CHANNEL_TYPE_CHROMA], IntAry1d(1,0), "As per InternalBitDepth but for chroma component. (default:InternalBitDepth)")
+#else
   ("SourceWidth,-wdt",                                m_iSourceWidth,                                       0, "Source picture width")
   ("SourceHeight,-hgt",                               m_iSourceHeight,                                      0, "Source picture height")
@@ -855,4 +987,5 @@
   ("MSBExtendedBitDepthC",                            m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA],           0, "As per MSBExtendedBitDepth but for chroma component. (default:MSBExtendedBitDepth)")
   ("InternalBitDepthC",                               m_internalBitDepth[CHANNEL_TYPE_CHROMA],              0, "As per InternalBitDepth but for chroma component. (default:InternalBitDepth)")
+#endif
   ("ExtendedPrecision",                               m_extendedPrecisionProcessingFlag,                false, "Increased internal accuracies to support high bit depths (not valid in V1 profiles)")
   ("HighPrecisionPredictionWeighting",                m_highPrecisionOffsetsEnabledFlag,                false, "Use high precision option for weighted prediction (not valid in V1 profiles)")
@@ -860,22 +993,52 @@
   ("SNRInternalColourSpace",                          m_snrInternalColourSpace,                         false, "If true, then no colour space conversion is applied prior to SNR, otherwise inverse of input is applied.")
   ("OutputInternalColourSpace",                       m_outputInternalColourSpace,                      false, "If true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied.")
+#if NH_MV
+  ("InputChromaFormat",                               tmpInputChromaFormat,                   IntAry1d(1,420), "InputChromaFormatIDC")
+#else
   ("InputChromaFormat",                               tmpInputChromaFormat,                               420, "InputChromaFormatIDC")
+#endif
   ("MSEBasedSequencePSNR",                            m_printMSEBasedSequencePSNR,                      false, "0 (default) emit sequence PSNR only as a linear average of the frame PSNRs, 1 = also emit a sequence PSNR based on an average of the frame MSEs")
   ("PrintFrameMSE",                                   m_printFrameMSE,                                  false, "0 (default) emit only bit count and PSNRs for each frame, 1 = also emit MSE values")
   ("PrintSequenceMSE",                                m_printSequenceMSE,                               false, "0 (default) emit only bit rate and PSNRs for the whole sequence, 1 = also emit MSE values")
+#if JVET_F0064_MSSSIM  
+  ("PrintMSSSIM",                                     m_printMSSSIM,                                    false, "0 (default) do not print MS-SSIM scores, 1 = print MS-SSIM scores for each frame and for the whole sequence")
+#endif
   ("CabacZeroWordPaddingEnabled",                     m_cabacZeroWordPaddingEnabled,                     true, "0 do not add conforming cabac-zero-words to bit streams, 1 (default) = add cabac-zero-words as required")
+#if NH_MV
+#if NH_3D
+  ("ChromaFormatIDC,-cf",                             tmpChromaFormat,                    tmpChromaFormatInit, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
+#else
+  ("ChromaFormatIDC,-cf",                             tmpChromaFormat,                          IntAry1d(1,0), "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
+#endif
+#else
   ("ChromaFormatIDC,-cf",                             tmpChromaFormat,                                      0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
+#endif
   ("ConformanceMode",                                 m_conformanceWindowMode,                              0, "Deprecated alias of ConformanceWindowMode")
   ("ConformanceWindowMode",                           m_conformanceWindowMode,                              0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
+#if NH_MV
+  ("HorizontalPadding,-pdx",                          tmpPad[0] ,                               IntAry1d(1,0), "Horizontal source padding for conformance window mode 2")
+  ("VerticalPadding,-pdy",                            tmpPad[1] ,                               IntAry1d(1,0), "Vertical source padding for conformance window mode 2")
+#else
   ("HorizontalPadding,-pdx",                          m_aiPad[0],                                           0, "Horizontal source padding for conformance window mode 2")
   ("VerticalPadding,-pdy",                            m_aiPad[1],                                           0, "Vertical source padding for conformance window mode 2")
+#endif
+
+#if NH_MV
+  ("ConfWinLeft",                                     m_confWinLefts,                         IntAry1d(1, 0) , "Left offset for window conformance mode 3")
+  ("ConfWinRight",                                    m_confWinRights,                        IntAry1d(1, 0) , "Right offset for window conformance mode 3")
+  ("ConfWinTop",                                      m_confWinTops,                          IntAry1d(1, 0) , "Top offset for window conformance mode 3")
+  ("ConfWinBottom",                                   m_confWinBottoms,                       IntAry1d(1, 0) , "Bottom offset for window conformance mode 3")
+#else
   ("ConfLeft",                                        m_confWinLeft,                                        0, "Deprecated alias of ConfWinLeft")
   ("ConfRight",                                       m_confWinRight,                                       0, "Deprecated alias of ConfWinRight")
   ("ConfTop",                                         m_confWinTop,                                         0, "Deprecated alias of ConfWinTop")
   ("ConfBottom",                                      m_confWinBottom,                                      0, "Deprecated alias of ConfWinBottom")
+
   ("ConfWinLeft",                                     m_confWinLeft,                                        0, "Left offset for window conformance mode 3")
   ("ConfWinRight",                                    m_confWinRight,                                       0, "Right offset for window conformance mode 3")
   ("ConfWinTop",                                      m_confWinTop,                                         0, "Top offset for window conformance mode 3")
   ("ConfWinBottom",                                   m_confWinBottom,                                      0, "Bottom offset for window conformance mode 3")
+#endif
+  
   ("AccessUnitDelimiter",                             m_AccessUnitDelimiter,                            false, "Enable Access Unit Delimiter NALUs")
   ("FrameRate,-fr",                                   m_iFrameRate,                                         0, "Frame rate")
@@ -901,9 +1064,19 @@
   ("Tier"    ,                                        cfg_tiers  ,                                 string(""), "Tier indication in VpsProfileTierLevel (Indication only)")
   ("InblFlag",                                        m_inblFlag ,                       std::vector<Bool>(0), "InblFlags in VpsProfileTierLevel (Indication only)" )
-#else
-  ("Profile",                                         extendedProfile,                                   NONE, "Profile name to use for encoding. Use main (for main), main10 (for main10), main-still-picture, main-RExt (for Range Extensions profile), any of the RExt specific profile names, or none")
+
+  ("MaxBitDepthConstraint",                           m_bitDepthConstraints,           std::vector<Int>( 1,0u) , "Bit depth to use for profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
+  ("MaxChromaFormatConstraint",                       m_tmpConstraintChromaFormats,    IntAry1d(1,     0)       , "Chroma-format to use for the profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
+  ("IntraConstraintFlag",                             m_intraConstraintFlags,          BoolAry1d(1,false)       , "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
+  ("OnePictureOnlyConstraintFlag",                    m_onePictureOnlyConstraintFlags, BoolAry1d(1,false)       , "Value of general_one_picture_only_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
+  ("LowerBitRateConstraintFlag",                      m_lowerBitRateConstraintFlags,   BoolAry1d(1,true)        , "Value of general_lower_bit_rate_constraint_flag to use for RExt profiles")
+  ("ProgressiveSource",                               m_progressiveSourceFlags,        BoolAry1d(1,false)       , "Indicate that source is progressive")
+  ("InterlacedSource",                                m_interlacedSourceFlags,         BoolAry1d(1,false)       , "Indicate that source is interlaced")
+  ("NonPackedSource",                                 m_nonPackedConstraintFlags,      BoolAry1d(1,false)       , "Indicate that source does not contain frame packing")
+  ("FrameOnly",                                       m_frameOnlyConstraintFlags,      BoolAry1d(1,false)       , "Indicate that the bitstream contains only frames")
+
+#else
+  ("Profile",                                         UIProfile,                                      UI_NONE, "Profile name to use for encoding. Use main (for main), main10 (for main10), main-still-picture, main-RExt (for Range Extensions profile), any of the RExt specific profile names, or none")
   ("Level",                                           m_level,                                    Level::NONE, "Level limit to be used, eg 5.1, or none")
   ("Tier",                                            m_levelTier,                                Level::MAIN, "Tier to use for interpretation of --Level (main or high only)")
-#endif
   ("MaxBitDepthConstraint",                           m_bitDepthConstraint,                                0u, "Bit depth to use for profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
   ("MaxChromaFormatConstraint",                       tmpConstraintChromaFormat,                            0, "Chroma-format to use for the profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
@@ -911,9 +1084,11 @@
   ("OnePictureOnlyConstraintFlag",                    m_onePictureOnlyConstraintFlag,                   false, "Value of general_one_picture_only_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
   ("LowerBitRateConstraintFlag",                      m_lowerBitRateConstraintFlag,                      true, "Value of general_lower_bit_rate_constraint_flag to use for RExt profiles")
-
   ("ProgressiveSource",                               m_progressiveSourceFlag,                          false, "Indicate that source is progressive")
   ("InterlacedSource",                                m_interlacedSourceFlag,                           false, "Indicate that source is interlaced")
   ("NonPackedSource",                                 m_nonPackedConstraintFlag,                        false, "Indicate that source does not contain frame packing")
   ("FrameOnly",                                       m_frameOnlyConstraintFlag,                        false, "Indicate that the bitstream contains only frames")
+
+#endif
+
 
   // Unit definition parameters
@@ -939,4 +1114,12 @@
   ("DecodingRefreshType,-dr",                         m_iDecodingRefreshType,                               0, "Intra refresh type (0:none 1:CRA 2:IDR 3:RecPointSEI)")
   ("GOPSize,g",                                       m_iGOPSize,                                           1, "GOP size of temporal structure")
+#if JCTVC_Y0038_PARAMS
+#if NH_MV
+  // To keep compatibility to legacy bit streams.
+  ("ReWriteParamSetsFlag",                            m_bReWriteParamSetsFlag,                           false, "Enable rewriting of Parameter sets before every (intra) random access point")
+#else
+  ("ReWriteParamSetsFlag",                            m_bReWriteParamSetsFlag,                           true, "Enable rewriting of Parameter sets before every (intra) random access point")
+#endif
+#endif 
 
   // motion search options
@@ -967,11 +1150,25 @@
   ("LambdaModifier6,-LM6",                            m_adLambdaModifier[ 6 ],                  ( Double )1.0, "Lambda modifier for temporal layer 6. If LambdaModifierI is used, this will not affect intra pictures")
   ("LambdaModifierI,-LMI",                            cfg_adIntraLambdaModifier,    cfg_adIntraLambdaModifier, "Lambda modifiers for Intra pictures, comma separated, up to one the number of temporal layer. If entry for temporalLayer exists, then use it, else if some are specified, use the last, else use the standard LambdaModifiers.")
-  ("IQPFactor,-IQF",                                  m_dIntraQpFactor,                                  -1.0, "Intra QP Factor for Lambda Computation. If negative, use the default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? (GopSize-1)/2 : GopSize-1) ))")
+  ("IQPFactor,-IQF",                                  m_dIntraQpFactor,                                  -1.0, "Intra QP Factor for Lambda Computation. If negative, the default will scale lambda based on GOP size (unless LambdaFromQpEnable then IntraQPOffset is used instead)")
 
   /* Quantization parameters */
 #if NH_MV
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+  ("QP,q",                                            m_iQP,                                               std::vector<Int>(1,30)  , "Qp value")
+  ("QPIncrementFrame,-qpif",                          m_qpIncrementAtSourceFrame,                          std::vector<Int>( 0 ), "If a source file frame number is specified, the internal QP will be incremented for all POCs associated with source frames >= frame number. If empty, do not increment.")
+#else
   ("QP,q",          m_fQP, std::vector<double>(1,30.0), "Qp values for each layer, if value is float, QP is switched once during encoding")
+#endif
+#else
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+  ("QP,q",                                            m_iQP,                                               30, "Qp value")
+  ("QPIncrementFrame,-qpif",                          m_qpIncrementAtSourceFrame,       OptionalValue<UInt>(), "If a source file frame number is specified, the internal QP will be incremented for all POCs associated with source frames >= frame number. If empty, do not increment.")
 #else
   ("QP,q",                                            m_fQP,                                             30.0, "Qp value, if value is float, QP is switched once during encoding")
+#endif
+#endif
+#if X0038_LAMBDA_FROM_QP_CAPABILITY
+  ("IntraQPOffset",                                   m_intraQPOffset,                                      0, "Qp offset value for intra slice, typically determined based on GOP size")
+  ("LambdaFromQpEnable",                              m_lambdaFromQPEnable,                             false, "Enable flag for derivation of lambda from QP")
 #endif
   ("DeltaQpRD,-dqr",                                  m_uiDeltaQpRD,                                       0u, "max dQp offset for slice")
@@ -981,12 +1178,18 @@
   ("FastDeltaQP",                                     m_bFastDeltaQP,                                   false, "Fast Delta QP Algorithm")
 
+  ("LumaLevelToDeltaQPMode",                          lumaLevelToDeltaQPMode,                              0u, "Luma based Delta QP 0(default): not used. 1: Based on CTU average, 2: Based on Max luma in CTU")
+  ("LumaLevelToDeltaQPMaxValWeight",                  m_lumaLevelToDeltaQPMapping.maxMethodWeight,        1.0, "Weight of block max luma val when LumaLevelToDeltaQPMode = 2")
+  ("LumaLevelToDeltaQPMappingLuma",                   cfg_lumaLeveltoDQPMappingLuma,  cfg_lumaLeveltoDQPMappingLuma, "Luma to Delta QP Mapping - luma thresholds")
+  ("LumaLevelToDeltaQPMappingDQP",                    cfg_lumaLeveltoDQPMappingQP,  cfg_lumaLeveltoDQPMappingQP, "Luma to Delta QP Mapping - DQP values")
   ("CbQpOffset,-cbqpofs",                             m_cbQpOffset,                                         0, "Chroma Cb QP Offset")
   ("CrQpOffset,-crqpofs",                             m_crQpOffset,                                         0, "Chroma Cr QP Offset")
-
-#if W0038_CQP_ADJ
-  ("SliceChromaQPOffsetPeriodicity",                  m_sliceChromaQpOffsetPeriodicity,                    0u, "Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.")
+  ("WCGPPSEnable",                                    m_wcgChromaQpControl.enabled,                     false, "1: Enable the WCG PPS chroma modulation scheme. 0 (default) disabled")
+  ("WCGPPSCbQpScale",                                 m_wcgChromaQpControl.chromaCbQpScale,               1.0, "WCG PPS Chroma Cb QP Scale")
+  ("WCGPPSCrQpScale",                                 m_wcgChromaQpControl.chromaCrQpScale,               1.0, "WCG PPS Chroma Cr QP Scale")
+  ("WCGPPSChromaQpScale",                             m_wcgChromaQpControl.chromaQpScale,                 0.0, "WCG PPS Chroma QP Scale")
+  ("WCGPPSChromaQpOffset",                            m_wcgChromaQpControl.chromaQpOffset,                0.0, "WCG PPS Chroma QP Offset")
+("SliceChromaQPOffsetPeriodicity",                  m_sliceChromaQpOffsetPeriodicity,                    0u, "Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.")
   ("SliceCbQpOffsetIntraOrPeriodic",                  m_sliceChromaQpOffsetIntraOrPeriodic[0],              0, "Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.")
   ("SliceCrQpOffsetIntraOrPeriodic",                  m_sliceChromaQpOffsetIntraOrPeriodic[1],              0, "Chroma Cr QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.")
-#endif
 #if ADAPTIVE_QP_SELECTION
   ("AdaptiveQpSelection,-aqps",                       m_bUseAdaptQpSelect,                              false, "AdaptiveQpSelection")
@@ -998,7 +1201,5 @@
   ("RDOQ",                                            m_useRDOQ,                                         true)
   ("RDOQTS",                                          m_useRDOQTS,                                       true)
-#if T0196_SELECTIVE_RDOQ
   ("SelectiveRDOQ",                                   m_useSelectiveRDOQ,                               false, "Enable selective RDOQ")
-#endif
   ("RDpenalty",                                       m_rdPenalty,                                          0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disabled  1:RD-penalty  2:maximum RD-penalty")
 
@@ -1012,9 +1213,5 @@
   ("LoopFilterBetaOffset_div2",                       m_loopFilterBetaOffsetDiv2,                           0)
   ("LoopFilterTcOffset_div2",                         m_loopFilterTcOffsetDiv2,                             0)
-#if W0038_DB_OPT
   ("DeblockingFilterMetric",                          m_deblockingFilterMetric,                             0)
-#else
-  ("DeblockingFilterMetric",                          m_DeblockingFilterMetric,                         false)
-#endif
   // Coding tools
   ("AMP",                                             m_enableAMP,                                       true, "Enable asymmetric motion partitions")
@@ -1042,7 +1239,5 @@
   ("MaxNumOffsetsPerPic",                             m_maxNumOffsetsPerPic,                             2048, "Max number of SAO offset per picture (Default: 2048)")
   ("SAOLcuBoundary",                                  m_saoCtuBoundary,                                 false, "0: right/bottom CTU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
-#if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
   ("SAOResetEncoderStateAfterIRAP",                   m_saoResetEncoderStateAfterIRAP,                  false, "When true, resets the encoder's SAO state after an IRAP (POC order). Disabled by default.")
-#endif
   ("SliceMode",                                       tmpSliceMode,                            Int(NO_SLICES), "0: Disable all Recon slice limits, 1: Enforce max # of CTUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
   ("SliceArgument",                                   m_sliceArgument,                                      0, "Depending on SliceMode being:"
@@ -1086,5 +1281,5 @@
   ("ScalingList",                                     m_useScalingListId,                    SCALING_LIST_OFF, "0/off: no scaling list, 1/default: default scaling lists, 2/file: scaling lists specified in ScalingListFile")
   ("ScalingListFile",                                 m_scalingListFileName,                       string(""), "Scaling list file name. Use an empty string to produce help.")
-  ("SignHideFlag,-SBH",                               m_signHideFlag,                                    true)
+  ("SignHideFlag,-SBH",                               m_signDataHidingEnabledFlag,                                    true)
   ("MaxNumMergeCand",                                 m_maxNumMergeCand,                                   5u, "Maximum number of merge candidates")
   /* Misc. */
@@ -1107,11 +1302,7 @@
   ( "InitialQP",                                      m_RCInitialQP,                                        0, "Rate control: initial QP" )
   ( "RCForceIntraQP",                                 m_RCForceIntraQP,                                 false, "Rate control: force intra QP to be equal to initial QP" )
-
-#if U0132_TARGET_BITS_SATURATION
   ( "RCCpbSaturation",                                m_RCCpbSaturationEnabled,                         false, "Rate control: enable target bits saturation to avoid CPB overflow and underflow" )
   ( "RCCpbSize",                                      m_RCCpbSize,                                         0u, "Rate control: CPB size" )
   ( "RCInitialCpbFullness",                           m_RCInitialCpbFullness,                             0.9, "Rate control: initial CPB fullness" )
-#endif
-
 #if KWU_RC_VIEWRC_E0227
   ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
@@ -1150,6 +1341,7 @@
 #endif
 
-  ("TransquantBypassEnableFlag",                      m_TransquantBypassEnableFlag,                     false, "transquant_bypass_enable_flag indicator in PPS")
-  ("CUTransquantBypassFlagForce",                     m_CUTransquantBypassFlagForce,                    false, "Force transquant bypass mode, when transquant_bypass_enable_flag is enabled")
+  ("TransquantBypassEnable",                          m_TransquantBypassEnabledFlag,                    false, "transquant_bypass_enabled_flag indicator in PPS")
+  ("TransquantBypassEnableFlag",                      m_TransquantBypassEnabledFlag,                    false, "deprecated alias for TransquantBypassEnable")
+  ("CUTransquantBypassFlagForce",                     m_CUTransquantBypassFlagForce,                    false, "Force transquant bypass mode, when transquant_bypass_enabled_flag is enabled")
   ("CostMode",                                        m_costMode,                         COST_STANDARD_LOSSY, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).")
   ("RecalculateQPAccordingToLambda",                  m_recalculateQPAccordingToLambda,                 false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
@@ -1263,4 +1455,7 @@
   ("SEIScalableNesting",                              m_scalableNestingSEIEnabled,                      false, "Control generation of scalable nesting SEI messages")
   ("SEITempMotionConstrainedTileSets",                m_tmctsSEIEnabled,                                false, "Control generation of temporal motion constrained tile sets SEI message")
+#if MCTS_ENC_CHECK
+  ("SEITMCTSTileConstraint",                          m_tmctsSEITileConstraint,                         false, "Constrain motion vectors at tile boundaries")
+#endif
   ("SEITimeCodeEnabled",                              m_timeCodeSEIEnabled,                             false, "Control generation of time code information SEI message")
   ("SEITimeCodeNumClockTs",                           m_timeCodeSEINumTs,                                   0, "Number of clock time sets [0..3]")
@@ -1296,7 +1491,8 @@
   ("SEIMasteringDisplayPrimaries",                    cfg_DisplayPrimariesCode,       cfg_DisplayPrimariesCode, "Mastering display primaries for all three colour planes in CIE xy coordinates in increments of 1/50000 (results in the ranges 0 to 50000 inclusive)")
   ("SEIMasteringDisplayWhitePoint",                   cfg_DisplayWhitePointCode,     cfg_DisplayWhitePointCode, "Mastering display white point CIE xy coordinates in normalised increments of 1/50000 (e.g. 0.333 = 16667)")
-#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
   ("SEIPreferredTransferCharacterisics",              m_preferredTransferCharacteristics,                   -1, "Value for the preferred_transfer_characteristics field of the Alternative transfer characteristics SEI which will override the corresponding entry in the VUI. If negative, do not produce the respective SEI message")
-#endif
+  ("SEIGreenMetadataType",                            m_greenMetadataType,                   0u, "Value for the green_metadata_type specifies the type of metadata that is present in the SEI message. If green_metadata_type is 1, then metadata enabling quality recovery after low-power encoding is present")
+  ("SEIXSDMetricType",                                m_xsdMetricType,                      0u, "Value for the xsd_metric_type indicates the type of the objective quality metric. PSNR is the only type currently supported")
+
 #if NH_MV
   ("SeiCfgFileName_%d",                               m_seiCfgFileNames,             (TChar *) 0 ,MAX_NUM_SEIS , "SEI cfg file name %d")
@@ -1331,9 +1527,8 @@
   ("DWeight",                                         m_iDWeight                , 1                             ,"Depth Distortion weight" )
 #endif //HHI_VSO
+
+#if NH_3D
 /* 3D- HEVC Tools */                                                            
-#if NH_3D_QTL
   ("QTL"                   ,                          m_bUseQTL                 , true                          , "Use depth quad tree limitation (encoder only)" )
-#endif
-#if NH_3D
 
   ("IvMvPredFlag"          ,                          m_ivMvPredFlag            , BoolAry1d(2,true)             , "Inter-view motion prediction"              )
@@ -1355,10 +1550,14 @@
   ("IlluCompEnable"        ,                          m_abUseIC                 , true                          , "Enable illumination compensation"          )
   ("IlluCompLowLatencyEnc" ,                          m_bUseLowLatencyICEnc     , false                         , "Enable low-latency illumination compensation encoding")
-#endif //NH_3D
-    
+#endif //NH_3D    
   ;
 
-#if NH_MV
-  // parse coding structure
+#if EXTENSION_360_VIDEO
+  TExt360AppEncCfg::TExt360AppEncCfgContext ext360CfgContext;
+  m_ext360.addOptions(opts, ext360CfgContext);
+#endif
+
+
+#if NH_MV
   for( Int k = 0; k < MAX_NUM_LAYERS; k++ )
   {
@@ -1414,4 +1613,5 @@
   const list<const TChar*>& argv_unhandled = po::scanArgv(opts, argc, (const TChar**) argv, err);
 
+
   for (list<const TChar*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
@@ -1435,16 +1635,67 @@
   }
 
+#if NH_MV
+  if ( m_layerIdxInVpsToRepFormatIdx.size() == 0 )
+  {
+    m_layerIdxInVpsToRepFormatIdx.push_back( 0 ); 
+#if NH_3D
+    m_layerIdxInVpsToRepFormatIdx.push_back( 1 ); 
+#endif
+  }
+
+  xResizeVector( m_layerIdxInVpsToRepFormatIdx );
+
+  // parse coding structure
+  if ( m_layerIdxInVpsToGopDefIdx.size() == 0 )
+  {
+    for( Int k = 0; k < m_numberOfLayers; k++ )
+    {
+      m_layerIdxInVpsToGopDefIdx.push_back( k );
+    }
+  }
+
+  xConvertRepFormatParameters(
+    tmpPad                       ,             
+    tmpInputBitDepth             ,
+    tmpOutputBitDepth            ,
+    tmpMSBExtendedBitDepth       ,
+    tmpInternalBitDepth          ,
+    tmpInputChromaFormat         ,
+    tmpChromaFormat
+    );
+#endif
   /*
    * Set any derived parameters
    */
+#if NH_MV
+  m_inputFileWidths  = m_iSourceWidths;
+  m_inputFileHeights = m_iSourceHeights;
+#else
+  m_inputFileWidth  = m_iSourceWidth;
+  m_inputFileHeight = m_iSourceHeight;
+#endif
 
   m_framesToBeEncoded = ( m_framesToBeEncoded + m_temporalSubsampleRatio - 1 ) / m_temporalSubsampleRatio;
   m_adIntraLambdaModifier = cfg_adIntraLambdaModifier.values;
+
+#if NH_MV
+  m_iSourceHeightOrgs = m_iSourceHeights;
+#endif
   if(m_isField)
   {
+#if NH_MV
+    //Frame height
+    m_iSourceHeightOrgs = m_iSourceHeights;
+    //Field height
+    for (Int i = 0; i < m_iSourceHeights.size(); i++ )
+    {
+      m_iSourceHeights[i] = m_iSourceHeights[i] >> 1;
+    }
+#else
     //Frame height
     m_iSourceHeightOrg = m_iSourceHeight;
     //Field height
     m_iSourceHeight = m_iSourceHeight >> 1;
+#endif
     //number of fields to encode
     m_framesToBeEncoded *= 2;
@@ -1503,4 +1754,12 @@
   }
 
+#if NH_MV
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    Int* m_MSBExtendedBitDepth   = &m_MSBExtendedBitDepths[i][0];
+    Int* m_internalBitDepth      = &m_internalBitDepths   [i][0];
+    Int* m_outputBitDepth        = &m_outputBitDepths     [i][0];
+    Int* m_inputBitDepth         = &m_inputBitDepths      [i][0];
+#endif
   /* rules for input, output and internal bitdepths as per help text */
   if (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] == 0)
@@ -1533,7 +1792,24 @@
   }
 
+  
+#if NH_MV
+  }
   m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat);
+#endif
+
+
+#if NH_MV
+  std::vector<ChromaFormat> tempChromaFormatIdc = numberToChromaFormat(tmpChromaFormat);
+  for(Int i = 0 ; i < m_InputChromaFormatIDC.size(); i++)
+  {
+    m_chromaFormatIDCs.push_back( ((tmpChromaFormat[i] == 0) ? (m_InputChromaFormatIDC[i]) : tempChromaFormatIdc[i] ) );
+  }
+#else
   m_chromaFormatIDC      = ((tmpChromaFormat == 0) ? (m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat)));
-
+#endif
+
+#if EXTENSION_360_VIDEO
+  m_ext360.processOptions(ext360CfgContext);
+#endif
 
   assert(tmpWeightedPredictionMethod>=0 && tmpWeightedPredictionMethod<=WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT_AND_CLIPPING_AND_EXTENSION);
@@ -1558,6 +1834,6 @@
   m_motionEstimationSearchMethod=MESearchMethod(tmpMotionEstimationSearchMethod);
 
-#if NH_MV
-  // parse PTL
+#if NH_MV 
+
   Bool anyEmpty = false; 
   if( cfg_profiles.empty() )
@@ -1602,117 +1878,185 @@
   }
 
-  xReadStrToEnum( cfg_profiles, extendedProfiles  ); 
+  xReadStrToEnum( cfg_profiles, m_uiProfiles  ); 
   xReadStrToEnum( cfg_levels,   m_level     ); 
   xReadStrToEnum( cfg_tiers ,   m_levelTier ); 
-
-
-#if NH_MV
-  m_profiles.resize( extendedProfiles.size()); 
-
-  for (Int i = 0; i < m_profiles.size(); i++)
-  {
-    Profile::Name& m_profile             = m_profiles      [i];  
-    ExtendedProfileName& extendedProfile = extendedProfiles[i];  
-#endif
-#endif
-
-  if (extendedProfile >= 1000 && extendedProfile <= 12316)
-    {
+   
+#else
+    switch (UIProfile)
+    {
+    case UI_NONE:
+      m_profile = Profile::NONE;
+      m_onePictureOnlyConstraintFlag = false;
+      break;
+    case UI_MAIN:
+      m_profile = Profile::MAIN;
+      m_onePictureOnlyConstraintFlag = false;
+      break;
+    case UI_MAIN10:
+      m_profile = Profile::MAIN10;
+      m_onePictureOnlyConstraintFlag = false;
+      break;
+    case UI_MAINSTILLPICTURE:
+      m_profile = Profile::MAINSTILLPICTURE;
+      m_onePictureOnlyConstraintFlag = false;
+      break;
+    case UI_MAIN10_STILL_PICTURE:
+      m_profile = Profile::MAIN10;
+      m_onePictureOnlyConstraintFlag = true;
+      break;
+    case UI_MAINREXT:
       m_profile = Profile::MAINREXT;
-      if (m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
-      {
-        fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
-        exit(EXIT_FAILURE);
-      }
-      m_bitDepthConstraint     = (extendedProfile%100);
-    m_intraConstraintFlag          = ((extendedProfile%10000)>=2000);
-    m_onePictureOnlyConstraintFlag = (extendedProfile >= 10000);
-      switch ((extendedProfile/100)%10)
-      {
-      case 0:  tmpConstraintChromaFormat=400; break;
-      case 1:  tmpConstraintChromaFormat=420; break;
-      case 2:  tmpConstraintChromaFormat=422; break;
-      default: tmpConstraintChromaFormat=444; break;
-      }
-    }
-    else
-    {
-      m_profile = Profile::Name(extendedProfile);
-    }
-
-    if (m_profile == Profile::HIGHTHROUGHPUTREXT )
-    {
-      if (m_bitDepthConstraint == 0)
-      {
-        m_bitDepthConstraint = 16;
-      }
-      m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
-    }
-    else if (m_profile == Profile::MAINREXT)
-    {
-      if (m_bitDepthConstraint == 0 && tmpConstraintChromaFormat == 0)
-      {
-        // produce a valid combination, if possible.
-      const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
-                                           m_transformSkipContextEnabledFlag         ||
-                                           m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ||
-                                           m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ||
-          !m_enableIntraReferenceSmoothing         ||
-                                           m_persistentRiceAdaptationEnabledFlag     ||
-                                           m_log2MaxTransformSkipBlockSize!=2;
-      const Bool bUsingChromaQPAdjustment= m_diffCuChromaQpOffsetDepth >= 0;
-      const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
-      if (m_onePictureOnlyConstraintFlag)
-      {
-        m_chromaFormatConstraint = CHROMA_444;
-        if (m_intraConstraintFlag != true)
+      m_onePictureOnlyConstraintFlag = false;
+      break;
+    case UI_HIGHTHROUGHPUTREXT:
+      m_profile = Profile::HIGHTHROUGHPUTREXT;
+      m_onePictureOnlyConstraintFlag = false;
+      break;
+    default:
+      if (UIProfile >= 1000 && UIProfile <= 12316)
+      {
+        m_profile = Profile::MAINREXT;
+        if (m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
         {
-          fprintf(stderr, "Error: Intra constraint flag must be true when one_picture_only_constraint_flag is true\n");
+          fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
           exit(EXIT_FAILURE);
         }
-        const Int maxBitDepth = m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
-        m_bitDepthConstraint = maxBitDepth>8 ? 16:8;
+        m_bitDepthConstraint           = (UIProfile%100);
+        m_intraConstraintFlag          = ((UIProfile%10000)>=2000);
+        m_onePictureOnlyConstraintFlag = (UIProfile >= 10000);
+        switch ((UIProfile/100)%10)
+        {
+        case 0:  tmpConstraintChromaFormat=400; break;
+        case 1:  tmpConstraintChromaFormat=420; break;
+        case 2:  tmpConstraintChromaFormat=422; break;
+        default: tmpConstraintChromaFormat=444; break;
+        }
+      }
+      else if (UIProfile >= 21308 && UIProfile <= 22316)
+      {
+        m_profile = Profile::HIGHTHROUGHPUTREXT;
+        if (m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
+        {
+          fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
+          exit(EXIT_FAILURE);
+        }
+        m_bitDepthConstraint           = (UIProfile%100);
+        m_intraConstraintFlag          = ((UIProfile%10000)>=2000);
+        m_onePictureOnlyConstraintFlag = 0;
+        if((UIProfile == UI_HIGHTHROUGHPUT_444) || (UIProfile == UI_HIGHTHROUGHPUT_444_10) )
+        {
+          assert(m_cabacBypassAlignmentEnabledFlag==0);
+        }
+        switch ((UIProfile/100)%10)
+        {
+        case 0:  tmpConstraintChromaFormat=400; break;
+        case 1:  tmpConstraintChromaFormat=420; break;
+        case 2:  tmpConstraintChromaFormat=422; break;
+        default: tmpConstraintChromaFormat=444; break;
+        }
       }
       else
       {
-        m_chromaFormatConstraint = NUM_CHROMA_FORMAT;
-        automaticallySelectRExtProfile(bUsingGeneralRExtTools,
-          bUsingChromaQPAdjustment,
-          bUsingExtendedPrecision,
-          m_intraConstraintFlag,
-          m_bitDepthConstraint,
-          m_chromaFormatConstraint,
-          m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]),
-          m_chromaFormatIDC);
-      }
-    }
-      else if (m_bitDepthConstraint == 0 || tmpConstraintChromaFormat == 0)
-      {
-        fprintf(stderr, "Error: The bit depth and chroma format constraints must either both be specified or both be configured automatically\n");
+        fprintf(stderr, "Error: Unprocessed UI profile\n");
+        assert(0);
         exit(EXIT_FAILURE);
       }
-      else
-      {
-        m_chromaFormatConstraint = numberToChromaFormat(tmpConstraintChromaFormat);
-      }
-    }
-    else
-    {
+      break;
+    }
+
+    switch (m_profile)
+    {
+    case Profile::HIGHTHROUGHPUTREXT:
+      {
+        if (m_bitDepthConstraint == 0)
+        {
+          m_bitDepthConstraint = 16;
+        }
+        m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
+      }
+      break;
+    case Profile::MAINREXT:
+
+      {
+        if (m_bitDepthConstraint == 0 && tmpConstraintChromaFormat == 0)
+        {
+          // produce a valid combination, if possible.
+          const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
+            m_transformSkipContextEnabledFlag         ||
+            m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ||
+            m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ||
+            !m_enableIntraReferenceSmoothing         ||
+            m_persistentRiceAdaptationEnabledFlag     ||
+            m_log2MaxTransformSkipBlockSize!=2;
+          const Bool bUsingChromaQPAdjustment= m_diffCuChromaQpOffsetDepth >= 0;
+          const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
+          if (m_onePictureOnlyConstraintFlag)
+          {
+            m_chromaFormatConstraint = CHROMA_444;
+            if (m_intraConstraintFlag != true)
+            {
+              fprintf(stderr, "Error: Intra constraint flag must be true when one_picture_only_constraint_flag is true\n");
+              exit(EXIT_FAILURE);
+            }
+            const Int maxBitDepth = m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+            m_bitDepthConstraint = maxBitDepth>8 ? 16:8;
+          }
+          else
+          {
+            m_chromaFormatConstraint = NUM_CHROMA_FORMAT;
+            automaticallySelectRExtProfile(bUsingGeneralRExtTools,
+              bUsingChromaQPAdjustment,
+              bUsingExtendedPrecision,
+              m_intraConstraintFlag,
+              m_bitDepthConstraint,
+              m_chromaFormatConstraint,
+              m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]),
+              m_chromaFormatIDC);
+          }
+        }
+        else if (m_bitDepthConstraint == 0 || tmpConstraintChromaFormat == 0)
+        {
+          fprintf(stderr, "Error: The bit depth and chroma format constraints must either both be specified or both be configured automatically\n");
+          exit(EXIT_FAILURE);
+        }
+        else
+        {
+          m_chromaFormatConstraint = numberToChromaFormat(tmpConstraintChromaFormat);
+        }
+      }
+      break;
+    case Profile::MAIN:
+    case Profile::MAIN10:
+    case Profile::MAINSTILLPICTURE:
       m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? m_chromaFormatIDC : numberToChromaFormat(tmpConstraintChromaFormat);
       m_bitDepthConstraint = (m_profile == Profile::MAIN10?10:8);
-    }
-#if NH_MV
-  }
-
-  if ( m_numberOfLayers != 0 && ( m_profiles[0] != Profile::MAIN || m_profiles[1] != Profile::MAIN )  )
-  {
-    fprintf(stderr, "Error: The base layer must conform to the Main profile for Multilayer coding.\n");
-    exit(EXIT_FAILURE);
-  }
-#endif
-
+      break;
+    case Profile::NONE:
+      m_chromaFormatConstraint = m_chromaFormatIDC;
+      m_bitDepthConstraint = m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+      break;
+    default:
+      fprintf(stderr, "Unknown profile selected\n");
+      exit(EXIT_FAILURE);
+      break;
+    }
+#endif
 
   m_inputColourSpaceConvert = stringToInputColourSpaceConvert(inputColourSpaceConvert, true);
 
+
+#if NH_MV
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    Int*          m_aiPad            = &m_aiPads[i][0];
+    ChromaFormat &m_chromaFormatIDC  = m_chromaFormatIDCs [i];
+    Int          &m_confWinRight     = m_confWinRights    [i];
+    Int          &m_confWinBottom    = m_confWinBottoms   [i];
+    Int          &m_confWinLeft      = m_confWinLefts     [i];
+    Int          &m_confWinTop       = m_confWinTops      [i];
+    Int          &m_iSourceHeight    = m_iSourceHeights   [i];
+    Int          &m_iSourceWidth     = m_iSourceWidths    [i];
+    Int          &m_iSourceHeightOrg = m_iSourceHeightOrgs[i];
+#endif
   switch (m_conformanceWindowMode)
   {
@@ -1779,4 +2123,7 @@
     }
   }
+#if NH_MV
+  }
+#endif
 
   if (tmpSliceMode<0 || tmpSliceMode>=Int(NUMBER_OF_SLICE_CONSTRAINT_MODES))
@@ -1837,5 +2184,14 @@
   xResizeVector( m_depthFlag ); 
 #endif
+
+#if JVET_E0059_FLOATING_POINT_QP_FIX  
+  if ( !m_qpIncrementAtSourceFrame.empty() )
+  {
+    xResizeVector( m_qpIncrementAtSourceFrame );
+  }
+  xResizeVector( m_iQP ); 
+#else
   xResizeVector( m_fQP ); 
+#endif
 
   for( Int layer = 0; layer < m_numberOfLayers; layer++ )
@@ -1844,4 +2200,21 @@
     ::memset( m_aidQP[layer], 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
 
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+    if ( !m_qpIncrementAtSourceFrame.empty() )
+    {
+      UInt switchingPOC=0;
+      if (m_qpIncrementAtSourceFrame[layer] > m_FrameSkip)
+      {
+        // if switch source frame (ssf) = 10, and frame skip (fs)=2 and temporal subsample ratio (tsr) =1, then
+        //    for this simulation switch at POC 8 (=10-2).
+        // if ssf=10, fs=2, tsr=2, then for this simulation, switch at POC 4 (=(10-2)/2): POC0=Src2, POC1=Src4, POC2=Src6, POC3=Src8, POC4=Src10
+        switchingPOC = (m_qpIncrementAtSourceFrame[layer] - m_FrameSkip) / m_temporalSubsampleRatio;
+      }
+      for(UInt i=switchingPOC; i<( m_framesToBeEncoded + m_iGOPSize + 1 ); i++)
+      {
+        m_aidQP[layer][i]=1;
+      }
+    }
+#else
     // handling of floating-point QP values
     // if QP is not integer, sequence is split into two sections having QP and QP+1
@@ -1857,4 +2230,5 @@
       }
     }
+#endif
 
     for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
@@ -1862,7 +2236,12 @@
       if (saoOffsetBitShift[ch]<0)
       {
+#if NH_MV
+        Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[ layer ];
+        if (m_internalBitDepths[repFormatIdx][ch]>10)
+#else
         if (m_internalBitDepth[ch]>10)
+#endif
         {
-          m_log2SaoOffsetScale[layer][ch]=UInt(Clip3<Int>(0, m_internalBitDepth[ch]-10, Int(m_internalBitDepth[ch]-10 + 0.165*m_iQP[layer] - 3.22 + 0.5) ) );
+          m_log2SaoOffsetScale[layer][ch]=UInt(Clip3<Int>(0, m_internalBitDepths[repFormatIdx][ch]-10, Int(m_internalBitDepths[repFormatIdx][ch]-10 + 0.165*m_iQP[layer] - 3.22 + 0.5) ) );
         }
         else
@@ -1893,4 +2272,21 @@
   ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
 
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+  if (m_qpIncrementAtSourceFrame.bPresent)
+  {
+    UInt switchingPOC=0;
+    if (m_qpIncrementAtSourceFrame.value > m_FrameSkip)
+    {
+      // if switch source frame (ssf) = 10, and frame skip (fs)=2 and temporal subsample ratio (tsr) =1, then
+      //    for this simulation switch at POC 8 (=10-2).
+      // if ssf=10, fs=2, tsr=2, then for this simulation, switch at POC 4 (=(10-2)/2): POC0=Src2, POC1=Src4, POC2=Src6, POC3=Src8, POC4=Src10
+      switchingPOC = (m_qpIncrementAtSourceFrame.value - m_FrameSkip) / m_temporalSubsampleRatio;
+    }
+    for(UInt i=switchingPOC; i<( m_framesToBeEncoded + m_iGOPSize + 1 ); i++)
+    {
+      m_aidQP[i]=1;
+    }
+  }
+#else
   // handling of floating-point QP values
   // if QP is not integer, sequence is split into two sections having QP and QP+1
@@ -1906,4 +2302,5 @@
     }
   }
+#endif
 
   for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
@@ -1927,4 +2324,21 @@
 
 #endif
+
+  assert(lumaLevelToDeltaQPMode<LUMALVL_TO_DQP_NUM_MODES);
+  if (lumaLevelToDeltaQPMode>=LUMALVL_TO_DQP_NUM_MODES)
+  {
+    exit(EXIT_FAILURE);
+  }
+  m_lumaLevelToDeltaQPMapping.mode=LumaLevelToDQPMode(lumaLevelToDeltaQPMode);
+
+  if (m_lumaLevelToDeltaQPMapping.mode)
+  {
+    assert(  cfg_lumaLeveltoDQPMappingLuma.values.size() == cfg_lumaLeveltoDQPMappingQP.values.size() );
+    m_lumaLevelToDeltaQPMapping.mapping.resize(cfg_lumaLeveltoDQPMappingLuma.values.size());
+    for(UInt i=0; i<cfg_lumaLeveltoDQPMappingLuma.values.size(); i++)
+    {
+      m_lumaLevelToDeltaQPMapping.mapping[i]=std::pair<Int,Int>(cfg_lumaLeveltoDQPMappingLuma.values[i], cfg_lumaLeveltoDQPMappingQP.values[i]);
+    }
+  }
 
   // reading external dQP description from file
@@ -2070,9 +2484,10 @@
     m_dLambdaScaleVSO *= adLambdaScaleTable[m_iQP[firstDepthLayer]]; 
   }
+
   if ( m_bUseVSO && m_uiVSOMode == 4)
   {
     m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig );
     m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
-      m_internalBitDepth[ CHANNEL_TYPE_LUMA],
+      m_internalBitDepths[0][ CHANNEL_TYPE_LUMA],
       (UInt)m_iCodedCamParPrecision,
       m_FrameSkip,
@@ -2087,5 +2502,5 @@
   {
     m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
-      m_internalBitDepth[ CHANNEL_TYPE_LUMA],
+      m_internalBitDepths[0][ CHANNEL_TYPE_LUMA],
       (UInt)m_iCodedCamParPrecision,
       m_FrameSkip,
@@ -2102,5 +2517,5 @@
   {
     m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
-      m_internalBitDepth[ CHANNEL_TYPE_LUMA],
+      m_internalBitDepths[0][ CHANNEL_TYPE_LUMA],
       (UInt) m_iCodedCamParPrecision,
       m_FrameSkip,
@@ -2125,5 +2540,14 @@
   }
 
-  m_uiMaxTotalCUDepth = m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_chromaFormatIDC, m_uiQuadtreeTULog2MinSize); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.
+
+#if NH_MV
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    m_uiMaxTotalCUDepth               .push_back( m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_chromaFormatIDCs[i], m_uiQuadtreeTULog2MinSize) ); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.    
+  }
+#else
+  m_uiMaxTotalCUDepth = m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_chromaFormatIDC, m_uiQuadtreeTULog2MinSize); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.  
+#endif
+
   m_uiLog2DiffMaxMinCodingBlockSize = m_uiMaxCUDepth - 1;
 
@@ -2134,8 +2558,439 @@
 }
 
+#if NH_MV
+Void TAppEncCfg::xDeriveProfAndConstrFlags( const TComVPS& vps )
+{
+
+  UInt numPtl = (Int) m_uiProfiles.size();
+  m_profiles.resize( numPtl );
+  m_chromaFormatConstraints.resize( m_uiProfiles.size() );
+  
+  xResizeVector( m_onePictureOnlyConstraintFlags , numPtl );
+  xResizeVector( m_bitDepthConstraints           , numPtl );
+  xResizeVector( m_frameOnlyConstraintFlags      , numPtl );
+  xResizeVector( m_nonPackedConstraintFlags      , numPtl );
+  xResizeVector( m_intraConstraintFlags          , numPtl );  
+  xResizeVector( m_interlacedSourceFlags         , numPtl );
+  xResizeVector( m_progressiveSourceFlags        , numPtl );
+  xResizeVector( m_lowerBitRateConstraintFlags   , numPtl );
+  xResizeVector( m_tmpConstraintChromaFormats    , numPtl );
+
+  for (Int i = 0; i < m_profiles.size(); i++)
+  { 
+    UIProfileName UIProfile = m_uiProfiles[i];
+
+    ChromaFormat maxChromaFormatIdc       ;
+    Int          maxInternalBitDepthLuma  ;
+    Int          maxInternalBitDepthChroma;
+    Int          maxNumRefLayers          ;
+
+    xGetMaxValuesOfApplicableLayers(vps, i, maxInternalBitDepthLuma,maxInternalBitDepthChroma, maxChromaFormatIdc, maxNumRefLayers );
+
+    switch ( UIProfile )
+    {
+    case UI_MULTIVIEWMAIN:
+      m_profiles[i] = Profile::MULTIVIEWMAIN;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+#if NH_3D
+    case UI_MAIN3D:
+      m_profiles[i] = Profile::MAIN3D;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+#endif
+    case UI_NONE:
+      m_profiles[i] = Profile::NONE;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+    case UI_MAIN:
+      m_profiles[i] = Profile::MAIN;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+    case UI_MAIN10:
+      m_profiles[i] = Profile::MAIN10;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+    case UI_MAINSTILLPICTURE:
+      m_profiles[i] = Profile::MAINSTILLPICTURE;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+    case UI_MAIN10_STILL_PICTURE:
+      m_profiles[i] = Profile::MAIN10;
+      m_onePictureOnlyConstraintFlags[i] = true;
+      break;
+    case UI_MAINREXT:
+      m_profiles[i] = Profile::MAINREXT;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+    case UI_HIGHTHROUGHPUTREXT:
+      m_profiles[i] = Profile::HIGHTHROUGHPUTREXT;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+#if NH_MV_ALLOW_NON_CONFORMING
+    case UI_MULTIVIEWMAIN_NONCONF:
+      m_profiles[i] = Profile::MULTIVIEWMAIN_NONCONFORMING;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+#if NH_3D
+    case UI_MAIN3D_NONCONF:
+      m_profiles[i] = Profile::MAIN3D_NONCONFORMING;
+      m_onePictureOnlyConstraintFlags[i] = false;
+      break;
+#endif
+#endif
+
+    default:
+      if (UIProfile >= 1000 && UIProfile <= 12316)
+      {
+        m_profiles[i] = Profile::MAINREXT;
+        if (m_bitDepthConstraints[i] != 0 || m_tmpConstraintChromaFormats[i] != 0)
+        {
+          fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
+          exit(EXIT_FAILURE);
+        }
+        m_bitDepthConstraints[i]           = (UIProfile%100);
+        m_intraConstraintFlags[i]          = ((UIProfile%10000)>=2000);
+        m_onePictureOnlyConstraintFlags[i] = (UIProfile >= 10000);
+        switch ((UIProfile/100)%10)
+        {
+        case 0:  m_tmpConstraintChromaFormats[i]=400; break;
+        case 1:  m_tmpConstraintChromaFormats[i]=420; break;
+        case 2:  m_tmpConstraintChromaFormats[i]=422; break;
+        default: m_tmpConstraintChromaFormats[i]=444; break;
+        }
+      }
+      else if (UIProfile >= 21308 && UIProfile <= 22316)
+      {
+        m_profiles[i] = Profile::HIGHTHROUGHPUTREXT;
+        if (m_bitDepthConstraints[i] != 0 || m_tmpConstraintChromaFormats[i] != 0)
+        {
+          fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
+          exit(EXIT_FAILURE);
+        }
+        m_bitDepthConstraints[i]           = (UIProfile%100);
+        m_intraConstraintFlags[i]          = ((UIProfile%10000)>=2000);
+        m_onePictureOnlyConstraintFlags[i] = 0;
+        if((UIProfile == UI_HIGHTHROUGHPUT_444) || (UIProfile == UI_HIGHTHROUGHPUT_444_10) )
+        {
+          assert(m_cabacBypassAlignmentEnabledFlag==0);
+        }
+        switch ((UIProfile/100)%10)
+        {
+        case 0:  m_tmpConstraintChromaFormats[i]=400; break;
+        case 1:  m_tmpConstraintChromaFormats[i]=420; break;
+        case 2:  m_tmpConstraintChromaFormats[i]=422; break;
+        default: m_tmpConstraintChromaFormats[i]=444; break;
+        }
+      }
+      else
+      {
+        fprintf(stderr, "Error: Unprocessed UI profile\n");
+        assert(0);
+        exit(EXIT_FAILURE);
+      }
+      break;
+    }
+
+    switch (m_profiles[i])
+    {
+    case Profile::HIGHTHROUGHPUTREXT:
+      {
+        if (m_bitDepthConstraints[i] == 0)
+        {
+          m_bitDepthConstraints[i] = 16;
+        }
+        m_chromaFormatConstraints[i] = (m_tmpConstraintChromaFormats[i] == 0) ? CHROMA_444 : numberToChromaFormat(m_tmpConstraintChromaFormats[i]);
+      }
+      break;
+    case Profile::MAINREXT:
+
+      {
+        if (m_bitDepthConstraints[i] == 0 && m_tmpConstraintChromaFormats[i] == 0)
+        {
+          // produce a valid combination, if possible.
+          const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
+            m_transformSkipContextEnabledFlag         ||
+            m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ||
+            m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ||
+            !m_enableIntraReferenceSmoothing         ||
+            m_persistentRiceAdaptationEnabledFlag     ||
+            m_log2MaxTransformSkipBlockSize!=2;
+          const Bool bUsingChromaQPAdjustment= m_diffCuChromaQpOffsetDepth >= 0;
+          const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
+          if (m_onePictureOnlyConstraintFlags[i])
+          {
+            m_chromaFormatConstraints[i] = CHROMA_444;
+            if (m_intraConstraintFlags[i] != true)
+            {
+              fprintf(stderr, "Error: Intra constraint flag must be true when one_picture_only_constraint_flag is true\n");
+              exit(EXIT_FAILURE);
+            }
+            const Int maxBitDepth = maxChromaFormatIdc==CHROMA_400 ? maxInternalBitDepthLuma : std::max( maxInternalBitDepthLuma, maxInternalBitDepthChroma);
+            m_bitDepthConstraints[i] = maxBitDepth>8 ? 16:8;
+          }
+          else
+          {
+            m_chromaFormatConstraints[i] = NUM_CHROMA_FORMAT;
+
+            UInt tempBitDepthConstraint = (UInt) m_bitDepthConstraints[i];
+
+            automaticallySelectRExtProfile(bUsingGeneralRExtTools,
+              bUsingChromaQPAdjustment,
+              bUsingExtendedPrecision,
+              m_intraConstraintFlags[i],
+              tempBitDepthConstraint,
+              m_chromaFormatConstraints[i],
+              maxChromaFormatIdc==CHROMA_400 ? maxInternalBitDepthLuma : std::max(maxInternalBitDepthLuma, maxInternalBitDepthChroma),
+              maxChromaFormatIdc);
+
+            m_bitDepthConstraints[i] = (Int) tempBitDepthConstraint;
+          }
+        }
+        else if (m_bitDepthConstraints[i] == 0 || m_tmpConstraintChromaFormats[i] == 0)
+        {
+          fprintf(stderr, "Error: The bit depth and chroma format constraints must either both be specified or both be configured automatically\n");
+          exit(EXIT_FAILURE);
+        }
+        else
+        {
+          m_chromaFormatConstraints[i] = numberToChromaFormat(m_tmpConstraintChromaFormats[i]);
+        }
+      }
+      break;
+    case Profile::MAIN:
+    case Profile::MAIN10:
+    case Profile::MAINSTILLPICTURE:
+      m_chromaFormatConstraints[i] = (m_tmpConstraintChromaFormats[i] == 0) ? maxChromaFormatIdc : numberToChromaFormat(m_tmpConstraintChromaFormats[i]);
+      m_bitDepthConstraints[i] = (m_profiles[i] == Profile::MAIN10?10:8);
+      break;
+#if NH_MV_ALLOW_NON_CONFORMING
+    case Profile::MULTIVIEWMAIN_NONCONFORMING:
+#if NH_3D
+    case Profile::MAIN3D_NONCONFORMING:
+#endif
+#endif
+    case Profile::NONE:
+
+      m_chromaFormatConstraints[i] = maxChromaFormatIdc;
+      m_bitDepthConstraints[i]     = maxChromaFormatIdc==CHROMA_400 ? maxInternalBitDepthLuma : std::max(maxInternalBitDepthLuma, maxInternalBitDepthChroma);
+      break;
+    case Profile::MULTIVIEWMAIN:
+      m_chromaFormatConstraints[i] = CHROMA_420;
+      m_bitDepthConstraints[i]     = 8;
+      break;
+
+#if NH_3D
+    case Profile::MAIN3D:
+      // Here depth layers could use a different ptl struct. 
+      // For simplicity, depth and texture share currently the same.
+      m_chromaFormatConstraints[i] = CHROMA_420;
+      m_bitDepthConstraints[i]     = 8;
+      break;
+#endif
+    default:
+      fprintf(stderr, "Unknown profile selected\n");
+      exit(EXIT_FAILURE);
+      break;
+    }
+  }
+}
+#endif
 
 // ====================================================================================================================
 // Private member functions
 // ====================================================================================================================
+
+#if NH_MV
+Void TAppEncCfg::xCheckProfiles( const TComVPS& vps )
+{
+  Bool check_failed = false; 
+
+
+#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
+
+  // TBD: disallow 3D tools when 3D Main profile is not used.
+
+  for (Int i = 0; i < m_profiles.size(); i++ )
+  {
+    ChromaFormat maxChromaFormatIdc; 
+    Int          maxBitDepthLuma   ;
+    Int          maxBitDepthChroma ;
+    Int          maxNumRefLayers   ;
+
+    xGetMaxValuesOfApplicableLayers(vps, i, maxBitDepthLuma, maxBitDepthChroma , maxChromaFormatIdc, maxNumRefLayers );
+
+    const UInt maxBitDepth=(maxChromaFormatIdc==CHROMA_400) ? maxBitDepthLuma : std::max(maxBitDepthLuma, maxBitDepthChroma);
+
+    xConfirmPara(m_bitDepthConstraints    [i] < maxBitDepth       , "The internalBitDepth must not be greater than the bitDepthConstraint value"      );
+    xConfirmPara(m_chromaFormatConstraints[i] < maxChromaFormatIdc, "The chroma format used must not be greater than the chromaFormatConstraint value");
+
+    switch (m_profiles[i] )
+    {
+    case Profile::MAINREXT:
+    case Profile::HIGHTHROUGHPUTREXT:
+
+      {
+        xConfirmPara(m_lowerBitRateConstraintFlags[i] == false  &&  m_intraConstraintFlags[i] == false                        , "The lowerBitRateConstraint flag cannot be false when intraConstraintFlag is false");
+        xConfirmPara(m_cabacBypassAlignmentEnabledFlag          &&              m_profiles[i] != Profile::HIGHTHROUGHPUTREXT  , "AlignCABACBeforeBypass must not be enabled unless the high throughput profile is being used.");
+
+        if (m_profiles[i] == Profile::MAINREXT)
+        {
+          const UInt intraIdx        = m_intraConstraintFlags[i] ? 1:0;
+          const UInt bitDepthIdx     = (m_bitDepthConstraints[i] == 8 ? 0 : (m_bitDepthConstraints[i] ==10 ? 1 : (m_bitDepthConstraints[i] == 12 ? 2 : (m_bitDepthConstraints[i] == 16 ? 3 : 4 ))));
+          const UInt chromaFormatIdx = UInt(m_chromaFormatConstraints[i]);
+          const Bool bValidProfile   = (bitDepthIdx > 3 || chromaFormatIdx>3) ? false : (validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx] != UI_NONE);
+
+          xConfirmPara(!bValidProfile, "Invalid intra constraint flag, bit depth constraint flag and chroma format constraint flag combination for a RExt profile");
+          const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag   ||
+            m_transformSkipContextEnabledFlag                                       ||
+            m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT]                               ||
+            m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT]                               ||
+            !m_enableIntraReferenceSmoothing                                        ||
+            m_persistentRiceAdaptationEnabledFlag                                   ||
+            m_log2MaxTransformSkipBlockSize!=2;
+          const Bool bUsingChromaQPTool      = m_diffCuChromaQpOffsetDepth >= 0;
+          const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
+
+          xConfirmPara((m_chromaFormatConstraints[i]==CHROMA_420 || m_chromaFormatConstraints[i]==CHROMA_400) && bUsingChromaQPTool, "CU Chroma QP adjustment cannot be used for 4:0:0 or 4:2:0 RExt profiles");
+          xConfirmPara(m_bitDepthConstraints[i] != 16 && bUsingExtendedPrecision, "Extended precision can only be used in 16-bit RExt profiles");
+          if (!(m_chromaFormatConstraints[i] == CHROMA_400 && m_bitDepthConstraints[i] == 16) && m_chromaFormatConstraints[i]!=CHROMA_444)
+          {
+            xConfirmPara(bUsingGeneralRExtTools, "Combination of tools and profiles are not possible in the specified RExt profile.");
+          }
+          xConfirmPara( m_onePictureOnlyConstraintFlags[i] && m_chromaFormatConstraints[i]!=CHROMA_444, "chroma format constraint must be 4:4:4 when one-picture-only constraint flag is 1");
+          xConfirmPara( m_onePictureOnlyConstraintFlags[i] && m_bitDepthConstraints[i] != 8 && m_bitDepthConstraints[i] != 16, "bit depth constraint must be 8 or 16 when one-picture-only constraint flag is 1");
+          xConfirmPara( m_onePictureOnlyConstraintFlags[i] && m_framesToBeEncoded > 1, "Number of frames to be encoded must be 1 when one-picture-only constraint flag is 1.");
+
+          if (!m_intraConstraintFlags[i] && m_bitDepthConstraints[i]==16 && m_chromaFormatConstraints[i]==CHROMA_444)
+          {
+            fprintf(stderr, "********************************************************************************************************\n");
+            fprintf(stderr, "** WARNING: The RExt constraint flags describe a non standard combination (used for development only) **\n");
+            fprintf(stderr, "********************************************************************************************************\n");
+          }
+        }
+        else
+        {
+          xConfirmPara( m_chromaFormatConstraints[i] != CHROMA_444, "chroma format constraint must be 4:4:4 in the High Throughput 4:4:4 16-bit Intra profile.");
+          const UInt intraIdx      =   m_intraConstraintFlags[i]     ? 1     : 0;
+          const UInt bitDepthIdx   = ( m_bitDepthConstraints[i] == 8 ? 0     : (m_bitDepthConstraints[i] == 10 ? 1 : (m_bitDepthConstraints[i] == 14 ? 2 : (m_bitDepthConstraints[i] == 16 ? 3 : 4 ))));
+          const Bool bValidProfile = ( bitDepthIdx > 3)              ? false : (validRExtHighThroughPutProfileNames[intraIdx][bitDepthIdx] != UI_NONE);
+          xConfirmPara(!bValidProfile, "Invalid intra constraint flag and bit depth constraint flag combination for a RExt high profile throughput profile");
+          if(bitDepthIdx < 2)
+          {
+            xConfirmPara((m_extendedPrecisionProcessingFlag || m_cabacBypassAlignmentEnabledFlag), "Invalid configuration for a RExt high throughput 8 and 10 bit profile");
+          }
+          if(bitDepthIdx == 3)
+          {
+            xConfirmPara(!m_cabacBypassAlignmentEnabledFlag, "Cabac Bypass Alignment flag must be 1 in the High Throughput 4:4:4 16-bit Intra profile");
+          }
+          else if(bitDepthIdx < 3)
+          {
+            xConfirmPara(!m_entropyCodingSyncEnabledFlag, "WPP flag must be 1 in the High Throughput 4:4:4 non 16-bit Intra profile");
+          }
+        }
+      }
+      break;
+    case Profile::MAIN:
+    case Profile::MAIN10:
+    case Profile::MAINSTILLPICTURE:
+    case Profile::MULTIVIEWMAIN:
+#if NH_3D
+    case Profile::MAIN3D:
+#endif
+      {
+        xConfirmPara(m_bitDepthConstraints        [i] != ((m_profiles[i]==Profile::MAIN10)?10:8), "BitDepthConstraint must be 8 for MAIN profile, Multiview main profile, and 3D Main profile and 10 for MAIN10 profile.");
+#if NH_3D
+        if (m_profiles[i] == Profile::MAIN3D )
+        {
+          xConfirmPara(m_chromaFormatConstraints    [i] != CHROMA_420 && m_chromaFormatConstraints    [i] != CHROMA_400   , "ChromaFormatConstraint must be 420 or 400 for the 3D main profile.");
+        }
+        else
+#endif
+        {
+          xConfirmPara(m_chromaFormatConstraints    [i] != CHROMA_420   , "ChromaFormatConstraint must be 420 for non main-RExt profiles.");
+        }
+       
+        xConfirmPara(m_intraConstraintFlags       [i] == true         , "IntraConstraintFlag must be false for non main_RExt profiles.");
+        xConfirmPara(m_lowerBitRateConstraintFlags[i] == false        , "LowerBitrateConstraintFlag must be true for non main-RExt profiles.");
+        xConfirmPara(m_profiles[i] == Profile::MAINSTILLPICTURE && m_framesToBeEncoded > 1, "Number of frames to be encoded must be 1 when main still picture profile is used.");
+
+        xConfirmPara(m_crossComponentPredictionEnabledFlag    == true , "CrossComponentPrediction must not be used for non main-RExt profiles.");
+        xConfirmPara(m_log2MaxTransformSkipBlockSize          != 2    , "Transform Skip Log2 Max Size must be 2 for V1 profiles.");
+        xConfirmPara(m_transformSkipRotationEnabledFlag       == true , "UseResidualRotation must not be enabled for non main-RExt profiles.");
+        xConfirmPara(m_transformSkipContextEnabledFlag        == true , "UseSingleSignificanceMapContext must not be enabled for non main-RExt profiles.");
+        xConfirmPara(m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT]== true , "ImplicitResidualDPCM must not be enabled for non main-RExt profiles.");
+        xConfirmPara(m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT]== true , "ExplicitResidualDPCM must not be enabled for non main-RExt profiles.");
+        xConfirmPara(m_persistentRiceAdaptationEnabledFlag    == true , "GolombRiceParameterAdaption must not be enabled for non main-RExt profiles.");
+        xConfirmPara(m_extendedPrecisionProcessingFlag        == true , "UseExtendedPrecision must not be enabled for non main-RExt profiles.");
+        xConfirmPara(m_highPrecisionOffsetsEnabledFlag        == true , "UseHighPrecisionPredictionWeighting must not be enabled for non main-RExt profiles.");
+        xConfirmPara(m_enableIntraReferenceSmoothing          == false, "EnableIntraReferenceSmoothing must be enabled for non main-RExt profiles.");
+        xConfirmPara(m_cabacBypassAlignmentEnabledFlag                , "AlignCABACBeforeBypass cannot be enabled for non main-RExt profiles.");
+
+        if ( m_profiles[i] == Profile::MULTIVIEWMAIN )
+        {
+          xConfirmPara( maxNumRefLayers > 4, "When using the MV-Main profile, NumRefLayers must be less than or equal to 4 for all layers in the subBitstream"  );
+          // -  For a layer with nuh_layer_id iNuhLId equal to any value included in layerIdListTarget that was used to derive subBitstream, 
+          //    the value of NumRefLayers[ iNuhLId ], which specifies the total number of direct and indirect reference layers and is derived as 
+          //    specified in F.7.4.3.1, shall be less than or equal to 4.
+        }
+
+#if NH_3D
+        if ( m_profiles[i] == Profile::MAIN3D )
+        {
+          xConfirmPara( maxNumRefLayers > 9, "When using the 3D-Main profile, NumRefLayers must be less than or equal to 9 for all layers in the subBitstream."  );
+            // -  For a layer with nuh_layer_id iNuhLId equal to any value included in layerIdListTarget that was used to derive subBitstream, 
+            //   the value of NumRefLayers[ iNuhLId ], which specifies the total number of direct and indirect reference layers and is derived as 
+            //   specified in F.7.4.3.1, shall be less than or equal to 9.
+        }
+#endif
+
+
+      }
+      break;
+#if NH_MV_ALLOW_NON_CONFORMING
+    case Profile::MULTIVIEWMAIN_NONCONFORMING:
+#if NH_3D
+    case Profile::MAIN3D_NONCONFORMING:
+#endif
+#endif
+    case Profile::NONE:
+      // Non-conforming configuration, so all settings are valid.
+      break;
+    default:
+      xConfirmPara( 1, "Unknown profile selected.");
+      break;
+    }
+
+    if ( check_failed )
+    {
+      printf("Error: Checking VpsProfileTierLevel[%d]. \n", i );
+      exit(EXIT_FAILURE);
+    }
+
+  }
+  #undef xConfirmPara
+
+  Bool anyMultiLayerProfile = false; 
+
+  for (Int i = 0; i < m_profiles.size(); i++ )
+  {
+    anyMultiLayerProfile = ( anyMultiLayerProfile
+       
+      ||  (m_profiles[i] == Profile::MULTIVIEWMAIN)
+#if NH_3D
+      || ( m_profiles[i] == Profile::MAIN3D       )
+#endif
+      ) ;
+  }
+
+  if ( anyMultiLayerProfile && ( m_profiles[0] != Profile::MAIN || m_profiles[1] != Profile::MAIN  ) )
+  {
+    fprintf(stderr, "Error: The base layer must conform to the Main profile for Multilayer coding.\n");
+    exit(EXIT_FAILURE);
+  }
+
+}
+
+#endif
 
 Void TAppEncCfg::xCheckParameter()
@@ -2168,14 +3023,17 @@
   Bool check_failed = false; /* abort if there is a fatal configuration problem */
 #define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
-
+  
   xConfirmPara(m_bitstreamFileName.empty(), "A bitstream file name must be specified (BitstreamFile)");
+#if !NH_MV
   const UInt maxBitDepth=(m_chromaFormatIDC==CHROMA_400) ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+
   xConfirmPara(m_bitDepthConstraint<maxBitDepth, "The internalBitDepth must not be greater than the bitDepthConstraint value");
   xConfirmPara(m_chromaFormatConstraint<m_chromaFormatIDC, "The chroma format used must not be greater than the chromaFormatConstraint value");
-#if NH_MV
-  Profile::Name & m_profile = m_profiles[0];
-#endif
-
-  if (m_profile==Profile::MAINREXT || m_profile==Profile::HIGHTHROUGHPUTREXT)
+
+  switch (m_profile)
+  {
+    case Profile::MAINREXT:
+    case Profile::HIGHTHROUGHPUTREXT:
+
   {
     xConfirmPara(m_lowerBitRateConstraintFlag==false && m_intraConstraintFlag==false, "The lowerBitRateConstraint flag cannot be false when intraConstraintFlag is false");
@@ -2186,5 +3044,5 @@
       const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 12 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
       const UInt chromaFormatIdx = UInt(m_chromaFormatConstraint);
-      const Bool bValidProfile = (bitDepthIdx > 3 || chromaFormatIdx>3) ? false : (validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx] != NONE);
+          const Bool bValidProfile = (bitDepthIdx > 3 || chromaFormatIdx>3) ? false : (validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx] != UI_NONE);
       xConfirmPara(!bValidProfile, "Invalid intra constraint flag, bit depth constraint flag and chroma format constraint flag combination for a RExt profile");
       const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
@@ -2218,9 +3076,26 @@
     {
       xConfirmPara( m_chromaFormatConstraint != CHROMA_444, "chroma format constraint must be 4:4:4 in the High Throughput 4:4:4 16-bit Intra profile.");
-      xConfirmPara( m_bitDepthConstraint     != 16,         "bit depth constraint must be 4:4:4 in the High Throughput 4:4:4 16-bit Intra profile.");
-      xConfirmPara( m_intraConstraintFlag    != 1,          "intra constraint flag must be 1 in the High Throughput 4:4:4 16-bit Intra profile.");
-    }
-  }
-  else
+          const UInt intraIdx = m_intraConstraintFlag ? 1:0;
+          const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 14 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
+          const Bool bValidProfile = (bitDepthIdx > 3) ? false : (validRExtHighThroughPutProfileNames[intraIdx][bitDepthIdx] != UI_NONE);
+          xConfirmPara(!bValidProfile, "Invalid intra constraint flag and bit depth constraint flag combination for a RExt high profile throughput profile");
+          if(bitDepthIdx < 2)
+          {
+            xConfirmPara((m_extendedPrecisionProcessingFlag || m_cabacBypassAlignmentEnabledFlag), "Invalid configuration for a RExt high throughput 8 and 10 bit profile");
+    }
+          if(bitDepthIdx == 3)
+          {
+            xConfirmPara(!m_cabacBypassAlignmentEnabledFlag, "Cabac Bypass Alignment flag must be 1 in the High Throughput 4:4:4 16-bit Intra profile");
+  }
+          else if(bitDepthIdx < 3)
+          {
+            xConfirmPara(!m_entropyCodingSyncEnabledFlag, "WPP flag must be 1 in the High Throughput 4:4:4 non 16-bit Intra profile");
+          }
+        }
+      }
+      break;
+    case Profile::MAIN:
+    case Profile::MAIN10:
+    case Profile::MAINSTILLPICTURE:
   {
     xConfirmPara(m_bitDepthConstraint!=((m_profile==Profile::MAIN10)?10:8), "BitDepthConstraint must be 8 for MAIN profile and 10 for MAIN10 profile.");
@@ -2242,5 +3117,21 @@
     xConfirmPara(m_cabacBypassAlignmentEnabledFlag, "AlignCABACBeforeBypass cannot be enabled for non main-RExt profiles.");
   }
-
+      break;
+    case Profile::NONE:
+      // Non-conforming configuration, so all settings are valid.
+      break;
+    default:
+      xConfirmPara( 1, "Unknown profile selected.");
+      break;
+  }
+#endif
+
+#if NH_MV
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    Int* m_internalBitDepth    = &m_internalBitDepths   [i][0];
+    Int* m_inputBitDepth       = &m_inputBitDepths      [i][0];
+    Int* m_MSBExtendedBitDepth = &m_MSBExtendedBitDepths[i][0];  
+#endif
   // check range of parameters
   xConfirmPara( m_inputBitDepth[CHANNEL_TYPE_LUMA  ] < 8,                                   "InputBitDepth must be at least 8" );
@@ -2263,23 +3154,36 @@
   }
 #endif
-
   xConfirmPara( (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] < m_inputBitDepth[CHANNEL_TYPE_LUMA  ]), "MSB-extended bit depth for luma channel (--MSBExtendedBitDepth) must be greater than or equal to input bit depth for luma channel (--InputBitDepth)" );
   xConfirmPara( (m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] < m_inputBitDepth[CHANNEL_TYPE_CHROMA]), "MSB-extended bit depth for chroma channel (--MSBExtendedBitDepthC) must be greater than or equal to input bit depth for chroma channel (--InputBitDepthC)" );
 
 #if NH_MV
+  }
   for (Int i = 0; i < m_numberOfLayers; i++)
   {
-    xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_LUMA]   > (m_internalBitDepth[CHANNEL_TYPE_LUMA  ]<10?0:(m_internalBitDepth[CHANNEL_TYPE_LUMA  ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive");
-    xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_CHROMA] > (m_internalBitDepth[CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepth[CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepthC-10, inclusive");
+    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[i];
+    xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_LUMA]   > (m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA  ]<10?0:(m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA  ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive");
+    xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_CHROMA] > (m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepthC-10, inclusive");
+  }
+
+  for (Int i = 0; i < m_numRepFormats; i++)
+  {
+    xConfirmPara( m_chromaFormatIDCs[i] >= NUM_CHROMA_FORMAT,                                     "ChromaFormatIDC must be either 400, 420, 422 or 444" );
   }
 #else
   xConfirmPara( m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]   > (m_internalBitDepth[CHANNEL_TYPE_LUMA  ]<10?0:(m_internalBitDepth[CHANNEL_TYPE_LUMA  ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive");
   xConfirmPara( m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] > (m_internalBitDepth[CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepth[CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepthC-10, inclusive");
-#endif
-
   xConfirmPara( m_chromaFormatIDC >= NUM_CHROMA_FORMAT,                                     "ChromaFormatIDC must be either 400, 420, 422 or 444" );
+#endif
+
   std::string sTempIPCSC="InputColourSpaceConvert must be empty, "+getListOfColourSpaceConverts(true);
   xConfirmPara( m_inputColourSpaceConvert >= NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS,         sTempIPCSC.c_str() );
+#if NH_MV
+  for (Int i = 0 ; i < m_InputChromaFormatIDC.size(); i++ )
+  {
+    xConfirmPara( m_InputChromaFormatIDC[i] >= NUM_CHROMA_FORMAT,                                "InputChromaFormatIDC must be either 400, 420, 422 or 444" );
+  }
+#else
   xConfirmPara( m_InputChromaFormatIDC >= NUM_CHROMA_FORMAT,                                "InputChromaFormatIDC must be either 400, 420, 422 or 444" );
+#endif
   xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
   xConfirmPara( m_temporalSubsampleRatio < 1,                                               "Temporal subsample rate must be no less than 1" );
@@ -2291,4 +3195,11 @@
   xConfirmPara( m_layerIdInNuh[0] != 0      , "LayerIdInNuh must be 0 for the first layer. ");
   xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
+
+#if NH_MV
+  xConfirmPara( !m_shareParameterSets && (m_numberOfLayers > 16)                            , "When NumberOfLayers is greater than 16, ShareParameterSets must be 1.");  
+  xConfirmPara( ! (m_layerIdxInVpsToGopDefIdx.size() == 0     || m_layerIdxInVpsToGopDefIdx.size() == m_numberOfLayers), "The number of entries in LayerIdxInVpsToGopDefIdx must zero or equal to NumberOfLayers.");  
+  xConfirmPara( ! (m_layerIdxInVpsToRepFormatIdx.size() == 0  || m_layerIdxInVpsToRepFormatIdx.size() == m_numberOfLayers), "The number of entries in LayerIdxInVpsToRepFormatIdx must zero or equal to NumberOfLayers.");  
+  
+#endif
 
 #if NH_3D
@@ -2370,5 +3281,4 @@
       xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
 
-#if !H_3D_FCO
       if ( numDiff  == 1 ) 
       {
@@ -2381,5 +3291,4 @@
         xConfirmPara( shallBeButIsNotIncreasing,  "DimensionIds shall be increasing within one dimension. " );
       }
-#endif
     }
   }
@@ -2447,13 +3356,13 @@
 
   // PTL
-  xConfirmPara( ( m_profiles.size() != m_inblFlag.size() || m_profiles.size() != m_level.size()  ||  m_profiles.size() != m_levelTier.size() ), "The number of Profiles, Levels, Tiers and InblFlags must be equal." ); 
+  xConfirmPara( ( m_uiProfiles.size() != m_inblFlag.size() || m_uiProfiles.size() != m_level.size()  ||  m_uiProfiles.size() != m_levelTier.size() ), "The number of Profiles, Levels, Tiers and InblFlags must be equal." ); 
 
   if ( m_numberOfLayers > 1)
   {
-    xConfirmPara( m_profiles.size() <= 1, "The number of profiles, tiers, levels, and inblFlags must be greater than 1.");
+    xConfirmPara( m_uiProfiles.size() <= 1, "The number of profiles, tiers, levels, and inblFlags must be greater than 1.");
     xConfirmPara( m_inblFlag[0], "VpsProfileTierLevel[0] must have inblFlag equal to 0");
-    if (m_profiles.size() > 1 )
-    {
-      xConfirmPara( m_profiles[0]  != m_profiles[1], "The profile in VpsProfileTierLevel[1] must be equal to the profile in VpsProfileTierLevel[0].");
+    if (m_uiProfiles.size() > 1 )
+    {
+      xConfirmPara( m_uiProfiles[0]  != m_uiProfiles[1], "The profile in VpsProfileTierLevel[1] must be equal to the profile in VpsProfileTierLevel[0].");
       xConfirmPara( m_inblFlag[0] != m_inblFlag[1], "inblFlag in VpsProfileTierLevel[1] must be equal to the inblFlag in VpsProfileTierLevel[0].");
     }
@@ -2467,5 +3376,10 @@
     for (Int j = 0; j < m_directRefLayers[i].size(); j++)
     {
-      xConfirmPara( m_directRefLayers[i][j] < 0 || m_directRefLayers[i][j] >= i , "Reference layer id shall be greater than or equal to 0 and less than dependent layer id"); 
+      if ( m_directRefLayers[i][j] < 0 || m_directRefLayers[i][j] >= i )
+      {
+        printf( "Error: Reference layer id (%d) shall be greater than or equal to 0 and less than dependent layer id (%d). ", m_directRefLayers[i][j],  i );
+        check_failed = true; 
+      }       
+
       xConfirmPara( m_dependencyTypes[i][j] < 0 || m_dependencyTypes[i][j] >  6 , "Dependency type shall be greater than or equal to 0 and less than 7");
     }        
@@ -2499,5 +3413,11 @@
   }
 
+#if NH_MV
+  for (Int i = 0; i < m_numRepFormats; i++)
+  {
+    if(m_crossComponentPredictionEnabledFlag && (m_chromaFormatIDCs[i] != CHROMA_444))
+#else
   if(m_crossComponentPredictionEnabledFlag && (m_chromaFormatIDC != CHROMA_444))
+#endif
   {
     fprintf(stderr, "****************************************************************************\n");
@@ -2507,4 +3427,7 @@
     m_crossComponentPredictionEnabledFlag = false;
   }
+#if NH_MV
+  }
+#endif
 
   if ( m_CUTransquantBypassFlagForce && m_bUseHADME )
@@ -2531,14 +3454,11 @@
   for( Int layer = 0; layer < m_numberOfLayers; layer++ )
   {
-    xConfirmPara( m_iQP[layer] <  -6 * (m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8) || m_iQP[layer] > 51,      "QP exceeds supported range (-QpBDOffsety to 51)" );
+    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
+    xConfirmPara( m_iQP[layer] <  -6 * (m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA] - 8) || m_iQP[layer] > 51,      "QP exceeds supported range (-QpBDOffsety to 51)" );
     xConfirmPara( m_deblockingFilterMetric!=0 && (m_bLoopFilterDisable[layer] || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is true then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0");
   }
 #else
   xConfirmPara( m_iQP <  -6 * (m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8) || m_iQP > 51,    "QP exceeds supported range (-QpBDOffsety to 51)" );
-#if W0038_DB_OPT
   xConfirmPara( m_deblockingFilterMetric!=0 && (m_bLoopFilterDisable || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is non-zero then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0");
-#else
-  xConfirmPara( m_DeblockingFilterMetric && (m_bLoopFilterDisable || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is true then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0");
-#endif
 #endif
   
@@ -2552,4 +3472,5 @@
 #endif
   xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
+  xConfirmPara(m_lumaLevelToDeltaQPMapping.mode &&  m_uiDeltaQpRD > 0, "Luma-level-based Delta QP cannot be used together with slice level multiple-QP optimization\n" );
   xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,                                          "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
 
@@ -2560,29 +3481,23 @@
 
   xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
+#if NH_MV
+  for (Int i = 0; i < m_numberOfLayers; i++ )
+  {
+    if (m_iDecodingRefreshType == 2 || m_saoResetEncoderStateAfterIRAP)
+    {
+      xConfirmPara( m_iIntraPeriod[i] > 0 && m_iIntraPeriod[i] <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
+    }
+  }
+#else
   if (m_iDecodingRefreshType == 2)
   {
-#if NH_MV
-    for (Int i = 0; i < m_numberOfLayers; i++ )
-    {
-      xConfirmPara( m_iIntraPeriod[i] > 0 && m_iIntraPeriod[i] <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
-#if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
+   xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
+  }
   if (m_saoResetEncoderStateAfterIRAP)
   {
-    xConfirmPara( m_iIntraPeriod[i] > 0 && m_iIntraPeriod[i] <= m_iGOPSize ,                      "Intra period must be larger than GOP size when SAOResetEncoderStateAfterIRAP is enabled");
-  }
-#endif
-
-    }
-#else
-#if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
-  if (m_saoResetEncoderStateAfterIRAP)
-  {
     xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size when SAOResetEncoderStateAfterIRAP is enabled");
   }
 #endif
-
-   xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
-#endif
-  }
+  
   xConfirmPara( m_uiMaxCUDepth < 1,                                                         "MaxPartitionDepth must be greater than zero");
   xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
@@ -2590,6 +3505,14 @@
   xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
   xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
+#if NH_MV
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    xConfirmPara( (m_iSourceWidths[i]  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
+    xConfirmPara( (m_iSourceHeights[i] % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
+  }
+#else
   xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
   xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
+#endif
 
   xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
@@ -2631,5 +3554,12 @@
     for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
     {
+#if NH_MV
+      for (Int i = 0; i < m_numRepFormats; i++)
+      {
+        xConfirmPara(((m_MSBExtendedBitDepths[i][channelType] > m_internalBitDepths[i][channelType]) && m_bPCMInputBitDepthFlag), "PCM bit depth cannot be greater than internal bit depth (PCMInputBitDepthFlag cannot be used when InputBitDepth or MSBExtendedBitDepth > InternalBitDepth)");
+      }
+#else
       xConfirmPara(((m_MSBExtendedBitDepth[channelType] > m_internalBitDepth[channelType]) && m_bPCMInputBitDepthFlag), "PCM bit depth cannot be greater than internal bit depth (PCMInputBitDepthFlag cannot be used when InputBitDepth or MSBExtendedBitDepth > InternalBitDepth)");
+#endif
     }
     xConfirmPara(  m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
@@ -2649,8 +3579,22 @@
 
   Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
+
+#if !NH_MV
   if (m_profile!=Profile::HIGHTHROUGHPUTREXT)
   {
     xConfirmPara( tileFlag && m_entropyCodingSyncEnabledFlag, "Tiles and entropy-coding-sync (Wavefronts) can not be applied together, except in the High Throughput Intra 4:4:4 16 profile");
   }
+#else
+  for (Int i = 0; i < m_numRepFormats; i++)
+  {
+    ChromaFormat m_chromaFormatIDC  = m_chromaFormatIDCs[i];
+    Int*         m_aiPad            = &m_aiPads          [i][0];
+    Int          m_confWinLeft      = m_confWinLefts    [i];
+    Int          m_confWinRight     = m_confWinRights   [i];
+    Int          m_confWinTop       = m_confWinTops     [i];
+    Int          m_confWinBottom    = m_confWinBottoms  [i];  
+    Int          m_iSourceWidth     = m_iSourceWidths   [i];
+    Int          m_iSourceHeight    = m_iSourceHeights  [i];
+#endif
 
   xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
@@ -2674,4 +3618,8 @@
     xConfirmPara( m_defDispWinBottomOffset % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Bottom default display window offset must be an integer multiple of the specified chroma subsampling");
   }
+
+#if NH_MV
+  }
+#endif
 
 #if NH_3D_VSO || NH_3D
@@ -2717,7 +3665,7 @@
       for( Int i = 0; i < MAX_GOP; i++ )
       {
-        if( m_GOPListMvc[k][i].m_POC != m_GOPListMvc[0][i].m_POC )
+        if( xGetGopEntries(k)[i].m_POC != xGetGopEntries(0)[i].m_POC )
         {
-          printf( "\nError: Frame%d_l%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListMvc[k][i].m_POC, i );
+          printf( "\nError: Frame%d_l%d POC %d is not identical to Frame%d POC\n", i, k, xGetGopEntries(k)[i].m_POC, i );
           bErrorMvePoc = true;
         }
@@ -2731,5 +3679,5 @@
   for( Int i = 0; i < MAX_GOP; i++ )
   {
-    if( m_GOPListMvc[0][i].m_numActiveRefLayerPics != 0 )
+    if( xGetGopEntries(0)[i].m_numActiveRefLayerPics != 0 )
     {
       printf( "\nError: Frame%d inter_layer refs not available in layer 0\n", i );
@@ -2747,5 +3695,5 @@
       for( Int i = 0; i < MAX_GOP+1; i++ )
       {
-        GOPEntry gopEntry = m_GOPListMvc[layer][i];  
+        GOPEntry gopEntry = xGetGopEntries(layer)[i];  
         for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
         {
@@ -2790,5 +3738,5 @@
           {
             printf( "\nWarning: temporal references not possible for FrameI_l%d\n", layer );
-            for( Int j = 0; j < m_GOPListMvc[layer][MAX_GOP].m_numRefPics; j++ )
+            for( Int j = 0; j < xGetGopEntries(layer)[MAX_GOP].m_numRefPics; j++ )
             {
               gopEntry.m_referencePics[j] = 0;
@@ -2850,9 +3798,9 @@
     for( Int layer = 0; layer < m_numberOfLayers; layer++ )
     {
-      GOPEntry* m_GOPList            = m_GOPListMvc           [layer]; // It is not a member, but this name helps avoiding code duplication !!!
+      GOPEntry* m_GOPList            = xGetGopEntries         (layer); // It is not a member, but this name helps avoiding code duplication !!!
       Int&      m_extraRPSs          = m_extraRPSsMvc         [layer]; // It is not a member, but this name helps avoiding code duplication !!!
       Int&      m_maxTempLayer       = m_maxTempLayerMvc      [layer]; // It is not a member, but this name helps avoiding code duplication !!!
       Int*      m_maxDecPicBuffering = m_maxDecPicBufferingMvc[layer]; // It is not a member, but this name helps avoiding code duplication !!!
-      Int*      m_numReorderPics     = m_numReorderPicsMvc    [layer]; // It is not a member, but this name helps avoiding code duplication !!!
+      Int*      m_numReorderPics     = m_numReorderPicsMvc    [layer]; // It is not a member, but this name helps avoiding code duplication !!!      
 #endif
 
@@ -2874,5 +3822,7 @@
   else
   {
+#if !NH_MV
     xConfirmPara( m_intraConstraintFlag, "IntraConstraintFlag cannot be 1 for inter sequences");
+#endif
   }
 
@@ -2920,5 +3870,4 @@
   }
 
-#if W0038_CQP_ADJ
   for(Int i=0; i<m_iGOPSize; i++)
   {
@@ -2928,9 +3877,8 @@
     xConfirmPara( abs(m_GOPList[i].m_CrQPoffset + m_crQpOffset) > 12, "Cr QP Offset for one of the GOP entries, when combined with the PPS Cr offset, exceeds supported range (-12 to 12)" );
   }
-  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[0]                 > 12), "Intra/periodic Cb QP Offset exceeds supported range (-12 to 12)" );
-  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[0]  + m_cbQpOffset > 12), "Intra/periodic Cb QP Offset, when combined with the PPS Cb offset, exceeds supported range (-12 to 12)" );
-  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[1]                 > 12), "Intra/periodic Cr QP Offset exceeds supported range (-12 to 12)" );
-  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[1]  + m_crQpOffset > 12), "Intra/periodic Cr QP Offset, when combined with the PPS Cr offset, exceeds supported range (-12 to 12)" );
-#endif
+  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[0]                 ) > 12, "Intra/periodic Cb QP Offset exceeds supported range (-12 to 12)" );
+  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[0]  + m_cbQpOffset ) > 12, "Intra/periodic Cb QP Offset, when combined with the PPS Cb offset, exceeds supported range (-12 to 12)" );
+  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[1]                 ) > 12, "Intra/periodic Cr QP Offset exceeds supported range (-12 to 12)" );
+  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[1]  + m_crQpOffset ) > 12, "Intra/periodic Cr QP Offset, when combined with the PPS Cr offset, exceeds supported range (-12 to 12)" );
 
   m_extraRPSs=0;
@@ -3206,4 +4154,14 @@
   if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
   {
+#if NH_MV
+
+    if( m_numRepFormats > 1 )
+    {
+        AOT( true ); //TBD
+    }
+
+    Int m_iSourceWidth  = m_iSourceWidths [0];
+    Int m_iSourceHeight = m_iSourceHeights[0];
+#endif
     Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
     if(tileFlag)
@@ -3307,5 +4265,12 @@
   if (m_chromaResamplingFilterSEIenabled)
   {
+#if NH_MV
+    for (Int i = 0 ; i < m_numRepFormats; i++ )
+    {
+      xConfirmPara( (m_chromaFormatIDCs[i] == CHROMA_400 ), "chromaResamplingFilterSEI is not allowed to be present when ChromaFormatIDC is equal to zero (4:0:0)" );
+    }
+#else
     xConfirmPara( (m_chromaFormatIDC == CHROMA_400 ), "chromaResamplingFilterSEI is not allowed to be present when ChromaFormatIDC is equal to zero (4:0:0)" );
+#endif
     xConfirmPara(m_vuiParametersPresentFlag && m_chromaLocInfoPresentFlag && (m_chromaSampleLocTypeTopField != m_chromaSampleLocTypeBottomField ), "When chromaResamplingFilterSEI is enabled, ChromaSampleLocTypeTopField has to be equal to ChromaSampleLocTypeBottomField" );
   }
@@ -3322,13 +4287,5 @@
     }
     xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
-#if U0132_TARGET_BITS_SATURATION
-#if NH_MV
-    if ((m_RCCpbSaturationEnabled) && (m_level[0]!=Level::NONE) && (m_profile!=Profile::NONE))
-    {
-      UInt uiLevelIdx = (m_level[0] / 10) + (UInt)((m_level[0] % 10) / 3);    // (m_level / 30)*3 + ((m_level % 10) / 3);
-      xConfirmPara(m_RCCpbSize > g_uiMaxCpbSize[m_levelTier[0]][uiLevelIdx], "RCCpbSize should be smaller than or equal to Max CPB size according to tier and level");
-      xConfirmPara(m_RCInitialCpbFullness > 1, "RCInitialCpbFullness should be smaller than or equal to 1");
-    }
-#else
+#if !NH_MV    
     if ((m_RCCpbSaturationEnabled) && (m_level!=Level::NONE) && (m_profile!=Profile::NONE))
     {
@@ -3338,12 +4295,19 @@
     }
 #endif
-#endif
-  }
-#if U0132_TARGET_BITS_SATURATION
+  }
   else
   {
     xConfirmPara( m_RCCpbSaturationEnabled != 0, "Target bits saturation cannot be processed without Rate control" );
   }
-#endif
+
+  if (m_vuiParametersPresentFlag)
+  {
+    xConfirmPara(m_RCTargetBitrate == 0, "A target bit rate is required to be set for VUI/HRD parameters.");
+    if (m_RCCpbSize == 0)
+    {
+      printf ("Warning: CPB size is set equal to zero. Adjusting value to be equal to TargetBitrate!\n");
+      m_RCCpbSize = m_RCTargetBitrate;
+    }
+  }
 
 #if NH_MV
@@ -3370,5 +4334,5 @@
 #endif
 
-  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
+  xConfirmPara(!m_TransquantBypassEnabledFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
 
   xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
@@ -3394,4 +4358,12 @@
   }
 
+#if MCTS_ENC_CHECK
+  if ((m_tmctsSEIEnabled) && (m_tmctsSEITileConstraint) && (m_bLFCrossTileBoundaryFlag) )
+  {
+    printf("Warning: Constrained Encoding for Temporal Motion Constrained Tile Sets is enabled. Disabling filtering across tile boundaries!\n");
+    m_bLFCrossTileBoundaryFlag = false;
+  }
+#endif
+
   if(m_timeCodeSEIEnabled)
   {
@@ -3399,6 +4371,8 @@
   }
 
-#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
   xConfirmPara(m_preferredTransferCharacteristics > 255, "transfer_characteristics_idc should not be greater than 255.");
+
+#if EXTENSION_360_VIDEO
+  check_failed |= m_ext360.verifyParameters();
 #endif
 
@@ -3429,4 +4403,63 @@
 }
 
+#if NH_MV
+Void TAppEncCfg::xPrintProfiles()
+{
+  printf("Profiles                          :");
+  for (Int i = 0; i < m_profiles.size(); i++)
+  {
+    if (m_profiles[i] == Profile::MAINREXT)
+    {
+      UIProfileName validProfileName;
+      if (m_onePictureOnlyConstraintFlags[i])
+      {
+        validProfileName = m_bitDepthConstraints[i] == 8 ? UI_MAIN_444_STILL_PICTURE : (m_bitDepthConstraints[i] == 16 ? UI_MAIN_444_16_STILL_PICTURE : UI_NONE);
+      }
+      else
+      {
+        const UInt intraIdx        =  m_intraConstraintFlags[i] ? 1:0;
+        const UInt bitDepthIdx     = (m_bitDepthConstraints[i] == 8 ? 0 : (m_bitDepthConstraints[i] ==10 ? 1 : (m_bitDepthConstraints[i] == 12 ? 2 : (m_bitDepthConstraints[i] == 16 ? 3 : 4 ))));
+        const UInt chromaFormatIdx = UInt(m_chromaFormatConstraints[i]);
+        validProfileName = (bitDepthIdx > 3 || chromaFormatIdx>3) ? UI_NONE : validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx];
+      }
+      std::string rextSubProfile;
+      if (validProfileName!=UI_NONE)
+      {
+        rextSubProfile=enumToString(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), validProfileName);
+      }
+      if (rextSubProfile == "main_444_16")
+      {
+        rextSubProfile="main_444_16 [NON STANDARD]";
+      }
+      printf(" %s (%s) ", profileToString(m_profiles[i]), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
+
+    }
+    else if (m_profiles[i] == Profile::HIGHTHROUGHPUTREXT)
+    {
+      UIProfileName validProfileName;
+      const UInt intraIdx    = m_intraConstraintFlags[i] ? 1 : 0;
+      const UInt bitDepthIdx = (m_bitDepthConstraints[i] == 8 ? 0 : (m_bitDepthConstraints[i] ==10 ? 1 : (m_bitDepthConstraints[i] == 12 ? 2 : (m_bitDepthConstraints[i] == 16 ? 3 : 4 ))));
+      validProfileName = (bitDepthIdx > 3) ? UI_NONE : validRExtHighThroughPutProfileNames[intraIdx][bitDepthIdx];
+      std::string subProfile;
+      if (validProfileName!=UI_NONE)
+      {
+        subProfile=enumToString(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), validProfileName);
+      }
+      printf(" : %s (%s)\n", profileToString(m_profiles[i]), (subProfile.empty())?"INVALID HIGH THROUGHPUT REXT PROFILE":subProfile.c_str() );
+    }
+    else if (m_profiles[i] == Profile::MAIN10 && m_onePictureOnlyConstraintFlags[i])
+    {
+      printf(" : %s (main10-still-picture)\n", profileToString(m_profiles[i]) );
+    }
+    else
+    {
+      printf(" %s ", profileToString(m_profiles[i]) );
+    }
+  }
+  printf("\n\n");
+
+}
+#endif
+
 Void TAppEncCfg::xPrintParameter()
 {
@@ -3435,14 +4468,14 @@
   for( Int layer = 0; layer < m_numberOfLayers; layer++)
   {
-    printf("Input File %i                     : %s\n", layer, m_pchInputFileList[layer]);
+    printf("Input          File %i             : %s\n", layer, m_pchInputFileList[layer]);    
   }
 #else
   printf("Input          File                    : %s\n", m_inputFileName.c_str()          );
 #endif
-  printf("Bitstream      File                    : %s\n", m_bitstreamFileName.c_str()      );
+  printf("Bitstream      File               : %s\n", m_bitstreamFileName.c_str()      );
 #if NH_MV
   for( Int layer = 0; layer < m_numberOfLayers; layer++)
-  {
-    printf("Reconstruction File %i            : %s\n", layer, m_pchReconFileList[layer]);
+  { 
+    printf("Reconstruction File %i             : %s\n", layer, m_pchReconFileList[layer]);
   }
 #else
@@ -3464,14 +4497,37 @@
 #endif
 #if NH_MV  
+#if !JVET_E0059_FLOATING_POINT_QP_FIX
   xPrintParaVector( "QP"               , m_fQP                ); 
+#endif
   xPrintParaVector( "LoopFilterDisable", m_bLoopFilterDisable ); 
   xPrintParaVector( "SAO"              , m_bUseSAO            ); 
-#endif
-
+  printf("ShareParameterSets                : %d\n",  m_shareParameterSets ?  1  : 0  );         
+#endif
+
+#if NH_MV
+  printf("Real     Format                   :");
+  for(Int i = 0; i < m_numRepFormats; i++ )
+  { 
+    printf(" (%dx%d %gHz)", m_iSourceWidths[i] - m_confWinLefts[i] - m_confWinRights[i], m_iSourceHeights[i] - m_confWinTops[i] - m_confWinBottoms[i], (Double)m_iFrameRate/m_temporalSubsampleRatio );
+  }
+
+  printf("\nInternal Format                   :" );
+  for(Int i = 0; i < m_numRepFormats; i++ )
+  { 
+
+    printf(" (%dx%d %gHz)", m_iSourceWidths[i], m_iSourceHeights[i], (Double)m_iFrameRate/m_temporalSubsampleRatio );
+  }  
+  printf("\n"); 
+#else
   printf("Real     Format                        : %dx%d %gHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, (Double)m_iFrameRate/m_temporalSubsampleRatio );
   printf("Internal Format                        : %dx%d %gHz\n", m_iSourceWidth, m_iSourceHeight, (Double)m_iFrameRate/m_temporalSubsampleRatio );
+
+#endif
   printf("Sequence PSNR output              : %s\n", (m_printMSEBasedSequencePSNR ? "Linear average, MSE-based" : "Linear average only") );
   printf("Sequence MSE output               : %s\n", (m_printSequenceMSE ? "Enabled" : "Disabled") );
   printf("Frame MSE output                  : %s\n", (m_printFrameMSE    ? "Enabled" : "Disabled") );
+#if JVET_F0064_MSSSIM  
+  printf("MS-SSIM output                    : %s\n", (m_printMSSSIM      ? "Enabled" : "Disabled") );
+#endif
   printf("Cabac-zero-word-padding           : %s\n", (m_cabacZeroWordPaddingEnabled? "Enabled" : "Disabled") );
   if (m_isField)
@@ -3487,17 +4543,11 @@
     printf("Frame index                       : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
   }
-#if NH_MV
-  printf("Profile                           :");
-  for (Int i = 0; i < m_profiles.size(); i++)
-  {
-    Profile::Name m_profile = m_profiles[i];
-
-#endif
+#if !NH_MV
     if (m_profile == Profile::MAINREXT)
     {
-    ExtendedProfileName validProfileName;
+    UIProfileName validProfileName;
     if (m_onePictureOnlyConstraintFlag)
     {
-      validProfileName = m_bitDepthConstraint == 8 ? MAIN_444_STILL_PICTURE : (m_bitDepthConstraint == 16 ? MAIN_444_16_STILL_PICTURE : NONE);
+      validProfileName = m_bitDepthConstraint == 8 ? UI_MAIN_444_STILL_PICTURE : (m_bitDepthConstraint == 16 ? UI_MAIN_444_16_STILL_PICTURE : UI_NONE);
     }
     else
@@ -3506,10 +4556,10 @@
       const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 12 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
       const UInt chromaFormatIdx = UInt(m_chromaFormatConstraint);
-      validProfileName = (bitDepthIdx > 3 || chromaFormatIdx>3) ? NONE : validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx];
+      validProfileName = (bitDepthIdx > 3 || chromaFormatIdx>3) ? UI_NONE : validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx];
     }
       std::string rextSubProfile;
-      if (validProfileName!=NONE)
-      {
-        rextSubProfile=enumToString(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), validProfileName);
+    if (validProfileName!=UI_NONE)
+      {
+      rextSubProfile=enumToString(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), validProfileName);
       }
       if (rextSubProfile == "main_444_16")
@@ -3517,24 +4567,34 @@
         rextSubProfile="main_444_16 [NON STANDARD]";
       }
-#if NH_MV
-      printf(" %s (%s) ", profileToString(m_profile), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
-#else
       printf("Profile                           : %s (%s)\n", profileToString(m_profile), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
-#endif
-    }
-    else
-    {
-#if NH_MV
-      printf(" %s ", profileToString(m_profile) );
-#else
+  }
+  else if (m_profile == Profile::HIGHTHROUGHPUTREXT)
+  {
+    UIProfileName validProfileName;
+    const UInt intraIdx = m_intraConstraintFlag ? 1:0;
+    const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 12 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
+    validProfileName = (bitDepthIdx > 3) ? UI_NONE : validRExtHighThroughPutProfileNames[intraIdx][bitDepthIdx];
+    std::string subProfile;
+    if (validProfileName!=UI_NONE)
+    {
+      subProfile=enumToString(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), validProfileName);
+    }
+    printf("Profile                                : %s (%s)\n", profileToString(m_profile), (subProfile.empty())?"INVALID HIGH THROUGHPUT REXT PROFILE":subProfile.c_str() );
+  }
+  else if (m_profile == Profile::MAIN10 && m_onePictureOnlyConstraintFlag)
+  {
+    printf("Profile                                : %s (main10-still-picture)\n", profileToString(m_profile) );
+  }
+  else
+  {
       printf("Profile                           : %s\n", profileToString(m_profile) );
-#endif
-    }
-#if NH_MV    
-  }
-  printf("\n");
-#endif
-
+   }
+#endif
+
+#if NH_MV
+  printf("CU size / depth / total-depth     : %d / %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth, m_uiMaxTotalCUDepth[0] );
+#else
   printf("CU size / depth / total-depth     : %d / %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth, m_uiMaxTotalCUDepth );
+#endif
   printf("RQT trans. size (min / max)       : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
   printf("Max RQT depth inter               : %d\n", m_uiQuadtreeTUMaxDepthInter);
@@ -3552,5 +4612,26 @@
 #endif
   printf("Decoding refresh type             : %d\n", m_iDecodingRefreshType );
-#if !NH_MV
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+
+#if NH_MV
+  if ( !m_qpIncrementAtSourceFrame.empty() )
+  {
+    xPrintParaVector( "QPIncrementFrame", m_qpIncrementAtSourceFrame );     
+  }
+#else
+  if (m_qpIncrementAtSourceFrame.bPresent)
+  {
+    printf("QP                                     : %d (incrementing internal QP at source frame %d)\n", m_iQP, m_qpIncrementAtSourceFrame.value );
+  }
+#endif
+  else
+  {
+#if NH_MV
+    xPrintParaVector( "QP", m_iQP ); 
+#else
+    printf("QP                                     : %d\n", m_iQP );
+#endif
+  }
+#else
   printf("QP                                : %5.2f\n", m_fQP );
 #endif
@@ -3561,4 +4642,32 @@
   printf("QP adaptation                     : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
   printf("GOP size                          : %d\n", m_iGOPSize );
+
+#if NH_MV
+  printf("Input bit depth                   :");
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    printf(" (Y:%d, C:%d)", m_inputBitDepths[i][CHANNEL_TYPE_LUMA], m_inputBitDepths[i][CHANNEL_TYPE_CHROMA] );
+  }
+
+  printf("\nMSB-extended bit depth            :");
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    printf(" (Y:%d, C:%d)", m_MSBExtendedBitDepths[i][CHANNEL_TYPE_LUMA], m_MSBExtendedBitDepths[i][CHANNEL_TYPE_CHROMA] );
+  }
+
+  printf("\nInternal bit depth                :");
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    printf(" (Y:%d, C:%d)", m_internalBitDepths[i][CHANNEL_TYPE_LUMA], m_internalBitDepths[i][CHANNEL_TYPE_CHROMA] );
+  }
+  
+  printf("\nPCM sample bit depth              :");
+  for (Int i = 0; i < m_numRepFormats; i++ )
+  {
+    printf(" (Y:%d, C:%d)", m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepths[i][CHANNEL_TYPE_LUMA]   : m_internalBitDepths[i][CHANNEL_TYPE_LUMA], 
+                             m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepths[i][CHANNEL_TYPE_CHROMA] : m_internalBitDepths[i][CHANNEL_TYPE_CHROMA] );
+  }
+  printf("\n" );
+#else
   printf("Input bit depth                   : (Y:%d, C:%d)\n", m_inputBitDepth[CHANNEL_TYPE_LUMA], m_inputBitDepth[CHANNEL_TYPE_CHROMA] );
   printf("MSB-extended bit depth            : (Y:%d, C:%d)\n", m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA], m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] );
@@ -3566,4 +4675,5 @@
   printf("PCM sample bit depth              : (Y:%d, C:%d)\n", m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA] : m_internalBitDepth[CHANNEL_TYPE_LUMA],
                                                                m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] : m_internalBitDepth[CHANNEL_TYPE_CHROMA] );
+#endif
   printf("Intra reference smoothing         : %s\n", (m_enableIntraReferenceSmoothing          ? "Enabled" : "Disabled") );
   printf("diff_cu_chroma_qp_offset_depth         : %d\n", m_diffCuChromaQpOffsetDepth);
@@ -3629,6 +4739,4 @@
     printf("InitialQP                         : %d\n", m_RCInitialQP );
     printf("ForceIntraQP                      : %d\n", m_RCForceIntraQP );
-
-#if U0132_TARGET_BITS_SATURATION
     printf("CpbSaturation                          : %d\n", m_RCCpbSaturationEnabled );
     if (m_RCCpbSaturationEnabled)
@@ -3637,5 +4745,4 @@
       printf("InitalCpbFullness                      : %.2f\n", m_RCInitialCpbFullness);
     }
-#endif
 
 #if KWU_RC_MADPRED_E0227
@@ -3686,12 +4793,19 @@
 #if NH_MV
   printf("TOOL CFG General: ");
+
+  for( Int i = 0; i < m_numRepFormats; i++)
+  {
+    printf("IBD(%d):%d ", i, ((m_internalBitDepths[i][CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepths[i][CHANNEL_TYPE_LUMA]) || (m_internalBitDepths[i][CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepths[i][CHANNEL_TYPE_CHROMA])));
+  }
 #else
   printf("TOOL CFG: ");
-#endif
-  printf("IBD:%d ", ((m_internalBitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (m_internalBitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
+    printf("IBD:%d ", ((m_internalBitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (m_internalBitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
+#endif
+
   printf("HAD:%d ", m_bUseHADME           );
   printf("RDQ:%d ", m_useRDOQ            );
   printf("RDQTS:%d ", m_useRDOQTS        );
   printf("RDpenalty:%d ", m_rdPenalty  );
+  printf("LQP:%d ", m_lumaLevelToDeltaQPMapping.mode     );
   printf("SQP:%d ", m_uiDeltaQpRD         );
   printf("ASR:%d ", m_bUseASR             );
@@ -3723,5 +4837,5 @@
   printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
 
-  if (m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce)
+  if (m_TransquantBypassEnabledFlag && m_CUTransquantBypassFlagForce)
   {
     printf("TransQuantBypassEnabled: =1");
@@ -3729,5 +4843,5 @@
   else
   {
-    printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnableFlag)? 1:0 );
+    printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnabledFlag)? 1:0 );
   }
 
@@ -3735,6 +4849,14 @@
   printf("WPB:%d ", (Int)m_useWeightedBiPred);
   printf("PME:%d ", m_log2ParallelMergeLevel);
+#if NH_MV
+  for( Int i = 0; i < m_numRepFormats; i++ )
+  {
+    const Int iWaveFrontSubstreams = m_entropyCodingSyncEnabledFlag ? (m_iSourceHeights[i] + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
+    printf(" WaveFrontSynchro(%d):%d WaveFrontSubstreams(%d):%d", i, m_entropyCodingSyncEnabledFlag?1:0, i, iWaveFrontSubstreams );
+  }
+#else
   const Int iWaveFrontSubstreams = m_entropyCodingSyncEnabledFlag ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
   printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_entropyCodingSyncEnabledFlag?1:0, iWaveFrontSubstreams);
+#endif
   printf(" ScalingList:%d ", m_useScalingListId );
   printf("TMVPMode:%d ", m_TMVPModeId     );
@@ -3743,14 +4865,15 @@
 #endif
 
-  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
+  printf(" SignBitHidingFlag:%d ", m_signDataHidingEnabledFlag);
   printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
+#if EXTENSION_360_VIDEO
+  m_ext360.outputConfigurationSummary();
+#endif
 #if NH_3D_VSO
   printf(" VSO:%d ", m_bUseVSO   );
   printf("WVSO:%d ", m_bUseWVSO );  
 #endif
-#if NH_3D_QTL
+#if NH_3D
   printf( "QTL:%d "                  , m_bUseQTL);
-#endif
-#if NH_3D
   printf( "IlluCompEnable:%d "       , m_abUseIC);
   printf( "IlluCompLowLatencyEnc:%d ",  m_bUseLowLatencyICEnc);
@@ -3780,4 +4903,199 @@
   fflush(stdout);
 }
+#if NH_MV
+
+Void TAppEncCfg::xConfirmRepFormat(const TComVPS& vps )
+{
+  Bool checkFailed = false; 
+
+  // This might not cover all disallowed cases. To be further tested.
+#if NH_3D
+  Bool allDepthSameBitDepth = true; 
+  Bool allSameSize          = true; 
+  Bool allTextureChroma420  = true; 
+  
+  Int  lastBitDepth         = -1; 
+  Int  lastWidth            = -1; 
+  Int  lastHeight           = -1; 
+
+  Int lastChromaFormat     = (Int) CHROMA_420; 
+
+  for(Int i = 0; i <= vps.getMaxLayersMinus1(); i++ )
+  {
+    Int curLayerIdInNuh = vps.getLayerIdInNuh( i );
+
+    const TComRepFormat* repFormat = vps.getRepFormat( vps.getVpsRepFormatIdx( i  ) ); 
+
+    Int curWidth = repFormat->getPicWidthVpsInLumaSamples();
+    allSameSize  = allSameSize && ( lastWidth == -1 || lastWidth  == curWidth );
+    lastWidth    = curWidth; 
+
+    Int curHeight = repFormat->getPicHeightVpsInLumaSamples();
+    allSameSize   = allSameSize && ( lastHeight == -1 || lastHeight  == curHeight );
+    lastHeight    = curHeight; 
+
+    if ( vps.getVpsDepthFlag( curLayerIdInNuh ))
+    { 
+      Int curBitDepth      = repFormat->getBitDepthVpsLumaMinus8(); 
+      allDepthSameBitDepth = allDepthSameBitDepth && ( lastBitDepth == -1 || lastBitDepth  == curBitDepth );
+      lastBitDepth         = curBitDepth; 
+    }
+    else
+    {
+      Int curChromaFormat = repFormat->getChromaFormatVpsIdc();
+      allTextureChroma420 = allTextureChroma420 && ( lastChromaFormat  == curChromaFormat );
+      lastChromaFormat    = curChromaFormat; 
+    }
+  }
+
+  checkFailed |= confirmPara( !allDepthSameBitDepth                                         ,  "The HTM implementation requires that InternalBitDepth of all depth layers must be equal."  );
+  checkFailed |= confirmPara( !allSameSize           && ( m_bUseVSO || m_bUseEstimatedVSD ) ,  "When VSO or VSD are enabled, the HTM implementation requires that SourceHeight and SourceWidth of all layers must be equal."  );
+  checkFailed |= confirmPara( !allTextureChroma420   &&  m_bUseVSO                          ,  "When VSO is enabled, the HTM implementation requires that all textures have ChromaFormat 420."  );  
+#endif
+
+  // Check reference layers
+  for (Int curLayerId = 0; curLayerId <= vps.getMaxLayersMinus1(); curLayerId++ )
+  {  
+
+    const TComRepFormat* curRepFormat = vps.getRepFormat( vps.getVpsRepFormatIdx( curLayerId  ) ); 
+
+    Int curLayerIdInNuh      = vps.getLayerIdInNuh( curLayerId );
+    
+    for( Int i = 0; i < vps.getNumDirectRefLayers( curLayerIdInNuh ); i++ )
+    { 
+      Int refLayerId =  vps.getLayerIdInVps( vps.getIdDirectRefLayer( curLayerIdInNuh, i ));//   refLayers[i];
+      const TComRepFormat* refRepFormat = vps.getRepFormat( vps.getVpsRepFormatIdx( refLayerId ) ); 
+
+      // Require equal size
+      xConfirmSingleRepFormat( checkFailed, "SourceHeight",curLayerId, refLayerId,  curRepFormat->getPicHeightVpsInLumaSamples(), refRepFormat->getPicHeightVpsInLumaSamples() );
+      xConfirmSingleRepFormat( checkFailed, "SourceWidth" ,curLayerId, refLayerId,  curRepFormat->getPicWidthVpsInLumaSamples() , refRepFormat->getPicWidthVpsInLumaSamples () );
+#if NH_3D
+
+      // For 3D-HEVC, dependencies can be e.g. from texture 4:2:0 to depth 4:0:0, so check only layers that might be inserted to the reference lists.
+    }
+
+    for( Int i = 0; i < vps.getNumRefListLayers( curLayerIdInNuh  ); i++ )
+    {
+      Int refLayerId =  vps.getLayerIdInVps( vps.getIdRefListLayer( curLayerIdInNuh, i ) );//   refLayers[i];
+      const TComRepFormat* refRepFormat = vps.getRepFormat( vps.getVpsRepFormatIdx( refLayerId ) ); 
+#endif
+      // Sample dependency -> require same bit depth and chroma format
+      xConfirmSingleRepFormat( checkFailed, "ChromaFormatIDC"          , curLayerId, refLayerId,  curRepFormat->getChromaFormatVpsIdc()     , refRepFormat->getChromaFormatVpsIdc()  );
+      xConfirmSingleRepFormat( checkFailed, "InternalBitDepth (Luma)"  , curLayerId, refLayerId,  curRepFormat->getBitDepthVpsLumaMinus8()  , refRepFormat->getBitDepthVpsLumaMinus8());
+      xConfirmSingleRepFormat( checkFailed, "InternalBitDepth (Chroma)", curLayerId, refLayerId,  curRepFormat->getBitDepthVpsChromaMinus8(), refRepFormat->getBitDepthVpsChromaMinus8());
+    }
+    // TBD: add 3D-HEVC constraints e.g. for VSP, QTL
+  }
+
+  if( checkFailed )
+  {
+    exit(0);
+  }
+}
+
+Void TAppEncCfg::xConvertRepFormatParameters(
+  IntAry2d& tmpPad                       ,             
+  IntAry2d& tmpInputBitDepth             ,
+  IntAry2d& tmpOutputBitDepth            ,
+  IntAry2d& tmpMSBExtendedBitDepth       ,
+  IntAry2d& tmpInternalBitDepth          ,
+  IntAry1d& tmpInputChromaFormat         ,
+  IntAry1d& tmpChromaFormat
+  ) 
+{
+  typedef std::pair< IntAry2d*,  IntAry2d* > ParamMapPair;
+  std::vector< ParamMapPair > paramTwoElem;
+  paramTwoElem.push_back( ParamMapPair( &tmpPad                ,  &m_aiPads               )  );
+  paramTwoElem.push_back( ParamMapPair( &tmpInputBitDepth      ,  &m_inputBitDepths       )  );
+  paramTwoElem.push_back( ParamMapPair( &tmpOutputBitDepth     ,  &m_outputBitDepths      )  );
+  paramTwoElem.push_back( ParamMapPair( &tmpMSBExtendedBitDepth,  &m_MSBExtendedBitDepths )  );
+  paramTwoElem.push_back( ParamMapPair( &tmpInternalBitDepth   ,  &m_internalBitDepths    )  );
+  
+  std::vector< IntAry1d* > paramOneElem;
+  paramOneElem.push_back(  &m_confWinLefts  );  
+  paramOneElem.push_back(  &m_confWinRights );
+  paramOneElem.push_back(  &m_confWinTops   );
+  paramOneElem.push_back(  &m_confWinBottoms);
+  paramOneElem.push_back(  &m_iSourceWidths );
+  paramOneElem.push_back(  &m_iSourceHeights);
+  paramOneElem.push_back(  &tmpInputChromaFormat );
+  paramOneElem.push_back(  &tmpChromaFormat );
+
+
+  // Get maximum number of representation formats
+  size_t maxSize = 0;
+
+  for (Int i = 0; i < paramTwoElem.size(); i++)
+  {
+    for (Int j = 0; j < 2; j++ )
+    {
+      IntAry1d& curElems = (* (paramTwoElem[i].first) )[j];
+      maxSize = std::max<size_t>(  maxSize, curElems.size()  );
+    }    
+  }
+
+  for (Int i = 0; i < paramOneElem.size(); i++)
+  {
+    maxSize = std::max<size_t>(  maxSize, (paramOneElem[i]->size() ) );
+  }
+
+  // Resize to maximum
+  for (Int i = 0; i < paramTwoElem.size(); i++)
+  {
+    IntAry2d& curElems = (* (paramTwoElem[i].first) );    
+    for (Int j = 0; j < 2; j++ )
+    { 
+      xResizeVector( curElems[j], (UInt) maxSize );        
+    }
+  }
+
+  for (Int i = 0; i < paramOneElem.size(); i++)
+  {
+    xResizeVector( (*paramOneElem[i]), (UInt) maxSize );              
+  }
+  
+  // Transpose
+  for (Int i = 0; i < paramTwoElem.size(); i++)
+  {
+    IntAry2d&  curElem  = (* (paramTwoElem[i].first  ) );
+    IntAry2d&  curElemT = (* (paramTwoElem[i].second ) );
+
+    curElemT.resize(maxSize);
+    for (Int k = 0; k < maxSize; k++ )
+    {
+      curElemT[k].resize(2);
+      for (Int j = 0; j < 2; j++ )
+      {
+        curElemT[k][j] = curElem[j][k];
+      }
+    }    
+  }
+
+  m_numRepFormats = (Int) maxSize; 
+}
+
+
+
+Void TAppEncCfg::xGetMaxValuesOfApplicableLayers(const TComVPS& vps, Int vpsPtlIdx, Int& maxBitDepthLuma, Int& maxBitDepthChroma, ChromaFormat& maxChromaFormatIdc, Int& maxNumRefLayers )
+{ 
+  maxChromaFormatIdc        = CHROMA_400;
+  maxBitDepthLuma   = -1;
+  maxBitDepthChroma = -1;
+  maxNumRefLayers   = 0; 
+
+  IntAry1d applicableLayerIdsInVps = vps.getLayersOfVpsPtl( vpsPtlIdx );
+
+  for (Int i = 0; i < applicableLayerIdsInVps.size(); i++ )
+  {
+    Int curLayerIdInVps       = applicableLayerIdsInVps[ i ];
+    Int repFormatIdx          = m_layerIdxInVpsToRepFormatIdx[ curLayerIdInVps ];
+    maxChromaFormatIdc        = std::max<ChromaFormat> ( m_chromaFormatIDCs[ repFormatIdx], maxChromaFormatIdc );
+    maxBitDepthLuma   = std::max<Int> ( m_internalBitDepths[ repFormatIdx ][CHANNEL_TYPE_LUMA  ], maxBitDepthLuma   );
+    maxBitDepthChroma = std::max<Int> ( m_internalBitDepths[ repFormatIdx ][CHANNEL_TYPE_CHROMA], maxBitDepthChroma );
+    maxNumRefLayers   = std::max<Int> ( vps.getNumRefLayers( vps.getLayerIdInNuh( curLayerIdInVps ) ), maxNumRefLayers ) ;
+  }
+}
+
+#endif
 
 Bool confirmPara(Bool bflag, const TChar* message)
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 1405)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.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.
  *
@@ -42,4 +42,7 @@
 
 #include "TLibEncoder/TEncCfg.h"
+#if EXTENSION_360_VIDEO
+#include "TAppEncHelper360/TExt360AppEncCfg.h"
+#endif
 #include <sstream>
 #include <vector>
@@ -56,7 +59,80 @@
 // ====================================================================================================================
 
+#if NH_MV
+enum UIProfileName // this is used for determining profile strings, where multiple profiles map to a single profile idc with various constraint flag combinations
+{
+  UI_NONE = 0,
+  UI_MAIN = 1,
+  UI_MAIN10 = 2,
+  UI_MAIN10_STILL_PICTURE=10002,
+  UI_MAINSTILLPICTURE = 3,
+  UI_MAINREXT = 4,
+  UI_HIGHTHROUGHPUTREXT = 5,
+  // The following are RExt profiles, which would map to the MAINREXT profile idc.
+  // The enumeration indicates the bit-depth constraint in the bottom 2 digits
+  //                           the chroma format in the next digit
+  //                           the intra constraint in the next digit (1 for no intra constraint, 2 for intra constraint)
+  //                           If it is a RExt still picture, there is a '1' for the top digit.
+#if NH_MV
+  UI_MULTIVIEWMAIN     = 6,
+#if NH_3D
+  UI_MAIN3D            = 8, 
+#endif
+#endif
+  UI_MONOCHROME_8      = 1008,
+  UI_MONOCHROME_12     = 1012,
+  UI_MONOCHROME_16     = 1016,
+  UI_MAIN_12           = 1112,
+  UI_MAIN_422_10       = 1210,
+  UI_MAIN_422_12       = 1212,
+  UI_MAIN_444          = 1308,
+  UI_MAIN_444_10       = 1310,
+  UI_MAIN_444_12       = 1312,
+  UI_MAIN_444_16       = 1316, // non-standard profile definition, used for development purposes
+  UI_MAIN_INTRA        = 2108,
+  UI_MAIN_10_INTRA     = 2110,
+  UI_MAIN_12_INTRA     = 2112,
+  UI_MAIN_422_10_INTRA = 2210,
+  UI_MAIN_422_12_INTRA = 2212,
+  UI_MAIN_444_INTRA    = 2308,
+  UI_MAIN_444_10_INTRA = 2310,
+  UI_MAIN_444_12_INTRA = 2312,
+  UI_MAIN_444_16_INTRA = 2316,
+  UI_MAIN_444_STILL_PICTURE = 11308,
+  UI_MAIN_444_16_STILL_PICTURE = 12316,
+  // The following are high throughput profiles, which would map to the HIGHTHROUGHPUTREXT profile idc.
+  // The enumeration indicates the bit-depth constraint in the bottom 2 digits
+  //                           the chroma format in the next digit
+  //                           the intra constraint in the next digit
+  //                           There is a '2' for the top digit to indicate it is high throughput profile
+
+  UI_HIGHTHROUGHPUT_444     = 21308,
+  UI_HIGHTHROUGHPUT_444_10  = 21310,
+  UI_HIGHTHROUGHPUT_444_14  = 21314,
+  UI_HIGHTHROUGHPUT_444_16_INTRA  = 22316
+#if NH_MV_ALLOW_NON_CONFORMING
+  , 
+  UI_MULTIVIEWMAIN_NONCONF     = 10000006,
+#if NH_3D
+  UI_MAIN3D_NONCONF            = 10000008, 
+#endif
+#endif
+};
+#endif
+
 /// encoder configuration class
 class TAppEncCfg
 {
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+public:
+  template <class T>
+  struct OptionalValue
+  {
+    Bool bPresent;
+    T    value;
+    OptionalValue() : bPresent(false), value() { }
+  };
+#endif
+
 protected:
   // file I/O
@@ -71,4 +147,11 @@
   Int                    m_numberOfLayers;                    ///< number of Layers to Encode
   Int                    m_iNumberOfViews;                    ///< number of Layers that are views
+#if NH_MV
+  Bool                   m_shareParameterSets;
+  IntAry1d               m_layerIdxInVpsToGopDefIdx;
+  IntAry1d               m_layerIdxInVpsToRepFormatIdx;  
+  Int                    m_numRepFormats;
+  Int                    m_numInputOutputRepFormats;
+#endif
 #else
   std::string m_reconFileName;                                ///< output reconstruction file
@@ -91,12 +174,12 @@
 // layer sets   
   Int                    m_vpsNumLayerSets;                   ///< Number of layer sets
-  IntAry2d m_layerIdxInVpsInSets;           ///< LayerIds in vps of layer set 
-  Int                    m_numAddLayerSets;                    ///< Number of additional layer sets
-  IntAry2d m_highestLayerIdxPlus1;      ///< HighestLayerIdxPlus1 for each additional layer set and each independent layer (value with index 0 will be ignored)
+  IntAry2d               m_layerIdxInVpsInSets;               ///< LayerIds in vps of layer set 
+  Int                    m_numAddLayerSets;                   ///< Number of additional layer sets
+  IntAry2d               m_highestLayerIdxPlus1;              ///< HighestLayerIdxPlus1 for each additional layer set and each independent layer (value with index 0 will be ignored)
   Int                    m_defaultOutputLayerIdc;             ///< Specifies output layers of layer sets, 0: output all layers, 1: output highest layers, 2: specified by LayerIdsInDefOuputLayerSet
   IntAry1d               m_outputLayerSetIdx;                 ///< Indices of layer sets used as additional output layer sets  
-  IntAry2d m_layerIdsInAddOutputLayerSet; ///< LayerIds in vps of additional output layers
-  IntAry2d m_layerIdsInDefOutputLayerSet; ///< Indices in vps of output layers in layer sets
-  IntAry2d               m_profileTierLevelIdx;      ///< Indices of of profile, per layer in layer set
+  IntAry2d               m_layerIdsInAddOutputLayerSet;       ///< LayerIds in vps of additional output layers
+  IntAry2d               m_layerIdsInDefOutputLayerSet;       ///< Indices in vps of output layers in layer sets
+  IntAry2d               m_profileTierLevelIdx;               ///< Indices of of profile, per layer in layer set
   BoolAry1d              m_altOutputLayerFlag;                ///< Alt output layer flag
 
@@ -145,8 +228,20 @@
   UInt      m_FrameSkip;                                   ///< number of skipped frames from the beginning
   UInt      m_temporalSubsampleRatio;                         ///< temporal subsample ratio, 2 means code every two frames
-  Int       m_iSourceWidth;                                   ///< source width in pixel
-  Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
+  
+#if NH_MV
+  IntAry1d       m_iSourceWidths   ;                                   ///< source width in pixel
+  IntAry1d       m_iSourceHeights  ;                                  ///< source height in pixel (when interlaced = field height)
+  IntAry1d       m_inputFileWidths ;                                 ///< width of image in input file  (this is equivalent to sourceWidth,  if sourceWidth  is not subsequently altered due to padding)
+  IntAry1d       m_inputFileHeights;                                ///< height of image in input file (this is equivalent to sourceHeight, if sourceHeight is not subsequently altered due to padding)
+
+  IntAry1d       m_iSourceHeightOrgs;                               ///< original source height in pixel (when interlaced = frame height)
+#else
+  Int       m_iSourceWidth   ;                                   ///< source width in pixel
+  Int       m_iSourceHeight  ;                                  ///< source height in pixel (when interlaced = field height)
+  Int       m_inputFileWidth ;                                 ///< width of image in input file  (this is equivalent to sourceWidth,  if sourceWidth  is not subsequently altered due to padding)
+  Int       m_inputFileHeight;                                ///< height of image in input file (this is equivalent to sourceHeight, if sourceHeight is not subsequently altered due to padding)
 
   Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
+#endif
 
   Bool      m_isField;                                        ///< enable field coding
@@ -156,19 +251,37 @@
 
   Int       m_conformanceWindowMode;
+#if NH_MV
+  IntAry1d  m_confWinLefts  ;
+  IntAry1d  m_confWinRights ;
+  IntAry1d  m_confWinTops   ;
+  IntAry1d  m_confWinBottoms;
+#else
   Int       m_confWinLeft;
   Int       m_confWinRight;
   Int       m_confWinTop;
   Int       m_confWinBottom;
+#endif
   Int       m_framesToBeEncoded;                              ///< number of encoded frames
+#if NH_MV
+  IntAry2d  m_aiPads;                              ///< number of padded pixels for width and height
+#else
   Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
+#endif
   Bool      m_AccessUnitDelimiter;                            ///< add Access Unit Delimiter NAL units
   InputColourSpaceConversion m_inputColourSpaceConvert;       ///< colour space conversion to apply to input video
   Bool      m_snrInternalColourSpace;                       ///< if true, then no colour space conversion is applied for snr calculation, otherwise inverse of input is applied.
   Bool      m_outputInternalColourSpace;                    ///< if true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied.
+#if NH_MV
+  std::vector<ChromaFormat> m_InputChromaFormatIDC;
+#else
   ChromaFormat m_InputChromaFormatIDC;
+#endif
 
   Bool      m_printMSEBasedSequencePSNR;
   Bool      m_printFrameMSE;
   Bool      m_printSequenceMSE;
+#if JVET_F0064_MSSSIM
+  Bool      m_printMSSSIM;
+#endif
   Bool      m_cabacZeroWordPaddingEnabled;
   Bool      m_bClipInputVideoToRec709Range;
@@ -178,12 +291,26 @@
 #if NH_MV
   std::vector< Profile::Name > m_profiles;
+  
+  std::vector<UIProfileName>   m_uiProfiles;
+
   std::vector< Level::Tier   > m_levelTier;
   std::vector< Level::Name   > m_level;
   std::vector< Bool          > m_inblFlag; 
+
+  IntAry1d                    m_bitDepthConstraints          ;
+  IntAry1d                    m_tmpConstraintChromaFormats   ;
+  std::vector< ChromaFormat > m_chromaFormatConstraints      ;
+  BoolAry1d                   m_intraConstraintFlags         ;
+  BoolAry1d                   m_onePictureOnlyConstraintFlags;
+  BoolAry1d                   m_lowerBitRateConstraintFlags  ;
+  BoolAry1d                   m_progressiveSourceFlags       ;
+  BoolAry1d                   m_interlacedSourceFlags        ;
+  BoolAry1d                   m_nonPackedConstraintFlags     ;
+  BoolAry1d                   m_frameOnlyConstraintFlags     ;
+
 #else
   Profile::Name m_profile;
   Level::Tier   m_levelTier;
   Level::Name   m_level;
-#endif
   UInt          m_bitDepthConstraint;
   ChromaFormat  m_chromaFormatConstraint;
@@ -191,8 +318,9 @@
   Bool          m_onePictureOnlyConstraintFlag;
   Bool          m_lowerBitRateConstraintFlag;
-  Bool m_progressiveSourceFlag;
-  Bool m_interlacedSourceFlag;
-  Bool m_nonPackedConstraintFlag;
-  Bool m_frameOnlyConstraintFlag;
+  Bool          m_progressiveSourceFlag;
+  Bool          m_interlacedSourceFlag;
+  Bool          m_nonPackedConstraintFlag;
+  Bool          m_frameOnlyConstraintFlag;
+#endif
 
   // coding structure
@@ -204,4 +332,7 @@
   Int       m_iDecodingRefreshType;                           ///< random access type
   Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
+#if JCTVC_Y0038_PARAMS
+  Bool      m_bReWriteParamSetsFlag;                          ///< Flag to enable rewriting of parameter sets at random access points
+#endif  
 #if NH_MV
   Int       m_extraRPSsMvc[MAX_NUM_LAYERS];                       ///< extra RPSs added to handle CRA for each layer
@@ -234,9 +365,21 @@
   // coding quality
 #if NH_MV
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+  std::vector<Int>   m_qpIncrementAtSourceFrame;             ///< Optional source frame number at which all subsequent frames are to use an increased internal QP.
+#else
   std::vector<Double>  m_fQP;                                 ///< QP value of key-picture (floating point) for each layer
+#endif
   std::vector<Int>     m_iQP;                                 ///< QP value of key-picture (integer) for each layer
 #else
+#if JVET_E0059_FLOATING_POINT_QP_FIX
+  OptionalValue<UInt> m_qpIncrementAtSourceFrame;             ///< Optional source frame number at which all subsequent frames are to use an increased internal QP.
+#else
   Double    m_fQP;                                            ///< QP value of key-picture (floating point)
+#endif
   Int       m_iQP;                                            ///< QP value of key-picture (integer)
+#endif
+#if X0038_LAMBDA_FROM_QP_CAPABILITY
+  Int       m_intraQPOffset;                                  ///< QP offset for intra slice (integer)
+  Bool      m_lambdaFromQPEnable;                             ///< enable flag for QP:lambda fix
 #endif
   std::string m_dQPFileName;                                  ///< QP offset for each slice (initialized from external file)
@@ -254,9 +397,8 @@
   Int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default)
   Int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
-
-#if W0038_CQP_ADJ
+  WCGChromaQPControl m_wcgChromaQpControl;                    ///< Wide-colour-gamut chroma QP control.
   UInt      m_sliceChromaQpOffsetPeriodicity;                 ///< Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.
   Int       m_sliceChromaQpOffsetIntraOrPeriodic[2/*Cb,Cr*/]; ///< Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.
-#endif
+  LumaLevelToDeltaQPMapping m_lumaLevelToDeltaQPMapping;      ///< mapping from luma level to Delta QP.
 #if ADAPTIVE_QP_SELECTION
   Bool      m_bUseAdaptQpSelect;
@@ -282,5 +424,9 @@
   UInt      m_uiMaxCUHeight;                                  ///< max. CU height in pixel
   UInt      m_uiMaxCUDepth;                                   ///< max. CU depth (as specified by command line)
-  UInt      m_uiMaxTotalCUDepth;                              ///< max. total CU depth - includes depth of transform-block structure
+#if NH_MV
+  IntAry1d  m_uiMaxTotalCUDepth;                              ///< max. total CU depth - includes depth of transform-block structure  
+#else
+  UInt      m_uiMaxTotalCUDepth;                              ///< max. total CU depth - includes depth of transform-block structure  
+#endif
   UInt      m_uiLog2DiffMaxMinCodingBlockSize;                ///< difference between largest and smallest CU depth
 
@@ -293,13 +439,25 @@
 
   // coding tools (bit-depth)
+#if NH_MV
+  IntAry2d  m_inputBitDepths      ;         ///< bit-depth of input file
+  IntAry2d  m_outputBitDepths     ;         ///< bit-depth of output file
+  IntAry2d  m_MSBExtendedBitDepths;         ///< bit-depth of input samples after MSB extension
+  IntAry2d  m_internalBitDepths   ;         ///< bit-depth codec operates at (input/output files will be converted)
+#else
   Int       m_inputBitDepth   [MAX_NUM_CHANNEL_TYPE];         ///< bit-depth of input file
   Int       m_outputBitDepth  [MAX_NUM_CHANNEL_TYPE];         ///< bit-depth of output file
   Int       m_MSBExtendedBitDepth[MAX_NUM_CHANNEL_TYPE];      ///< bit-depth of input samples after MSB extension
   Int       m_internalBitDepth[MAX_NUM_CHANNEL_TYPE];         ///< bit-depth codec operates at (input/output files will be converted)
+#endif
+
   Bool      m_extendedPrecisionProcessingFlag;
   Bool      m_highPrecisionOffsetsEnabledFlag;
 
   //coding tools (chroma format)
+#if NH_MV
+  std::vector<ChromaFormat> m_chromaFormatIDCs;
+#else
   ChromaFormat m_chromaFormatIDC;
+#endif
 
   // coding tools (PCM bit-depth)
@@ -317,7 +475,5 @@
   Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
   Bool      m_saoCtuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for CTU bottom and right boundary areas
-#if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
   Bool      m_saoResetEncoderStateAfterIRAP;                  ///< When true, SAO encoder state will be reset following an IRAP.
-#endif
   // coding tools (loop filter)
 #if NH_MV
@@ -329,9 +485,5 @@
   Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
   Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
-#if W0038_DB_OPT
   Int       m_deblockingFilterMetric;                         ///< blockiness metric in encoder
-#else
-  Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
-#endif
   // coding tools (PCM)
   Bool      m_usePCM;                                         ///< flag for using IPCM
@@ -346,7 +498,5 @@
   Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
   Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
-#if T0196_SELECTIVE_RDOQ
   Bool      m_useSelectiveRDOQ;                               ///< flag for using selective RDOQ
-#endif
   Int       m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
   Bool      m_bDisableIntraPUsInInterSlices;                  ///< Flag for disabling intra predicted PUs in inter slices.
@@ -437,4 +587,7 @@
   Bool      m_scalableNestingSEIEnabled;
   Bool      m_tmctsSEIEnabled;
+#if MCTS_ENC_CHECK
+  Bool      m_tmctsSEITileConstraint;
+#endif
   Bool      m_timeCodeSEIEnabled;
   Int       m_timeCodeSEINumTs;
@@ -451,7 +604,7 @@
   Int*      m_kneeSEIInputKneePoint;
   Int*      m_kneeSEIOutputKneePoint;
-#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
   Int       m_preferredTransferCharacteristics;
-#endif
+  UInt      m_greenMetadataType;
+  UInt      m_xsdMetricType;
 
   // weighted prediction
@@ -464,5 +617,5 @@
 
   Int       m_TMVPModeId;
-  Bool      m_signHideFlag;
+  Bool      m_signDataHidingEnabledFlag;
   Bool      m_RCEnableRateControl;                ///< enable rate control or not
   Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
@@ -472,10 +625,7 @@
   Int       m_RCInitialQP;                        ///< inital QP for rate control
   Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
-
-#if U0132_TARGET_BITS_SATURATION
   Bool      m_RCCpbSaturationEnabled;             ///< enable target bits saturation to avoid CPB overflow and underflow
   UInt      m_RCCpbSize;                          ///< CPB size
   Double    m_RCInitialCpbFullness;               ///< initial CPB fullness 
-#endif
 
 #if KWU_RC_VIEWRC_E0227
@@ -490,6 +640,6 @@
   std::string m_scalingListFileName;                          ///< quantization matrix file name
 
-  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
-  Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true.
+  Bool      m_TransquantBypassEnabledFlag;                    ///< transquant_bypass_enabled_flag setting in PPS.
+  Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enabled_flag, then, if true, all CU transquant bypass flags will be set to true.
   CostMode  m_costMode;                                       ///< Cost mode to use
 
@@ -537,4 +687,11 @@
   std::string m_summaryPicFilenameBase;                       ///< Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended.
   UInt        m_summaryVerboseness;                           ///< Specifies the level of the verboseness of the text output.
+
+#if EXTENSION_360_VIDEO
+  TExt360AppEncCfg m_ext360;
+  friend class TExt360AppEncCfg;
+  friend class TExt360AppEncTop;
+#endif
+
 #if NH_MV
   Bool              m_outputVpsInfo;
@@ -546,6 +703,7 @@
   Bool      m_depth420OutputFlag;                             ///< Output depth layers in 4:2:0 format
 #endif
+
+#if NH_3D || NH_3D_VSO
     // Camera parameters
-#if NH_3D || NH_3D_VSO
   TChar*    m_pchCameraParameterFile;                         ///< camera parameter file
   TAppComCamPara m_cCameraData;
@@ -578,9 +736,6 @@
 #if NH_3D
   Bool       m_useDLT;                                        ///< flag for using DLT
-#endif
-#if NH_3D_QTL
   Bool       m_bUseQTL;                                        ///< flag for using depth QuadTree Limitation
-#endif
-#if NH_3D
+
   BoolAry1d  m_ivMvPredFlag;
   BoolAry1d  m_ivMvScalingFlag;
@@ -601,7 +756,26 @@
   // internal member functions
   Void  xCheckParameter ();                                   ///< check validity of configuration values
-  Void  xPrintParameter ();                                   ///< print configuration values
+  Void  xPrintParameter ();                                   ///< print configuration values  
+ 
   Void  xPrintUsage     ();                                   ///< print usage
 #if NH_MV
+  Void xConfirmRepFormat( const TComVPS& vps);
+  Void xDeriveProfAndConstrFlags( const TComVPS& vps ); 
+  Void xCheckProfiles           ( const TComVPS& vps ); 
+
+  Void xPrintProfiles();
+
+  template< typename T >
+  Void xConfirmSingleRepFormat(Bool& checkFailed, std::string name, Int curLayer, Int refLayer, T valCur, T valRef )
+  {
+    if ( valCur != valRef )
+    {
+      printf("Error: %s of layer %d and its reference layer %d must be equal. \n", name.c_str(), curLayer, refLayer ); 
+      checkFailed = true; 
+    }
+  }
+
+  GOPEntry*  xGetGopEntries( Int layerIdInVps );
+  GOPEntry*  xGetGopEntry( Int layerIdInVps, Int poc );
 
   template<typename T>
@@ -697,4 +871,16 @@
   Bool  parseCfg  ( Int argc, TChar* argv[] );                ///< parse configuration file to fill member variables
 
+private:
+  Void   xConvertRepFormatParameters(
+    IntAry2d& tmpPad                       ,             
+    IntAry2d& tmpInputBitDepth             ,
+    IntAry2d& tmpOutputBitDepth            ,
+    IntAry2d& tmpMSBExtendedBitDepth       ,
+    IntAry2d& tmpInternalBitDepth          ,
+    IntAry1d& tmpInputChromaFormat         ,
+    IntAry1d& tmpChromaFormat
+    );
+
+  Void xGetMaxValuesOfApplicableLayers(const TComVPS& vps, Int vpsPtlIdx, Int& maxBitDepthLuma, Int& maxBitDepthChroma, ChromaFormat& maxChromaFormatIdc, Int& maxNumRefLayers);
 };// END CLASS DEFINITION TAppEncCfg
 
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1405)
+++ trunk/source/App/TAppEncoder/TAppEncTop.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.
  *
@@ -47,4 +47,8 @@
 #include "TLibEncoder/AnnexBwrite.h"
 
+#if EXTENSION_360_VIDEO
+#include "TAppEncHelper360/TExt360AppEncTop.h"
+#endif
+
 using namespace std;
 
@@ -57,6 +61,9 @@
 
 TAppEncTop::TAppEncTop()
+#if NH_MV
+  : m_spsMap( MAX_NUM_SPS ),
+    m_ppsMap( MAX_NUM_PPS )
+#endif
 {
-
 #if NH_MV
   m_vps = new TComVPS; 
@@ -88,9 +95,5 @@
   
 #if NH_3D
-  vps.createCamPars(m_iNumberOfViews);  
-#endif
-
-#if NH_3D_DLT
-  TComDLT dlt = TComDLT();
+  vps.createCamPars(m_iNumberOfViews);    
 #endif
 
@@ -140,7 +143,7 @@
   xSetDimensionIdAndLength ( vps );
   xSetDependencies         ( vps );
-  xSetRepFormat            ( vps ); 
-  xSetProfileTierLevel     ( vps ); 
-  xSetLayerSets            ( vps ); 
+  xSetRepFormat            ( vps );   
+  xSetLayerSets            ( vps );   
+  xSetProfileTierLevel     ( vps );   
   xSetDpbSize              ( vps ); 
   xSetVPSVUI               ( vps ); 
@@ -151,7 +154,12 @@
   m_ivPicLists.setVPS      ( &vps );
 #endif
-#if NH_3D_DLT
+#if NH_3D
+  TComDLT dlt = TComDLT();
   xDeriveDltArray          ( vps, &dlt );
 #endif
+
+
+  xDeriveParameterSetIds( vps );
+
   if ( m_targetEncLayerIdList.size() == 0 )
   {
@@ -182,4 +190,5 @@
     vps.printLayerSets(); 
     vps.printPTL(); 
+    vps.printRepFormat();
   }
 
@@ -188,23 +197,23 @@
   for (Int d = 0; d < 2; d++)
   {  
-    m_sps3dExtension.setIvDiMcEnabledFlag          ( d, m_ivMvPredFlag[d]       );
-    m_sps3dExtension.setIvMvScalEnabledFlag       ( d, m_ivMvScalingFlag[d]    );
+    m_sps3dExtension.setIvDiMcEnabledFlag             ( d, m_ivMvPredFlag[d]       );
+    m_sps3dExtension.setIvMvScalEnabledFlag           ( d, m_ivMvScalingFlag[d]    );
     if (d == 0 )
     {    
-      m_sps3dExtension.setLog2IvmcSubPbSizeMinus3   ( d, m_log2SubPbSizeMinus3   );
-      m_sps3dExtension.setIvResPredEnabledFlag         ( d, m_ivResPredFlag         );
-      m_sps3dExtension.setDepthRefEnabledFlag   ( d, m_depthRefinementFlag   );
-      m_sps3dExtension.setVspMcEnabledFlag ( d, m_viewSynthesisPredFlag );
-      m_sps3dExtension.setDbbpEnabledFlag ( d, m_depthBasedBlkPartFlag );
+      m_sps3dExtension.setLog2IvmcSubPbSizeMinus3     ( d, m_log2SubPbSizeMinus3   );
+      m_sps3dExtension.setIvResPredEnabledFlag        ( d, m_ivResPredFlag         );
+      m_sps3dExtension.setDepthRefEnabledFlag         ( d, m_depthRefinementFlag   );
+      m_sps3dExtension.setVspMcEnabledFlag            ( d, m_viewSynthesisPredFlag );
+      m_sps3dExtension.setDbbpEnabledFlag             ( d, m_depthBasedBlkPartFlag );
     }
     else
     {    
-      m_sps3dExtension.setTexMcEnabledFlag               ( d, m_mpiFlag               );
-      m_sps3dExtension.setLog2TexmcSubPbSizeMinus3( d, m_log2MpiSubPbSizeMinus3);
-      m_sps3dExtension.setIntraContourEnabledFlag      ( d, m_intraContourFlag      );
-      m_sps3dExtension.setIntraDcOnlyWedgeEnabledFlag     ( d, m_intraSdcFlag || m_intraWedgeFlag     );
-      m_sps3dExtension.setCqtCuPartPredEnabledFlag            ( d, m_qtPredFlag            );
-      m_sps3dExtension.setInterDcOnlyEnabledFlag          ( d, m_interSdcFlag          );
-      m_sps3dExtension.setSkipIntraEnabledFlag    ( d, m_depthIntraSkipFlag    );  
+      m_sps3dExtension.setTexMcEnabledFlag            ( d, m_mpiFlag               );
+      m_sps3dExtension.setLog2TexmcSubPbSizeMinus3    ( d, m_log2MpiSubPbSizeMinus3);
+      m_sps3dExtension.setIntraContourEnabledFlag     ( d, m_intraContourFlag      );
+      m_sps3dExtension.setIntraDcOnlyWedgeEnabledFlag ( d, m_intraSdcFlag || m_intraWedgeFlag     );
+      m_sps3dExtension.setCqtCuPartPredEnabledFlag    ( d, m_qtPredFlag            );
+      m_sps3dExtension.setInterDcOnlyEnabledFlag      ( d, m_interSdcFlag          );
+      m_sps3dExtension.setSkipIntraEnabledFlag        ( d, m_depthIntraSkipFlag    );  
     }
   }
@@ -216,5 +225,9 @@
   {
     m_frameRcvd                 .push_back(0);
+#if NH_MV
+    m_acTEncTopList             .push_back(new TEncTop( m_spsMap, m_ppsMap ) ); 
+#else
     m_acTEncTopList             .push_back(new TEncTop); 
+#endif
     m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
     m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
@@ -261,16 +274,10 @@
   for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
   {
+    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdInVps];
     m_cListPicYuvRec            .push_back(new TComList<TComPicYuv*>) ;
-
-#if !NH_MV
-    m_ivPicLists.push_back( m_acTEncTopList[ layerIdInVps ]->getListPic()  ); 
-#endif
-
     TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ];  // It is not a member, but this name helps avoiding code duplication !!!
 
     Int layerId = vps.getLayerIdInNuh          ( layerIdInVps );
-#if NH_MV
     m_ivPicLists.getSubDpb( layerId, true ); 
-#endif
 
     m_cTEncTop.setLayerIdInVps                 ( layerIdInVps ); 
@@ -278,4 +285,6 @@
     m_cTEncTop.setViewId                       ( vps.getViewId      (  layerId ) );
     m_cTEncTop.setViewIndex                    ( vps.getViewIndex   (  layerId ) );
+    m_cTEncTop.setSendParameterSets            ( m_sendParameterSets[ layerIdInVps ]  );
+    m_cTEncTop.setParameterSetId               ( m_parameterSetId   [ layerIdInVps ]  );
 #if NH_3D_VSO || NH_3D
     Bool isDepth    = ( vps.getDepthId     ( layerId ) != 0  ) ;
@@ -305,18 +314,13 @@
 #endif // H_3D_VSO
 #if NH_3D
-#if NH_3D_IC
     m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC );
     m_cTEncTop.setUseICLowLatencyEnc           ( m_bUseLowLatencyICEnc );
-#endif
-
-    
+
     m_cTEncTop.setUseDMM                       ( isDepth ? m_intraWedgeFlag   : false );
     m_cTEncTop.setUseSDC                       ( isDepth ? m_intraSdcFlag     : false );
     m_cTEncTop.setUseDLT                       ( isDepth ? m_useDLT   : false );
-#endif
-#if NH_3D_QTL
+
     m_cTEncTop.setUseQTL                       ( isDepth || isAuxDepth ? m_bUseQTL  : false );
-#endif
-#if NH_3D
+
     m_cTEncTop.setSps3dExtension               ( m_sps3dExtension );
 #endif // NH_3D
@@ -326,15 +330,31 @@
   m_cTEncTop.setVPS(&vps);
 
-#if NH_3D_DLT
+#if NH_3D
   m_cTEncTop.setDLT(dlt);
 #endif
 
 #if NH_MV
-  m_cTEncTop.setProfile                                           ( m_profiles[0]);
-  m_cTEncTop.setLevel                                             ( m_levelTier[0], m_level[0] );
+  // These values go to the SPS of the base layer only and should apply as follows:
+  //   If the profile_tier_level( ) syntax structure is included in an active SPS for the base layer 
+  //    or is the profile_tier_level( ) syntax structure VpsProfileTierLevel[ 0 ], 
+  //    it applies to the OLS containing all layers in the bitstream but with only the base layer being the output layer.
+  //   Otherwise, if the profile_tier_level( ) syntax structure is included in an active SPS 
+  //    for an independent non-base layer with nuh_layer_id equal to layerId, it applies to the output bitstream 
+  //    of the independent non-base layer rewriting process of clause F.10.2 with the input variables assignedBaseLayerId equal to layerId and tIdTarget equal to 6.
+
+  m_cTEncTop.setProfile                                           ( m_profiles[0]                       );
+  m_cTEncTop.setLevel                                             ( m_levelTier[0], m_level[0]          );
+  m_cTEncTop.setProgressiveSourceFlag                             ( m_progressiveSourceFlags        [0] );
+  m_cTEncTop.setInterlacedSourceFlag                              ( m_interlacedSourceFlags         [0] );
+  m_cTEncTop.setNonPackedConstraintFlag                           ( m_nonPackedConstraintFlags      [0] );
+  m_cTEncTop.setFrameOnlyConstraintFlag                           ( m_frameOnlyConstraintFlags      [0] );
+  m_cTEncTop.setBitDepthConstraintValue                           ( m_bitDepthConstraints           [0] );
+  m_cTEncTop.setChromaFormatConstraintValue                       ( m_chromaFormatConstraints       [0] );
+  m_cTEncTop.setIntraConstraintFlag                               ( m_intraConstraintFlags          [0] );
+  m_cTEncTop.setOnePictureOnlyConstraintFlag                      ( m_onePictureOnlyConstraintFlags [0] );
+  m_cTEncTop.setLowerBitRateConstraintFlag                        ( m_lowerBitRateConstraintFlags   [0] );
 #else
   m_cTEncTop.setProfile                                           ( m_profile);
   m_cTEncTop.setLevel                                             ( m_levelTier, m_level);
-#endif
   m_cTEncTop.setProgressiveSourceFlag                             ( m_progressiveSourceFlag);
   m_cTEncTop.setInterlacedSourceFlag                              ( m_interlacedSourceFlag);
@@ -347,7 +367,12 @@
   m_cTEncTop.setLowerBitRateConstraintFlag                        ( m_lowerBitRateConstraintFlag );
 
+#endif
+
   m_cTEncTop.setPrintMSEBasedSequencePSNR                         ( m_printMSEBasedSequencePSNR);
   m_cTEncTop.setPrintFrameMSE                                     ( m_printFrameMSE);
   m_cTEncTop.setPrintSequenceMSE                                  ( m_printSequenceMSE);
+#if JVET_F0064_MSSSIM
+  m_cTEncTop.setPrintMSSSIM                                       ( m_printMSSSIM );
+#endif
   m_cTEncTop.setCabacZeroWordPaddingEnabled                       ( m_cabacZeroWordPaddingEnabled );
 
@@ -355,7 +380,14 @@
   m_cTEncTop.setFrameSkip                                         ( m_FrameSkip );
   m_cTEncTop.setTemporalSubsampleRatio                            ( m_temporalSubsampleRatio );
+#if NH_MV
+  m_cTEncTop.setSourceWidth                                       ( m_iSourceWidths [repFormatIdx] );
+  m_cTEncTop.setSourceHeight                                      ( m_iSourceHeights[repFormatIdx] );
+
+  m_cTEncTop.setConformanceWindow                                 ( m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx] );
+#else
   m_cTEncTop.setSourceWidth                                       ( m_iSourceWidth );
   m_cTEncTop.setSourceHeight                                      ( m_iSourceHeight );
   m_cTEncTop.setConformanceWindow                                 ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
+#endif
   m_cTEncTop.setFramesToBeEncoded                                 ( m_framesToBeEncoded );
 
@@ -368,6 +400,9 @@
   m_cTEncTop.setDecodingRefreshType                               ( m_iDecodingRefreshType );
   m_cTEncTop.setGOPSize                                           ( m_iGOPSize );
-#if NH_MV
-  m_cTEncTop.setGopList                                           ( m_GOPListMvc[layerIdInVps] );
+#if JCTVC_Y0038_PARAMS
+  m_cTEncTop.setReWriteParamSetsFlag                              ( m_bReWriteParamSetsFlag );
+#endif
+#if NH_MV
+  m_cTEncTop.setGopList                                           ( xGetGopEntries(layerIdInVps) );
   m_cTEncTop.setExtraRPSs                                         ( m_extraRPSsMvc[layerIdInVps] );
   for(Int i = 0; i < MAX_TLAYER; i++)
@@ -398,5 +433,14 @@
 #endif
 
+#if X0038_LAMBDA_FROM_QP_CAPABILITY
+  m_cTEncTop.setIntraQPOffset                                     ( m_intraQPOffset );
+  m_cTEncTop.setLambdaFromQPEnable                                ( m_lambdaFromQPEnable );
+#endif
+#if NH_MV
+  m_cTEncTop.setPad                                               ( &m_aiPads[ repFormatIdx ][0] );
+#else
   m_cTEncTop.setPad                                               ( m_aiPad );
+#endif
+
   m_cTEncTop.setAccessUnitDelimiter                               ( m_AccessUnitDelimiter );
 #if NH_MV
@@ -418,9 +462,5 @@
   m_cTEncTop.setLoopFilterBetaOffset                              ( m_loopFilterBetaOffsetDiv2  );
   m_cTEncTop.setLoopFilterTcOffset                                ( m_loopFilterTcOffsetDiv2    );
-#if W0038_DB_OPT
   m_cTEncTop.setDeblockingFilterMetric                            ( m_deblockingFilterMetric );
-#else
-  m_cTEncTop.setDeblockingFilterMetric                            ( m_DeblockingFilterMetric );
-#endif
 
   //====== Motion search ========
@@ -444,10 +484,9 @@
   m_cTEncTop.setChromaCbQpOffset                                  ( m_cbQpOffset     );
   m_cTEncTop.setChromaCrQpOffset                                  ( m_crQpOffset  );
-#if W0038_CQP_ADJ
+  m_cTEncTop.setWCGChromaQpControl                                ( m_wcgChromaQpControl );
   m_cTEncTop.setSliceChromaOffsetQpIntraOrPeriodic                ( m_sliceChromaQpOffsetPeriodicity, m_sliceChromaQpOffsetIntraOrPeriodic );
-#endif
-
-#if NH_3D
-  m_cTEncTop.setChromaFormatIdc                                   ( isDepth ? CHROMA_400 : m_chromaFormatIDC );
+
+#if NH_MV
+  m_cTEncTop.setChromaFormatIdc                                   ( m_chromaFormatIDCs[ repFormatIdx ] );
 #else
   m_cTEncTop.setChromaFormatIdc                                   ( m_chromaFormatIDC  );
@@ -466,5 +505,10 @@
 
   //====== Tool list ========
+  m_cTEncTop.setLumaLevelToDeltaQPControls                        ( m_lumaLevelToDeltaQPMapping );
+#if X0038_LAMBDA_FROM_QP_CAPABILITY
+  m_cTEncTop.setDeltaQpRD( (m_costMode==COST_LOSSLESS_CODING) ? 0 : m_uiDeltaQpRD );
+#else
   m_cTEncTop.setDeltaQpRD                                         ( m_uiDeltaQpRD  );
+#endif
   m_cTEncTop.setFastDeltaQp                                       ( m_bFastDeltaQP  );
   m_cTEncTop.setUseASR                                            ( m_bUseASR      );
@@ -477,11 +521,13 @@
   m_cTEncTop.setUseRDOQ                                           ( m_useRDOQ     );
   m_cTEncTop.setUseRDOQTS                                         ( m_useRDOQTS   );
-#if T0196_SELECTIVE_RDOQ
   m_cTEncTop.setUseSelectiveRDOQ                                  ( m_useSelectiveRDOQ );
-#endif
   m_cTEncTop.setRDpenalty                                         ( m_rdPenalty );
   m_cTEncTop.setMaxCUWidth                                        ( m_uiMaxCUWidth );
   m_cTEncTop.setMaxCUHeight                                       ( m_uiMaxCUHeight );
+#if NH_MV
+  m_cTEncTop.setMaxTotalCUDepth                                   ( m_uiMaxTotalCUDepth[ repFormatIdx] );
+#else
   m_cTEncTop.setMaxTotalCUDepth                                   ( m_uiMaxTotalCUDepth );
+#endif
   m_cTEncTop.setLog2DiffMaxMinCodingBlockSize                     ( m_uiLog2DiffMaxMinCodingBlockSize );
   m_cTEncTop.setQuadtreeTULog2MaxSize                             ( m_uiQuadtreeTULog2MaxSize );
@@ -524,6 +570,11 @@
   for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
   {
+#if NH_MV
+    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepths[repFormatIdx][channelType]);
+    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepths[repFormatIdx][channelType] : m_internalBitDepths[repFormatIdx][channelType]);
+#else
     m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]);
     m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]);
+#endif
   }
 
@@ -562,7 +613,5 @@
 
   m_cTEncTop.setSaoCtuBoundary                                    ( m_saoCtuBoundary);
-#if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
   m_cTEncTop.setSaoResetEncoderStateAfterIRAP                     ( m_saoResetEncoderStateAfterIRAP);
-#endif
   m_cTEncTop.setPCMInputBitDepthFlag                              ( m_bPCMInputBitDepthFlag);
   m_cTEncTop.setPCMFilterDisableFlag                              ( m_bPCMFilterDisableFlag);
@@ -620,4 +669,7 @@
   m_cTEncTop.setScalableNestingSEIEnabled                         ( m_scalableNestingSEIEnabled );
   m_cTEncTop.setTMCTSSEIEnabled                                   ( m_tmctsSEIEnabled );
+#if MCTS_ENC_CHECK
+  m_cTEncTop.setTMCTSSEITileConstraint                            ( m_tmctsSEITileConstraint );
+#endif
   m_cTEncTop.setTimeCodeSEIEnabled                                ( m_timeCodeSEIEnabled );
   m_cTEncTop.setNumberOfTimeSets                                  ( m_timeCodeSEINumTs );
@@ -639,9 +691,9 @@
   m_cTEncTop.setColourRemapInfoSEIFileRoot                        ( m_colourRemapSEIFileRoot );
   m_cTEncTop.setMasteringDisplaySEI                               ( m_masteringDisplay );
-#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
   m_cTEncTop.setSEIAlternativeTransferCharacteristicsSEIEnable    ( m_preferredTransferCharacteristics>=0     );
   m_cTEncTop.setSEIPreferredTransferCharacteristics               ( UChar(m_preferredTransferCharacteristics) );
-#endif
-
+  m_cTEncTop.setSEIGreenMetadataInfoSEIEnable                     ( m_greenMetadataType > 0 );
+  m_cTEncTop.setSEIGreenMetadataType                              ( UChar(m_greenMetadataType) );
+  m_cTEncTop.setSEIXSDMetricType                                  ( UChar(m_xsdMetricType) );
 #if NH_MV
   m_cTEncTop.setSeiMessages                                       ( &m_seiMessages ); 
@@ -667,5 +719,6 @@
   m_cTEncTop.setUseScalingListId                                  ( m_useScalingListId  );
   m_cTEncTop.setScalingListFileName                               ( m_scalingListFileName );
-  m_cTEncTop.setSignHideFlag                                      ( m_signHideFlag);
+  m_cTEncTop.setSignDataHidingEnabledFlag                         ( m_signDataHidingEnabledFlag);
+
 #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
   if(!m_cTEncTop.getIsDepth())    //only for texture
@@ -688,9 +741,7 @@
   m_cTEncTop.setInitialQP                                         ( m_RCInitialQP );
   m_cTEncTop.setForceIntraQP                                      ( m_RCForceIntraQP );
-#if U0132_TARGET_BITS_SATURATION
   m_cTEncTop.setCpbSaturationEnabled                              ( m_RCCpbSaturationEnabled );
   m_cTEncTop.setCpbSize                                           ( m_RCCpbSize );
   m_cTEncTop.setInitialCpbFullness                                ( m_RCInitialCpbFullness );
-#endif
 
 #if KWU_RC_MADPRED_E0227
@@ -761,5 +812,5 @@
   }
 #endif
-  m_cTEncTop.setTransquantBypassEnableFlag                        ( m_TransquantBypassEnableFlag );
+  m_cTEncTop.setTransquantBypassEnabledFlag                       ( m_TransquantBypassEnabledFlag );
   m_cTEncTop.setCUTransquantBypassFlagForceValue                  ( m_CUTransquantBypassFlagForce );
   m_cTEncTop.setCostMode                                          ( m_costMode );
@@ -812,8 +863,18 @@
     if ( m_uiVSOMode == 4 )
     {
+
+      for( Int i = 1; i < m_numRepFormats; i++)
+      {
+        if ( m_iSourceWidths[0] != m_iSourceWidths[i] || m_iSourceHeights[0] != m_iSourceHeights[i] )
+        {
+          std::cout << "Enabling the RM requires equal size of all layers." << std::endl;
+          AOF( false );
+        }
+      }
+
 #if H_3D_VSO_EARLY_SKIP
-      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, true, m_bVSOEarlySkip );
-#else
-      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 , true);
+      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidths[0], m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, true, m_bVSOEarlySkip );
+#else
+      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidths[0], m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 , true);
 #endif
       for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
@@ -851,5 +912,5 @@
   // initialize global variables
   initROM();
-#if NH_3D_DMM
+#if NH_3D
   initWedgeLists( true );
 #endif
@@ -857,10 +918,11 @@
   for( Int layer=0; layer < m_numberOfLayers; layer++)
   {
-    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
-    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
+    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
+    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, &m_inputBitDepths[repFormatIdx][0], &m_MSBExtendedBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0] );  // read  mode
+    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidths[repFormatIdx] - m_aiPads[repFormatIdx][0], m_iSourceHeights[repFormatIdx] - m_aiPads[repFormatIdx][1], m_InputChromaFormatIDC[repFormatIdx]);
 
     if (m_pchReconFileList[layer])
     {
-      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth);  // write mode
+      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, &m_outputBitDepths[repFormatIdx][0], &m_outputBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0]);  // write mode
     }
     m_acTEncTopList[layer]->create();
@@ -869,5 +931,5 @@
   // Video I/O
   m_cTVideoIOYuvInputFile.open( m_inputFileName,     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
-  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
+  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC);
 
   if (!m_reconFileName.empty())
@@ -949,5 +1011,5 @@
   }
 
-#if !NH_3D
+#if !NH_MV
   TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
 #endif
@@ -958,6 +1020,7 @@
   xCreateLib();
   xInitLib(m_isField);
-
+#if NH_MV
   printChromaFormat();
+#endif
 
   // main encoder loop
@@ -985,12 +1048,12 @@
   list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
   
-#if NH_3D
-  TComPicYuv* picYuvOrg[2]; 
-  TComPicYuv  picYuvTrueOrg[2]; 
-  for (Int d = 0; d < 2 ; d++)
-  {
+#if NH_MV
+  std::vector<TComPicYuv*> picYuvOrg    ( m_numRepFormats ); 
+  std::vector<TComPicYuv > picYuvTrueOrg( m_numRepFormats ); 
+  for (Int d = 0; d < m_numRepFormats ; d++)
+  { 
     picYuvOrg[d] = new TComPicYuv;
-    picYuvOrg[d]   ->create( m_iSourceWidth, m_isField ? m_iSourceHeightOrg : m_iSourceHeight, ( d > 0 ) ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
-    picYuvTrueOrg[d].create( m_iSourceWidth, m_isField ? m_iSourceHeightOrg : m_iSourceHeight, ( d > 0 ) ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
+    picYuvOrg[d]   ->create( m_iSourceWidths[d], m_isField ? m_iSourceHeightOrgs[d] : m_iSourceHeights[d], m_chromaFormatIDCs[d], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[d], true );
+    picYuvTrueOrg[d].create( m_iSourceWidths[d], m_isField ? m_iSourceHeightOrgs[d] : m_iSourceHeights[d], m_chromaFormatIDCs[d], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[d], true );
   }
 #else
@@ -1009,4 +1072,10 @@
   }
 #endif
+
+
+#if EXTENSION_360_VIDEO
+  TExt360AppEncTop           ext360(*this, m_cTEncTop.getGOPEncoder()->getExt360Data(), *(m_cTEncTop.getGOPEncoder()), *pcPicYuvOrg);
+#endif
+
 #if NH_MV
   while ( (m_targetEncLayerIdList.size() != 0 ) && !allEos )
@@ -1014,8 +1083,9 @@
     for(Int layer=0; layer < m_numberOfLayers; layer++ )
     {
-#if NH_3D
-      TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ m_depthFlag[layer] ];
-      TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ m_depthFlag[layer] ];
-#endif
+      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
+
+      TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ repFormatIdx ];
+      TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ repFormatIdx ];
+
       if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
       {
@@ -1030,5 +1100,5 @@
 
         // read input YUV file        
-        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC );
+        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, &m_aiPads[repFormatIdx][0], m_InputChromaFormatIDC[repFormatIdx] );
         m_acTEncTopList             [layer]->initNewPic( pcPicYuvOrg );
 
@@ -1062,7 +1132,8 @@
       for(Int layer=0; layer < m_numberOfLayers; layer++ )
       {
-#if NH_3D
-        TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ m_depthFlag[layer] ];
-        TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ m_depthFlag[layer] ];
+        Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
+#if NH_MV
+        TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ repFormatIdx ];
+        TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ repFormatIdx ];
 #endif
         if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
@@ -1104,7 +1175,17 @@
     // get buffers
     xGetBuffer(pcPicYuvRec);
-
     // read input YUV file
+#if EXTENSION_360_VIDEO
+    if (ext360.isEnabled())
+    {
+      ext360.read(m_cTVideoIOYuvInputFile, *pcPicYuvOrg, cPicYuvTrueOrg, ipCSC);
+    }
+    else
+    {
+      m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
+    }
+#else
     m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
+#endif
 
     // increase number of received frames
@@ -1142,5 +1223,5 @@
     if( m_temporalSubsampleRatio > 1 )
     {
-      m_cTVideoIOYuvInputFile.skipFrames(m_temporalSubsampleRatio-1, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
+      m_cTVideoIOYuvInputFile.skipFrames(m_temporalSubsampleRatio-1, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC);
     }
   }
@@ -1149,7 +1230,7 @@
 #endif
 
-#if NH_3D
+#if NH_MV
   // delete original YUV buffer
-  for (Int d = 0; d < 2; d++)
+  for (Int d = 0; d < m_numRepFormats; d++)
   {
     picYuvOrg[d]->destroy();
@@ -1169,6 +1250,4 @@
   // delete used buffers in encoder class
   m_cTEncTop.deletePicBuffer();
-#endif
-#if !NH_3D
   cPicYuvTrueOrg.destroy();
 #endif
@@ -1212,4 +1291,6 @@
   // org. buffer
 #if NH_MV
+  Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
+
   if ( m_cListPicYuvRec[layer]->size() == (UInt)m_iGOPSize )
   {
@@ -1224,6 +1305,6 @@
   {
     rpcPicYuvRec = new TComPicYuv;
-#if NH_3D
-    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_depthFlag[layer] > 0 ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
+#if NH_MV
+    rpcPicYuvRec->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], m_chromaFormatIDCs[ repFormatIdx ], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[repFormatIdx], true );
 #else
     rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
@@ -1306,8 +1387,9 @@
       if (m_pchReconFileList[layerIdx])
       {
+        Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdx];
 #if NH_3D
-        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT, m_isTopFieldFirst );
-#else
-        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
+        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT, m_isTopFieldFirst );
+#else
+        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], NUM_CHROMA_FORMAT, m_isTopFieldFirst );
 #endif
       }
@@ -1361,10 +1443,11 @@
       TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
 #if NH_MV
+      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdx];
       if (m_pchReconFileList[layerIdx])
       {
 #if NH_3D
-        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT  );
-#else
-        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
+        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT  );
+#else
+        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx] );
 #endif
 
@@ -1454,6 +1537,16 @@
 Void TAppEncTop::printChromaFormat()
 {
+  
+#if NH_MV    
+  std::cout << "Input ChromaFormatIDC             : ";
+  for (Int i = 0; i < m_numRepFormats; i++)
+  {
+    
+    
+    switch (m_InputChromaFormatIDC[i])
+#else
   std::cout << std::setw(43) << "Input ChromaFormatIDC = ";
   switch (m_InputChromaFormatIDC)
+#endif
   {
   case CHROMA_400:  std::cout << "  4:0:0"; break;
@@ -1465,11 +1558,17 @@
     exit(1);
   }
+#if NH_MV
+  std::cout << " ";
+}
+#endif
+
   std::cout << std::endl;
 
 #if NH_MV
-  for (Int i = 0; i < m_numberOfLayers; i++)
-  {
-    std::cout << "Layer " << i << std::setw( 43 - (i > 9 ? 6 : 7) ) << "Internal ChromaFormatIDC = ";
-    switch (m_acTEncTopList[i]->getChromaFormatIdc())
+  std::cout << "Output (internal) ChromaFormatIDC : ";
+  for (Int i = 0; i < m_numRepFormats; i++)
+  {
+    
+    switch ( m_chromaFormatIDCs[i] )
 #else
     std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = ";
@@ -1486,5 +1585,5 @@
     }
 #if NH_MV
-    std::cout << std::endl;
+    std::cout << " ";
   }
 #endif
@@ -1492,20 +1591,22 @@
 }
 
-#if NH_3D_DLT
+#if NH_3D
 Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt)
 {
+  Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
+
   TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
   TComPicYuv*       pcDepthPicYuvTrueOrg = new TComPicYuv;
   // allocate original YUV buffer
-  pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, false );
-  pcDepthPicYuvTrueOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, false );
+  pcDepthPicYuvOrg->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight    , m_uiMaxTotalCUDepth[repFormatIdx], false );
+  pcDepthPicYuvTrueOrg->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[repFormatIdx], false );
   
   TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
   
-  UInt uiMaxDepthValue = ((1 << m_inputBitDepth[CHANNEL_TYPE_LUMA])-1);
+  UInt uiMaxDepthValue = ((1 << m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA])-1);
   
   std::vector<Bool> abValidDepths(256, false);
   
-  depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );
+  depthVideoFile->open( m_pchInputFileList[layer], false, &m_inputBitDepths[repFormatIdx][0], &m_MSBExtendedBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0] );
   
   Int iHeight   = pcDepthPicYuvOrg->getHeight(COMPONENT_Y);
@@ -1515,7 +1616,8 @@
   Pel* pInDM    = pcDepthPicYuvOrg->getAddr(COMPONENT_Y);
   
+  
   for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
   {
-    depthVideoFile->read( pcDepthPicYuvOrg, pcDepthPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
+    depthVideoFile->read( pcDepthPicYuvOrg, pcDepthPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, &m_aiPads[repFormatIdx][0], m_InputChromaFormatIDC[repFormatIdx], m_bClipInputVideoToRec709Range );
     
     // check all pixel values
@@ -1551,5 +1653,5 @@
   }
   
-  if( uiNumFrames == 0 || gCeilLog2(iNumDepthValues) == m_inputBitDepth[CHANNEL_TYPE_LUMA] )
+  if( uiNumFrames == 0 || gCeilLog2(iNumDepthValues) == m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA] )
   {
     dlt->setUseDLTFlag(layer, false);
@@ -1653,5 +1755,5 @@
     for( Int i = 0; i < getGOPSize(); i++ ) 
     {
-      GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][i];
+      GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[i];
       curSubLayersMaxMinus1 = std::max( curSubLayersMaxMinus1, geCur.m_temporalId ); 
     }  
@@ -1679,6 +1781,6 @@
           for( Int i = 0; i < ( getGOPSize() + 1); i++ ) 
           {        
-            GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
-            GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
+            GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
+            GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
             for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
             {
@@ -1705,6 +1807,6 @@
               for( Int i = 0; i < ( getGOPSize() + 1); i++ ) 
               {        
-                GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
-                GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
+                GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
+                GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
                 if ( geCur.m_interCompPredFlag )
                 {
@@ -1719,6 +1821,6 @@
             for( Int i = 0; i < ( getGOPSize() + 1); i++ ) 
             {        
-              GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
-              GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
+              GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
+              GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
 
               if ( geCur.m_interCompPredFlag )
@@ -1761,5 +1863,5 @@
     for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) 
     {        
-      GOPEntry ge =  m_GOPListMvc[layerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
+      GOPEntry ge =  xGetGopEntries(layerIdInVps)[ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
       maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); 
     }            
@@ -1784,5 +1886,5 @@
     for( Int i = 0; i < ( getGOPSize() + 1) && allRefLayersActiveFlag; i++ ) 
     {        
-      GOPEntry ge =  m_GOPListMvc[layerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
+      GOPEntry ge =  xGetGopEntries(layerIdInVps)[ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
       Int tId = ge.m_temporalId;  // Should be equal for all layers. 
       
@@ -1838,20 +1940,4 @@
 
 
-GOPEntry* TAppEncTop::xGetGopEntry( Int layerIdInVps, Int poc )
-{
-  GOPEntry* geFound = NULL; 
-  for( Int i = 0; i < ( getGOPSize() + 1) && geFound == NULL ; i++ ) 
-  {
-    GOPEntry* ge = &(m_GOPListMvc[layerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]);
-    if ( ge->m_POC == poc )
-    {
-      geFound = ge;       
-    }
-  }
-  assert( geFound != NULL ); 
-  return geFound; 
-}
-
-
 Void TAppEncTop::xSetTimingInfo( TComVPS& vps )
 {
@@ -1905,4 +1991,8 @@
 { 
 
+  xDeriveProfAndConstrFlags( vps );  
+  xCheckProfiles           ( vps );
+  xPrintProfiles           (  );
+  
   // SET PTL
   assert( m_profiles.size() == m_level.size() && m_profiles.size() == m_levelTier.size() ); 
@@ -1912,18 +2002,40 @@
     if ( ptlIdx > 1 )
     {
-      Bool vpsProfilePresentFlag = ( m_profiles[ptlIdx] != m_profiles[ptlIdx - 1] )
-        || ( m_inblFlag[ptlIdx ] != m_inblFlag[ptlIdx - 1] ); 
+      Bool vpsProfilePresentFlag = 
+           ( m_profiles                [ptlIdx ] != m_profiles                [ptlIdx - 1] )
+        || ( m_progressiveSourceFlags  [ptlIdx ] != m_progressiveSourceFlags  [ptlIdx - 1] )
+        || ( m_interlacedSourceFlags   [ptlIdx ] != m_interlacedSourceFlags   [ptlIdx - 1] )
+        || ( m_nonPackedConstraintFlags[ptlIdx ] != m_nonPackedConstraintFlags[ptlIdx - 1] )
+        || ( m_frameOnlyConstraintFlags[ptlIdx ] != m_frameOnlyConstraintFlags[ptlIdx - 1] )
+        || ( m_inblFlag                [ptlIdx ] != m_inblFlag                [ptlIdx - 1] );
+
+      
+      if ( m_profiles[ ptlIdx ] >= 4 && m_profiles[ ptlIdx ] <= 7 )
+      {
+
+        vpsProfilePresentFlag = vpsProfilePresentFlag
+          || ( m_profiles                [ptlIdx ] != m_profiles                [ptlIdx - 1] )
+          || ( m_progressiveSourceFlags  [ptlIdx ] != m_progressiveSourceFlags  [ptlIdx - 1] )
+          || ( m_interlacedSourceFlags   [ptlIdx ] != m_interlacedSourceFlags   [ptlIdx - 1] )
+          || ( m_nonPackedConstraintFlags[ptlIdx ] != m_nonPackedConstraintFlags[ptlIdx - 1] )
+          || ( m_frameOnlyConstraintFlags[ptlIdx ] != m_frameOnlyConstraintFlags[ptlIdx - 1] )
+          || ( m_inblFlag                [ptlIdx ] != m_inblFlag                [ptlIdx - 1] );
+
+      }
+
+      
       vps.setVpsProfilePresentFlag( ptlIdx, vpsProfilePresentFlag ); 
     }
 
     xSetProfileTierLevel( vps, ptlIdx, -1, m_profiles[ptlIdx], m_level[ptlIdx], 
-      m_levelTier[ ptlIdx ], m_progressiveSourceFlag, m_interlacedSourceFlag,
-      m_nonPackedConstraintFlag, m_frameOnlyConstraintFlag,  m_inblFlag[ptlIdx] );     
-  }  
-}
-
-Void TAppEncTop::xSetProfileTierLevel(TComVPS& vps, Int profileTierLevelIdx, Int subLayer, Profile::Name profile, Level::Name level, Level::Tier tier, Bool progressiveSourceFlag, Bool interlacedSourceFlag, Bool nonPackedConstraintFlag, Bool frameOnlyConstraintFlag, Bool inbldFlag)
+      m_levelTier[ ptlIdx ], m_progressiveSourceFlags[ptlIdx], m_interlacedSourceFlags[ptlIdx],
+      m_nonPackedConstraintFlags[ptlIdx], m_frameOnlyConstraintFlags[ptlIdx],  m_inblFlag[ptlIdx] );     
+  }
+}
+
+Void TAppEncTop::xSetProfileTierLevel(TComVPS& vps, Int ptlIdx, Int subLayer, Profile::Name profile, Level::Name level, Level::Tier tier, Bool progressiveSourceFlag, Bool interlacedSourceFlag, Bool nonPackedConstraintFlag, Bool frameOnlyConstraintFlag, Bool inbldFlag)
 {
-  TComPTL* ptlStruct = vps.getPTL( profileTierLevelIdx );    
+  
+  TComPTL* ptlStruct = vps.getPTL( ptlIdx );    
   assert( ptlStruct != NULL ); 
 
@@ -1940,49 +2052,27 @@
   assert( ptl != NULL );
 
-  ptl->setProfileIdc( profile );
-  ptl->setTierFlag  ( tier    );
-  ptl->setLevelIdc  ( level   );
-  ptl->setProfileCompatibilityFlag( profile, true );
-  ptl->setInbldFlag( inbldFlag );
-
-  switch ( profile )
-  {
-  case Profile::MAIN:
-    break; 
-  case Profile::MULTIVIEWMAIN:
-#if NH_3D
-  case Profile::MAIN3D:
-#endif
-    ptl->setMax12bitConstraintFlag      ( true  ); 
-    ptl->setMax12bitConstraintFlag      ( true  );
-    ptl->setMax10bitConstraintFlag      ( true  );
-    ptl->setMax8bitConstraintFlag       ( true  );
-    ptl->setMax422chromaConstraintFlag  ( true  );
-    ptl->setMax420chromaConstraintFlag  ( true  );
-    ptl->setMaxMonochromeConstraintFlag ( false );
-    ptl->setIntraConstraintFlag         ( false ); 
-    ptl->setOnePictureOnlyConstraintFlag( false );
-    ptl->setLowerBitRateConstraintFlag  ( true  );        
-    break; 
-  default:
-    assert( 0 ); // other profiles currently not supported
-    break; 
-  }
+  ptl->setProfileIdc              ( m_profiles [ ptlIdx ] );
+  ptl->setTierFlag                ( m_levelTier[ ptlIdx ] );
+  ptl->setLevelIdc                ( m_level    [ ptlIdx ] );
+  ptl->setProfileCompatibilityFlag( m_profiles [ ptlIdx ], true );
+  ptl->setInbldFlag               ( m_inblFlag [ ptlIdx ] );
+
+  Int        bitDepth = m_bitDepthConstraints[ptlIdx];
+  ChromaFormat chroma = m_chromaFormatConstraints[ptlIdx];
+
+  ptl->setMax12bitConstraintFlag      (  bitDepth <= 12  );   
+  ptl->setMax10bitConstraintFlag      (  bitDepth <= 10 );
+  ptl->setMax8bitConstraintFlag       (  bitDepth <= 8 );
+  ptl->setMax422chromaConstraintFlag  ( chroma == CHROMA_400 || chroma == CHROMA_420 || chroma == CHROMA_422    );
+  ptl->setMax420chromaConstraintFlag  ( chroma == CHROMA_400 || chroma == CHROMA_420                            );                         ;
+  ptl->setMaxMonochromeConstraintFlag ( chroma == CHROMA_400                       );
+  ptl->setIntraConstraintFlag         ( m_intraConstraintFlags[ ptlIdx ]           ); 
+  ptl->setOnePictureOnlyConstraintFlag( m_onePictureOnlyConstraintFlags[ ptlIdx ]  );
+  ptl->setLowerBitRateConstraintFlag  ( m_lowerBitRateConstraintFlags[ ptlIdx ]    );    
 }
 
 Void TAppEncTop::xSetRepFormat( TComVPS& vps )
 {
-
-  Bool anyDepth = false; 
-#if NH_3D
-  for ( Int i = 0; i < m_numberOfLayers; i++ )
-  {
-    vps.setVpsRepFormatIdx( i, m_depthFlag[ i ] ? 1 : 0 );
-    anyDepth = anyDepth || m_depthFlag[ i ];
-  }
-#endif
-
-  vps.setRepFormatIdxPresentFlag( anyDepth ); 
-  vps.setVpsNumRepFormatsMinus1 ( anyDepth ? 1 : 0     ); 
+  vps.setVpsNumRepFormatsMinus1 ( m_numRepFormats - 1 ); 
 
 
@@ -1991,9 +2081,9 @@
   for ( Int j = 0; j <= vps.getVpsNumRepFormatsMinus1(); j++ )
   {           
-    repFormat[j].setBitDepthVpsChromaMinus8   ( m_internalBitDepth[CHANNEL_TYPE_LUMA  ] - 8 ); 
-    repFormat[j].setBitDepthVpsLumaMinus8     ( m_internalBitDepth[CHANNEL_TYPE_CHROMA] - 8 );
-    repFormat[j].setChromaFormatVpsIdc        ( j == 1 ? CHROMA_400 :  CHROMA_420 );
-    repFormat[j].setPicHeightVpsInLumaSamples ( m_iSourceHeight );
-    repFormat[j].setPicWidthVpsInLumaSamples  ( m_iSourceWidth  );    
+    repFormat[j].setBitDepthVpsChromaMinus8   ( m_internalBitDepths[j][CHANNEL_TYPE_LUMA  ] - 8 ); 
+    repFormat[j].setBitDepthVpsLumaMinus8     ( m_internalBitDepths[j][CHANNEL_TYPE_CHROMA] - 8 );
+    repFormat[j].setChromaFormatVpsIdc        ( m_chromaFormatIDCs[j] );
+    repFormat[j].setPicHeightVpsInLumaSamples ( m_iSourceHeights[j] );
+    repFormat[j].setPicWidthVpsInLumaSamples  ( m_iSourceWidths [j] );    
     repFormat[j].setChromaAndBitDepthVpsPresentFlag( true );    
     // ToDo not supported yet. 
@@ -2001,11 +2091,39 @@
 
     repFormat[j].setConformanceWindowVpsFlag( true );
-    repFormat[j].setConfWinVpsLeftOffset    ( m_confWinLeft   / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
-    repFormat[j].setConfWinVpsRightOffset   ( m_confWinRight  / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() )  );
-    repFormat[j].setConfWinVpsTopOffset     ( m_confWinTop    / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() )  );
-    repFormat[j].setConfWinVpsBottomOffset  ( m_confWinBottom / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) ); 
+    repFormat[j].setConfWinVpsLeftOffset    ( m_confWinLefts  [j] / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
+    repFormat[j].setConfWinVpsRightOffset   ( m_confWinRights [j] / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
+    repFormat[j].setConfWinVpsTopOffset     ( m_confWinTops   [j] / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) );
+    repFormat[j].setConfWinVpsBottomOffset  ( m_confWinBottoms[j] / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) ); 
   }
 
   vps.setRepFormat( repFormat );
+
+
+  if ( vps.getVpsNumRepFormatsMinus1() > 0 )
+  {
+    Bool repFormatIdxPresentFlag = false;
+    for( Int i = vps.getVpsBaseLayerInternalFlag() ? 1 : 0; i <= vps.getMaxLayersMinus1(); i++ )
+    {
+      repFormatIdxPresentFlag = repFormatIdxPresentFlag ||  ( m_layerIdxInVpsToRepFormatIdx[i]  != vps.inferVpsRepFormatIdx( i ) );
+    }
+    vps.setRepFormatIdxPresentFlag( repFormatIdxPresentFlag ); 
+  }
+
+  for( Int i =  0; i <=  vps.getMaxLayersMinus1(); i++ )
+  {
+    // When base_layer_internal_flag is equal to 1, the first repFormatIdx cannot be signaled but is inferred.
+    if( !vps.getRepFormatIdxPresentFlag() || ( vps.getVpsBaseLayerInternalFlag() && i == 0 )   ) 
+    {
+      vps.setVpsRepFormatIdx( i, vps.inferVpsRepFormatIdx( i ) );
+      AOF( vps.getVpsRepFormatIdx( i ) == m_layerIdxInVpsToRepFormatIdx[i] ); 
+    }
+    else
+    {
+      vps.setVpsRepFormatIdx( i, m_layerIdxInVpsToRepFormatIdx[i] );          
+    }
+  }
+
+
+  xConfirmRepFormat( vps );
 
 }
@@ -2431,7 +2549,8 @@
 
 
-#if NH_3D_DLT
+#if NH_3D
 Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT* dlt )
 {
+  std::cout << "Analyzing input depth for DLT ";
   Int  iNumDepthViews  = 0;
   Bool bDltPresentFlag = false;
@@ -2449,4 +2568,5 @@
     if( dlt->getUseDLTFlag( layer ) )
     {
+      std::cout << ".";
       xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, dlt);
       bDltPresentFlag = bDltPresentFlag || dlt->getUseDLTFlag(layer);
@@ -2523,5 +2643,6 @@
       
       // bit map branch
-      uiNumBitsBitMap = 1 << m_inputBitDepth[CHANNEL_TYPE_LUMA];
+      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[ layer ];
+      uiNumBitsBitMap = 1 << m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA];
       
       // determine bDltBitMapFlag
@@ -2529,10 +2650,14 @@
       
       dlt->setUseBitmapRep(layer, bDltBitMapRepFlag);
-    }
+
+      AOF( m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA] == m_inputBitDepths[0][CHANNEL_TYPE_LUMA] )
+    }
+    
   }
 
   dlt->setDltPresentFlag( bDltPresentFlag );
   dlt->setNumDepthViews ( iNumDepthViews  );
-  dlt->setDepthViewBitDepth( m_inputBitDepth[CHANNEL_TYPE_LUMA] );
+  dlt->setDepthViewBitDepth( m_inputBitDepths[CHANNEL_TYPE_LUMA][0] );
+  std::cout << " done." << std::endl; 
 }
 #endif
Index: trunk/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 1405)
+++ trunk/source/App/TAppEncoder/TAppEncTop.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.
  *
@@ -73,6 +73,13 @@
 
   std::vector<Int>           m_frameRcvd;                   ///< number of received frames 
-
   TComPicLists               m_ivPicLists;                  ///< picture buffers of encoder instances
+
+  ParameterSetMap<TComSPS>   m_spsMap;
+  ParameterSetMap<TComPPS>   m_ppsMap;
+  
+  IntAry1d                   m_parameterSetId;  
+  BoolAry1d                  m_sendParameterSets;
+
+
 #if NH_MV
   TComVPS*                   m_vps;                         ///< vps
@@ -147,9 +154,82 @@
   Void xSetCamPara                ( TComVPS& vps );
 #endif
-  GOPEntry* xGetGopEntry( Int layerIdInVps, Int poc );
+
+  Void xDeriveParameterSetIds( TComVPS& vps )
+  {
+
+    m_parameterSetId  .clear();
+    m_sendParameterSets.clear();
+
+    m_parameterSetId  .resize( m_numberOfLayers, -1 );
+    m_sendParameterSets.resize( m_numberOfLayers, false );
+    if ( !m_shareParameterSets )
+    {
+      AOT( m_numberOfLayers > 16 ); 
+      for (Int curVpsLayerId = 0; curVpsLayerId < m_numberOfLayers; curVpsLayerId++ )
+      {
+        m_parameterSetId   [curVpsLayerId] = curVpsLayerId; 
+        m_sendParameterSets[curVpsLayerId] = true         ; 
+      }
+    }
+    else
+    {
+      // The spec requires e.g.:
+      // - It is a requirement of bitstream conformance that, when present, the value of chroma_format_idc shall be less than or equal to chroma_format_vps_idc 
+      //   of the vps_rep_format_idx[ j ]-th rep_format( ) syntax structure in the active VPS, where j is equal to LayerIdxInVps[ layerIdCurr ].  
+
+      // Consequently, a depth layer with chorma format 4:0:0 cannot refer to a base layer SPS with chroma format 4:2:0
+
+      // Furthermore, it is required that
+      // - the SPS RBSP shall have nuh_layer_id equal to 0, nuhLayerId, or IdRefLayer[ nuhLayerId ][ i ] with any value of i in the range of 0 to NumRefLayers[ nuhLayerId ] - 1, inclusive.
+
+      // Because of these requirements and when parameter set sharing is enabled, HTM sends the parameter sets for a current layer in its smallest reference layer having the same representation format. 
+
+
+      Int curPsId = 0; 
+
+      // Loop all layers
+      for (Int curVpsLayerId = 0; curVpsLayerId < m_numberOfLayers; curVpsLayerId++ )
+      {
+        // Get smallest reference layer with same rep format idx
+        Int curNuhLayerId = vps.getLayerIdInNuh(curVpsLayerId);
+        Int smallestRefNuhLIdSameRepFmt   = curNuhLayerId;
+
+        Int curRepFormatIdx = m_layerIdxInVpsToRepFormatIdx[ curVpsLayerId ];
+
+        for (Int j = 0; j < vps.getNumRefLayers( curNuhLayerId ); j++ )
+        {
+          Int refNuhLayerId = vps.getIdRefLayer( curNuhLayerId, j );
+          Int refVpsLayerId = vps.getLayerIdInVps( refNuhLayerId ); 
+
+          if ( smallestRefNuhLIdSameRepFmt > refNuhLayerId &&  m_layerIdxInVpsToRepFormatIdx[refVpsLayerId] == curRepFormatIdx  )
+          {
+            smallestRefNuhLIdSameRepFmt = refNuhLayerId; 
+          }
+        }
+
+        Int smallestRefVpsLIdSameRepFmt =   vps.getLayerIdInVps(  smallestRefNuhLIdSameRepFmt ); 
+
+        if (smallestRefVpsLIdSameRepFmt == curVpsLayerId )
+        {
+          m_sendParameterSets[ curVpsLayerId ] = true;         
+          m_parameterSetId   [ curVpsLayerId ] = curPsId;
+          curPsId++;
+          AOT( curPsId > 15 ); 
+        }
+        else
+        {
+          AOT( m_parameterSetId   [ smallestRefVpsLIdSameRepFmt  ] == -1 );
+          m_parameterSetId   [ curVpsLayerId ] = m_parameterSetId   [ smallestRefVpsLIdSameRepFmt  ];
+        }
+
+        
+      }
+    }
+  }
+
   Int  xGetMax( std::vector<Int>& vec);
   Bool xLayerIdInTargetEncLayerIdList( Int nuhLayerId );
 #endif
-#if NH_3D_DLT
+#if NH_3D
   Void xDeriveDltArray( TComVPS& vps, TComDLT* dlt );
   Void xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt);
@@ -165,5 +245,8 @@
 #else
   TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
-#endif
+ 
+#endif
+private:
+
 };// END CLASS DEFINITION TAppEncTop
 
Index: trunk/source/App/TAppEncoder/encmain.cpp
===================================================================
--- trunk/source/App/TAppEncoder/encmain.cpp	(revision 1405)
+++ trunk/source/App/TAppEncoder/encmain.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.
  *
@@ -57,5 +57,10 @@
   fprintf( stdout, "\n" );
 #if NH_MV
-  fprintf( stdout, "3D-HTM Software: Encoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION );  
+#if NH_3D
+  const char* hevcExt = "3D";
+#else
+  const char* hevcExt = "MV";
+#endif
+  fprintf( stdout, "HTM Software: Encoder Version [%s][%s] based on HM Version [%s]", NV_VERSION, hevcExt , HM_VERSION);  
 #else
   fprintf( stdout, "HM software: Encoder Version [%s] (including RExt)", NV_VERSION );
@@ -65,5 +70,7 @@
   fprintf( stdout, NVM_BITS );
   fprintf( stdout, "\n\n" );
-
+#if NH_MV
+  fprintf( stdout, "Use the HEVC_EXT define to select between MV- and 3D-HEVC. \n\n" );  
+#endif
   // create application encoder class
   cTAppEncTop.create();
Index: trunk/source/App/utils/BitrateTargeting/ExtractBitrates.cpp
===================================================================
--- trunk/source/App/utils/BitrateTargeting/ExtractBitrates.cpp	(revision 1405)
+++ trunk/source/App/utils/BitrateTargeting/ExtractBitrates.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.
  *
Index: trunk/source/App/utils/BitrateTargeting/ExtractBitrates.h
===================================================================
--- trunk/source/App/utils/BitrateTargeting/ExtractBitrates.h	(revision 1405)
+++ trunk/source/App/utils/BitrateTargeting/ExtractBitrates.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/utils/BitrateTargeting/ExtractBitratesMain.cpp
===================================================================
--- trunk/source/App/utils/BitrateTargeting/ExtractBitratesMain.cpp	(revision 1405)
+++ trunk/source/App/utils/BitrateTargeting/ExtractBitratesMain.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.
  *
Index: trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.cpp
===================================================================
--- trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.cpp	(revision 1405)
+++ trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.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.
  *
Index: trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.h
===================================================================
--- trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.h	(revision 1405)
+++ trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.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/utils/BitrateTargeting/GuessLambdaModifiersMain.cpp
===================================================================
--- trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiersMain.cpp	(revision 1405)
+++ trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiersMain.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.
  *
Index: trunk/source/App/utils/BitrateTargeting/RuntimeError.h
===================================================================
--- trunk/source/App/utils/BitrateTargeting/RuntimeError.h	(revision 1405)
+++ trunk/source/App/utils/BitrateTargeting/RuntimeError.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/utils/annexBbytecount.cpp
===================================================================
--- trunk/source/App/utils/annexBbytecount.cpp	(revision 1405)
+++ trunk/source/App/utils/annexBbytecount.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.
  *
Index: trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp
===================================================================
--- trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp	(revision 1405)
+++ trunk/source/App/utils/convert_NtoMbit_YCbCr.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.
  *
