Index: branches/SHM-1.1-dev/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibCommon/CommonDef.h	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibCommon/CommonDef.h	(revision 38)
@@ -56,5 +56,5 @@
 // ====================================================================================================================
 
-#define NV_VERSION        "1.0"                 ///< Current software version
+#define NV_VERSION        "1.1"                 ///< Current software version
 
 // ====================================================================================================================
Index: branches/SHM-1.1-dev/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 38)
@@ -383,5 +383,4 @@
   m_layerId          = pcPic->getLayerId();
 #endif 
-
   for(int i=0; i<pcPic->getNumPartInCU(); i++) 
   {
Index: branches/SHM-1.1-dev/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibCommon/TComMotionInfo.h	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibCommon/TComMotionInfo.h	(revision 38)
@@ -141,4 +141,9 @@
   Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
 
+#if AVC_SYNTAX
+  Void           setMv    (TComMv cMv,  Int iIdx )         { m_pcMv    [iIdx] = cMv; }
+  Void           setRefIdx(Int iRefIdx, Int iIdx   )       { m_piRefIdx[iIdx] =  iRefIdx; }
+#endif
+
   Void setNumPartition( Int iNumPart )
   {
Index: branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 38)
@@ -669,3 +669,161 @@
 #endif
 
+#if AVC_SYNTAX
+Void TComPic::readBLSyntax( fstream* filestream, UInt numBytes )
+{
+  if( !filestream->good() )
+  {
+    return;
+  }
+
+  UInt   uiWidth      = this->getPicYuvRec()->getWidth() - this->getPicYuvRec()->getPicCropLeftOffset() - this->getPicYuvRec()->getPicCropRightOffset();
+  UInt   uiHeight     = this->getPicYuvRec()->getHeight() - this->getPicYuvRec()->getPicCropTopOffset() - this->getPicYuvRec()->getPicCropBottomOffset();
+  UInt64 uiPOC        = (UInt64)this->getPOC();
+  UInt   uiPartWidth  = uiWidth / 4;
+  UInt   uiPartHeight = uiHeight / 4;
+
+  UInt uiNumPartInWidth    = this->getNumPartInWidth();
+  UInt uiNumPartInHeight   = this->getNumPartInHeight();
+  UInt uiNumPartLCUInWidth = this->getFrameWidthInCU();
+
+  UInt64 uiPos = (UInt64)uiPOC * uiWidth * uiHeight * numBytes / 16;
+   
+  filestream->seekg( uiPos, ios_base::beg );
+
+  for( Int i = 0; i < this->getNumCUsInFrame(); i++ )
+  {
+    TComDataCU* pcCU = this->getCU( i );
+    pcCU->initCU( this, i );
+  }
+
+  for( Int i = 0; i < uiPartHeight; i++ )
+  {
+    for( Int j = 0; j < uiPartWidth; j++ )
+    {
+      UInt uiX = ( j / uiNumPartInWidth );
+      UInt uiY = ( i / uiNumPartInHeight );
+
+      UInt uiLCUAddr = uiY * uiNumPartLCUInWidth + uiX;
+      UInt uiPartAddr = ( i - uiY * uiNumPartInHeight ) * uiNumPartInWidth + ( j - uiX * uiNumPartInWidth );
+      uiPartAddr = g_auiRasterToZscan[uiPartAddr];
+      
+      TComDataCU* pcCU = this->getCU( uiLCUAddr );
+      
+      TComMv mv;
+      Short temp;
+
+      // RefIdxL0
+      Char refIdxL0 = -1;
+      filestream->read( &refIdxL0, 1 );
+      assert( refIdxL0 >= -1 );
+      pcCU->getCUMvField( REF_PIC_LIST_0 )->setRefIdx( (Int)refIdxL0, uiPartAddr );
+
+      // RefIdxL1
+      Char refIdxL1 = -1;
+      filestream->read( &refIdxL1, 1 );
+      assert( refIdxL1 >= -1 );
+      pcCU->getCUMvField( REF_PIC_LIST_1 )->setRefIdx( (Int)refIdxL1, uiPartAddr );
+
+      // MV L0
+      temp = 0;
+      filestream->read( reinterpret_cast<char*>(&temp), 2 );
+      mv.setHor( (Short)temp );
+      temp = 0;
+      filestream->read( reinterpret_cast<char*>(&temp), 2 );
+      mv.setVer( (Short)temp );
+      pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv( mv, uiPartAddr );
+
+      // MV L1
+      temp = 0;
+      filestream->read( reinterpret_cast<char*>(&temp), 2 );
+      mv.setHor( (Short)temp );
+      temp = 0;
+      filestream->read( reinterpret_cast<char*>(&temp), 2 );
+      mv.setVer( (Short)temp );
+      pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv( mv, uiPartAddr );
+
+      // set dependent information
+      pcCU->setPredictionMode( uiPartAddr, ( refIdxL0 == NOT_VALID && refIdxL1 == NOT_VALID ) ? MODE_INTRA : MODE_INTER );
+      UInt uiInterDir = ( refIdxL0 != NOT_VALID ) + ( refIdxL1 != NOT_VALID && pcCU->getSlice()->isInterB() ) * 2;
+      assert( uiInterDir >= 0 && uiInterDir <= 3 );
+      pcCU->setInterDir( uiPartAddr, uiInterDir );
+    }
+  }
+}
+#endif
+
+#if SYNTAX_OUTPUT
+Void TComPic::wrireBLSyntax( fstream* filestream, UInt numBytes )
+{
+  if( !filestream->good() )
+  {
+    return;
+  }
+
+  UInt   uiWidth      = this->getPicYuvRec()->getWidth() - getSlice(0)->getSPS()->getPicCropLeftOffset() - getSlice(0)->getSPS()->getPicCropRightOffset();
+  UInt   uiHeight     = this->getPicYuvRec()->getHeight() - getSlice(0)->getSPS()->getPicCropTopOffset() - getSlice(0)->getSPS()->getPicCropBottomOffset();
+  UInt64 uiPOC        = (UInt64)this->getPOC();
+  UInt   uiPartWidth  = uiWidth / 4;
+  UInt   uiPartHeight = uiHeight / 4;
+
+  UInt uiNumPartInWidth    = this->getNumPartInWidth();
+  UInt uiNumPartInHeight   = this->getNumPartInHeight();
+  UInt uiNumPartLCUInWidth = this->getFrameWidthInCU();
+
+  filestream->seekg( uiPOC * uiWidth * uiHeight * numBytes / 16 );
+    
+  for( Int i = 0; i < uiPartHeight; i++ )
+  {
+    for( Int j = 0; j < uiPartWidth; j++ )
+    {
+      UInt uiX = ( j / uiNumPartInWidth );
+      UInt uiY = ( i / uiNumPartInHeight );
+
+      UInt uiLCUAddr = uiY * uiNumPartLCUInWidth + uiX;
+      UInt uiPartAddr = ( i - uiY * uiNumPartInHeight ) * uiNumPartInWidth + ( j - uiX * uiNumPartInWidth );
+      uiPartAddr = g_auiRasterToZscan[uiPartAddr];
+      
+      TComDataCU* pcCU = this->getCU( uiLCUAddr );
+      
+      TComMv mv;
+      Short temp;
+      Char refIdxL0 = NOT_VALID, refIdxL1 = NOT_VALID;
+
+      // RefIdx
+      if( !pcCU->isIntra( uiPartAddr ) )
+      {
+        refIdxL0 = (Char)pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr );
+        refIdxL1 = (Char)pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr );
+      }
+      assert( refIdxL0 >= - 1 && refIdxL1 >= - 1 );
+      filestream->put( refIdxL0 );
+      filestream->put( refIdxL1 );
+
+      // MV L0
+      mv.setZero();
+      if( refIdxL0 >= 0 )
+      {
+        mv = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+      }
+      temp = (Short)mv.getHor();
+      filestream->write( reinterpret_cast<char*>(&temp), 2 );
+      temp = (Short)mv.getVer();
+      filestream->write( reinterpret_cast<char*>(&temp), 2 );
+
+      // MV L1
+      mv.setZero();
+      if( refIdxL1 >= 0 )
+      {
+        mv = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
+      }
+      temp = (Short)mv.getHor();
+      filestream->write( reinterpret_cast<char*>(&temp), 2 );
+      temp = (Short)mv.getVer();
+      filestream->write( reinterpret_cast<char*>(&temp), 2 );
+    }
+  }
+}
+#endif
+
+
 //! \}
