Index: /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1236)
+++ /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1237)
@@ -235,7 +235,7 @@
       if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  ||
 #if CONFORMANCE_BITSTREAM_MODE
-        (nalu.m_layerId > m_commonDecoderParams.getTargetLayerId()) )
-#else
-        (nalu.m_layerId > m_tgtLayerId) )
+        (nalu.m_nuhLayerId > m_commonDecoderParams.getTargetLayerId()) )
+#else
+        (nalu.m_nuhLayerId > m_tgtLayerId) )
 #endif
       {
@@ -244,8 +244,8 @@
       else
       {
-        bNewPicture = m_acTDecTop[nalu.m_layerId].decode(nalu, m_iSkipFrame, m_aiPOCLastDisplay[nalu.m_layerId], curLayerId, bNewPOC);
+        bNewPicture = m_acTDecTop[nalu.m_nuhLayerId].decode(nalu, m_iSkipFrame, m_aiPOCLastDisplay[nalu.m_nuhLayerId], curLayerId, bNewPOC);
 
 #if SVC_POC
-        if( (bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() == 3) || (m_acTDecTop[nalu.m_layerId].getParseIdc() == 0) )
+        if( (bNewPicture && m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 3) || (m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 0) )
 #else
         if (bNewPicture)
@@ -267,5 +267,5 @@
         }
 #if SVC_POC
-        else if(m_acTDecTop[nalu.m_layerId].getParseIdc() == 1) 
+        else if(m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 1) 
         {
           bitstreamFile.clear();
@@ -283,9 +283,9 @@
 
 #if SVC_POC
-    if( ( (bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() == 3) || m_acTDecTop[nalu.m_layerId].getParseIdc() == 0 || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) && 
-        !m_acTDecTop[nalu.m_layerId].getFirstSliceInSequence() )
+    if( ( (bNewPicture && m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 3) || m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 0 || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) && 
+        !m_acTDecTop[nalu.m_nuhLayerId].getFirstSliceInSequence() )
 #else
     if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) &&
-        !m_acTDecTop[nalu.m_layerId].getFirstSliceInSequence() )
+        !m_acTDecTop[nalu.m_nuhLayerId].getFirstSliceInSequence() )
 #endif
     {
@@ -302,17 +302,17 @@
       if (nalu.m_nalUnitType == NAL_UNIT_EOS)
       {
-        m_acTDecTop[nalu.m_layerId].setFirstSliceInSequence(true);
+        m_acTDecTop[nalu.m_nuhLayerId].setFirstSliceInSequence(true);
       }
     }
     else if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) &&
-              m_acTDecTop[nalu.m_layerId].getFirstSliceInSequence () ) 
-    {
-      m_acTDecTop[nalu.m_layerId].setFirstSliceInPicture (true);
+              m_acTDecTop[nalu.m_nuhLayerId].getFirstSliceInSequence () ) 
+    {
+      m_acTDecTop[nalu.m_nuhLayerId].setFirstSliceInPicture (true);
     }
 
 #if SVC_POC
-    if( bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() == 0 )
-    {
-      outputAllPictures( nalu.m_layerId, true );
+    if( bNewPicture && m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 0 )
+    {
+      outputAllPictures( nalu.m_nuhLayerId, true );
     }
 #endif
@@ -333,5 +333,5 @@
       Bool outputPicturesFlag = true;  
 
-      if( m_acTDecTop[nalu.m_layerId].getNoOutputPriorPicsFlag() )
+      if( m_acTDecTop[nalu.m_nuhLayerId].getNoOutputPriorPicsFlag() )
       {
         outputPicturesFlag = false;
@@ -340,9 +340,9 @@
       if (nalu.m_nalUnitType == NAL_UNIT_EOS) // End of sequence
       {
-        flushAllPictures( nalu.m_layerId, outputPicturesFlag );       
+        flushAllPictures( nalu.m_nuhLayerId, outputPicturesFlag );       
       }
 
 #if SVC_POC
-      if( bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() != 0 )
+      if( bNewPicture && m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() != 0 )
       // New picture, slice header parsed but picture not decoded
 #else
@@ -356,9 +356,9 @@
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP   )
         {
-          flushAllPictures( nalu.m_layerId, outputPicturesFlag );
+          flushAllPictures( nalu.m_nuhLayerId, outputPicturesFlag );
         }
         else
         {
-          this->checkOutputBeforeDecoding( nalu.m_layerId );
+          this->checkOutputBeforeDecoding( nalu.m_nuhLayerId );
         }
       }
@@ -1242,5 +1242,5 @@
   }
 #if SVC_EXTENSION
