Index: trunk/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecCfg.h	(revision 125)
+++ trunk/source/App/TAppDecoder/TAppDecCfg.h	(revision 189)
@@ -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: trunk/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 125)
+++ trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 189)
@@ -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 );
@@ -254,9 +242,9 @@
       }
       if ( bNewPicture && bNewPOC && 
-           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
+           (   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_BLA_N_LP
-            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
-            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
+            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
+            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
       {
         xFlushOutput( pcListPic, curLayerId );
@@ -414,9 +402,9 @@
       }
       if ( bNewPicture && 
-           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
+           (   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_BLA_N_LP
-            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
-            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
+            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
+            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
       {
         xFlushOutput( pcListPic );
@@ -572,4 +560,7 @@
       if ( m_pchReconFile )
       {
+#if SYNTAX_OUTPUT && ILP_DECODED_PICTURE
+        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec() );
+#else
         const Window &conf = pcPic->getConformanceWindow();
         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
@@ -579,4 +570,5 @@
                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
+#endif
       }
       
Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 125)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 189)
@@ -66,4 +66,7 @@
 TAppEncCfg::TAppEncCfg()
 : m_pBitstreamFile()
+#if AVC_BASE
+, m_avcBaseLayerFlag(0)
+#endif
 , m_pColumnWidth()
 , m_pRowHeight()
@@ -89,4 +92,9 @@
 {
   m_aidQP = NULL;
+#if J0149_TONE_MAPPING_SEI
+  m_startOfCodedInterval = NULL;
+  m_codedPivotValue = NULL;
+  m_targetPivotValue = NULL;
+#endif
 }
 #endif
@@ -102,4 +110,21 @@
     delete[] m_aidQP;
   }
+#if J0149_TONE_MAPPING_SEI
+  if ( m_startOfCodedInterval )
+  {
+    delete[] m_startOfCodedInterval;
+    m_startOfCodedInterval = NULL;
+  }
+   if ( m_codedPivotValue )
+  {
+    delete[] m_codedPivotValue;
+    m_codedPivotValue = NULL;
+  }
+  if ( m_targetPivotValue )
+  {
+    delete[] m_targetPivotValue;
+    m_targetPivotValue = NULL;
+  }
+#endif
   free(m_pchInputFile);
 #endif
@@ -119,4 +144,13 @@
 Void TAppEncCfg::destroy()
 {
+#if VPS_EXTN_DIRECT_REF_LAYERS
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 )
+    {
+      delete [] m_acLayerCfg[layer].m_refLayerIds;
+    }
+  }
+#endif
 }
 
@@ -297,4 +331,10 @@
   string* cfg_refLayerIdsPtr   [MAX_LAYERS];
 #endif
+#if SCALED_REF_LAYER_OFFSETS
+  Int*    cfg_scaledRefLayerLeftOffset [MAX_LAYERS];
+  Int*    cfg_scaledRefLayerTopOffset [MAX_LAYERS];
+  Int*    cfg_scaledRefLayerRightOffset [MAX_LAYERS];
+  Int*    cfg_scaledRefLayerBottomOffset [MAX_LAYERS];
+#endif
   for(UInt layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -311,5 +351,14 @@
     cfg_refLayerIdsPtr      [layer]  = &cfg_refLayerIds[layer];
 #endif
-  }
+#if SCALED_REF_LAYER_OFFSETS
+    cfg_scaledRefLayerLeftOffset  [layer] = &m_acLayerCfg[layer].m_scaledRefLayerLeftOffset;
+    cfg_scaledRefLayerTopOffset   [layer] = &m_acLayerCfg[layer].m_scaledRefLayerTopOffset;
+    cfg_scaledRefLayerRightOffset [layer] = &m_acLayerCfg[layer].m_scaledRefLayerRightOffset;
+    cfg_scaledRefLayerBottomOffset[layer] = &m_acLayerCfg[layer].m_scaledRefLayerBottomOffset;
+#endif
+  }
+#if AVC_BASE
+  string  cfg_BLInputFile;
+#endif
 #if AVC_SYNTAX
   string  cfg_BLSyntaxFile;
