Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 871)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 872)
@@ -1506,4 +1506,5 @@
 Void TEncCavlc::codeVpsDpbSizeTable(TComVPS *vps)
 {
+#if !SUB_LAYERS_IN_LAYER_SET  // MaxSLInLayerSets calculated earlier in the encoder
 #if DPB_PARAMS_MAXTLAYERS
 #if BITRATE_PICRATE_SIGNALLING
@@ -1534,4 +1535,5 @@
     }
 #endif
+#endif
     
     
@@ -1542,4 +1544,7 @@
 #endif
     WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]");
+#if SUB_LAYERS_IN_LAYER_SET
+    for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++)
+#else
 #if DPB_PARAMS_MAXTLAYERS
 #if BITRATE_PICRATE_SIGNALLING
@@ -1550,4 +1555,5 @@
 #else
     for(Int j = 0; j < vps->getMaxTLayers(); j++)
+#endif
 #endif
     {
@@ -1585,4 +1591,5 @@
   }
 
+#if !SUB_LAYERS_IN_LAYER_SET
 #if BITRATE_PICRATE_SIGNALLING
   if( MaxSubLayersInLayerSetMinus1 )
@@ -1590,4 +1597,5 @@
     delete [] MaxSubLayersInLayerSetMinus1;
   }
+#endif
 #endif
 }