Index: branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPic.h	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPic.h	(revision 38)
@@ -44,4 +44,8 @@
 #include "TComPicYuv.h"
 #include "TComBitStream.h"
+#if AVC_BASE || SYNTAX_OUTPUT
+#include <fstream>
+#endif
+
 
 //! \ingroup TLibCommon
@@ -209,4 +213,11 @@
   Void  copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut); 
 #endif
+#if AVC_SYNTAX
+  Void readBLSyntax( fstream* filestream, UInt numBytes );
+#endif
+#if SYNTAX_OUTPUT
+  Void wrireBLSyntax( fstream* filestream, UInt numBytes );
+#endif
+
 };// END CLASS DEFINITION TComPic
 
@@ -214,2 +225,3 @@
 
 #endif // __TCOMPIC__
+
Index: branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPicSym.h
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPicSym.h	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPicSym.h	(revision 38)
@@ -125,4 +125,10 @@
   UInt        getNumberOfCUsInFrame()   { return m_uiNumCUsInFrame;  }
   TComDataCU*&  getCU( UInt uiCUAddr )  { return m_apcTComDataCU[uiCUAddr];     }
+
+#if AVC_SYNTAX
+  UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
+  UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
+  UInt        getMaxDepth()             { return m_uhTotalDepth;               }
+#endif
   
   Void        setSlice(TComSlice* p, UInt i) { m_apcTComSlice[i] = p;           }
