Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1198)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1199)
@@ -1844,12 +1844,8 @@
   {
     // Derive the value of PocMsbValRequiredFlag
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     slice->setPocMsbValRequiredFlag( (slice->getCraPicFlag() || slice->getBlaPicFlag())
                                   && (!slice->getVPS()->getVpsPocLsbAlignedFlag() ||
                                       (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0))
                                    );
-#else
-    slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag() );
-#endif
 
     // Determine value of SH extension length.
@@ -1868,10 +1864,5 @@
     }
 
-
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag())
-#else
-    if (!slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */)
-#endif
     {
       shExtnLengthInBit++;
@@ -1889,10 +1880,8 @@
     }
 
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     if (slice->getPocMsbNeeded())
     {
       slice->setPocMsbValPresentFlag(true);
     }
-#endif
 
     if (slice->getPocMsbValPresentFlag())
@@ -1930,25 +1919,15 @@
     }
 
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-    if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag())
-#else
-    if (!slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */)
-#endif
-    {
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
+    if( !slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag() )
+    {
       WRITE_FLAG( slice->getPocMsbValPresentFlag(),                           "poc_msb_cycle_val_present_flag" );
-#else
-      WRITE_FLAG( slice->getPocMsbValPresentFlag(),                           "poc_msb_val_present_flag" );
-#endif
-    }
-    if (slice->getPocMsbValPresentFlag())
+    }
+
+    if( slice->getPocMsbValPresentFlag() )
     {
       assert(slice->getPocMsbVal() % maxPocLsb == 0);
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
       WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_cycle_val");
-#else
-      WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_val");
-#endif
-    }
+    }
+
     for (Int i = 0; i < shExtnAdditionalBits; i++)
     {
@@ -1956,4 +1935,5 @@
     }
   }
+
   shBitsWrittenTillNow += ( getNumberOfWrittenBits() - tmpBitsBeforeWriting );
   
@@ -2189,7 +2169,6 @@
 
   WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
+
   WRITE_FLAG(vps->getVpsPocLsbAlignedFlag(), "vps_poc_lsb_aligned_flag");
-#endif
 
   for( i = 1; i< vps->getMaxLayers(); i++ )
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1198)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1199)
@@ -49,5 +49,5 @@
 #include <time.h>
 #include <math.h>
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
+#if SVC_EXTENSION
 #include <limits.h>
 #endif
@@ -1146,5 +1146,4 @@
     determinePocResetIdc(pocCurr, pcSlice);
 
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     Bool pocResettingFlag = false;
 
@@ -1164,12 +1163,7 @@
       }
     }
-#endif
 
     // If reset, do the following steps:
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     if( pocResettingFlag )
-#else
-    if( pcSlice->getPocResetIdc() )
-#endif
     {
       updatePocValuesOfPics(pocCurr, pcSlice);
@@ -3457,8 +3451,7 @@
 #if SVC_EXTENSION
     pcPicYuvRecOut->setReconstructed(true);
-#endif
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     m_pcEncTop->setFirstPicInLayerDecodedFlag(true);
 #endif
+
     pcPic->setReconMark   ( true );
     m_bFirst = false;
@@ -4643,5 +4636,4 @@
 #endif
 
-
 #if POC_RESET_IDC_ENCODER
 Void TEncGOP::determinePocResetIdc(Int const pocCurr, TComSlice *const slice)
@@ -4650,7 +4642,6 @@
   // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2
   // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2.
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
   slice->setPocMsbNeeded(false);
-#endif
+
   if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices
   {
@@ -4678,5 +4669,5 @@
       }
     }
