Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 865)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 866)
@@ -1481,4 +1481,5 @@
 #endif
 #endif
+#if !PER_LAYER_PTL
   for(i = 1; i < vps->getNumLayerSets(); i++)
   {
@@ -1488,4 +1489,5 @@
 #endif
   }  
+#endif
 #endif
  #if VPS_DPB_SIZE_TABLE
@@ -1554,4 +1556,25 @@
   vps->deriveNecessaryLayerFlag();
   vps->checkNecessaryLayerFlagCondition();
+#endif
+#if PER_LAYER_PTL
+  vps->getProfileLevelTierIdx()->resize(vps->getNumOutputLayerSets());
+  vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0 ); // Default 0-th output layer set
+  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
+  {
+    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
+    Int numLayerInLayerSet = vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet );
+    for(Int j = 0; j < numLayerInLayerSet; j++)
+    {
+      Int layerIdxInVps = vps->getLayerIdInVps( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) );
+      if( vps->getNecessaryLayerFlag(i, j) )
+      {
+        vps->getProfileLevelTierIdx(i)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? layerIdxInVps + 1 : layerIdxInVps);
+      }
+      else
+      {
+        vps->getProfileLevelTierIdx(i)->push_back( -1 );
+      }
+    }
+  }
 #endif
   // Initialize dpb_size_table() for all ouput layer sets in the VPS extension
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 865)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 866)
@@ -2446,5 +2446,7 @@
 #endif
 #endif
+#if !PER_LAYER_PTL
   ::memset(m_profileLevelTierIdx,  0, sizeof(m_profileLevelTierIdx));
+#endif
   m_maxOneActiveRefLayerFlag = true;
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
@@ -3074,4 +3076,15 @@
     assert( layerFoundNecessaryLayerFlag );
   }
+}
+#endif
+#if PER_LAYER_PTL
+Int const TComVPS::calculateLenOfSyntaxElement( Int const numVal )
+{
+  Int numBits = 1;
+  while((1 << numBits) < numVal)
+  {
+    numBits++;
+  }
+  return numBits;
 }
 #endif
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 865)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 866)
@@ -585,5 +585,9 @@
 #endif
 #endif
+#if PER_LAYER_PTL
+  std::vector< std::vector<Int> >  m_profileLevelTierIdx;
+#else
   Int        m_profileLevelTierIdx[64];     
+#endif
   Bool       m_maxOneActiveRefLayerFlag;
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
@@ -984,6 +988,15 @@
 #endif
 #endif
+#if PER_LAYER_PTL
+  Bool const getNecessaryLayerFlag(Int const i, Int const j) { return m_necessaryLayerFlag[i][j]; }
+  std::vector< std::vector<Int> >* const getProfileLevelTierIdx() { return &m_profileLevelTierIdx; }
+  std::vector<Int>* const getProfileLevelTierIdx(Int const olsIdx) { return &m_profileLevelTierIdx[olsIdx]; }
+  Int    getProfileLevelTierIdx(Int const olsIdx, Int const layerIdx)     { return m_profileLevelTierIdx[olsIdx][layerIdx]; }
+  Void   setProfileLevelTierIdx(Int const olsIdx, Int const layerIdx, Int const ptlIdx)     { m_profileLevelTierIdx[olsIdx][layerIdx] = ptlIdx; }
+  Int const calculateLenOfSyntaxElement( Int const numVal );
+#else
   Int    getProfileLevelTierIdx(Int i)                        { return m_profileLevelTierIdx[i]; }
   Void   setProfileLevelTierIdx(Int i, Int x)                 { m_profileLevelTierIdx[i] = x   ; }
+#endif
   Bool   getMaxOneActiveRefLayerFlag()                                          { return m_maxOneActiveRefLayerFlag;                      }
   Void   setMaxOneActiveRefLayerFlag(Bool x)                                    { m_maxOneActiveRefLayerFlag = x;                         }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 865)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 866)
@@ -57,4 +57,5 @@
 #define LIST_OF_PTL                      1      ///< JCTVC-R0272: Signalling the PTL for the 0-th OLS
 #define NECESSARY_LAYER_FLAG                   1      ////< Derivation of NecessaryLayerFlag