@@ -324,4 +373,9 @@
   string cfg_RowHeight;
   string cfg_ScalingListFile;
+#if J0149_TONE_MAPPING_SEI
+  string cfg_startOfCodedInterval;
+  string cfg_codedPivotValue;
+  string cfg_targetPivotValue;
+#endif
 #if SIGNAL_BITRATE_PICRATE_IN_VPS
   string cfg_bitRateInfoPresentFlag;
@@ -361,7 +415,17 @@
   ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
   ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
-
+#if SCALED_REF_LAYER_OFFSETS
+  ("ScaledRefLayerLeftOffset%d",   cfg_scaledRefLayerLeftOffset,  0, MAX_LAYERS, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to"
+                                                                 " top-left luma sample of the EL picture, in units of two luma samples")
+  ("ScaledRefLayerTopOffset%d",    cfg_scaledRefLayerTopOffset,   0, MAX_LAYERS,   "Vertical offset of top-left luma sample of scaled base layer picture with respect to"
+                                                                 " top-left luma sample of the EL picture, in units of two luma samples")
+  ("ScaledRefLayerRightOffset%d",  cfg_scaledRefLayerRightOffset, 0, MAX_LAYERS, "Horizontal offset of bottom-right luma sample of scaled base layer picture with respect to"
+                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
+  ("ScaledRefLayerBottomOffset%d", cfg_scaledRefLayerBottomOffset,0, MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to"
+                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
+#endif
 #if AVC_BASE
-  ("InputBLFile,-ibl",        *cfg_InputFile[0],     string(""), "Base layer rec YUV input file name")
+  ("AvcBase,-avc",            m_avcBaseLayerFlag,     0, "avc_base_layer_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")
@@ -369,5 +433,5 @@
 #endif
 #if REF_IDX_FRAMEWORK
-  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture_")
+  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
 #endif  
 #else  
@@ -430,5 +494,7 @@
   ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
   ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
+#if !L0034_COMBINED_LIST_CLEANUP
   ("ListCombination,-lc",     m_bUseLComb,               true, "Combined reference list for uni-prediction estimation in B-slices")
+#endif
   // motion options
   ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
@@ -488,4 +554,7 @@
   ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0 )
   ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false )
+#if L0386_DB_METRIC
+  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
+#endif
 
   // Coding tools
@@ -602,4 +671,36 @@
   ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
   ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
+#if J0149_TONE_MAPPING_SEI
+  ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false, "Control generation of Tone Mapping SEI messages")
+  ("SEIToneMapId",                             m_toneMapId,                        0, "Specifies Id of Tone Mapping SEI message for a given session")
+  ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false, "Indicates that Tone Mapping SEI message cancels the persistance or follows")
+  ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true, "Specifies the persistence of the Tone Mapping SEI message")
+  ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
+  ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8, "Specifies Output BitDepth of Tome mapping function")
+  ("SEIToneMapModelId",                        m_toneMapModelId,                   0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
+                                                                                      "\t0:  linear mapping with clipping\n"
+                                                                                      "\t1:  sigmoidal mapping\n"
+                                                                                      "\t2:  user-defined table mapping\n"
+                                                                                      "\t3:  piece-wise linear mapping\n"
+                                                                                      "\t4:  luminance dynamic range information ")
+  ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0, "Specifies the minimum value in mode 0")
+  ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023, "Specifies the maxmum value in mode 0")
+  ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512, "Specifies the centre point in mode 1")
+  ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
+  ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""), "Array of user-defined mapping table")
+  ("SEIToneMapNumPivots",                             m_numPivots,                                0, "Specifies the number of pivot points in mode 3")
+  ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
+  ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
+  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0, "Indicates the camera ISO speed for daylight illumination")
+  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
+  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0, "Specifies the sign of ExposureCompensationValue")
+  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0, "Specifies the numerator of ExposureCompensationValue")
+  ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2, "Specifies the denominator of ExposureCompensationValue")
+  ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350, "Specifies reference screen brightness setting in units of candela per square metre")
+  ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800, "Indicates the luminance dynamic range")
+  ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16, "Specifies luma sample value of the nominal black level assigned decoded pictures")
+  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
+  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
+#endif
   ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
   ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
