Index: branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 933)
+++ branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 945)
@@ -88,8 +88,5 @@
   MAIN_444_12_INTRA = 2312,
   MAIN_444_16_INTRA = 2316,
-#if SVC_EXTENSION
-  SCALABLE          = 6,
-  SCALABLE10        = 7,
-#endif
+
 };
 
@@ -341,8 +338,4 @@
   {"main-RExt",            Profile::MAINREXT           },
   {"high-throughput-RExt", Profile::HIGHTHROUGHPUTREXT },
-#if SVC_EXTENSION
-  {"scalable",             Profile::SCALABLE           },
-  {"scalable10",           Profile::SCALABLE10         },
-#endif
 };
 
@@ -379,8 +372,4 @@
     {"main_444_12_intra",  MAIN_444_12_INTRA},
     {"main_444_16_intra",  MAIN_444_16_INTRA},
-#if SVC_EXTENSION
-    {"scalable",           SCALABLE         },
-    {"scalable10",         SCALABLE10       },
-#endif
 };
 
@@ -786,6 +775,4 @@
   UInt*      cfg_uiQuadtreeTUMaxDepthIntra[MAX_LAYERS];
 #endif
-  Int      cfg_tmpChromaFormatIDC  [MAX_LAYERS];
-  Int      cfg_tmpInputChromaFormat[MAX_LAYERS];
 #if AUXILIARY_PICTURES
   Int*     cfg_auxId               [MAX_LAYERS];
@@ -875,4 +862,11 @@
 #endif
   Int*    cfg_waveFrontSynchro[MAX_LAYERS];
+
+#if MULTIPLE_PTL_SUPPORT
+  Bool    tmpIntraConstraintFlag;
+  Bool    tmpLowerBitRateConstraintFlag;
+  UInt    tmpBitDepthConstraint;
+  Int*    cfg_layerPTLIdx[MAX_VPS_LAYER_ID_PLUS1];
+#endif
 
   for(UInt layer = 0; layer < MAX_LAYERS; layer++)
@@ -971,4 +965,7 @@
     cfg_auxId[layer]                = &m_acLayerCfg[layer].m_auxId; 
 #endif
+#if MULTIPLE_PTL_SUPPORT
+    cfg_layerPTLIdx[layer]          = &m_acLayerCfg[layer].m_layerPTLIdx; 
+#endif
   }
 #if Q0078_ADD_LAYER_SETS
@@ -992,4 +989,7 @@
   string* cfg_outputLayerSetIdx      = new string;
 #endif
+#if MULTIPLE_PTL_SUPPORT
+  string* cfg_listOfLayerPTLOfOlss   = new string[MAX_VPS_OUTPUT_LAYER_SETS_PLUS1];
+#endif
 #if AVC_BASE
   string  cfg_BLInputFile;
@@ -1013,5 +1013,9 @@
   Int tmpConstraintChromaFormat;
   string inputColourSpaceConvert;
+#if MULTIPLE_PTL_SUPPORT
+  ExtendedProfileName extendedProfile[NUM_POSSIBLE_LEVEL];
+#else
   ExtendedProfileName extendedProfile;
+#endif
   Int saoOffsetBitShift[MAX_NUM_CHANNEL_TYPE];
 
@@ -1112,6 +1116,4 @@
   ("OutputLayerSetIdx",                             cfg_outputLayerSetIdx,                       string(""), 1, "Corresponding layer set index, only for non-default output layer sets")
 #endif
-  ("InputChromaFormat%d",                           cfg_tmpInputChromaFormat,                  420, MAX_LAYERS, "InputChromaFormatIDC for layer %d")
-  ("ChromaFormatIDC%d,-cf",                         cfg_tmpChromaFormatIDC,                    420, MAX_LAYERS, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat) for layer %d")
 #if AUXILIARY_PICTURES
   ("AuxId%d",                                       cfg_auxId,                                   0, MAX_LAYERS, "Auxilary picture ID for layer %d (0: Not aux pic, 1: Alpha plane, 2: Depth picture, 3: Cb enh, 4: Cr enh")
@@ -1263,4 +1265,22 @@
 
   // Profile and level