-  if (nalu->m_layerId == 0 && (nalu->m_nalUnitType == NAL_UNIT_VPS || nalu->m_nalUnitType == NAL_UNIT_SPS || nalu->m_nalUnitType == NAL_UNIT_PPS || nalu->m_nalUnitType == NAL_UNIT_EOS))
+  if (nalu->m_nuhLayerId == 0 && (nalu->m_nalUnitType == NAL_UNIT_VPS || nalu->m_nalUnitType == NAL_UNIT_SPS || nalu->m_nalUnitType == NAL_UNIT_PPS || nalu->m_nalUnitType == NAL_UNIT_EOS))
   {
     return true;
@@ -1249,5 +1249,5 @@
   for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
   {
-    if ( nalu->m_reservedZero6Bits == (*it) )
+    if ( nalu->m_nuhLayerId == (*it) )
     {
       return true;
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1236)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1237)
@@ -1904,5 +1904,5 @@
       {
         OutputNALUnit nalu(NAL_UNIT_EOB);
-        nalu.m_layerId = 0;
+        nalu.m_nuhLayerId = 0;
 
         AccessUnit& accessUnit = outputAccessUnits.back();
Index: /branches/SHM-dev/source/Lib/TLibCommon/NAL.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/NAL.h	(revision 1236)
+++ /branches/SHM-dev/source/Lib/TLibCommon/NAL.h	(revision 1237)
@@ -50,23 +50,14 @@
   NalUnitType m_nalUnitType; ///< nal_unit_type
   UInt        m_temporalId;  ///< temporal_id
-#if SVC_EXTENSION
-  UInt        m_layerId;   ///< layer id
-#endif
-  UInt        m_reservedZero6Bits; ///< reserved_zero_6bits
+  UInt        m_nuhLayerId;  ///< nuh_layer_id
 
   /** construct an NALunit structure with given header values. */
-  NALUnit(
+NALUnit(
     NalUnitType nalUnitType,
     Int         temporalId = 0,
-#if SVC_EXTENSION
-    UInt        layerId = 0,
-#endif
-    Int         reservedZero6Bits = 0)
+    Int         nuhLayerId = 0)
     :m_nalUnitType (nalUnitType)
     ,m_temporalId  (temporalId)
-#if SVC_EXTENSION
-    ,m_layerId   (layerId)
-#endif
-    ,m_reservedZero6Bits(reservedZero6Bits)
+    ,m_nuhLayerId  (nuhLayerId)
   {}
 
Index: /branches/SHM-dev/source/Lib/TLibDecoder/NALread.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/NALread.cpp	(revision 1236)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/NALread.cpp	(revision 1237)
@@ -110,10 +110,5 @@
   assert(forbidden_zero_bit == 0);
   nalu.m_nalUnitType = (NalUnitType) bs.read(6);  // nal_unit_type
-  nalu.m_reservedZero6Bits = bs.read(6);       // nuh_reserved_zero_6bits
-#if SVC_EXTENSION
-  nalu.m_layerId = nalu.m_reservedZero6Bits;
-#else
-  assert(nalu.m_reservedZero6Bits == 0);
-#endif
+  nalu.m_nuhLayerId = bs.read(6);                 // nuh_layer_id
   nalu.m_temporalId = bs.read(3) - 1;             // nuh_temporal_id_plus1
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
@@ -121,7 +116,31 @@
 #endif
 
-  if ( nalu.m_temporalId )
+  // only check these rules for base layer
+  if (nalu.m_nuhLayerId == 0)
   {
+    if ( nalu.m_temporalId )
+    {
+      assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
+           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
+           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP
+           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL
+           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP
+           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
+           && nalu.m_nalUnitType != NAL_UNIT_VPS
+           && nalu.m_nalUnitType != NAL_UNIT_SPS
+           && nalu.m_nalUnitType != NAL_UNIT_EOS
+           && nalu.m_nalUnitType != NAL_UNIT_EOB );
+    }
+    else
+    {
+      assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
+           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
+           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
+           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N );
+    }
+  }
 #if SVC_EXTENSION
+  else if ( nalu.m_temporalId )
+  {
     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
@@ -133,30 +152,12 @@
          && nalu.m_nalUnitType != NAL_UNIT_SPS
          && nalu.m_nalUnitType != NAL_UNIT_EOS);
-#else
-    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
-         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
-         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP
-         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL
-         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP
-         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
-         && nalu.m_nalUnitType != NAL_UNIT_VPS
-         && nalu.m_nalUnitType != NAL_UNIT_SPS
-         && nalu.m_nalUnitType != NAL_UNIT_EOS
-         && nalu.m_nalUnitType != NAL_UNIT_EOB ); 
-#endif
   }
   else
   {
-#if SVC_EXTENSION
     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
          );
-#else
-    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
-         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
-         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
-         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N );
+  }
 #endif
