Index: /branches/SHM-2.0-dev/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- /branches/SHM-2.0-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 153)
+++ /branches/SHM-2.0-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 154)
@@ -60,20 +60,6 @@
 #if SVC_EXTENSION
   Char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
-#if AVC_BASE
-  Char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
-  Int           m_iBLSourceWidth;
-  Int           m_iBLSourceHeight;
-#if AVC_SYNTAX
-  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name  
-#endif
-#endif
 #else
   Char*         m_pchReconFile;                       ///< output reconstruction file name
-#endif
-#if SYNTAX_OUTPUT
-  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
-  Int           m_iBLSourceWidth;
-  Int           m_iBLSourceHeight;
-  Int           m_iBLFrames;
 #endif
   Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
@@ -86,5 +72,21 @@
 #if SVC_EXTENSION
   Int           m_tgtLayerId;                        ///< target layer ID
+#if AVC_BASE
+  Char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
+  Int           m_iBLSourceWidth;
+  Int           m_iBLSourceHeight;
+#if AVC_SYNTAX
+  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name  
 #endif
+#endif
+#endif
+
+#if SYNTAX_OUTPUT
+  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
+  Int           m_iBLSourceWidth;
+  Int           m_iBLSourceHeight;
+  Int           m_iBLFrames;
+#endif
+
   std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
   Int           m_respectDefDispWindow;               ///< Only output content inside the default display window 
@@ -103,6 +105,4 @@
 #if SVC_EXTENSION
   , m_tgtLayerId(0)
-#endif
-  , m_respectDefDispWindow(0)
 #if AVC_BASE
   , m_iBLSourceWidth(0)
@@ -114,4 +114,6 @@
   , m_iBLFrames(0)
 #endif
+#endif
+  , m_respectDefDispWindow(0)
   {}
   virtual ~TAppDecCfg() {}
Index: /branches/SHM-2.0-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /branches/SHM-2.0-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 153)
+++ /branches/SHM-2.0-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 154)
@@ -157,14 +157,8 @@
 #if AVC_BASE
   TComPic pcBLPic;
-  if( !m_pchBLReconFile )
-  {
-    printf( "Wrong base layer YUV input file\n" );
-    exit(EXIT_FAILURE);
-  }
-  fstream streamYUV( m_pchBLReconFile, fstream::in | fstream::binary );
-  if( !streamYUV.good() )
-  {
-    printf( "Base layer YUV input reading error\n" );
-    exit(EXIT_FAILURE);
+  fstream streamYUV;
+  if( m_pchBLReconFile )
+  {
+    streamYUV.open( m_pchBLReconFile, fstream::in | fstream::binary );
   }
   TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
@@ -174,14 +168,8 @@
   cListPic->pushBack( &pcBLPic );
 #if AVC_SYNTAX
-  if( !m_pchBLSyntaxFile )
-  {
-    printf( "Wrong base layer syntax file\n" );
-    exit(EXIT_FAILURE);
-  }
-  fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::in | fstream::binary );
-  if( !streamSyntaxFile.good() )
-  {
-    printf( "Base layer syntax input reading error\n" );
-    exit(EXIT_FAILURE);
+  fstream streamSyntaxFile;
+  if( m_pchBLSyntaxFile )
+  {
+    streamSyntaxFile.open( m_pchBLSyntaxFile, fstream::in | fstream::binary );
   }
   m_acTDecTop[0].setBLSyntaxFile( &streamSyntaxFile );
Index: /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 153)
+++ /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 154)
@@ -343,4 +343,7 @@
 #endif
   }
+#if AVC_BASE
+  string  cfg_BLInputFile;
+#endif
 #if AVC_SYNTAX
   string  cfg_BLSyntaxFile;
@@ -399,5 +402,6 @@
 
 #if AVC_BASE