@@ -622,4 +723,10 @@
   ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0, "Control generation of gradual decoding refresh information SEI message")
   ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0, "Control generation of decoding unit information SEI message.")
+#if L0208_SOP_DESCRIPTION_SEI
+  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
+#endif
 #if SIGNAL_BITRATE_PICRATE_IN_VPS
   ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0, "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
@@ -662,4 +769,10 @@
   /* convert std::string to c string for compatability */
 #if SVC_EXTENSION
+#if AVC_BASE
+  if( m_avcBaseLayerFlag )
+  {
+    *cfg_InputFile[0] = cfg_BLInputFile;
+  }
+#endif
   m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
 #if AVC_SYNTAX
@@ -878,4 +991,64 @@
   }
   m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
+#endif
+#if J0149_TONE_MAPPING_SEI
+  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
+  {
+    Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str());
+    Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str());
+    Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str());
+    if( m_toneMapModelId == 2 && pcStartOfCodedInterval )
+    {
+      char *startOfCodedInterval;
+      UInt num = 1u<< m_toneMapTargetBitDepth;
+      m_startOfCodedInterval = new Int[num];
+      ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num );
+      startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
+      int i = 0;
+      while( startOfCodedInterval && ( i < num ) )
+      {
+        m_startOfCodedInterval[i] = atoi( startOfCodedInterval );
+        startOfCodedInterval = strtok(NULL, " .");
+        i++;
+      }
+    } 
+    else
+    {
+      m_startOfCodedInterval = NULL;
+    }
+    if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) )
+    {
+      if( pcCodedPivotValue && pcTargetPivotValue )
+      {
+        char *codedPivotValue;
+        char *targetPivotValue;
+        m_codedPivotValue = new Int[m_numPivots];
+        m_targetPivotValue = new Int[m_numPivots];
+        ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) );
+        ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) );
+        codedPivotValue = strtok(pcCodedPivotValue, " .");
+        int i=0;
+        while(codedPivotValue&&i<m_numPivots)
+        {
+          m_codedPivotValue[i] = atoi( codedPivotValue );
+          codedPivotValue = strtok(NULL, " .");
+          i++;
+        }
+        i=0;
+        targetPivotValue = strtok(pcTargetPivotValue, " .");
+        while(targetPivotValue&&i<m_numPivots)
+        {
+          m_targetPivotValue[i]= atoi( targetPivotValue );
+          targetPivotValue = strtok(NULL, " .");
+          i++;
+        }
+      }
+    }
+    else
+    {
+      m_codedPivotValue = NULL;
+      m_targetPivotValue = NULL;
+    }
+  }
 #endif
   // check validity of input parameters
@@ -1139,4 +1312,7 @@
 
 #if SVC_EXTENSION
+  xConfirmPara( m_numLayers > MAX_LAYERS , "Number of layers in config file is greater than MAX_LAYERS" );
+  m_numLayers = m_numLayers > MAX_LAYERS ? MAX_LAYERS : m_numLayers;
+
   // verify layer configuration parameters
   for(UInt layer=0; layer<m_numLayers; layer++)