-    
+
     if( !needReset )// No need reset due to base layer IRAP
     {
@@ -4685,6 +4676,6 @@
       {
         Bool idrFlag = ( (m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() == 2) 
-                        && ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
-                        );
+          && ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
+          );
         for(Int j = 0; j < slice->getVPS()->getMaxLayers(); j++)
         {
@@ -4695,6 +4686,6 @@
 
           Bool idrOtherPicFlag = ( (m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshType() == 2) 
-                                  && ( pocCurr % m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
-                                  );
+            && ( pocCurr % m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
+            );
 
           if( idrFlag != idrOtherPicFlag )
@@ -4713,10 +4704,9 @@
         {
           slice->setPocResetIdc( 2 ); // Full reset needed
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-          if (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0)
+
+          if( slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0 )
           {
             slice->setPocMsbNeeded(true);  // Force msb writing
           }
-#endif
         }
         else
@@ -4736,10 +4726,8 @@
         m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ;
 
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-        for (UInt i = 0; i < MAX_LAYERS; i++)
+        for( UInt i = 0; i < MAX_LAYERS; i++ )
         {
           m_ppcTEncTop[i]->setPocDecrementedInDPBFlag(false);
         }
-#endif
       }
       else
@@ -4758,5 +4746,4 @@
 Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice)
 {
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
   UInt affectedLayerList[MAX_NUM_LAYER_IDS];
   Int  numAffectedLayers;
@@ -4773,5 +4760,4 @@
     numAffectedLayers = m_pcEncTop->getVPS()->getNumPredictedLayers(m_layerId) + 1;
   }
-#endif
 
   Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
@@ -4782,145 +4768,116 @@
   maxPocLsb   = 1 << slice->getSPS()->getBitsForPOC();
 
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
   Int adjustedPocValue = pocCurr;
 
   if (m_pcEncTop->getFirstPicInLayerDecodedFlag())
   {
-#endif
-
-  pocLsbVal   = (slice->getPocResetIdc() == 3)
-                ? slice->getPocLsbVal()
-                : pocAdjustValue % maxPocLsb; 
-  pocMsbDelta = pocAdjustValue - pocLsbVal;
-  pocLsbDelta = (slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() )) 
-                ? pocLsbVal 
-                : 0; 
-  deltaPocVal = pocMsbDelta  + pocLsbDelta;
-
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-  Int origDeltaPocVal = deltaPocVal;  // original value needed when updating POC adjustment value
-
-  if (slice->getPocMsbNeeded())  // IDR picture in base layer, non-IDR picture in other layers, poc_lsb_aligned_flag = 1
-  {
-    if (slice->getLayerId() == 0)
-    {
-      Int highestPoc = INT_MIN;
-      // Find greatest POC in DPB for layer 0
-      for (TComList<TComPic*>::iterator iterPic = m_pcEncTop->getListPic()->begin(); iterPic != m_pcEncTop->getListPic()->end(); ++iterPic)
-      {
-        TComPic *dpbPic = *iterPic;
-        if (dpbPic->getReconMark() && dpbPic->getLayerId() == 0 && dpbPic->getPOC() > highestPoc)
-        {
-          highestPoc = dpbPic->getPOC();
-        }
-      }
-      deltaPocVal = (highestPoc - (highestPoc & (maxPocLsb - 1))) + 1*maxPocLsb;
-      m_pcEncTop->setCurrPocMsb(deltaPocVal);
-    }
-    else
-    {
-      deltaPocVal = m_ppcTEncTop[0]->getCurrPocMsb();  // copy from base layer
-    }
-    slice->setPocMsbVal(deltaPocVal);
-  }
-
-  for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++)
-  {
-    UInt lIdx = slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx]);
-
-    if (!m_ppcTEncTop[lIdx]->getPocDecrementedInDPBFlag())
-    {
-      m_ppcTEncTop[lIdx]->setPocDecrementedInDPBFlag(true);
-
-      // Decrement value of associatedIrapPoc of the TEncGop object
-      m_ppcTEncTop[lIdx]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal;
-
-      // Decrememnt the value of m_pocCRA
-      m_ppcTEncTop[lIdx]->getGOPEncoder()->m_pocCRA -= deltaPocVal;
-
-      TComList<TComPic*>::iterator  iterPic = m_ppcTEncTop[lIdx]->getListPic()->begin();
-      while (iterPic != m_ppcTEncTop[lIdx]->getListPic()->end())
-#else
-  // Decrement value of associatedIrapPoc of the TEncGop object
-  this->m_associatedIRAPPOC -= deltaPocVal;
-
-  // Decrememnt the value of m_pocCRA
-  this->m_pocCRA -= deltaPocVal;
-
-  // Iterate through all pictures in the DPB
-  TComList<TComPic*>::iterator  iterPic = getListPic()->begin();  
-  while( iterPic != getListPic()->end() )
-#endif
-  {
-    TComPic *dpbPic = *iterPic;
-    
-    if( dpbPic->getReconMark() )
-    {
-      for(Int i = dpbPic->getNumAllocatedSlice() - 1; i >= 0; i--)
-      {
-        TComSlice *dpbPicSlice = dpbPic->getSlice( i );
-        TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS();
-
-        // Decrement POC of slice
-        dpbPicSlice->setPOC( dpbPicSlice->getPOC() - deltaPocVal );
-
-        // Decrement POC value stored in the RPS of each such slice
-        for( Int j = dpbPicRps->getNumberOfPictures() - 1; j >= 0; j-- )
-        {
-          dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal );
-        }
-
-        // Decrement value of refPOC
-        dpbPicSlice->decrementRefPocValues( deltaPocVal );
-
-        // Update value of associatedIrapPoc of each slice
-        dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal );
-
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-        if (slice->getPocMsbNeeded())
-        {
-          // this delta value is needed when computing delta POCs in reference picture set initialization
-          dpbPicSlice->setPocResetDeltaPoc(dpbPicSlice->getPocResetDeltaPoc() + (deltaPocVal - pocLsbVal));
-        }
-#endif
-      }
-    }
-    iterPic++;
-  }
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-    }
-  }
-#endif
-
-  // Actual POC value before reset
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-  adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
-#else
-  Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
-#endif
-
-  // Set MSB value before reset
-  Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1);
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-  if (!slice->getPocMsbNeeded())  // set poc msb normally if special msb handling is not needed
-  {
-#endif
-    slice->setPocMsbVal(adjustedPocValue - tempLsbVal);
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-  }
-#endif
-
-  // Set LSB value before reset - this is needed in the case of resetIdc = 2
-  slice->setPicOrderCntLsb( tempLsbVal );
-
-  // Cumulative delta
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-  deltaPocVal = origDeltaPocVal;  // restore deltaPoc for correct adjustment value update
-#endif
-  m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal );
-
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
-  }
-#endif
+    pocLsbVal   = (slice->getPocResetIdc() == 3)
+      ? slice->getPocLsbVal()
+      : pocAdjustValue % maxPocLsb; 
+    pocMsbDelta = pocAdjustValue - pocLsbVal;
+    pocLsbDelta = (slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() )) 
+      ? pocLsbVal 
+      : 0; 
+    deltaPocVal = pocMsbDelta  + pocLsbDelta;
+
+    Int origDeltaPocVal = deltaPocVal;  // original value needed when updating POC adjustment value
+
+    // IDR picture in base layer, non-IDR picture in other layers, poc_lsb_aligned_flag = 1
+    if( slice->getPocMsbNeeded() )
+    {
+      if (slice->getLayerId() == 0)
+      {
+        Int highestPoc = INT_MIN;
+
+        // Find greatest POC in DPB for layer 0
+        for (TComList<TComPic*>::iterator iterPic = m_pcEncTop->getListPic()->begin(); iterPic != m_pcEncTop->getListPic()->end(); ++iterPic)
+        {
+          TComPic *dpbPic = *iterPic;
+          if (dpbPic->getReconMark() && dpbPic->getLayerId() == 0 && dpbPic->getPOC() > highestPoc)
+          {
+            highestPoc = dpbPic->getPOC();
+          }
+        }
+        deltaPocVal = (highestPoc - (highestPoc & (maxPocLsb - 1))) + 1*maxPocLsb;
+        m_pcEncTop->setCurrPocMsb(deltaPocVal);
+      }
+      else
+      {
+        deltaPocVal = m_ppcTEncTop[0]->getCurrPocMsb();  // copy from base layer
+      }
+      slice->setPocMsbVal(deltaPocVal);
+    }
+
+    for( UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++ )
+    {
+      UInt lIdx = slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx]);
+
+      if( !m_ppcTEncTop[lIdx]->getPocDecrementedInDPBFlag() )
+      {
+        m_ppcTEncTop[lIdx]->setPocDecrementedInDPBFlag(true);
+
+        // Decrement value of associatedIrapPoc of the TEncGop object
+        m_ppcTEncTop[lIdx]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal;
+
+        // Decrememnt the value of m_pocCRA
+        m_ppcTEncTop[lIdx]->getGOPEncoder()->m_pocCRA -= deltaPocVal;
+
+        TComList<TComPic*>::iterator  iterPic = m_ppcTEncTop[lIdx]->getListPic()->begin();
+        while (iterPic != m_ppcTEncTop[lIdx]->getListPic()->end())
+        {
+          TComPic *dpbPic = *iterPic;
+
+          if( dpbPic->getReconMark() )
+          {
+            for( Int i = dpbPic->getNumAllocatedSlice() - 1; i >= 0; i-- )
+            {
+              TComSlice *dpbPicSlice = dpbPic->getSlice( i );
+              TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS();
+
+              // Decrement POC of slice
+              dpbPicSlice->setPOC( dpbPicSlice->getPOC() - deltaPocVal );
+
+              // Decrement POC value stored in the RPS of each such slice
+              for( Int j = dpbPicRps->getNumberOfPictures() - 1; j >= 0; j-- )
+              {
+                dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal );
+              }
+
+              // Decrement value of refPOC
+              dpbPicSlice->decrementRefPocValues( deltaPocVal );
+
+              // Update value of associatedIrapPoc of each slice
+              dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal );
+
+              if( slice->getPocMsbNeeded() )
+              {
+                // this delta value is needed when computing delta POCs in reference picture set initialization
+                dpbPicSlice->setPocResetDeltaPoc(dpbPicSlice->getPocResetDeltaPoc() + (deltaPocVal - pocLsbVal));
+              }
+            }
+          }
+          iterPic++;
+        }
+      }
+    }
+
+    // Actual POC value before reset
+    adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
+
+    // Set MSB value before reset
+    Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1);
+    if (!slice->getPocMsbNeeded())  // set poc msb normally if special msb handling is not needed
+    {
+      slice->setPocMsbVal(adjustedPocValue - tempLsbVal);
+    }
+
+    // Set LSB value before reset - this is needed in the case of resetIdc = 2
+    slice->setPicOrderCntLsb( tempLsbVal );
+
+    // Cumulative delta
+    deltaPocVal = origDeltaPocVal;  // restore deltaPoc for correct adjustment value update
+
+    m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal );
+  }
 
   // New LSB value, after reset