-  ("InputBLFile,-ibl",        *cfg_InputFile[0],     string(""), "Base layer rec YUV input file name")
+  ("AvcBase",                 m_avcBaseLayerFlag,     0, "AVC_BASElayer_flag")
+  ("InputBLFile,-ibl",        cfg_BLInputFile,     string(""), "Base layer rec YUV input file name")
 #if AVC_SYNTAX
   ("InputBLSyntaxFile,-ibs",  cfg_BLSyntaxFile,     string(""), "Base layer syntax input file name")
@@ -716,4 +720,11 @@
   ;
   
+#if AVC_BASE
+  if( m_avcBaseLayerFlag )
+  {
+    *cfg_InputFile[0] = cfg_BLInputFile;
+  }
+#endif
+
   for(Int i=1; i<MAX_GOP+1; i++) {
     std::ostringstream cOSS;
@@ -1906,5 +1917,9 @@
 #if SVC_EXTENSION
   printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
-  printf("AVC_BASE:%d ", AVC_BASE);
+#if AVC_BASE
+  printf("AvcBase:%d ", m_avcBaseLayerFlag ? 1 : 0);
+#else
+  printf("AvcBase:%d ", 0);
+#endif
 #if REF_IDX_FRAMEWORK
   printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK);
Index: /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 153)
+++ /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 154)
@@ -67,6 +67,9 @@
   UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
   Int       m_framesToBeEncoded;                              ///< number of encoded frames
+#if AVC_BASE
+  Int       m_avcBaseLayerFlag;                               ///< AVC_BASElayer_flag
+#endif
 #if AVC_SYNTAX
-  char*     m_BLSyntaxFile;                                   ///< input syntax file
+  Char*     m_BLSyntaxFile;                                   ///< input syntax file
 #endif
 #else
Index: /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 153)
+++ /branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 154)
@@ -112,5 +112,9 @@
 
 #if REF_IDX_MFM
+#if AVC_BASE
+    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ));
+#else
     m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : true);
+#endif
 #endif
     // set layer ID 
@@ -805,5 +809,9 @@
 #if VPS_EXTN_MASK_AND_DIM_INFO
   UInt i = 0, dimIdLen = 0;
+#if AVC_BASE
+  vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag);
+#else
   vps->setAvcBaseLayerFlag(false);
+#endif
   vps->setSplittingFlag(false);
   for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
@@ -931,16 +939,20 @@
 
 #if AVC_SYNTAX
-  if( !m_BLSyntaxFile )
-  {
-    printf( "Wrong base layer syntax input file\n" );
-    exit(EXIT_FAILURE);
-  }
-  fstream streamSyntaxFile( m_BLSyntaxFile, fstream::in | fstream::binary );
-  if( !streamSyntaxFile.good() )
-  {
-    printf( "Base layer syntax input reading error\n" );
-    exit(EXIT_FAILURE);
-  }
-  m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
+  fstream streamSyntaxFile;
+  if( m_acTEncTop[0].getVPS()->getAvcBaseLayerFlag() )
+  {
+    if( !m_BLSyntaxFile )
+    {
+      printf( "Wrong base layer syntax input file\n" );
+      exit(EXIT_FAILURE);
+    }
+    streamSyntaxFile.open( m_BLSyntaxFile, fstream::in | fstream::binary );
+    if( !streamSyntaxFile.good() )
+    {
+      printf( "Base layer syntax input reading error\n" );
+      exit(EXIT_FAILURE);
+    }
+    m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
+  }
 #endif
 
Index: /branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 153)
+++ /branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 154)
@@ -1612,5 +1612,4 @@
 #endif
 {
-
   for( Int i = 0; i < MAX_TLAYER; i++)
   {
Index: /branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 153)
+++ /branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 154)
@@ -66,5 +66,4 @@
 #define JCTVC_M0259_LAMBDAREFINEMENT     1      ///< JCTVC-M0259: lambda refinement (encoder only optimization)
 
-#define AVC_BASE                         0      ///< YUV BL reading for AVC base SVC
 #define REF_IDX_FRAMEWORK                1      ///< inter-layer reference framework
 