@@ -1375,11 +1551,23 @@
   {
     m_numReorderPics[i] = 0;
+#if L0323_DPB
+    m_maxDecPicBuffering[i] = 1;
+#else
     m_maxDecPicBuffering[i] = 0;
+#endif
   }
   for(Int i=0; i<m_iGOPSize; i++) 
   {
+#if L0323_DPB
+    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
+#else
     if(m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
-    {
+#endif
+    {
+#if L0323_DPB
+      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
+#else
       m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics;
+#endif
     }
     Int highestDecodingNumberWithLowerPOC = 0; 
@@ -1412,4 +1600,11 @@
       m_numReorderPics[i+1] = m_numReorderPics[i];
     }
+#if L0323_DPB
+    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
+    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
+    {
+      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
+    }
+#else
     // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
     if(m_numReorderPics[i] > m_maxDecPicBuffering[i])
@@ -1417,4 +1612,5 @@
       m_maxDecPicBuffering[i] = m_numReorderPics[i];
     }
+#endif
     // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
     if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
@@ -1423,4 +1619,13 @@
     }
   }
+
+
+#if L0323_DPB
+  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
+  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
+  {
+    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
+  }
+#else
   // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
   if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1])
@@ -1428,4 +1633,5 @@
     m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1];
   }
+#endif
 
 #if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
@@ -1511,6 +1717,7 @@
   }
 #endif
-
+#if !L0034_COMBINED_LIST_CLEANUP
   xConfirmPara( m_bUseLComb==false && m_numReorderPics[MAX_TLAYER-1]!=0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" );  // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
+#endif
   xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
 #if !SVC_EXTENSION
@@ -1520,4 +1727,17 @@
 
   xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
+
+#if J0149_TONE_MAPPING_SEI
+  if (m_toneMappingInfoSEIEnabled)
+  {
+    xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
+    xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
+    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
+    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
+    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
+    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
+    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
+  }
+#endif
 
 #if RATE_CONTROL_LAMBDA_DOMAIN
@@ -1609,5 +1829,9 @@
   {
     printf("=== Layer %d settings === \n", layer);
+#if AVC_SYNTAX
+    m_acLayerCfg[layer].xPrintParameter( layer );
+#else
     m_acLayerCfg[layer].xPrintParameter();
+#endif
     printf("\n");
   }
@@ -1677,5 +1901,7 @@
   printf("SQP:%d ", m_uiDeltaQpRD         );
   printf("ASR:%d ", m_bUseASR             );
+#if !L0034_COMBINED_LIST_CLEANUP
   printf("LComb:%d ", m_bUseLComb         );
+#endif
   printf("FEN:%d ", m_bUseFastEnc         );
   printf("ECU:%d ", m_bUseEarlyCU         );
@@ -1718,9 +1944,15 @@
 #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);
   printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
-  printf("REF_IDX_ME_ZEROMV: %d", REF_IDX_ME_ZEROMV);
+  printf("REF_IDX_ME_ZEROMV: %d ", REF_IDX_ME_ZEROMV);
+  printf("ENCODER_FAST_MODE: %d ", ENCODER_FAST_MODE);
+  printf("REF_IDX_MFM: %d ", REF_IDX_MFM);
 #elif INTRA_BL
   printf("INTRA_BL:%d ", INTRA_BL);
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 125)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 189)
@@ -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
@@ -109,6 +112,12 @@
   GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
   Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
+#if L0323_DPB
+  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of pictures in the decoded picture buffer
+#else
   Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
+#endif
+#if !L0034_COMBINED_LIST_CLEANUP
   Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
+#endif
   Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
   Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
@@ -172,4 +181,7 @@
   Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
   Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
+#if L0386_DB_METRIC
+  Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
+#endif
  
   // coding tools (PCM)
@@ -223,4 +235,31 @@
   Int       m_bufferingPeriodSEIEnabled;
   Int       m_pictureTimingSEIEnabled;
