Index: /branches/SHM-upgrade/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-upgrade/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1009)
+++ /branches/SHM-upgrade/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1010)
@@ -1291,8 +1291,4 @@
 #endif
     m_acTEncTop[layer].init(isFieldCoding);
-#if P0182_VPS_VUI_PS_FLAG
-    m_acTEncTop[layer].getVPS()->setSPSId(layer, m_acTEncTop[layer].getSPS()->getSPSId());
-    m_acTEncTop[layer].getVPS()->setPPSId(layer, m_acTEncTop[layer].getPPS()->getPPSId());
-#endif
   }
 
Index: /branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.h	(revision 1009)
+++ /branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.h	(revision 1010)
@@ -903,6 +903,4 @@
 
 #if P0182_VPS_VUI_PS_FLAG
-  UInt       m_SPSId[MAX_LAYERS];
-  UInt       m_PPSId[MAX_LAYERS];
   UInt       m_baseLayerPSCompatibilityFlag[MAX_LAYERS];
 #endif
@@ -1355,8 +1353,4 @@
 #endif
 #if P0182_VPS_VUI_PS_FLAG
-  Int    getSPSId       (Int layer)                   { return m_SPSId[layer];       }
-  Void   setSPSId       (Int layer, Int val)          { m_SPSId[layer] = val;        }
-  Int    getPPSId       (Int layer)                   { return m_PPSId[layer];       }
-  Void   setPPSId       (Int layer, Int val)          { m_PPSId[layer] = val;        }
   Void   setBaseLayerPSCompatibilityFlag (Int layer, int val)        { m_baseLayerPSCompatibilityFlag[layer] = val; }
   Int    getBaseLayerPSCompatibilityFlag (Int layer)   { return m_baseLayerPSCompatibilityFlag[layer];}
Index: /branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1009)
+++ /branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1010)
@@ -763,4 +763,26 @@
 #endif
     }
+
+#if P0182_VPS_VUI_PS_FLAG
+    UInt layerIdx = activeVPS->getLayerIdInVps( m_layerId );
+
+    if( activeVPS->getBaseLayerPSCompatibilityFlag(layerIdx) )
+    {
+      RepFormat* repFormat = activeVPS->getVpsRepFormat(activeVPS->getVpsRepFormatIdx(layerIdx));
+
+      assert( pps->getLayerId() == 0 );
+      assert( sps->getLayerId() == 0 );
+      assert( repFormat->getChromaFormatVpsIdc() == sps->getChromaFormatIdc() );
+      assert( repFormat->getSeparateColourPlaneVpsFlag() == 0 );
+      assert( repFormat->getPicHeightVpsInLumaSamples() == sps->getPicHeightInLumaSamples() );
+      assert( repFormat->getPicWidthVpsInLumaSamples()  == sps->getPicWidthInLumaSamples() );
+      assert( repFormat->getBitDepthVpsLuma()   == sps->getBitDepth(CHANNEL_TYPE_LUMA) );
+      assert( repFormat->getBitDepthVpsChroma() == sps->getBitDepth(CHANNEL_TYPE_CHROMA) );
+      assert( repFormat->getConformanceWindowVps().getWindowLeftOffset()   == sps->getConformanceWindow().getWindowLeftOffset() );
+      assert( repFormat->getConformanceWindowVps().getWindowRightOffset()  == sps->getConformanceWindow().getWindowRightOffset() );
+      assert( repFormat->getConformanceWindowVps().getWindowTopOffset()    == sps->getConformanceWindow().getWindowTopOffset() );
+      assert( repFormat->getConformanceWindowVps().getWindowBottomOffset() == sps->getConformanceWindow().getWindowBottomOffset() );
+    }    
+#endif
   }
 #endif
Index: /branches/SHM-upgrade/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-upgrade/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1009)
+++ /branches/SHM-upgrade/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1010)
@@ -3109,12 +3109,4 @@
       if( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0 ) 
       {
-        if( (vps->getSPSId(i) == 0) && (vps->getPPSId(i) == 0) )
-        {
-          vps->setBaseLayerPSCompatibilityFlag(i, 1);
-        }
-        else
-        {
-          vps->setBaseLayerPSCompatibilityFlag(i, 0);
-        }
         WRITE_FLAG(vps->getBaseLayerPSCompatibilityFlag(i), "base_layer_parameter_set_compatibility_flag" );
       }
Index: /branches/SHM-upgrade/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- /branches/SHM-upgrade/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1009)
+++ /branches/SHM-upgrade/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1010)
@@ -1639,4 +1639,32 @@
       }
     }
+
+#if P0182_VPS_VUI_PS_FLAG
+    if( m_cVPS.getNumRefLayers( m_layerId ) == 0 )
+    {
+      UInt layerIdx = m_cVPS.getLayerIdInVps( m_layerId );
+      RepFormat* repFormat = m_cVPS.getVpsRepFormat(m_cVPS.getVpsRepFormatIdx(layerIdx));
+      
+      if( m_cPPS.getLayerId() == 0 && 
+          m_cSPS.getLayerId() == 0 &&
+          repFormat->getChromaFormatVpsIdc() == m_cSPS.getChromaFormatIdc() &&
+          repFormat->getSeparateColourPlaneVpsFlag() == 0 &&
+          repFormat->getPicHeightVpsInLumaSamples() == m_cSPS.getPicHeightInLumaSamples() &&
+          repFormat->getPicWidthVpsInLumaSamples()  == m_cSPS.getPicWidthInLumaSamples() &&
+          repFormat->getBitDepthVpsLuma()   == m_cSPS.getBitDepth(CHANNEL_TYPE_LUMA) &&
+          repFormat->getBitDepthVpsChroma() == m_cSPS.getBitDepth(CHANNEL_TYPE_CHROMA) &&
+          repFormat->getConformanceWindowVps().getWindowLeftOffset()   == m_cSPS.getConformanceWindow().getWindowLeftOffset() &&
+          repFormat->getConformanceWindowVps().getWindowRightOffset()  == m_cSPS.getConformanceWindow().getWindowRightOffset() &&
+          repFormat->getConformanceWindowVps().getWindowTopOffset()    == m_cSPS.getConformanceWindow().getWindowTopOffset() &&
+          repFormat->getConformanceWindowVps().getWindowBottomOffset() == m_cSPS.getConformanceWindow().getWindowBottomOffset() )
+      {
+        m_cVPS.setBaseLayerPSCompatibilityFlag(layerIdx, 1);
+      }
+      else
+      {
+        m_cVPS.setBaseLayerPSCompatibilityFlag(layerIdx, 0);
+      }
+    }
+#endif
   }
 }
