Index: /branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1523)
+++ /branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1524)
@@ -170,5 +170,5 @@
   if( targetLayerId < 0 )
   {
-    targetLayerId = layerNum - 1;
+    targetLayerId = MAX_VPS_LAYER_IDX_PLUS1 - 1;
   }
 
Index: /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1523)
+++ /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1524)
@@ -91,5 +91,5 @@
   for(Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1; i++ )
 #else
-  for( Int i = 0; i <= m_tgtLayerId; i++ )
+  for( Int i = 0; i <= m_commonDecoderParams.getTargetLayerId(); i++ )
 #endif
   {
@@ -179,5 +179,5 @@
   for(UInt layer = 0; layer < MAX_VPS_LAYER_IDX_PLUS1; layer++)
 #else
-  for(UInt layer=0; layer<=m_tgtLayerId; layer++)
+  for(UInt layer=0; layer <= m_commonDecoderParams.getTargetLayerId(); layer++)
 #endif
   {
@@ -234,5 +234,4 @@
       read(nalu);
 
-#if SVC_EXTENSION
       // ignore any NAL units with nuh_layer_id == 63
       if( nalu.m_nuhLayerId == 63 )
@@ -241,12 +240,6 @@
         continue;
       }
-#endif
-
-      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  ||
-#if CONFORMANCE_BITSTREAM_MODE
-        (nalu.m_nuhLayerId > m_commonDecoderParams.getTargetLayerId()) )
-#else
-        (nalu.m_nuhLayerId > m_tgtLayerId) )
-#endif
+
+      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) || nalu.m_nuhLayerId > m_commonDecoderParams.getTargetLayerId() )
       {
         bNewPicture = false;
@@ -422,8 +415,8 @@
   for(UInt layer = layerIdxmin; layer < MAX_VPS_LAYER_IDX_PLUS1; layer++)
 #else
-  for(UInt layer = layerIdxmin; layer <= m_tgtLayerId; layer++)
-#endif
-#else
-  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+  for(UInt layer = layerIdxmin; layer <= m_commonDecoderParams.getTargetLayerId(); layer++)
+#endif
+#else
+  for(UInt layer = 0; layer <= m_commonDecoderParams.getTargetLayerId(); layer++)
 #endif
   {
@@ -583,5 +576,5 @@
   for(UInt layer = 0; layer < MAX_VPS_LAYER_IDX_PLUS1; layer++)
 #else
-  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+  for(UInt layer = 0; layer <= m_commonDecoderParams.getTargetLayerId(); layer++)
 #endif
   {
@@ -612,5 +605,5 @@
   for(UInt layer = 0; layer < MAX_VPS_LAYER_IDX_PLUS1; layer++)
 #else
-  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+  for(UInt layer = 0; layer <= m_commonDecoderParams.getTargetLayerId(); layer++)
 #endif
   {
@@ -646,5 +639,5 @@
   for(UInt layer = 0; layer < MAX_VPS_LAYER_IDX_PLUS1; layer++)
 #else
-  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
+  for(UInt layer = 0; layer <= m_commonDecoderParams.getTargetLayerId(); layer++)
 #endif
   {
@@ -665,10 +658,7 @@
 #if SVC_EXTENSION  
 #if CONFORMANCE_BITSTREAM_MODE
-    m_cTDecTop.setNumLayer( MAX_LAYERS );
-#else
-    m_cTDecTop.setNumLayer( m_tgtLayerId + 1 );
+    m_cTDecTop.setConfModeFlag( m_confModeFlag );
 #endif
     m_cTDecTop.setCommonDecoderParams( &m_commonDecoderParams );
-    m_cTDecTop.setConfModeFlag( m_confModeFlag );
   }
 #endif
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1523)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1524)
@@ -121,8 +121,5 @@
 #if SVC_EXTENSION
 TAppEncCfg::TAppEncCfg()
-#if AVC_BASE
-: m_nonHEVCBaseLayerFlag(false)
-#endif
-, m_maxTidRefPresentFlag(1)
+: m_maxTidRefPresentFlag(1)
 , m_defaultTargetOutputLayerIdc (-1)
 , m_numOutputLayerSets          (-1)
@@ -131,4 +128,7 @@
 , m_outputInternalColourSpace(false)
 , m_elRapSliceBEnabled(false)
+#if AVC_BASE
+, m_nonHEVCBaseLayerFlag(false)
+#endif
 {
   memset( m_apcLayerCfg, 0, sizeof(m_apcLayerCfg) );
@@ -3130,5 +3130,9 @@
     ii++;
   }
+#if AVC_BASE
   if( m_numLayers > 1 && m_numPTLInfo > 1 && !m_nonHEVCBaseLayerFlag )
+#else
+  if( m_numLayers > 1 && m_numPTLInfo > 1 )
+#endif
   {
     assert(m_profileList[0] <= Profile::MULTIVIEWMAIN);  //Profile IDC of PTL in VPS shall be one of single-layer profile IDCs
@@ -3506,5 +3510,5 @@
   m_numLayers = m_numLayers > MAX_LAYERS ? MAX_LAYERS : m_numLayers;
   
-  // it can be updated after AVC BL support will be added to the WD
+#if AVC_BASE
   if( m_nonHEVCBaseLayerFlag )
   {
@@ -3513,4 +3517,5 @@
     m_crossLayerAlignedIdrOnlyFlag = false;
   }
+#endif
 
   // verify layer configuration parameters
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1523)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1524)
@@ -118,7 +118,4 @@
   Int       m_numLayers;                                      ///< number of layers
   Int       m_scalabilityMask[MAX_VPS_NUM_SCALABILITY_TYPES]; ///< scalability_mask
-#if AVC_BASE
-  Bool      m_nonHEVCBaseLayerFlag;                           ///< non HEVC BL
-#endif
   Bool      m_maxTidRefPresentFlag; 
 
@@ -542,4 +539,7 @@
   Bool      m_altOutputLayerFlag;                             ///< Specifies the value of alt_output_laye_flag in VPS extension
   Bool      m_elRapSliceBEnabled;
+#if AVC_BASE
+  Bool      m_nonHEVCBaseLayerFlag;                           ///< non HEVC BL
+#endif
 #endif
 
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1523)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1524)
@@ -249,5 +249,9 @@
     //1
     m_cTEncTop.setInterLayerWeightedPredFlag                      ( m_useInterLayerWeightedPred );
