Index: branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 580)
+++ branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 582)
@@ -1937,4 +1937,15 @@
 , m_bitDepthVpsChroma           (0)
 {}
+#if RESOLUTION_BASED_DPB
+Void RepFormat::init()
+{
+  m_chromaFormatVpsIdc          = CHROMA_420;
+  m_separateColourPlaneVpsFlag  = false;
+  m_picWidthVpsInLumaSamples    = 0;
+  m_picHeightVpsInLumaSamples   = 0;
+  m_bitDepthVpsLuma             = 0;
+  m_bitDepthVpsChroma           = 0;
+}
+#endif
 #endif
 
@@ -2126,4 +2137,7 @@
   ::memset( m_subLayerDpbInfoPresentFlag,   0, sizeof(m_subLayerDpbInfoPresentFlag )  );
   ::memset( m_maxVpsDecPicBufferingMinus1,  0, sizeof(m_maxVpsDecPicBufferingMinus1 ) );
+#if RESOLUTION_BASED_DPB
+  ::memset( m_maxVpsLayerDecPicBuffMinus1,  0, sizeof(m_maxVpsLayerDecPicBuffMinus1 ) );
+#endif
   ::memset( m_maxVpsNumReorderPics,         0, sizeof(m_maxVpsNumReorderPics )        );
   ::memset( m_maxVpsLatencyIncreasePlus1,   0, sizeof(m_maxVpsLatencyIncreasePlus1 )  );
@@ -2182,4 +2196,5 @@
 }
 #endif
+#if !RESOLUTION_BASED_DPB
 #if VPS_DPB_SIZE_TABLE
 Void TComVPS::deriveNumberOfSubDpbs()
@@ -2205,4 +2220,5 @@
 }
 #endif
+#endif
 #if VPS_VUI_TILES_NOT_IN_USE__FLAG
 Void TComVPS::setTilesNotInUseFlag(Bool x)
@@ -2329,11 +2345,17 @@
         checkFlagInner[j] |= ( getMaxVpsNumReorderPics(i, j) != getMaxVpsNumReorderPics(i, j - 1) );
 #if CHANGE_NUMSUBDPB_IDX
-        for(Int k = 0; k < getNumSubDpbs(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; k++)  // If checkFlagInner[j] is true, break and signal the values
+        for(Int subDpbIdx = 0; subDpbIdx < getNumSubDpbs(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; subDpbIdx++)  // If checkFlagInner[j] is true, break and signal the values
 #else
         for(Int k = 0; k < getNumSubDpbs(i) && !checkFlagInner[j]; k++)  // If checkFlagInner[j] is true, break and signal the values
 #endif
         {
-          checkFlagInner[j] |= ( getMaxVpsDecPicBufferingMinus1(i, k, j - 1) != getMaxVpsDecPicBufferingMinus1(i, k, j) );
+          checkFlagInner[j] |= ( getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j - 1) != getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j) );
         }
+#if RESOLUTION_BASED_DPB
+        for(Int layerIdx = 0; layerIdx < this->getNumLayersInIdList(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; layerIdx++)  // If checkFlagInner[j] is true, break and signal the values
+        {
+          checkFlagInner[j] |= ( getMaxVpsLayerDecPicBuffMinus1(i, layerIdx, j - 1) != getMaxVpsLayerDecPicBuffMinus1(i, layerIdx, j) );
+        }
+#endif
       }
       // If checkFlagInner[j] = true, then some value needs to be signalled for the j-th sub-layer
@@ -2355,4 +2377,100 @@
     setSubLayerFlagInfoPresentFlag( i, checkFlagOuter );
   }
