Index: trunk/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 55)
+++ trunk/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -64,5 +64,5 @@
 Bool TAppDecCfg::parseCfg( Int argc, Char* argv[] )
 {
-  bool do_help = false;
+  Bool do_help = false;
   string cfg_BitstreamFile;
 #if SVC_EXTENSION
@@ -78,7 +78,5 @@
   string cfg_BLSyntaxFile;
 #endif
-#if TARGET_DECLAYERID_SET
   string cfg_TargetDecLayerIdSetFile;
-#endif
 
   po::Options opts;
@@ -108,22 +106,21 @@
 #endif
   ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
-  ("OutputBitDepth,d", m_outputBitDepth, 0u, "bit depth of YUV output file (use 0 for native depth)")
+  ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)")
+  ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)")
 #if SVC_EXTENSION
   ("LayerNum,-ls", nLayerNum, 1, "Number of layers to be decoded.")
 #endif 
   ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
-  ("SEIpictureDigest", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n"
-                                              "\t3: checksum\n"
-                                              "\t2: CRC\n"
-                                              "\t1: MD5\n"
-                                              "\t0: ignore")
-#if TARGET_DECLAYERID_SET
+  ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n"
+                                              "\t1: check hash in SEI messages if available in the bitstream\n"
+                                              "\t0: ignore SEI message")
+  ("SEIpictureDigest", m_decodedPictureHashSEIEnabled, 1, "deprecated alias for SEIDecodedPictureHash")
   ("TarDecLayerIdSetFile,l", cfg_TargetDecLayerIdSetFile, string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
-#endif
+  ("RespectDefDispWindow,w", m_respectDefDispWindow, 0, "Only output content inside the default display window\n")
   ;
   po::setDefaults(opts);
-  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv);
-
-  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
+
+  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
@@ -161,5 +158,4 @@
   }
 
-#if TARGET_DECLAYERID_SET
   if ( !cfg_TargetDecLayerIdSetFile.empty() )
   {
@@ -206,5 +202,4 @@
     }
   }
-#endif
 
   return true;
Index: trunk/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecCfg.h	(revision 55)
+++ trunk/source/App/TAppDecoder/TAppDecCfg.h	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -44,7 +44,5 @@
 
 #include "TLibCommon/CommonDef.h"
-#if TARGET_DECLAYERID_SET
 #include <vector>
-#endif
 
 //! \ingroup TAppDecoder
@@ -59,20 +57,20 @@
 {
 protected:
-  char*         m_pchBitstreamFile;                   ///< input bitstream file name
+  Char*         m_pchBitstreamFile;                   ///< input bitstream file name
 #if SVC_EXTENSION
-  char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
+  Char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
 #if AVC_BASE
-  char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
+  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  
+  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name  
 #endif
 #endif
 #else
-  char*         m_pchReconFile;                       ///< output reconstruction file name
+  Char*         m_pchReconFile;                       ///< output reconstruction file name
 #endif
 #if SYNTAX_OUTPUT
-  char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
+  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
   Int           m_iBLSourceWidth;
   Int           m_iBLSourceHeight;
@@ -80,5 +78,6 @@
 #endif
   Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
-  UInt          m_outputBitDepth;                     ///< bit depth used for writing output
+  Int           m_outputBitDepthY;                     ///< bit depth used for writing output (luma)
+  Int           m_outputBitDepthC;                     ///< bit depth used for writing output (chroma)t
 
   Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
@@ -88,11 +87,32 @@
   Int           m_tgtLayerId;                        ///< target layer ID
 #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 
 
-#if TARGET_DECLAYERID_SET
-  std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
+public:
+  TAppDecCfg()
+  : m_pchBitstreamFile(NULL)
+#if !SVC_EXTENSION
+  , m_pchReconFile(NULL) 
 #endif
-  
-public:
-  TAppDecCfg()          {}
+  , m_iSkipFrame(0)
+  , m_outputBitDepthY(0)
+  , m_outputBitDepthC(0)
+  , m_iMaxTemporalLayer(-1)
+  , m_decodedPictureHashSEIEnabled(0)
+#if SVC_EXTENSION
+  , m_tgtLayerId(0)
+#endif
+  , m_respectDefDispWindow(0)
+#if AVC_BASE
+  , m_iBLSourceWidth(0)
+  , m_iBLSourceHeight(0)
+#endif
+#if SYNTAX_OUTPUT
+  , m_iBLSourceWidth(0)
+  , m_iBLSourceHeight(0)
+  , m_iBLFrames(0)
+#endif
+  {}
   virtual ~TAppDecCfg() {}
   
Index: trunk/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 55)
+++ trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -53,8 +53,8 @@
 // ====================================================================================================================
 
+#if SVC_EXTENSION
 TAppDecTop::TAppDecTop()
 {
   ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
-#if SVC_EXTENSION
   for(UInt layer=0; layer < MAX_LAYERS; layer++)
   {
@@ -62,9 +62,12 @@
     m_apcTDecTop[layer] = &m_acTDecTop[layer];
   }
-#else
-  m_iPOCLastDisplay  = -MAX_INT;
-#endif
-
-}
+}
+#else
+TAppDecTop::TAppDecTop()
+: m_iPOCLastDisplay(-MAX_INT)
+{
+  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
+}
+#endif
 
 Void TAppDecTop::create()
@@ -126,5 +129,5 @@
 Void TAppDecTop::decode()
 {
-  UInt                uiPOC;
+  Int                poc;
   TComList<TComPic*>* pcListPic = NULL;
 
@@ -143,5 +146,5 @@
 
   // main decoder loop
-  bool recon_opened[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)
+  Bool recon_opened[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)
   for(UInt layer=0; layer<=m_tgtLayerId; layer++)
   {
@@ -200,6 +203,6 @@
 
     // call actual decoding function
-    bool bNewPicture = false;
-    bool bNewPOC = false;
+    Bool bNewPicture = false;
+    Bool bNewPOC = false;
     if (nalUnit.empty())
     {
@@ -214,11 +217,6 @@
     {
       read(nalu, nalUnit);
-#if TARGET_DECLAYERID_SET
       if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  ||
         (nalu.m_layerId > m_tgtLayerId) )
-#else
-      if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer ||
-        (nalu.m_layerId > m_tgtLayerId) )
-#endif
       {
         bNewPicture = false;
@@ -241,5 +239,5 @@
     if (bNewPicture || !bitstreamFile)
     {
-      m_acTDecTop[curLayerId].executeDeblockAndAlf(uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplay[curLayerId]);
+      m_acTDecTop[curLayerId].executeLoopFilters(poc, pcListPic);
     }
 
@@ -248,18 +246,15 @@
       if ( m_pchReconFile[curLayerId] && !recon_opened[curLayerId] )
       {
-        if ( m_outputBitDepth == 0 )
-        {
-          m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
-        }
-
-        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); // write mode
+        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }        
+        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
+
+        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
+
         recon_opened[curLayerId] = true;
       }
       if ( bNewPicture && bNewPOC && 
            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
-#if SUPPORT_FOR_RAP_N_LP
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
-#endif
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
@@ -306,5 +301,5 @@
 Void TAppDecTop::decode()
 {
-  UInt                uiPOC;
+  Int                 poc;
   TComList<TComPic*>* pcListPic = NULL;
 
@@ -324,5 +319,5 @@
 
   // main decoder loop
-  bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
+  Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
 
 #if SYNTAX_OUTPUT
@@ -355,5 +350,5 @@
     streampos location = bitstreamFile.tellg();
     AnnexBStats stats = AnnexBStats();
-    bool bPreviousPictureDecoded = false;
+    Bool bPreviousPictureDecoded = false;
 
     vector<uint8_t> nalUnit;
@@ -362,5 +357,5 @@
 
     // call actual decoding function
-    bool bNewPicture = false;
+    Bool bNewPicture = false;
     if (nalUnit.empty())
     {
@@ -375,9 +370,5 @@
     {
       read(nalu, nalUnit);
-#if TARGET_DECLAYERID_SET
       if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
-#else
-      if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer)
-#endif
       {
         if(bPreviousPictureDecoded)
@@ -409,5 +400,5 @@
     if (bNewPicture || !bitstreamFile)
     {
-      m_cTDecTop.executeDeblockAndAlf(uiPOC, pcListPic, m_iSkipFrame, m_iPOCLastDisplay);
+      m_cTDecTop.executeLoopFilters(poc, pcListPic);
     }
 
@@ -416,18 +407,14 @@
       if ( m_pchReconFile && !recon_opened )
       {
-        if ( m_outputBitDepth == 0 )
-        {
-          m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
-        }
-
-        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); // write mode
+        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
+        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
+
+        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
         recon_opened = true;
       }
       if ( bNewPicture && 
            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
-#if SUPPORT_FOR_RAP_N_LP
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
-#endif
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
@@ -442,5 +429,5 @@
     }
   }
-
+  
 #if SYNTAX_OUTPUT
   if( streamSyntaxFile.is_open() )
@@ -559,10 +546,9 @@
   {
     TComPic* pcPic = *(iterPic);
-    TComSPS *sps = pcPic->getSlice(0)->getSPS();
     
 #if SVC_EXTENSION
-    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
-#else
-    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
+    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
+#else
+    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
 #endif
     {
@@ -572,5 +558,11 @@
       if ( m_pchReconFile[layerId] )
       {
-        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
+        const Window &conf = pcPic->getConformanceWindow();
+        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
+        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
+                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
       }
       
@@ -580,5 +572,11 @@
       if ( m_pchReconFile )
       {
-        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
+        const Window &conf = pcPic->getConformanceWindow();
+        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
+        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
+                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
       }
       
@@ -630,5 +628,4 @@
   {
     TComPic* pcPic = *(iterPic);
-    TComSPS *sps = pcPic->getSlice(0)->getSPS();
 
     if ( pcPic->getOutputMark() )
@@ -638,5 +635,11 @@
       if ( m_pchReconFile[layerId] )
       {
-        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
+        const Window &conf = pcPic->getConformanceWindow();
+        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
+        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
+                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
       }
       
@@ -646,5 +649,11 @@
       if ( m_pchReconFile )
       {
-        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
+        const Window &conf = pcPic->getConformanceWindow();
+        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
+        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
+                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
       }
       
@@ -679,5 +688,5 @@
       pcPic = NULL;
     }
-#endif
+#endif    
 #endif
     iterPic++;
@@ -686,10 +695,9 @@
   m_aiPOCLastDisplay[layerId] = -MAX_INT;
 #else
-  pcListPic->clear(); //k Cannot be cleared here. Otherwise, pictures will never be destroyed.
+  pcListPic->clear();
   m_iPOCLastDisplay = -MAX_INT;
 #endif
 }
 
-#if TARGET_DECLAYERID_SET
 /** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet
  */
@@ -709,5 +717,4 @@
   return false;
 }
-#endif
 
 //! \}
Index: trunk/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecTop.h	(revision 55)
+++ trunk/source/App/TAppDecoder/TAppDecTop.h	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -98,7 +98,5 @@
   Void  xFlushOutput      ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file
 #endif
-#if TARGET_DECLAYERID_SET
   Bool  isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
-#endif
 };
 
Index: trunk/source/App/TAppDecoder/decmain.cpp
===================================================================
--- trunk/source/App/TAppDecoder/decmain.cpp	(revision 55)
+++ trunk/source/App/TAppDecoder/decmain.cpp	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 55)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -42,4 +42,9 @@
 #include "TLibCommon/TComRom.h"
 #include "TAppEncCfg.h"
+
+static istream& operator>>(istream &, Level::Name &);
+static istream& operator>>(istream &, Level::Tier &);
+static istream& operator>>(istream &, Profile::Name &);
+
 #include "TAppCommon/program_options_lite.h"
 #include "TLibEncoder/TEncRateCtrl.h"
@@ -58,49 +63,51 @@
 // ====================================================================================================================
 
+#if SVC_EXTENSION
 TAppEncCfg::TAppEncCfg()
-#if SVC_EXTENSION
-: m_pchBitstreamFile()
-, m_pchColumnWidth()
-, m_pchRowHeight()
+: m_pBitstreamFile()
+, m_pColumnWidth()
+, m_pRowHeight()
 , m_scalingListFile()
 #if REF_IDX_FRAMEWORK
 , m_elRapSliceBEnabled(0)
 #endif
+{
+  for(UInt layer=0; layer<MAX_LAYERS; layer++)
+  {
+    m_acLayerCfg[layer].setAppEncCfg(this);
+  }
+}
 #else
+TAppEncCfg::TAppEncCfg()
 : m_pchInputFile()
 , m_pchBitstreamFile()
 , m_pchReconFile()
 , m_pchdQPFile()
-, m_pchColumnWidth()
-, m_pchRowHeight()
+, m_pColumnWidth()
+, m_pRowHeight()
 , m_scalingListFile()
-#endif
+{
+  m_aidQP = NULL;
+}
+#endif
+
+TAppEncCfg::~TAppEncCfg()
 {
 #if SVC_EXTENSION
-  for(UInt layer=0; layer<MAX_LAYERS; layer++)
-  {
-    m_acLayerCfg[layer].setAppEncCfg(this);
-  }
+  free(m_pBitstreamFile);
 #else
-  m_aidQP = NULL;
-#endif
-}
-
-TAppEncCfg::~TAppEncCfg()
-{
-#if !SVC_EXTENSION
+  free(m_pchBitstreamFile);
   if ( m_aidQP )
   {
     delete[] m_aidQP;
   }
-  free(m_pchInputFile); 
-#endif
-  free(m_pchBitstreamFile);
+  free(m_pchInputFile);
+#endif
 #if !SVC_EXTENSION  
   free(m_pchReconFile);
   free(m_pchdQPFile);
 #endif
-  free(m_pchColumnWidth);
-  free(m_pchRowHeight);
+  free(m_pColumnWidth);
+  free(m_pRowHeight);
   free(m_scalingListFile);
 }
@@ -120,9 +127,8 @@
   in>>entry.m_QPOffset;
   in>>entry.m_QPFactor;
+  in>>entry.m_tcOffsetDiv2;
+  in>>entry.m_betaOffsetDiv2;
   in>>entry.m_temporalId;
   in>>entry.m_numRefPicsActive;
-#if !TEMPORAL_LAYER_NON_REFERENCE
-  in>>entry.m_refPic;
-#endif
   in>>entry.m_numRefPics;
   for ( Int i = 0; i < entry.m_numRefPics; i++ )
@@ -134,7 +140,4 @@
   if (entry.m_interRPSPrediction==1)
   {
-#if !J0234_INTER_RPS_SIMPL
-    in>>entry.m_deltaRIdxMinus1;
-#endif
     in>>entry.m_deltaRPS;
     in>>entry.m_numRefIdc;
@@ -146,7 +149,4 @@
   else if (entry.m_interRPSPrediction==2)
   {
-#if !J0234_INTER_RPS_SIMPL
-    in>>entry.m_deltaRIdxMinus1;
-#endif
     in>>entry.m_deltaRPS;
   }
@@ -154,7 +154,4 @@
   if (entry.m_interRPSPrediction)
   {
-#if !J0234_INTER_RPS_SIMPL
-    in>>entry.m_deltaRIdxMinus1;
-#endif
     in>>entry.m_deltaRPS;
     in>>entry.m_numRefIdc;
@@ -194,4 +191,81 @@
 #endif
 
+static const struct MapStrToProfile {
+  const Char* str;
+  Profile::Name value;
+} strToProfile[] = {
+  {"none", Profile::NONE},
+  {"main", Profile::MAIN},
+  {"main10", Profile::MAIN10},
+  {"main-still-picture", Profile::MAINSTILLPICTURE},
+};
+
+static const struct MapStrToTier {
+  const Char* str;
+  Level::Tier value;
+} strToTier[] = {
+  {"main", Level::MAIN},
+  {"high", Level::HIGH},
+};
+
+static const struct MapStrToLevel {
+  const Char* str;
+  Level::Name value;
+} strToLevel[] = {
+  {"none",Level::NONE},
+  {"1",   Level::LEVEL1},
+  {"2",   Level::LEVEL2},
+  {"2.1", Level::LEVEL2_1},
+  {"3",   Level::LEVEL3},
+  {"3.1", Level::LEVEL3_1},
+  {"4",   Level::LEVEL4},
+  {"4.1", Level::LEVEL4_1},
+  {"5",   Level::LEVEL5},
+  {"5.1", Level::LEVEL5_1},
+  {"5.2", Level::LEVEL5_2},
+  {"6",   Level::LEVEL6},
+  {"6.1", Level::LEVEL6_1},
+  {"6.2", Level::LEVEL6_2},
+};
+
+template<typename T, typename P>
+static istream& readStrToEnum(P map[], unsigned long mapLen, istream &in, T &val)
+{
+  string str;
+  in >> str;
+
+  for (Int i = 0; i < mapLen; i++)
+  {
+    if (str == map[i].str)
+    {
+      val = map[i].value;
+      goto found;
+    }
+  }
+  /* not found */
+  in.setstate(ios::failbit);
+found:
+  return in;
+}
+
+static istream& operator>>(istream &in, Profile::Name &profile)
+{
+  return readStrToEnum(strToProfile, sizeof(strToProfile)/sizeof(*strToProfile), in, profile);
+}
+
+static istream& operator>>(istream &in, Level::Tier &tier)
+{
+  return readStrToEnum(strToTier, sizeof(strToTier)/sizeof(*strToTier), in, tier);
+}
+
+static istream& operator>>(istream &in, Level::Name &level)
+{
+  return readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), in, level);
+}
+
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName);
+Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName);
+#endif
 // ====================================================================================================================
 // Public member functions