-  }
 }
 /**
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1236)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1237)
@@ -1006,5 +1006,5 @@
 #else
   READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
-  READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
+  READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );
 #endif
   READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 );    assert(uiCode+1 <= MAX_TLAYER);
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1236)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1237)
@@ -723,5 +723,5 @@
 {
 #if SVC_EXTENSION
-  m_apcSlicePilot->initSlice( nalu.m_layerId );
+  m_apcSlicePilot->initSlice( nalu.m_nuhLayerId );
   m_apcSlicePilot->setTLayer( nalu.m_temporalId );
 #else //SVC_EXTENSION
@@ -768,5 +768,5 @@
   if( !vps->getBaseLayerAvailableFlag() )
   {
-    assert( nalu.m_layerId != 0 );
+    assert( nalu.m_nuhLayerId != 0 );
     assert( vps->getNumAddLayerSets() > 0 );
 
@@ -1512,6 +1512,6 @@
 
 #if SVC_EXTENSION
-  m_pcPic->setLayerId(nalu.m_layerId);
-  pcSlice->setLayerId(nalu.m_layerId);
+  m_pcPic->setLayerId(nalu.m_nuhLayerId);
+  pcSlice->setLayerId(nalu.m_nuhLayerId);
   pcSlice->setPic(m_pcPic);
 #endif
@@ -1928,4 +1928,12 @@
 #endif
 {
+#if !SVC_EXTENSION
+  // ignore all NAL units of layers > 0
+  if (nalu.m_nuhLayerId > 0)
+  {
+    fprintf (stderr, "Warning: found NAL unit with nuh_layer_id equal to %d. Ignoring.\n", nalu.m_nuhLayerId);
+    return false;
+  }
+#endif
   // Initialize entropy decoder
   m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
@@ -1934,5 +1942,5 @@
 #if SVC_EXTENSION
   // ignore any NAL units with nuh_layer_id == 63
-  if( nalu.m_layerId == 63 )
+  if( nalu.m_nuhLayerId == 63 )
   {  
     return false;
@@ -1943,5 +1951,5 @@
     case NAL_UNIT_VPS:
 #if SVC_EXTENSION
-      assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
+      assert( nalu.m_nuhLayerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
 #endif
       xDecodeVPS(nalu.m_Bitstream->getFifo());
@@ -2041,5 +2049,5 @@
 #if SVC_EXTENSION
       //Check layer id of the nalu. if it is not 0, give a warning message.
-      if (nalu.m_layerId > 0)
+      if (nalu.m_nuhLayerId > 0)
       {
         printf( "\n\nThis bitstream is ended with EOB NALU that has layer id greater than 0\n" );
Index: /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.cpp	(revision 1236)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.cpp	(revision 1237)
@@ -53,9 +53,5 @@
   bsNALUHeader.write(0,1);                    // forbidden_zero_bit
   bsNALUHeader.write(nalu.m_nalUnitType, 6);  // nal_unit_type
-#if SVC_EXTENSION
-  bsNALUHeader.write(nalu.m_layerId, 6); // reserved_one_5bits
-#else
-  bsNALUHeader.write(nalu.m_reservedZero6Bits, 6);                   // nuh_reserved_zero_6bits
-#endif
+  bsNALUHeader.write(nalu.m_nuhLayerId, 6);   // nuh_layer_id
   bsNALUHeader.write(nalu.m_temporalId+1, 3); // nuh_temporal_id_plus1
 
Index: /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.h	(revision 1236)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.h	(revision 1237)
@@ -61,9 +61,10 @@
     UInt temporalID = 0,
 #if SVC_EXTENSION
-    UInt     layerId = 0,
+    UInt     layerId = 0)
+#else
+    UInt reserved_zero_6bits = 0)
 #endif
-    UInt reserved_zero_6bits = 0)
 #if SVC_EXTENSION
-  : NALUnit(nalUnitType, temporalID, layerId, reserved_zero_6bits)
+  : NALUnit(nalUnitType, temporalID, layerId)
 #else
   : NALUnit(nalUnitType, temporalID, reserved_zero_6bits)
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1236)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1237)
@@ -785,5 +785,5 @@
 #else
   WRITE_CODE( 3,                                    2,        "vps_reserved_three_2bits" );
-  WRITE_CODE( 0,                                    6,        "vps_reserved_zero_6bits" );
+  WRITE_CODE( 0,                                    6,        "vps_max_layers_minus1" );
 #endif
   WRITE_CODE( pcVPS->getMaxTLayers() - 1,           3,        "vps_max_sub_layers_minus1" );
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1236)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1237)
@@ -2139,5 +2139,5 @@
       {
         // For independent base layer rewriting
-        nalu.m_layerId = 0; 
+        nalu.m_nuhLayerId = 0; 
       }
 #else
@@ -2163,5 +2163,5 @@
       {
         // For independent base layer rewriting
-        nalu.m_layerId = 0;
+        nalu.m_nuhLayerId = 0;
       }
 #else