+#if J0149_TONE_MAPPING_SEI
+  Bool      m_toneMappingInfoSEIEnabled;
+  Int       m_toneMapId;
+  Bool      m_toneMapCancelFlag;
+  Bool      m_toneMapPersistenceFlag;
+  Int       m_toneMapCodedDataBitDepth;
+  Int       m_toneMapTargetBitDepth;
+  Int       m_toneMapModelId; 
+  Int       m_toneMapMinValue;
+  Int       m_toneMapMaxValue;
+  Int       m_sigmoidMidpoint;
+  Int       m_sigmoidWidth;
+  Int       m_numPivots;
+  Int       m_cameraIsoSpeedIdc;
+  Int       m_cameraIsoSpeedValue;
+  Int       m_exposureCompensationValueSignFlag;
+  Int       m_exposureCompensationValueNumerator;
+  Int       m_exposureCompensationValueDenomIdc;
+  Int       m_refScreenLuminanceWhite;
+  Int       m_extendedRangeWhiteLevel;
+  Int       m_nominalBlackLevelLumaCodeValue;
+  Int       m_nominalWhiteLevelLumaCodeValue;
+  Int       m_extendedWhiteLevelLumaCodeValue;
+  Int*      m_startOfCodedInterval;
+  Int*      m_codedPivotValue;
+  Int*      m_targetPivotValue;
+#endif
   Int       m_framePackingSEIEnabled;
   Int       m_framePackingSEIType;
@@ -232,4 +271,10 @@
   Int       m_gradualDecodingRefreshInfoEnabled;
   Int       m_decodingUnitInfoSEIEnabled;
+#if L0208_SOP_DESCRIPTION_SEI
+  Int       m_SOPDescriptionSEIEnabled;
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+  Int       m_scalableNestingSEIEnabled;
+#endif
   // weighted prediction
   Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
@@ -316,5 +361,4 @@
   Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
 #endif
-  #
 public:
   TAppEncCfg();
Index: trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 125)
+++ trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 189)
@@ -116,10 +116,17 @@
 }
 
+#if AVC_SYNTAX
+Void TAppEncLayerCfg::xPrintParameter( UInt layerId )
+#else
 Void TAppEncLayerCfg::xPrintParameter()
+#endif
 {
   printf("Input File                    : %s\n", m_cInputFile.c_str()  );
   printf("Reconstruction File           : %s\n", m_cReconFile.c_str()  );
 #if AVC_SYNTAX
-  printf("Base layer input file         : %s\n", m_cAppEncCfg->getBLSyntaxFile() );
+  if( layerId == 0 )
+  {
+    printf("Base layer syntax file        : %s\n", m_cAppEncCfg->getBLSyntaxFile() );
+  }
 #endif
   printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
Index: trunk/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 125)
+++ trunk/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 189)
@@ -54,4 +54,10 @@
   Int*      m_aidQP;                                          ///< array of slice QP values
   TAppEncCfg* m_cAppEncCfg;                                   ///< pointer to app encoder config
+#if SCALED_REF_LAYER_OFFSETS
+  Int       m_scaledRefLayerLeftOffset;
+  Int       m_scaledRefLayerTopOffset;
+  Int       m_scaledRefLayerRightOffset;
+  Int       m_scaledRefLayerBottomOffset;
+#endif  
 public:
   TAppEncLayerCfg();
@@ -63,5 +69,9 @@
   bool  parseCfg  ( const string& cfgFileName );              ///< parse layer configuration file to fill member variables
 
+#if AVC_SYNTAX
+  Void  xPrintParameter( UInt layerId );
+#else
   Void  xPrintParameter();
+#endif
   Bool  xCheckParameter();
 
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 125)
+++ trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 189)
@@ -1,37 +1,37 @@
 /* The copyright in this software is being made available under the BSD
-* License, included below. This software may be subject to other third party
-* and contributor rights, including patent rights, and no such rights are
-* granted under this license.  
-*
-* Copyright (c) 2010-2013, ITU/ISO/IEC
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-*  * Redistributions of source code must retain the above copyright notice,
-*    this list of conditions and the following disclaimer.
-*  * Redistributions in binary form must reproduce the above copyright notice,
-*    this list of conditions and the following disclaimer in the documentation
-*    and/or other materials provided with the distribution.
-*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
-*    be used to endorse or promote products derived from this software without
-*    specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-* THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * License, included below. This software may be subject to other third party
+ * and contributor rights, including patent rights, and no such rights are
+ * granted under this license.  
+ *
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
+ *    be used to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
 /** \file     TAppEncTop.cpp
-\brief    Encoder application class
+    \brief    Encoder application class
 */
 