@@ -204,5 +278,5 @@
 Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] )
 {
-  bool do_help = false;
+  Bool do_help = false;
   
 #if SVC_EXTENSION
@@ -217,5 +291,10 @@
   Int*    cfg_FrameRate     [MAX_LAYERS];
   Int*    cfg_IntraPeriod   [MAX_LAYERS];
-  Int*    cfg_CroppingMode  [MAX_LAYERS];
+  Int*    cfg_conformanceMode  [MAX_LAYERS];
+#if VPS_EXTN_DIRECT_REF_LAYERS
+  Int*    cfg_numDirectRefLayers [MAX_LAYERS];
+  string cfg_refLayerIds   [MAX_LAYERS];
+  string* cfg_refLayerIdsPtr   [MAX_LAYERS];
+#endif
   for(UInt layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -227,5 +306,9 @@
     cfg_FrameRate[layer]    = &m_acLayerCfg[layer].m_iFrameRate; 
     cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod; 
-    cfg_CroppingMode[layer] = &m_acLayerCfg[layer].m_croppingMode;
+    cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
+#if VPS_EXTN_DIRECT_REF_LAYERS
+    cfg_numDirectRefLayers  [layer] = &m_acLayerCfg[layer].m_numDirectRefLayers;
+    cfg_refLayerIdsPtr      [layer]  = &cfg_refLayerIds[layer];
+#endif
   }
 #if AVC_SYNTAX
@@ -241,4 +324,12 @@
   string cfg_RowHeight;
   string cfg_ScalingListFile;
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+  string cfg_bitRateInfoPresentFlag;
+  string cfg_picRateInfoPresentFlag;
+  string cfg_avgBitRate;
+  string cfg_maxBitRate;
+  string cfg_avgPicRate;
+  string cfg_constantPicRateIdc;
+#endif
   po::Options opts;
   opts.addOptions()
@@ -251,14 +342,24 @@
   ("ReconFile%d,-o%d",        cfg_ReconFile,  string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d")
   ("LayerConfig%d,-lc%d",     cfg_LayerCfgFile, string(""), MAX_LAYERS, "layer %d configuration file name")
-  ("BitstreamFile,b",         cfg_BitstreamFile, string(""), "bitstream output file name")
   ("SourceWidth%d,-wdt%d",    cfg_SourceWidth, 0, MAX_LAYERS, "Source picture width for layer %d")
   ("SourceHeight%d,-hgt%d",   cfg_SourceHeight, 0, MAX_LAYERS, "Source picture height for layer %d")
   ("FrameRate%d,-fr%d",       cfg_FrameRate,  0, MAX_LAYERS, "Frame rate for layer %d")
   ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
-  ("CroppingMode%d",          cfg_CroppingMode,0, MAX_LAYERS, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
-  ("InputBitDepth",           m_uiInputBitDepth, 8u, "bit-depth of input file")
-  ("BitDepth",                m_uiInputBitDepth, 8u, "deprecated alias of InputBitDepth")
-  ("OutputBitDepth",          m_uiOutputBitDepth, 0u, "bit-depth of output file")
-  ("InternalBitDepth",        m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)")
+#if VPS_EXTN_DIRECT_REF_LAYERS
+  ("NumDirectRefLayers%d",    cfg_numDirectRefLayers, -1, MAX_LAYERS, "Number of direct reference layers")
+  ("RefLayerIds%d",           cfg_refLayerIdsPtr, string(""), MAX_LAYERS, "direct reference layer IDs")
+#endif
+  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
+  ("ConformanceMode%d",       cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
+
+  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
+  ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
+  ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
+  ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
+                                                       "If different to InputBitDepth, source data will be converted")
+  ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
+  ("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 AVC_BASE
   ("InputBLFile,-ibl",        *cfg_InputFile[0],     string(""), "Base layer rec YUV input file name")
@@ -269,6 +370,6 @@
 #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_")
-#endif
-#else
+#endif  
+#else  
   ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
   ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
@@ -276,22 +377,33 @@
   ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
   ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
-  ("InputBitDepth",         m_uiInputBitDepth,    8u, "Bit-depth of input file")
-  ("BitDepth",              m_uiInputBitDepth,    8u, "Deprecated alias of InputBitDepth")
-  ("OutputBitDepth",        m_uiOutputBitDepth,   0u, "Bit-depth of output file")
-  ("InternalBitDepth",      m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)")
-  ("CroppingMode",          m_croppingMode,        0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
-  ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for cropping mode 2")
-  ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for cropping mode 2")
-  ("CropLeft",              m_cropLeft,            0, "Left cropping for cropping mode 3")
-  ("CropRight",             m_cropRight,           0, "Right cropping for cropping mode 3")
-  ("CropTop",               m_cropTop,             0, "Top cropping for cropping mode 3")
-  ("CropBottom",            m_cropBottom,          0, "Bottom cropping for cropping mode 3")
+  ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
+  ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
+  ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
+                                                       "If different to InputBitDepth, source data will be converted")
+  ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
+  ("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)")
+  ("ConformanceMode",       m_conformanceMode,     0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
+  ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
+  ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
+  ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
+  ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
+  ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
+  ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
   ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
 #endif
   ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
-  ("FramesToBeEncoded,f",   m_iFrameToBeEncoded,   0, "Number of frames to be encoded (default=all)")
-  
-#if SVC_EXTENSION
-  ("NumLayers",             m_numLayers, 1, "Number of layers to code")
+  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
+  
+  // Profile and level
+  ("Profile", m_profile,   Profile::NONE, "Profile to be used when encoding (Incomplete)")
+  ("Level",   m_level,     Level::NONE,   "Level limit to be used, eg 5.1 (Incomplete)")
+  ("Tier",    m_levelTier, Level::MAIN,   "Tier to use for interpretation of --Level")
+
+#if L0046_CONSTRAINT_FLAGS
+  ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive")
+  ("InterlacedSource",  m_interlacedSourceFlag,  false, "Indicate that source is interlaced")
+  ("NonPackedSource",   m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing")
+  ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
 #endif
 
@@ -326,14 +438,16 @@
   ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
 
-#if !SVC_EXTENSION
+#if SVC_EXTENSION
+  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
+#else
   // Mode decision parameters
-  ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( double )1.0, "Lambda modifier for temporal layer 0")
-  ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( double )1.0, "Lambda modifier for temporal layer 1")
-  ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( double )1.0, "Lambda modifier for temporal layer 2")
-  ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( double )1.0, "Lambda modifier for temporal layer 3")
-  ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( double )1.0, "Lambda modifier for temporal layer 4")
-  ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( double )1.0, "Lambda modifier for temporal layer 5")
-  ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( double )1.0, "Lambda modifier for temporal layer 6")
-  ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( double )1.0, "Lambda modifier for temporal layer 7")
+  ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( Double )1.0, "Lambda modifier for temporal layer 0")
+  ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( Double )1.0, "Lambda modifier for temporal layer 1")
+  ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( Double )1.0, "Lambda modifier for temporal layer 2")
+  ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( Double )1.0, "Lambda modifier for temporal layer 3")
+  ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( Double )1.0, "Lambda modifier for temporal layer 4")
+  ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( Double )1.0, "Lambda modifier for temporal layer 5")
+  ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6")
+  ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( Double )1.0, "Lambda modifier for temporal layer 7")
 #endif
 
@@ -360,6 +474,9 @@
   ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
 #endif
