Index: trunk/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 547)
+++ trunk/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 588)
@@ -148,5 +148,5 @@
 #endif
 #if OUTPUT_LAYER_SET_INDEX  
-  this->getCommonDecoderParams()->setOutputLayerSetIdx( olsIdx       );
+  this->getCommonDecoderParams()->setTargetOutputLayerSetIdx( olsIdx       );
   this->getCommonDecoderParams()->setTargetLayerId    ( m_tgtLayerId );
 #endif
Index: trunk/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 547)
+++ trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 588)
@@ -81,5 +81,5 @@
   }
 #if SVC_EXTENSION
-  for( Int i = 0; i < m_tgtLayerId; i++ )
+  for( Int i = 0; i <= m_tgtLayerId; i++ )
   {
     if( m_pchReconFile[i] )
Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 547)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 588)
@@ -80,7 +80,4 @@
   {
     m_acLayerCfg[layer].setAppEncCfg(this);
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-    m_ilSampleOnlyPred[layer] = 0;
-#endif
   }
   memset( m_scalabilityMask, 0, sizeof(m_scalabilityMask) );
@@ -146,5 +143,4 @@
 {
 #if VPS_EXTN_DIRECT_REF_LAYERS
-#if M0457_PREDICTION_INDICATIONS
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -152,27 +148,15 @@
     {
       delete [] m_acLayerCfg[layer].m_samplePredRefLayerIds;
-    }
-  }
-  for(Int layer = 0; layer < MAX_LAYERS; layer++)
-  {
+      m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL;
+    }
     if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 )
     {
       delete [] m_acLayerCfg[layer].m_motionPredRefLayerIds;
-    }
-  }
-#else
-  for(Int layer = 0; layer < MAX_LAYERS; layer++)
-  {
-    if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 )
-    {
-      delete [] m_acLayerCfg[layer].m_refLayerIds;
-    }
-  }
-#endif
-  for(Int layer = 0; layer < MAX_LAYERS; layer++)
-  {
+      m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL;
+    }
     if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
     {
       delete [] m_acLayerCfg[layer].m_predLayerIds;
+      m_acLayerCfg[layer].m_predLayerIds = NULL;
     }
   }
@@ -383,5 +367,4 @@
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
-#if M0457_PREDICTION_INDICATIONS
   Int*    cfg_numSamplePredRefLayers  [MAX_LAYERS];
   string  cfg_samplePredRefLayerIds   [MAX_LAYERS];
@@ -390,9 +373,4 @@
   string  cfg_motionPredRefLayerIds   [MAX_LAYERS];
   string* cfg_motionPredRefLayerIdsPtr[MAX_LAYERS];
-#else
-  Int*    cfg_numDirectRefLayers [MAX_LAYERS];
-  string  cfg_refLayerIds        [MAX_LAYERS];
-  string* cfg_refLayerIdsPtr     [MAX_LAYERS];
-#endif
   Int*    cfg_numActiveRefLayers [MAX_LAYERS];
   string  cfg_predLayerIds       [MAX_LAYERS];
@@ -462,13 +440,8 @@
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
-#if M0457_PREDICTION_INDICATIONS
     cfg_numSamplePredRefLayers  [layer] = &m_acLayerCfg[layer].m_numSamplePredRefLayers;
     cfg_samplePredRefLayerIdsPtr[layer] = &cfg_samplePredRefLayerIds[layer];
     cfg_numMotionPredRefLayers  [layer] = &m_acLayerCfg[layer].m_numMotionPredRefLayers;
     cfg_motionPredRefLayerIdsPtr[layer] = &cfg_motionPredRefLayerIds[layer];
-#else
-    cfg_numDirectRefLayers  [layer] = &m_acLayerCfg[layer].m_numDirectRefLayers;
-    cfg_refLayerIdsPtr      [layer]  = &cfg_refLayerIds[layer];
-#endif
     cfg_numActiveRefLayers  [layer] = &m_acLayerCfg[layer].m_numActiveRefLayers;
     cfg_predLayerIdsPtr     [layer]  = &cfg_predLayerIds[layer];
@@ -551,13 +524,8 @@
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
-#if M0457_PREDICTION_INDICATIONS
   ("NumSamplePredRefLayers%d",cfg_numSamplePredRefLayers, -1, MAX_LAYERS, "Number of sample prediction reference layers")
   ("SamplePredRefLayerIds%d", cfg_samplePredRefLayerIdsPtr, string(""), MAX_LAYERS, "sample pred reference layer IDs")
   ("NumMotionPredRefLayers%d",cfg_numMotionPredRefLayers, -1, MAX_LAYERS, "Number of motion prediction reference layers")
   ("MotionPredRefLayerIds%d", cfg_motionPredRefLayerIdsPtr, string(""), MAX_LAYERS, "motion pred reference layer IDs")
-#else
-  ("NumDirectRefLayers%d",    cfg_numDirectRefLayers, -1, MAX_LAYERS, "Number of direct reference layers")
-  ("RefLayerIds%d",           cfg_refLayerIdsPtr, string(""), MAX_LAYERS, "direct reference layer IDs")
-#endif
   ("NumActiveRefLayers%d",    cfg_numActiveRefLayers, -1, MAX_LAYERS, "Number of active reference layers")
   ("PredLayerIds%d",          cfg_predLayerIdsPtr, string(""), MAX_LAYERS, "inter-layer prediction layer IDs")
@@ -619,5 +587,8 @@
 #endif
 #if N0147_IRAP_ALIGN_FLAG
-    ("CrossLayerIrapAlignFlag", m_crossLayerIrapAlignFlag, true, "align IRAP across layers" )  
+  ("CrossLayerIrapAlignFlag", m_crossLayerIrapAlignFlag, true, "align IRAP across layers" )  
+#endif
+#if O0194_WEIGHTED_PREDICTION_CGS
+  ("InterLayerWeightedPred", m_useInterLayerWeightedPred, false, "enable IL WP parameters estimation at encoder" )  
 #endif
 #if AVC_BASE
@@ -629,7 +600,4 @@
 #endif
   ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  ("IlSampleOnlyPred%d",       m_ilSampleOnlyPred, 0, MAX_LAYERS, "Set inter_layer_sample_pred_only_flag for all slices")
-#endif
 #else //SVC_EXTENSION
   ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
@@ -956,6 +924,6 @@
   ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0, "Control generation of gradual decoding refresh information SEI message")
   ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0, "Control generation of decoding unit information SEI message.")
-#if M0043_LAYERS_PRESENT_SEI
-  ("SEILayersPresent",               m_layersPresentSEIEnabled,                0, "Control generation of layers present SEI message")
+#if LAYERS_NOT_PRESENT_SEI
+  ("SEILayersNotPresent",            m_layersNotPresentSEIEnabled,             0, "Control generation of layers not present SEI message")
 #endif
   ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
@@ -1190,5 +1158,4 @@
   }
 #if VPS_EXTN_DIRECT_REF_LAYERS
-#if M0457_PREDICTION_INDICATIONS
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -1253,37 +1220,5 @@
     }
   }
-#else
-  for(Int layer = 0; layer < MAX_LAYERS; layer++)
-  {
-    Char* pRefLayerIds = cfg_refLayerIds[layer].empty() ? NULL: strdup(cfg_refLayerIds[layer].c_str());
-    if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 )
-    {
-      char *refLayerId;
-      int  i=0;
-      m_acLayerCfg[layer].m_refLayerIds = new Int[m_acLayerCfg[layer].m_numDirectRefLayers];
-      refLayerId = strtok(pRefLayerIds, " ,-");
-      while(refLayerId != NULL)
-      {
-        if( i >= m_acLayerCfg[layer].m_numDirectRefLayers )
-        {
-          printf( "NumDirectRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
-          exit( EXIT_FAILURE );
-        }
-        *( m_acLayerCfg[layer].m_refLayerIds + i ) = atoi( refLayerId );
-        refLayerId = strtok(NULL, " ,-");
-        i++;
-      }
-      if( i < m_acLayerCfg[layer].m_numDirectRefLayers )
-      {
-        printf( "NumDirectRefLayers: The width of some columns is not defined.\n" );
-        exit( EXIT_FAILURE );
-      }
-    }
-    else
-    {
-      m_acLayerCfg[layer].m_refLayerIds = NULL;
-    }
-  }
-#endif
+
 #if AUXILIARY_PICTURES
   for(UInt layer = 0; layer < MAX_LAYERS; layer++)
@@ -2231,5 +2166,4 @@
   }
 #if VPS_EXTN_DIRECT_REF_LAYERS
-#if M0457_PREDICTION_INDICATIONS
   xConfirmPara( (m_acLayerCfg[0].m_numSamplePredRefLayers != 0) && (m_acLayerCfg[0].m_numSamplePredRefLayers != -1), "Layer 0 cannot have any reference layers" );
   // NOTE: m_numSamplePredRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
@@ -2254,22 +2188,9 @@
     }
   }
-#else
-  xConfirmPara( (m_acLayerCfg[0].m_numDirectRefLayers != 0) && (m_acLayerCfg[0].m_numDirectRefLayers != -1), "Layer 0 cannot have any reference layers" );
-  // NOTE: m_numDirectRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
-  for(Int layer = 1; layer < MAX_LAYERS; layer++)
-  {
-    xConfirmPara(m_acLayerCfg[layer].m_numDirectRefLayers > layer, "Cannot reference more layers than before current layer");
-    for(Int i = 0; i < m_acLayerCfg[layer].m_numDirectRefLayers; i++)
-    {
-      xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] > layer, "Cannot reference higher layers");
-      xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] == layer, "Cannot reference the current layer itself");
-    }
-  }
-#endif
+
   xConfirmPara( (m_acLayerCfg[0].m_numActiveRefLayers != 0) && (m_acLayerCfg[0].m_numActiveRefLayers != -1), "Layer 0 cannot have any active reference layers" );
   // NOTE: m_numActiveRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
   for(Int layer = 1; layer < MAX_LAYERS; layer++)
   {
-#if M0457_PREDICTION_INDICATIONS
     Bool predEnabledFlag[MAX_LAYERS];
     for (Int refLayer = 0; refLayer < layer; refLayer++)
@@ -2295,13 +2216,6 @@
       xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] >= numDirectRefLayers, "Cannot reference higher layers");
     }
-#else
-    xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers");
-    for(Int i = 0; i < m_acLayerCfg[layer].m_numActiveRefLayers; i++)
-    {
-      xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] >= m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference higher layers");
-    }
-#endif
-  }
-#endif
+  }
+#endif //VPS_EXTN_DIRECT_REF_LAYERS
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   if (m_adaptiveResolutionChange > 0)
@@ -2435,4 +2349,7 @@
 #if N0147_IRAP_ALIGN_FLAG
   printf("Cross layer IRAP alignment    : %d\n", m_crossLayerIrapAlignFlag );
+#endif
+#if O0194_WEIGHTED_PREDICTION_CGS
+  printf("InterLayerWeightedPred        : %d\n", m_useInterLayerWeightedPred );
 #endif
   for(UInt layer=0; layer<m_numLayers; layer++)
@@ -2581,5 +2498,4 @@
   printf("O0194_DIFFERENT_BITDEPTH_EL_BL: %d ", O0194_DIFFERENT_BITDEPTH_EL_BL);
   printf("O0194_JOINT_US_BITSHIFT: %d ", O0194_JOINT_US_BITSHIFT);
-  printf("O0194_WEIGHTED_PREDICTION_CGS: %d ",O0194_WEIGHTED_PREDICTION_CGS);
 #else
   printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 547)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 588)
@@ -72,7 +72,4 @@
 #if AVC_SYNTAX
   Char*     m_BLSyntaxFile;                                   ///< input syntax file
-#endif
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  Int       m_ilSampleOnlyPred[ MAX_LAYERS ];
 #endif
 #if N0120_MAX_TID_REF_CFG
@@ -283,6 +280,6 @@
   Int       m_gradualDecodingRefreshInfoEnabled;
   Int       m_decodingUnitInfoSEIEnabled;
-#if M0043_LAYERS_PRESENT_SEI
-  Int       m_layersPresentSEIEnabled;
+#if LAYERS_NOT_PRESENT_SEI
+  Int       m_layersNotPresentSEIEnabled;
 #endif
   Int       m_SOPDescriptionSEIEnabled;
@@ -384,14 +381,17 @@
 #endif
 #if O0215_PHASE_ALIGNMENT
-  Bool m_phaseAlignFlag;
+  Bool      m_phaseAlignFlag;
 #endif
 #if O0223_PICTURE_TYPES_ALIGN_FLAG
-  Bool m_crossLayerPictureTypeAlignFlag;
+  Bool      m_crossLayerPictureTypeAlignFlag;
 #endif
 #if N0147_IRAP_ALIGN_FLAG
-  Bool m_crossLayerIrapAlignFlag;
+  Bool      m_crossLayerIrapAlignFlag;
 #endif
 #if O0149_CROSS_LAYER_BLA_FLAG
-  bool      m_crossLayerBLAFlag;
+  Bool      m_crossLayerBLAFlag;
+#endif
+#if O0194_WEIGHTED_PREDICTION_CGS
+  Bool      m_useInterLayerWeightedPred;
 #endif
 public:
Index: trunk/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 547)
+++ trunk/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 588)
@@ -48,13 +48,8 @@
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
-#if M0457_PREDICTION_INDICATIONS
   Int       *m_samplePredRefLayerIds;
   Int       m_numSamplePredRefLayers;
   Int       *m_motionPredRefLayerIds;
   Int       m_numMotionPredRefLayers;
-#else
-  Int       *m_refLayerIds;
-  Int       m_numDirectRefLayers;
-#endif
   Int       *m_predLayerIds;
   Int       m_numActiveRefLayers;
@@ -153,5 +148,4 @@
   Int*    getdQPs()                   {return m_aidQP;            }
 #if VPS_EXTN_DIRECT_REF_LAYERS
-#if M0457_PREDICTION_INDICATIONS
   Int     getNumSamplePredRefLayers()    {return m_numSamplePredRefLayers;   }
   Int*    getSamplePredRefLayerIds()     {return m_samplePredRefLayerIds;    }
@@ -160,9 +154,4 @@
   Int*    getMotionPredRefLayerIds()     {return m_motionPredRefLayerIds;    }
   Int     getMotionPredRefLayerId(Int i) {return m_motionPredRefLayerIds[i]; }
-#else
-  Int     getNumDirectRefLayers()     {return m_numDirectRefLayers;}
-  Int*    getRefLayerIds()            {return m_refLayerIds;      }
-  Int     getRefLayerId(Int i)        {return m_refLayerIds[i];   }
-#endif
 
   Int     getNumActiveRefLayers()     {return m_numActiveRefLayers;}
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 547)
+++ trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 588)
@@ -177,4 +177,5 @@
   delete [] mapIdxToLayer;
 #endif
+
   for(UInt layer=0; layer<m_numLayers; layer++)
   {
@@ -190,4 +191,8 @@
     g_bitDepthYLayer[layer] = g_bitDepthY;
     g_bitDepthCLayer[layer] = g_bitDepthC;
+
+#if O0194_WEIGHTED_PREDICTION_CGS
+    m_acTEncTop[layer].setInterLayerWeightedPredFlag( m_useInterLayerWeightedPred );
+#endif
 #endif
     //m_acTEncTop[layer].setVPS(&vps);
@@ -209,18 +214,7 @@
 #if REF_IDX_MFM
 #if AVC_BASE
-#if M0457_PREDICTION_INDICATIONS
     m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
 #else
-    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ));
-#endif
-#else
-#if M0457_PREDICTION_INDICATIONS
     m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) );
-#else
-    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : true);
-#endif
-#endif
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-    m_acTEncTop[layer].setIlSampleOnlyPred( layer == 0 ? 0 : m_ilSampleOnlyPred[layer] );
 #endif
 #endif
@@ -261,5 +255,4 @@
     if(layer)
     {
-#if M0457_PREDICTION_INDICATIONS
       for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++)
       {
@@ -309,27 +302,8 @@
       }
       m_acTEncTop[layer].setNumDirectRefLayers(numDirectRefLayers);
-#else
-      if(m_acLayerCfg[layer].getNumDirectRefLayers() == -1)
-      {
-        // Not included in the configuration file; assume that each layer depends on previous layer
-        m_acTEncTop[layer].setNumDirectRefLayers       (1);      // One ref. layer
-        m_acTEncTop[layer].setRefLayerId               (0, layer - 1);   // Previous layer
-      }
-      else
-      {
-        m_acTEncTop[layer].setNumDirectRefLayers       ( m_acLayerCfg[layer].getNumDirectRefLayers() );
-        for(Int i = 0; i < m_acTEncTop[layer].getNumDirectRefLayers(); i++)
-        {
-          m_acTEncTop[layer].setRefLayerId             ( i, m_acLayerCfg[layer].getRefLayerId(i));
-        }
-      }
-#endif
+
       if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1)
       {
-#if M0457_PREDICTION_INDICATIONS
         m_acTEncTop[layer].setNumActiveRefLayers( m_acTEncTop[layer].getNumDirectRefLayers() );
-#else
-        m_acTEncTop[layer].setNumActiveRefLayers( m_acLayerCfg[layer].getNumDirectRefLayers() );
-#endif
         for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ )
         {
@@ -346,5 +320,5 @@
       }
     }
-#endif
+#endif //VPS_EXTN_DIRECT_REF_LAYERS
     //===== Slice ========
 
@@ -426,5 +400,5 @@
     m_acTEncTop[layer].setWPBiPred                ( m_useWeightedBiPred   );
 #if O0194_WEIGHTED_PREDICTION_CGS
-    if (layer!=0)
+    if( layer != 0 && m_useInterLayerWeightedPred )
     {
       // Enable weighted prediction for enhancement layer
@@ -514,6 +488,6 @@
     m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
     m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
-#if M0043_LAYERS_PRESENT_SEI
-    m_acTEncTop[layer].setLayersPresentSEIEnabled( m_layersPresentSEIEnabled );
+#if LAYERS_NOT_PRESENT_SEI
+    m_acTEncTop[layer].setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled );
 #endif
     m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
@@ -828,6 +802,6 @@
   m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
   m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