+#if MULTIPLE_PTL_SUPPORT
+  ("NumProfileTierLevel",                             m_numPTLInfo,                                         2, "Number of Profile, Tier and Level information")
+  ("Profile%d",                                       extendedProfile,               NONE, NUM_POSSIBLE_LEVEL,  "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%d",                                         m_levelList,            Level::NONE, NUM_POSSIBLE_LEVEL, "Level limit to be used, eg 5.1, or none")
+  ("Tier%d",                                          m_levelTierList,        Level::MAIN, NUM_POSSIBLE_LEVEL, "Tier to use for interpretation of --Level (main or high only)")
+  ("MaxBitDepthConstraint",                           tmpBitDepthConstraint,                               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")
+  ("IntraConstraintFlag",                             tmpIntraConstraintFlag,                           false, "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
+  ("LowerBitRateConstraintFlag",                      tmpLowerBitRateConstraintFlag,                     true, "Value of general_lower_bit_rate_constraint_flag to use for RExt profiles")
+  
+  ("ProgressiveSource%d",                             m_progressiveSourceFlagList,   false, NUM_POSSIBLE_LEVEL, "Indicate that source is progressive")
+  ("InterlacedSource%d",                              m_interlacedSourceFlagList,    false, NUM_POSSIBLE_LEVEL, "Indicate that source is interlaced")
+  ("NonPackedSource%d",                               m_nonPackedConstraintFlagList, false, NUM_POSSIBLE_LEVEL, "Indicate that source does not contain frame packing")
+  ("FrameOnly%d",                                     m_frameOnlyConstraintFlagList, false, NUM_POSSIBLE_LEVEL, "Indicate that the bitstream contains only frames")
+  
+  ("LayerPTLIndex%d",                                 cfg_layerPTLIdx,               0, MAX_VPS_LAYER_ID_PLUS1, "Index of PTL for each layer")
+  ("ListOfProfileTierLevelOls%d",                     cfg_listOfLayerPTLOfOlss, string(""), MAX_VPS_LAYER_ID_PLUS1, "PTL Index for each layer in each OLS except the first OLS. The PTL index for layer in the first OLS is set to 1")
+#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")
   ("Level",                                           m_level,                                    Level::NONE, "Level limit to be used, eg 5.1, or none")
@@ -1275,4 +1295,5 @@
   ("NonPackedSource",                                 m_nonPackedConstraintFlag,                        false, "Indicate that source does not contain frame packing")
   ("FrameOnly",                                       m_frameOnlyConstraintFlag,                        false, "Indicate that the bitstream contains only frames")
+#endif
 
 #if LAYER_CTB
@@ -1874,6 +1895,7 @@
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
-    if (m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] == 0) { m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] = m_acLayerCfg[layer].m_inputBitDepth      [CHANNEL_TYPE_LUMA  ]; }
-    if (m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] == 0) { m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ]; }
+    m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] = m_acLayerCfg[layer].m_inputBitDepth      [CHANNEL_TYPE_LUMA  ];
+    m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ];
+
     if (m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] == 0) { m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] = m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ]; }
     if (m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_CHROMA] == 0) { m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_LUMA  ]; }
@@ -1883,5 +1905,8 @@
 
     m_acLayerCfg[layer].m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat);
-    m_acLayerCfg[layer].m_chromaFormatIDC      = ((tmpChromaFormat == 0) ? (m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat)));    
+    m_acLayerCfg[layer].m_chromaFormatIDC      = ((tmpChromaFormat == 0) ? (m_acLayerCfg[layer].m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat)));
+
+    m_acLayerCfg[layer].m_useHighPrecisionPredictionWeighting = false;
+    m_acLayerCfg[layer].m_useExtendedPrecision = false;
   }
 #else
@@ -1899,20 +1924,104 @@
 #endif
 