-  ("RDOQ",                          m_bUseRDOQ,                  true )
-  
+  ("RDOQ",                          m_useRDOQ,                  true )
+  ("RDOQTS",                        m_useRDOQTS,                true )
+#if L0232_RD_PENALTY
+  ("RDpenalty",                     m_rdPenalty,                0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
+#endif
   // Entropy coding parameters
   ("SBACRD",                         m_bUseSBACRD,                      true, "SBAC based RD estimation")
@@ -373,70 +490,55 @@
 
   // Coding tools
-#if !REMOVE_NSQT
-  ("NSQT",                    m_enableNSQT,              true, "Enable non-square transforms")
-#endif
-  ("AMP",                     m_enableAMP,               true, "Enable asymmetric motion partitions")
-#if !REMOVE_LMCHROMA
-  ("LMChroma",                m_bUseLMChroma,            true, "Intra chroma prediction based on reconstructed luma")
-#endif
-  ("TransformSkip",           m_useTransformSkip,        false, "Intra transform skipping")
-  ("TransformSkipFast",       m_useTransformSkipFast,    false, "Fast intra transform skipping")
-#if !REMOVE_ALF
-  ("ALF",                     m_bUseALF,                 true, "Enable Adaptive Loop Filter")
-#endif
-  ("SAO",                     m_bUseSAO,                 true, "Enable Sample Adaptive Offset")
-  ("MaxNumOffsetsPerPic",     m_maxNumOffsetsPerPic,     2048, "Max number of SAO offset per picture (Default: 2048)")   
-#if SAO_LCU_BOUNDARY
-  ("SAOLcuBoundary",          m_saoLcuBoundary,          false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
-#endif
-  ("SAOLcuBasedOptimization", m_saoLcuBasedOptimization, true, "0: SAO picture-based optimization, 1: SAO LCU-based optimization ")
-#if !REMOVE_ALF
-  ("ALFLowLatencyEncode", m_alfLowLatencyEncoding, false, "Low-latency ALF encoding, 0: picture latency (trained from current frame), 1: LCU latency(trained from previous frame)")
-#endif
-  ("SliceMode",            m_iSliceMode,           0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes")
-    ("SliceArgument",        m_iSliceArgument,       0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.")
-    ("DependentSliceMode",     m_iDependentSliceMode,    0, "0: Disable all dependent slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based dependent slices")
-    ("DependentSliceArgument", m_iDependentSliceArgument,0, "if DependentSliceMode==1 SliceArgument represents max # of LCUs. if DependentSliceMode==2 DependentSliceArgument represents max # of bins.")
-#if DEPENDENT_SLICES
-#if TILES_WPP_ENTROPYSLICES_FLAGS
-    ("EntropySliceEnabledFlag", m_entropySliceEnabledFlag, false, "Enable use of entropy slices instead of dependent slices." )
-#else
-    ("CabacIndependentFlag", m_bCabacIndependentFlag, false)
-#endif
-#endif
-#if !REMOVE_FGS
-    ("SliceGranularity",     m_iSliceGranularity,    0, "0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.")
-#endif
-    ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
-
-    ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction")
-    ("PCMEnabledFlag", m_usePCM         , false)
-    ("PCMLog2MaxSize", m_pcmLog2MaxSize, 5u)
-    ("PCMLog2MinSize", m_uiPCMLog2MinSize, 3u)
-
-    ("PCMInputBitDepthFlag", m_bPCMInputBitDepthFlag, true)
-    ("PCMFilterDisableFlag", m_bPCMFilterDisableFlag, false)
-    ("LosslessCuEnabled", m_useLossless, false)
-    ("weighted_pred_flag,-wpP",     m_bUseWeightPred, false, "weighted prediction flag (P-Slices)")
-    ("weighted_bipred_flag,-wpB",   m_useWeightedBiPred,    false,    "weighted bipred flag (B-Slices)")
-    ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
-    ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
-    ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
-    ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
-    ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
-    ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
-    ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
-    ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
-    ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
-    ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
-    ("SignHideFlag,-SBH",                m_signHideFlag, 1)
-    ("MaxNumMergeCand",             m_maxNumMergeCand,             5u,         "Maximum number of merge candidates")
+  ("AMP",                      m_enableAMP,                 true,  "Enable asymmetric motion partitions")
+  ("TransformSkip",            m_useTransformSkip,          false, "Intra transform skipping")
+  ("TransformSkipFast",        m_useTransformSkipFast,      false, "Fast intra transform skipping")
+  ("SAO",                      m_bUseSAO,                   true,  "Enable Sample Adaptive Offset")
+  ("MaxNumOffsetsPerPic",      m_maxNumOffsetsPerPic,       2048,  "Max number of SAO offset per picture (Default: 2048)")   
+  ("SAOLcuBoundary",           m_saoLcuBoundary,            false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
+  ("SAOLcuBasedOptimization",  m_saoLcuBasedOptimization,   true,  "0: SAO picture-based optimization, 1: SAO LCU-based optimization ")
+  ("SliceMode",                m_sliceMode,                0,     "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
+  ("SliceArgument",            m_sliceArgument,            0,     "Depending on SliceMode being:"
+                                                                   "\t1: max number of CTUs per slice"
+                                                                   "\t2: max number of bytes per slice"
+                                                                   "\t3: max number of tiles per slice")
+  ("SliceSegmentMode",         m_sliceSegmentMode,       0,     "0: Disable all slice segment limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
+  ("SliceSegmentArgument",     m_sliceSegmentArgument,   0,     "Depending on SliceSegmentMode being:"
+                                                                   "\t1: max number of CTUs per slice segment"
+                                                                   "\t2: max number of bytes per slice segment"
+                                                                   "\t3: max number of tiles per slice segment")
+  ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
+
+  ("ConstrainedIntraPred",     m_bUseConstrainedIntraPred,  false, "Constrained Intra Prediction")
+
+  ("PCMEnabledFlag",           m_usePCM,                    false)
+  ("PCMLog2MaxSize",           m_pcmLog2MaxSize,            5u)
+  ("PCMLog2MinSize",           m_uiPCMLog2MinSize,          3u)
+  ("PCMInputBitDepthFlag",     m_bPCMInputBitDepthFlag,     true)
+  ("PCMFilterDisableFlag",     m_bPCMFilterDisableFlag,    false)
+
+  ("LosslessCuEnabled",        m_useLossless, false)
+
+  ("WeightedPredP,-wpP",          m_useWeightedPred,               false,      "Use weighted prediction in P slices")
+  ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,      "Use weighted (bidirectional) prediction in B slices")
+  ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
+  ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
+  ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
+  ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
+  ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
+  ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
+  ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
+  ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
+  ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
+  ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
+  ("SignHideFlag,-SBH",                m_signHideFlag, 1)
+  ("MaxNumMergeCand",             m_maxNumMergeCand,             5u,         "Maximum number of merge candidates")
 
   /* Misc. */
-  ("SEIpictureDigest",  m_decodePictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n"
-                                              "\t3: checksum\n"
-                                              "\t2: CRC\n"
-                                              "\t1: use MD5\n"
-                                              "\t0: disable")
+  ("SEIDecodedPictureHash",       m_decodedPictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n"
+                                                                    "\t3: checksum\n"
+                                                                    "\t2: CRC\n"
+                                                                    "\t1: use MD5\n"
+                                                                    "\t0: disable")
+  ("SEIpictureDigest",            m_decodedPictureHashSEIEnabled, 0, "deprecated alias for SEIDecodedPictureHash")
   ("TMVPMode", m_TMVPModeId, 1, "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only")
   ("FEN", m_bUseFastEnc, false, "fast encoder setting")
@@ -445,20 +547,23 @@
   ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
   ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting")
+#if RATE_CONTROL_LAMBDA_DOMAIN
+  ( "RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control" )
+  ( "TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate" )
+  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, false, "Rate control: keep hierarchical bit allocation in rate control algorithm" )
+  ( "LCULevelRateControl", m_RCLCULevelRC,           true, "Rate control: true: LCU level RC; false: picture level RC" )
+  ( "RCLCUSeparateModel",  m_RCUseLCUSeparateModel,  true, "Rate control: use LCU level separate R-lambda model" )
+  ( "InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP" )
+  ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
+#else
   ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
   ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
   ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
+#endif
 
   ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS")
   ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false, "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled")
-#if RECALCULATE_QP_ACCORDING_LAMBDA
   ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
-#endif
-#if ACTIVE_PARAMETER_SETS_SEI_MESSAGE 
-  ("ActiveParameterSets", m_activeParameterSetsSEIEnabled, 0, "Control generation of active parameter sets SEI messages\n"
-                                                              "\t2: enable active parameter sets SEI message with active_sps_id\n"
-                                                              "\t1: enable active parameter sets SEI message without active_sps_id\n"
-                                                              "\t0: disable")
-#endif 
-#if SUPPORT_FOR_VUI
+  ("StrongIntraSmoothing,-sis",      m_useStrongIntraSmoothing,           true, "Enable strong intra smoothing for 32x32 blocks")
+  ("SEIActiveParameterSets",         m_activeParameterSetsSEIEnabled,          0, "Enable generation of active parameter sets SEI messages")
   ("VuiParametersPresent,-vui",      m_vuiParametersPresentFlag,           false, "Enable generation of vui_parameters()")
   ("AspectRatioInfoPresent",         m_aspectRatioInfoPresentFlag,         false, "Signals whether aspect_ratio_idc is present")
@@ -466,6 +571,6 @@
   ("SarWidth",                       m_sarWidth,                               0, "horizontal size of the sample aspect ratio")
   ("SarHeight",                      m_sarHeight,                              0, "vertical size of the sample aspect ratio")
-  ("OverscanInfoPresent",            m_overscanInfoPresentFlag,            false, "Indicates whether cropped decoded pictures are suitable for display using overscan\n")
-  ("OverscanAppropriate",            m_overscanAppropriateFlag,            false, "Indicates whether cropped decoded pictures are suitable for display using overscan\n")
+  ("OverscanInfoPresent",            m_overscanInfoPresentFlag,            false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
+  ("OverscanAppropriate",            m_overscanAppropriateFlag,            false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
   ("VideoSignalTypePresent",         m_videoSignalTypePresentFlag,         false, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present")
   ("VideoFormat",                    m_videoFormat,                            5, "Indicates representation of pictures")
@@ -479,4 +584,12 @@
   ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField,         0, "Specifies the location of chroma samples for bottom field")
   ("NeutralChromaIndication",        m_neutralChromaIndicationFlag,        false, "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)")
+  ("DefaultDisplayWindowFlag",       m_defaultDisplayWindowFlag,           false, "Indicates the presence of the Default Window parameters")
+  ("DefDispWinLeftOffset",           m_defDispWinLeftOffset,                   0, "Specifies the left offset of the default display window from the conformance window")
+  ("DefDispWinRightOffset",          m_defDispWinRightOffset,                  0, "Specifies the right offset of the default display window from the conformance window")
+  ("DefDispWinTopOffset",            m_defDispWinTopOffset,                    0, "Specifies the top offset of the default display window from the conformance window")
+  ("DefDispWinBottomOffset",         m_defDispWinBottomOffset,                 0, "Specifies the bottom offset of the default display window from the conformance window")
+  ("FrameFieldInfoPresentFlag",      m_frameFieldInfoPresentFlag,               false, "Indicates that pic_struct and field coding related values are present in picture timing SEI messages")
+  ("PocProportionalToTimingFlag",   m_pocProportionalToTimingFlag,         false, "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS")
+  ("NumTicksPocDiffOneMinus1",      m_numTicksPocDiffOneMinus1,                0, "Number of ticks minus 1 that for a POC difference of one")
   ("BitstreamRestriction",           m_bitstreamRestrictionFlag,           false, "Signals whether bitstream restriction parameters are present")
   ("TilesFixedStructure",            m_tilesFixedStructureFlag,            false, "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles")
@@ -486,11 +599,39 @@
   ("Log2MaxMvLengthHorizontal",      m_log2MaxMvLengthHorizontal,             15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units")
   ("Log2MaxMvLengthVertical",        m_log2MaxMvLengthVertical,               15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units")
-#endif
-#if RECOVERY_POINT_SEI
   ("SEIRecoveryPoint",               m_recoveryPointSEIEnabled,                0, "Control generation of recovery point SEI messages")
-#endif
-#if BUFFERING_PERIOD_AND_TIMING_SEI
   ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
   ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
+  ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
+  ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
+                                                                                  "\t0: checkerboard - pixels alternatively represent either frames\n"
+                                                                                  "\t1: column alternation - frames are interlaced by column\n"
+                                                                                  "\t2: row alternation - frames are interlaced by row\n"
+                                                                                  "\t3: side by side - frames are displayed horizontally\n"
+                                                                                  "\t4: top bottom - frames are displayed vertically\n"
+                                                                                  "\t5: frame alternation - one frame is alternated with the other")
+  ("SEIFramePackingId",              m_framePackingSEIId,                      0, "Id of frame packing SEI message for a given session")
+  ("SEIFramePackingQuincunx",        m_framePackingSEIQuincunx,                0, "Indicate the presence of a Quincunx type video frame")
+  ("SEIFramePackingInterpretation",  m_framePackingSEIInterpretation,          0, "Indicate the interpretation of the frame pair\n"
+                                                                                  "\t0: unspecified\n"
+                                                                                  "\t1: stereo pair, frame0 represents left view\n"
+                                                                                  "\t2: stereo pair, frame0 represents right view")
+  ("SEIDisplayOrientation",          m_displayOrientationSEIAngle,             0, "Control generation of display orientation SEI messages\n"
+                                                              "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n"
+                                                              "\t0: disable")
+  ("SEITemporalLevel0Index",         m_temporalLevel0IndexSEIEnabled,          0, "Control generation of temporal level 0 index SEI messages")
+  ("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 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")
+  ("BitRateInfoPresent",         cfg_bitRateInfoPresentFlag,          string(""), "Control signalling of bit rate information of avg. bit rate and max. bit rate in VPS\n"
+                                                                          "\t0: Do not sent bit rate info\n"
+                                                                          "\tN (N > 0): Send bit rate info for N sub-layers. N should equal maxTempLayers.")                                                                     
+  ("PicRateInfoPresent",         cfg_picRateInfoPresentFlag,          string(""), "Control signalling of picture rate information of avg. bit rate and max. bit rate in VPS\n"
+                                                                          "\t0: Do not sent picture rate info\n"
+                                                                          "\tN (N > 0): Send picture rate info for N sub-layers. N should equal maxTempLayers.")                                                                     
+  ("AvgBitRate",                   cfg_avgBitRate,                    string(""), "List of avg. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
+  ("MaxBitRate",                   cfg_maxBitRate,                    string(""), "List of max. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
+  ("AvgPicRate",                   cfg_avgPicRate,                    string(""), "List of avg. picture rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
+  ("ConstantPicRateIdc",           cfg_constantPicRateIdc,            string(""), "List of constant picture rate IDCs; include non-negative number even if corresponding flag is 0")
 #endif
   ;
@@ -502,7 +643,7 @@
   }
   po::setDefaults(opts);
-  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv);
-
-  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
+
+  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
@@ -521,5 +662,5 @@
   /* convert std::string to c string for compatability */
 #if SVC_EXTENSION
-  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
+  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
 #if AVC_SYNTAX
   m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
@@ -530,18 +671,121 @@
   m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
   m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
-#endif
-  
-  m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
-  m_pchRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
+#endif  
+
+  Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
+  Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
+  if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
+  {
+    char *columnWidth;
+    int  i=0;
+    m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
+    columnWidth = strtok(pColumnWidth, " ,-");
+    while(columnWidth!=NULL)
+    {
+      if( i>=m_iNumColumnsMinus1 )
+      {
+        printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
+        exit( EXIT_FAILURE );
+      }
+      *( m_pColumnWidth + i ) = atoi( columnWidth );
+      columnWidth = strtok(NULL, " ,-");
+      i++;
+    }
+    if( i<m_iNumColumnsMinus1 )
+    {
+      printf( "The width of some columns is not defined.\n" );
+      exit( EXIT_FAILURE );
+    }
+  }
+  else
+  {
+    m_pColumnWidth = NULL;
+  }
+
+  if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
+  {
+    char *rowHeight;
+    int  i=0;
+    m_pRowHeight = new UInt[m_iNumRowsMinus1];
+    rowHeight = strtok(pRowHeight, " ,-");
+    while(rowHeight!=NULL)
+    {
+      if( i>=m_iNumRowsMinus1 )
+      {
+        printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" );
+        exit( EXIT_FAILURE );
+      }
+      *( m_pRowHeight + i ) = atoi( rowHeight );
+      rowHeight = strtok(NULL, " ,-");
+      i++;
+    }
+    if( i<m_iNumRowsMinus1 )
+    {
+      printf( "The height of some rows is not defined.\n" );
+      exit( EXIT_FAILURE );
+   }
+  }
+  else
+  {
+    m_pRowHeight = NULL;
+  }
+#if VPS_EXTN_DIRECT_REF_LAYERS
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    Char* pRefLayerIds = cfg_refLayerIds[layer].empty() ? NULL: strdup(cfg_refLayerIds[layer].c_str());
+    if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 )
+    {
+      char *refLayerId;
+      int  i=0;
+      m_acLayerCfg[layer].m_refLayerIds = new Int[m_acLayerCfg[layer].m_numDirectRefLayers];
+      refLayerId = strtok(pRefLayerIds, " ,-");
+      while(refLayerId != NULL)
+      {
+        if( i >= m_acLayerCfg[layer].m_numDirectRefLayers )
+        {
+          printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
+          exit( EXIT_FAILURE );
+        }
+        *( m_acLayerCfg[layer].m_refLayerIds + i ) = atoi( refLayerId );
+        refLayerId = strtok(NULL, " ,-");
+        i++;
+      }
+      if( i < m_acLayerCfg[layer].m_numDirectRefLayers )
+      {
+        printf( "The width of some columns is not defined.\n" );
+        exit( EXIT_FAILURE );
+      }
+    }
+    else
+    {
+      m_acLayerCfg[layer].m_refLayerIds = NULL;
+    }
+  }
+#endif
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+  readBoolString(cfg_bitRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_bitRateInfoPresentFlag, "bit rate info. present flag" );
+  readIntString (cfg_avgBitRate,             m_bitRatePicRateMaxTLayers, m_avgBitRate,             "avg. bit rate"               );
+  readIntString (cfg_maxBitRate,             m_bitRatePicRateMaxTLayers, m_maxBitRate,             "max. bit rate"               );
+  readBoolString(cfg_picRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_picRateInfoPresentFlag, "bit rate info. present flag" );
+  readIntString (cfg_avgPicRate,             m_bitRatePicRateMaxTLayers, m_avgPicRate,             "avg. pic rate"               );
+  readIntString (cfg_constantPicRateIdc,     m_bitRatePicRateMaxTLayers, m_constantPicRateIdc,     "constant pic rate Idc"       );
+#endif
   m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
- 
+  
+  /* rules for input, output and internal bitdepths as per help text */
+  if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; }
+  if (!m_internalBitDepthC) { m_internalBitDepthC = m_internalBitDepthY; }
+  if (!m_inputBitDepthC) { m_inputBitDepthC = m_inputBitDepthY; }
+  if (!m_outputBitDepthY) { m_outputBitDepthY = m_internalBitDepthY; }
+  if (!m_outputBitDepthC) { m_outputBitDepthC = m_internalBitDepthC; }
+
 #if !SVC_EXTENSION
   // TODO:ChromaFmt assumes 4:2:0 below
-  switch (m_croppingMode)
+  switch (m_conformanceMode)
   {
   case 0:
     {
-      // no cropping or padding
-      m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0;
+      // no conformance or padding
+      m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
       m_aiPad[1] = m_aiPad[0] = 0;
       break;
@@ -553,18 +797,18 @@
       if (m_iSourceWidth % minCuSize)
       {
-        m_aiPad[0] = m_cropRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
-        m_iSourceWidth  += m_cropRight;
+        m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
+        m_iSourceWidth  += m_confRight;
       }
       if (m_iSourceHeight % minCuSize)
       {
-        m_aiPad[1] = m_cropBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
-        m_iSourceHeight += m_cropBottom;
-      }
-      if (m_aiPad[0] % TComSPS::getCropUnitX(CHROMA_420) != 0)
+        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
+        m_iSourceHeight += m_confBottom;
+      }
+      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
       {
         fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n");
         exit(EXIT_FAILURE);
       }
-      if (m_aiPad[1] % TComSPS::getCropUnitY(CHROMA_420) != 0)
+      if (m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0)
       {
         fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
@@ -578,18 +822,18 @@
       m_iSourceWidth  += m_aiPad[0];
       m_iSourceHeight += m_aiPad[1];
-      m_cropRight  = m_aiPad[0];
-      m_cropBottom = m_aiPad[1];
+      m_confRight  = m_aiPad[0];
+      m_confBottom = m_aiPad[1];
       break;
     }
   case 3:
     {
-      // cropping
-      if ((m_cropLeft == 0) && (m_cropRight == 0) && (m_cropTop == 0) && (m_cropBottom == 0))
-      {
-        fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n");
+      // conformance
+      if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
+      {
+        fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
       }
       if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0))
       {
-        fprintf(stderr, "Warning: Cropping enabled, padding parameters will be ignored\n");
+        fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n");
       }
       m_aiPad[1] = m_aiPad[0] = 0;
@@ -599,6 +843,6 @@
   
   // allocate slice-based dQP values
-  m_aidQP = new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ];
-  ::memset( m_aidQP, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) );
+  m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ];
+  ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
   
   // handling of floating-point QP values
@@ -607,8 +851,8 @@
   if ( m_iQP < m_fQP )
   {
-    Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_fQP - m_iQP)*m_iFrameToBeEncoded + 0.5 );
+    Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP - m_iQP)*m_framesToBeEncoded + 0.5 );
     
     iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
-    for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ )
+    for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ )
     {
       m_aidQP[i] = 1;
@@ -624,5 +868,5 @@
       Int iValue;
       Int iPOC = 0;
-      while ( iPOC < m_iFrameToBeEncoded )
+      while ( iPOC < m_framesToBeEncoded )
       {
         if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
@@ -633,5 +877,5 @@
     }
   }
-  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1; 
+  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
 #endif
   // check validity of input parameters
@@ -646,38 +890,102 @@
   return true;
 }
-
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName)
+{
+  Char* inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
+  Int i = 0;
+  if(numEntries)
+  {
+    Char* tempArray = strtok(inpArray, " ,-");
+    memberArray = new Bool[numEntries];
+    while( tempArray != NULL )
+    {
+      if( i >= numEntries )
+      {
+        printf( "The number of %s defined is larger than the allowed number\n", elementName );
+        exit( EXIT_FAILURE );
+      }
+      assert( (atoi(tempArray) == 0) || (atoi(tempArray) == 1) );
+      *( memberArray + i ) = atoi(tempArray);
+      tempArray = strtok(NULL, " ,-");
+      i++;
+    }
+    if( i < numEntries )
+    {
+      printf( "Some %s are not defined\n", elementName );
+      exit( EXIT_FAILURE );
+    }
+  }
+  else
+  {
+    memberArray = NULL;
+  }
+}
+
+Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName)
+{
+  Char* inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
+  Int i = 0;
+  if(numEntries)
+  {
+    Char* tempArray = strtok(inpArray, " ,-");
+    memberArray = new Int[numEntries];
+    while( tempArray != NULL )
+    {
+      if( i >= numEntries )
+      {
+        printf( "The number of %s defined is larger than the allowed number\n", elementName );
+        exit( EXIT_FAILURE );
+      }
+      *( memberArray + i ) = atoi(tempArray);
+      tempArray = strtok(NULL, " ,-");
+      i++;
+    }
+    if( i < numEntries )
+    {
+      printf( "Some %s are not defined\n", elementName );
+      exit( EXIT_FAILURE );
+    }
+  }
+  else
+  {
+    memberArray = NULL;
+  }
+}
+#endif
 // ====================================================================================================================
 // Private member functions
 // ====================================================================================================================
 