+#define PER_LAYER_PTL                    1      ///< Signal profile-tier-level information for each layer.
 #endif
 #define O0137_MAX_LAYERID                1      ///< JCTVC-O0137, JCTVC-O0200, JCTVC-O0223: restrict nuh_layer_id and vps_max_layers_minus1
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 865)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 866)
@@ -1374,4 +1374,7 @@
   READ_UVLC(  uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 );
 #endif
+#if PER_LAYER_PTL
+  Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() );
+#endif
   vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel());
 #if LIST_OF_PTL
@@ -1472,4 +1475,8 @@
   vps->setOutputLayerFlag(0, 0, true);
   vps->deriveNecessaryLayerFlag(0);
+#if PER_LAYER_PTL
+  vps->getProfileLevelTierIdx()->resize(numOutputLayerSets);
+  vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0);
+#endif
 #endif
   for(i = 1; i < numOutputLayerSets; i++)
@@ -1488,4 +1495,5 @@
       vps->setOutputLayerSetIdx( i, i );
     }
+    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
 #if Q0078_ADD_LAYER_SETS
     if ( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 )
@@ -1494,7 +1502,6 @@
 #endif
     {
-      Int lsIdx = vps->getOutputLayerSetIdx(i);
 #if NUM_OL_FLAGS
-      for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
+      for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
 #else
       for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
@@ -1508,15 +1515,14 @@
       // i <= (vps->getNumLayerSets() - 1)
       // Assign OutputLayerFlag depending on default_one_target_output_layer_flag
-      Int lsIdx = i;
       if( vps->getDefaultTargetOutputLayerIdc() == 1 )
       {
-        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
-        {
-          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1) == 0) );
+        for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
+        {
+          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) && (vps->getDimensionId(j,1) == 0) );
         }
       }
       else if ( vps->getDefaultTargetOutputLayerIdc() == 0 )
       {
-        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
+        for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
         {
           vps->setOutputLayerFlag(i, j, 1);
@@ -1527,4 +1533,15 @@
     vps->deriveNecessaryLayerFlag(i);  
 #endif
+#if PER_LAYER_PTL
+    vps->getProfileLevelTierIdx(i)->assign(vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet), -1);
+    for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++)
+    {
+      if( vps->getNecessaryLayerFlag(i, j) )
+      {
+        READ_CODE( numBitsForPtlIdx, uiCode, "profile_level_tier_idx[i]" ); 
+        vps->setProfileLevelTierIdx(i, j, uiCode );
+      }
+    }
+#else
     Int numBits = 1;
     while ((1 << numBits) < (vps->getNumProfileTierLevel()))
@@ -1533,7 +1550,7 @@
     }
     READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
+#endif
 #if P0300_ALT_OUTPUT_LAYER_FLAG
     NumOutputLayersInOutputLayerSet[i] = 0;
-    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
     for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
     {
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 865)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 866)
@@ -1070,4 +1070,7 @@
 #else
   WRITE_UVLC( vps->getNumProfileTierLevel() - 1, "vps_num_profile_tier_level_minus1"); 
+#if PER_LAYER_PTL
+  Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() );
+#endif
 #endif
 #if LIST_OF_PTL
@@ -1153,4 +1156,5 @@
   for(i = 1; i < numOutputLayerSets; i++)
   {
+    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
     if( i > (vps->getNumLayerSets() - 1) )
     {
@@ -1170,7 +1174,6 @@
     {
 #endif
-      Int lsIdx = vps->getOutputLayerSetIdx(i);
 #if NUM_OL_FLAGS
-      for(j = 0; j < vps->getNumLayersInIdList(lsIdx) ; j++)
+      for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++)
 #else
       for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
@@ -1180,4 +1183,13 @@
       }
     }
+#if PER_LAYER_PTL
+    for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++)
+    {
+      if( vps->getNecessaryLayerFlag(i, j) )
+      {
+        WRITE_CODE( vps->getProfileLevelTierIdx(i, j), numBitsForPtlIdx, "profile_level_tier_idx[i]" );
+      }
+    }
+#else
     Int numBits = 1;
     while ((1 << numBits) < (vps->getNumProfileTierLevel()))
@@ -1186,7 +1198,7 @@
     }
     WRITE_CODE( vps->getProfileLevelTierIdx(i), numBits, "profile_level_tier_idx[i]" );     
+#endif
 #if P0300_ALT_OUTPUT_LAYER_FLAG
     NumOutputLayersInOutputLayerSet[i] = 0;
-    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
     for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
     {