-#if M0043_LAYERS_PRESENT_SEI
-  m_cTEncTop.setLayersPresentSEIEnabled( m_layersPresentSEIEnabled );
+#if LAYERS_NOT_PRESENT_SEI
+  m_cTEncTop.setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled );
 #endif
   m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
@@ -1171,8 +1145,12 @@
   vps->setNumOutputLayerSets(vps->getNumLayerSets());
   vps->setNumProfileTierLevel(vps->getNumLayerSets());
+#if P0295_DEFAULT_OUT_LAYER_IDC
+  vps->setDefaultTargetOutputLayerIdc(1);
+#else
 #if O0109_DEFAULT_ONE_OUT_LAYER_IDC
   vps->setDefaultOneTargetOutputLayerIdc(1);
 #else
   vps->setDefaultOneTargetOutputLayerFlag(true);
+#endif
 #endif
   for(i = 1; i < vps->getNumLayerSets(); i++)
@@ -1199,52 +1177,47 @@
   vps->deriveLayerIdListVariables();
 #endif
+#if RESOLUTION_BASED_DPB
+  vps->assignSubDpbIndices();
+#else
   vps->deriveNumberOfSubDpbs();
+#endif
   // Initialize dpb_size_table() for all ouput layer sets in the VPS extension
   for(i = 1; i < vps->getNumOutputLayerSets(); i++)
   {
+#if CHANGE_NUMSUBDPB_IDX
+    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
+#endif
     Int layerSetId = vps->getOutputLayerSetIdx(i);
 
-    // For each output layer set, set the DPB size for each layer and the reorder/latency value the maximum for all layers
-    Bool checkFlagOuter = false;      // Used to calculate sub_layer_flag_info_present_flag
-    Bool checkFlagInner[MAX_TLAYER];  // Used to calculate sub_layer_dpb_info_present_flag
-
     for(Int j = 0; j < vps->getMaxTLayers(); j++)
     {
 
       Int maxNumReorderPics = -1;
+#if CHANGE_NUMSUBDPB_IDX
+#if RESOLUTION_BASED_DPB
+      for(Int k = 0; k < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); k++)
+#else
+      for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
+#endif
+#else
       for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
+#endif
       {
         Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set
+#if RESOLUTION_BASED_DPB
+        vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 );
+        // Add sub-DPB sizes of layers belonging to a sub-DPB. If a different sub-DPB size is calculated
+        // at the encoder, modify below
+        Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j );
+        oldValue += vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j );
+        vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue );
+#else
         vps->setMaxVpsDecPicBufferingMinus1( i, k, j,  m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 );
+#endif
         maxNumReorderPics       = std::max( maxNumReorderPics, m_acTEncTop[layerId].getNumReorderPics(j));
       }
       vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics);
-      
-      if( j == 0 )  // checkFlagInner[0] is always 1
-      {
-        checkFlagInner[j] = true;     // Always signal sub-layer DPB information for the first sub-layer
-      }
-      else
-      {
-        checkFlagInner[j] = false;    // Initialize to be false. If the values of the current sub-layers matches with the earlier sub-layer, 
-                                      // then will be continue to be false - i.e. the j-th sub-layer DPB info is not signaled
-        checkFlagInner[j] |= ( maxNumReorderPics != vps->getMaxVpsNumReorderPics(i, j - 1) );
-        for(Int k = 0; k < vps->getNumSubDpbs(i) && !checkFlagInner[j]; k++)  // If checkFlagInner[j] is true, break and signal the values
-        {
-          checkFlagInner[j] |= ( vps->getMaxVpsDecPicBufferingMinus1(i, k, j - 1) != vps->getMaxVpsDecPicBufferingMinus1(i, k, j) );
-        }
-      }
-      // If checkFlagInner[j] = true, then some value needs to be signalled for the j-th sub-layer
-      vps->setSubLayerDpbInfoPresentFlag( i, j, checkFlagInner[j] );
-    }
-    for(Int j = 1; j < vps->getMaxTLayers(); j++) // Check if DPB info of any of non-zero sub-layers is signaled. If so set flag to one
-    {
-      if( vps->getSubLayerDpbInfoPresentFlag(i, j) )
-      {
-        checkFlagOuter = true;
-        break;
-      }
-    }
-    vps->setSubLayerFlagInfoPresentFlag( i, checkFlagOuter );
+      vps->determineSubDpbInfoFlags();
+    }
   }
 #endif
@@ -1274,5 +1247,5 @@
       vps->setDirectDependencyFlag( layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true);
     }
-#if M0457_PREDICTION_INDICATIONS
+    // prediction indications
     vps->setDirectDepTypeLen(2); // sample and motion types are encoded
     for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
@@ -1301,5 +1274,4 @@
       }
     }
-#endif
   }
 
@@ -1318,7 +1290,5 @@
 #endif
 #endif
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
     vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true);
-#endif
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
     for(i = 1; i< vps->getMaxLayers(); i++)
@@ -1361,8 +1331,10 @@
   vps->setHigherLayerIrapSkipFlag(m_skipPictureAtArcSwitch);
 #endif
+#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
 #if !VPS_EXTN_OFFSET_CALC
 #if VPS_EXTN_OFFSET
   // to be updated according to the current semantics
   vps->setExtensionOffset( 0xffff );
+#endif
 #endif
 #endif
@@ -1653,4 +1625,15 @@
     if(iTotalNumEncoded)
     {
+#if P0130_EOB
+      if( bEos )
+      {
+        OutputNALUnit nalu(NAL_UNIT_EOB);
+        nalu.m_layerId = 0;
+
+        AccessUnit& accessUnit = outputAccessUnits.back();
+        nalu.m_temporalId = accessUnit.front()->m_temporalId;
+        accessUnit.push_back(new NALUnitEBSP(nalu));
+      }
+#endif
       xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits);
       outputAccessUnits.clear();
Index: trunk/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/CommonDef.h	(revision 547)
+++ trunk/source/Lib/TLibCommon/CommonDef.h	(revision 588)
@@ -57,5 +57,5 @@
 #if SVC_EXTENSION
 #include <vector>
-#define NV_VERSION        "4.1"                 ///< Current software version
+#define NV_VERSION        "5.0 (HM-12.1)"                 ///< Current software version
 #else
 #define NV_VERSION        "12.1"                ///< Current software version
@@ -284,5 +284,5 @@
 {
   Int m_targetLayerId;
-  Int m_outputLayerSetIdx;
+  Int m_targetOutputLayerSetIdx;
   std::vector<Int> *m_targetDecLayerIdSet; 
   Bool m_valueCheckedFlag;
@@ -290,5 +290,5 @@
   CommonDecoderParams(): 
     m_targetLayerId(0)
-    , m_outputLayerSetIdx(-1)
+    , m_targetOutputLayerSetIdx(-1)
     , m_targetDecLayerIdSet(NULL)
     , m_valueCheckedFlag(false)
@@ -298,6 +298,6 @@
   Int  getTargetLayerId()            { return m_targetLayerId;}
   
-  Void setOutputLayerSetIdx(const Int x) { m_outputLayerSetIdx = x;   }
-  Int  getOutputLayerSetIdx()            { return m_outputLayerSetIdx;}
+  Void setTargetOutputLayerSetIdx(const Int x) { m_targetOutputLayerSetIdx = x;   }
+  Int  getTargetOutputLayerSetIdx()            { return m_targetOutputLayerSetIdx;}
 
   Void               setTargetDecLayerIdSet(std::vector<Int> *x) { m_targetDecLayerIdSet = x;   }
Index: trunk/source/Lib/TLibCommon/SEI.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/SEI.cpp	(revision 547)
+++ trunk/source/Lib/TLibCommon/SEI.cpp	(revision 588)
@@ -41,4 +41,17 @@
 //Table D-7 Meaning of camera iso sensitivity indicator and exposure index rating indicator
 Int  Table_exp_indicator[32] = {0, 10, 12, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, -1};
+
+#if SUB_BITSTREAM_PROPERTY_SEI
+SEISubBitstreamProperty::SEISubBitstreamProperty()
+{
+  m_activeVpsId             = -1;
+  m_numAdditionalSubStreams = 0;
+  ::memset(m_subBitstreamMode       , 0, sizeof(m_subBitstreamMode));
+  ::memset(m_outputLayerSetIdxToVps , 0, sizeof(m_outputLayerSetIdxToVps));
+  ::memset(m_highestSublayerId      , 0, sizeof(m_highestSublayerId));
+  ::memset(m_avgBitRate             , 0, sizeof(m_avgBitRate));
+  ::memset(m_maxBitRate             , 0, sizeof(m_maxBitRate));
+}
+#endif
 
 SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
Index: trunk/source/Lib/TLibCommon/SEI.h
===================================================================
--- trunk/source/Lib/TLibCommon/SEI.h	(revision 547)
+++ trunk/source/Lib/TLibCommon/SEI.h	(revision 588)
@@ -72,9 +72,12 @@
     SCALABLE_NESTING                     = 133,
     REGION_REFRESH_INFO                  = 134,
-#if M0043_LAYERS_PRESENT_SEI
-    LAYERS_PRESENT                       = 137,
+#if LAYERS_NOT_PRESENT_SEI
+    LAYERS_NOT_PRESENT                   = 137,
 #endif
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     INTER_LAYER_CONSTRAINED_TILE_SETS    = 138
+#endif
+#if SUB_BITSTREAM_PROPERTY_SEI
+   ,SUB_BITSTREAM_PROPERTY               = 139    // Final PayloadType to be defined after finalization
 #endif
   };
@@ -319,16 +322,16 @@
 };
 
-#if M0043_LAYERS_PRESENT_SEI
-class SEILayersPresent : public SEI
-{
-public:
-  PayloadType payloadType() const { return LAYERS_PRESENT; }
-
-  SEILayersPresent() {}
-  virtual ~SEILayersPresent() {}
+#if LAYERS_NOT_PRESENT_SEI
+class SEILayersNotPresent : public SEI
+{
+public:
+  PayloadType payloadType() const { return LAYERS_NOT_PRESENT; }
+
+  SEILayersNotPresent() {}
+  virtual ~SEILayersNotPresent() {}
 
   UInt m_activeVpsId;
   UInt m_vpsMaxLayers;
-  Bool m_layerPresentFlag[MAX_LAYERS];
+  Bool m_layerNotPresentFlag[MAX_LAYERS];
 };
 #endif
@@ -407,4 +410,22 @@
 #endif
 
+#if SUB_BITSTREAM_PROPERTY_SEI
+class SEISubBitstreamProperty : public SEI
+{
+public:
+  PayloadType payloadType() const { return SUB_BITSTREAM_PROPERTY; }
+
+  SEISubBitstreamProperty();
+  virtual ~SEISubBitstreamProperty() {}
+
+  Int  m_activeVpsId;
+  Int  m_numAdditionalSubStreams;
+  Int  m_subBitstreamMode       [MAX_SUB_STREAMS];
+  Int  m_outputLayerSetIdxToVps [MAX_SUB_STREAMS];
+  Int  m_highestSublayerId      [MAX_SUB_STREAMS];
+  Int  m_avgBitRate             [MAX_SUB_STREAMS];
+  Int  m_maxBitRate             [MAX_SUB_STREAMS];
+};
+#endif
 
 typedef std::list<SEI*> SEIMessages;
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 547)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 588)
@@ -3438,17 +3438,5 @@
 
   // use coldir.
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-  TComPic *pColPic;
-  if (m_layerId > 0 && getSlice()->getAltColIndicationFlag())
-  {
-    pColPic = getSlice()->getMotionPredIlp();
-  }
-  else
-  {
-    pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
-  }
-#else
   TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
-#endif
   TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
   if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE)
Index: trunk/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.cpp	(revision 547)
+++ trunk/source/Lib/TLibCommon/TComRom.cpp	(revision 588)
@@ -530,4 +530,45 @@
 Int g_mvScalingFactor  [MAX_LAYERS][2] = {{0,0}, {0,0}};
 Int g_posScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}};
+
+std::string NaluToStr( NalUnitType nalu )
+{
+  switch( nalu )
+  {
+  case NAL_UNIT_CODED_SLICE_TRAIL_N:
+  case NAL_UNIT_CODED_SLICE_TRAIL_R:
+    return "TRAIL";
+  
+  case NAL_UNIT_CODED_SLICE_TSA_N:
+  case NAL_UNIT_CODED_SLICE_TSA_R:
+    return "  TSA";
+  
+  case NAL_UNIT_CODED_SLICE_STSA_N:
+  case NAL_UNIT_CODED_SLICE_STSA_R:
+    return " STSA";
+
+  case NAL_UNIT_CODED_SLICE_RADL_N:
+  case NAL_UNIT_CODED_SLICE_RADL_R:
+    return " RADL";
+  
+  case NAL_UNIT_CODED_SLICE_RASL_N:
+  case NAL_UNIT_CODED_SLICE_RASL_R:
+    return " RASL";
+
+  case NAL_UNIT_CODED_SLICE_BLA_W_LP:
+  case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
+  case NAL_UNIT_CODED_SLICE_BLA_N_LP:
+    return "  BLA";
+
+  case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
+  case NAL_UNIT_CODED_SLICE_IDR_N_LP:
+    return "  IDR";
+  
+  case NAL_UNIT_CODED_SLICE_CRA:
+    return "  CRA";
+
+  default:
+    return "     ";
+  };
+}
 #endif
 
Index: trunk/source/Lib/TLibCommon/TComRom.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.h	(revision 547)
+++ trunk/source/Lib/TLibCommon/TComRom.h	(revision 588)
@@ -288,5 +288,6 @@
 #if SVC_EXTENSION
 extern Int g_mvScalingFactor  [MAX_LAYERS][2];
-extern Int g_posScalingFactor [MAX_LAYERS][2]; 
+extern Int g_posScalingFactor [MAX_LAYERS][2];
+std::string NaluToStr( NalUnitType nalu );
 #endif
 
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 547)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 588)
@@ -117,19 +117,7 @@
 #if SVC_EXTENSION
   memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) );
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
   m_activeNumILRRefIdx        = 0; 
   m_interLayerPredEnabledFlag = 0;
   ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) );
-#else
-  m_numILRRefIdx = 0;
-#endif 
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-  m_altColIndicationFlag = false;
-  m_colRefLayerIdx       = 0;
-#endif
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  m_numSamplePredRefLayers       = 0;
-  m_interLayerSamplePredOnlyFlag = false;
-#endif
 #endif //SVC_EXTENSION
 
@@ -175,14 +163,6 @@
 #if SVC_EXTENSION
   m_layerId = layerId;
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
   m_activeNumILRRefIdx        = 0;
   m_interLayerPredEnabledFlag = 0;
-#else
-  m_numILRRefIdx              = 0;
-#endif
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  m_numSamplePredRefLayers       = 0;
-  m_interLayerSamplePredOnlyFlag = false;
-#endif
 #endif
   m_aiNumRefIdx[0]      = 0;
@@ -410,7 +390,4 @@
       pcRefPic->getPicYuvRec()->extendPicBorder();
       RefPicSetStCurr0[NumPocStCurr0] = pcRefPic;
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-      if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) 
-#endif
       NumPocStCurr0++;
       pcRefPic->setCheckLTMSBPresent(false);  
@@ -426,7 +403,4 @@
       pcRefPic->getPicYuvRec()->extendPicBorder();
       RefPicSetStCurr1[NumPocStCurr1] = pcRefPic;
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-      if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) 
-#endif
       NumPocStCurr1++;
       pcRefPic->setCheckLTMSBPresent(false);  
@@ -442,7 +416,4 @@
       pcRefPic->getPicYuvRec()->extendPicBorder();
       RefPicSetLtCurr[NumPocLtCurr] = pcRefPic;
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-      if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) 
-#endif
       NumPocLtCurr++;
     }
@@ -470,9 +441,5 @@
     {
 #if REF_IDX_MFM
-#if M0457_COL_PICTURE_SIGNALING
       if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && getMFMEnabledFlag())
-#else
-      if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && m_pcSPS->getMFMEnabledFlag())
-#endif
       { 
         ilpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] );
@@ -508,7 +475,9 @@
       {
         numInterLayerRPSPics++;
-      }
-    }
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
+#if DISCARDABLE_PIC_RPS
+        assert( ilpPic[i]->getSlice(0)->getDiscardableFlag() == 0 );    // Inter-layer RPS shall not contain picture with discardable_flag = 1.
+#endif
+      }
+    }
     if (numInterLayerRPSPics < m_activeNumILRRefIdx)
     {
@@ -589,17 +558,7 @@
 #endif
     }
-#endif 
-#else
-    if (numInterLayerRPSPics < m_numILRRefIdx)
-    {
-      m_numILRRefIdx = numInterLayerRPSPics;
-    }
-#endif
-  }
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
+#endif
+  }
   Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_activeNumILRRefIdx;
-#else
-  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_numILRRefIdx;
-#endif 
 #else //SVC_EXTENSION
   Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