-Bool confirmPara(Bool bflag, const char* message);
+Bool confirmPara(Bool bflag, const Char* message);
 
 Void TAppEncCfg::xCheckParameter()
 {
-  if (!m_decodePictureHashSEIEnabled)
-  {
-    fprintf(stderr, "*************************************************************\n");
-    fprintf(stderr, "** WARNING: --SEIpictureDigest is now disabled by default. **\n");
-    fprintf(stderr, "**          Automatic verification of decoded pictures by  **\n");
-    fprintf(stderr, "**          a decoder requires this option to be enabled.  **\n");
-    fprintf(stderr, "*************************************************************\n");
-  }
-
-  bool check_failed = false; /* abort if there is a fatal configuration problem */
+  if (!m_decodedPictureHashSEIEnabled)
+  {
+    fprintf(stderr, "******************************************************************\n");
+    fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n");
+    fprintf(stderr, "**          Automatic verification of decoded pictures by a     **\n");
+    fprintf(stderr, "**          decoder requires this option to be enabled.         **\n");
+    fprintf(stderr, "******************************************************************\n");
+  }
+
+  Bool check_failed = false; /* abort if there is a fatal configuration problem */
 #define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
   // check range of parameters
-  xConfirmPara( m_uiInputBitDepth < 8,                                                      "InputBitDepth must be at least 8" );
-#if !SVC_EXTENSION
+  xConfirmPara( m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
+  xConfirmPara( m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
+#if !SVC_EXTENSION  
   xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
 #endif
-  xConfirmPara( m_iFrameToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
+  xConfirmPara( m_framesToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
   xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
   xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
-#if !SVC_EXTENSION
+#if !SVC_EXTENSION 
   xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
 #endif
   xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
 #if !SVC_EXTENSION
-  xConfirmPara( m_iQP <  -6 * ((Int)m_uiInternalBitDepth - 8) || m_iQP > 51,                "QP exceeds supported range (-QpBDOffsety to 51)" );
+  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
 #endif
   xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
@@ -711,7 +1019,7 @@
   
   xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
-  xConfirmPara( m_uiQuadtreeTULog2MinSize > 5,                                        "QuadtreeTULog2MinSize must be 5 or smaller.");
-  xConfirmPara( m_uiQuadtreeTULog2MaxSize < 2,                                        "QuadtreeTULog2MaxSize must be 2 or greater.");
   xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5,                                        "QuadtreeTULog2MaxSize must be 5 or smaller.");
+  xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth,                                        "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller.");
+  
   xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,                "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
   xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
@@ -720,7 +1028,7 @@
   xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." );
   xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1,                                                         "QuadtreeTUMaxDepthInter must be greater than or equal to 1" );
-  xConfirmPara( m_uiQuadtreeTUMaxDepthInter > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthInter must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
+  xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthInter - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" );
   xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1,                                                         "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" );
-  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
+  xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthIntra - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" );
   
   xConfirmPara(  m_maxNumMergeCand < 1,  "MaxNumMergeCand must be 1 or greater.");
@@ -742,61 +1050,32 @@
   }
 
-  xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 3, "SliceMode exceeds supported range (0 to 3)" );
-  if (m_iSliceMode!=0)
-  {
-    xConfirmPara( m_iSliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
-  }
-#if !REMOVE_FGS
-  if (m_iSliceMode==3)
-  {
-    xConfirmPara( m_iSliceGranularity > 0 ,      "When SliceMode == 3 is chosen, the SliceGranularity must be 0" );
-  }
-#endif
-  xConfirmPara( m_iDependentSliceMode < 0 || m_iDependentSliceMode > 2, "DependentSliceMode exceeds supported range (0 to 2)" );
-  if (m_iDependentSliceMode!=0)
-  {
-    xConfirmPara( m_iDependentSliceArgument < 1 ,         "DependentSliceArgument should be larger than or equal to 1" );
-  }
-#if !REMOVE_FGS
-  xConfirmPara( m_iSliceGranularity >= m_uiMaxCUDepth, "SliceGranularity must be smaller than maximum cu depth");
-  xConfirmPara( m_iSliceGranularity <0 || m_iSliceGranularity > 3, "SliceGranularity exceeds supported range (0 to 3)" );
-  xConfirmPara( m_iSliceGranularity > m_iMaxCuDQPDepth, "SliceGranularity must be smaller smaller than or equal to maximum dqp depth" );
-#endif
-  
-  bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
-#if !TILES_WPP_ENTROPYSLICES_FLAGS
-  xConfirmPara( tileFlag && m_iDependentSliceMode,            "Tile and Dependent Slice can not be applied together");
-#endif
+  xConfirmPara( m_sliceMode < 0 || m_sliceMode > 3, "SliceMode exceeds supported range (0 to 3)" );
+  if (m_sliceMode!=0)
+  {
+    xConfirmPara( m_sliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
+  }
+  xConfirmPara( m_sliceSegmentMode < 0 || m_sliceSegmentMode > 3, "SliceSegmentMode exceeds supported range (0 to 3)" );
+  if (m_sliceSegmentMode!=0)
+  {
+    xConfirmPara( m_sliceSegmentArgument < 1 ,         "SliceSegmentArgument should be larger than or equal to 1" );
+  }
+  
+  Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
   xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
-#if !DEPENDENT_SLICES
-  xConfirmPara( m_iWaveFrontSynchro && m_iDependentSliceMode, "Wavefront and Dependent Slice can not be applied together");
-#endif
-#if DEPENDENT_SLICES
-#if TILES_WPP_ENTROPYSLICES_FLAGS
-  xConfirmPara( m_iWaveFrontSynchro && m_entropySliceEnabledFlag, "WaveFrontSynchro and EntropySliceEnabledFlag can not be applied together");
-#else
-  xConfirmPara( m_iWaveFrontSynchro && m_bCabacIndependentFlag, "Wavefront and CabacIndependentFlag can not be applied together");
-#endif
-#endif
 
   //TODO:ChromaFmt assumes 4:2:0 below
 #if !SVC_EXTENSION
-  xConfirmPara( m_iSourceWidth  % TComSPS::getCropUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
-  xConfirmPara( m_iSourceHeight % TComSPS::getCropUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
-#endif
-
-#if !SVC_EXTENSION 
-  xConfirmPara( m_aiPad[0] % TComSPS::getCropUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
-  xConfirmPara( m_aiPad[1] % TComSPS::getCropUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
-
-  xConfirmPara( m_cropLeft   % TComSPS::getCropUnitX(CHROMA_420) != 0, "Left cropping must be an integer multiple of the specified chroma subsampling");
-  xConfirmPara( m_cropRight  % TComSPS::getCropUnitX(CHROMA_420) != 0, "Right cropping must be an integer multiple of the specified chroma subsampling");
-  xConfirmPara( m_cropTop    % TComSPS::getCropUnitY(CHROMA_420) != 0, "Top cropping must be an integer multiple of the specified chroma subsampling");
-  xConfirmPara( m_cropBottom % TComSPS::getCropUnitY(CHROMA_420) != 0, "Bottom cropping must be an integer multiple of the specified chroma subsampling");
-#endif
-
-#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV
-  xConfirmPara( REF_IDX_ME_AROUND_ZEROMV && REF_IDX_ME_ZEROMV, "REF_IDX_ME_AROUND_ZEROMV and REF_IDX_ME_ZEROMV cannot be enabled simultaneously");
-#endif
+  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
+
+  xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
+
+  xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
+#endif
+
   // max CU width and height should be power of 2
   UInt ui = m_uiMaxCUWidth;
@@ -814,4 +1093,24 @@
       xConfirmPara( ui != 1 , "Height should be 2^n");
   }
+
+
+  /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
+   * This permits the ability to omit a GOP structure specification */
+#if SVC_EXTENSION
+  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
+#endif
+  if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
+    m_GOPList[0] = GOPEntry();
+    m_GOPList[0].m_QPFactor = 1;
+    m_GOPList[0].m_betaOffsetDiv2 = 0;
+    m_GOPList[0].m_tcOffsetDiv2 = 0;
+    m_GOPList[0].m_POC = 1;
+    m_GOPList[0].m_numRefPicsActive = 4;
+  }
+#if SVC_EXTENSION
+  }
+#endif
   
   Bool verifiedGOP=false;
@@ -838,6 +1137,4 @@
     }
   }
-  
-  m_extraRPSs=0;
 
 #if SVC_EXTENSION
@@ -851,6 +1148,25 @@
     }
   }
-#endif
-
+#endif  
+
+#if SVC_EXTENSION
+  // verify layer configuration parameters
+  for(UInt layer=0; layer<m_numLayers; layer++)
+  {
+    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
+#endif
+  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
+  {
+    for(Int i=0; i<m_iGOPSize; i++)
+    {
+      xConfirmPara( (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 || (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" );
+      xConfirmPara( (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 || (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" );
+    }
+  }
+#if SVC_EXTENSION
+  }
+#endif
+
+  m_extraRPSs=0;
   //start looping through frames in coding order until we can verify that the GOP structure is correct.
   while(!verifiedGOP&&!errorGOP) 
@@ -886,10 +1202,8 @@
                 if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize)
                 {
-#if TEMPORAL_LAYER_NON_REFERENCE
                   if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId)
                   {
                     m_GOPList[k].m_refPic = true;
                   }
-#endif
                   m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId;
                 }
@@ -939,9 +1253,5 @@
           Int offGOP = (checkGOP-1+offset)%m_iGOPSize;
           Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC;
-#if TEMPORAL_LAYER_NON_REFERENCE
           if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId)
-#else
-          if(offPOC>=0&&m_GOPList[offGOP].m_refPic&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId) 
-#endif
           {
             Bool newRef=false;
@@ -964,10 +1274,8 @@
               Int insertPoint=newRefs;
               //this picture can be added, find appropriate place in list and insert it.
-#if TEMPORAL_LAYER_NON_REFERENCE
               if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId)
               {
                 m_GOPList[offGOP].m_refPic = true;
               }
-#endif
               for(Int j=0; j<newRefs; j++)
               {
@@ -1035,7 +1343,4 @@
           m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc;
           m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs].m_POC; 
-#if !J0234_INTER_RPS_SIMPL
-          m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRIdxMinus1 = 0; 
-#endif
         }
         curGOP=m_iGOPSize+m_extraRPSs;
@@ -1124,4 +1429,87 @@
   }
 
+#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
+  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    Int m_iSourceWidth = m_acLayerCfg[layer].m_iSourceWidth;
+    Int m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight;
+#endif
+  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
+  { 
+    Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
+    if(tileFlag)
+    {
+      Int maxTileWidth = 0;
+      Int maxTileHeight = 0;
+      Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
+      Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
+      if(m_iUniformSpacingIdr)
+      {
+        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1));
+        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1));
+        // if only the last tile-row is one treeblock higher than the others 
+        // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
+        if(!((heightInCU-1)%(m_iNumRowsMinus1+1)))
+        {
+          maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
+        }     
+        // if only the last tile-column is one treeblock wider than the others 
+        // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others   
+        if(!((widthInCU-1)%(m_iNumColumnsMinus1+1)))
+        {
+          maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
+        }
+      }
+      else // not uniform spacing
+      {
+        if(m_iNumColumnsMinus1<1)
+        {
+          maxTileWidth = m_iSourceWidth;
+        }
+        else
+        {
+          Int accColumnWidth = 0;
+          for(Int col=0; col<(m_iNumColumnsMinus1); col++)
+          {
+            maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth;
+            accColumnWidth += m_pColumnWidth[col];
+          }
+          maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
+        }
+        if(m_iNumRowsMinus1<1)
+        {
+          maxTileHeight = m_iSourceHeight;
+        }
+        else
+        {
+          Int accRowHeight = 0;
+          for(Int row=0; row<(m_iNumRowsMinus1); row++)
+          {
+            maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight;
+            accRowHeight += m_pRowHeight[row];
+          }
+          maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
+        }
+      }
+      Int maxSizeInSamplesY = maxTileWidth*maxTileHeight;
+      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/maxSizeInSamplesY-4;
+    }
+    else if(m_iWaveFrontSynchro)
+    {
+      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_iSourceHeight+m_iSourceWidth)*m_uiMaxCUHeight)-4;
+    }
+    else if(m_sliceMode == 1)
+    {
+      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/(m_sliceArgument*m_uiMaxCUWidth*m_uiMaxCUHeight)-4;
+    }
+    else
+    {
+      m_minSpatialSegmentationIdc = 0;
+    }
+  }
+#if SVC_EXTENSION
+  }
+#endif
+
   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.
   xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
@@ -1131,7 +1519,20 @@
 #endif
 
-  xConfirmPara( m_decodePictureHashSEIEnabled<0 || m_decodePictureHashSEIEnabled>3, "this hash type is not correct!\n");
-
-#if !SVC_EXTENSION 
+  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
+
+#if RATE_CONTROL_LAMBDA_DOMAIN
+  if ( m_RCEnableRateControl )
+  {
+    if ( m_RCForceIntraQP )
+    {
+      if ( m_RCInitialQP == 0 )
+      {
+        printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" );
+        m_RCForceIntraQP = false;
+      }
+    }
+    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
+  }
+#else
   if(m_enableRateCtrl)
   {
@@ -1150,9 +1551,23 @@
 
   xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
-
-#if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
-  xConfirmPara(m_activeParameterSetsSEIEnabled < 0 || m_activeParameterSetsSEIEnabled > 2, "ActiveParametersSEIEnabled exceeds supported range (0 to 2)"); 
-#endif 
-
+#if L0444_FPA_TYPE
+  if (m_framePackingSEIEnabled)
+  {
+    xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5");
+  }
+#endif
+#if VPS_EXTN_DIRECT_REF_LAYERS
+  xConfirmPara( (m_acLayerCfg[0].m_numDirectRefLayers != 0) && (m_acLayerCfg[0].m_numDirectRefLayers != -1), "Layer 0 cannot have any reference layers" );
+  // NOTE: m_numDirectRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
+  for(Int layer = 1; layer < MAX_LAYERS; layer++)
+  {
+    xConfirmPara(m_acLayerCfg[layer].m_numDirectRefLayers > layer, "Cannot reference more layers than before current layer");
+    for(Int i = 0; i < m_acLayerCfg[layer].m_numDirectRefLayers; i++)
+    {
+      xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] > layer, "Cannot reference higher layers");
+      xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] == layer, "Cannot reference the current layer itself");
+    }
+  }
+#endif
 #undef xConfirmPara
   if (check_failed)
@@ -1179,27 +1594,9 @@
   
   // set internal bit-depth and constants
-#if FULL_NBIT
-  g_uiBitDepth = m_uiInternalBitDepth;
-  g_uiBitIncrement = 0;
-#else
-  g_uiBitDepth = 8;
-  g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth;
-#endif
-
-  g_uiBASE_MAX     = ((1<<(g_uiBitDepth))-1);
-  
-#if IBDI_NOCLIP_RANGE
-  g_uiIBDI_MAX     = g_uiBASE_MAX << g_uiBitIncrement;
-#else
-  g_uiIBDI_MAX     = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1);
-#endif
-  
-  if (m_uiOutputBitDepth == 0)
-  {
-    m_uiOutputBitDepth = m_uiInternalBitDepth;
-  }
-
-  g_uiPCMBitDepthLuma = m_uiPCMBitDepthLuma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth);
-  g_uiPCMBitDepthChroma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth);
+  g_bitDepthY = m_internalBitDepthY;
+  g_bitDepthC = m_internalBitDepthC;
+  
+  g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY;
+  g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC;
 }
 
@@ -1216,13 +1613,13 @@
   }
   printf("=== Common configuration settings === \n");
-  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
+  printf("Bitstream      File          : %s\n", m_pBitstreamFile      );
 #else
   printf("Input          File          : %s\n", m_pchInputFile          );
   printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
   printf("Reconstruction File          : %s\n", m_pchReconFile          );
-  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate );
+  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
   printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
 #endif
-  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded );
+  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
   printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
   printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
@@ -1245,6 +1642,18 @@
   printf("QP adaptation                : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
   printf("GOP size                     : %d\n", m_iGOPSize );
-  printf("Internal bit depth           : %d\n", m_uiInternalBitDepth );
-  printf("PCM sample bit depth         : %d\n", m_uiPCMBitDepthLuma );
+  printf("Internal bit depth           : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC );
+  printf("PCM sample bit depth         : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma );
+#if RATE_CONTROL_LAMBDA_DOMAIN
+  printf("RateControl                  : %d\n", m_RCEnableRateControl );
+  if(m_RCEnableRateControl)
+  {
+    printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
+    printf("KeepHierarchicalBit          : %d\n", m_RCKeepHierarchicalBit );
+    printf("LCULevelRC                   : %d\n", m_RCLCULevelRC );
+    printf("UseLCUSeparateModel          : %d\n", m_RCUseLCUSeparateModel );
+    printf("InitialQP                    : %d\n", m_RCInitialQP );
+    printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
+  }
+#else
   printf("RateControl                  : %d\n", m_enableRateCtrl);
   if(m_enableRateCtrl)
@@ -1253,16 +1662,17 @@
     printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
   }
+#endif
   printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
   printf("\n");
   
   printf("TOOL CFG: ");
-#if !REMOVE_ALF
-  printf("ALF:%d ", m_bUseALF             );
-  printf("ALFLowLatencyEncode:%d ", m_alfLowLatencyEncoding?1:0);
-#endif
-  printf("IBD:%d ", !!g_uiBitIncrement);
+  printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC);
   printf("HAD:%d ", m_bUseHADME           );
   printf("SRD:%d ", m_bUseSBACRD          );
-  printf("RDQ:%d ", m_bUseRDOQ            );
+  printf("RDQ:%d ", m_useRDOQ            );
+  printf("RDQTS:%d ", m_useRDOQTS        );
+#if L0232_RD_PENALTY
+  printf("RDpenalty:%d ", m_rdPenalty  );
+#endif
   printf("SQP:%d ", m_uiDeltaQpRD         );
   printf("ASR:%d ", m_bUseASR             );
@@ -1274,22 +1684,15 @@
   printf("ESD:%d ", m_useEarlySkipDetection  );
   printf("RQT:%d ", 1     );
-#if !REMOVE_LMCHROMA
-  printf("LMC:%d ", m_bUseLMChroma        );
-#endif
   printf("TransformSkip:%d ",     m_useTransformSkip              );
   printf("TransformSkipFast:%d ", m_useTransformSkipFast       );
-#if REMOVE_FGS
-  printf("Slice: M=%d ", m_iSliceMode);
-#else
-  printf("Slice: G=%d M=%d ", m_iSliceGranularity, m_iSliceMode);
-#endif
-  if (m_iSliceMode!=0)
-  {
-    printf("A=%d ", m_iSliceArgument);
-  }
-  printf("DependentSlice: M=%d ",m_iDependentSliceMode);
-  if (m_iDependentSliceMode!=0)
-  {
-    printf("A=%d ", m_iDependentSliceArgument);
+  printf("Slice: M=%d ", m_sliceMode);
+  if (m_sliceMode!=0)
+  {
+    printf("A=%d ", m_sliceArgument);
+  }
+  printf("SliceSegment: M=%d ",m_sliceSegmentMode);
+  if (m_sliceSegmentMode!=0)
+  {
+    printf("A=%d ", m_sliceSegmentArgument);
   }
   printf("CIP:%d ", m_bUseConstrainedIntraPred);
@@ -1299,5 +1702,5 @@
 
   printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 );
-  printf("WPP:%d ", (Int)m_bUseWeightPred);
+  printf("WPP:%d ", (Int)m_useWeightedPred);
   printf("WPB:%d ", (Int)m_useWeightedBiPred);
   printf("PME:%d ", m_log2ParallelMergeLevel);
@@ -1314,12 +1717,9 @@
   printf(" SignBitHidingFlag:%d ", m_signHideFlag);
 #if SVC_EXTENSION
-#if RECALCULATE_QP_ACCORDING_LAMBDA
   printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
-#endif
   printf("AVC_BASE:%d ", AVC_BASE);
 #if REF_IDX_FRAMEWORK
   printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK);
   printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