+#if AVC_BASE
     m_cTEncTop.setMFMEnabledFlag                                  ( layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_apcLayerCfg[layer]->getNumMotionPredRefLayers());
+#else
+    m_cTEncTop.setMFMEnabledFlag                                  ( layer == 0 ? false : m_apcLayerCfg[layer]->getNumMotionPredRefLayers());
+#endif
 
     // set layer ID
@@ -1059,10 +1063,8 @@
 #if AVC_BASE
   vps->setNonHEVCBaseLayerFlag( m_nonHEVCBaseLayerFlag );
-  if ( m_nonHEVCBaseLayerFlag )
-  {
-    vps->setBaseLayerInternalFlag (false);
-  }
-#else
-  vps->setAvcBaseLayerFlag(false);
+  if( m_nonHEVCBaseLayerFlag )
+  {
+    vps->setBaseLayerInternalFlag(false);
+  }
 #endif
   
@@ -1607,8 +1609,10 @@
     {
       list<AccessUnit>::iterator first_au = outputAccessUnits.begin();
+#if AVC_BASE
       if( m_nonHEVCBaseLayerFlag )
       {
         first_au++;
       }
+#endif
       AccessUnit::iterator it_sps;
       for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++)
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1523)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1524)
@@ -1879,5 +1879,5 @@
   ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag));
 
-  ::memset(m_directDependencyFlag, 0, sizeof(m_directDependencyFlag));
+  ::memset(m_directDependencyFlag, false, sizeof(m_directDependencyFlag));
   ::memset(m_numDirectRefLayers,   0, sizeof(m_numDirectRefLayers  ));
   ::memset(m_refLayerId,           0, sizeof(m_refLayerId          ));
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1523)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1524)
@@ -2294,7 +2294,12 @@
 Void TDecTop::setRefLayerParams( const TComVPS* vps )
 {
-  for(UInt layerIdx = 0; layerIdx < m_numLayer; layerIdx++)
-  {
-    TDecTop *decTop = (TDecTop *)getLayerDec(vps->getLayerIdInNuh(layerIdx));
+#if CONFORMANCE_BITSTREAM_MODE
+  for(UInt layerIdx = 0; layerIdx < MAX_VPS_LAYER_IDX_PLUS1; layerIdx++)
+#else
+  for(UInt layerIdx = 0; layerIdx <= m_commonDecoderParams->getTargetLayerId(); layerIdx++)
+#endif
+  {
+    UInt layerId = vps->getLayerIdInNuh(layerIdx);
+    TDecTop *decTop = m_ppcTDecTop[layerId];
     decTop->setNumSamplePredRefLayers(0);
     decTop->setNumMotionPredRefLayers(0);
@@ -2305,5 +2310,5 @@
       if (vps->getDirectDependencyFlag(layerIdx, j))
       {
-        decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layerIdx));
+        decTop->setRefLayerId(decTop->getNumDirectRefLayers(), layerId);
         decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1);
 
@@ -2320,5 +2325,5 @@
 Void TDecTop::checkValueOfTargetOutputLayerSetIdx(TComVPS *vps)
 {
-  CommonDecoderParams* params = this->getCommonDecoderParams();
+  CommonDecoderParams* params = m_commonDecoderParams;
 
   if( params->getValueCheckedFlag() )
@@ -2390,7 +2395,4 @@
 #endif
     Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() );  // Index to the layer set
-#if !CONFORMANCE_BITSTREAM_MODE
-    assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1);
-#endif
     
     // Check if the targetdeclayerIdlist matches the output layer set
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 1523)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 1524)
@@ -133,5 +133,4 @@
   static Bool             m_bFirstSliceInSequence;
   UInt                    m_layerId;      
-  UInt                    m_numLayer;
   TDecTop**               m_ppcTDecTop;
   UInt                    m_smallestLayerId;
@@ -226,6 +225,4 @@
   UInt      getLayerId                      ()                              { return m_layerId;                }
   Void      setLayerId                      (UInt layer)                    { m_layerId = layer;               }
-  UInt      getNumLayer                     ()                              { return m_numLayer;               }
-  Void      setNumLayer                     (UInt uiNum)                    { m_numLayer = uiNum;              }
   TComList<TComPic*>*  getListPic           ()                              { return &m_cListPic;              }
   Void      setLayerDec                     (TDecTop **p)                   { m_ppcTDecTop = p;                }