+}
+#endif
+#if RESOLUTION_BASED_DPB
+Void TComVPS::assignSubDpbIndices()
+{
+  RepFormat layerRepFormat  [MAX_LAYERS];
+  RepFormat subDpbRepFormat [MAX_LAYERS];
+
+  for(Int lsIdx = 0; lsIdx < this->getNumLayerSets(); lsIdx++)
+  {
+    for(Int j = 0; j < MAX_LAYERS; j++)
+    {
+      layerRepFormat [j].init();
+      subDpbRepFormat[j].init();
+    }
+
+    // Assign resolution, bit-depth, colour format for each layer in the layer set
+    for(Int i = 0; i < this->getNumLayersInIdList( lsIdx ); i++)
+    {
+      Int layerIdxInVps = this->getLayerIdInVps( this->getLayerSetLayerIdList(lsIdx, i) );
+      Int repFormatIdx  = this->getVpsRepFormatIdx( layerIdxInVps );
+      RepFormat* repFormat = this->getVpsRepFormat( repFormatIdx );
+
+      // Assign the rep_format() to the layer
+      layerRepFormat[i] = *repFormat;
+    }
+
+    // ----------------------------------------
+    // Sub-DPB assignment
+    // ----------------------------------------
+    // For the base layer 
+    m_subDpbAssigned[lsIdx][0] = 0;
+    subDpbRepFormat[0] = layerRepFormat[0];
+
+    // Sub-DPB counter
+    Int subDpbCtr = 1;
+
+    for(Int i = 1; i < this->getNumLayersInIdList( lsIdx ); i++)
+    {
+      Bool newSubDpbFlag = true;
+      for(Int j = 0; (j < subDpbCtr) && (newSubDpbFlag); j++)
+      {
+        if( RepFormat::checkSameSubDpb( layerRepFormat[i], subDpbRepFormat[j] ) )
+        {
+          // Belong to i-th sub-DPB
+          m_subDpbAssigned[lsIdx][i] = j;
+          newSubDpbFlag = false;
+        }
+      }
+      if( newSubDpbFlag )
+      {
+        // New sub-DPB
+        subDpbRepFormat[subDpbCtr] = layerRepFormat[i];
+        m_subDpbAssigned[lsIdx][i] = subDpbCtr;
+        subDpbCtr++;                                    // Increment # subDpbs
+      }
+    }
+    m_numSubDpbs[lsIdx] = subDpbCtr;
+  }
+}
+Int  TComVPS::findLayerIdxInLayerSet ( Int lsIdx, Int nuhLayerId )
+{
+  for(Int i = 0; i < this->getNumLayersInIdList(lsIdx); i++)
+  {
+    if( this->getLayerSetLayerIdList( lsIdx, i) == nuhLayerId )
+    {
+      return i;
+    }
+  }
+  return -1;  // Layer not found
+}
+// RepFormat Assignment operator
+RepFormat& RepFormat::operator= (const RepFormat &other)
+{
+  if( this != &other)
+  {
+    m_chromaAndBitDepthVpsPresentFlag = other.m_chromaAndBitDepthVpsPresentFlag;
+    m_chromaFormatVpsIdc              = other.m_chromaFormatVpsIdc;
+    m_separateColourPlaneVpsFlag      = other.m_separateColourPlaneVpsFlag;
+    m_picWidthVpsInLumaSamples        = other.m_picWidthVpsInLumaSamples;
+    m_picHeightVpsInLumaSamples       = other.m_picHeightVpsInLumaSamples;
+    m_bitDepthVpsLuma                 = other.m_bitDepthVpsLuma;
+    m_bitDepthVpsChroma               = other.m_bitDepthVpsChroma;
+  }
+  return *this;
+}
+
+// Check whether x and y share the same resolution, chroma format and bit-depth.
+Bool RepFormat::checkSameSubDpb(const RepFormat &x, const RepFormat &y)
+{
+  return (    (x.m_chromaFormatVpsIdc              == y.m_chromaFormatVpsIdc)
+          &&  (x.m_picWidthVpsInLumaSamples        == y.m_picWidthVpsInLumaSamples)
+          &&  (x.m_picHeightVpsInLumaSamples       == y.m_picHeightVpsInLumaSamples)
+          &&  (x.m_bitDepthVpsLuma                 == y.m_bitDepthVpsLuma)
+          &&  (x.m_bitDepthVpsChroma               == y.m_bitDepthVpsChroma)
+          );
 }
 #endif