-  printf("REF_IDX_ME_AROUND_ZEROMV:%d ", REF_IDX_ME_AROUND_ZEROMV);
   printf("REF_IDX_ME_ZEROMV: %d", REF_IDX_ME_ZEROMV);
 #elif INTRA_BL
@@ -1331,7 +1731,5 @@
 #endif
 #else
-#if RECALCULATE_QP_ACCORDING_LAMBDA
   printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
-#endif
 #endif
   printf("\n\n");
@@ -1340,5 +1738,5 @@
 }
 
-Bool confirmPara(Bool bflag, const char* message)
+Bool confirmPara(Bool bflag, const Char* message)
 {
   if (!bflag)
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 55)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -60,33 +60,46 @@
 #if SVC_EXTENSION
   TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS]; 
-  Int       m_numLayers;                                     ///< number of layers
-
-  char*     m_pchBitstreamFile;                               ///< output bitstream file
+  Int       m_numLayers;                                      ///< number of layers
+
+  Char*     m_pBitstreamFile;                                 ///< output bitstream file
   Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
   // source specification
-  unsigned int m_FrameSkip;                                   ///< number of skipped frames from the beginning
-  Int       m_iFrameToBeEncoded;                              ///< number of encoded frames
+  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
+  Int       m_framesToBeEncoded;                              ///< number of encoded frames
 #if AVC_SYNTAX
   char*     m_BLSyntaxFile;                                   ///< input syntax file
 #endif
 #else
-  char*     m_pchInputFile;                                   ///< source file name
-  char*     m_pchBitstreamFile;                               ///< output bitstream file
-  char*     m_pchReconFile;                                   ///< output reconstruction file
+  Char*     m_pchInputFile;                                   ///< source file name
+  Char*     m_pchBitstreamFile;                               ///< output bitstream file
+  Char*     m_pchReconFile;                                   ///< output reconstruction file
   Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
   // source specification
   Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
-  unsigned int m_FrameSkip;                                   ///< number of skipped frames from the beginning
+  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
   Int       m_iSourceWidth;                                   ///< source width in pixel
   Int       m_iSourceHeight;                                  ///< source height in pixel
-  Int       m_croppingMode;
-  Int       m_cropLeft;
-  Int       m_cropRight;
-  Int       m_cropTop;
-  Int       m_cropBottom;
-  Int       m_iFrameToBeEncoded;                              ///< number of encoded frames
+  Int       m_conformanceMode;
+  Int       m_confLeft;
+  Int       m_confRight;
+  Int       m_confTop;
+  Int       m_confBottom;
+  Int       m_framesToBeEncoded;                              ///< number of encoded frames
   Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
+#endif  
+
+  // profile/level
+  Profile::Name m_profile;
+  Level::Tier   m_levelTier;
+  Level::Name   m_level;
+#if L0046_CONSTRAINT_FLAGS
+  Bool m_progressiveSourceFlag;
+  Bool m_interlacedSourceFlag;
+  Bool m_nonPackedConstraintFlag;
+  Bool m_frameOnlyConstraintFlag;
+#endif
   
   // coding structure
+#if !SVC_EXTENSION
   Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
 #endif
@@ -100,7 +113,4 @@
   Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
   Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
-#if !REMOVE_NSQT
-  Bool      m_enableNSQT;                                     ///< flag for enabling NSQT
-#endif
   Bool      m_enableAMP;
   // coding quality
@@ -108,5 +118,5 @@
   Double    m_fQP;                                            ///< QP value of key-picture (floating point)
   Int       m_iQP;                                            ///< QP value of key-picture (integer)
-  char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
+  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
   Int*      m_aidQP;                                          ///< array of slice QP values
 #endif
@@ -140,11 +150,13 @@
   
   // coding tools (bit-depth)
-  UInt      m_uiInputBitDepth;                                ///< bit-depth of input file
-  UInt      m_uiOutputBitDepth;                               ///< bit-depth of output file
-  UInt      m_uiInternalBitDepth;                             ///< Internal bit-depth (BitDepth+BitIncrement)
+  Int       m_inputBitDepthY;                               ///< bit-depth of input file (luma component)
+  Int       m_inputBitDepthC;                               ///< bit-depth of input file (chroma component)
+  Int       m_outputBitDepthY;                              ///< bit-depth of output file (luma component)
+  Int       m_outputBitDepthC;                              ///< bit-depth of output file (chroma component)
+  Int       m_internalBitDepthY;                            ///< bit-depth codec operates at in luma (input/output files will be converted)
+  Int       m_internalBitDepthC;                            ///< bit-depth codec operates at in chroma (input/output files will be converted)
 
   // coding tools (PCM bit-depth)
   Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
-  UInt      m_uiPCMBitDepthLuma;                              ///< PCM bit-depth for luma
 
   // coding tool (lossless)
@@ -152,13 +164,7 @@
   Bool      m_bUseSAO; 
   Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
-#if SAO_LCU_BOUNDARY
   Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
-#endif
   Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
   // coding tools (loop filter)
-#if !REMOVE_ALF
-  Bool      m_bUseALF;                                        ///< flag for using adaptive loop filter
-  Bool      m_alfLowLatencyEncoding;
-#endif
   Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
   Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
@@ -167,8 +173,4 @@
   Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
  
-#if !REMOVE_LMCHROMA
-  Bool      m_bUseLMChroma;                                  ///< JL: Chroma intra prediction based on luma signal
-#endif
-  
   // coding tools (PCM)
   Bool      m_usePCM;                                         ///< flag for using IPCM
@@ -181,5 +183,9 @@
   Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
   Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
-  Bool      m_bUseRDOQ;                                       ///< flag for using RD optimized quantization
+  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
+  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
+#if L0232_RD_PENALTY
+  Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty) 
+#endif
   Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
   Int       m_iSearchRange;                                   ///< ME search range
@@ -190,26 +196,20 @@
   Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
   Bool      m_useEarlySkipDetection;                         ///< flag for using Early SKIP Detection
-  Int       m_iSliceMode;           ///< 0: Disable all Recon slice limits, 1 : Maximum number of largest coding units per slice, 2: Maximum number of bytes in a slice
-  Int       m_iSliceArgument;       ///< If m_iSliceMode==1, m_iSliceArgument=max. # of largest coding units. If m_iSliceMode==2, m_iSliceArgument=max. # of bytes.
-  Int       m_iDependentSliceMode;    ///< 0: Disable all dependent slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based dependent slice
-  Int       m_iDependentSliceArgument;///< If m_iDependentSliceMode==1, m_iEDependentSliceArgument=max. # of largest coding units. If m_iDependnetSliceMode==2, m_iDependnetSliceArgument=max. # of bins.
-#if DEPENDENT_SLICES
-#if TILES_WPP_ENTROPYSLICES_FLAGS
-  Bool      m_entropySliceEnabledFlag;
-#else
-  Bool       m_bCabacIndependentFlag;  // 0: CABAC dependence between slices, 1:CABAC independence between slices
-#endif
-#endif
-
-#if !REMOVE_FGS
-  Int       m_iSliceGranularity;///< 0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.
-#endif
-  Bool      m_bLFCrossSliceBoundaryFlag;  ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
-  Bool      m_bLFCrossTileBoundaryFlag;  //!< 1: Cross-tile-boundary in-loop filtering 0: non-cross-tile-boundary in-loop filtering
+  Int       m_sliceMode;                                     ///< 0: no slice limits, 1 : max number of CTBs per slice, 2: max number of bytes per slice, 
+                                                             ///< 3: max number of tiles per slice
+  Int       m_sliceArgument;                                 ///< argument according to selected slice mode
+  Int       m_sliceSegmentMode;                              ///< 0: no slice segment limits, 1 : max number of CTBs per slice segment, 2: max number of bytes per slice segment, 
+                                                             ///< 3: max number of tiles per slice segment
+  Int       m_sliceSegmentArgument;                          ///< argument according to selected slice segment mode
+
+  Bool      m_bLFCrossSliceBoundaryFlag;  ///< 1: filter across slice boundaries 0: do not filter across slice boundaries
+  Bool      m_bLFCrossTileBoundaryFlag;   ///< 1: filter across tile boundaries  0: do not filter across tile boundaries
   Int       m_iUniformSpacingIdr;
   Int       m_iNumColumnsMinus1;
-  char*     m_pchColumnWidth;
+  Char*     m_pchColumnWidth;
   Int       m_iNumRowsMinus1;
-  char*     m_pchRowHeight;
+  Char*     m_pchRowHeight;
+  UInt*     m_pColumnWidth;
+  UInt*     m_pRowHeight;
   Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
 #if !SVC_EXTENSION
@@ -219,15 +219,20 @@
   Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
   
-  Int       m_decodePictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
-#if RECOVERY_POINT_SEI
+  Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
   Int       m_recoveryPointSEIEnabled;
-#endif
-#if BUFFERING_PERIOD_AND_TIMING_SEI
   Int       m_bufferingPeriodSEIEnabled;
   Int       m_pictureTimingSEIEnabled;
-#endif
+  Int       m_framePackingSEIEnabled;
+  Int       m_framePackingSEIType;
+  Int       m_framePackingSEIId;
+  Int       m_framePackingSEIQuincunx;
+  Int       m_framePackingSEIInterpretation;
+  Int       m_displayOrientationSEIAngle;
+  Int       m_temporalLevel0IndexSEIEnabled;
+  Int       m_gradualDecodingRefreshInfoEnabled;
+  Int       m_decodingUnitInfoSEIEnabled;
   // weighted prediction
-  Bool      m_bUseWeightPred;                                 ///< Use of explicit Weighting Prediction for P_SLICE
-  Bool      m_useWeightedBiPred;                                    ///< Use of Bi-Directional Weighting Prediction (B_SLICE)
+  Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
+  Bool      m_useWeightedBiPred;                  ///< Use of bi-directional weighted prediction in B slices
   
   UInt      m_log2ParallelMergeLevel;                         ///< Parallel merge estimation region
@@ -236,21 +241,27 @@
   Int       m_TMVPModeId;
   Int       m_signHideFlag;
+#if RATE_CONTROL_LAMBDA_DOMAIN
+  Bool      m_RCEnableRateControl;                ///< enable rate control or not
+  Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
+  Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
+  Bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control
+  Bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level
+  Int       m_RCInitialQP;                        ///< inital QP for rate control
+  Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
+#else
   Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
   Int       m_targetBitrate;                                 ///< target bitrate
   Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
+#endif
   Int       m_useScalingListId;                               ///< using quantization matrix
-  char*     m_scalingListFile;                                ///< quantization matrix file name
+  Char*     m_scalingListFile;                                ///< quantization matrix file name
 
   Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
   Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
 
-#if RECALCULATE_QP_ACCORDING_LAMBDA
   Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
-#endif
-#if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
+  Bool      m_useStrongIntraSmoothing;                        ///< enable strong intra smoothing for 32x32 blocks where the reference samples are flat
   Int       m_activeParameterSetsSEIEnabled;
-#endif 
-
-#if SUPPORT_FOR_VUI
+
   Bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
   Bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
@@ -259,5 +270,5 @@
   Int       m_sarHeight;                                      ///< vertical size of the sample aspect ratio
   Bool      m_overscanInfoPresentFlag;                        ///< Signals whether overscan_appropriate_flag is present
-  Bool      m_overscanAppropriateFlag;                        ///< Indicates whether cropped decoded pictures are suitable for display using overscan
+  Bool      m_overscanAppropriateFlag;                        ///< Indicates whether conformant decoded pictures are suitable for display using overscan
   Bool      m_videoSignalTypePresentFlag;                     ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present
   Int       m_videoFormat;                                    ///< Indicates representation of pictures
@@ -271,12 +282,21 @@
   Int       m_chromaSampleLocTypeBottomField;                 ///< Specifies the location of chroma samples for bottom field
   Bool      m_neutralChromaIndicationFlag;                    ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)
+  Bool      m_defaultDisplayWindowFlag;                       ///< Indicates the presence of the default window parameters
+  Int       m_defDispWinLeftOffset;                           ///< Specifies the left offset from the conformance window of the default window
+  Int       m_defDispWinRightOffset;                          ///< Specifies the right offset from the conformance window of the default window
+  Int       m_defDispWinTopOffset;                            ///< Specifies the top offset from the conformance window of the default window
+  Int       m_defDispWinBottomOffset;                         ///< Specifies the bottom offset from the conformance window of the default window
+  Bool      m_frameFieldInfoPresentFlag;                      ///< Indicates that pic_struct values are present in picture timing SEI messages
+  Bool      m_pocProportionalToTimingFlag;                    ///< Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS
+  Int       m_numTicksPocDiffOneMinus1;                       ///< Number of ticks minus 1 that for a POC difference of one
   Bool      m_bitstreamRestrictionFlag;                       ///< Signals whether bitstream restriction parameters are present
   Bool      m_tilesFixedStructureFlag;                        ///< Indicates that each active picture parameter set has the same values of the syntax elements related to tiles
   Bool      m_motionVectorsOverPicBoundariesFlag;             ///< Indicates that no samples outside the picture boundaries are used for inter prediction
+  Int       m_minSpatialSegmentationIdc;                      ///< Indicates the maximum size of the spatial segments in the pictures in the coded video sequence
   Int       m_maxBytesPerPicDenom;                            ///< Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture
   Int       m_maxBitsPerMinCuDenom;                           ///< Indicates an upper bound for the number of bits of coding_unit() data
   Int       m_log2MaxMvLengthHorizontal;                      ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
   Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
-#endif
+
 #if REF_IDX_FRAMEWORK
   Int       m_elRapSliceBEnabled;
@@ -287,5 +307,14 @@
   Void  xPrintParameter ();                                   ///< print configuration values
   Void  xPrintUsage     ();                                   ///< print usage
-  
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+  Int       m_bitRatePicRateMaxTLayers;                       ///< Indicates max. number of sub-layers for which bit rate is signalled.
+  Bool*     m_bitRateInfoPresentFlag;                         ///< Indicates whether bit rate information is signalled
+  Bool*     m_picRateInfoPresentFlag;                         ///< Indicates whether pic rate information is signalled
+  Int*      m_avgBitRate;                                     ///< Indicates avg. bit rate information for various sub-layers
+  Int*      m_maxBitRate;                                     ///< Indicates max. bit rate information for various sub-layers
+  Int*      m_avgPicRate;                                     ///< Indicates avg. picture rate information for various sub-layers
+  Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
+#endif
+  #
 public:
   TAppEncCfg();
@@ -298,14 +327,15 @@
   
 #if SVC_EXTENSION
-  Int  getNumFrameToBeEncoded()    {return m_iFrameToBeEncoded; }
+  Int  getNumFrameToBeEncoded()    {return m_framesToBeEncoded; }
   Int  getNumLayer()               {return m_numLayers;        }
   Int  getGOPSize()                {return m_iGOPSize;          }
-  UInt getInternalBitDepth()       {return m_uiInternalBitDepth; }
+  UInt getInternalBitDepthY()      {return m_internalBitDepthY; }
+  UInt getInternalBitDepthC()      {return m_internalBitDepthC; }
   UInt getMaxCUWidth()             {return m_uiMaxCUWidth;      }
   UInt getMaxCUHeight()            {return m_uiMaxCUHeight;     }
   UInt getMaxCUDepth()             {return m_uiMaxCUDepth;      }
   Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
+  Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
   Void getDirFilename(string& filename, string& dir, const string path);
-  Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
 #if AVC_SYNTAX
   Char* getBLSyntaxFile()           { return m_BLSyntaxFile;      }