@@ -609,5 +568,5 @@
   {
     // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr:
-#if ILP_RAP    // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0
+#if SVC_EXTENSION    // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0
     // – If the current picture is a BLA or CRA picture with nuh_layer_id equal to 0, the value of NumPocTotalCurr shall be equal to 0.
     // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
@@ -623,25 +582,17 @@
 
     if (m_eSliceType == I_SLICE)
-  {
+    {
       ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
       ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
-      
+
       return;
     }
-    
+
     assert(numPocTotalCurr > 0);
-    
+
     m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
     m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
   }
 
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-    if( m_interLayerSamplePredOnlyFlag && getLayerId() ) 
-    {
-      m_aiNumRefIdx[0] = m_aiNumRefIdx[0] > m_activeNumILRRefIdx ? m_activeNumILRRefIdx : m_aiNumRefIdx[0];
-      m_aiNumRefIdx[1] = m_aiNumRefIdx[1] > m_activeNumILRRefIdx ? m_activeNumILRRefIdx : m_aiNumRefIdx[1];
-    }
-#endif
- 
     Int cIdx = 0;
     for ( i=0; i<NumPocStCurr0; i++, cIdx++)
@@ -653,9 +604,5 @@
     if( m_layerId > 0 )
     {      
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
       for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)      
-#else
-      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
-#endif 
       {
         Int refLayerIdc = m_interLayerPredLayerIdc[i];
@@ -685,9 +632,5 @@
     if( m_layerId > 0 )
     {
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
       for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)      
-#else
-      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
-#endif 
       {
         Int refLayerIdc = m_interLayerPredLayerIdc[i];
@@ -726,9 +669,5 @@
     if( m_layerId > 0 )
     {
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
       for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
-#else
-      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
-#endif 
       {
         Int refLayerIdc = m_interLayerPredLayerIdc[i];
@@ -832,9 +771,5 @@
     else
     {
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
       for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
-#else
-      for(Int i = m_numILRRefIdx; i > 0; i-- )
-#endif 
       {
 #if RPL_INIT_N0316_N0082
@@ -881,9 +816,5 @@
     else
     {
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
       for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
-#else
-      for(Int i = m_numILRRefIdx; i > 0; i-- )
-#endif 
       {
         refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i);
@@ -927,9 +858,5 @@
   {
 #if SVC_EXTENSION
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
     return m_activeNumILRRefIdx;
-#else
-    return getNumILRRefIdx();
-#endif 
 #else
     return 0;
@@ -946,9 +873,5 @@
   if( m_layerId > 0 )
   {
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
     numRpsCurrTempList += m_activeNumILRRefIdx;
-#else
-    numRpsCurrTempList += getNumILRRefIdx();
-#endif
 }
 #endif
@@ -1179,9 +1102,7 @@
   m_pcVPS                = pSrc->m_pcVPS;
   m_layerId              = pSrc->m_layerId;
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
   m_activeNumILRRefIdx         = pSrc->m_activeNumILRRefIdx;
   m_interLayerPredEnabledFlag  = pSrc->m_interLayerPredEnabledFlag;
   memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) );
-#endif
 #endif
   m_pcSPS                = pSrc->m_pcSPS;
@@ -1508,4 +1429,10 @@
 
     }
+#if DISCARDABLE_PIC_RPS
+    if( isReference ) // Current picture is in the temporal RPS
+    {
+      assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1
+    }
+#endif
     // mark the picture as "unused for reference" if it is not in
     // the Reference Picture Set
@@ -2010,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
 
@@ -2036,10 +1974,16 @@
 #endif
 , m_numProfileTierLevel       (0)
+#if !VPS_EXTN_UEV_CODING
 , m_moreOutputLayerSetsThanDefaultFlag (false)
+#endif
 , m_numAddOutputLayerSets     (0)
+#if P0295_DEFAULT_OUT_LAYER_IDC
+, m_defaultTargetOutputLayerIdc     (0)
+#else
 #if O0109_DEFAULT_ONE_OUT_LAYER_IDC
 , m_defaultOneTargetOutputLayerIdc     (0)
 #else
 , m_defaultOneTargetOutputLayerFlag    (false)
+#endif
 #endif
 #if VPS_VUI_BITRATE_PICRATE
@@ -2058,6 +2002,11 @@
 #endif
 #endif
+#if !P0307_REMOVE_VPS_VUI_OFFSET
 #if VPS_VUI_OFFSET
 , m_vpsVuiOffset (0)
+#endif
+#endif
+#if P0307_VPS_NON_VUI_EXTENSION
+, m_vpsNonVuiExtLength (0)
 #endif
 {
@@ -2082,5 +2031,7 @@
 #if VPS_EXTN_PROFILE_INFO
   ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag));
+#if !P0048_REMOVE_PROFILE_REF
   ::memset(m_profileLayerSetRef, 0, sizeof(m_profileLayerSetRef));
+#endif
 #endif
 #if VPS_EXTN_OP_LAYER_SETS
@@ -2094,8 +2045,6 @@
   ::memset(m_numDirectRefLayers,   0, sizeof(m_numDirectRefLayers  ));
   ::memset(m_refLayerId,           0, sizeof(m_refLayerId          ));
-#if M0457_PREDICTION_INDICATIONS
   m_directDepTypeLen = 2;
   ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType));
-#endif
 #endif
 #if DERIVE_LAYER_ID_LIST_VARIABLES
@@ -2104,7 +2053,5 @@
 #endif
   ::memset(m_profileLevelTierIdx,  0, sizeof(m_profileLevelTierIdx));
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
   m_maxOneActiveRefLayerFlag = true;
-#endif
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
   ::memset(m_pocLsbNotPresentFlag, 0, sizeof(m_pocLsbNotPresentFlag));
@@ -2116,5 +2063,4 @@
   m_crossLayerIrapAlignFlag = true;
 #endif 
-#if JCTVC_M0203_INTERLAYER_PRED_IDC
 #if N0120_MAX_TID_REF_PRESENT_FLAG
   m_maxTidRefPresentFlag = true;
@@ -2123,44 +2069,43 @@
   {
 #if O0225_MAX_TID_FOR_REF_LAYERS
-  for( Int j = 0; j < MAX_VPS_LAYER_ID_PLUS1; j++)
-  {
-    m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1;
-  }
+    for( Int j = 0; j < MAX_VPS_LAYER_ID_PLUS1; j++)
+    {
+      m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1;
+    }
 #else
     m_maxTidIlRefPicsPlus1[i] = m_uiMaxTLayers + 1;
 #endif 
   }
-#endif
 #if VPS_VUI_TILES_NOT_IN_USE__FLAG
-   m_tilesNotInUseFlag = true;
-   ::memset(m_tilesInUseFlag,  0, sizeof(m_tilesInUseFlag));
-   ::memset(m_loopFilterNotAcrossTilesFlag,  0, sizeof(m_loopFilterNotAcrossTilesFlag));
+  m_tilesNotInUseFlag = true;
+  ::memset(m_tilesInUseFlag,  0, sizeof(m_tilesInUseFlag));
+  ::memset(m_loopFilterNotAcrossTilesFlag,  0, sizeof(m_loopFilterNotAcrossTilesFlag));
 #endif
 #if TILE_BOUNDARY_ALIGNED_FLAG
-   ::memset(m_tileBoundariesAlignedFlag,  0, sizeof(m_tileBoundariesAlignedFlag));
+  ::memset(m_tileBoundariesAlignedFlag,  0, sizeof(m_tileBoundariesAlignedFlag));
 #endif 
 #if VPS_VUI_WPP_NOT_IN_USE__FLAG
-   m_wppNotInUseFlag = true;
-   ::memset(m_wppInUseFlag,  0, sizeof(m_wppInUseFlag));
+  m_wppNotInUseFlag = true;
+  ::memset(m_wppInUseFlag,  0, sizeof(m_wppInUseFlag));
 #endif
 #if N0160_VUI_EXT_ILP_REF
-   m_numIlpRestrictedRefLayers = false;
-   ::memset(m_minSpatialSegmentOffsetPlus1,  0, sizeof(m_minSpatialSegmentOffsetPlus1));
-   ::memset(m_ctuBasedOffsetEnabledFlag,     0, sizeof(m_ctuBasedOffsetEnabledFlag));
-   ::memset(m_minHorizontalCtuOffsetPlus1,   0, sizeof(m_minHorizontalCtuOffsetPlus1));
+  m_ilpRestrictedRefLayersFlag = false;
+  ::memset(m_minSpatialSegmentOffsetPlus1,  0, sizeof(m_minSpatialSegmentOffsetPlus1));
+  ::memset(m_ctuBasedOffsetEnabledFlag,     0, sizeof(m_ctuBasedOffsetEnabledFlag));
+  ::memset(m_minHorizontalCtuOffsetPlus1,   0, sizeof(m_minHorizontalCtuOffsetPlus1));
 #endif
 #if VPS_VUI_VIDEO_SIGNAL
-    m_vidSigPresentVpsFlag=true;
-    m_vpsVidSigInfo=1;
-    ::memset( m_vpsVidSigIdx, 0, sizeof(m_vpsVidSigIdx) );
-    m_vpsVidSigIdx[0]=0;
-    for (Int i=0; i < 16; i++)
-    {
-      m_vpsVidFormat[i] = 5;
-      m_vpsFullRangeFlag[i] = false;
-      m_vpsColorPrimaries[i] = 2;
-      m_vpsTransChar[i] = 2;
-      m_vpsMatCoeff[i] = 2;
-    }
+  m_vidSigPresentVpsFlag=true;
+  m_vpsVidSigInfo=1;
+  ::memset( m_vpsVidSigIdx, 0, sizeof(m_vpsVidSigIdx) );
+  m_vpsVidSigIdx[0]=0;
+  for (Int i=0; i < 16; i++)
+  {
+    m_vpsVidFormat[i] = 5;
+    m_vpsFullRangeFlag[i] = false;
+    m_vpsColorPrimaries[i] = 2;
+    m_vpsTransChar[i] = 2;
+    m_vpsMatCoeff[i] = 2;
+  }
 #endif
 #if VPS_VUI_BITRATE_PICRATE  
@@ -2192,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 )  );
@@ -2248,8 +2196,18 @@
 }
 #endif
+#if !RESOLUTION_BASED_DPB
 #if VPS_DPB_SIZE_TABLE
 Void TComVPS::deriveNumberOfSubDpbs()
 {
   // Derive number of sub-DPBs
+#if CHANGE_NUMSUBDPB_IDX
+  // For layer set 0
+  setNumSubDpbs(0, 1);
+  // For other layer sets
+  for( Int i = 1; i < getNumLayerSets(); i++)
+  {
+    setNumSubDpbs( i, getNumLayersInIdList( i ) );
+  }
+#else
   // For output layer set 0
   setNumSubDpbs(0, 1);
@@ -2259,5 +2217,7 @@
     setNumSubDpbs( i, getNumLayersInIdList( getOutputLayerSetIdx(i)) );
   }
-}
+#endif
+}
+#endif
 #endif
 #if VPS_VUI_TILES_NOT_IN_USE__FLAG
@@ -2358,4 +2318,159 @@
 
   return scalIdx; 
+}
+#endif
+#if VPS_DPB_SIZE_TABLE
+Void TComVPS::determineSubDpbInfoFlags()
+{
+  for(Int i = 1; i < getNumOutputLayerSets(); i++)
+  {
+    Int layerSetIdxForOutputLayerSet = getOutputLayerSetIdx( i );
+    // For each output layer set, set the DPB size for each layer and the reorder/latency value the maximum for all layers
+    Bool checkFlagOuter = false;      // Used to calculate sub_layer_flag_info_present_flag
+    Bool checkFlagInner[MAX_TLAYER];  // Used to calculate sub_layer_dpb_info_present_flag
+
+    for(Int j = 0; j < getMaxTLayers(); j++)
+    {
+      // --------------------------------------------------------
+      // To determine value of m_subLayerDpbInfoPresentFlag
+      // --------------------------------------------------------
+      if( j == 0 )  // checkFlagInner[0] is always 1
+      {
+        checkFlagInner[j] = true;     // Always signal sub-layer DPB information for the first sub-layer
+      }
+      else
+      {
+        checkFlagInner[j] = false;    // Initialize to be false. If the values of the current sub-layers matches with the earlier sub-layer, 
+                                      // then will be continue to be false - i.e. the j-th sub-layer DPB info is not signaled
+        checkFlagInner[j] |= ( getMaxVpsNumReorderPics(i, j) != getMaxVpsNumReorderPics(i, j - 1) );
+#if CHANGE_NUMSUBDPB_IDX
+        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, 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
+      setSubLayerDpbInfoPresentFlag( i, j, checkFlagInner[j] );
+    }
+
+    // --------------------------------------------------------
+    // To determine value of m_subLayerFlagInfoPresentFlag
+    // --------------------------------------------------------
+
+    for(Int j = 1; j < getMaxTLayers(); j++) // Check if DPB info of any of non-zero sub-layers is signaled. If so set flag to one
+    {
+      if( getSubLayerDpbInfoPresentFlag(i, j) )
+      {
+        checkFlagOuter = true;
+        break;
+      }
+    }
+    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
@@ -2404,8 +2519,4 @@
 , m_vuiParameters             ()
 #if SVC_EXTENSION
-#if M0463_VUI_EXT_ILP_REF
-, m_interViewMvVertConstraintFlag (false)
-, m_numIlpRestrictedRefLayers ( 0 )
-#endif
 , m_layerId                   ( 0 )
 , m_numScaledRefLayerOffsets  ( 0 )
@@ -2431,12 +2542,4 @@
   ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps));
   ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag));
-#if M0463_VUI_EXT_ILP_REF
-  for (Int i = 0; i < MAX_LAYERS; i++ )
-  {
-    m_minSpatialSegmentOffsetPlus1[ i ] = 0;
-    m_ctuBasedOffsetEnabledFlag   [ i ] = false;
-    m_minHorizontalCtuOffsetPlus1 [ i ] = 0;
-  }
-#endif
 }
 
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 547)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 588)
@@ -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; }
@@ -483,6 +487,8 @@
   Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1];
 #endif
+#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
 #if VPS_EXTN_OFFSET
   UInt        m_extensionOffset;
+#endif
 #endif
 #if VPS_RENAME
@@ -514,5 +520,7 @@
   // Profile-tier-level signalling related
   Bool       m_profilePresentFlag[MAX_VPS_LAYER_SETS_PLUS1];    // The value with index 0 will not be used.
+#if !P0048_REMOVE_PROFILE_REF
   UInt       m_profileLayerSetRef[MAX_VPS_LAYER_SETS_PLUS1];    // The value with index 0 will not be used.
+#endif
   std::vector<TComPTL>    m_pcPTLForExtn;  
 #endif