@@ -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 
@@ -167,4 +171,7 @@
     m_acTEncTop[layer].setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
     m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
+#if L0386_DB_METRIC
+    m_acTEncTop[layer].setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
+#endif
 
     //====== Motion search ========
@@ -200,5 +207,7 @@
     m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
     m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
-    m_acTEncTop[layer].setUseLComb                     ( m_bUseLComb    );
+#if !L0034_COMBINED_LIST_CLEANUP
+    m_cTEncTop.setUseLComb                             ( m_bUseLComb    );
+#endif
     m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
     m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
@@ -270,4 +279,31 @@
     m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
     m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
+#if J0149_TONE_MAPPING_SEI
+    m_acTEncTop[layer].setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
+    m_acTEncTop[layer].setTMISEIToneMapId                           ( m_toneMapId );
+    m_acTEncTop[layer].setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
+    m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
+    m_acTEncTop[layer].setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
+    m_acTEncTop[layer].setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
+    m_acTEncTop[layer].setTMISEIModelID                             ( m_toneMapModelId );
+    m_acTEncTop[layer].setTMISEIMinValue                            ( m_toneMapMinValue );
+    m_acTEncTop[layer].setTMISEIMaxValue                            ( m_toneMapMaxValue );
+    m_acTEncTop[layer].setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
+    m_acTEncTop[layer].setTMISEISigmoidWidth                        ( m_sigmoidWidth );
+    m_acTEncTop[layer].setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
+    m_acTEncTop[layer].setTMISEINumPivots                           ( m_numPivots );
+    m_acTEncTop[layer].setTMISEICodedPivotValue                     ( m_codedPivotValue );
+    m_acTEncTop[layer].setTMISEITargetPivotValue                    ( m_targetPivotValue );
+    m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
+    m_acTEncTop[layer].setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
+    m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
+    m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
+    m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
+    m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
+    m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
+    m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
+    m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
+    m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
+#endif
     m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
@@ -279,4 +315,10 @@
     m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
     m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
+#if L0208_SOP_DESCRIPTION_SEI
+    m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+    m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
+#endif
     m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
     m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
@@ -376,4 +418,11 @@
     m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
 #endif
+#if SCALED_REF_LAYER_OFFSETS
+    if( layer > 0 )
+    {
+      m_acTEncTop[layer].getScaledRefLayerWindow().setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset, 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset,
+                                                  2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset, 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset);  
+    }
+#endif
   }
 }
@@ -442,4 +491,7 @@
   m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
   m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
+#if L0386_DB_METRIC
+  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
+#endif
 
   //====== Motion search ========
@@ -475,5 +527,7 @@
   m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
   m_cTEncTop.setUseLossless                  ( m_useLossless );
+#if !L0034_COMBINED_LIST_CLEANUP
   m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
+#endif
   m_cTEncTop.setdQPs                         ( m_aidQP        );
   m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
@@ -545,4 +599,31 @@
   m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
   m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
+#if J0149_TONE_MAPPING_SEI
+  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
+  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
+  m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
+  m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
+  m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
+  m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
+  m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
+  m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
+  m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
+  m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
+  m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
+  m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
+  m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
+  m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
+  m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
+  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
+  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
+  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
+  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
+  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
+  m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
+  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
+  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
+  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
+  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
+#endif
   m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
   m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
@@ -554,4 +635,10 @@
   m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
   m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
+#if L0208_SOP_DESCRIPTION_SEI
+  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
+#endif
   m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
   m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
@@ -729,5 +816,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++)
@@ -769,7 +860,16 @@
 #endif
   // Target output layer