Index: trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 55)
+++ trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 125)
@@ -1,4 +1,4 @@
 /** \file     TAppEncLayerCfg.cpp
-    \brief    Handle encoder configuration parameters
+\brief    Handle encoder configuration parameters
 */
 
@@ -28,10 +28,10 @@
 #if SVC_EXTENSION
 TAppEncLayerCfg::TAppEncLayerCfg()
-:m_cInputFile(string("")),
- m_cReconFile(string("")),
- m_croppingMode( 0 ),
- m_aidQP(NULL)
-{
-  m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0;
+  :m_cInputFile(string("")),
+  m_cReconFile(string("")),
+  m_conformanceMode( 0 ),
+  m_aidQP(NULL)
+{
+  m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
   m_aiPad[1] = m_aiPad[0] = 0;
 }
@@ -59,7 +59,7 @@
 
 /** \param  argc        number of arguments
-    \param  argv        array of arguments
-    \retval             true when success
- */
+\param  argv        array of arguments
+\retval             true when success
+*/
 bool TAppEncLayerCfg::parseCfg( const string& cfgFileName  )
 {
@@ -69,24 +69,24 @@
   po::Options opts;
   opts.addOptions()
-  ("InputFile,i",           cfg_InputFile,  string(""), "original YUV input file name")
+    ("InputFile,i",           cfg_InputFile,  string(""), "original YUV input file name")
 #if AVC_BASE
-  ("InputBLFile,-ibl",      cfg_InputFile,  string(""), "original YUV input file name")
-#endif
-  ("ReconFile,o",           cfg_ReconFile,  string(""), "reconstructed YUV output file name")
-  ("SourceWidth,-wdt",      m_iSourceWidth,  0, "Source picture width")
-  ("SourceHeight,-hgt",     m_iSourceHeight, 0, "Source picture height")
-  ("CroppingMode",          m_croppingMode,  0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
-  ("CropLeft",              m_cropLeft,      0, "Left cropping/padding for cropping mode 3")
-  ("CropRight",             m_cropRight,     0, "Right cropping/padding for cropping mode 3")
-  ("CropTop",               m_cropTop,       0, "Top cropping/padding for cropping mode 3")
-  ("CropBottom",            m_cropBottom,    0, "Bottom cropping/padding for cropping mode 3")
-  ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding for cropping mode 2")
-  ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding for cropping mode 2")
-  ("IntraPeriod,-ip",       m_iIntraPeriod,  -1, "intra period in frames, (-1: only first frame)")
-  ("FrameRate,-fr",         m_iFrameRate,    0, "Frame rate")
-  ("dQPFile,m",             cfg_dQPFile, string(""), "dQP file name")
-  ("QP,q",                  m_fQP,          30.0, "Qp value, if value is float, QP is switched once during encoding")
-  ;
-  
+    ("InputBLFile,-ibl",      cfg_InputFile,  string(""), "original YUV input file name")
+#endif
+    ("ReconFile,o",           cfg_ReconFile,  string(""), "reconstructed YUV output file name")
+    ("SourceWidth,-wdt",      m_iSourceWidth,  0, "Source picture width")
+    ("SourceHeight,-hgt",     m_iSourceHeight, 0, "Source picture height")
+    ("CroppingMode",          m_conformanceMode,  0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
+    ("CropLeft",              m_confLeft,      0, "Left cropping/padding for cropping mode 3")
+    ("CropRight",             m_confRight,     0, "Right cropping/padding for cropping mode 3")
+    ("CropTop",               m_confTop,       0, "Top cropping/padding for cropping mode 3")
+    ("CropBottom",            m_confBottom,    0, "Bottom cropping/padding for cropping mode 3")
+    ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding for cropping mode 2")
+    ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding for cropping mode 2")
+    ("IntraPeriod,-ip",       m_iIntraPeriod,  -1, "intra period in frames, (-1: only first frame)")
+    ("FrameRate,-fr",         m_iFrameRate,    0, "Frame rate")
+    ("dQPFile,m",             cfg_dQPFile, string(""), "dQP file name")
+    ("QP,q",                  m_fQP,          30.0, "Qp value, if value is float, QP is switched once during encoding")
+    ;
+
   po::setDefaults(opts);
   po::parseConfigFile(opts, cfgFileName);
@@ -123,12 +123,9 @@
   printf("Base layer input file         : %s\n", m_cAppEncCfg->getBLSyntaxFile() );
 #endif
-  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate );
+  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
   printf("Internal Format               : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
   printf("QP                            : %5.2f\n", m_fQP );
   printf("Intra period                  : %d\n", m_iIntraPeriod );
-#if SVC_EXTENSION
-  printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d",
-          m_cAppEncCfg->getWaveFrontSynchro(), m_iWaveFrontSubstreams);
-#endif
+  printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_cAppEncCfg->getWaveFrontSynchro(), m_iWaveFrontSubstreams);
 }
 
@@ -137,10 +134,10 @@
 Bool TAppEncLayerCfg::xCheckParameter()
 {
-  switch (m_croppingMode)
+  switch (m_conformanceMode)
   {
   case 0:
     {
       // no cropping or padding
-      m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0;
+      m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
       m_aiPad[1] = m_aiPad[0] = 0;
       break;
@@ -152,11 +149,11 @@
       if (m_iSourceWidth % minCuSize)
       {
-        m_aiPad[0] = m_cropRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
-        m_iSourceWidth  += m_cropRight;
+        m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
+        m_iSourceWidth  += m_confRight;
       }
       if (m_iSourceHeight % minCuSize)
       {
-        m_aiPad[1] = m_cropBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
-        m_iSourceHeight += m_cropBottom;
+        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
+        m_iSourceHeight += m_confBottom;
       }
       break;
@@ -167,12 +164,12 @@
       m_iSourceWidth  += m_aiPad[0];
       m_iSourceHeight += m_aiPad[1];
-      m_cropRight  = m_aiPad[0];
-      m_cropBottom = m_aiPad[1];
+      m_confRight  = m_aiPad[0];
+      m_confBottom = m_aiPad[1];
       break;
     }
   case 3:
     {
-      // cropping
-      if ((m_cropLeft == 0) && (m_cropRight == 0) && (m_cropTop == 0) && (m_cropBottom == 0))
+      // conformance
+      if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
       {
         fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n");
@@ -200,5 +197,5 @@
   {
     Int iSwitchPOC = (Int)( iFrameToBeEncoded - (m_fQP - m_iQP)*iFrameToBeEncoded + 0.5 );
-    
+
 
     iSwitchPOC = (Int)( (Double)iSwitchPOC / iGOPSize + 0.5 )*iGOPSize;
@@ -224,13 +221,22 @@
   }
 
-  xConfirmPara( m_iQP <  -6 * ((Int)m_cAppEncCfg->getInternalBitDepth() - 8) || m_iQP > 51,                "QP exceeds supported range (-QpBDOffsety to 51)" );
-
-  
-#if SVC_EXTENSION
+  xConfirmPara( m_iQP <  -6 * ((Int)m_cAppEncCfg->getInternalBitDepthY() - 8) || m_iQP > 51,                "QP exceeds supported range (-QpBDOffsety to 51)" );
+
+
   m_iWaveFrontSubstreams = m_cAppEncCfg->getWaveFrontSynchro() ? (m_iSourceHeight + m_cAppEncCfg->getMaxCUHeight() - 1) / m_cAppEncCfg->getMaxCUHeight() : 1;
   xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
   xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_cAppEncCfg->getWaveFrontSynchro(), "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
-#endif
-
+
+  //chekc parameters
+  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
+
+  xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
+
+  xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
 #undef xConfirmPara
   return check_failed;
Index: trunk/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 55)
+++ trunk/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 125)
@@ -34,13 +34,16 @@
   Int       m_iSourceWidth;                                   ///< source width in pixel
   Int       m_iSourceHeight;                                  ///< source height in pixel
-  Int       m_croppingMode;
-  Int       m_cropLeft;
-  Int       m_cropRight;
-  Int       m_cropTop;
-  Int       m_cropBottom;
+  Int       m_conformanceMode;
+  Int       m_confLeft;
+  Int       m_confRight;
+  Int       m_confTop;
+  Int       m_confBottom;
   Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
   Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
   Double    m_fQP;                                            ///< QP value of key-picture (floating point)
-
+#if VPS_EXTN_DIRECT_REF_LAYERS
+  Int       *m_refLayerIds;
+  Int       m_numDirectRefLayers;
+#endif
 #if SVC_EXTENSION
   Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
@@ -64,4 +67,5 @@
 
   Void    setAppEncCfg(TAppEncCfg* p) {m_cAppEncCfg = p;          }
+
   string  getInputFile()              {return m_cInputFile;       }
   string  getReconFile()              {return m_cReconFile;       }
@@ -69,15 +73,19 @@
   Int     getSourceWidth()            {return m_iSourceWidth;     }
   Int     getSourceHeight()           {return m_iSourceHeight;    }
-  Int     getCroppingMode()           {return m_croppingMode;     }
-  Int     getCropLeft()               {return m_cropLeft;         }
-  Int     getCropRight()              {return m_cropRight;        }
-  Int     getCropTop()                {return m_cropTop;          }
-  Int     getCropBottom()             {return m_cropBottom;       }
+  Int     getConformanceMode()        { return m_conformanceMode; }
   Int*    getPad()                    {return m_aiPad;            }
   Double  getFloatQP()                {return m_fQP;              }
+  Int     getConfLeft()               {return m_confLeft;         }
+  Int     getConfRight()              {return m_confRight;        }
+  Int     getConfTop()                {return m_confTop;          }
+  Int     getConfBottom()             {return m_confBottom;       }
 
   Int     getIntQP()                  {return m_iQP;              } 
   Int*    getdQPs()                   {return m_aidQP;            }
-
+#if VPS_EXTN_DIRECT_REF_LAYERS
+  Int     getNumDirectRefLayers()     {return m_numDirectRefLayers;}
+  Int*    getRefLayerIds()            {return m_refLayerIds;      }
+  Int     getRefLayerId(Int i)        {return m_refLayerIds[i];   }
+#endif
 }; // END CLASS DEFINITION TAppEncLayerCfg
 
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 55)
+++ trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 125)
@@ -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-2012, 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
 */
 
@@ -75,36 +75,42 @@
 Void TAppEncTop::xInitLibCfg()
 {
+  TComVPS* vps = m_acTEncTop[0].getVPS();
+
+  vps->setMaxTLayers                       ( m_maxTempLayer );
+  if (m_maxTempLayer == 1)
+  {
+    vps->setTemporalNestingFlag(true);
+  }
+#if !VPS_RENAME
+  vps.setMaxLayers                        ( 1 );
+#endif
+  for(Int i = 0; i < MAX_TLAYER; i++)
+  {
+    vps->setNumReorderPics                 ( m_numReorderPics[i], i );
+    vps->setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
+  }
+
   for(UInt layer=0; layer<m_numLayers; layer++)
   {
-    TComVPS vps;
-
-    vps.setMaxTLayers                       ( m_maxTempLayer );
-    vps.setMaxLayers                        ( 1 );
-    for(Int i = 0; i < MAX_TLAYER; i++)
-    {
-      vps.setNumReorderPics                 ( m_numReorderPics[i], i );
-      vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
-    }
-    m_acTEncTop[layer].setVPS(&vps);
+    //m_acTEncTop[layer].setVPS(&vps);
     m_acTEncTop[layer].setFrameRate                    ( m_acLayerCfg[layer].getFrameRate() );
     m_acTEncTop[layer].setFrameSkip                    ( m_FrameSkip );
     m_acTEncTop[layer].setSourceWidth                  ( m_acLayerCfg[layer].getSourceWidth() );
     m_acTEncTop[layer].setSourceHeight                 ( m_acLayerCfg[layer].getSourceHeight() );
-    m_acTEncTop[layer].setCroppingMode                 ( m_acLayerCfg[layer].getCroppingMode() );
-    m_acTEncTop[layer].setCropLeft                     ( m_acLayerCfg[layer].getCropLeft() );
-    m_acTEncTop[layer].setCropRight                    ( m_acLayerCfg[layer].getCropRight() );
-    m_acTEncTop[layer].setCropTop                      ( m_acLayerCfg[layer].getCropTop() );
-    m_acTEncTop[layer].setCropBottom                   ( m_acLayerCfg[layer].getCropBottom() );
-    m_acTEncTop[layer].setFrameToBeEncoded             ( m_iFrameToBeEncoded );
+    m_acTEncTop[layer].setConformanceMode              ( m_acLayerCfg[layer].getConformanceMode() );
+    m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom );
+    m_acTEncTop[layer].setFramesToBeEncoded            ( m_framesToBeEncoded );
+
+    m_acTEncTop[layer].setProfile(m_profile);
+    m_acTEncTop[layer].setLevel(m_levelTier, m_level);
+#if L0046_CONSTRAINT_FLAGS
+    m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag);
+    m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag);
+    m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
+    m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
+#endif
 
 #if REF_IDX_MFM
-    if(layer == 0)
-    {
-      m_acTEncTop[layer].setMFMEnabledFlag(false);
-    }
-    else
-    {
-      m_acTEncTop[layer].setMFMEnabledFlag(true);
-    }
+    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : true);
 #endif
     // set layer ID 
@@ -112,5 +118,4 @@
     m_acTEncTop[layer].setNumLayer ( m_numLayers );
     m_acTEncTop[layer].setLayerEnc(m_apcTEncTop);
-
 
     //====== Coding Structure ========
@@ -134,9 +139,24 @@
 
     m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
-#if !REMOVE_NSQT
-    m_acTEncTop[layer].setUseNSQT( m_enableNSQT );
-#endif
     m_acTEncTop[layer].setUseAMP( m_enableAMP );
-
+#if VPS_EXTN_DIRECT_REF_LAYERS
+    if(layer)
+    {
+      if(m_acLayerCfg[layer].getNumDirectRefLayers() == -1)
+      {
+        // Not included in the configuration file; assume that each layer depends on previous layer
+        m_acTEncTop[layer].setNumDirectRefLayers       (1);      // One ref. layer
+        m_acTEncTop[layer].setRefLayerId               (0, layer - 1);   // Previous layer
+      }
+      else
+      {
+        m_acTEncTop[layer].setNumDirectRefLayers       ( m_acLayerCfg[layer].getNumDirectRefLayers() );      
+        for(Int i = 0; i < m_acTEncTop[layer].getNumDirectRefLayers(); i++)
+        {
+          m_acTEncTop[layer].setRefLayerId             ( i, m_acLayerCfg[layer].getRefLayerId(i));
+        }        
+      }
+    }
+#endif
     //===== Slice ========
 
@@ -157,6 +177,6 @@
     m_acTEncTop[layer].setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
 
-    m_acTEncTop[layer].setChromaCbQpOffset               ( m_cbQpOffset     );
-    m_acTEncTop[layer].setChromaCrQpOffset            ( m_crQpOffset  );
+    m_acTEncTop[layer].setChromaCbQpOffset             ( m_cbQpOffset     );
+    m_acTEncTop[layer].setChromaCrQpOffset             ( m_crQpOffset  );
 
 #if ADAPTIVE_QP_SELECTION
@@ -165,5 +185,5 @@
 
     Int lowestQP;
-    lowestQP =  - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
+    lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
 
     if ((m_iMaxDeltaQP == 0 ) && (m_acLayerCfg[layer].getIntQP() == lowestQP) && (m_useLossless == true))
@@ -179,11 +199,12 @@
     m_acTEncTop[layer].setUseASR                       ( m_bUseASR      );
     m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
-#if !REMOVE_ALF
-    m_acTEncTop[layer].setUseALF                       ( m_bUseALF      );
-#endif
     m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
     m_acTEncTop[layer].setUseLComb                     ( m_bUseLComb    );
-    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs()        );
-    m_acTEncTop[layer].setUseRDOQ                      ( m_bUseRDOQ     );
+    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
+    m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
+    m_acTEncTop[layer].setUseRDOQTS                    ( m_useRDOQTS   );
+#if L0232_RD_PENALTY
+    m_acTEncTop[layer].setRDpenalty                    ( m_rdPenalty );
+#endif
     m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
     m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
@@ -193,14 +214,11 @@
     m_acTEncTop[layer].setUseEarlyCU                   ( m_bUseEarlyCU  ); 
     m_acTEncTop[layer].setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
-    m_acTEncTop[layer].setUseCbfFastMode            ( m_bUseCbfFastMode  );
-    m_acTEncTop[layer].setUseEarlySkipDetection            ( m_useEarlySkipDetection );
-
-#if !REMOVE_LMCHROMA
-    m_acTEncTop[layer].setUseLMChroma                  ( m_bUseLMChroma );
-#endif
+    m_acTEncTop[layer].setUseCbfFastMode               ( m_bUseCbfFastMode  );
+    m_acTEncTop[layer].setUseEarlySkipDetection        ( m_useEarlySkipDetection );
+
     m_acTEncTop[layer].setUseTransformSkip             ( m_useTransformSkip      );
     m_acTEncTop[layer].setUseTransformSkipFast         ( m_useTransformSkipFast  );
     m_acTEncTop[layer].setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
-    m_acTEncTop[layer].setPCMLog2MinSize          ( m_uiPCMLog2MinSize);
+    m_acTEncTop[layer].setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
     m_acTEncTop[layer].setUsePCM                       ( m_usePCM );
     m_acTEncTop[layer].setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
@@ -209,5 +227,5 @@
 
     //====== Weighted Prediction ========
-    m_acTEncTop[layer].setUseWP                   ( m_bUseWeightPred      );
+    m_acTEncTop[layer].setUseWP                   ( m_useWeightedPred      );
     m_acTEncTop[layer].setWPBiPred                ( m_useWeightedBiPred   );
     //====== Parallel Merge Estimation ========
@@ -215,43 +233,25 @@
 
     //====== Slice ========
-    m_acTEncTop[layer].setSliceMode               ( m_iSliceMode                );
-    m_acTEncTop[layer].setSliceArgument           ( m_iSliceArgument            );
+    m_acTEncTop[layer].setSliceMode               ( m_sliceMode                );
+    m_acTEncTop[layer].setSliceArgument           ( m_sliceArgument            );
 
     //====== Dependent Slice ========
-    m_acTEncTop[layer].setDependentSliceMode        ( m_iDependentSliceMode         );
-    m_acTEncTop[layer].setDependentSliceArgument    ( m_iDependentSliceArgument     );
-#if DEPENDENT_SLICES
-#if TILES_WPP_ENTROPYSLICES_FLAGS
-    m_acTEncTop[layer].setEntropySliceEnabledFlag   ( m_entropySliceEnabledFlag );
-#else
-    m_acTEncTop[layer].setCabacIndependentFlag      ( m_bCabacIndependentFlag   );
-#endif
-#endif
-    int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
-    if(m_iDependentSliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE)
-    {
-#if REMOVE_FGS
-      m_acTEncTop[layer].setDependentSliceArgument ( m_iDependentSliceArgument * iNumPartInCU );
-#else
-      m_acTEncTop[layer].setDependentSliceArgument ( m_iDependentSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
-#endif
-    }
-    if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
-    {
-#if REMOVE_FGS
-      m_acTEncTop[layer].setSliceArgument ( m_iSliceArgument * iNumPartInCU );
-#else
-      m_acTEncTop[layer].setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
-#endif
-    }
-    if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
-    {
-      m_acTEncTop[layer].setSliceArgument ( m_iSliceArgument );
-    }
-
-#if !REMOVE_FGS
-    m_acTEncTop[layer].setSliceGranularity        ( m_iSliceGranularity         );
-#endif
-    if(m_iSliceMode == 0 )
+    m_acTEncTop[layer].setSliceSegmentMode        ( m_sliceSegmentMode         );
+    m_acTEncTop[layer].setSliceSegmentArgument    ( m_sliceSegmentArgument     );
+    Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
+    if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
+    {
+      m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
+    }
+    if(m_sliceMode==FIXED_NUMBER_OF_LCU)
+    {
+      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU );
+    }
+    if(m_sliceMode==FIXED_NUMBER_OF_TILES)
+    {
+      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument );
+    }
+
+    if(m_sliceMode == 0 )
     {
       m_bLFCrossSliceBoundaryFlag = true;
@@ -261,19 +261,22 @@
     m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
 
-#if SAO_LCU_BOUNDARY
     m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary);
-#endif
     m_acTEncTop[layer].setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
     m_acTEncTop[layer].setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
     m_acTEncTop[layer].setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
 
-    m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodePictureHashSEIEnabled);
-#if RECOVERY_POINT_SEI
+    m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
-#endif
-#if BUFFERING_PERIOD_AND_TIMING_SEI
     m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
     m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
-#endif
+    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
+    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
+    m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId );
+    m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
+    m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
+    m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
+    m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
+    m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
+    m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
     m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
     m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
@@ -281,6 +284,6 @@
     if(m_iUniformSpacingIdr==0)
     {
-      m_acTEncTop[layer].setColumnWidth              ( m_pchColumnWidth );
-      m_acTEncTop[layer].setRowHeight                ( m_pchRowHeight );
+      m_acTEncTop[layer].setColumnWidth              ( m_pColumnWidth );
+      m_acTEncTop[layer].setRowHeight                ( m_pRowHeight );
     }
     m_acTEncTop[layer].xCheckGSParameters();
@@ -297,19 +300,22 @@
     m_acTEncTop[layer].setScalingListFile            ( m_scalingListFile   );
     m_acTEncTop[layer].setSignHideFlag(m_signHideFlag);
-#if !REMOVE_ALF
-    m_acTEncTop[layer].setALFLowLatencyEncoding( m_alfLowLatencyEncoding );
-#endif
+#if RATE_CONTROL_LAMBDA_DOMAIN
+    m_acTEncTop[layer].setUseRateCtrl         ( m_RCEnableRateControl );
+    m_acTEncTop[layer].setTargetBitrate       ( m_RCTargetBitrate );
+    m_acTEncTop[layer].setKeepHierBit         ( m_RCKeepHierarchicalBit );
+    m_acTEncTop[layer].setLCULevelRC          ( m_RCLCULevelRC );
+    m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
+    m_acTEncTop[layer].setInitialQP           ( m_RCInitialQP );
+    m_acTEncTop[layer].setForceIntraQP        ( m_RCForceIntraQP );
+#else
     m_acTEncTop[layer].setUseRateCtrl     ( m_enableRateCtrl);
     m_acTEncTop[layer].setTargetBitrate   ( m_targetBitrate);
     m_acTEncTop[layer].setNumLCUInUnit    ( m_numLCUInUnit);
+#endif
     m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
     m_acTEncTop[layer].setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
-#if RECALCULATE_QP_ACCORDING_LAMBDA
     m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
-#endif
-#if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
+    m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
     m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); 
-#endif 
-#if SUPPORT_FOR_VUI
     m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
     m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc );
@@ -329,11 +335,41 @@
     m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
     m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
+    m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
+    m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
+    m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
+    m_acTEncTop[layer].setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
     m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
     m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
     m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
+    m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
     m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
     m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
     m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
     m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+    TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop[layer].getVPS()->getBitratePicrateInfo();
+    // The number of bit rate/pic rate have to equal to number of sub-layers.
+    if(m_bitRatePicRateMaxTLayers)
+    {
+      assert(m_bitRatePicRateMaxTLayers == m_cTEncTop[layer].getVPS()->getMaxTLayers());
+    }
+    for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
+    {
+      bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
+      if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
+      {
+        bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
+        bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
+      }
+    }
+    for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
+    {
+      bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
+      if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
+      {
+        bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
+        bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
+      }
+    }
 #endif
 #if REF_IDX_FRAMEWORK
@@ -346,6 +382,10 @@
 {
   TComVPS vps;
-  
+
   vps.setMaxTLayers                       ( m_maxTempLayer );
+  if (m_maxTempLayer == 1)
+  {
+    vps.setTemporalNestingFlag(true);
+  }
   vps.setMaxLayers                        ( 1 );
   for(Int i = 0; i < MAX_TLAYER; i++)
@@ -355,15 +395,21 @@
   }
   m_cTEncTop.setVPS(&vps);
+
+  m_cTEncTop.setProfile(m_profile);
+  m_cTEncTop.setLevel(m_levelTier, m_level);
+#if L0046_CONSTRAINT_FLAGS
+  m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
+  m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
+  m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
+  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
+#endif
+
   m_cTEncTop.setFrameRate                    ( m_iFrameRate );
   m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
   m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
   m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
-  m_cTEncTop.setCroppingMode                 ( m_croppingMode );
-  m_cTEncTop.setCropLeft                     ( m_cropLeft );
-  m_cTEncTop.setCropRight                    ( m_cropRight );
-  m_cTEncTop.setCropTop                      ( m_cropTop );
-  m_cTEncTop.setCropBottom                   ( m_cropBottom );
-  m_cTEncTop.setFrameToBeEncoded             ( m_iFrameToBeEncoded );
-  
+  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
+  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
+
   //====== Coding Structure ========
   m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
@@ -382,15 +428,12 @@
   }
   m_cTEncTop.setQP                           ( m_iQP );
-  
+
   m_cTEncTop.setPad                          ( m_aiPad );
-    
+
   m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
-#if !REMOVE_NSQT
-  m_cTEncTop.setUseNSQT( m_enableNSQT );
-#endif
   m_cTEncTop.setUseAMP( m_enableAMP );
-  
+
   //===== Slice ========
-  
+
   //====== Loop/Deblock Filter ========
   m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
@@ -417,5 +460,5 @@
 
   Int lowestQP;
-  lowestQP =  - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
+  lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
 
   if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
@@ -425,5 +468,5 @@
   m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
   m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
-  
+
   //====== Tool list ========
   m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
@@ -431,11 +474,12 @@
   m_cTEncTop.setUseASR                       ( m_bUseASR      );
   m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
-#if !REMOVE_ALF
-  m_cTEncTop.setUseALF                       ( m_bUseALF      );
-#endif
   m_cTEncTop.setUseLossless                  ( m_useLossless );
   m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
   m_cTEncTop.setdQPs                         ( m_aidQP        );
-  m_cTEncTop.setUseRDOQ                      ( m_bUseRDOQ     );
+  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
+  m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
+#if L0232_RD_PENALTY
+  m_cTEncTop.setRDpenalty                 ( m_rdPenalty );
+#endif
   m_cTEncTop.setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
   m_cTEncTop.setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
@@ -448,7 +492,4 @@
   m_cTEncTop.setUseEarlySkipDetection            ( m_useEarlySkipDetection );
 
-#if !REMOVE_LMCHROMA
-  m_cTEncTop.setUseLMChroma                  ( m_bUseLMChroma );
-#endif
   m_cTEncTop.setUseTransformSkip             ( m_useTransformSkip      );
   m_cTEncTop.setUseTransformSkipFast         ( m_useTransformSkipFast  );
@@ -458,8 +499,8 @@
   m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
   m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
-  
+
 
   //====== Weighted Prediction ========
-  m_cTEncTop.setUseWP                   ( m_bUseWeightPred      );
+  m_cTEncTop.setUseWP                   ( m_useWeightedPred      );
   m_cTEncTop.setWPBiPred                ( m_useWeightedBiPred   );
   //====== Parallel Merge Estimation ========
@@ -467,43 +508,25 @@
 
   //====== Slice ========
-  m_cTEncTop.setSliceMode               ( m_iSliceMode                );
-  m_cTEncTop.setSliceArgument           ( m_iSliceArgument            );
+  m_cTEncTop.setSliceMode               ( m_sliceMode                );
+  m_cTEncTop.setSliceArgument           ( m_sliceArgument            );
 
   //====== Dependent Slice ========
-  m_cTEncTop.setDependentSliceMode        ( m_iDependentSliceMode         );
-  m_cTEncTop.setDependentSliceArgument    ( m_iDependentSliceArgument     );
-#if DEPENDENT_SLICES
-#if TILES_WPP_ENTROPYSLICES_FLAGS
-  m_cTEncTop.setEntropySliceEnabledFlag   ( m_entropySliceEnabledFlag );
-#else
-  m_cTEncTop.setCabacIndependentFlag      ( m_bCabacIndependentFlag   );
-#endif
-#endif
-  int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
-  if(m_iDependentSliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE)
-  {
-#if REMOVE_FGS
-    m_cTEncTop.setDependentSliceArgument ( m_iDependentSliceArgument * iNumPartInCU );
-#else
-    m_cTEncTop.setDependentSliceArgument ( m_iDependentSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
-#endif
-  }
-  if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
-  {
-#if REMOVE_FGS
-    m_cTEncTop.setSliceArgument ( m_iSliceArgument * iNumPartInCU );
-#else
-    m_cTEncTop.setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
-#endif
-  }
-  if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
-  {
-    m_cTEncTop.setSliceArgument ( m_iSliceArgument );
-  }
-  
-#if !REMOVE_FGS
-  m_cTEncTop.setSliceGranularity        ( m_iSliceGranularity         );
-#endif
-  if(m_iSliceMode == 0 )
+  m_cTEncTop.setSliceSegmentMode        ( m_sliceSegmentMode         );
+  m_cTEncTop.setSliceSegmentArgument    ( m_sliceSegmentArgument     );
+  Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
+  if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
+  {
+    m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
+  }
+  if(m_sliceMode==FIXED_NUMBER_OF_LCU)
+  {
+    m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU );
+  }
+  if(m_sliceMode==FIXED_NUMBER_OF_TILES)
+  {
+    m_cTEncTop.setSliceArgument ( m_sliceArgument );
+  }
+
+  if(m_sliceMode == 0 )
   {
     m_bLFCrossSliceBoundaryFlag = true;
@@ -513,19 +536,22 @@
   m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
 
-#if SAO_LCU_BOUNDARY
   m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
-#endif
   m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
   m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
   m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
 
-  m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodePictureHashSEIEnabled);
-#if RECOVERY_POINT_SEI
+  m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
   m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
-#endif
-#if BUFFERING_PERIOD_AND_TIMING_SEI
   m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
   m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
-#endif
+  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
+  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
+  m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId );
+  m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
+  m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
+  m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
+  m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
+  m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
+  m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
   m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
   m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
@@ -533,6 +559,6 @@
   if(m_iUniformSpacingIdr==0)
   {
-    m_cTEncTop.setColumnWidth              ( m_pchColumnWidth );
-    m_cTEncTop.setRowHeight                ( m_pchRowHeight );
+    m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
+    m_cTEncTop.setRowHeight                ( m_pRowHeight );
   }
   m_cTEncTop.xCheckGSParameters();
@@ -549,19 +575,22 @@
   m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
   m_cTEncTop.setSignHideFlag(m_signHideFlag);
-#if !REMOVE_ALF
-  m_cTEncTop.setALFLowLatencyEncoding( m_alfLowLatencyEncoding );
-#endif
+#if RATE_CONTROL_LAMBDA_DOMAIN
+  m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
+  m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
+  m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
+  m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
+  m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
+  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
+  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
+#else
   m_cTEncTop.setUseRateCtrl     ( m_enableRateCtrl);
   m_cTEncTop.setTargetBitrate   ( m_targetBitrate);
   m_cTEncTop.setNumLCUInUnit    ( m_numLCUInUnit);
+#endif
   m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
   m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
-#if RECALCULATE_QP_ACCORDING_LAMBDA
   m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
-#endif
-#if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
+  m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
   m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); 
-#endif 
-#if SUPPORT_FOR_VUI
   m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
   m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
@@ -581,11 +610,41 @@
   m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
   m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
+  m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
+  m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
+  m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
+  m_cTEncTop.setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
   m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
   m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
   m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
+  m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
   m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
   m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
   m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
   m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+  TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop.getVPS()->getBitratePicrateInfo();
+  // The number of bit rate/pic rate have to equal to number of sub-layers.
+  if(m_bitRatePicRateMaxTLayers)
+  {
+    assert(m_bitRatePicRateMaxTLayers == m_cTEncTop.getVPS()->getMaxTLayers());
+  }
+  for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
+  {
+    bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
+    if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
+    {
+      bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
+      bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
+    }
+  }
+  for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
+  {
+    bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
+    if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
+    {
+      bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
+      bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
+    }
+  }
 #endif
 }