@@ -528,5 +536,4 @@
   UInt       m_numDirectRefLayers[MAX_VPS_LAYER_ID_PLUS1];
   UInt       m_refLayerId[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
-#if M0457_PREDICTION_INDICATIONS
   UInt       m_directDepTypeLen;
 #if O0096_DEFAULT_DEPENDENCY_TYPE
@@ -536,8 +543,12 @@
   UInt       m_directDependencyType[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
 #endif
-#endif
   UInt       m_numProfileTierLevel;
+#if !VPS_EXTN_UEV_CODING
   Bool       m_moreOutputLayerSetsThanDefaultFlag;
+#endif
   Int        m_numAddOutputLayerSets;
+#if P0295_DEFAULT_OUT_LAYER_IDC
+  UInt       m_defaultTargetOutputLayerIdc;
+#else
 #if O0109_DEFAULT_ONE_OUT_LAYER_IDC
   UInt       m_defaultOneTargetOutputLayerIdc;
@@ -545,8 +556,7 @@
   Bool       m_defaultOneTargetOutputLayerFlag;
 #endif
+#endif
   Int        m_profileLevelTierIdx[64];     
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
   Bool       m_maxOneActiveRefLayerFlag;
-#endif
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
   Bool       m_pocLsbNotPresentFlag[MAX_VPS_LAYER_ID_PLUS1];
@@ -558,10 +568,8 @@
   Bool       m_crossLayerIrapAlignFlag;
 #endif
-#if JCTVC_M0203_INTERLAYER_PRED_IDC
 #if O0225_MAX_TID_FOR_REF_LAYERS
   UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1][MAX_VPS_LAYER_ID_PLUS1];
 #else
   UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
-#endif
 #endif
 #if N0120_MAX_TID_REF_PRESENT_FLAG
@@ -591,5 +599,5 @@
 #endif 
 #if N0160_VUI_EXT_ILP_REF    
-  Bool        m_numIlpRestrictedRefLayers;
+  Bool        m_ilpRestrictedRefLayersFlag;
   Int         m_minSpatialSegmentOffsetPlus1[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
   Bool        m_ctuBasedOffsetEnabledFlag   [MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
@@ -597,12 +605,12 @@
 #endif 
 #if VPS_VUI_VIDEO_SIGNAL
-    Bool        m_vidSigPresentVpsFlag;
-    Int         m_vpsVidSigInfo;
-    Int         m_vpsVidSigIdx[MAX_VPS_LAYER_ID_PLUS1];
-    Int         m_vpsVidFormat[16];
-    Bool        m_vpsFullRangeFlag[16];
-    Int         m_vpsColorPrimaries[16];
-    Int         m_vpsTransChar[16];
-    Int         m_vpsMatCoeff[16];
+  Bool        m_vidSigPresentVpsFlag;
+  Int         m_vpsVidSigInfo;
+  Int         m_vpsVidSigIdx[MAX_VPS_LAYER_ID_PLUS1];
+  Int         m_vpsVidFormat[16];
+  Bool        m_vpsFullRangeFlag[16];
+  Int         m_vpsColorPrimaries[16];
+  Int         m_vpsTransChar[16];
+  Int         m_vpsMatCoeff[16];
 #endif 
 #if VPS_VUI_BITRATE_PICRATE
@@ -646,7 +654,14 @@
   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];
+#if CHANGE_NUMSUBDPB_IDX
+  Int     m_numSubDpbs                  [MAX_VPS_LAYER_SETS_PLUS1];
+#else
   Int     m_numSubDpbs                  [MAX_VPS_OP_LAYER_SETS_PLUS1];
+#endif
 #endif
 
@@ -655,8 +670,16 @@
 #endif
 
-#endif //SVC_EXTENSION
+#if !P0307_REMOVE_VPS_VUI_OFFSET
 #if VPS_VUI_OFFSET
   Int     m_vpsVuiOffset;
 #endif
+#endif
+#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
 public:
   TComVPS();
@@ -777,6 +800,8 @@
   Void   setProfilePresentFlag(Int id, Bool x)                  { m_profilePresentFlag[id] = x;    }
 
+#if !P0048_REMOVE_PROFILE_REF
   UInt   getProfileLayerSetRef(Int id)                          { return m_profileLayerSetRef[id]; }
   Void   setProfileLayerSetRef(Int id, Bool x)                  { m_profileLayerSetRef[id] = x;    }
+#endif
 
   std::vector<TComPTL>* getPTLForExtnPtr()                      { return &m_pcPTLForExtn;          }
@@ -805,5 +830,4 @@
   Void   setRefLayerId(Int layerId, Int refLayerIdx, UInt refLayerId)           { m_refLayerId[layerId][refLayerIdx] = refLayerId;        }
 
-#if M0457_PREDICTION_INDICATIONS
   UInt   getDirectDepTypeLen()                                                  { return m_directDepTypeLen;                              }
   Void   setDirectDepTypeLen(UInt x)                                            { m_directDepTypeLen = x;                                 }
@@ -817,14 +841,19 @@
   Void   setDirectDependencyType(Int currLayerId, Int refLayerId, UInt x)       { m_directDependencyType[currLayerId][refLayerId] = x;    }
 #endif
-#endif
   UInt   getNumProfileTierLevel()                                { return m_numProfileTierLevel; }
   Void   setNumProfileTierLevel(Int x)                           { m_numProfileTierLevel = x;    }
 
+#if !VPS_EXTN_UEV_CODING
   Bool   getMoreOutputLayerSetsThanDefaultFlag()                 { return m_moreOutputLayerSetsThanDefaultFlag;}
   Void   setMoreOutputLayerSetsThanDefaultFlag(Bool x)           { m_moreOutputLayerSetsThanDefaultFlag = x   ;}
+#endif
 
   Int    getNumAddOutputLayerSets()                              { return m_numAddOutputLayerSets; }
   Void   setNumAddOutputLayerSets(Int x)                         { m_numAddOutputLayerSets = x   ; }
 
+#if P0295_DEFAULT_OUT_LAYER_IDC
+  UInt   getDefaultTargetOutputLayerIdc()                 { return m_defaultTargetOutputLayerIdc;}
+  Void   setDefaultTargetOutputLayerIdc(UInt x)           { m_defaultTargetOutputLayerIdc = x    ;}
+#else
 #if O0109_DEFAULT_ONE_OUT_LAYER_IDC
   UInt   getDefaultOneTargetOutputLayerIdc()                 { return m_defaultOneTargetOutputLayerIdc;}
@@ -834,10 +863,9 @@
   Void   setDefaultOneTargetOutputLayerFlag(Bool x)           { m_defaultOneTargetOutputLayerFlag= x    ;}
 #endif
+#endif
   Int    getProfileLevelTierIdx(Int i)                        { return m_profileLevelTierIdx[i]; }
   Void   setProfileLevelTierIdx(Int i, Int x)                 { m_profileLevelTierIdx[i] = x   ; }
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
   Bool   getMaxOneActiveRefLayerFlag()                                          { return m_maxOneActiveRefLayerFlag;                      }
   Void   setMaxOneActiveRefLayerFlag(Bool x)                                    { m_maxOneActiveRefLayerFlag = x;                         }
-#endif
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
   UInt   getPocLsbNotPresentFlag(Int i)                                         { return m_pocLsbNotPresentFlag[i]; }
@@ -852,5 +880,4 @@
   Void   setCrossLayerIrapAlignFlag(Bool x)                                     { m_crossLayerIrapAlignFlag = x;                         }
 #endif 
-#if JCTVC_M0203_INTERLAYER_PRED_IDC
 #if O0225_MAX_TID_FOR_REF_LAYERS
   UInt   getMaxTidIlRefPicsPlus1(Int layerId, Int refLayerId)                     { return m_maxTidIlRefPicsPlus1[layerId][refLayerId];           }
@@ -859,5 +886,4 @@
   UInt   getMaxTidIlRefPicsPlus1(Int layerId)                     { return m_maxTidIlRefPicsPlus1[layerId];                   }
   Void   setMaxTidIlRefPicsPlus1(Int layerId, UInt maxSublayer)   { m_maxTidIlRefPicsPlus1[layerId] = maxSublayer;            }
-#endif
 #endif
 #if N0120_MAX_TID_REF_PRESENT_FLAG
@@ -898,6 +924,6 @@
 #endif 
 #if N0160_VUI_EXT_ILP_REF  
-  Bool  getNumIlpRestrictedRefLayers   ( )                                         { return m_numIlpRestrictedRefLayers        ;}
-  Void  setNumIlpRestrictedRefLayers   ( Int val )                                 { m_numIlpRestrictedRefLayers         = val;}
+  Bool  getIlpRestrictedRefLayersFlag   ( )                                        { return m_ilpRestrictedRefLayersFlag        ;}
+  Void  setIlpRestrictedRefLayersFlag   ( Int val )                                { m_ilpRestrictedRefLayersFlag         = val;}
   
   Int  getMinSpatialSegmentOffsetPlus1( Int currLayerId, Int refLayerId )          { return m_minSpatialSegmentOffsetPlus1[currLayerId][refLayerId];}
@@ -983,8 +1009,10 @@
   Int     scalTypeToScalIdx( ScalabilityType scalType );
 #endif
+#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
 #if VPS_EXTN_OFFSET
   Int     getExtensionOffset()                 { return m_extensionOffset;   }
   Void    setExtensionOffset( UInt offset )    { m_extensionOffset = offset; }
 #endif
+#endif
 #if O0215_PHASE_ALIGNMENT
   Bool   getPhaseAlignFlag()                             { return m_phaseAlignFlag; }
@@ -1002,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;    }
@@ -1010,4 +1043,5 @@
   Int     getNumSubDpbs(Int i)                          { return m_numSubDpbs[i]; }
   Void    setNumSubDpbs(Int i, Int x)                   { m_numSubDpbs[i] = x;    }
+  Void    determineSubDpbInfoFlags();
 #endif
 
@@ -1017,7 +1051,18 @@
 #endif
 
+#if !P0307_REMOVE_VPS_VUI_OFFSET
 #if VPS_VUI_OFFSET
   Int     getVpsVuiOffset()         { return m_vpsVuiOffset; }
   Void    setVpsVuiOffset(Int x)    { m_vpsVuiOffset = x; }
+#endif
+#endif
+#if P0307_VPS_NON_VUI_EXTENSION
+  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
@@ -1312,19 +1357,5 @@
 
 #if SVC_EXTENSION
-#if M0463_VUI_EXT_ILP_REF
-  Bool        m_interViewMvVertConstraintFlag;
-  Int         m_numIlpRestrictedRefLayers        ;
-  Int         m_minSpatialSegmentOffsetPlus1[MAX_LAYERS];
-  Bool        m_ctuBasedOffsetEnabledFlag   [MAX_LAYERS];
-  Int         m_minHorizontalCtuOffsetPlus1 [MAX_LAYERS];
-#endif
-
   UInt m_layerId;
-
-#if REF_IDX_MFM
-#if !M0457_COL_PICTURE_SIGNALING
-  Bool m_bMFMEnabledFlag;
-#endif
-#endif
   UInt        m_numScaledRefLayerOffsets;
 #if O0098_SCALED_REF_LAYER_ID
@@ -1485,29 +1516,6 @@
 
 #if SVC_EXTENSION
-#if M0463_VUI_EXT_ILP_REF
-  Void setInterViewMvVertConstraintFlag(Bool val) { m_interViewMvVertConstraintFlag = val; }
-  Bool getInterViewMvVertConstraintFlag()         { return m_interViewMvVertConstraintFlag;}
-
-  ////  sps_extension_vui_parameters( )
-  Void setNumIlpRestrictedRefLayers   ( Int val )        { m_numIlpRestrictedRefLayers         = val;}
-  Int  getNumIlpRestrictedRefLayers   ( )                { return m_numIlpRestrictedRefLayers        ;}
-
-  Void setMinSpatialSegmentOffsetPlus1( Int i, Int val ) { m_minSpatialSegmentOffsetPlus1[ i ] = val;}
-  Int  getMinSpatialSegmentOffsetPlus1( Int i )          { return m_minSpatialSegmentOffsetPlus1[ i ];}
-
-  Void setCtuBasedOffsetEnabledFlag   ( Int i, Bool flag ) { m_ctuBasedOffsetEnabledFlag   [ i ] = flag;}
-  Bool getCtuBasedOffsetEnabledFlag   ( Int i )            { return m_ctuBasedOffsetEnabledFlag   [ i ];}
-
-  Void setMinHorizontalCtuOffsetPlus1 ( Int i, Int val )   { m_minHorizontalCtuOffsetPlus1 [ i ] = val;}
-  Int  getMinHorizontalCtuOffsetPlus1 ( Int i )            { return m_minHorizontalCtuOffsetPlus1 [ i ];}
-#endif
   Void     setLayerId(UInt layerId) { m_layerId = layerId; }
   UInt     getLayerId() { return m_layerId; }
-#if REF_IDX_MFM
-#if !M0457_COL_PICTURE_SIGNALING
-  Void     setMFMEnabledFlag(Bool flag) {m_bMFMEnabledFlag = flag;}
-  Bool     getMFMEnabledFlag()          {return m_bMFMEnabledFlag;}
-#endif
-#endif
   UInt     getNumScaledRefLayerOffsets()  { return m_numScaledRefLayerOffsets; }
   Void     setNumScaledRefLayerOffsets(Int x)  { m_numScaledRefLayerOffsets = x; }
@@ -1889,5 +1897,4 @@
   TComPic*    m_pcBaseColPic[MAX_LAYERS];
   TComPicYuv* m_pcFullPelBaseRec[MAX_LAYERS];
-#if M0457_COL_PICTURE_SIGNALING
   Int         m_numMotionPredRefLayers;
 #if REF_IDX_MFM
@@ -1897,19 +1904,8 @@
   TComPic*    m_pcIlpPic;
 #endif
-#endif
-
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
+
   Bool        m_interLayerPredEnabledFlag;
   Int         m_activeNumILRRefIdx;        //< Active inter-layer reference pictures
   Int         m_interLayerPredLayerIdc  [MAX_VPS_LAYER_ID_PLUS1];
-#else
-#if SVC_EXTENSION
-  Int         m_numILRRefIdx;       //< for inter-layer reference picture ser
-#endif
-#endif 
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  Int         m_numSamplePredRefLayers;
-  Bool        m_interLayerSamplePredOnlyFlag;
-#endif
 #if POC_RESET_FLAG
   Bool        m_bPocResetFlag;
@@ -2174,5 +2170,4 @@
 #endif
 
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
   Int       getActiveNumILRRefIdx     ( )               { return  m_activeNumILRRefIdx; }
   Void      setActiveNumILRRefIdx     ( Int i )         { m_activeNumILRRefIdx = i;     }  
@@ -2183,16 +2178,5 @@
   Void      setInterLayerPredEnabledFlag     ( Bool   val )    { m_interLayerPredEnabledFlag = val; }
   Bool      getInterLayerPredEnabledFlag     ()                { return m_interLayerPredEnabledFlag;}
-#else
-  Void      setNumILRRefIdx     ( Int i )               { m_numILRRefIdx = i;     }
-#endif 
-
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  Int       getNumSamplePredRefLayers      ( )          { return  m_numSamplePredRefLayers;       }
-  Void      setNumSamplePredRefLayers      ( Int i )    { m_numSamplePredRefLayers = i;           }
-  Bool      getInterLayerSamplePredOnlyFlag( )          { return  m_interLayerSamplePredOnlyFlag; }
-  Void      setInterLayerSamplePredOnlyFlag( Bool val ) { m_interLayerSamplePredOnlyFlag = val;   }
-#endif
-
-#if M0457_COL_PICTURE_SIGNALING
+
   Void      setNumMotionPredRefLayers(int i)            { m_numMotionPredRefLayers = i; }
   Int       getNumMotionPredRefLayers()                 { return m_numMotionPredRefLayers; }
@@ -2200,21 +2184,10 @@
   Void      setMFMEnabledFlag(Bool flag)                { m_bMFMEnabledFlag = flag; }
   Bool      getMFMEnabledFlag()                         { return m_bMFMEnabledFlag; }
-#if !REMOVE_COL_PICTURE_SIGNALING
-  Void      setColRefLayerIdx(Int i)                    { m_colRefLayerIdx = i;     }
-  Int       getColRefLayerIdx()                         { return m_colRefLayerIdx;  }
-  Void      setAltColIndicationFlag(Bool i)             { m_altColIndicationFlag = i; }
-  Bool      getAltColIndicationFlag()                   { return m_altColIndicationFlag; }
-  Void      setMotionPredIlp(TComPic *ilpPic)           { m_pcIlpPic = ilpPic; }
-  TComPic*  getMotionPredIlp()                          { return m_pcIlpPic; }
-#endif
-#endif
 #endif
 
   TComPic* getRefPic(TComList<TComPic*>& rcListPic, Int poc) { return xGetRefPic( rcListPic, poc ); } 
 
-#if RESTR_CHK
-  Bool     isRADL() {  return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); }
-  Bool     isRASL()   {   return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_R); }
-#endif
+  Bool     isRADL()   { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); }
+  Bool     isRASL()   { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_R); }
 
 #if POC_RESET_FLAG
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 547)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 588)
@@ -43,15 +43,29 @@
 #define SYNTAX_BYTES                     10      ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
 
+#if SVC_EXTENSION
+#define MAX_LAYERS                       8      ///< max number of layers the codec is supposed to handle
+
 #define VPS_VUI_OFFSET                   1      ///< N0085: Signal VPS VUI offset in the VPS extension 
-
 #define RANDOM_ACCESS_SEI_FIX            1
-#if SVC_EXTENSION
-#define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
-
 #define O0137_MAX_LAYERID                1      ///< JCTVC-O0137, JCTVC-O0200, JCTVC-O0223: restrict nuh_layer_id and vps_max_layers_minus1
 
+#define P0130_EOB                        1      ///< JCTVC-P0130, set layer Id of EOB NALU to be fixed to 0
+#define P0307_REMOVE_VPS_VUI_OFFSET      1      ///< JCTVC-P0307, remove implementation related to VPS VUI offset signalling
+#define P0307_VPS_NON_VUI_EXTENSION      1      ///< JCTVC-P0307, implementation related to NON VUI VPS Extension signalling
+
+#define DISCARDABLE_PIC_RPS              1      ///< JCTVC-P0130: Inter-layer RPS and temporal RPS should not contain picture with discardable_flag equal to 1
+#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 SUB_BITSTREAM_PROPERTY_SEI       1      ///< JCTVC-P0204: Sub-bitstream property SEI message
 #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
+
+#define P0048_REMOVE_PROFILE_REF         1      ///< JCTVC-P0048: remove profile_ref_minus1
+#if !P0048_REMOVE_PROFILE_REF
 #define O0109_PROF_REF_MINUS1            1      ///< JCTVC-O0109: constraint that profile_ref_minus1[i] shall be less than or equal to i
+#endif
+
+#define P0295_DEFAULT_OUT_LAYER_IDC      1      ///< JCTVC-P0295: modifify default_one_target_output_layer_idc to default_target_output_layer_idc
 #define O0109_DEFAULT_ONE_OUT_LAYER_IDC  1      ///< JCTVC-O0109: default_one_target_output_layer_flag to default_one_target_output_layer_idc
 #define O0109_MOVE_VPS_VUI_FLAG          1      ///< JCTVC-O0109: move vps_vui_present_flag before vps_vui_offset
@@ -63,5 +77,5 @@
 #define O0194_JOINT_US_BITSHIFT          1      ///< JCTVC-O0194: Joint Upsampling and bit-shift
 #endif
-#define O0194_WEIGHTED_PREDICTION_CGS    0      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
+#define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
 #define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
 #define VPS_NUH_LAYER_ID                 1      ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0
@@ -76,10 +90,8 @@
 
 #define SCALINGLIST_INFERRING            1      ///< JCTVC-N0371: inter-layer scaling list
-#define M0463_VUI_EXT_ILP_REF            0      ///< JCTVC-M0463: VUI extension inter-layer dependency offset signalling
 #define SPS_EXTENSION                    1      ///< Define sps_extension() syntax structure
 #if SPS_EXTENSION
 #define O0142_CONDITIONAL_SPS_EXTENSION  1      ///< JCTVC-O0142: Conditional SPS extension
 #endif
-#define VERT_MV_CONSTRAINT               1      ///< Vertical MV component constraint flag
 #define SCALABILITY_MASK_E0104           1      ///< JCT3V-E0104: scalability mask for depth
 #define LAYER_CTB                        0      ///< enable layer-specific CTB structure
@@ -103,5 +115,4 @@
 #define VPS_EXTN_PROFILE_INFO            1      ///< Include profile information for layer sets in VPS extension
 #define VPS_EXTN_DIRECT_REF_LAYERS       1      ///< Include indication of direct dependency of layers in VPS extension
-#define M0457_PREDICTION_INDICATIONS     1
 #define M0040_ADAPTIVE_RESOLUTION_CHANGE 1
 #define VPS_VUI                          1      ///< Include function structure for VPS VUI
@@ -117,8 +128,12 @@
 #endif
 #define VPS_VUI_VIDEO_SIGNAL             1      ///< JCTVC-O0118 video signal information
+#if VPS_VUI_VIDEO_SIGNAL
+#define VPS_VUI_VIDEO_SIGNAL_MOVE        1      ///< JCTVC-P0076 Move video signal information syntax structure earlier in the VPS VUI
+#endif 
 #endif //VPS_VUI
 
 #endif
 
+#define P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED        1   ///< JCTVC-P0125 -- Keep it as a reserved FFFF value --- The following two macros (VPS_EXTN_OFFSET & VPS_EXTN_OFFSET_CALC) will have no effect when this macro is set to 1.
 #define VPS_EXTN_OFFSET                  1      ///< implementation of vps_extension_offset syntax element
 #define VPS_EXTN_OFFSET_CALC             1      ///< Calculation of VPS extension offset
@@ -133,6 +148,4 @@
 
 #define JCTVC_M0259_LAMBDAREFINEMENT     1      ///< JCTVC-M0259: lambda refinement (encoder only optimization)
-#define RESTR_CHK                        1      ///< JCTVC-M0208 proposal 1
-#define ILP_RAP                          1      ///< JCTVC-M0208 proposal 3
 
 #define AVC_BASE                         1      ///< YUV BL reading for AVC base SVC
@@ -144,11 +157,6 @@
 #define ENCODER_FAST_MODE                1      ///< JCTVC-L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
 #define REF_IDX_MFM                      1      ///< JCTVC-L0336: motion vector mapping of inter-layer reference picture