+#if VPS_PROFILE_OUTPUT_LAYERS
+  vps->setNumOutputLayerSets(2);    // 2 including the default base-layer set.
+  vps->setNumProfileTierLevel(2);   // 1 for the enhancement layer
+  vps->setProfileLevelTierIdx(1, 1);
+  vps->setDefaultOneTargetOutputLayerFlag(true);
+  Int lsIdx = 1;
+  vps->setOutputLayerSetIdx(1, lsIdx); // Because only one layer set
+#else
   vps->setNumOutputLayerSets(1);
   Int lsIdx = 1;
   vps->setOutputLayerSetIdx(0, lsIdx); // Because only one layer set
+#endif
   // Include the highest layer as output layer 
   for(UInt layer=0; layer <= vps->getMaxLayerId() ; layer++)
@@ -802,4 +902,7 @@
   }
 #endif
+#if JCTVC_M0458_INTERLAYER_RPS_SIG        
+    vps->setMaxOneActiveRefLayerFlag(true); 
+#endif 
 #else
   m_cTEncTop.init();
@@ -812,11 +915,11 @@
 
 /**
-- create internal class
-- initialize internal variable
-- until the end of input YUV file, call encoding function in TEncTop class
-- delete allocated buffers
-- destroy internal class
-.
-*/
+ - create internal class
+ - initialize internal variable
+ - until the end of input YUV file, call encoding function in TEncTop class
+ - delete allocated buffers
+ - destroy internal class
+ .
+ */
 #if SVC_EXTENSION
 Void TAppEncTop::encode()
@@ -855,16 +958,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
 
@@ -1102,9 +1209,9 @@
 
 /**
-- application has picture buffer list with size of GOP
-- picture buffer list acts as ring buffer
-- end of the list has the latest picture
-.
-*/
+ - application has picture buffer list with size of GOP
+ - picture buffer list acts as ring buffer
+ - end of the list has the latest picture
+ .
+ */
 #if SVC_EXTENSION
 Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
@@ -1222,5 +1329,5 @@
 
 /** \param iNumEncoded  number of encoded frames
-*/
+ */
 Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
 {
@@ -1240,5 +1347,9 @@
     if (m_pchReconFile)
     {
+#if SYNTAX_OUTPUT && ILP_DECODED_PICTURE
+      m_cTVideoIOYuvReconFile.write( pcPicYuvRec );
+#else
       m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
+#endif
     }
 
@@ -1251,6 +1362,6 @@
 
 /**
-*
-*/
+ *
+ */
 void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
 {
@@ -1264,18 +1375,18 @@
     case NAL_UNIT_CODED_SLICE_TRAIL_R:
     case NAL_UNIT_CODED_SLICE_TRAIL_N:
-    case NAL_UNIT_CODED_SLICE_TLA:
+    case NAL_UNIT_CODED_SLICE_TLA_R:
     case NAL_UNIT_CODED_SLICE_TSA_N:
     case NAL_UNIT_CODED_SLICE_STSA_R:
     case NAL_UNIT_CODED_SLICE_STSA_N:
-    case NAL_UNIT_CODED_SLICE_BLA:
-    case NAL_UNIT_CODED_SLICE_BLANT:
+    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
+    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
     case NAL_UNIT_CODED_SLICE_BLA_N_LP:
-    case NAL_UNIT_CODED_SLICE_IDR:
+    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
     case NAL_UNIT_CODED_SLICE_IDR_N_LP:
     case NAL_UNIT_CODED_SLICE_CRA:
     case NAL_UNIT_CODED_SLICE_RADL_N:
-    case NAL_UNIT_CODED_SLICE_DLP:
+    case NAL_UNIT_CODED_SLICE_RADL_R:
     case NAL_UNIT_CODED_SLICE_RASL_N:
-    case NAL_UNIT_CODED_SLICE_TFD:
+    case NAL_UNIT_CODED_SLICE_RASL_R:
     case NAL_UNIT_VPS:
     case NAL_UNIT_SPS:
