Index: branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 35)
+++ branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 38)
@@ -75,4 +75,7 @@
   string cfg_ReconFile;
 #endif
+#if AVC_SYNTAX || SYNTAX_OUTPUT
+  string cfg_BLSyntaxFile;
+#endif
 #if TARGET_DECLAYERID_SET
   string cfg_TargetDecLayerIdSetFile;
@@ -90,8 +93,17 @@
   ("BLSourceWidth,-wdt",    m_iBLSourceWidth,        0, "BL source picture width")
   ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
+#if AVC_SYNTAX
+  ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name")  
+#endif
 #endif
 #else
   ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
                                                      "YUV writing is skipped if omitted")
+#endif
+#if SYNTAX_OUTPUT
+  ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name")
+  ("BLSourceWidth,-wdt",    m_iBLSourceWidth,        0, "BL source picture width")
+  ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
+  ("BLFrames,-fr",          m_iBLFrames,       0, "BL number of frames")
 #endif
   ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
@@ -138,4 +150,7 @@
 #else
   m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
+#endif
+#if AVC_SYNTAX || SYNTAX_OUTPUT
+  m_pchBLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
 #endif
 
Index: branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 35)
+++ branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 38)
@@ -66,7 +66,16 @@
   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
Index: branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 35)
+++ branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 38)
@@ -102,4 +102,11 @@
   }
 #endif
+#if AVC_SYNTAX || SYNTAX_OUTPUT
+  if( m_pchBLSyntaxFile )
+  {
+    free ( m_pchBLSyntaxFile );
+    m_pchBLSyntaxFile = NULL;
+  }
+#endif
 }
 
@@ -147,15 +154,34 @@
 #if AVC_BASE
   TComPic pcBLPic;
-  FILE* pFile = fopen( m_pchBLReconFile, "rb" );
-  if( !pFile )
-  {
-    printf( "BL input reading error\n" );
-    exit(0);
+  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);
   }
   TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
   m_acTDecTop[0].setBLsize( m_iBLSourceWidth, m_iBLSourceHeight );
-  m_acTDecTop[0].setBLReconFile( pFile );
+  m_acTDecTop[0].setBLReconFile( &streamYUV );
   pcBLPic.setLayerId( 0 );
   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);
+  }
+  m_acTDecTop[0].setBLSyntaxFile( &streamSyntaxFile );
+#endif
 #endif
 
@@ -254,8 +280,14 @@
   // delete buffers
 #if AVC_BASE
-  if( pFile )
-  {
-    fclose( pFile );
-  }
+  if( streamYUV.is_open() )
+  {
+    streamYUV.close();
+  }
+#if AVC_SYNTAX
+  if( streamSyntaxFile.is_open() )
+  {
+    streamSyntaxFile.close();
+  }
+#endif
   pcBLPic.destroy();
 
@@ -293,4 +325,25 @@
   // main decoder loop
   bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
+
+#if SYNTAX_OUTPUT
+  if( !m_pchBLSyntaxFile )
+  {
+    printf( "Wrong base layer syntax file\n" );
+    exit(EXIT_FAILURE);
+  }
+  fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::out | fstream::binary );
+  if( !streamSyntaxFile.good() )
+  {
+    printf( "Base layer syntax input reading error\n" );
+    exit(EXIT_FAILURE);
+  }
+  m_cTDecTop.setBLSyntaxFile( &streamSyntaxFile );
+
+  for( Int i = m_iBLFrames * m_iBLSourceWidth * m_iBLSourceHeight * SYNTAX_BYTES / 16; i >= 0; i-- )
+  {
+    streamSyntaxFile.put( 0 );
+  }
+  streamSyntaxFile.seekp( 0 );
+#endif
 
   while (!!bitstreamFile)
@@ -389,4 +442,11 @@
     }
   }
+
+#if SYNTAX_OUTPUT
+  if( streamSyntaxFile.is_open() )
+  {
+    streamSyntaxFile.close();
+  }
+#endif
   
   xFlushOutput( pcListPic );