-#define JCTVC_M0458_INTERLAYER_RPS_SIG   1      ///< implementation of JCTVC-L0178
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
 #define MAX_ONE_RESAMPLING_DIRECT_LAYERS 1      ///< Allow maximum of one resampling process for direct reference layers
 #define MOTION_RESAMPLING_CONSTRAINT     1      ///< JCTVC-N0108: Allow maximum of one motion resampling process for direct reference layers, and use motion inter-layer prediction from the same layer as texture inter-layer prediction.
-#endif
-#define JCTVC_M0203_INTERLAYER_PRED_IDC  1      ///< JCTVC-M0203: implementation of Inter-layer Prediction Indication
-#if JCTVC_M0203_INTERLAYER_PRED_IDC
 #define EARLY_REF_PIC_MARKING            1      ///< Decoded picture marking of sub-layer non-reference pictures
 #define N0120_MAX_TID_REF_PRESENT_FLAG   1      ///< JCTVC-N0120: max_tid_ref_pics_plus1_present_flag
@@ -156,18 +164,9 @@
 #define O0225_MAX_TID_FOR_REF_LAYERS     1
 #define O0225_TID_BASED_IL_RPS_DERIV     1
-
 #define VPS_TSLAYERS                     1      ///< JCTVC-O0120 signal max temporal sub-layers for each layer
 #define TSLAYERS_IL_RPS                  1      ///< JCTVC-O0120 IL RPS based on max temporal sub-layers
-#endif
+#define P0079_DERIVE_NUMACTIVE_REF_PICS  1      ///< JCTVC-P0079 Modification of derivation of variable NumActiveRefLayerPics
 #if REF_IDX_MFM
-#define REMOVE_COL_PICTURE_SIGNALING     1      ///< JCTVC-N0107: remove alternative collocated picture signalling
-#define M0457_COL_PICTURE_SIGNALING      1
 #define N0139_POSITION_ROUNDING_OFFSET   1      ///< JCTVC-N0139: offset for collocated block in motion mapping
-#endif
-
-#if !VPS_EXTN_DIRECT_REF_LAYERS || !M0457_PREDICTION_INDICATIONS || !JCTVC_M0458_INTERLAYER_RPS_SIG
-#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0      ///< shall be 0, JCTVC-N0107
-#else
-#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0      ///< shall be 0, JCTVC-N0107
 #endif
 
@@ -190,5 +189,5 @@
 
 #define VIEW_ID_RELATED_SIGNALING        1      ///< Introduce syntax elements view_id and view_id_val
-#define M0043_LAYERS_PRESENT_SEI         0      ///< JCTVC-M0043: add layers present SEI. Macro shall be equal to 0 according to the JCTVC-N0174 discussion. The code is to be removed.
+#define LAYERS_NOT_PRESENT_SEI           1      ///< JCTVC-M0043: add layers not present SEI.
 #define N0383_IL_CONSTRAINED_TILE_SETS_SEI  1
 #define N0065_LAYER_POC_ALIGNMENT        1
@@ -252,4 +251,8 @@
 #define MAX_VPS_OP_SETS_PLUS1                     1024
 #define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1  1
+#endif
+
+#if SUB_BITSTREAM_PROPERTY_SEI
+#define MAX_SUB_STREAMS                           1024
 #endif
 
Index: trunk/source/Lib/TLibDecoder/SEIread.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/SEIread.cpp	(revision 547)
+++ trunk/source/Lib/TLibDecoder/SEIread.cpp	(revision 588)
@@ -93,6 +93,6 @@
     fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n");
     break;
-#if M0043_LAYERS_PRESENT_SEI
-  case SEI::LAYERS_PRESENT:
+#if LAYERS_NOT_PRESENT_SEI
+  case SEI::LAYERS_NOT_PRESENT:
     fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n");
     break;
@@ -106,4 +106,9 @@
     break;
 #endif
+#if SUB_BITSTREAM_PROPERTY_SEI
+    case SEI::SUB_BITSTREAM_PROPERTY:
+      fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n");
+      break;
+#endif
   case SEI::SCALABLE_NESTING:
     fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
@@ -119,5 +124,5 @@
  * unmarshal a single SEI message from bitstream bs
  */
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
 void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps)
 #else
@@ -130,5 +135,5 @@
   do
   {
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
     xReadSEImessage(seis, nalUnitType, vps, sps);
 #else
@@ -145,5 +150,5 @@
 }
 
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps)
 #else
@@ -254,14 +259,14 @@
       xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize);
       break;
-#if M0043_LAYERS_PRESENT_SEI
-    case SEI::LAYERS_PRESENT:
+#if LAYERS_NOT_PRESENT_SEI
+    case SEI::LAYERS_NOT_PRESENT:
       if (!vps)
       {
-        printf ("Warning: Found Layers present SEI message, but no active VPS is available. Ignoring.");
+        printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring.");
       }
       else
       {
-        sei = new SEILayersPresent;
-        xParseSEILayersPresent((SEILayersPresent&) *sei, payloadSize, vps);
+        sei = new SEILayersNotPresent;
+        xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps);
       }
       break;
@@ -277,7 +282,13 @@
       break;
 #endif
+#if SUB_BITSTREAM_PROPERTY_SEI
+   case SEI::SUB_BITSTREAM_PROPERTY:
+     sei = new SEISubBitstreamProperty;
+     xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei);
+     break;
+#endif
     case SEI::SCALABLE_NESTING:
       sei = new SEIScalableNesting;
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
       xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps);
 #else
@@ -741,6 +752,6 @@
 }
 
-#if M0043_LAYERS_PRESENT_SEI
-Void SEIReader::xParseSEILayersPresent(SEILayersPresent &sei, UInt payloadSize, TComVPS *vps)
+#if LAYERS_NOT_PRESENT_SEI
+Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps)
 {
   UInt uiCode;
@@ -752,9 +763,9 @@
   for (; i < sei.m_vpsMaxLayers; i++)
   {
-    READ_FLAG( uiCode,         "layer_present_flag"   ); sei.m_layerPresentFlag[i] = uiCode ? true : false;
+    READ_FLAG( uiCode,         "layer_not_present_flag"   ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false;
   }
   for (; i < MAX_LAYERS; i++)
   {
-    sei.m_layerPresentFlag[i] = false;
+    sei.m_layerNotPresentFlag[i] = false;
   }
   xParseByteAlign();
@@ -829,6 +840,23 @@
 }
 #endif
-
-#if M0043_LAYERS_PRESENT_SEI
+#if SUB_BITSTREAM_PROPERTY_SEI
+Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei)
+{
+  UInt uiCode;
+  READ_CODE( 4, uiCode, "active_vps_id" );                      sei.m_activeVpsId = uiCode;
+  READ_UVLC(    uiCode, "num_additional_sub_streams_minus1" );  sei.m_numAdditionalSubStreams = uiCode + 1;
+
+  for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ )
+  {
+    READ_CODE(  2, uiCode, "sub_bitstream_mode[i]"           ); sei.m_subBitstreamMode[i] = uiCode;
+    READ_UVLC(     uiCode, "output_layer_set_idx_to_vps[i]"  ); sei.m_outputLayerSetIdxToVps[i] = uiCode;
+    READ_CODE(  3, uiCode, "highest_sub_layer_id[i]"         ); sei.m_highestSublayerId[i] = uiCode;
+    READ_CODE( 16, uiCode, "avg_bit_rate[i]"                 ); sei.m_avgBitRate[i] = uiCode;
+    READ_CODE( 16, uiCode, "max_bit_rate[i]"                 ); sei.m_maxBitRate[i] = uiCode;
+  }
+  xParseByteAlign();
+}
+#endif
+#if LAYERS_NOT_PRESENT_SEI
 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps)
 #else
@@ -876,5 +904,5 @@
   // read nested SEI messages
   do {
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
     xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps);
 #else
Index: trunk/source/Lib/TLibDecoder/SEIread.h
===================================================================
--- trunk/source/Lib/TLibDecoder/SEIread.h	(revision 547)
+++ trunk/source/Lib/TLibDecoder/SEIread.h	(revision 588)
@@ -56,5 +56,5 @@
   SEIReader() {};
   virtual ~SEIReader() {};
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
   Void parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps);
 #else
@@ -62,5 +62,5 @@
 #endif
 protected:
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
   Void xReadSEImessage                (SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps);
 #else
@@ -83,6 +83,9 @@
   Void xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize);
 #endif
-#if M0043_LAYERS_PRESENT_SEI
-  Void xParseSEILayersPresent         (SEILayersPresent &sei, UInt payloadSize, TComVPS *vps);
+#if SUB_BITSTREAM_PROPERTY_SEI
+Void   xParseSEISubBitstreamProperty   (SEISubBitstreamProperty &sei);
+#endif
+#if LAYERS_NOT_PRESENT_SEI
+  Void xParseSEILayersNotPresent      (SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps);
   Void xParseSEIScalableNesting       (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps);
 #else
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 547)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 588)
@@ -756,13 +756,4 @@
   }
   READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" );            pcSPS->setTMVPFlagsPresent(uiCode);
-#if REF_IDX_MFM
-#if !M0457_COL_PICTURE_SIGNALING
-  if(pcSPS->getLayerId() > 0)
-  {
-    READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" );
-    pcSPS->setMFMEnabledFlag( uiCode ? true : false );
-  }
-#endif
-#endif
   READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" );  pcSPS->setUseStrongIntraSmoothing(uiCode);
 
@@ -815,9 +806,8 @@
   // more syntax elements to be parsed here
 
-#if VERT_MV_CONSTRAINT
   READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" );
   // Vertical MV component restriction is not used in SHVC CTC
   assert( uiCode == 0 );
-#endif
+
   if( pcSPS->getLayerId() > 0 )
   {
@@ -836,24 +826,4 @@
     }
   }
-#if M0463_VUI_EXT_ILP_REF
-  ////   sps_extension_vui_parameters( )
-  if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() )
-  {
-    READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode );
-    for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ )
-    {
-      READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode );
-      if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 )
-      {
-        READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 );
-        if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) )
-        {
-          READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode );
-        }
-      }
-    }
-  }
-  ////   sps_extension_vui_parameters( ) END
-#endif
 }
 #endif
@@ -877,6 +847,10 @@
   READ_FLAG(     uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
   assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
+#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
 #if VPS_EXTN_OFFSET
   READ_CODE( 16, uiCode,  "vps_extension_offset" );               pcVPS->setExtensionOffset( uiCode );
+#else
+  READ_CODE( 16, uiCode,  "vps_reserved_ffff_16bits" );           assert(uiCode == 0xffff);
+#endif
 #else
   READ_CODE( 16, uiCode,  "vps_reserved_ffff_16bits" );           assert(uiCode == 0xffff);
@@ -995,4 +969,5 @@
   READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false);
 
+#if !P0307_REMOVE_VPS_VUI_OFFSET
 #if O0109_MOVE_VPS_VUI_FLAG
   READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false);
@@ -1005,4 +980,5 @@
 #if O0109_MOVE_VPS_VUI_FLAG
   }
+#endif
 #endif
   READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false);
@@ -1122,5 +1098,4 @@
     }
 #endif
-#if JCTVC_M0203_INTERLAYER_PRED_IDC
 #if N0120_MAX_TID_REF_PRESENT_FLAG
   READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false);
@@ -1180,5 +1155,4 @@
   }
 #endif
-#endif
 #if ILP_SSH_SIG
     READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false);
@@ -1186,6 +1160,10 @@
 #if VPS_EXTN_PROFILE_INFO
   // Profile-tier-level signalling
+#if !VPS_EXTN_UEV_CODING
   READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" );     assert( uiCode == (vps->getNumLayerSets() - 1) );
   READ_CODE(  6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 );
+#else
+  READ_UVLC(  uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 );
+#endif
   vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel());
   for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
@@ -1194,4 +1172,8 @@
     if( !vps->getProfilePresentFlag(idx) )
     {
+#if P0048_REMOVE_PROFILE_REF
+      // Copy profile information from previous one
+      vps->getPTLForExtn(idx)->copyProfileInfo( (idx==1) ? vps->getPTL() : vps->getPTLForExtn( idx - 1 ) );
+#else
       READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
 #if O0109_PROF_REF_MINUS1
@@ -1202,4 +1184,5 @@
       // Copy profile information as indicated
       vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) );
+#endif
     }
     parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 );
@@ -1207,4 +1190,5 @@
 #endif
 
+#if !VPS_EXTN_UEV_CODING
   READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false );
   Int numOutputLayerSets = 0;
@@ -1218,4 +1202,67 @@
     numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets();
   }
+#else
+  READ_UVLC( uiCode, "num_add_output_layer_sets" );          vps->setNumAddOutputLayerSets( uiCode );
+  Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets();
+#endif
+
+#if P0295_DEFAULT_OUT_LAYER_IDC
+  if( numOutputLayerSets > 1 )
+  {
+    READ_CODE( 2, uiCode, "default_target_output_layer_idc" );   vps->setDefaultTargetOutputLayerIdc( uiCode );
+  }
+  vps->setNumOutputLayerSets( numOutputLayerSets );
+
+  for(i = 1; i < numOutputLayerSets; i++)
+  {
+    if( i > (vps->getNumLayerSets() - 1) )
+    {
+      Int numBits = 1;
+      while ((1 << numBits) < (vps->getNumLayerSets() - 1))
+      {
+        numBits++;
+      }
+      READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1");   vps->setOutputLayerSetIdx( i, uiCode + 1);
+    }
+    else
+    {
+      vps->setOutputLayerSetIdx( i, i );
+    }
+    if ( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 )
+    {
+      Int lsIdx = vps->getOutputLayerSetIdx(i);
+      for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
+      {
+        READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode);
+      }
+    }
+    else
+    {
+      // 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) );
+        }
+      }
+      else if ( vps->getDefaultTargetOutputLayerIdc() == 0 )
+      {
+        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
+        {
+          vps->setOutputLayerFlag(i, j, 1);
+        }
+      }
+    }
+    Int numBits = 1;
+    while ((1 << numBits) < (vps->getNumProfileTierLevel()))
+    {
+      numBits++;
+    }
+    READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
+  }
+#else
   if( numOutputLayerSets > 1 )
   {
@@ -1299,4 +1346,5 @@
     READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
   }
+#endif
 
 #if O0153_ALT_OUTPUT_LAYER_FLAG
@@ -1315,5 +1363,9 @@
   {
 #if O0096_REP_FORMAT_INDEX
+#if !VPS_EXTN_UEV_CODING
     READ_CODE( 8, uiCode, "vps_num_rep_formats_minus1" );
+#else
+    READ_UVLC( uiCode, "vps_num_rep_formats_minus1" );
+#endif
 #else
     READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" );
@@ -1342,5 +1394,14 @@
       {
 #if O0096_REP_FORMAT_INDEX
+#if !VPS_EXTN_UEV_CODING
         READ_CODE( 8, uiCode, "vps_rep_format_idx[i]" );
+#else
+        Int numBits = 1;
+        while ((1 << numBits) < (vps->getVpsNumRepFormats()))
+        {
+          numBits++;
+        }
+        READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" );
+#endif
 #else
         READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" );
@@ -1364,8 +1425,9 @@
   }
 #endif
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
+#if RESOLUTION_BASED_DPB
+  vps->assignSubDpbIndices();
+#endif
   READ_FLAG(uiCode, "max_one_active_ref_layer_flag" );
   vps->setMaxOneActiveRefLayerFlag(uiCode);
-#endif
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
   for(i = 1; i< vps->getMaxLayers(); i++)
@@ -1388,38 +1450,8 @@
 
 #if VPS_DPB_SIZE_TABLE
-  vps->deriveNumberOfSubDpbs();
-  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
-  {
-    READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]");  vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false );
-    for(j = 0; j < vps->getMaxTLayers(); j++)
-    {
-      if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) )
-      {
-        READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]");  vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false);
-      }
-      else
-      {
-        if( j == 0 )  // Always signal for the first sub-layer
-        {
-          vps->setSubLayerDpbInfoPresentFlag( i, j, true );
-        }
-        else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i)
-        {
-          vps->setSubLayerDpbInfoPresentFlag( i, j, false );
-        }
-      }
-      if( vps->getSubLayerDpbInfoPresentFlag(i, j) )  // If sub-layer DPB information is present
-      {
-        for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
-        {
-          READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode );
-        }
-        READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" );              vps->setMaxVpsNumReorderPics( i, j, uiCode);
-        READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" );        vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode);
-      }
-    }
-  }
-#endif
-#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+  parseVpsDpbSizeTable(vps);
+#endif
+
+#if VPS_EXTN_DIRECT_REF_LAYERS
   READ_UVLC( uiCode,           "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2);
 #if O0096_DEFAULT_DEPENDENCY_TYPE
@@ -1470,4 +1502,12 @@
 #endif
 
+#if P0307_VPS_NON_VUI_EXTENSION
+  READ_UVLC( uiCode,           "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode);
+  if ( vps->getVpsNonVuiExtLength() > 0 )
+  {
+    printf("\n\nUp to the current spec, the value of vps_non_vui_extension_length is supposed to be 0\n");
+  }
+#endif
+
 #if !O0109_O0199_FLAGS_TO_VUI
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
@@ -1477,4 +1517,8 @@
   READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false);
 #endif
+#endif
+
+#if P0307_REMOVE_VPS_VUI_OFFSET
+  READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false);
 #endif
 
@@ -1540,4 +1584,67 @@
   READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" );         repFormat->setBitDepthVpsChroma( uiCode + 8 );
 #endif 
+}
+#endif
+#if VPS_DPB_SIZE_TABLE
+Void TDecCavlc::parseVpsDpbSizeTable( TComVPS *vps )
+{
+  UInt uiCode;
+#if !RESOLUTION_BASED_DPB
+  vps->deriveNumberOfSubDpbs();
+#endif
+  for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
+  {
+#if CHANGE_NUMSUBDPB_IDX
+    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
+#endif
+    READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]");  vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false );
+    for(Int j = 0; j < vps->getMaxTLayers(); j++)
+    {
+      if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) )
+      {
+        READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]");  vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false);
+      }
+      else
+      {
+        if( j == 0 )  // Always signal for the first sub-layer
+        {
+          vps->setSubLayerDpbInfoPresentFlag( i, j, true );
+        }
+        else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i)
+        {
+          vps->setSubLayerDpbInfoPresentFlag( i, j, false );
+        }
+      }
+      if( vps->getSubLayerDpbInfoPresentFlag(i, j) )  // If sub-layer DPB information is present
+      {
+#if CHANGE_NUMSUBDPB_IDX
+        for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
+#else
+        for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
+#endif
+        {
+          READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode );
+        }
+        READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" );              vps->setMaxVpsNumReorderPics( i, j, uiCode);
+#if RESOLUTION_BASED_DPB
+        if( vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) != vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) )  
+        {
+          for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++)
+          {
+            READ_UVLC( uiCode, "max_vps_layer_dec_pic_buff_minus1[i][k][j]" ); vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, uiCode);
+          }
+        }
+        else  // vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) == vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet )
+        {          
+          for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++)
+          {
+            vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j));
+          }
+        }
+#endif
+        READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" );        vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode);
+      }
+    }
+  }
 }
 #endif
@@ -1614,4 +1721,46 @@
   }
 #endif
+#if VPS_VUI_VIDEO_SIGNAL_MOVE
+  READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 );
+  if (vps->getVideoSigPresentVpsFlag())
+  {
+    READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1);
+  }
+  else
+  {
+    vps->setNumVideoSignalInfo(vps->getMaxLayers());
+  }
+
+
+  for(i = 0; i < vps->getNumVideoSignalInfo(); i++)
+  {
+    READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode);
+    READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode);
+    READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode);
+    READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode);
+    READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode);
+  }
+  if(!vps->getVideoSigPresentVpsFlag())
+  {
+    for (i=0; i < vps->getMaxLayers(); i++)
+    {
+      vps->setVideoSignalInfoIdx(i,i);
+    }
+  }
+  else {
+    vps->setVideoSignalInfoIdx(0,0);
+    if (vps->getNumVideoSignalInfo() > 1 )
+    {
+      for (i=1; i < vps->getMaxLayers(); i++)
+        READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode);
+    }
+    else {
+      for (i=1; i < vps->getMaxLayers(); i++)
+      {
+        vps->setVideoSignalInfoIdx(i,0);
+      }
+    }
+  }
+#endif 
 #if VPS_VUI_TILES_NOT_IN_USE__FLAG
   UInt layerIdx;
@@ -1672,6 +1821,6 @@
 
 #if N0160_VUI_EXT_ILP_REF
-    READ_FLAG( uiCode, "num_ilp_restricted_ref_layers" ); vps->setNumIlpRestrictedRefLayers( uiCode == 1 );
-  if( vps->getNumIlpRestrictedRefLayers())
+  READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vps->setIlpRestrictedRefLayersFlag( uiCode == 1 );
+  if( vps->getIlpRestrictedRefLayersFlag())
   {
     for(i = 1; i < vps->getMaxLayers(); i++)
@@ -1693,4 +1842,6 @@
 #endif
 #if VPS_VUI_VIDEO_SIGNAL
+#if VPS_VUI_VIDEO_SIGNAL_MOVE
+#else
     READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 );
     if (vps->getVideoSigPresentVpsFlag())
@@ -1733,4 +1884,5 @@
         }
     }
+#endif 
 #endif
 }
@@ -1820,5 +1972,9 @@
     if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits)
     {
+#if DISCARDABLE_PIC_RPS
+      READ_FLAG(uiCode, "discardable_flag"); rpcSlice->setDiscardableFlag( uiCode ? true : false );
+#else
       READ_FLAG(uiCode, "discardable_flag"); // ignored
+#endif
       iBits++;
     }
@@ -2064,5 +2220,4 @@
 
 #if SVC_EXTENSION
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
     rpcSlice->setActiveNumILRRefIdx(0);
 #if ILP_SSH_SIG
@@ -2094,5 +2249,21 @@
           else
           {
+#if P0079_DERIVE_NUMACTIVE_REF_PICS
+            Int   numRefLayerPics = 0;
+            Int   i = 0;
+            Int   refLayerPicIdc  [MAX_VPS_LAYER_ID_PLUS1];
+            for(i = 0, numRefLayerPics = 0;  i < rpcSlice->getNumILRRefIdx(); i++ ) 
+            {
+              if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
+                (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
+              {          
+                refLayerPicIdc[ numRefLayerPics++ ] = i;
+              }
+            }
+            if (numRefLayerPics)
+              rpcSlice->setActiveNumILRRefIdx(1);
+#else
             rpcSlice->setActiveNumILRRefIdx(1);
+#endif 
           }
 #if ILP_NUM_REF_CHK
@@ -2166,18 +2337,4 @@
     }
 #endif
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-    rpcSlice->setInterLayerSamplePredOnlyFlag( false );
-    if( rpcSlice->getNumSamplePredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 )
-    {
-      READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" );
-      rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode > 0 );
-    }
-#endif
-#else
-    if( rpcSlice->getLayerId() > 0 )
-    {
-      rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) );
-    }
-#endif
 #endif
 
@@ -2357,25 +2514,7 @@
     if ( rpcSlice->getEnableTMVPFlag() )
     {
-#if M0457_COL_PICTURE_SIGNALING
-#if REMOVE_COL_PICTURE_SIGNALING
+#if SVC_EXTENSION && REF_IDX_MFM
+      // set motion mapping flag
       rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() ) ? true : false );
-#else
-      rpcSlice->setMFMEnabledFlag( false );
-      rpcSlice->setColRefLayerIdx( 0 );
-      rpcSlice->setAltColIndicationFlag( false );
-      if ( sps->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 )
-      {
-        READ_FLAG( uiCode, "alt_collocated_indication_flag" );
-        rpcSlice->setAltColIndicationFlag( uiCode == 1 ? true : false );
-        rpcSlice->setMFMEnabledFlag( uiCode == 1 ? true : false );
-        if ( rpcSlice->getNumMotionPredRefLayers() > 1 )
-        {
-          READ_UVLC( uiCode, "collocated_ref_layer_idx" );
-          rpcSlice->setColRefLayerIdx( uiCode );
-        }
-      }
-      else
-      {
-#endif //REMOVE_COL_PICTURE_SIGNALING
 #endif
       if ( rpcSlice->getSliceType() == B_SLICE )
@@ -2400,7 +2539,4 @@
         rpcSlice->setColRefIdx(0);
       }
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-      }
-#endif
     }
     if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) )
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 547)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 588)
@@ -83,4 +83,7 @@
   Void  parseRepFormat      ( RepFormat *repFormat );
 #endif
+#if VPS_DPB_SIZE_TABLE
+  Void  parseVpsDpbSizeTable( TComVPS *vps );
+#endif
   Void  parseSPS            ( TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager );
   Void  parseSPSExtension    ( TComSPS* pcSPS );
Index: trunk/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 547)
+++ trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 588)
@@ -234,8 +234,9 @@
   //-- For time output for each slice
 #if SVC_EXTENSION
-  printf("\nPOC %4d LId: %1d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(),
+  printf("\nPOC %4d LId: %1d TId: %1d ( %c-SLICE %s, QP%3d ) ", pcSlice->getPOC(),
                                                     rpcPic->getLayerId(),
                                                     pcSlice->getTLayer(),
                                                     c,
+                                                    NaluToStr( pcSlice->getNalUnitType() ).data(),
                                                     pcSlice->getSliceQp() );
 #else
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 547)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 588)
@@ -86,4 +86,7 @@
   m_bRefreshPending            = false;
 #endif
+#if RESOLUTION_BASED_DPB
+  m_subDpbIdx = -1;
+#endif
 }
 
@@ -178,5 +181,5 @@
     {
 #if USE_DPB_SIZE_TABLE
-      if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 )
+      if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
       {
         assert( this->getLayerId() == 0 );
@@ -187,5 +190,5 @@
         TComVPS *vps = slice->getVPS();
         // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
-        numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getOutputLayerSetIdx() , temporalLayer);
+        numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
       }
 #else
@@ -196,5 +199,5 @@
     if (m_cIlpPic[0] == NULL)
     {
-      for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++)  // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
+      for (Int j=0; j < m_numDirectRefLayers; j++)
       {
 
@@ -282,5 +285,5 @@
   {
 #if USE_DPB_SIZE_TABLE
-    if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 )
+    if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
     {
       assert( this->getLayerId() == 0 );
@@ -291,5 +294,5 @@
       TComVPS *vps = pcSlice->getVPS();
       // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
-      numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getOutputLayerSetIdx() , temporalLayer);
+      numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
     }
 #else
@@ -299,5 +302,5 @@
 
 #if USE_DPB_SIZE_TABLE
-  if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 )
+  if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
   {
     assert( this->getLayerId() == 0 );
@@ -306,5 +309,11 @@
   else
   {
-    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
+#if RESOLUTION_BASED_DPB
+    Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() );
+    Int layerIdx = pcSlice->getVPS()->findLayerIdxInLayerSet( layerSetIdxForOutputLayerSet, pcSlice->getLayerId() );  assert( layerIdx != -1 );
+    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsLayerDecPicBuffMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), layerIdx, pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
+#else
+    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
+#endif
   }
 #else
@@ -815,5 +824,9 @@
 #if OUTPUT_LAYER_SET_INDEX
   // Following check should go wherever the VPS is activated
-  checkValueOfOutputLayerSetIdx( m_apcSlicePilot->getVPS());
+  checkValueOfTargetOutputLayerSetIdx( m_apcSlicePilot->getVPS());
+#endif
+#if RESOLUTION_BASED_DPB
+  // Following assignment should go wherever a new VPS is activated
+  assignSubDpbs(m_apcSlicePilot->getVPS());
 #endif
   m_apcSlicePilot->initSlice( nalu.m_layerId );
@@ -845,13 +858,8 @@
 #if SVC_EXTENSION
   m_apcSlicePilot->setSliceIdx( m_uiSliceIdx ); // it should be removed if HM will reflect it in above
-#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+#if VPS_EXTN_DIRECT_REF_LAYERS
   setRefLayerParams(m_apcSlicePilot->getVPS());
 #endif
-#if M0457_COL_PICTURE_SIGNALING
   m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers);
-#endif
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  m_apcSlicePilot->setNumSamplePredRefLayers( getNumSamplePredRefLayers() );
-#endif
 #endif
   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
@@ -1478,14 +1486,7 @@
 
 #if REF_IDX_MFM
-#if M0457_COL_PICTURE_SIGNALING
       if( pcSlice->getMFMEnabledFlag() )
-#else
-      if( pcSlice->getSPS()->getMFMEnabledFlag() )
-#endif
       {
         pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-        pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice));
-#endif
       }
       pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic);
@@ -1668,5 +1669,5 @@
     }
 #endif
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
 #else
@@ -1676,5 +1677,5 @@
   else
   {
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
 #else
@@ -1696,5 +1697,5 @@
   if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
   {
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
 #else
@@ -1704,5 +1705,5 @@
   else
   {
-#if M0043_LAYERS_PRESENT_SEI
+#if LAYERS_NOT_PRESENT_SEI
     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
 #else
@@ -1865,4 +1866,11 @@
       
     case NAL_UNIT_EOB:
+#if P0130_EOB
+      //Check layer id of the nalu. if it is not 0, give a warning message.
+      if (nalu.m_layerId > 0)
+      {
+        printf( "\n\nThis bitstream is ended with EOB NALU that has layer id greater than 0\n" );
+      }
+#endif
       return false;
       
@@ -1959,5 +1967,5 @@
 #endif
 
-#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+#if VPS_EXTN_DIRECT_REF_LAYERS
 
 Void TDecTop::setRefLayerParams( TComVPS* vps )
@@ -2013,41 +2021,16 @@
 #endif
 
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-TComPic* TDecTop::getMotionPredIlp(TComSlice* pcSlice)
-{
-  TComPic* ilpPic = NULL;
-  Int activeMotionPredReflayerIdx = 0;
-
-  for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
-  {
-    UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
-    if( getMotionPredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) ) )
-    {
-      if (activeMotionPredReflayerIdx == pcSlice->getColRefLayerIdx())
-      {
-        ilpPic = m_cIlpPic[refLayerIdc];
-        break;
-      }
-      else
-      {
-        activeMotionPredReflayerIdx++;
-      }
-    }
-  }
-
-  assert(ilpPic != NULL);
-
-  return ilpPic;
-}
-#endif
 #if OUTPUT_LAYER_SET_INDEX
-Void TDecTop::checkValueOfOutputLayerSetIdx(TComVPS *vps)
+Void TDecTop::checkValueOfTargetOutputLayerSetIdx(TComVPS *vps)
 {
   CommonDecoderParams* params = this->getCommonDecoderParams();
+
+  assert( params->getTargetLayerId() < vps->getMaxLayers() );
+
   if( params->getValueCheckedFlag() )
   {
     return; // Already checked
   }
-  if( params->getOutputLayerSetIdx() == -1 )  // Output layer set index not specified
+  if( params->getTargetOutputLayerSetIdx() == -1 )  // Output layer set index not specified
   {
     Bool layerSetMatchFound = false;
@@ -2096,5 +2079,5 @@
           // Match found
           layerSetMatchFound = true;
-          params->setOutputLayerSetIdx( i );
+          params->setTargetOutputLayerSetIdx( i );
           params->setValueCheckedFlag( true );
           break;
@@ -2107,5 +2090,6 @@
   {
     // Check if the target decoded layer is the highest layer in the list
-    Int layerSetIdx = vps->getOutputLayerSetIdx( params->getOutputLayerSetIdx() );  // Index to the layer set
+    assert( params->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() );
+    Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() );  // Index to the layer set
     assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1);
 
@@ -2138,3 +2122,18 @@
 }
 #endif
+#if RESOLUTION_BASED_DPB
+Void TDecTop::assignSubDpbs(TComVPS *vps)
+{
+  if( m_subDpbIdx == -1 ) // Sub-DPB index is not already assigned
+  {
+    Int lsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() );
+
+    Int layerIdx = vps->findLayerIdxInLayerSet( lsIdx, getLayerId() );
+    assert( layerIdx != -1 ); // Current layer should be found in the layer set.
+
+    // Copy from the active VPS based on the layer ID.
+    m_subDpbIdx = vps->getSubDpbAssigned( lsIdx, layerIdx );
+  }
+}
+#endif
 //! \}
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 547)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 588)
@@ -117,5 +117,5 @@
   Int                     m_iBLSourceHeight;  
 #endif
-#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+#if VPS_EXTN_DIRECT_REF_LAYERS
   Int                     m_numDirectRefLayers;
   Int                     m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
@@ -144,5 +144,8 @@
   Bool                   m_bRefreshPending;
 #endif
-
+#if RESOLUTION_BASED_DPB
+  Int                    m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
+                                          // When new VPS is activated, this should be re-initialized to -1
+#endif
 public:
   TDecTop();
@@ -177,5 +180,4 @@
 #if VPS_EXTN_DIRECT_REF_LAYERS
   TDecTop*  getRefLayerDec(UInt refLayerIdc);
-#if M0457_PREDICTION_INDICATIONS
   Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
   Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
@@ -206,5 +208,4 @@
 
   Void      setRefLayerParams( TComVPS* vps );
-#endif
 #endif
 #if AVC_BASE
@@ -244,7 +245,4 @@
   Void      xDecodePPS();
   Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-  TComPic*  getMotionPredIlp(TComSlice* pcSlice);
-#endif
 
 #if NO_CLRAS_OUTPUT_FLAG
@@ -262,9 +260,14 @@
   CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
   Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
-  Void      checkValueOfOutputLayerSetIdx(TComVPS *vps);
+  Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
 #endif
 #if SCALINGLIST_INFERRING
   ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
 #endif
+#if RESOLUTION_BASED_DPB
+  Void setSubDpbIdx(Int idx)    { m_subDpbIdx = idx; }
+  Int  getSubDpbIdx()           { return m_subDpbIdx; }
+  Void assignSubDpbs(TComVPS *vps);
+#endif
 };// END CLASS DEFINITION TDecTop
 
Index: trunk/source/Lib/TLibEncoder/NALwrite.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/NALwrite.cpp	(revision 547)
+++ trunk/source/Lib/TLibEncoder/NALwrite.cpp	(revision 588)
@@ -91,4 +91,8 @@
   vector<uint8_t>& rbsp   = nalu.m_Bitstream.getFIFO();
 
+#if P0130_EOB
+  if (rbsp.size() == 0) return;
+#endif
+
   for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
   {
Index: trunk/source/Lib/TLibEncoder/SEIwrite.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/SEIwrite.cpp	(revision 547)
+++ trunk/source/Lib/TLibEncoder/SEIwrite.cpp	(revision 588)
@@ -87,6 +87,6 @@
     fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
     break;
-#if M0043_LAYERS_PRESENT_SEI
-  case SEI::LAYERS_PRESENT:
+#if LAYERS_NOT_PRESENT_SEI
+  case SEI::LAYERS_NOT_PRESENT:
     fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n");
     break;
@@ -99,4 +99,9 @@
     fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n");
     break;
+#endif
+#if SUB_BITSTREAM_PROPERTY_SEI
+    case SEI::SUB_BITSTREAM_PROPERTY:
+      fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n");
+      break;
 #endif
   case SEI::SCALABLE_NESTING:
@@ -150,7 +155,7 @@
     xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
     break;
-#if M0043_LAYERS_PRESENT_SEI
-  case SEI::LAYERS_PRESENT:
-    xWriteSEILayersPresent(*static_cast<const SEILayersPresent*>(&sei));
+#if LAYERS_NOT_PRESENT_SEI
+  case SEI::LAYERS_NOT_PRESENT:
+    xWriteSEILayersNotPresent(*static_cast<const SEILayersNotPresent*>(&sei));
     break;
 #endif
@@ -162,4 +167,9 @@
     xWriteSEIInterLayerConstrainedTileSets(*static_cast<const SEIInterLayerConstrainedTileSets*>(&sei));
     break;
+#endif
+#if SUB_BITSTREAM_PROPERTY_SEI
+   case SEI::SUB_BITSTREAM_PROPERTY:
+     xWriteSEISubBitstreamProperty(*static_cast<const SEISubBitstreamProperty*>(&sei));
+     break;
 #endif
   case SEI::SCALABLE_NESTING:
@@ -536,11 +546,11 @@
 }
 