-  if (extendedProfile >= 1000 && extendedProfile <= 2316)
-  {
-    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>=2000);
-    switch ((extendedProfile/100)%10)
-    {
+#if MULTIPLE_PTL_SUPPORT
+  for( Int layer = 0; layer < MAX_LAYERS; layer++ )
+  {
+    m_acLayerCfg[layer].m_bitDepthConstraint = tmpBitDepthConstraint;
+    m_acLayerCfg[layer].m_intraConstraintFlag = tmpIntraConstraintFlag;
+    m_acLayerCfg[layer].m_lowerBitRateConstraintFlag = tmpLowerBitRateConstraintFlag;    
+
+    for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
+    {
+      m_acLayerCfg[layer].m_saoOffsetBitShift[channelType] = 0;
+    }
+        
+    Int layerPTLIdx = m_acLayerCfg[layer].m_layerPTLIdx;
+
+    if( extendedProfile[layerPTLIdx] >= 1000 && extendedProfile[layerPTLIdx] <= 2316 )
+    {
+      m_profileList[layerPTLIdx] = Profile::MAINREXT;            
+
+      if( m_acLayerCfg[layer].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_acLayerCfg[layer].m_bitDepthConstraint  = (extendedProfile[layerPTLIdx]%100);
+      m_acLayerCfg[layer].m_intraConstraintFlag = (extendedProfile[layerPTLIdx]>=2000);
+      switch ((extendedProfile[layerPTLIdx]/100)%10)
+      {
       case 0:  tmpConstraintChromaFormat=400; break;
       case 1:  tmpConstraintChromaFormat=420; break;
       case 2:  tmpConstraintChromaFormat=422; break;
       default: tmpConstraintChromaFormat=444; break;
+      }
+    }
+    else
+    {
+      m_profileList[layerPTLIdx] = Profile::Name(extendedProfile[layerPTLIdx]);
+    }
+
+    if( m_profileList[layerPTLIdx] == Profile::HIGHTHROUGHPUTREXT )
+    {
+      if( m_acLayerCfg[layer].m_bitDepthConstraint == 0 ) m_acLayerCfg[layer].m_bitDepthConstraint = 16;
+      m_acLayerCfg[layer].m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
+    }
+    else if( m_profileList[layerPTLIdx] == Profile::MAINREXT )
+    {
+      if( m_acLayerCfg[layer].m_bitDepthConstraint == 0 && tmpConstraintChromaFormat == 0 )
+      {
+        // produce a valid combination, if possible.
+        const Bool bUsingGeneralRExtTools  = m_useResidualRotation                    ||
+          m_useSingleSignificanceMapContext        ||
+          m_useResidualDPCM[RDPCM_SIGNAL_IMPLICIT] ||
+          m_useResidualDPCM[RDPCM_SIGNAL_EXPLICIT] ||
+          !m_enableIntraReferenceSmoothing         ||
+          m_useGolombRiceParameterAdaptation       ||
+          m_transformSkipLog2MaxSize!=2;
+        const Bool bUsingChromaQPAdjustment= m_maxCUChromaQpAdjustmentDepth >= 0;
+        const Bool bUsingExtendedPrecision = m_acLayerCfg[layer].m_useExtendedPrecision;
+        m_acLayerCfg[layer].m_chromaFormatConstraint = NUM_CHROMA_FORMAT;
+        automaticallySelectRExtProfile(bUsingGeneralRExtTools,
+          bUsingChromaQPAdjustment,
+          bUsingExtendedPrecision,
+          m_acLayerCfg[layer].m_intraConstraintFlag,
+          m_acLayerCfg[layer].m_bitDepthConstraint,
+          m_acLayerCfg[layer].m_chromaFormatConstraint,
+          m_acLayerCfg[layer].m_chromaFormatIDC==CHROMA_400 ? m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]),
+          m_acLayerCfg[layer].m_chromaFormatIDC);
+      }
+      else if( m_acLayerCfg[layer].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_acLayerCfg[layer].m_chromaFormatConstraint = numberToChromaFormat(tmpConstraintChromaFormat);
+      }
+    }
+    else
+    {
+      m_acLayerCfg[layer].m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? m_acLayerCfg[layer].m_chromaFormatIDC : numberToChromaFormat(tmpConstraintChromaFormat);
+      m_acLayerCfg[layer].m_bitDepthConstraint = (m_profileList[layerPTLIdx] == Profile::MAIN10?10:8);
+    }
+  }
+#else
+  if (extendedProfile >= 1000 && extendedProfile <= 2316)
+  {
+    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>=2000);
+    switch ((extendedProfile/100)%10)
+    {
+      case 0:  tmpConstraintChromaFormat=400; break;
+      case 1:  tmpConstraintChromaFormat=420; break;
+      case 2:  tmpConstraintChromaFormat=422; break;
+      default: tmpConstraintChromaFormat=444; break;
     }
   }
@@ -1921,4 +2030,8 @@
     m_profile = Profile::Name(extendedProfile);
   }
+
+#if SVC_EXTENSION
+  ChromaFormat m_chromaFormatIDC = m_acLayerCfg[0].m_chromaFormatIDC;
+#endif
 
   if (m_profile == Profile::HIGHTHROUGHPUTREXT )
@@ -1932,6 +2045,7 @@
     {
 #if SVC_EXTENSION
-      Bool m_useExtendedPrecision = m_acLayerCfg[0].m_useExtendedPrecision;
-      Int  m_internalBitDepth[]   = {m_acLayerCfg[0].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[0].m_internalBitDepth[CHANNEL_TYPE_CHROMA]};
+      Bool m_useExtendedPrecision    = m_acLayerCfg[0].m_useExtendedPrecision;
+      Int  m_internalBitDepth[]      = {m_acLayerCfg[0].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[0].m_internalBitDepth[CHANNEL_TYPE_CHROMA]};
+      ChromaFormat m_chromaFormatIDC = m_acLayerCfg[0].m_chromaFormatIDC;
 #endif
       // produce a valid combination, if possible.
@@ -1965,35 +2079,4 @@
     }
   }