@@ -75,6 +74,7 @@
 #define IDR_ALIGNMENT                    1      ///< align IDR picures across layers 
 
+#define AVC_BASE                         1      ///< YUV BL reading for AVC base SVC
 #if AVC_BASE
-#define AVC_SYNTAX                       1      ///< Syntax reading for AVC base
+#define AVC_SYNTAX                       0      ///< Syntax reading for AVC base
 #endif
 
@@ -82,7 +82,5 @@
 #define REF_IDX_ME_ZEROMV                1      ///< L0051: use zero motion for inter-layer reference picture (without fractional ME)
 #define ENCODER_FAST_MODE                1      ///< 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.
-#if !AVC_BASE || AVC_SYNTAX
 #define REF_IDX_MFM                      1      ///< L0336: motion vector mapping of inter-layer reference picture
-#endif
 
 #if REF_IDX_MFM
Index: /branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 153)
+++ /branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 154)
@@ -581,8 +581,12 @@
   {
 #if AVC_BASE
-  if( m_layerId == 1 )
+  if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
   {
     TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
+#if ILP_DECODED_PICTURE
+    UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth();
+    UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight();
+#else
     const Window &conf = pBLPic->getConformanceWindow();
 #if ILP_DECODED_PICTURE
@@ -796,18 +800,30 @@
     {
 #if AVC_BASE
-      pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
+      if( m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
+      {
+        pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
 #if AVC_SYNTAX
-      TComPic* pBLPic = pcSlice->getBaseColPic();
-      if( pcSlice->getPOC() == 0 )
-      {
-        // initialize partition order.
-        UInt* piTmp = &g_auiZscanToRaster[0];
-        initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
-        initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
-      }      
-      pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
-      pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
-#endif
-
+        TComPic* pBLPic = pcSlice->getBaseColPic();
+        if( pcSlice->getPOC() == 0 )
+        {
+          // initialize partition order.
+          UInt* piTmp = &g_auiZscanToRaster[0];
+          initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
+          initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
+        }      
+        pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
+        pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
+#endif
+      }
+      else
+      {
+#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
+        TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId );
+#else
+        TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
+#endif
+        TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
+        pcSlice->setBaseColPic ( *cListPic, m_layerId );
+      }
 #else
 #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
@@ -837,5 +853,8 @@
       setILRPic(pcPic);
 #if REF_IDX_MFM
-      pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
+      if( pcSlice->getSPS()->getMFMEnabledFlag() )
+      {
+        pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
+      }
 #endif
 #if REF_LIST_BUGFIX
@@ -1079,4 +1098,26 @@
     case NAL_UNIT_VPS:
       xDecodeVPS();
+#if AVC_BASE
+      if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
+      {
+        if( !m_ppcTDecTop[0]->getBLReconFile()->good() )
+        {
+          printf( "Base layer YUV input reading error\n" );
+          exit(EXIT_FAILURE);
+        }        
+#if AVC_SYNTAX
+        if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() )
+        {
+          printf( "Base layer syntax input reading error\n" );
+          exit(EXIT_FAILURE);
+        }
+#endif
+      }
+      else
+      {
+        TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic();
+        cListPic->clear();
+      }
+#endif
       return false;
       
@@ -1084,4 +1125,5 @@
       xDecodeSPS();
 #if AVC_BASE
+      if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
       {
         TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
Index: /branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 153)
+++ /branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 154)
@@ -1109,5 +1109,5 @@
     startCUAddrSliceSegmentIdx++;
 #if AVC_BASE
-    if( m_layerId == 0 )
+    if( m_layerId == 0 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() )
     {
       pcPic->getPicYuvOrg()->copyToPic( pcPic->getPicYuvRec() );
@@ -1225,5 +1225,5 @@
       OutputNALUnit nalu(NAL_UNIT_VPS, 0, m_layerId);
 #if AVC_BASE
-      if( m_layerId == 1 )
+      if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) )
 #else
       if( m_layerId == 0 )