Index: branches/SHM-1.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 38)
@@ -40,4 +40,7 @@
 
 #define SVC_EXTENSION                    1
+
+#define SYNTAX_BYTES                     10      ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
+
 #if SVC_EXTENSION
 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
@@ -49,10 +52,12 @@
 #define BUGFIX_925                       1      ///< bug fix ticket #925
 #define ENCODER_BUGFIX                   1      ///< L0167: encoder bug fix for inter mode
-
 #define CHROMA_UPSAMPLING                1      ///< L0335: Chroma upsampling with 5 bits coefficients
 
-#define AVC_BASE                         0      ///< YUV BL reading for AVC base SVC
-
+#define AVC_BASE                         1      ///< YUV BL reading for AVC base SVC
 #define REF_IDX_FRAMEWORK                0      ///< inter-layer reference framework
+
+#if AVC_BASE
+#define AVC_SYNTAX                       1      ///< Syntax reading for AVC base
+#endif
 
 #if REF_IDX_FRAMEWORK
@@ -60,5 +65,7 @@
 #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
 #else
 #define INTRA_BL                         1      ///< inter-layer texture prediction
@@ -69,6 +76,7 @@
 
 // Hooks
-#if !AVC_BASE
+#if !AVC_BASE || AVC_SYNTAX
 #define SVC_MVP                          1      ///< motion hook for merge mode as an example
+#if !AVC_SYNTAX
 #define SVC_BL_CAND_INTRA                0      ///< Intra Base Mode Prediction hook as an example 
 #endif
@@ -80,4 +88,7 @@
 
 #endif
+#endif
+#else
+#define SYNTAX_OUTPUT                    1
 #endif
 
Index: branches/SHM-1.1-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 38)
@@ -81,4 +81,7 @@
   memset(m_cIlpPic, 0, sizeof(m_cIlpPic));
 #endif
+#if AVC_SYNTAX || SYNTAX_OUTPUT
+  m_pBLSyntaxFile = NULL;
+#endif
 
 }
@@ -335,4 +338,8 @@
 
   m_cGopDecoder.filterPicture(pcPic);
+
+#if SYNTAX_OUTPUT
+  pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES );
+#endif
 
   TComSlice::sortPicList( m_cListPic ); // sorting for application output
@@ -559,11 +566,13 @@
   {
     TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
-    FILE* pFile = m_ppcTDecTop[0]->getBLReconFile();
-    UInt uiWidth = pBLPic->getPicYuvRec()->getWidth();
-    UInt uiHeight = pBLPic->getPicYuvRec()->getHeight();
+    fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
+    UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - pBLPic->getPicYuvRec()->getPicCropLeftOffset() - pBLPic->getPicYuvRec()->getPicCropRightOffset();;
+    UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - pBLPic->getPicYuvRec()->getPicCropTopOffset() - pBLPic->getPicYuvRec()->getPicCropBottomOffset();
         
-    if( pFile )
-    {
-      fseek( pFile, m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2, SEEK_SET );
+    if( pFile->good() )
+    {
+      UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
+
+      pFile->seekg((UInt)uiPos, ios::beg );
 
       Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
@@ -573,5 +582,5 @@
         for( Int j = 0; j < uiWidth; j++ )
         {
-          pPel[j] = fgetc( pFile );
+          pPel[j] = pFile->get();
         }
         pPel += uiStride;
@@ -584,5 +593,5 @@
         for( Int j = 0; j < uiWidth/2; j++ )
         {
-          pPel[j] = fgetc( pFile );
+          pPel[j] = pFile->get();
         }
         pPel += uiStride;
@@ -595,9 +604,21 @@
         for( Int j = 0; j < uiWidth/2; j++ )
         {
-          pPel[j] = fgetc( pFile );
+          pPel[j] = pFile->get();
         }
         pPel += uiStride;
       }
     }
+#if AVC_SYNTAX
+    if( m_apcSlicePilot->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 )->setPOC( m_apcSlicePilot->getPOC() );
+    pBLPic->getSlice( 0 )->setSliceType( m_apcSlicePilot->getSliceType() );
+    pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
+#endif
   }
 #endif
@@ -979,5 +1000,10 @@
         {
 #if SVC_UPSAMPLING
+#if AVC_SYNTAX
+          TComSPS* sps = new TComSPS();
+          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, sps, true);
+#else
           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL, true);
+#endif
 #else
           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
Index: branches/SHM-1.1-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 38)
@@ -127,9 +127,12 @@
   TDecTop**               m_ppcTDecTop;
 #if AVC_BASE
-  FILE*                   m_pBLReconFile;
+  fstream*                m_pBLReconFile;
   Int                     m_iBLSourceWidth;
   Int                     m_iBLSourceHeight;
 #endif
 #endif 
+#if AVC_SYNTAX || SYNTAX_OUTPUT
+  fstream*               m_pBLSyntaxFile;
+#endif
 #if REF_IDX_FRAMEWORK
   TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture 
@@ -165,10 +168,14 @@
   TDecTop*            getLayerDec(UInt layer)   { return m_ppcTDecTop[layer]; }
 #if AVC_BASE
-  Void      setBLReconFile( FILE* pFile ) { m_pBLReconFile = pFile; }
-  FILE*     getBLReconFile() { return m_pBLReconFile; }
+  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
+  fstream*  getBLReconFile() { return m_pBLReconFile; }
   Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
   Int       getBLWidth() { return  m_iBLSourceWidth; }
   Int       getBLHeight() { return  m_iBLSourceHeight; }
 #endif
+#endif
+#if AVC_SYNTAX || SYNTAX_OUTPUT
+  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
+  fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
 #endif
 #if REF_IDX_FRAMEWORK
Index: branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 38)
@@ -774,4 +774,7 @@
     {
       pcPic->getPicYuvOrg()->copyToPic( pcPic->getPicYuvRec() );
+#if AVC_SYNTAX
+      pcPic->readBLSyntax( m_ppcTEncTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
+#endif
       return;
     }
Index: branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 35)
+++ branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 38)
@@ -77,4 +77,7 @@
   static Int              m_iSPSIdCnt;                    ///< next Id number for SPS    
   static Int              m_iPPSIdCnt;                    ///< next Id number for PPS    
+#if AVC_SYNTAX
+  fstream*                m_pBLSyntaxFile;
+#endif
 #endif
   
@@ -223,4 +226,8 @@
 
   Void encodePrep( bool bEos, TComPicYuv* pcPicYuvOrg );
+#if AVC_SYNTAX
+  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
+  fstream*  getBLSyntaxFile() { return m_pBLSyntaxFile; }
+#endif
 #else
   Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