-#if SVC_EXTENSION
-  else if( m_profile == Profile::SCALABLE || m_profile == Profile::SCALABLE10 )
-  {
-    for(Int layer = 0; layer < m_numLayers; layer++)
-    {
-      m_acLayerCfg[layer].m_bitDepthConstraint     = (m_profile == Profile::SCALABLE10 ? 10 : 8);
-      m_acLayerCfg[layer].m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_420 : numberToChromaFormat(tmpConstraintChromaFormat);
-
-      for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
-      {
-        m_acLayerCfg[layer].m_MSBExtendedBitDepth[ch] = m_acLayerCfg[layer].m_inputBitDepth[ch];
-
-        if (saoOffsetBitShift[ch]<0)
-        {
-          if (m_acLayerCfg[layer].m_internalBitDepth[ch]>10)
-          {
-            m_acLayerCfg[layer].m_saoOffsetBitShift[ch]=UInt(Clip3<Int>(0, m_acLayerCfg[layer].m_internalBitDepth[ch]-10, Int(m_acLayerCfg[layer].m_internalBitDepth[ch]-10 + 0.165*m_acLayerCfg[layer].m_iQP - 3.22 + 0.5) ) );
-          }
-          else
-          {
-            m_acLayerCfg[layer].m_saoOffsetBitShift[ch]=0;
-          }
-        }
-        else
-        {
-          m_acLayerCfg[layer].m_saoOffsetBitShift[ch]=UInt(saoOffsetBitShift[ch]);
-        }
-      }
-    }
-  }
-#endif
   else
   {
@@ -2001,5 +2084,5 @@
     m_bitDepthConstraint = (m_profile == Profile::MAIN10?10:8);
   }
-
+#endif
 
   m_inputColourSpaceConvert = stringToInputColourSpaceConvert(inputColourSpaceConvert, true);
@@ -2008,4 +2091,9 @@
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
+#if !MULTIPLE_PTL_SUPPORT
+    m_acLayerCfg[layer].m_chromaFormatConstraint = m_chromaFormatConstraint;
+    m_acLayerCfg[layer].m_bitDepthConstraint = m_bitDepthConstraint;
+#endif
+
     // If number of scaled ref. layer offsets is non-zero, at least one of the offsets should be specified
     if(m_acLayerCfg[layer].m_numScaledRefLayerOffsets)
@@ -2377,11 +2465,4 @@
   }
 
-#if AUXILIARY_PICTURES
-  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
-  {
-    m_acLayerCfg[layer].m_InputChromaFormatIDC =  numberToChromaFormat(cfg_tmpChromaFormatIDC[layer]);
-    m_acLayerCfg[layer].m_chromaFormatIDC = ((cfg_tmpChromaFormatIDC[layer] == 0) ? (m_acLayerCfg[layer].m_InputChromaFormatIDC ) : (numberToChromaFormat(cfg_tmpChromaFormatIDC[layer])));
-  }
-#endif
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -2516,4 +2597,9 @@
   // Layers in the output layer set
   m_listOfOutputLayers.resize(m_numOutputLayerSets);
+
+#if MULTIPLE_PTL_SUPPORT
+  m_listOfLayerPTLofOlss.resize(m_numOutputLayerSets);
+#endif
+
   Int startOlsCtr = 1;
   if( m_defaultTargetOutputLayerIdc == 0 || m_defaultTargetOutputLayerIdc == 1 )
@@ -2535,5 +2621,19 @@
       assert( scanStringToArray( cfg_listOfOutputLayers[olsCtr], m_numLayersInOutputLayerSet[olsCtr], "ListOfOutputLayers", m_listOfOutputLayers[olsCtr] ) );
     }
-  }
+#if MULTIPLE_PTL_SUPPORT
+    if( olsCtr > m_numLayerSets )
+    {
+      scanStringToArray( cfg_listOfLayerPTLOfOlss[olsCtr], m_numLayerInIdList[m_outputLayerSetIdx[olsCtr - m_numLayerSets]], "ListOfOutputLayers", m_listOfLayerPTLofOlss[olsCtr] );
+    }
+    else
+    {
+      scanStringToArray( cfg_listOfLayerPTLOfOlss[olsCtr], m_numLayerInIdList[olsCtr], "List of PTL for each layer in OLS", m_listOfLayerPTLofOlss[olsCtr] );
+    }
+#endif
+  }
+#if MULTIPLE_PTL_SUPPORT
+  m_listOfLayerPTLofOlss[0].push_back(*cfg_layerPTLIdx[0]);
+  delete [] cfg_listOfLayerPTLOfOlss;
+#endif
   delete cfg_numLayersInOutputLayerSet;
   delete [] cfg_listOfOutputLayers;
@@ -3062,7 +3162,7 @@
   Bool m_useExtendedPrecision                = m_acLayerCfg[layerId].m_useExtendedPrecision;
   Bool m_useHighPrecisionPredictionWeighting = m_acLayerCfg[layerId].m_useHighPrecisionPredictionWeighting;
-  m_chromaFormatIDC                          = m_acLayerCfg[layerId].m_chromaFormatIDC;
-  m_chromaFormatConstraint                   = m_acLayerCfg[layerId].m_chromaFormatConstraint;
-  m_bitDepthConstraint                       = m_acLayerCfg[layerId].m_bitDepthConstraint;
+  ChromaFormat m_chromaFormatIDC             = m_acLayerCfg[layerId].m_chromaFormatIDC;
+  ChromaFormat m_chromaFormatConstraint      = m_acLayerCfg[layerId].m_chromaFormatConstraint;
+  ChromaFormat m_InputChromaFormatIDC        = m_acLayerCfg[layerId].m_InputChromaFormatIDC;
 
   Int m_inputBitDepth[]       = {m_acLayerCfg[layerId].m_inputBitDepth[CHANNEL_TYPE_LUMA],       m_acLayerCfg[layerId].m_inputBitDepth[CHANNEL_TYPE_CHROMA]};
@@ -3072,4 +3172,13 @@
   m_saoOffsetBitShift[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layerId].m_saoOffsetBitShift[CHANNEL_TYPE_LUMA];
   m_saoOffsetBitShift[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layerId].m_saoOffsetBitShift[CHANNEL_TYPE_CHROMA];
+
+#if MULTIPLE_PTL_SUPPORT
+  Int layerPTLIdx = m_acLayerCfg[layerId].m_layerPTLIdx;
+  Profile::Name m_profile           = m_profileList[layerPTLIdx];
+  Level::Name m_level               = m_levelList[layerPTLIdx];
+  UInt m_bitDepthConstraint         = m_acLayerCfg[layerId].m_bitDepthConstraint;
+  Bool m_intraConstraintFlag        = m_acLayerCfg[layerId].m_intraConstraintFlag;
+  Bool m_lowerBitRateConstraintFlag = m_acLayerCfg[layerId].m_lowerBitRateConstraintFlag;
+#endif
 #else
 Void TAppEncCfg::xCheckParameter()
@@ -3085,4 +3194,23 @@
     fprintf(stderr, "******************************************************************\n");
   }
+#if SVC_EXTENSION && MULTIPLE_PTL_SUPPORT
+  Int ii = 0;
+  while( ii < m_numPTLInfo )
+  {
+    if( m_profileList[ii] == Profile::NONE )
+    {
+      fprintf(stderr, "***************************************************************************\n");
+      fprintf(stderr, "** WARNING: For conforming bitstreams a valid Profile value must be set! **\n");
+      fprintf(stderr, "***************************************************************************\n");
+    }
+    if( m_levelList[ii] == Level::NONE )
+    {
+      fprintf(stderr, "***************************************************************************\n");
+      fprintf(stderr, "** WARNING: For conforming bitstreams a valid Level value must be set!   **\n");
+      fprintf(stderr, "***************************************************************************\n");
+    }
+    ii++;
+  }
+#else
   if( m_profile==Profile::NONE )
   {
@@ -3097,4 +3225,5 @@
     fprintf(stderr, "***************************************************************************\n");
   }
+#endif
 
   Bool check_failed = false; /* abort if there is a fatal configuration problem */
@@ -3146,25 +3275,4 @@
     }
   }
-#if SVC_EXTENSION
-  else if( m_profile==Profile::SCALABLE || m_profile==Profile::SCALABLE10 )
-  {
-    xConfirmPara(m_bitDepthConstraint!=((m_profile==Profile::SCALABLE10)?10:8), "BitDepthConstraint must be 8 for MAIN profile and 10 for MAIN10 profile.");
-    xConfirmPara(m_chromaFormatConstraint!=CHROMA_420, "ChromaFormatConstraint must be 420 for non main-RExt profiles.");
-    xConfirmPara(m_intraConstraintFlag==true, "IntraConstraintFlag must be false for non main_RExt profiles.");
-    xConfirmPara(m_lowerBitRateConstraintFlag==false, "LowerBitrateConstraintFlag must be true for non main-RExt profiles.");
-
-    xConfirmPara(m_useCrossComponentPrediction==true, "CrossComponentPrediction must not be used for non main-RExt profiles.");
-    xConfirmPara(m_transformSkipLog2MaxSize!=2, "Transform Skip Log2 Max Size must be 2 for V1 profiles.");
-    xConfirmPara(m_useResidualRotation==true, "UseResidualRotation must not be enabled for non main-RExt profiles.");
-    xConfirmPara(m_useSingleSignificanceMapContext==true, "UseSingleSignificanceMapContext must not be enabled for non main-RExt profiles.");
-    xConfirmPara(m_useResidualDPCM[RDPCM_SIGNAL_IMPLICIT]==true, "ImplicitResidualDPCM must not be enabled for non main-RExt profiles.");
-    xConfirmPara(m_useResidualDPCM[RDPCM_SIGNAL_EXPLICIT]==true, "ExplicitResidualDPCM must not be enabled for non main-RExt profiles.");
-    xConfirmPara(m_useGolombRiceParameterAdaptation==true, "GolombRiceParameterAdaption must not be enabled for non main-RExt profiles.");
-    xConfirmPara(m_useExtendedPrecision==true, "UseExtendedPrecision must not be enabled for non main-RExt profiles.");
-    xConfirmPara(m_useHighPrecisionPredictionWeighting==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_alignCABACBeforeBypass, "AlignCABACBeforeBypass cannot be enabled for non main-RExt profiles.");
-  }
-#endif
   else
   {
@@ -4508,4 +4616,5 @@
   Int m_internalBitDepth[]    = {m_acLayerCfg[layerId].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layerId].m_internalBitDepth[CHANNEL_TYPE_CHROMA]};
   Int m_MSBExtendedBitDepth[] = {m_acLayerCfg[layerId].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layerId].m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA]};
+  ChromaFormat m_chromaFormatIDC = m_acLayerCfg[layerId].m_chromaFormatIDC;
 #endif
 
@@ -4626,4 +4735,5 @@
     printf("Frame index                       : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
   }
+#if !MULTIPLE_PTL_SUPPORT
   if (m_profile == Profile::MAINREXT)
   {
@@ -4641,4 +4751,5 @@
     printf("Profile                           : %s\n", profileToString(m_profile) );
   }
+#endif
 #if !LAYER_CTB
   printf("CU size / depth                   : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
Index: branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.h	(revision 933)
+++ branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.h	(revision 945)
@@ -120,5 +120,7 @@
   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 !SVC_EXTENSION
   ChromaFormat m_InputChromaFormatIDC;
+#endif
 
   Bool      m_printMSEBasedSequencePSNR;
@@ -127,4 +129,16 @@
   Bool      m_cabacZeroWordPaddingEnabled;
 
+#if MULTIPLE_PTL_SUPPORT
+  Int           m_numPTLInfo;
+  Profile::Name m_profileList[NUM_POSSIBLE_LEVEL];
+  Level::Tier   m_levelTierList[NUM_POSSIBLE_LEVEL];
+  Level::Name   m_levelList[NUM_POSSIBLE_LEVEL];
+  Bool          m_progressiveSourceFlagList[NUM_POSSIBLE_LEVEL];
+  Bool          m_interlacedSourceFlagList[NUM_POSSIBLE_LEVEL];
+  Bool          m_nonPackedConstraintFlagList[NUM_POSSIBLE_LEVEL];
+  Bool          m_frameOnlyConstraintFlagList[NUM_POSSIBLE_LEVEL];
+
+  std::vector< std::vector<Int> > m_listOfLayerPTLofOlss;
+#else
   // profile/level
   Profile::Name m_profile;
@@ -139,4 +153,5 @@
   Bool m_nonPackedConstraintFlag;
   Bool m_frameOnlyConstraintFlag;
+#endif
 
   // coding structure
@@ -227,5 +242,7 @@
 #endif
   //coding tools (chroma format)
+#if !SVC_EXTENSION
   ChromaFormat m_chromaFormatIDC;
+#endif
 
   // coding tools (PCM bit-depth)
Index: branches/SHM-upgrade/source/App/TAppEncoder/TAppEncLayerCfg.cpp
===================================================================
--- branches/SHM-upgrade/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 933)
+++ branches/SHM-upgrade/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 945)
@@ -308,4 +308,7 @@
 #endif
   printf("Internal Format                   : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
+#if MULTIPLE_PTL_SUPPORT
+  printf("PTL index                         : %d", m_layerPTLIdx );
+#endif
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
   printf("Input bit depth                   : (Y:%d, C:%d)\n", m_inputBitDepth[CHANNEL_TYPE_LUMA], m_inputBitDepth[CHANNEL_TYPE_CHROMA] );
@@ -313,15 +316,12 @@
   printf("PCM sample bit depth              : (Y:%d, C:%d)\n", m_cAppEncCfg->getPCMInputBitDepthFlag() ? m_inputBitDepth[CHANNEL_TYPE_LUMA] : m_internalBitDepth[CHANNEL_TYPE_LUMA], m_cAppEncCfg->getPCMInputBitDepthFlag() ? m_inputBitDepth[CHANNEL_TYPE_CHROMA] : m_internalBitDepth[CHANNEL_TYPE_CHROMA] );
 #endif
-#if SVC_EXTENSION
   std::cout << "Input ChromaFormatIDC             :";
-#else
-  std::cout << std::setw(43) << "Input ChromaFormatIDC = ";
-#endif
+
   switch (m_InputChromaFormatIDC)
   {
-  case CHROMA_400:  std::cout << "  4:0:0"; break;
-  case CHROMA_420:  std::cout << "  4:2:0"; break;
-  case CHROMA_422:  std::cout << "  4:2:2"; break;
-  case CHROMA_444:  std::cout << "  4:4:4"; break;
+  case CHROMA_400:  std::cout << " 4:0:0"; break;
+  case CHROMA_420:  std::cout << " 4:2:0"; break;
+  case CHROMA_422:  std::cout << " 4:2:2"; break;
+  case CHROMA_444:  std::cout << " 4:4:4"; break;
   default:
     std::cerr << "Invalid";
@@ -330,24 +330,16 @@
   std::cout << std::endl;
 
-#if SVC_EXTENSION
   std::cout << "Output (internal) ChromaFormatIDC :";
-#else
-  std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = ";
-#endif
   switch (m_chromaFormatIDC)
   {
-  case CHROMA_400:  std::cout << "  4:0:0"; break;
-  case CHROMA_420:  std::cout << "  4:2:0"; break;
-  case CHROMA_422:  std::cout << "  4:2:2"; break;
-  case CHROMA_444:  std::cout << "  4:4:4"; break;
+  case CHROMA_400:  std::cout << " 4:0:0"; break;
+  case CHROMA_420:  std::cout << " 4:2:0"; break;
+  case CHROMA_422:  std::cout << " 4:2:2"; break;
+  case CHROMA_444:  std::cout << " 4:4:4"; break;
   default:
     std::cerr << "Invalid";
     exit(1);
   }
-#if SVC_EXTENSION
   printf("\n");
-#else
-  std::cout << "\n" << std::endl;
-#endif
 #if LAYER_CTB
   printf("CU size / depth                   : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
Index: branches/SHM-upgrade/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- branches/SHM-upgrade/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 933)
+++ branches/SHM-upgrade/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 945)
@@ -47,4 +47,6 @@
   ChromaFormat m_chromaFormatConstraint;
   UInt      m_bitDepthConstraint;
+  Bool      m_intraConstraintFlag;
+  Bool      m_lowerBitRateConstraintFlag;
 #if AUXILIARY_PICTURES
   Int       m_auxId;
@@ -152,4 +154,9 @@
 #endif
 
+#if MULTIPLE_PTL_SUPPORT
+  // profile/level
+  Int       m_layerPTLIdx;
+#endif
+
 public:
   TAppEncLayerCfg();
Index: branches/SHM-upgrade/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-upgrade/source/App/TAppEncoder/TAppEncTop.cpp	(revision 933)
+++ branches/SHM-upgrade/source/App/TAppEncoder/TAppEncTop.cpp	(revision 945)
@@ -202,4 +202,36 @@
 #endif
 
+#if MULTIPLE_PTL_SUPPORT
+  //Populate PTL in VPS
+  TComVPS *pVPS = m_acTEncTop[0].getVPS();
+  ProfileTierLevel& profileTierLevel = *(pVPS->getPTL(0)->getGeneralPTL());
+  for( Int ii = 0; ii < m_numPTLInfo; ii++ )
+  {
+    profileTierLevel = *(pVPS->getPTL(ii)->getGeneralPTL());
+
+    profileTierLevel.setLevelIdc(m_levelList[ii]);
+    profileTierLevel.setTierFlag(m_levelTierList[ii]);
+    profileTierLevel.setProfileIdc(m_profileList[ii]);
+    profileTierLevel.setProfileCompatibilityFlag(m_profileList[ii], 1);
+    profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlagList[ii]);
+    profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlagList[ii]);
+    profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[ii]);
+    profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[ii]);
+  }
+  pVPS->setNumProfileTierLevel(m_numPTLInfo);
+
+  std::vector<int> myvector;
+  vps->getProfileLevelTierIdx()->resize(m_numOutputLayerSets);
+  for (int ii = 0; ii < m_numOutputLayerSets; ii++)
+  {
+    myvector =  m_listOfLayerPTLofOlss[ii];
+    vps->getProfileLevelTierIdx()->resize(myvector.size());
+    for (std::vector<int>::iterator it = myvector.begin() ; it != myvector.end(); ++it)
+    {
+      pVPS->addProfileLevelTierIdx(ii, it[0]);
+    }
+  }
+#endif
+
   assert( m_numLayers <= MAX_LAYERS );
 
@@ -222,5 +254,18 @@
 #endif
 #endif
-    //m_acTEncTop[layer].setVPS(&vps);
+    
+#if MULTIPLE_PTL_SUPPORT
+    Int layerPTLIdx = m_acLayerCfg[layer].m_layerPTLIdx;
+    m_acTEncTop[layer].setProfile                                         ( m_profileList[layerPTLIdx] );
+    m_acTEncTop[layer].setLevel                                           ( m_levelTierList[layerPTLIdx], m_levelList[layerPTLIdx] );
+    m_acTEncTop[layer].setProgressiveSourceFlag                           ( m_progressiveSourceFlagList[layerPTLIdx] );
+    m_acTEncTop[layer].setInterlacedSourceFlag                            ( m_interlacedSourceFlagList[layerPTLIdx] );
+    m_acTEncTop[layer].setNonPackedConstraintFlag                         ( m_nonPackedConstraintFlagList[layerPTLIdx] );
+    m_acTEncTop[layer].setFrameOnlyConstraintFlag                         ( m_frameOnlyConstraintFlagList[layerPTLIdx] );
+    m_acTEncTop[layer].setBitDepthConstraintValue                         ( m_acLayerCfg[layer].m_bitDepthConstraint );
+    m_acTEncTop[layer].setChromaFormatConstraintValue                     ( m_acLayerCfg[layer].m_chromaFormatConstraint );
+    m_acTEncTop[layer].setIntraConstraintFlag                             ( m_acLayerCfg[layer].m_intraConstraintFlag );
+    m_acTEncTop[layer].setLowerBitRateConstraintFlag                      ( m_acLayerCfg[layer].m_lowerBitRateConstraintFlag );
+#else
     m_acTEncTop[layer].setProfile                                         ( m_profile );
     m_acTEncTop[layer].setLevel                                           ( m_levelTier, m_level );
@@ -233,4 +278,5 @@
     m_acTEncTop[layer].setIntraConstraintFlag                             ( m_intraConstraintFlag );
     m_acTEncTop[layer].setLowerBitRateConstraintFlag                      ( m_lowerBitRateConstraintFlag );
+#endif
 
     m_acTEncTop[layer].setPrintMSEBasedSequencePSNR                       ( m_printMSEBasedSequencePSNR);
@@ -423,5 +469,5 @@
     m_acTEncTop[layer].setChromaCrQpOffset                                 ( m_crQpOffset  );
 
-    m_acTEncTop[layer].setChromaFormatIdc                                  ( m_chromaFormatIDC  );
+    m_acTEncTop[layer].setChromaFormatIdc                                  ( m_acLayerCfg[layer].m_chromaFormatIDC  );
 
 #if ADAPTIVE_QP_SELECTION
@@ -1438,5 +1484,5 @@
     vps->setIlpSshSignalingEnabledFlag(false);
 #if VPS_EXTN_PROFILE_INFO
-
+#if !MULTIPLE_PTL_SUPPORT
 #if LIST_OF_PTL
   vps->getPTLForExtnPtr()->resize(1);   // Dummy object - unused.
@@ -1467,4 +1513,5 @@
     *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL());
   }
+#endif
 #endif
 #endif
@@ -1577,4 +1624,5 @@
 #endif
   // Target output layer
+#if !MULTIPLE_PTL_SUPPORT
 #if LIST_OF_PTL
   vps->setNumProfileTierLevel( vps->getPTLForExtnPtr()->size() ); // +1 for the base VPS PTL()
@@ -1582,4 +1630,5 @@
   vps->setNumOutputLayerSets(vps->getNumLayerSets());
   vps->setNumProfileTierLevel(vps->getNumLayerSets());
+#endif
 #endif
 #if !OUTPUT_LAYER_SETS_CONFIG // Taken care by configuration file parameter
@@ -1673,4 +1722,5 @@
   vps->checkNecessaryLayerFlagCondition();
 #endif
+#if !MULTIPLE_PTL_SUPPORT
 #if PER_LAYER_PTL
   vps->getProfileLevelTierIdx()->resize(vps->getNumOutputLayerSets());
@@ -1693,4 +1743,5 @@
     }
   }
+#endif
 #endif
 #if SUB_LAYERS_IN_LAYER_SET