@@ -601,10 +660,10 @@
   for(UInt layer=0; layer<m_numLayers; layer++)
   {
-    m_acTVideoIOYuvInputFile[layer].open( (char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
+    m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]);
 
     if (!m_acLayerCfg[layer].getReconFile().empty())
     {
-      m_acTVideoIOYuvReconFile[layer].open((char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
+      m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // write mode
     }
 
@@ -612,10 +671,10 @@
   }
 #else
-  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
+  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
   m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
 
   if (m_pchReconFile)
-    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
-  
+    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
+
   // Neo Decoder
   m_cTEncTop.create();
@@ -640,5 +699,5 @@
   m_cTVideoIOYuvInputFile.close();
   m_cTVideoIOYuvReconFile.close();
-  
+
   // Neo Decoder
   m_cTEncTop.destroy();
@@ -653,4 +712,94 @@
     m_acTEncTop[layer].init();
   }
+#if VPS_RENAME
+  m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers );
+#endif
+#if VPS_EXTN_OP_LAYER_SETS
+  TComVPS* vps = m_acTEncTop[0].getVPS();
+  vps->setMaxLayerId(m_numLayers - 1);    // Set max-layer ID
+
+  vps->setNumLayerSets(m_numLayers);
+  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
+  {
+    for(Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++)
+    {
+      vps->setLayerIdIncludedFlag(true, setId, layerId);
+    }
+  }
+#if VPS_EXTN_MASK_AND_DIM_INFO
+  UInt i = 0, dimIdLen = 0;
+  vps->setAvcBaseLayerFlag(false);
+  vps->setSplittingFlag(false);
+  for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
+  {
+    vps->setScalabilityMask(i, false);
+  }
+  if(m_numLayers > 1) 
+  {
+    vps->setScalabilityMask(1, true); // Only turn on spatial/SNR scalability
+    vps->setNumScalabilityTypes(1);
+  }
+  else
+  {
+    vps->setNumScalabilityTypes(0);
+  }
+  while((1 << dimIdLen) < m_numLayers)
+  {
+    dimIdLen++;
+  }
+  vps->setDimensionIdLen(0, dimIdLen);
+  vps->setNuhLayerIdPresentFlag(false);
+  vps->setLayerIdInNuh(0, 0);
+  vps->setLayerIdInVps(0, 0);
+  for(i = 1; i < vps->getMaxLayers(); i++)
+  {
+    vps->setLayerIdInNuh(i, i);
+    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
+    vps->setDimensionId(i, 0, i);
+  }
+#endif
+#if VPS_EXTN_PROFILE_INFO
+  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
+  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
+  {
+    vps->setProfilePresentFlag(setId, true);
+    // Note - may need to be changed for other layer structures.
+    *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL());
+  }
+#endif
+  // Target output layer
+  vps->setNumOutputLayerSets(1);
+  Int lsIdx = 1;
+  vps->setOutputLayerSetIdx(0, lsIdx); // Because only one layer set
+  // Include the highest layer as output layer 
+  for(UInt layer=0; layer <= vps->getMaxLayerId() ; layer++)
+  {
+    if(vps->getLayerIdIncludedFlag(lsIdx, layer))
+    {
+      vps->setOutputLayerFlag(lsIdx, layer, layer == (vps->getMaxLayerId()));
+    }
+  }
+#endif
+#if VPS_EXTN_DIRECT_REF_LAYERS
+  // Direct reference layers
+  for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
+  {
+    vps->setNumDirectRefLayers( layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers() );
+    for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
+    {
+      vps->setRefLayerId( layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i) );
+    }
+    // Set direct dependency flag
+    // Initialize flag to 0
+    for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
+    {
+      vps->setDirectDependencyFlag( layerCtr, refLayerCtr, false );
+    }
+    for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
+    {
+      vps->setDirectDependencyFlag( layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true);
+    }
+  }
+#endif
 #else
   m_cTEncTop.init();
@@ -663,18 +812,18 @@
 
 /**
- - 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()
 {
-  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
+  fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out);
   if (!bitstreamFile)
   {
-    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
+    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile);
     exit(EXIT_FAILURE);
   }
@@ -682,7 +831,6 @@
   TComPicYuv*       pcPicYuvOrg [MAX_LAYERS];
   TComPicYuv*       pcPicYuvRec = NULL;
-  
+
   // initialize internal class & member variables
-
   xInitLibCfg();
   xCreateLib();
@@ -690,7 +838,7 @@
 
   // main encoder loop
-  Int   iNumEncoded, iTotalNumEncoded;
-  Bool  bEos = false, bBaseEos = false;
-  
+  Int   iNumEncoded = 0, iTotalNumEncoded = 0;
+  Bool  bEos = false;
+
   list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
 
@@ -699,8 +847,8 @@
     // allocate original YUV buffer
     pcPicYuvOrg[layer] = new TComPicYuv;
-#if SVC_UPSAMPLING 
+#if SVC_UPSAMPLING
     pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
 #else
-    pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
+    pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
 #endif
   }
@@ -733,6 +881,7 @@
         xGetBuffer(pcPicYuvRec, layer);
 
+        // read input YUV file
         m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() );
-    
+
         if(layer == m_numLayers-1)
         {
@@ -740,16 +889,20 @@
           m_iFrameRcvd++;
           // check end of file
-          bEos = ( m_acTVideoIOYuvInputFile[layer].isEof() == 1 ?   true : bBaseEos? true : bEos  );
-          bEos = ( m_iFrameRcvd == m_iFrameToBeEncoded ?    true : bEos   );
+          bEos = (m_iFrameRcvd == m_framesToBeEncoded);
         }
-        else
-        {
-          // check end of file of base layers
-          bBaseEos = ( m_acTVideoIOYuvInputFile[layer].isEof() == 1 ?   true : bBaseEos  );
-        }
-        m_acTEncTop[layer].encodePrep( bEos, pcPicYuvOrg[layer] );
+
+        m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
       }
 
       bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos );
+    }
+    Bool flush = 0;
+    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
+    if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof())
+    {
+      flush = true;
+      bEos = true;
+      m_iFrameRcvd--;
+      m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd);
     }
 
@@ -761,6 +914,5 @@
       {
         // call encoding function for one frame
-        m_acTEncTop[layer].encode( pcPicYuvOrg[layer], m_acListPicYuvRec[layer], 
-          outputAccessUnits, iPicIdInGOP );
+        m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
       }
     }
@@ -771,5 +923,5 @@
       // write bistream to file if necessary
       iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
-      if ( iNumEncoded > 0 )  
+      if ( iNumEncoded > 0 )
       {
         xWriteRecon(layer, iNumEncoded);
@@ -794,5 +946,4 @@
     bFirstFrame = false;
   }
-
   // delete original YUV buffer
   for(UInt layer=0; layer<m_numLayers; layer++)
@@ -805,5 +956,5 @@
     m_acTEncTop[layer].deletePicBuffer();
   }
-  
+
 #if AVC_SYNTAX
   if( streamSyntaxFile.is_open() )
@@ -816,10 +967,9 @@
   xDeleteBuffer();
   xDestroyLib();
-  
+
   printRateSummary();
 
   return;
 }
-
 
 Void TAppEncTop::printOutSummary()
@@ -843,5 +993,5 @@
     m_gcAnalyzeAll[layer].printOut('a', layer);
   }
-    
+
   printf( "\n\nI Slices--------------------------------------------------------\n" );
   printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
@@ -850,5 +1000,5 @@
     m_gcAnalyzeI[layer].printOut('i', layer);
   }
-    
+
   printf( "\n\nP Slices--------------------------------------------------------\n" );
   printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
@@ -857,5 +1007,5 @@
     m_gcAnalyzeP[layer].printOut('p', layer);
   }
-    
+
   printf( "\n\nB Slices--------------------------------------------------------\n" );
   printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
@@ -878,19 +1028,19 @@
   TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
   TComPicYuv*       pcPicYuvRec = NULL;
-  
+
   // initialize internal class & member variables
   xInitLibCfg();
   xCreateLib();
   xInitLib();
-  
+
   // main encoder loop
   Int   iNumEncoded = 0;
   Bool  bEos = false;
-  
+
   list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
 
   // allocate original YUV buffer
   pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
-  
+
   while ( !bEos )
   {
@@ -900,15 +1050,23 @@
     // read input YUV file
     m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
-    
+
     // increase number of received frames
     m_iFrameRcvd++;
-    
-    // check end of file
-    bEos = ( m_cTVideoIOYuvInputFile.isEof() == 1 ?   true : false  );
-    bEos = ( m_iFrameRcvd == m_iFrameToBeEncoded ?    true : bEos   );
-    
+
+    bEos = (m_iFrameRcvd == m_framesToBeEncoded);
+
+    Bool flush = 0;
+    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
+    if (m_cTVideoIOYuvInputFile.isEof())
+    {
+      flush = true;
+      bEos = true;
+      m_iFrameRcvd--;
+      m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd);
+    }
+
     // call encoding function for one frame
-    m_cTEncTop.encode( bEos, pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
-    
+    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
+
     // write bistream to file if necessary
     if ( iNumEncoded > 0 )
@@ -918,16 +1076,19 @@
     }
   }
+
+  m_cTEncTop.printSummary();
+
   // delete original YUV buffer
   pcPicYuvOrg->destroy();
   delete pcPicYuvOrg;
   pcPicYuvOrg = NULL;
-  
+
   // delete used buffers in encoder class
   m_cTEncTop.deletePicBuffer();
-  
+
   // delete buffers & classes
   xDeleteBuffer();
   xDestroyLib();
-  
+
   printRateSummary();
 
@@ -941,14 +1102,14 @@
 
 /**
- - 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)
 {
   assert( m_iGOPSize > 0 );
-  
+
   // org. buffer
   if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize )
@@ -960,5 +1121,5 @@
   {
     rpcPicYuvRec = new TComPicYuv;
-    
+
 #if SVC_UPSAMPLING
     rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
@@ -976,7 +1137,7 @@
   {
     TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_acListPicYuvRec[layer].begin();
-    
+
     Int iSize = Int( m_acListPicYuvRec[layer].size() );
-    
+
     for ( Int i = 0; i < iSize; i++ )
     {
@@ -988,17 +1149,15 @@
 }
 
-
-
 Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
 {
   Int i;
-  
+
   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
-  
+
   for ( i = 0; i < iNumEncoded; i++ )
   {
     --iterPicYuvRec;
   }
-  
+
   for ( i = 0; i < iNumEncoded; i++ )
   {
@@ -1006,21 +1165,20 @@
     if (!m_acLayerCfg[layer].getReconFile().empty())
     {
-      m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getCropLeft(), m_acLayerCfg[layer].getCropRight(), 
-        m_acLayerCfg[layer].getCropTop(), m_acLayerCfg[layer].getCropBottom() );
-    }
-  }
-}
-
+      m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), 
+        m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
+    }
+  }
+}
 
 Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
 {
   Int i;
-  
+
   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
-  
+
   for ( i = 0; i < iNumEncoded; i++ )
   {
     const AccessUnit& au = *(iterBitstream++);
-    const vector<unsigned>& stats = writeAnnexB(bitstreamFile, au);
+    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     rateStatsAccum(au, stats);
   }
@@ -1031,5 +1189,5 @@
 {
   assert( m_iGOPSize > 0 );
-  
+
   // org. buffer
   if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
@@ -1041,5 +1199,5 @@
   {
     rpcPicYuvRec = new TComPicYuv;
-    
+
     rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
 
@@ -1051,7 +1209,7 @@
 {
   TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
-  
+
   Int iSize = Int( m_cListPicYuvRec.size() );
-  
+
   for ( Int i = 0; i < iSize; i++ )
   {
@@ -1060,21 +1218,21 @@
     delete pcPicYuvRec; pcPicYuvRec = NULL;
   }
-  
+
 }
 
 /** \param iNumEncoded  number of encoded frames
- */
+*/
 Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
 {
   Int i;
-  
+
   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
-  
+
   for ( i = 0; i < iNumEncoded; i++ )
   {
     --iterPicYuvRec;
   }
-  
+
   for ( i = 0; i < iNumEncoded; i++ )
   {
@@ -1082,9 +1240,9 @@
     if (m_pchReconFile)
     {
-      m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
+      m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     }
 
     const AccessUnit& au = *(iterBitstream++);
-    const vector<unsigned>& stats = writeAnnexB(bitstreamFile, au);
+    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     rateStatsAccum(au, stats);
   }
@@ -1093,10 +1251,10 @@
 
 /**
- *
- */
-void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& annexBsizes)
+*
+*/
+void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
 {
   AccessUnit::const_iterator it_au = au.begin();
-  vector<unsigned>::const_iterator it_stats = annexBsizes.begin();
+  vector<UInt>::const_iterator it_stats = annexBsizes.begin();
 
   for (; it_au != au.end(); it_au++, it_stats++)
@@ -1104,5 +1262,4 @@
     switch ((*it_au)->m_nalUnitType)
     {
-#if NAL_UNIT_TYPES_J1003_D7
     case NAL_UNIT_CODED_SLICE_TRAIL_R:
     case NAL_UNIT_CODED_SLICE_TRAIL_N:
@@ -1117,16 +1274,8 @@
     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_RASL_N:
     case NAL_UNIT_CODED_SLICE_TFD:
-#else
-    case NAL_UNIT_CODED_SLICE:
-    case NAL_UNIT_CODED_SLICE_TFD:
-    case NAL_UNIT_CODED_SLICE_TLA:
-    case NAL_UNIT_CODED_SLICE_CRA:
-    case NAL_UNIT_CODED_SLICE_CRANT:
-    case NAL_UNIT_CODED_SLICE_BLA:
-    case NAL_UNIT_CODED_SLICE_BLANT:
-    case NAL_UNIT_CODED_SLICE_IDR:
-#endif
     case NAL_UNIT_VPS:
     case NAL_UNIT_SPS:
@@ -1145,7 +1294,7 @@
 {
 #if SVC_EXTENSION
-  double time = (double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate();
+  Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate();
 #else
-  double time = (double) m_iFrameRcvd / m_iFrameRate;
+  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
 #endif
   printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
Index: trunk/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 55)
+++ trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -73,9 +73,9 @@
   TComList<TComPicYuv*>      m_cListPicYuvRec;              ///< list of reconstruction YUV files
 #endif
-
+  
   Int                        m_iFrameRcvd;                  ///< number of received frames
   
-  unsigned m_essentialBytes;
-  unsigned m_totalBytes;
+  UInt m_essentialBytes;
+  UInt m_totalBytes;
 protected:
   // initialization
@@ -103,5 +103,5 @@
   Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file
 #endif
-  void rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& stats);
+  void rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& stats);
   void printRateSummary();
   
@@ -116,7 +116,4 @@
   TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
 #endif
-
-
-
 };// END CLASS DEFINITION TAppEncTop
 
Index: trunk/source/App/TAppEncoder/encmain.cpp
===================================================================
--- trunk/source/App/TAppEncoder/encmain.cpp	(revision 55)
+++ trunk/source/App/TAppEncoder/encmain.cpp	(revision 125)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -37,5 +37,10 @@
 
 #include <time.h>
+#include <iostream>
 #include "TAppEncTop.h"
+#include "TAppCommon/program_options_lite.h"
+
+using namespace std;
+namespace po = df::program_options_lite;
 
 //! \ingroup TAppEncoder
@@ -62,7 +67,15 @@
 
   // parse configuration
-  if(!cTAppEncTop.parseCfg( argc, argv ))
+  try
   {
-    cTAppEncTop.destroy();
+    if(!cTAppEncTop.parseCfg( argc, argv ))
+    {
+      cTAppEncTop.destroy();
+      return 1;
+    }
+  }
+  catch (po::ParseFailure& e)
+  {
+    cerr << "Error parsing option \""<< e.arg <<"\" with argument \""<< e.val <<"\"." << endl;
     return 1;
   }
Index: trunk/source/App/utils/BitrateTargeting/ExtractBitrates.cpp
===================================================================
--- trunk/source/App/utils/BitrateTargeting/ExtractBitrates.cpp	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/ExtractBitrates.cpp	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/ExtractBitrates.h
===================================================================
--- trunk/source/App/utils/BitrateTargeting/ExtractBitrates.h	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/ExtractBitrates.h	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/ExtractBitratesMain.cpp
===================================================================
--- trunk/source/App/utils/BitrateTargeting/ExtractBitratesMain.cpp	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/ExtractBitratesMain.cpp	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.cpp
===================================================================
--- trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.cpp	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.cpp	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.h
===================================================================
--- trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.h	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiers.h	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiersMain.cpp
===================================================================
--- trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiersMain.cpp	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/GuessLambdaModifiersMain.cpp	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/RuntimeError.h
===================================================================
--- trunk/source/App/utils/BitrateTargeting/RuntimeError.h	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/RuntimeError.h	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/encode.shl
===================================================================
--- trunk/source/App/utils/BitrateTargeting/encode.shl	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/encode.shl	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/encodeCommand.sh
===================================================================
--- trunk/source/App/utils/BitrateTargeting/encodeCommand.sh	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/encodeCommand.sh	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/makefile
===================================================================
--- trunk/source/App/utils/BitrateTargeting/makefile	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/makefile	(revision 125)
Index: trunk/source/App/utils/BitrateTargeting/targetBitrates.sh
===================================================================
--- trunk/source/App/utils/BitrateTargeting/targetBitrates.sh	(revision 55)
+++ trunk/source/App/utils/BitrateTargeting/targetBitrates.sh	(revision 125)
Index: trunk/source/App/utils/annexBbytecount.cpp
===================================================================
--- trunk/source/App/utils/annexBbytecount.cpp	(revision 55)
+++ trunk/source/App/utils/annexBbytecount.cpp	(revision 125)
Index: trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp
===================================================================
--- trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp	(revision 55)
+++ trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp	(revision 125)
@@ -76,6 +76,6 @@
   TVideoIOYuv output;
 
-  input.open((char*)filename_in.c_str(), false, bitdepth_in, bitdepth_out);
-  output.open((char*)filename_out.c_str(), true, bitdepth_out, bitdepth_out);
+  input.open((char*)filename_in.c_str(), false, bitdepth_in, bitdepth_in, bitdepth_out, bitdepth_out);
+  output.open((char*)filename_out.c_str(), true, bitdepth_out, bitdepth_out, bitdepth_out, bitdepth_out);
 
   input.skipFrames(num_frames_skip, width, height);