-#if M0043_LAYERS_PRESENT_SEI
-Void SEIWriter::xWriteSEILayersPresent(const SEILayersPresent& sei)
+#if LAYERS_NOT_PRESENT_SEI
+Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei)
 {
   WRITE_UVLC( sei.m_activeVpsId,           "lp_sei_active_vps_id" );
   for (UInt i = 0; i < sei.m_vpsMaxLayers; i++)
   {
-    WRITE_FLAG( sei.m_layerPresentFlag[i], "layer_present_flag"   );
+    WRITE_FLAG( sei.m_layerNotPresentFlag[i], "layer_not_present_flag"   );
   }
   xWriteByteAlign();
@@ -606,5 +616,22 @@
 }
 #endif
-
+#if SUB_BITSTREAM_PROPERTY_SEI
+Void SEIWriter::xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei)
+{
+  WRITE_CODE( sei.m_activeVpsId, 4, "active_vps_id" );
+  assert( sei.m_numAdditionalSubStreams >= 1 );
+  WRITE_UVLC( sei.m_numAdditionalSubStreams - 1, "num_additional_sub_streams_minus1" );
+
+  for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ )
+  {
+    WRITE_CODE( sei.m_subBitstreamMode[i],       2, "sub_bitstream_mode[i]"           );
+    WRITE_UVLC( sei.m_outputLayerSetIdxToVps[i],    "output_layer_set_idx_to_vps[i]"  );
+    WRITE_CODE( sei.m_highestSublayerId[i],      3, "highest_sub_layer_id[i]"         );
+    WRITE_CODE( sei.m_avgBitRate[i],            16, "avg_bit_rate[i]"                 );
+    WRITE_CODE( sei.m_maxBitRate[i],            16, "max_bit_rate[i]"                 );
+  }
+  xWriteByteAlign();
+}
+#endif
 Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps)
 {
Index: trunk/source/Lib/TLibEncoder/SEIwrite.h
===================================================================
--- trunk/source/Lib/TLibEncoder/SEIwrite.h	(revision 547)
+++ trunk/source/Lib/TLibEncoder/SEIwrite.h	(revision 588)
@@ -64,10 +64,13 @@
   Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
   Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
-#if M0043_LAYERS_PRESENT_SEI
-  Void xWriteSEILayersPresent(const SEILayersPresent& sei);
+#if LAYERS_NOT_PRESENT_SEI
+  Void xWriteSEILayersNotPresent(const SEILayersNotPresent& sei);
 #endif
   Void xWriteSEISOPDescription(const SEISOPDescription& sei);
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
   Void xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei);
+#endif
+#if SUB_BITSTREAM_PROPERTY_SEI
+  Void xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei);
 #endif
   Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps);
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 588)
@@ -579,12 +579,4 @@
   }
   WRITE_FLAG( pcSPS->getTMVPFlagsPresent()  ? 1 : 0,           "sps_temporal_mvp_enable_flag" );
-#if REF_IDX_MFM
-#if !M0457_COL_PICTURE_SIGNALING
-  if( pcSPS->getLayerId() > 0 )
-  {
-    WRITE_FLAG( pcSPS->getMFMEnabledFlag() ? 1 : 0,          "sps_enh_mfm_enable_flag" );
-  }
-#endif
-#endif
   WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(),             "sps_strong_intra_smoothing_enable_flag" );
 
@@ -623,8 +615,7 @@
   // more syntax elements to be written here
 
-#if VERT_MV_CONSTRAINT
   // Vertical MV component restriction is not used in SHVC CTC
   WRITE_FLAG( 0, "inter_view_mv_vert_constraint_flag" );
-#endif
+
   if( pcSPS->getLayerId() > 0 )
   {
@@ -642,33 +633,17 @@
     }
   }
-#if M0463_VUI_EXT_ILP_REF
-  ////   sps_extension_vui_parameters( )
-  if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() )
-  {  
-    WRITE_UVLC( pcSPS->getNumIlpRestrictedRefLayers( ),           "num_ilp_restricted_ref_layers" ); 
-    for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) 
-    {  
-      WRITE_UVLC( pcSPS->getMinSpatialSegmentOffsetPlus1( i ),    "min_spatial_segment_offset_plus1" ); 
-      if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) 
-      {  
-        WRITE_FLAG( pcSPS->getCtuBasedOffsetEnabledFlag( i ),      "ctu_based_offset_enabled_flag[ i ]"); 
-        if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) )  
-        {
-          WRITE_UVLC( pcSPS->getMinHorizontalCtuOffsetPlus1( i ), "min_horizontal_ctu_offset_plus1[ i ]"); 
-        }
-      }  
-    }  
-  }  
-  ////   sps_extension_vui_parameters( ) END
-#endif
 }
 #endif
 Void TEncCavlc::codeVPS( TComVPS* pcVPS )
 {
+#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
 #if VPS_EXTN_OFFSET_CALC
   UInt numBytesInVps = this->m_pcBitIf->getNumberOfWrittenBits();
 #endif
+#endif
+#if !P0307_REMOVE_VPS_VUI_OFFSET
 #if VPS_VUI_OFFSET
    m_vpsVuiCounter = this->m_pcBitIf->getNumberOfWrittenBits();
+#endif
 #endif
   WRITE_CODE( pcVPS->getVPSId(),                    4,        "vps_video_parameter_set_id" );
@@ -682,6 +657,10 @@
   WRITE_FLAG( pcVPS->getTemporalNestingFlag(),                "vps_temporal_id_nesting_flag" );
   assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
+#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
 #if VPS_EXTN_OFFSET
   WRITE_CODE( pcVPS->getExtensionOffset(),         16,        "vps_extension_offset" );
+#else
+  WRITE_CODE( 0xffff,                              16,        "vps_reserved_ffff_16bits" );
+#endif
 #else
   WRITE_CODE( 0xffff,                              16,        "vps_reserved_ffff_16bits" );
@@ -775,4 +754,5 @@
       WRITE_FLAG(1,                  "vps_extension_alignment_bit_equal_to_one");
     }
+#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
 #if VPS_EXTN_OFFSET_CALC
     Int vpsExntOffsetValueInBits = this->m_pcBitIf->getNumberOfWrittenBits() - numBytesInVps + 16; // 2 bytes for NUH
@@ -780,4 +760,5 @@
     pcVPS->setExtensionOffset( vpsExntOffsetValueInBits >> 3 );
 #endif
+#endif
     codeVPSExtension(pcVPS);
     WRITE_FLAG( 0,                     "vps_extension2_flag" );   // Flag value of 1 reserved
@@ -798,4 +779,5 @@
 
   WRITE_FLAG( vps->getAvcBaseLayerFlag(),              "avc_base_layer_flag" );
+#if !P0307_REMOVE_VPS_VUI_OFFSET
 #if O0109_MOVE_VPS_VUI_FLAG
 #if !VPS_VUI
@@ -819,4 +801,6 @@
   WRITE_FLAG( vps->getSplittingFlag(),                 "splitting_flag" );
 #endif // O0109_MOVE_VPS_VUI_FLAG
+#endif
+  WRITE_FLAG( vps->getSplittingFlag(),                 "splitting_flag" );
 
   for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
@@ -908,5 +892,4 @@
     }
 #endif
-#if JCTVC_M0203_INTERLAYER_PRED_IDC
 #if N0120_MAX_TID_REF_PRESENT_FLAG
    WRITE_FLAG( vps->getMaxTidRefPresentFlag(), "max_tid_ref_present_flag");
@@ -944,5 +927,4 @@
   }
 #endif
-#endif
 #if ILP_SSH_SIG
     WRITE_FLAG( vps->getIlpSshSignalingEnabledFlag(), "all_ref_layers_active_flag" );
@@ -950,17 +932,24 @@
 #if VPS_EXTN_PROFILE_INFO
   // Profile-tier-level signalling
+#if !VPS_EXTN_UEV_CODING
   WRITE_CODE( vps->getNumLayerSets() - 1   , 10, "vps_number_layer_sets_minus1" );     
   WRITE_CODE( vps->getNumProfileTierLevel() - 1,  6, "vps_num_profile_tier_level_minus1"); 
+#else
+  WRITE_UVLC( vps->getNumProfileTierLevel() - 1, "vps_num_profile_tier_level_minus1"); 
+#endif
   for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
   {
     WRITE_FLAG( vps->getProfilePresentFlag(idx),       "vps_profile_present_flag[i]" );
+#if !P0048_REMOVE_PROFILE_REF
     if( !vps->getProfilePresentFlag(idx) )
     {
       WRITE_CODE( vps->getProfileLayerSetRef(idx) - 1, 6, "profile_ref_minus1[i]" );
     }
+#endif
     codePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 );
   }
 #endif
 
+#if !VPS_EXTN_UEV_CODING
   Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
   WRITE_FLAG(  (numOutputLayerSets > vps->getNumLayerSets()), "more_output_layer_sets_than_default_flag" ); 
@@ -969,6 +958,14 @@
     WRITE_CODE( numOutputLayerSets - vps->getNumLayerSets(), 10, "num_add_output_layer_sets" );
   }
+#else
+  Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
+  assert( numOutputLayerSets - (Int)vps->getNumLayerSets() >= 0 );
+  WRITE_UVLC( numOutputLayerSets - vps->getNumLayerSets(), "num_add_output_layer_sets" );
+#endif
   if( numOutputLayerSets > 1 )
   {
+#if P0295_DEFAULT_OUT_LAYER_IDC
+    WRITE_CODE( vps->getDefaultTargetOutputLayerIdc(), 2, "default_target_output_layer_idc" );   
+#else
 #if O0109_DEFAULT_ONE_OUT_LAYER_IDC
     WRITE_CODE( vps->getDefaultOneTargetOutputLayerIdc(), 2, "default_one_target_output_layer_idc" );   
@@ -976,4 +973,5 @@
     WRITE_FLAG( vps->getDefaultOneTargetOutputLayerFlag(), "default_one_target_output_layer_flag" );   
 #endif
+#endif
   }
 
@@ -987,5 +985,10 @@
         numBits++;
       }
-      WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "output_layer_set_idx_minus1");  
+      WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "output_layer_set_idx_minus1"); 
+#if P0295_DEFAULT_OUT_LAYER_IDC
+    }
+    if ( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 ) //Instead of == 2, >= 2 is used to follow the agreement that value 3 should be interpreted as 2
+    {
+#endif
       Int lsIdx = vps->getOutputLayerSetIdx(i);
       for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
@@ -1015,5 +1018,9 @@
   {
 #if O0096_REP_FORMAT_INDEX
+#if !VPS_EXTN_UEV_CODING
     WRITE_CODE( vps->getVpsNumRepFormats() - 1, 8, "vps_num_rep_formats_minus1" );
+#else
+    WRITE_UVLC( vps->getVpsNumRepFormats() - 1, "vps_num_rep_formats_minus1" );
+#endif
 #else
     WRITE_CODE( vps->getVpsNumRepFormats() - 1, 4, "vps_num_rep_formats_minus1" );
@@ -1033,6 +1040,15 @@
       {
 #if O0096_REP_FORMAT_INDEX
+#if !VPS_EXTN_UEV_CODING
         WRITE_CODE( vps->getVpsRepFormatIdx(i), 8, "vps_rep_format_idx[i]" );
 #else
+        Int numBits = 1;
+        while ((1 << numBits) < (vps->getVpsNumRepFormats()))
+        {
+          numBits++;
+        }
+        WRITE_CODE( vps->getVpsRepFormatIdx(i), numBits, "vps_rep_format_idx[i]" );
+#endif
+#else
         WRITE_CODE( vps->getVpsRepFormatIdx(i), 4, "vps_rep_format_idx[i]" );
 #endif
@@ -1042,7 +1058,5 @@
 #endif
 
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
-      WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
-#endif
+  WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
   for(i = 1; i< vps->getMaxLayers(); i++)
@@ -1061,26 +1075,7 @@
 #endif 
 #if VPS_DPB_SIZE_TABLE
-  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
-  {
-    WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]");  
-    for(j = 0; j < vps->getMaxTLayers(); j++)
-    {
-      if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) )
-      {
-        WRITE_FLAG( vps->getSubLayerDpbInfoPresentFlag( i, j), "sub_layer_dpb_info_present_flag[i]");  
-      }
-      if( vps->getSubLayerDpbInfoPresentFlag(i, j) )
-      {
-        for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
-        {
-          WRITE_UVLC( vps->getMaxVpsDecPicBufferingMinus1( i, k, j), "max_vps_dec_pic_buffering_minus1[i][k][j]" ); 
-        }
-        WRITE_UVLC( vps->getMaxVpsNumReorderPics( i, j), "max_vps_num_reorder_pics[i][j]" );              
-        WRITE_UVLC( vps->getMaxVpsLatencyIncreasePlus1( i, j), "max_vps_latency_increase_plus1[i][j]" );        
-      }
-    }
-  }
-#endif
-#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+  codeVpsDpbSizeTable(vps);
+#endif
+#if VPS_EXTN_DIRECT_REF_LAYERS
   WRITE_UVLC( vps->getDirectDepTypeLen()-2,                           "direct_dep_type_len_minus2");
 #if O0096_DEFAULT_DEPENDENCY_TYPE
@@ -1126,4 +1121,12 @@
 #endif
 
+#if P0307_VPS_NON_VUI_EXTENSION
+  WRITE_UVLC( vps->getVpsNonVuiExtLength(), "vps_non_vui_extension_length" );
+  if ( vps->getVpsNonVuiExtLength() > 0 )
+  {
+    printf("\n\nUp to the current spec, the value of vps_non_vui_extension_length is supposed to be 0\n");
+  }
+#endif
+
 #if !O0109_MOVE_VPS_VUI_FLAG
 #if !VPS_VUI
@@ -1146,4 +1149,8 @@
 #endif 
 #else
+#if P0307_REMOVE_VPS_VUI_OFFSET
+  WRITE_FLAG( 1,                     "vps_vui_present_flag" );
+  vps->setVpsVuiPresentFlag(true);
+#endif
   if(vps->getVpsVuiPresentFlag())   // Should be conditioned on the value of vps_vui_present_flag
   {
@@ -1152,8 +1159,10 @@
       WRITE_FLAG(1,                  "vps_vui_alignment_bit_equal_to_one");
     }
+#if !P0307_REMOVE_VPS_VUI_OFFSET
 #if VPS_VUI_OFFSET
     Int vpsVuiOffsetValeInBits = this->m_pcBitIf->getNumberOfWrittenBits() - m_vpsVuiCounter + 16; // 2 bytes for NUH
     assert( vpsVuiOffsetValeInBits % 8 == 0 );
     vps->setVpsVuiOffset( vpsVuiOffsetValeInBits >> 3 );
+#endif
 #endif
     codeVPSVUI(vps);  
@@ -1204,4 +1213,45 @@
 }
 #endif
+#if VPS_DPB_SIZE_TABLE
+Void TEncCavlc::codeVpsDpbSizeTable(TComVPS *vps)
+{
+  for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
+  {
+#if CHANGE_NUMSUBDPB_IDX
+    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
+#endif
+    WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]");  
+    for(Int j = 0; j < vps->getMaxTLayers(); j++)
+    {
+      if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) )
+      {
+        WRITE_FLAG( vps->getSubLayerDpbInfoPresentFlag( i, j), "sub_layer_dpb_info_present_flag[i]");  
+      }
+      if( vps->getSubLayerDpbInfoPresentFlag(i, j) )
+      {
+#if CHANGE_NUMSUBDPB_IDX
+        for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
+#else
+        for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
+#endif
+        {
+          WRITE_UVLC( vps->getMaxVpsDecPicBufferingMinus1( i, k, j), "max_vps_dec_pic_buffering_minus1[i][k][j]" ); 
+        }
+        WRITE_UVLC( vps->getMaxVpsNumReorderPics( i, j), "max_vps_num_reorder_pics[i][j]" );              
+#if RESOLUTION_BASED_DPB
+        if( vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) != vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) )  // NumSubDpbs
+        {
+          for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++)
+          {
+            WRITE_UVLC( vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j), "max_vps_layer_dec_pic_buff_minus1[i][k][j]" );
+          }
+        }
+#endif
+        WRITE_UVLC( vps->getMaxVpsLatencyIncreasePlus1( i, j), "max_vps_latency_increase_plus1[i][j]" );        
+      }
+    }
+  }
+}
+#endif
 #if VPS_VUI
 Void TEncCavlc::codeVPSVUI (TComVPS *vps)
@@ -1251,4 +1301,26 @@
   }
 #endif
+#if VPS_VUI_VIDEO_SIGNAL_MOVE
+  WRITE_FLAG( vps->getVideoSigPresentVpsFlag(), "video_signal_info_idx_present_flag" );
+  if (vps->getVideoSigPresentVpsFlag())
+  {
+    WRITE_CODE(vps->getNumVideoSignalInfo()-1, 4, "vps_num_video_signal_info_minus1" );
+  }
+
+  for(i = 0; i < vps->getNumVideoSignalInfo(); i++)
+  {
+    WRITE_CODE(vps->getVideoVPSFormat(i), 3, "video_vps_format" );
+    WRITE_FLAG(vps->getVideoFullRangeVpsFlag(i), "video_full_range_vps_flag" );
+    WRITE_CODE(vps->getColorPrimaries(i), 8, "color_primaries_vps" );
+    WRITE_CODE(vps->getTransCharacter(i), 8, "transfer_characteristics_vps" );
+    WRITE_CODE(vps->getMaxtrixCoeff(i), 8, "matrix_coeffs_vps" );
+  }
+
+  if (vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 )
+  {
+    for (i=1; i < vps->getMaxLayers(); i++)
+      WRITE_CODE(vps->getVideoSignalInfoIdx(i), 4, "vps_video_signal_info_idx" );
+  }
+#endif 
 #if VPS_VUI_TILES_NOT_IN_USE__FLAG
   UInt layerIdx;