@@ -4940,7 +4897,7 @@
   {
     Int picOrderCntMsb = slice->getCurrMsb( newLsbVal, 
-                                        slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 
-                                        0,
-                                        maxPocLsb );
+      slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 
+      0,
+      maxPocLsb );
     slice->setPOC( picOrderCntMsb + newLsbVal );
   }
@@ -4951,5 +4908,4 @@
 }
 #endif
-
 
 #if O0164_MULTI_LAYER_HRD
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1198)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1199)
@@ -94,7 +94,5 @@
   m_noOutputOfPriorPicsFlags   = false;
 #endif
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
   m_pocDecrementedInDPBFlag    = false;
-#endif
 #endif //SVC_EXTENSION
 }
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 1198)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 1199)
@@ -148,8 +148,6 @@
 #endif
   Int                     m_numAddLayerSets;
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
   Bool                    m_pocDecrementedInDPBFlag;
   Int                     m_currPocMsb;
-#endif
   Bool                    m_prevPicHasEos;
 #endif //SVC_EXTENSION
@@ -270,10 +268,8 @@
   Void      setNumAddLayerSets(Int x)             { m_numAddLayerSets = x; }
   Int       getNumAddLayerSets()                  { return m_numAddLayerSets; }
-#if P0297_VPS_POC_LSB_ALIGNED_FLAG
   Void      setPocDecrementedInDPBFlag(Bool x)    { m_pocDecrementedInDPBFlag = x; }
   Bool      getPocDecrementedInDPBFlag()          { return m_pocDecrementedInDPBFlag; }
   Void      setCurrPocMsb(Int poc)                { m_currPocMsb = poc; }
   Int       getCurrPocMsb()                       { return m_currPocMsb; }
-#endif
 #else //SVC_EXTENSION
   Void encode( Bool bEos,