Index: branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 580)
+++ branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 582)
@@ -422,5 +422,9 @@
 public:
   RepFormat();
-
+#if RESOLUTION_BASED_DPB
+  Void init();
+  RepFormat& operator= (const RepFormat &);
+  static Bool checkSameSubDpb(const RepFormat &x, const RepFormat &y);
+#endif
 #if REPN_FORMAT_CONTROL_FLAG
   Bool getChromaAndBitDepthVpsPresentFlag() { return m_chromaAndBitDepthVpsPresentFlag; }
@@ -650,4 +654,7 @@
   Bool    m_subLayerDpbInfoPresentFlag  [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS];
   Int     m_maxVpsDecPicBufferingMinus1 [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS][MAX_TLAYER];
+#if RESOLUTION_BASED_DPB
+  Int     m_maxVpsLayerDecPicBuffMinus1 [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS][MAX_TLAYER];  
+#endif
   Int     m_maxVpsNumReorderPics        [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS];
   Int     m_maxVpsLatencyIncreasePlus1  [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS];
@@ -670,4 +677,7 @@
 #if P0307_VPS_NON_VUI_EXTENSION
   Int     m_vpsNonVuiExtLength;
+#endif
+#if RESOLUTION_BASED_DPB
+  Int     m_subDpbAssigned            [MAX_VPS_LAYER_SETS_PLUS1][MAX_LAYERS];
 #endif
 #endif //SVC_EXTENSION
@@ -1020,4 +1030,9 @@
   Void    setMaxVpsDecPicBufferingMinus1(Int i, Int k, Int j, Int x) { m_maxVpsDecPicBufferingMinus1[i][k][j] = x;    }
 
+#if RESOLUTION_BASED_DPB
+  Int     getMaxVpsLayerDecPicBuffMinus1(Int i, Int k, Int j)        { assert(i != 0); return m_maxVpsLayerDecPicBuffMinus1[i][k][j]; }
+  Void    setMaxVpsLayerDecPicBuffMinus1(Int i, Int k, Int j, Int x) { m_maxVpsLayerDecPicBuffMinus1[i][k][j] = x;    }
+#endif
+
   Int     getMaxVpsNumReorderPics(Int i, Int j)         { assert(i != 0); return m_maxVpsNumReorderPics[i][j]; }
   Void    setMaxVpsNumReorderPics(Int i, Int j, Int x) { m_maxVpsNumReorderPics[i][j] = x;    }
@@ -1045,4 +1060,9 @@
   Int     getVpsNonVuiExtLength()         { return m_vpsNonVuiExtLength; }
   Void    setVpsNonVuiExtLength(Int x)    { m_vpsNonVuiExtLength = x; }
+#endif
+#if RESOLUTION_BASED_DPB
+  Void assignSubDpbIndices();
+  Int  getSubDpbAssigned  (Int lsIdx, Int layerIdx) { return m_subDpbAssigned[lsIdx][layerIdx]; }
+  Int  findLayerIdxInLayerSet ( Int lsIdx, Int nuhLayerId );
 #endif
 #endif //SVC_EXTENSION
Index: branches/SHM-5.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-5.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 580)
+++ branches/SHM-5.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 582)
@@ -57,4 +57,5 @@
 #define VPS_EXTN_UEV_CODING              1      ///< JCTVC-P0306: Code some syntax elements as ue(v), and remove some syntax elements that duplicate behaviour
 #define CHANGE_NUMSUBDPB_IDX             1      ///< Change index of NumSubDpb from output layer set to layer set, to be more aligned with the Spec
+#define RESOLUTION_BASED_DPB             1      ///< JCTVC-P0192: Assign layers to sub-DPBs based on the rep_format() signaled in the VPS
 #define O0109_O0199_FLAGS_TO_VUI         1      ///< JCTVC-O0109, O0199: move single_layer_for_non_irap_flag and higher_layer_flag to vps_vui
 #define O0109_VIEW_ID_LEN                1      ///< JCTVC-O0109: view_id_len_minus1 to view_id_len, and add constraint (1<<view_id_len) is greater than or equal to NumViews