@@ -1304,6 +1376,6 @@
 #endif
 #if N0160_VUI_EXT_ILP_REF
-  WRITE_FLAG( vps->getNumIlpRestrictedRefLayers() ? 1 : 0 , "num_ilp_restricted_ref_layers" );    
-  if( vps->getNumIlpRestrictedRefLayers())
+  WRITE_FLAG( vps->getIlpRestrictedRefLayersFlag() ? 1 : 0 , "ilp_restricted_ref_layers_flag" );    
+  if( vps->getIlpRestrictedRefLayersFlag())
   {
     for(i = 1; i < vps->getMaxLayers(); i++)
@@ -1327,4 +1399,6 @@
 #endif 
 #if VPS_VUI_VIDEO_SIGNAL
+#if VPS_VUI_VIDEO_SIGNAL_MOVE
+#else 
     WRITE_FLAG( vps->getVideoSigPresentVpsFlag(), "video_signal_info_idx_present_flag" );
     if (vps->getVideoSigPresentVpsFlag())
@@ -1347,4 +1421,5 @@
             WRITE_CODE(vps->getVideoSignalInfoIdx(i), 4, "vps_video_signal_info_idx" );
     }
+#endif 
 #endif
 }
@@ -1611,5 +1686,5 @@
     }
 
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
+#if SVC_EXTENSION
 #if ILP_SSH_SIG
 #if ILP_SSH_SIG_FIX
@@ -1650,11 +1725,5 @@
       }
     }     
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-    if( pcSlice->getNumSamplePredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 )
-    {
-      WRITE_FLAG( pcSlice->getInterLayerSamplePredOnlyFlag(), "inter_layer_sample_pred_only_flag" );
-    }
-#endif
-#endif 
+#endif //SVC_EXTENSION
 
     if(pcSlice->getSPS()->getUseSAO())
@@ -1772,16 +1841,4 @@
     if ( pcSlice->getEnableTMVPFlag() )
     {
-#if SVC_EXTENSION && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-      if ( !pcSlice->getIdrPicFlag() && pcSlice->getLayerId() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 && pcSlice->getNumMotionPredRefLayers() > 0 )
-      {
-        WRITE_FLAG( pcSlice->getAltColIndicationFlag() ? 1 : 0, "alt_collocated_indication_flag" );
-        if (pcSlice->getAltColIndicationFlag() && pcSlice->getNumMotionPredRefLayers() > 1)
-        {
-          WRITE_UVLC(0, "collocated_ref_layer_idx");
-        }
-      }
-      else
-      {
-#endif
       if ( pcSlice->getSliceType() == B_SLICE )
       {
@@ -1795,7 +1852,4 @@
         WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" );
       }
-#if SVC_EXTENSION && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-      }
-#endif
     }
     if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) )
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 588)
@@ -68,6 +68,8 @@
   TComSlice*    m_pcSlice;
   UInt          m_uiCoeffCost;
+#if !P0307_REMOVE_VPS_VUI_OFFSET
 #if VPS_VUI_OFFSET
   Int m_vpsVuiCounter;
+#endif
 #endif
   Void codeShortTermRefPicSet              ( TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Bool calledFromSliceHeader, Int idx );
@@ -95,4 +97,7 @@
 #if REPN_FORMAT_IN_VPS
   Void  codeRepFormat           ( RepFormat *repFormat );
+#endif
+#if VPS_DPB_SIZE_TABLE
+  Void  codeVpsDpbSizeTable      (TComVPS *vps);
 #endif
   Void  codeVUI                 ( TComVUI *pcVUI, TComSPS* pcSPS );
Index: trunk/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 588)
@@ -168,5 +168,4 @@
   Int       m_numActiveRefLayers;
   Int       m_predLayerId[MAX_VPS_LAYER_ID_PLUS1];
-#if M0457_PREDICTION_INDICATIONS
   Int       m_numSamplePredRefLayers;
   Int       m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
@@ -175,5 +174,4 @@
   Bool      m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
   Bool      m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
-#endif
 #endif
 #if N0120_MAX_TID_REF_CFG
@@ -307,6 +305,6 @@
   Int       m_gradualDecodingRefreshInfoEnabled;
   Int       m_decodingUnitInfoSEIEnabled;
-#if M0043_LAYERS_PRESENT_SEI
-  Int       m_layersPresentSEIEnabled;
+#if LAYERS_NOT_PRESENT_SEI
+  Int       m_layersNotPresentSEIEnabled;
 #endif
   Int       m_SOPDescriptionSEIEnabled;
@@ -452,5 +450,4 @@
   Void      setPredLayerId                  (Int i, Int refLayerId)         { m_predLayerId[i] = refLayerId;    }
 
-#if M0457_PREDICTION_INDICATIONS
   Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
   Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
@@ -470,5 +467,4 @@
   Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
   Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
-#endif
 #endif
 #if N0120_MAX_TID_REF_CFG
@@ -752,7 +748,7 @@
   Void  setDecodingUnitInfoSEIEnabled(Int b)                { m_decodingUnitInfoSEIEnabled = b;    }
   Int   getDecodingUnitInfoSEIEnabled()                     { return m_decodingUnitInfoSEIEnabled; }
-#if M0043_LAYERS_PRESENT_SEI
-  Void  setLayersPresentSEIEnabled(Int b)                { m_layersPresentSEIEnabled = b; }
-  Int   getLayersPresentSEIEnabled()                     { return m_layersPresentSEIEnabled; }
+#if LAYERS_NOT_PRESENT_SEI
+  Void  setLayersNotPresentSEIEnabled(Int b)             { m_layersNotPresentSEIEnabled = b; }
+  Int   getLayersNotPresentSEIEnabled()                  { return m_layersNotPresentSEIEnabled; }
 #endif
   Void  setSOPDescriptionSEIEnabled(Int b)                { m_SOPDescriptionSEIEnabled = b; }
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 588)
@@ -462,10 +462,4 @@
         testInter = false;
       }
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-      if( pcSlice->getInterLayerSamplePredOnlyFlag() )
-      {
-        testInter = false;
-      }
-#endif
     }
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 588)
@@ -167,20 +167,20 @@
 }
 
-#if M0043_LAYERS_PRESENT_SEI
-SEILayersPresent* TEncGOP::xCreateSEILayersPresent ()
+#if LAYERS_NOT_PRESENT_SEI
+SEILayersNotPresent* TEncGOP::xCreateSEILayersNotPresent ()
 {
   UInt i = 0;
-  SEILayersPresent *seiLayersPresent = new SEILayersPresent(); 
-  seiLayersPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId(); 
-  seiLayersPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers();
-  for ( ; i < seiLayersPresent->m_vpsMaxLayers; i++)
-  {
-    seiLayersPresent->m_layerPresentFlag[i] = true; 
+  SEILayersNotPresent *seiLayersNotPresent = new SEILayersNotPresent(); 
+  seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId(); 
+  seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers();
+  for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++)
+  {
+    seiLayersNotPresent->m_layerNotPresentFlag[i] = true; 
   }
   for ( ; i < MAX_LAYERS; i++)
   {
-    seiLayersPresent->m_layerPresentFlag[i] = false; 
-  }
-  return seiLayersPresent;
+    seiLayersNotPresent->m_layerNotPresentFlag[i] = false; 
+  }
+  return seiLayersNotPresent;
 }
 #endif
@@ -363,8 +363,8 @@
   }
 
-#if M0043_LAYERS_PRESENT_SEI
-  if(m_pcCfg->getLayersPresentSEIEnabled())
-  {
-    SEILayersPresent *sei = xCreateSEILayersPresent ();
+#if LAYERS_NOT_PRESENT_SEI
+  if(m_pcCfg->getLayersNotPresentSEIEnabled())
+  {
+    SEILayersNotPresent *sei = xCreateSEILayersNotPresent ();
     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); 
@@ -690,22 +690,5 @@
       pcSlice->setActiveNumILRRefIdx(0);
       pcSlice->setInterLayerPredEnabledFlag(false);
-#if M0457_COL_PICTURE_SIGNALING
       pcSlice->setMFMEnabledFlag(false);
-#if !REMOVE_COL_PICTURE_SIGNALING
-      pcSlice->setAltColIndicationFlag(false);
-#endif
-#endif
-    }
-#endif
-
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-    pcSlice->setNumSamplePredRefLayers( m_pcEncTop->getNumSamplePredRefLayers() );
-    pcSlice->setInterLayerSamplePredOnlyFlag( 0 );
-    if( pcSlice->getNumSamplePredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 )
-    {
-      if( m_pcEncTop->getIlSampleOnlyPred() > 0 )
-      {
-        pcSlice->setInterLayerSamplePredOnlyFlag( true );
-      }
     }
 #endif
@@ -1159,5 +1142,4 @@
     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     {
-#if RESTR_CHK
 #if POC_RESET_FLAG
       if ( pocCurr > 0          && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
@@ -1166,13 +1148,7 @@
 #endif
       {
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
         pcSlice->setActiveNumILRRefIdx(0);
         pcSlice->setInterLayerPredEnabledFlag(0);
-#else
-        pcSlice->setNumILRRefIdx(0);
-#endif
-      }
-#endif
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
+      }
       if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
       {
@@ -1185,16 +1161,4 @@
         pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx());
       }
-#else
-      if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
-      {
-        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumILRRefIdx());
-        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumILRRefIdx());
-      }
-      else
-      {
-        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getNumILRRefIdx());
-        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getNumILRRefIdx());
-      }
-#endif
     }
 #endif //SVC_EXTENSION
@@ -1205,9 +1169,5 @@
 
 #if SVC_EXTENSION
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-    if ( pcSlice->getSliceType() == B_SLICE && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) )
-#else
     if( pcSlice->getSliceType() == B_SLICE )
-#endif
     {
       pcSlice->setColFromL0Flag(1-uiColDir);
@@ -1224,14 +1184,7 @@
       pcSlice->setILRPic( m_pcEncTop->getIlpList() );
 #if REF_IDX_MFM
-#if M0457_COL_PICTURE_SIGNALING
       if( pcSlice->getMFMEnabledFlag() )
-#else
-      if( pcSlice->getSPS()->getMFMEnabledFlag() )
-#endif
       {
         pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic());
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-        pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice));
-#endif
       }
 #else
@@ -1243,13 +1196,5 @@
 
 #if REF_IDX_MFM
-#if M0457_COL_PICTURE_SIGNALING
-#if REMOVE_COL_PICTURE_SIGNALING
       if( pcSlice->getMFMEnabledFlag() )
-#else
-      if( pcSlice->getMFMEnabledFlag() && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) )
-#endif
-#else
-      if( pcSlice->getSPS()->getMFMEnabledFlag() )
-#endif
       {
         Bool found         = false;
@@ -1308,9 +1253,5 @@
     }
 
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-    if (pcSlice->getSliceType() == B_SLICE && m_pcEncTop->getIlSampleOnlyPred() == 0)
-#else
     if (pcSlice->getSliceType() == B_SLICE)
-#endif
     {
 #if !SVC_EXTENSION
@@ -1617,5 +1558,8 @@
 #if O0194_WEIGHTED_PREDICTION_CGS
       // Calculate for the base layer to be used in EL as Inter layer reference
-      m_pcSliceEncoder->estimateILWpParam( pcSlice );
+      if( m_pcEncTop->getInterLayerWeightedPredFlag() )
+      {
+        m_pcSliceEncoder->estimateILWpParam( pcSlice );
+      }
 #endif
 #if AVC_SYNTAX
@@ -1756,8 +1700,10 @@
       // The following code also calculates the VPS VUI offset
 #endif
+#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
 #if VPS_EXTN_OFFSET_CALC
       OutputNALUnit tempNalu(NAL_UNIT_VPS, 0, 0        ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
       m_pcEntropyCoder->setBitstream(&tempNalu.m_Bitstream);
       m_pcEntropyCoder->encodeVPS(m_pcEncTop->getVPS());  // Use to calculate the VPS extension offset
+#endif
 #endif
       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
@@ -2068,5 +2014,5 @@
             startCUAddrSliceSegmentIdx++;
           }
-#if SVC_EXTENSION && M0457_COL_PICTURE_SIGNALING
+#if SVC_EXTENSION
           pcSlice->setNumMotionPredRefLayers(m_pcEncTop->getNumMotionPredRefLayers());
 #endif
@@ -3111,19 +3057,21 @@
 
 #if SVC_EXTENSION
-#if ADAPTIVE_QP_SELECTION
-  printf("POC %4d LId: %1d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits",
+#if ADAPTIVE_QP_SELECTION  
+  printf("POC %4d LId: %1d TId: %1d ( %c-SLICE %s, nQP %d QP %d ) %10d bits",
          pcSlice->getPOC(),
          pcSlice->getLayerId(),
          pcSlice->getTLayer(),
          c,
+         NaluToStr( pcSlice->getNalUnitType() ).data(),
          pcSlice->getSliceQpBase(),
          pcSlice->getSliceQp(),
          uibits );
 #else
-  printf("POC %4d LId: %1d TId: %1d ( %c-SLICE, QP %d ) %10d bits",
+  printf("POC %4d LId: %1d TId: %1d ( %c-SLICE %s, QP %d ) %10d bits",
          pcSlice->getPOC()-pcSlice->getLastIDR(),
          pcSlice->getLayerId(),
          pcSlice->getTLayer(),
          c,
+         NaluToStr( pcSlice->getNalUnitType() ).data().
          pcSlice->getSliceQp(),
          uibits );
@@ -3750,33 +3698,3 @@
   free(rowSAD);
 }
-
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-TComPic* TEncGOP::getMotionPredIlp(TComSlice* pcSlice)
-{
-  TComPic* ilpPic = NULL;
-  Int activeMotionPredReflayerIdx = 0;
-
-  for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
-  {
-    UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
-    if( m_pcEncTop->getMotionPredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) ) )
-    {
-      if (activeMotionPredReflayerIdx == pcSlice->getColRefLayerIdx())
-      {
-        ilpPic = m_pcEncTop->getIlpList()[refLayerIdc];
-        break;
-      }
-      else
-      {
-        activeMotionPredReflayerIdx++;
-      }
-    }
-  }
-
-  assert(ilpPic != NULL);
-
-  return ilpPic;
-}
-#endif
-
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.h	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.h	(revision 588)
@@ -181,6 +181,6 @@
 
   SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps);
-#if M0043_LAYERS_PRESENT_SEI
-  SEILayersPresent*       xCreateSEILayersPresent ();
+#if LAYERS_NOT_PRESENT_SEI
+  SEILayersNotPresent*    xCreateSEILayersNotPresent ();
 #endif
   SEIFramePacking*        xCreateSEIFramePacking();
@@ -210,7 +210,4 @@
 #endif
   Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
-#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
-  TComPic* getMotionPredIlp(TComSlice* pcSlice);
-#endif
 };// END CLASS DEFINITION TEncGOP
 
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 588)
@@ -523,5 +523,4 @@
   if( layerId > 0 )
   {
-#if JCTVC_M0458_INTERLAYER_RPS_SIG
     if( rpcSlice->getNumILRRefIdx() > 0 )
     {
@@ -533,13 +532,5 @@
       rpcSlice->setInterLayerPredEnabledFlag(1);
     }
-#else
-    rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( layerId ) );
-#endif
-#if M0457_COL_PICTURE_SIGNALING
     rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[layerId]->getMFMEnabledFlag());
-#if !REMOVE_COL_PICTURE_SIGNALING
-    rpcSlice->setAltColIndicationFlag(rpcSlice->getMFMEnabledFlag());
-#endif
-#endif
   }
 
@@ -820,5 +811,5 @@
   }
 #if O0194_WEIGHTED_PREDICTION_CGS
-  else
+  else if( m_ppcTEncTop[pcSlice->getLayerId()]->getInterLayerWeightedPredFlag() )
   {
     // Calculate for the base layer to be used in EL as Inter layer reference
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 588)
@@ -934,9 +934,4 @@
 #if SVC_EXTENSION
   m_cSPS.setLayerId(m_layerId);
-#if REF_IDX_MFM
-#if !M0457_COL_PICTURE_SIGNALING
-  m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag);
-#endif
-#endif
   m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets);
   for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++)
@@ -1632,5 +1627,5 @@
     if (m_cIlpPic[0] == NULL)
     {
-      for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
+      for (Int j=0; j < m_numLayer; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
       {
         m_cIlpPic[j] = new  TComPic;
@@ -1699,5 +1694,5 @@
     if (m_cIlpPic[0] == NULL)
     {
-      for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
+      for (Int j=0; j < m_numDirectRefLayers; j++)
       {
         m_cIlpPic[j] = new  TComPic;
Index: trunk/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.h	(revision 547)
+++ trunk/source/Lib/TLibEncoder/TEncTop.h	(revision 588)
@@ -137,7 +137,4 @@
   Bool                    m_bMFMEnabledFlag;
 #endif
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  Int                     m_ilSampleOnlyPred;
-#endif
   UInt                    m_numScaledRefLayerOffsets;
 #if O0098_SCALED_REF_LAYER_ID
@@ -153,4 +150,7 @@
   Bool                    m_firstPicInLayerDecodedFlag;
   Bool                    m_noOutputOfPriorPicsFlags;
+#endif
+#if O0194_WEIGHTED_PREDICTION_CGS
+  Bool                    m_interLayerWeightedPredFlag;
 #endif
 #endif //SVC_EXTENSION
@@ -237,7 +237,7 @@
   Bool      getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}    
 #endif
-#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
-  Void      setIlSampleOnlyPred( Int i )          { m_ilSampleOnlyPred = i;    }
-  Int       getIlSampleOnlyPred()                 { return m_ilSampleOnlyPred; }
+#if O0194_WEIGHTED_PREDICTION_CGS
+  Void      setInterLayerWeightedPredFlag(Bool flag)   { m_interLayerWeightedPredFlag = flag; }
+  Bool      getInterLayerWeightedPredFlag()            { return m_interLayerWeightedPredFlag; }
 #endif
 #if AVC_SYNTAX
