Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 443)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 608)
@@ -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,6 +42,11 @@
 #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"
 #ifdef WIN32
 #define strdup _strdup
@@ -53,17 +58,4 @@
 //! \ingroup TAppEncoder
 //! \{
-
-/* configuration helper funcs */
-void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg);
-void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg);
-
-// ====================================================================================================================
-// Local constants
-// ====================================================================================================================
-
-/// max value of source padding size
-/** \todo replace it by command line option
- */
-#define MAX_PAD_SIZE                16
 
 // ====================================================================================================================
@@ -72,21 +64,35 @@
 
 TAppEncCfg::TAppEncCfg()
+#if H_MV
+: m_pchBitstreamFile()
+#else
+: m_pchInputFile()
+, m_pchBitstreamFile()
+, m_pchReconFile()
+#endif
+, m_pchdQPFile()
+, m_pColumnWidth()
+, m_pRowHeight()
+, m_scalingListFile()
 {
+#if !H_MV
   m_aidQP = NULL;
-  m_aidQPdepth = NULL;
+#endif
+  m_startOfCodedInterval = NULL;
+  m_codedPivotValue = NULL;
+  m_targetPivotValue = NULL;
 }
 
 TAppEncCfg::~TAppEncCfg()
 {
-  if ( m_aidQP )
-  {
-    delete[] m_aidQP; m_aidQP = NULL;
-  }
-
-  if ( m_aidQPdepth )
-  {
-    delete[] m_aidQPdepth; m_aidQPdepth = NULL;
-  }
-
+#if H_MV
+  for( Int layer = 0; layer < m_aidQP.size(); layer++ )
+  {
+    if ( m_aidQP[layer] != NULL )
+    {
+      delete[] m_aidQP[layer];
+      m_aidQP[layer] = NULL;
+    }
+  }
   for(Int i = 0; i< m_pchInputFileList.size(); i++ )
   {
@@ -94,9 +100,30 @@
       free (m_pchInputFileList[i]);
   }
-  for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ )
-  {
-    if ( m_pchDepthInputFileList[i] != NULL )
-      free (m_pchDepthInputFileList[i]);
-  }
+#else
+  if ( m_aidQP )
+  {
+    delete[] m_aidQP;
+  }
+#endif
+  if ( m_startOfCodedInterval )
+  {
+    delete[] m_startOfCodedInterval;
+    m_startOfCodedInterval = NULL;
+  }
+   if ( m_codedPivotValue )
+  {
+    delete[] m_codedPivotValue;
+    m_codedPivotValue = NULL;
+  }
+  if ( m_targetPivotValue )
+  {
+    delete[] m_targetPivotValue;
+    m_targetPivotValue = NULL;
+  }
+#if !H_MV
+  free(m_pchInputFile);
+#endif
+  free(m_pchBitstreamFile);
+#if H_MV
   for(Int i = 0; i< m_pchReconFileList.size(); i++ )
   {
@@ -104,41 +131,32 @@
       free (m_pchReconFileList[i]);
   }
-  for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ )
-  {
-    if ( m_pchDepthReconFileList[i] != NULL )
-      free (m_pchDepthReconFileList[i]);
-  }
-  if (m_pchBitstreamFile != NULL)
-    free (m_pchBitstreamFile) ;
-#if FLEX_CODING_ORDER_M23723
-  if (m_pchMVCJointCodingOrder != NULL)
-  {
-    free(m_pchMVCJointCodingOrder) ;
-  }
-#endif
-#if HHI_VSO
+#else
+  free(m_pchReconFile);
+#endif
+  free(m_pchdQPFile);
+  free(m_pColumnWidth);
+  free(m_pRowHeight);
+  free(m_scalingListFile);
+#if H_MV
+  for( Int i = 0; i < m_GOPListMvc.size(); i++ )
+  {
+    if( m_GOPListMvc[i] )
+    {
+      delete[] m_GOPListMvc[i];
+      m_GOPListMvc[i] = NULL;
+    }
+  }
+#endif
+#if H_3D
+#if H_3D_VSO
   if (  m_pchVSOConfig != NULL)
     free (  m_pchVSOConfig );
 #endif
-
- if ( m_pchCameraParameterFile != NULL )
-   free ( m_pchCameraParameterFile ); 
-
- if ( m_pchBaseViewCameraNumbers != NULL )
-   free ( m_pchBaseViewCameraNumbers ); 
-
- if ( m_pchdQPFile      != NULL ) 
-   free ( m_pchdQPFile      );
-
- if ( m_pchColumnWidth  != NULL ) 
-   free ( m_pchColumnWidth  );
-
- if ( m_pchRowHeight    != NULL ) 
-   free ( m_pchRowHeight    );
-
- if ( m_scalingListFile != NULL ) 
-   free ( m_scalingListFile );
-
-
+  if ( m_pchCameraParameterFile != NULL )
+    free ( m_pchCameraParameterFile ); 
+
+  if ( m_pchBaseViewCameraNumbers != NULL )
+    free ( m_pchBaseViewCameraNumbers ); 
+#endif
 }
 
@@ -151,5 +169,5 @@
 }
 
-std::istringstream &operator>>( std::istringstream &in, GOPEntryMvc &entry )     //input
+std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry)     //input
 {
   in>>entry.m_sliceType;
@@ -157,7 +175,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;
-  in>>entry.m_refPic;
   in>>entry.m_numRefPics;
   for ( Int i = 0; i < entry.m_numRefPics; i++ )
@@ -166,7 +185,7 @@
   }
   in>>entry.m_interRPSPrediction;
-  if (entry.m_interRPSPrediction)
-  {
-    in>>entry.m_deltaRIdxMinus1;
+#if AUTO_INTER_RPS
+  if (entry.m_interRPSPrediction==1)
+  {
     in>>entry.m_deltaRPS;
     in>>entry.m_numRefIdc;
@@ -176,18 +195,119 @@
     }
   }
-  in>>entry.m_numInterViewRefPics;
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
-  {
-    in>>entry.m_interViewRefs[i];
-  }
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
-  {
-    in>>entry.m_interViewRefPosL0[i];
-  }
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
-  {
-    in>>entry.m_interViewRefPosL1[i];
-  }
+  else if (entry.m_interRPSPrediction==2)
+  {
+    in>>entry.m_deltaRPS;
+  }
+#else
+  if (entry.m_interRPSPrediction)
+  {
+    in>>entry.m_deltaRPS;
+    in>>entry.m_numRefIdc;
+    for ( Int i = 0; i < entry.m_numRefIdc; i++ )
+    {
+      in>>entry.m_refIdc[i];
+    }
+  }
+#endif
+#if H_MV
+  in>>entry.m_numActiveRefLayerPics;
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
+  {
+    in>>entry.m_interLayerPredLayerIdc[i];
+  }
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
+  {
+    in>>entry.m_interViewRefPosL[0][i];
+  }
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
+  {
+    in>>entry.m_interViewRefPosL[1][i];
+  }
+  if (entry.m_numActiveRefLayerPics > 0 )
+  {
+    in>>entry.m_collocatedRefLayerIdx; 
+  }
+#endif
   return in;
+}
+
+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},
+#if H_MV
+  {"main-stereo",    Profile::MAINSTEREO},
+  {"main-multiview", Profile::MAINMULTIVIEW},
+#if H_3D
+  {"main-3d"    , Profile::MAIN3D},
+#endif
+#endif
+};
+
+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);
 }
 
@@ -202,16 +322,29 @@
 Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] )
 {
-  bool do_help = false;
-  
+  Bool do_help = false;
+  
+#if !H_MV
+  string cfg_InputFile;
+#endif
   string cfg_BitstreamFile;
+#if !H_MV
+  string cfg_ReconFile;
+#endif
+#if H_MV
+  vector<Int>   cfg_dimensionLength; 
+#if H_3D 
+  cfg_dimensionLength.push_back( 2  );  // depth
+  cfg_dimensionLength.push_back( 32 );  // texture 
+#else
+  cfg_dimensionLength.push_back( 64 ); 
+#endif 
+#endif
   string cfg_dQPFile;
   string cfg_ColumnWidth;
   string cfg_RowHeight;
   string cfg_ScalingListFile;
-
- #if FLEX_CODING_ORDER_M23723
-  string cfg_JointCodingOrdering;
-#endif
-
+  string cfg_startOfCodedInterval;
+  string cfg_codedPivotValue;
+  string cfg_targetPivotValue;
   po::Options opts;
   opts.addOptions()
@@ -219,275 +352,381 @@
   ("c", po::parseConfigFile, "configuration file name")
   
-  /* File, I/O and source parameters */
-  ("InputFile_%d,i_%d",       m_pchInputFileList,       (char *) 0 , MAX_VIEW_NUM ,   "original Yuv input file name %d")
-  ("DepthInputFile_%d,di_%d", m_pchDepthInputFileList,  (char *) 0 , MAX_VIEW_NUM ,   "original Yuv depth input file name %d")
-  ("ReconFile_%d,o_%d",       m_pchReconFileList,       (char *) 0 , MAX_VIEW_NUM ,   "reconstructed Yuv output file name %d")
-  ("DepthReconFile_%d,do_%d", m_pchDepthReconFileList,  (char *) 0 , MAX_VIEW_NUM ,   "reconstructed Yuv depth output file name %d")
-  ("BitstreamFile,b",         cfg_BitstreamFile,        string(""),                   "bitstream output file name")
-  ("CodeDepthMaps",           m_bUsingDepthMaps,        false,                        "Encode depth maps" )
-  ("CodedCamParsPrecision",   m_iCodedCamParPrecision,  STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" )
-  ("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")
-  ("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")
-  ("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)")
-  ("FrameRate,-fr",         m_iFrameRate,        0, "Frame rate")
-  ("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)")
-  ("FrameToBeEncoded",      m_iFrameToBeEncoded, 0, "deprecated alias of FramesToBeEncoded")
-  
-  ("NumberOfViews",         m_iNumberOfViews,    0, "Number of views")
-#if FLEX_CODING_ORDER_M23723
-  ("FCO",               m_b3DVFlexOrder,   false, "flexible coding order flag" )
-  ("FCOCodingOrder",   cfg_JointCodingOrdering,  string(""), "The coding order for joint texture-depth coding")
-#endif
-  /* Unit definition parameters */
-  ("MaxCUWidth",          m_uiMaxCUWidth,  64u)
-  ("MaxCUHeight",         m_uiMaxCUHeight, 64u)
-  /* todo: remove defaults from MaxCUSize */
-  ("MaxCUSize,s",         m_uiMaxCUWidth,  64u, "max CU size")
-  ("MaxCUSize,s",         m_uiMaxCUHeight, 64u, "max CU size")
-  ("MaxPartitionDepth,h", m_uiMaxCUDepth,   4u, "CU depth")
-  
-  ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u)
-  ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u)
-  
-  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u)
-  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u)
-  
-  /* Coding structure paramters */
-  ("IntraPeriod,-ip",m_iIntraPeriod, -1, "intra period in frames, (-1: only first frame)")
-  ("DecodingRefreshType,-dr",m_iDecodingRefreshType, 0, "intra refresh, (0:none 1:CRA 2:IDR)")
-  ("GOPSize,g",      m_iGOPSize,      1, "GOP size of temporal structure")
-  ("ListCombination,-lc", m_bUseLComb, true, "combined reference list flag for uni-prediction in B-slices")
-  ("LCModification", m_bLCMod, false, "enables signalling of combined reference list derivation")
-  ("DisableInter4x4", m_bDisInter4x4, true, "Disable Inter 4x4")
-  ("NSQT", m_enableNSQT, true, "Enable non-square transforms")
-  ("AMP", m_enableAMP, true, "Enable asymmetric motion partitions")
-  /* motion options */
-  ("FastSearch", m_iFastSearch, 1, "0:Full search  1:Diamond  2:PMVFAST")
-  ("SearchRange,-sr",m_iSearchRange, 96, "motion search range")
-#if DV_V_RESTRICTION_B0037
-  ("DisparitySearchRangeRestriction",m_bUseDisparitySearchRangeRestriction, false, "restrict disparity search range")
-  ("VerticalDisparitySearchRange",m_iVerticalDisparitySearchRange, 56, "vertical disparity search range")
-#endif
-  ("BipredSearchRange", m_bipredSearchRange, 4, "motion search range for bipred refinement")
-  ("HadamardME", m_bUseHADME, true, "hadamard ME for fractional-pel")
-  ("ASR", m_bUseASR, false, "adaptive motion search range")
-  
+  // File, I/O and source parameters
+#if H_MV
+  ("InputFile_%d,i_%d",       m_pchInputFileList,       (char *) 0 , MAX_NUM_LAYER_IDS , "original Yuv input file name %d")
+#else
+  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
+#endif
+  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
+#if H_MV
+  ("ReconFile_%d,o_%d",       m_pchReconFileList,       (char *) 0 , MAX_NUM_LAYER_IDS , "reconstructed Yuv output file name %d")
+#else
+  ("ReconFile,o",           cfg_ReconFile,     string(""), "Reconstructed YUV output file name")
+#endif
+#if H_MV
+  ("NumberOfLayers",        m_numberOfLayers     , 1,                     "Number of layers")
+#if !H_3D
+  ("ScalabilityMask",       m_scalabilityMask    , 1                    , "Scalability Mask")    
+#else
+  ("ScalabilityMask",       m_scalabilityMask    , 3                    , "Scalability Mask, 1: Texture 3: Texture + Depth ")    
+#endif  
+  ("DimensionIdLen",        m_dimensionIdLen     , cfg_dimensionLength  , "Number of bits used to store dimensions Id")
+  ("ViewId",                m_viewId             , std::vector<Int>(1,0), "View Id")
+#if H_3D
+  ("DepthFlag",             m_depthFlag          , std::vector<Int>(1,0), "Depth Flag")
+#if H_3D_DIM
+  ("DMM",                   m_useDMM,           true,  "Depth intra model modes")
+  ("RBC",                   m_useRBC,           true,  "Region boundary chain mode")
+  ("SDC",                   m_useSDC,           true,  "Simplified depth coding")
+  ("DLT",                   m_useDLT,           true,  "Depth lookup table")
+#endif
+#endif
+  ("LayerIdInNuh",          m_layerIdInNuh       , std::vector<Int>(1,0), "LayerId in Nuh")
+  ("SplittingFlag",         m_splittingFlag      , false                , "Splitting Flag")    
+
+  // Layer Sets + Output Layer Sets + Profile Tier Level
+  ("VpsNumLayerSets",       m_vpsNumLayerSets    , 1                    , "Number of layer sets")    
+  ("LayerIdsInSet_%d",      m_layerIdsInSets     , std::vector<Int>(1,0), MAX_VPS_OP_SETS_PLUS1 ,"LayerIds of Layer set")  
+  ("DefaultOneTargetOutputLayerFlag", m_defaultOneTargetOutputLayerFlag,  false , "Output highest layer of layer sets by default")      
+  ("OutputLayerSetIdx",     m_outputLayerSetIdx  , std::vector<Int>(0,0), "Indices of layer sets used as additional output layer sets")  
+  ("LayerIdsInAddOutputLayerSet_%d", m_layerIdsInAddOutputLayerSet      , std::vector<Int>(1,0), MAX_VPS_ADD_OUTPUT_LAYER_SETS, "LayerIds of additional output layers")  
+  ("ProfileLevelTierIdx",   m_profileLevelTierIdx, std::vector<Int>(1,0), "Indices to profile level tier")
+  
+  // Layer dependencies
+  ("DirectRefLayers_%d",    m_directRefLayers    , std::vector<Int>(0,0), MAX_NUM_LAYERS, "LayerIds of direct reference layers")
+  ("DependencyTypes_%d",    m_dependencyTypes    , std::vector<Int>(0,0), MAX_NUM_LAYERS, "Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion")
+#endif
+  ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
+  ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
+  ("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")
+  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
+  ("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")
+
+  ("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")
+  
+  // Unit definition parameters
+  ("MaxCUWidth",              m_uiMaxCUWidth,             64u)
+  ("MaxCUHeight",             m_uiMaxCUHeight,            64u)
+  // todo: remove defaults from MaxCUSize
+  ("MaxCUSize,s",             m_uiMaxCUWidth,             64u, "Maximum CU size")
+  ("MaxCUSize,s",             m_uiMaxCUHeight,            64u, "Maximum CU size")
+  ("MaxPartitionDepth,h",     m_uiMaxCUDepth,              4u, "CU depth")
+  
+  ("QuadtreeTULog2MaxSize",   m_uiQuadtreeTULog2MaxSize,   6u, "Maximum TU size in logarithm base 2")
+  ("QuadtreeTULog2MinSize",   m_uiQuadtreeTULog2MinSize,   2u, "Minimum TU size in logarithm base 2")
+  
+  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs")
+  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
+  
+  // Coding structure paramters
+  ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
+  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
+  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
+  // motion options
+  ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
+  ("SearchRange,-sr",         m_iSearchRange,              96, "Motion search range")
+  ("BipredSearchRange",       m_bipredSearchRange,          4, "Motion search range for bipred refinement")
+  ("HadamardME",              m_bUseHADME,               true, "Hadamard ME for fractional-pel")
+  ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
+
+  // 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")
+
   /* Quantization parameters */
-  ("QP,q",          m_adQP,     std::vector<double>(1,32), "Qp value, if value is float, QP is switched once during encoding, if two values are given the second is used for depth")
+#if H_MV
+  ("QP,q",          m_fQP, std::vector<double>(1,30.0), "Qp values for each layer, if value is float, QP is switched once during encoding")
+#else
+  ("QP,q",          m_fQP,             30.0, "Qp value, if value is float, QP is switched once during encoding")
+#endif
   ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
   ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
   ("MaxCuDQPDepth,-dqd",  m_iMaxCuDQPDepth,        0, "max depth for a minimum CuDQP")
 
-    ("ChromaQpOffset,   -cqo",   m_iChromaQpOffset,           0, "ChromaQpOffset")
-    ("ChromaQpOffset2nd,-cqo2",  m_iChromaQpOffset2nd,        0, "ChromaQpOffset2nd")
+  ("CbQpOffset,-cbqpofs",  m_cbQpOffset,        0, "Chroma Cb QP Offset")
+  ("CrQpOffset,-crqpofs",  m_crQpOffset,        0, "Chroma Cr QP Offset")
 
 #if ADAPTIVE_QP_SELECTION
-    ("AdaptiveQpSelection,-aqps",   m_bUseAdaptQpSelect,           false, "AdaptiveQpSelection")
-#endif
-
-  ("AdaptiveQP,-aq", m_bUseAdaptiveQP, false, "QP adaptation based on a psycho-visual model")
-  ("MaxQPAdaptationRange,-aqr", m_iQPAdaptationRange, 6, "QP adaptation range")
-  ("dQPFile,m",     cfg_dQPFile, string(""), "dQP file name")
-  ("RDOQ",          m_abUseRDOQ, std::vector<Bool>(1,true), "Enable RDOQ")
-  ("TemporalLayerQPOffset_L0,-tq0", m_aiTLayerQPOffset[0], MAX_QP + 1, "QP offset of temporal layer 0")
-  ("TemporalLayerQPOffset_L1,-tq1", m_aiTLayerQPOffset[1], MAX_QP + 1, "QP offset of temporal layer 1")
-  ("TemporalLayerQPOffset_L2,-tq2", m_aiTLayerQPOffset[2], MAX_QP + 1, "QP offset of temporal layer 2")
-  ("TemporalLayerQPOffset_L3,-tq3", m_aiTLayerQPOffset[3], MAX_QP + 1, "QP offset of temporal layer 3")
-  
-
-  /* Entropy coding parameters */
-  ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation")
-  
-  /* Deblocking filter parameters */
-  ("LoopFilterDisable", m_abLoopFilterDisable, std::vector<Bool>(1,false), "Disables LoopFilter")
-
-  ("LoopFilterOffsetInAPS", m_loopFilterOffsetInAPS, false)
-  ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2, 0 )
-  ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2, 0 )
-#if LGE_ILLUCOMP_B0045
-#if LGE_ILLUCOMP_DEPTH_C0046
-  ("IlluCompEnable", m_abUseIC, std::vector<Bool>(2, true), "Enable illumination compensation for inter-view prediction")
-#else
-  ("IlluCompEnable",                  m_bUseIC                  , true         , "Use illumination compensation for inter-view prediction" )
-#endif
-#endif
-#if INTER_VIEW_VECTOR_SCALING_C0115
-  ("IVSEnable",                       m_bUseIVS                 , true         , "Use inter-view vector scaling" )
-#endif
-  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, true)
-
-  /* Camera Paremetes */
+  ("AdaptiveQpSelection,-aqps",   m_bUseAdaptQpSelect,           false, "AdaptiveQpSelection")
+#endif
+
+  ("AdaptiveQP,-aq",                m_bUseAdaptiveQP,           false, "QP adaptation based on a psycho-visual model")
+  ("MaxQPAdaptationRange,-aqr",     m_iQPAdaptationRange,           6, "QP adaptation range")
+  ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
+  ("RDOQ",                          m_useRDOQ,                  true )
+  ("RDOQTS",                        m_useRDOQTS,                true )
+  ("RDpenalty",                     m_rdPenalty,                0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
+  // Entropy coding parameters
+  ("SBACRD",                         m_bUseSBACRD,                      true, "SBAC based RD estimation")
+  
+  // Deblocking filter parameters
+#if H_MV
+  ("LoopFilterDisable",              m_bLoopFilterDisable,             std::vector<Bool>(1,false), "Disable Loop Filter per Layer" )
+#else
+  ("LoopFilterDisable",              m_bLoopFilterDisable,             false )
+#endif
+  ("LoopFilterOffsetInPPS",          m_loopFilterOffsetInPPS,          false )
+  ("LoopFilterBetaOffset_div2",      m_loopFilterBetaOffsetDiv2,           0 )
+  ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0 )
+  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false )
+  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
+
+#if H_3D_ARP
+  ("AdvMultiviewResPred",      m_uiUseAdvResPred,           (UInt)1, "Usage of Advanced Residual Prediction" )
+#endif
+#if H_3D_IC
+  ("IlluCompEnable",           m_abUseIC, std::vector<Bool>(2, true), "Enable illumination compensation")
+#endif
+#if LGE_INTER_SDC_E0156
+  ("InterSDC",                 m_bDepthInterSDCFlag,        true, "Enable depth inter SDC")
+#endif
+  // Coding tools
+  ("AMP",                      m_enableAMP,                 true,  "Enable asymmetric motion partitions")
+  ("TransformSkip",            m_useTransformSkip,          false, "Intra transform skipping")
+  ("TransformSkipFast",        m_useTransformSkipFast,      false, "Fast intra transform skipping")
+#if H_MV
+  ("SAO",                      m_bUseSAO, std::vector<Bool>(1,true), "Enable Sample Adaptive Offset per Layer")
+#else
+  ("SAO",                      m_bUseSAO,                   true,  "Enable Sample Adaptive Offset")
+#endif
+  ("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. */
+  ("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")
+  ("ECU", m_bUseEarlyCU, false, "Early CU setting") 
+  ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") 
+  ("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" )
+#if M0036_RC_IMPROVEMENT
+  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit,     0, "Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation" )
+#else
+  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, false, "Rate control: keep hierarchical bit allocation in rate control algorithm" )
+#endif
+  ( "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")
+  ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
+  ("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")
+  ("AspectRatioIdc",                 m_aspectRatioIdc,                         0, "aspect_ratio_idc")
+  ("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 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")
+  ("VideoFullRange",                 m_videoFullRangeFlag,                 false, "Indicates the black level and range of luma and chroma signals")
+  ("ColourDescriptionPresent",       m_colourDescriptionPresentFlag,       false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
+  ("ColourPrimaries",                m_colourPrimaries,                        2, "Indicates chromaticity coordinates of the source primaries")
+  ("TransferCharateristics",         m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
+  ("MatrixCoefficients",             m_matrixCoefficients,                     2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
+  ("ChromaLocInfoPresent",           m_chromaLocInfoPresentFlag,           false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
+  ("ChromaSampleLocTypeTopField",    m_chromaSampleLocTypeTopField,            0, "Specifies the location of chroma samples for top field")
+  ("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")
+  ("MotionVectorsOverPicBoundaries", m_motionVectorsOverPicBoundariesFlag, false, "Indicates that no samples outside the picture boundaries are used for inter prediction")
+  ("MaxBytesPerPicDenom",            m_maxBytesPerPicDenom,                    2, "Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture")
+  ("MaxBitsPerMinCuDenom",           m_maxBitsPerMinCuDenom,                   1, "Indicates an upper bound for the number of bits of coding_unit() data")
+  ("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")
+  ("SEIRecoveryPoint",               m_recoveryPointSEIEnabled,                0, "Control generation of recovery point SEI messages")
+  ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
+  ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
+  ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false, "Control generation of Tone Mapping SEI messages")
+  ("SEIToneMapId",                             m_toneMapId,                        0, "Specifies Id of Tone Mapping SEI message for a given session")
+  ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false, "Indicates that Tone Mapping SEI message cancels the persistance or follows")
+  ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true, "Specifies the persistence of the Tone Mapping SEI message")
+  ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
+  ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8, "Specifies Output BitDepth of Tome mapping function")
+  ("SEIToneMapModelId",                        m_toneMapModelId,                   0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
+                                                                                      "\t0:  linear mapping with clipping\n"
+                                                                                      "\t1:  sigmoidal mapping\n"
+                                                                                      "\t2:  user-defined table mapping\n"
+                                                                                      "\t3:  piece-wise linear mapping\n"
+                                                                                      "\t4:  luminance dynamic range information ")
+  ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0, "Specifies the minimum value in mode 0")
+  ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023, "Specifies the maxmum value in mode 0")
+  ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512, "Specifies the centre point in mode 1")
+  ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
+  ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""), "Array of user-defined mapping table")
+  ("SEIToneMapNumPivots",                             m_numPivots,                                0, "Specifies the number of pivot points in mode 3")
+  ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
+  ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
+  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0, "Indicates the camera ISO speed for daylight illumination")
+  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
+  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0, "Specifies the sign of ExposureCompensationValue")
+  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0, "Specifies the numerator of ExposureCompensationValue")
+  ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2, "Specifies the denominator of ExposureCompensationValue")
+  ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350, "Specifies reference screen brightness setting in units of candela per square metre")
+  ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800, "Indicates the luminance dynamic range")
+  ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16, "Specifies luma sample value of the nominal black level assigned decoded pictures")
+  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
+  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
+  ("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.")
+  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
+  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
+#if H_3D
   ("CameraParameterFile,cpf", m_pchCameraParameterFile,    (Char *) 0, "Camera Parameter File Name")
-#if QC_MVHEVC_B0046
-  ("BaseViewCameraNumbers" ,  m_aiVId,     std::vector<Int>(1, MAX_VIEW_NUM), "Numbers of base views")
-#endif
   ("BaseViewCameraNumbers" ,  m_pchBaseViewCameraNumbers,  (Char *) 0, "Numbers of base views")
-
-  /* View Synthesis Optimization */
-
-#if HHI_VSO
+  ("CodedCamParsPrecision",   m_iCodedCamParPrecision,  STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" )
+/* View Synthesis Optimization */
+
+#if H_3D_VSO
   ("VSOConfig",                       m_pchVSOConfig            , (Char *) 0    , "VSO configuration")
   ("VSO",                             m_bUseVSO                 , false         , "Use VSO" )    
   ("VSOMode",                         m_uiVSOMode               , (UInt)   4    , "VSO Mode")
   ("LambdaScaleVSO",                  m_dLambdaScaleVSO         , (Double) 1    , "Lambda Scaling for VSO")
-
-#if HHI_VSO_LS_TABLE_M23714
-  ("VSOLSTable",                      m_bVSOLSTable             , true          , "Depth QP dependent video/depth rate allocation by Lagrange multiplier" )    
-#endif
-
-#if SAIT_VSO_EST_A0033
+  ("VSOLSTable",                      m_bVSOLSTable             , true          , "Depth QP dependent video/depth rate allocation by Lagrange multiplier" )      
+  ("ForceLambdaScaleVSO",             m_bForceLambdaScaleVSO    , false         , "Force using Lambda Scale VSO also in non-VSO-Mode")
+  ("AllowNegDist",                    m_bAllowNegDist           , true          , "Allow negative Distortion in VSO")
+  
   ("UseEstimatedVSD",                 m_bUseEstimatedVSD        , true          , "Model based VSD estimation instead of rendering based for some encoder decisions" )      
-#endif
-#if LGE_VSO_EARLY_SKIP_A0093
   ("VSOEarlySkip",                    m_bVSOEarlySkip           , true          , "Early skip of VSO computation if synthesis error assumed to be zero" )      
-#endif
-  ("ForceLambdaScaleVSO",             m_bForceLambdaScaleVSO    , false         , "Force using Lambda Scale VSO also in non-VSO-Mode")
-#if HHI_VSO_DIST_INT
-  ("AllowNegDist",                    m_bAllowNegDist           , true          , "Allow negative Distortion in VSO")
-#endif
-#if LGE_WVSO_A0119
+  
   ("WVSO",                            m_bUseWVSO                , true          , "Use depth fidelity term for VSO" )
   ("VSOWeight",                       m_iVSOWeight              , 10            , "Synthesized View Distortion Change weight" )
   ("VSDWeight",                       m_iVSDWeight              , 1             , "View Synthesis Distortion estimate weight" )
   ("DWeight",                         m_iDWeight                , 1             , "Depth Distortion weight" )
-#endif
-
-#if H3D_QTL
-  ("QTLPC",                           m_bUseQTLPC               , true         , "Use depth Quadtree Limitation + Predictive Coding" )
-#endif
-
-#endif
-
-#if DEPTH_MAP_GENERATION
-  ("PredDepthMapGen",  m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" )
-#endif
-#if H3D_IVMP
-  ("MultiviewMvPred",  m_uiMultiviewMvPredMode,    (UInt)0, "usage of predicted depth maps" )
-  ("MultiviewMvRegMode",        m_uiMultiviewMvRegMode,         (UInt)0, "regularization mode for multiview motion vectors" )
-  ("MultiviewMvRegLambdaScale", m_dMultiviewMvRegLambdaScale, (Double)0, "lambda scale for multiview motion vector regularization" )
-#endif
-#if H3D_IVRP
-#if QC_ARP_D0177
-  ("MultiviewResPred", m_nUseAdvResPred,           (UInt)0, "usage of Advanced residual prediction" )
-#else
-  ("MultiviewResPred", m_uiMultiviewResPredMode,   (UInt)0, "usage of inter-view residual prediction" )
-#endif
-#endif
-#if MTK_D0156
-  ("UseVSPCompensation", m_bUseVSPCompensation,   true, "Depth dependent tools: BVSP" )
-  ("UseDVPRefine", m_bUseDVPRefine,   true, "Depth dependent tools: DoNBDV" )
-#endif
-
-  /* Coding tools */
-  ("LMChroma", m_bUseLMChroma, true, "intra chroma prediction based on recontructed luma")
-
-  ("ALF", m_abUseALF, std::vector<Bool>(1,true), "Enables ALF")
-  ("SAO", m_abUseSAO, std::vector<Bool>(1, true), "SAO")
-  ("MaxNumOffsetsPerPic", m_maxNumOffsetsPerPic, 2048, "2048: default")   
-#if LGE_SAO_MIGRATION_D0091
-  ("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 ")
-#else
-  ("SAOInterleaving", m_saoInterleavingFlag, false, "0: SAO Picture Mode, 1: SAO Interleaving ")   
-#endif
-
-  ("ALFEncodePassReduction", m_iALFEncodePassReduction, 0, "0:Original 16-pass, 1: 1-pass, 2: 2-pass encoding")
-
-  ("ALFMaxNumFilter,-ALFMNF", m_iALFMaxNumberFilters, 16, "16: No Constrained, 1-15: Constrained max number of filter")
-  ("ALFParamInSlice", m_bALFParamInSlice, false, "ALF parameters in 0: APS, 1: slice header")
-  ("ALFPicBasedEncode", m_bALFPicBasedEncode, true, "ALF picture-based encoding 0: false, 1: true")
-
-    ("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.")
-    ("EntropySliceMode",     m_iEntropySliceMode,    0, "0: Disable all entropy slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based entropy slices")
-    ("EntropySliceArgument", m_iEntropySliceArgument,0, "if EntropySliceMode==1 SliceArgument represents max # of LCUs. if EntropySliceMode==2 EntropySliceArgument represents max # of bins.")
-    ("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.")
-    ("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)
-#if LOSSLESS_CODING
-    ("LosslessCuEnabled", m_useLossless, false)
-#endif
-    ("weighted_pred_flag,-wpP",     m_bUseWeightPred, false, "weighted prediction flag (P-Slices)")
-    ("weighted_bipred_idc,-wpBidc", m_uiBiPredIdc,    0u,    "weighted bipred idc (B-Slices)")
-    ("TileInfoPresentFlag",         m_iColumnRowInfoPresent,         1,          "0: tiles parameters are NOT present in the PPS. 1: tiles parameters are present in the PPS")
-    ("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")
-    ("TileLocationInSliceHeaderFlag", m_iTileLocationInSliceHeaderFlag, 0,       "0: Disable transmission of tile location in slice header. 1: Transmit tile locations in slice header.")
-    ("TileMarkerFlag",                m_iTileMarkerFlag,                0,       "0: Disable transmission of lightweight tile marker. 1: Transmit light weight tile marker.")
-    ("MaxTileMarkerEntryPoints",    m_iMaxTileMarkerEntryPoints,    4,       "Maximum number of uniformly-spaced tile entry points (using light weigh tile markers). Default=4. If number of tiles < MaxTileMarkerEntryPoints then all tiles have entry points.")
-    ("TileControlPresentFlag",       m_iTileBehaviorControlPresentFlag,         1,          "0: tiles behavior control parameters are NOT present in the PPS. 1: tiles behavior control parameters are present in the PPS")
-    ("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")
-    ("WaveFrontFlush",              m_iWaveFrontFlush,               0,          "Flush and terminate CABAC coding for each LCU line")
-    ("WaveFrontSubstreams",         m_iWaveFrontSubstreams,          1,          "# coded substreams wanted; per tile if TileBoundaryIndependenceIdc is 1, otherwise per frame")
-    ("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)
-    ("SignHideThreshold,-TSIG",          m_signHidingThreshold,         4)
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-  ("DMM",                         m_bUseDMM,                       false,      "depth model modes flag")
-#endif
-
-  /* Misc. */
-  ("SEIpictureDigest", m_pictureDigestEnabled, true, "Control generation of picture_digest SEI messages\n"
-                                              "\t1: use MD5\n"
-                                              "\t0: disable")
-
-#if TMVP_DEPTH_SWITCH
-  ("TMVP", m_enableTMVP, std::vector<Bool>(1,true), "Enable TMVP" )
-#else
-  ("TMVP", m_enableTMVP, true, "Enable TMVP" )
-#endif
-
-  ("FEN", m_bUseFastEnc, false, "fast encoder setting")
-  ("ECU", m_bUseEarlyCU, false, "Early CU setting") 
-  ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") 
-  ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
-#if HHI_INTERVIEW_SKIP
-  ("InterViewSkip",  m_bInterViewSkip,    false, "usage of interview skip" )
-#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
-  ("InterViewSkipLambdaScale",  m_dInterViewSkipLambdaScale,    (Double)8, "lambda scale for interview skip" )
-#endif
-#endif
-  /* Compatability with old style -1 FOO or -0 FOO options. */
-  ("1", doOldStyleCmdlineOn, "turn option <name> on")
-  ("0", doOldStyleCmdlineOff, "turn option <name> off")
-#if HHI_MPI
-  ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding")
-#endif
-#if RWTH_SDC_DLT_B0036
-  ("DLT", m_bUseDLT, true, "use depth lookup table for depth map coding")
-  ("SDC", m_bUseSDC, true, "use simplified depth coding tree")
-#endif
+
+#endif //HHI_VSO
+#if H_3D_QTLPC
+  ("QTL",                             m_bUseQTL                 , true          , "Use depth Quadtree Limitation" )
+  ("PC",                              m_bUsePC                  , true          , "Use Predictive Coding with QTL" )
+#endif
+#if H_3D_IV_MERGE
+  ("IvMvPred",                        m_ivMvPredFlag,           true            , "inter view motion prediction " )  
+#endif
+#if H_3D_NBDV_REF
+  ("DepthRefinement",                 m_depthRefinementFlag,    true           , "depth refinement by DoNBDV" )  
+#endif
+#if H_3D_VSP
+  ("ViewSynthesisPred",               m_viewSynthesisPredFlag,  true           , "view synthesis prediction " )  
+#endif
+#if H_3D_TMVP
+  ("IvMvScaling",                     m_ivMvScalingFlag      ,  true            , "inter view motion vector scaling" )    
+#endif
+#endif //H_3D
   ;
-  
+  #if H_MV
   // parse coding structure
-  for( Int k = 0; k < MAX_VIEW_NUM; k++ )
-  {
+  for( Int k = 0; k < MAX_NUM_LAYERS; k++ )
+  {
+    m_GOPListMvc.push_back( new GOPEntry[MAX_GOP + 1] );
     if( k == 0 )
     {
@@ -496,5 +735,9 @@
         std::ostringstream cOSS;
         cOSS<<"Frame"<<i;
-        opts.addOptions()( cOSS.str(), m_GOPListsMvc[k][i-1], GOPEntryMvc() );
+        opts.addOptions()( cOSS.str(), m_GOPListMvc[k][i-1], GOPEntry() );
+        if ( i != 1 )
+        {
+          opts.opt_list.back()->opt->opt_duplicate = true; 
+        }        
       }
     }
@@ -502,20 +745,36 @@
     {
       std::ostringstream cOSS1;
-      cOSS1<<"FrameI"<<"_v"<<k;
-      opts.addOptions()(cOSS1.str(), m_GOPListsMvc[k][MAX_GOP], GOPEntryMvc());
+      cOSS1<<"FrameI"<<"_l"<<k;
+
+      opts.addOptions()(cOSS1.str(), m_GOPListMvc[k][MAX_GOP], GOPEntry());
+      if ( k > 1 )
+      {
+        opts.opt_list.back()->opt->opt_duplicate = true; 
+      }        
+
 
       for( Int i = 1; i < MAX_GOP + 1; i++ ) 
       {
         std::ostringstream cOSS2;
-        cOSS2<<"Frame"<<i<<"_v"<<k;
-        opts.addOptions()(cOSS2.str(), m_GOPListsMvc[k][i-1], GOPEntryMvc());
-      }
-    }
-  }
-
+        cOSS2<<"Frame"<<i<<"_l"<<k;
+        opts.addOptions()(cOSS2.str(), m_GOPListMvc[k][i-1], GOPEntry());
+        if ( i != 1 || k > 0 )
+        {
+          opts.opt_list.back()->opt->opt_duplicate = true; 
+        }        
+      }
+    }
+  }
+#else
+  for(Int i=1; i<MAX_GOP+1; i++) {
+    std::ostringstream cOSS;
+    cOSS<<"Frame"<<i;
+    opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry());
+  }
+#endif
   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);
@@ -526,5 +785,4 @@
     /* argc == 1: no options have been specified */
     po::doHelp(cout, opts);
-    xPrintUsage();
     return false;
   }
@@ -534,81 +792,90 @@
    */
   /* convert std::string to c string for compatability */
+#if !H_MV
+  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
+#endif
   m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
+#if !H_MV
+  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
+#endif
   m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
-#if FLEX_CODING_ORDER_M23723
-  m_pchMVCJointCodingOrder= cfg_JointCodingOrdering.empty()?NULL:strdup(cfg_JointCodingOrdering.c_str());
-  // If flexible order is enabled and if depth comes before the texture for a view, disable VSO
-#if HHI_VSO && DISABLE_FCO_FOR_VSO
-  Bool depthComesFirst = false;
-  int iter = 0;
-  if ( m_b3DVFlexOrder )
-  {
-    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-    {
-      iter = 0; 
-      for ( Int ii=1; ii<12; ii+=2 )
-      {
-        Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
-        if ( iViewIdxCfg == iViewIdx )
-        {
-          iter ++; 
-          if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
-          {
-            if(iter == 1)
-           { 
-            depthComesFirst = true;
-            break;
-           }
-          }
-          else
-          {
-            assert(m_pchMVCJointCodingOrder[ii-1]=='T');
-          }
-        }
-      }
-    }
-  }
-  if (depthComesFirst)
-  {
-    m_bUseVSO = false;
-  }
-#endif
-#endif
-  m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
-  m_pchRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
+  
+  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 H_MV
+  free ( pColumnWidth );
+  free ( pRowHeight   ); 
+#endif
   m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
   
-  if ( m_bUsingDepthMaps )
-  {
-    for(Int i = 0; i < m_pchDepthReconFileList.size() ; i++)
-    {
-      if ((m_pchDepthInputFileList[i] != NULL) && (m_pchReconFileList[i] != NULL) && (i < m_iNumberOfViews) )
-      {
-        if (m_pchDepthReconFileList[i] == NULL )
-        {
-          xAppendToFileNameEnd( m_pchReconFileList[i], "_depth", m_pchDepthReconFileList[i] );
-        }
-      }
-      else
-      {
-        m_pchDepthReconFileList[i] = NULL;
-      }
-    };
-  }
-  if ( m_adQP.size() < 2 )
-  {
-    m_adQP.push_back( m_adQP[0] );
-  };
-  for (UInt uiK = 0; uiK < m_adQP.size(); uiK++)
-  {
-    m_aiQP.push_back( (Int)( m_adQP[uiK] ) );
-  }
-
-  switch (m_croppingMode)
+  /* 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; }
+
+  // TODO:ChromaFmt assumes 4:2:0 below
+  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;
@@ -620,11 +887,21 @@
       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;
+      }
+      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::getWinUnitY(CHROMA_420) != 0)
+      {
+        fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
+        exit(EXIT_FAILURE);
       }
       break;
@@ -635,18 +912,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;
@@ -656,35 +933,69 @@
   
   // allocate slice-based dQP values
-  m_aidQP = new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ];
-  m_aidQPdepth =  new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ];
-  ::memset( m_aidQP, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) );
-  ::memset( m_aidQPdepth, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) );
+#if H_MV
+  xResizeVector( m_viewId    ); 
+#if H_3D
+  xResizeVector( m_depthFlag ); 
+
+  std::vector<Int> uniqueViewIds; 
+  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
+  {    
+    Bool isIn = false; 
+    for ( Int i = 0 ; i < uniqueViewIds.size(); i++ )
+    {
+      isIn = isIn || ( m_viewId[ layer ] == uniqueViewIds[ i ] ); 
+    }
+    if ( !isIn ) 
+    {
+      uniqueViewIds.push_back( m_viewId[ layer ] ); 
+    } 
+  }
+  m_iNumberOfViews = (Int) uniqueViewIds.size(); 
+#endif
+
+  xResizeVector( m_fQP ); 
+
+  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
+  {
+    m_aidQP.push_back( new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ] );
+    ::memset( m_aidQP[layer], 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
+
+    // handling of floating-point QP values
+    // if QP is not integer, sequence is split into two sections having QP and QP+1
+    m_iQP.push_back((Int)( m_fQP[layer] ));
+    if ( m_iQP[layer] < m_fQP[layer] )
+    {
+      Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP[layer] - m_iQP[layer])*m_framesToBeEncoded + 0.5 );
+
+      iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
+      for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ )
+      {
+        m_aidQP[layer][i] = 1;
+      }
+    }
+  }
+
+  xResizeVector( m_bLoopFilterDisable ); 
+  xResizeVector( m_bUseSAO ); 
+
+#else
+  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
   // if QP is not integer, sequence is split into two sections having QP and QP+1
-  m_aiQP[0] = (Int)( m_adQP[0] );
-  if ( m_aiQP[0] < m_adQP[0] )
-  {
-    Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_adQP[0] - m_aiQP[0])*m_iFrameToBeEncoded + 0.5 );
+  m_iQP = (Int)( m_fQP );
+  if ( m_iQP < m_fQP )
+  {
+    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;
     }
   }
-
-  m_aiQP[1] = (Int)( m_adQP[1] );
-  if ( m_aiQP[1] < m_adQP[1] )
-  {
-    Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_adQP[1] - m_aiQP[1])*m_iFrameToBeEncoded + 0.5 );
-
-    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
-    for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ )
-    {
-      m_aidQPdepth[i] = 1;
-    }
-  }
-
+#endif
+  
   // reading external dQP description from file
   if ( m_pchdQPFile )
@@ -693,63 +1004,90 @@
     if ( fpt )
     {
+#if H_MV
+      for( Int layer = 0; layer < m_numberOfLayers; layer++ )
+      {
+#endif
       Int iValue;
       Int iPOC = 0;
-      while ( iPOC < m_iFrameToBeEncoded )
+      while ( iPOC < m_framesToBeEncoded )
       {
         if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
+#if H_MV
+        m_aidQP[layer][ iPOC ] = iValue;
+        iPOC++;
+      }
+#else
         m_aidQP[ iPOC ] = iValue;
         iPOC++;
+#endif
       }
       fclose(fpt);
     }
   }
-
-#if HHI_VSO
-  m_bUseVSO = m_bUseVSO && m_bUsingDepthMaps && (m_uiVSOMode != 0);
-#endif
-
-#if LGE_WVSO_A0119
-  m_bUseWVSO = m_bUseVSO && m_bUseWVSO && m_bUsingDepthMaps;
-#endif
-  xCleanUpVectors();
-
-
-#if TMVP_DEPTH_SWITCH
-  if ( m_enableTMVP.size() < 2)
-  {
-    m_enableTMVP.push_back( m_enableTMVP[0]  );
-  }
-#endif
- 
-
-#if HHI_VSO
-  if ( m_abUseALF .size() < 2)
-    m_abUseALF .push_back( m_bUseVSO ? false : m_abUseALF[0]  );
-
-  if ( m_abUseRDOQ.size() < 2)
-    m_abUseRDOQ.push_back( m_bUseVSO ? true : m_abUseRDOQ[0] );
-
-  if ( m_abLoopFilterDisable.size() < 2)
-    m_abLoopFilterDisable.push_back( m_bUseVSO ? true : m_abLoopFilterDisable[0]  );
-
-  if (m_abUseSAO.size() < 2)
-    m_abUseSAO.push_back            ( m_bUseVSO ? false : m_abUseSAO[0] );
-#else
-  if ( m_abUseALF .size() < 2)
-    m_abUseALF .push_back( m_abUseALF[0]  );
-
-  if ( m_abUseRDOQ.size() < 2)
-    m_abUseRDOQ.push_back( m_abUseRDOQ[0] );
-
-  if ( m_abLoopFilterDisable.size() < 2)
-    m_abLoopFilterDisable.push_back( m_abLoopFilterDisable[0]  );
-
-  if (m_abUseSAO.size() < 2)
-    m_abUseSAO.push_back            ( m_abUseSAO[0] );
-#endif
-
-#if HHI_VSO
-
-#if HHI_VSO_LS_TABLE_M23714
+  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
+
+  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
+  {
+    Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str());
+    Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str());
+    Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str());
+    if( m_toneMapModelId == 2 && pcStartOfCodedInterval )
+    {
+      char *startOfCodedInterval;
+      UInt num = 1u<< m_toneMapTargetBitDepth;
+      m_startOfCodedInterval = new Int[num];
+      ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num );
+      startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
+      int i = 0;
+      while( startOfCodedInterval && ( i < num ) )
+      {
+        m_startOfCodedInterval[i] = atoi( startOfCodedInterval );
+        startOfCodedInterval = strtok(NULL, " .");
+        i++;
+      }
+    } 
+    else
+    {
+      m_startOfCodedInterval = NULL;
+    }
+    if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) )
+    {
+      if( pcCodedPivotValue && pcTargetPivotValue )
+      {
+        char *codedPivotValue;
+        char *targetPivotValue;
+        m_codedPivotValue = new Int[m_numPivots];
+        m_targetPivotValue = new Int[m_numPivots];
+        ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) );
+        ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) );
+        codedPivotValue = strtok(pcCodedPivotValue, " .");
+        int i=0;
+        while(codedPivotValue&&i<m_numPivots)
+        {
+          m_codedPivotValue[i] = atoi( codedPivotValue );
+          codedPivotValue = strtok(NULL, " .");
+          i++;
+        }
+        i=0;
+        targetPivotValue = strtok(pcTargetPivotValue, " .");
+        while(targetPivotValue&&i<m_numPivots)
+        {
+          m_targetPivotValue[i]= atoi( targetPivotValue );
+          targetPivotValue = strtok(NULL, " .");
+          i++;
+        }
+      }
+    }
+    else
+    {
+      m_codedPivotValue = NULL;
+      m_targetPivotValue = NULL;
+    }
+  }
+#if H_3D
+  // set global varibles
+  xSetGlobal();
+#if H_3D_VSO
+// Table base optimization 
   // Q&D
   Double adLambdaScaleTable[] = 
@@ -761,25 +1099,29 @@
      0.753550, 0.800000  
   }; 
-  if ( m_bVSOLSTable )
-  {
-    AOT( (m_aiQP[1] < 0) || (m_aiQP[1] > 51));
-    m_dLambdaScaleVSO *= adLambdaScaleTable[m_aiQP[1]]; 
-  }
-#endif
-#endif
-
- // set global variables
-  xSetGlobal();
-
-  // read and check camera parameters
-#if HHI_VSO
+  if ( m_bUseVSO && m_bVSOLSTable )
+  {
+    Int firstDepthLayer = -1; 
+    for (Int layer = 0; layer < m_numberOfLayers; layer++ )
+    {
+      if ( m_depthFlag[ layer ])
+      {
+        firstDepthLayer = layer;
+        break; 
+      }
+    }
+    AOT( firstDepthLayer == -1 );
+    AOT( (m_iQP[firstDepthLayer] < 0) || (m_iQP[firstDepthLayer] > 51));
+    m_dLambdaScaleVSO *= adLambdaScaleTable[m_iQP[firstDepthLayer]]; 
+  }
+#endif
+#if H_3D_VSO
 if ( m_bUseVSO && m_uiVSOMode == 4)
 {
   m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig );
-  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
-                                      m_uiInputBitDepth,
+  m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
+                                      g_bitDepthY,
                                 (UInt)m_iCodedCamParPrecision,
                                       m_FrameSkip,
-                                (UInt)m_iFrameToBeEncoded,
+                                (UInt)m_framesToBeEncoded,
                                       m_pchCameraParameterFile,
                                       m_pchBaseViewCameraNumbers,
@@ -790,9 +1132,9 @@
 else if ( m_bUseVSO && m_uiVSOMode != 4 )
 {
-  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
-                                      m_uiInputBitDepth,
+  m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
+                                      g_bitDepthY,
                                 (UInt)m_iCodedCamParPrecision,
                                       m_FrameSkip,
-                                (UInt)m_iFrameToBeEncoded,
+                                (UInt)m_framesToBeEncoded,
                                       m_pchCameraParameterFile,
                                       m_pchBaseViewCameraNumbers,
@@ -803,9 +1145,9 @@
 else
 {
-  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
-    m_uiInputBitDepth,
-    (UInt)m_iCodedCamParPrecision,
+  m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
+    g_bitDepthY,
+    (UInt) m_iCodedCamParPrecision,
     m_FrameSkip,
-    (UInt)m_iFrameToBeEncoded,
+    (UInt) m_framesToBeEncoded,
     m_pchCameraParameterFile,
     m_pchBaseViewCameraNumbers,
@@ -815,10 +1157,9 @@
 }
 #else
-#if !QC_MVHEVC_B0046
-  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
-    m_uiInputBitDepth,
-    (UInt)m_iCodedCamParPrecision,
+  m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
+    g_bitDepthY,
+    (UInt) m_iCodedCamParPrecision,
     m_FrameSkip,
-    (UInt)m_iFrameToBeEncoded,
+    (UInt) m_framesToBeEncoded,
     m_pchCameraParameterFile,
     m_pchBaseViewCameraNumbers,
@@ -827,12 +1168,14 @@
     LOG2_DISP_PREC_LUT );
 #endif
-#endif
-
-
+  m_cCameraData.check( false, true );
+#endif
   // check validity of input parameters
   xCheckParameter();
-#if !QC_MVHEVC_B0046
-  m_cCameraData.check( false, true );
-#endif
+
+#if !H_3D
+  // set global varibles
+  xSetGlobal();
+#endif
+  
   // print-out parameters
   xPrintParameter();
@@ -840,45 +1183,201 @@
   return true;
 }
-
 // ====================================================================================================================
 // Private member functions
 // ====================================================================================================================
 
-Bool confirmPara(Bool bflag, const char* message);
+Bool confirmPara(Bool bflag, const Char* message);
 
 Void TAppEncCfg::xCheckParameter()
 {
-  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");
+  }
+  if( m_profile==Profile::NONE )
+  {
+    fprintf(stderr, "***************************************************************************\n");
+    fprintf(stderr, "** WARNING: For conforming bitstreams a valid Profile value must be set! **\n");
+    fprintf(stderr, "***************************************************************************\n");
+  }
+  if( m_level==Level::NONE )
+  {
+    fprintf(stderr, "***************************************************************************\n");
+    fprintf(stderr, "** WARNING: For conforming bitstreams a valid Level value must be set!   **\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" );
+  xConfirmPara( m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
+  xConfirmPara( m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
   xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
-  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" );
+#if H_MV
+  xConfirmPara( m_numberOfLayers > MAX_NUM_LAYER_IDS ,                                      "NumberOfLayers must be less than or equal to MAX_NUM_LAYER_IDS");
+
+
+  xConfirmPara( m_layerIdInNuh[0] != 0      , "LayerIdInNuh must be 0 for the first layer. ");
+  xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
+  
+#if H_3D
+  xConfirmPara( m_scalabilityMask != 1 && m_scalabilityMask != 3, "Scalability Mask must be equal to 1 or 3. ");
+#else
+  xConfirmPara( m_scalabilityMask != 1 , "Scalability Mask must be equal to 1. ");
+#endif
+ 
+  m_dimIds.push_back( m_viewId ); 
+  const Int viewDimPosition = 0; 
+#if H_3D
+  if ( m_scalabilityMask & ( 1 << DEPTH_ID ) )
+    m_dimIds.push_back( m_depthFlag ); 
+#endif
+
+  xConfirmPara(  m_dimensionIdLen.size() < m_dimIds.size(), "DimensionIdLen must be given for all dimensions. "   );   Int dimBitOffset[MAX_NUM_SCALABILITY_TYPES+1]; 
+
+  dimBitOffset[ 0 ] = 0; 
+  for (Int j = 1; j <= ((Int) m_dimIds.size() - m_splittingFlag ? 1 : 0); j++ )
+ {
+    dimBitOffset[ j ] = dimBitOffset[ j - 1 ] + m_dimensionIdLen[ j - 1]; 
+  }
+
+  if ( m_splittingFlag )
+  {
+    dimBitOffset[ (Int) m_dimIds.size() ] = 6; 
+  }
+  
+  for( Int j = 0; j < m_dimIds.size(); j++ )
+  {    
+    xConfirmPara( m_dimIds[j].size() < m_numberOfLayers,  "DimensionId must be given for all layers and all dimensions. ");   
+    xConfirmPara( ( j != viewDimPosition ) &&  (m_dimIds[j][0] != 0), "DimensionId of layer 0 must be 0. " );
+    xConfirmPara( m_dimensionIdLen[j] < 1 || m_dimensionIdLen[j] > 8, "DimensionIdLen must be greater than 0 and less than 9 in all dimensions. " ); 
+     
+
+   for( Int i = 1; i < m_numberOfLayers; i++ )
+   {     
+      xConfirmPara(  ( m_dimIds[j][i] < 0 ) || ( m_dimIds[j][i] > ( ( 1 << m_dimensionIdLen[j] ) - 1 ) )   , "DimensionId shall be in the range of 0 to 2^DimensionIdLen - 1. " );
+      if ( m_splittingFlag )
+      {
+        Int layerIdInNuh = (m_layerIdInNuh.size()!=1) ? m_layerIdInNuh[i] :  i; 
+        xConfirmPara( ( ( layerIdInNuh & ( (1 << dimBitOffset[ j + 1 ] ) - 1) ) >> dimBitOffset[ j ] )  != m_dimIds[j][ i ]  , "When Splitting Flag is equal to 1 dimension ids shall match values derived from layer ids. "); 
+      }
+   }
+ }
+
+ for( Int i = 0; i < m_numberOfLayers; i++ )
+ {
+   for( Int j = 0; j < i; j++ )
+   {     
+     Int numDiff  = 0; 
+     Int lastDiff = -1; 
+     for( Int dim = 0; dim < m_dimIds.size(); dim++ )
+     {
+       if ( m_dimIds[dim][i] != m_dimIds[dim][j] )
+       {
+         numDiff ++; 
+         lastDiff = dim; 
+       }
+     }
+
+     Bool allEqual = ( numDiff == 0 ); 
+
+     if ( allEqual ) 
+     {
+       printf( "\nError: Positions of Layers %d and %d are identical in scalability space\n", i, j);
+     }
+
+     xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
+
+     if ( numDiff  == 1 ) 
+     {
+       Bool inc = m_dimIds[ lastDiff ][ i ] > m_dimIds[ lastDiff ][ j ]; 
+       Bool shallBeButIsNotIncreasing = ( !inc && ( lastDiff != viewDimPosition ) ) ; 
+       if ( shallBeButIsNotIncreasing )
+       {       
+         printf( "\nError: Positions of Layers %d and %d is not increasing in dimension %d \n", i, j, lastDiff);        
+       }
+       xConfirmPara( shallBeButIsNotIncreasing && ( lastDiff != viewDimPosition ),  "DimensionIds shall be increasing within one dimension. " );
+     }
+   }
+ }
+
+  /// Layer sets
+  xConfirmPara( m_vpsNumLayerSets < 0 || m_vpsNumLayerSets > 1024, "VpsNumLayerSets must be greater than 0 and less than 1025") ; 
+  for( Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
+  {
+    if (lsIdx == 0)
+    {
+      xConfirmPara( m_layerIdsInSets[lsIdx].size() != 1 || m_layerIdsInSets[lsIdx][0] != 0 , "0-th layer shall only include layer 0. ");
+    }
+    for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++ )
+    {
+      xConfirmPara( m_layerIdsInSets[lsIdx][i] < 0 || m_layerIdsInSets[lsIdx].size() >= MAX_NUM_LAYER_IDS, "LayerIdsInSet must be greater than and less than 64" ); 
+    }
+  }
+
+  // Output layer sets
+  xConfirmPara( m_outputLayerSetIdx.size() > 1024, "The number of output layer set indices must be less than 1025.") ;
+  for (Int lsIdx = 0; lsIdx < m_outputLayerSetIdx.size(); lsIdx++)
+  {   
+    Int refLayerSetIdx = m_outputLayerSetIdx[ lsIdx ]; 
+    xConfirmPara(  refLayerSetIdx < 0 || refLayerSetIdx >= m_vpsNumLayerSets, "Output layer set idx must be greater or equal to 0 and less than the VpsNumLayerSets." );
+
+    for (Int i = 0; i < m_layerIdsInAddOutputLayerSet[ lsIdx ].size(); i++)
+    {
+      Bool isAlsoInLayerSet = false; 
+      for (Int j = 0; j < m_layerIdsInSets[ refLayerSetIdx ].size(); j++ )
+      {
+        if ( m_layerIdsInSets[ refLayerSetIdx ][ j ] == m_layerIdsInAddOutputLayerSet[ lsIdx ][ i ] )
+        {
+          isAlsoInLayerSet = true; 
+          break; 
+        }        
+      }
+      xConfirmPara( !isAlsoInLayerSet, "All output layers of a output layer set be included in corresponding layer set.");
+    }
+  }
+  xConfirmPara( m_profileLevelTierIdx.size() < m_vpsNumLayerSets + m_outputLayerSetIdx.size(), "The number of Profile Level Tier indices must be equal to the number of layer set plus the number of output layer set indices" );
+
+  // Layer Dependencies  
+  for (Int i = 0; i < m_numberOfLayers; i++ )
+  {
+    xConfirmPara( (i == 0)  && m_directRefLayers[0].size() != 0, "Layer 0 shall not have reference layers." ); 
+    xConfirmPara( m_directRefLayers[i].size() != m_dependencyTypes[ i ].size(), "Each reference layer shall have a reference type." ); 
+    for (Int j = 0; j < m_directRefLayers[i].size(); j++)
+    {
+      xConfirmPara( m_directRefLayers[i][j] < 0 || m_directRefLayers[i][j] >= i , "Reference layer id shall be greater than or equal to 0 and less than dependent layer id"); 
+      xConfirmPara( m_dependencyTypes[i][j] < 0 || m_dependencyTypes[i][j] >  2 , "Dependency type shall be greater than or equal to 0 and less than 3"); 
+    }        
+  }  
+#endif
   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" );
   xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
   xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
-  xConfirmPara( m_aiQP[0] < -6 * ((Int)m_uiInternalBitDepth - 8) || m_aiQP[0] > 51,         "QP exceeds supported range (-QpBDOffsety to 51)" );
-  if ( m_aiQP.size() >= 2 )
-  {
-    xConfirmPara( m_aiQP[1] < -6 * ((Int)m_uiInternalBitDepth - 8) || m_aiQP[1] > 51,       "QP depth exceeds supported range (-QpBDOffsety to 51)" );
-  }
-  xConfirmPara( m_iALFEncodePassReduction < 0 || m_iALFEncodePassReduction > 2,             "ALFEncodePassReduction must be equal to 0, 1 or 2");
-  xConfirmPara( m_iALFMaxNumberFilters < 1,                                                 "ALFMaxNumFilter should be larger than 1");  
-  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
-  xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,              "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
+#if H_MV
+  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
+  {
+    xConfirmPara( m_iQP[layer] <  -6 * (m_internalBitDepthY - 8) || m_iQP[layer] > 51,      "QP exceeds supported range (-QpBDOffsety to 51)" );
+  }
+#else
+  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
+#endif
+  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -6 || m_loopFilterBetaOffsetDiv2 > 6,          "Loop Filter Beta Offset div. 2 exceeds supported range (-6 to 6)");
+  xConfirmPara( m_loopFilterTcOffsetDiv2 < -6 || m_loopFilterTcOffsetDiv2 > 6,              "Loop Filter Tc Offset div. 2 exceeds supported range (-6 to 6)");
   xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2,                                     "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)" );
   xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
-#if DV_V_RESTRICTION_B0037
-  xConfirmPara( m_iVerticalDisparitySearchRange <= 0 ,                                      "Vertical Disparity Search Range must be more than 0" );
-#endif
   xConfirmPara( m_bipredSearchRange < 0 ,                                                   "Search Range must be more than 0" );
   xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
   xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,                                          "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
 
-  xConfirmPara( m_iChromaQpOffset    < -12,   "Min. Chroma Qp Offset is -12"     );
-  xConfirmPara( m_iChromaQpOffset    >  12,   "Max. Chroma Qp Offset is  12"     );
-  xConfirmPara( m_iChromaQpOffset2nd < -12,   "Min. Chroma Qp Offset 2nd is -12" );
-  xConfirmPara( m_iChromaQpOffset2nd >  12,   "Max. Chroma Qp Offset 2nd is  12" );
+  xConfirmPara( m_cbQpOffset < -12,   "Min. Chroma Cb QP Offset is -12" );
+  xConfirmPara( m_cbQpOffset >  12,   "Max. Chroma Cb QP Offset is  12" );
+  xConfirmPara( m_crQpOffset < -12,   "Min. Chroma Cr QP Offset is -12" );
+  xConfirmPara( m_crQpOffset >  12,   "Max. Chroma Cr QP Offset is  12" );
 
   xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
@@ -895,7 +1394,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
@@ -904,61 +1403,24 @@
   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_iNumberOfViews > MAX_VIEW_NUM ,                                     "NumberOfViews must be less than or equal to MAX_VIEW_NUM");
-  xConfirmPara    ( Int( m_pchInputFileList.size() ) < m_iNumberOfViews,              "Number of InputFiles must be greater than or equal to NumberOfViews" );
-  xConfirmPara    ( Int( m_pchReconFileList.size() ) < m_iNumberOfViews,              "Number of ReconFiles must be greater than or equal to NumberOfViews" );
-  xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
-#if HHI_INTERVIEW_SKIP
-  xConfirmPara    ( m_bInterViewSkip && !m_bUsingDepthMaps,                       "RenderingSkipMode requires CodeDepthMaps = 1" );
-#endif
-#if DEPTH_MAP_GENERATION
-  xConfirmPara    ( m_uiPredDepthMapGeneration > 2,                                   "PredDepthMapGen must be less than or equal to 2" );
-  xConfirmPara    ( m_uiPredDepthMapGeneration >= 2 && !m_bUsingDepthMaps,            "PredDepthMapGen >= 2 requires CodeDepthMaps = 1" );
-#endif
-#if H3D_IVMP
-  xConfirmPara    ( m_uiMultiviewMvPredMode > 7,                                      "MultiviewMvPred must be less than or equal to 7" );
-  xConfirmPara    ( m_uiMultiviewMvPredMode > 0 && m_uiPredDepthMapGeneration == 0 ,  "MultiviewMvPred > 0 requires PredDepthMapGen > 0" );
-  xConfirmPara    ( m_uiMultiviewMvRegMode       > 1,                                 "MultiviewMvRegMode must be less than or equal to 1" );
-  xConfirmPara    ( m_dMultiviewMvRegLambdaScale < 0.0,                               "MultiviewMvRegLambdaScale must not be negative" );
-  if( m_uiMultiviewMvRegMode )
-  {
-    xConfirmPara  ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews,         "MultiviewMvRegMode > 0 requires the presence of input depth maps" );
-  }
-#endif
-#if H3D_IVRP
-#if QC_ARP_D0177
-#if QC_ARP_WARNING_FIX
-  xConfirmPara    ( m_nUseAdvResPred > 1 , "0<=ARP<=1" );
-#else
-  xConfirmPara    ( m_nUseAdvResPred < 0 || m_nUseAdvResPred > 1 , "0<=ARP<=1" );
-#endif
-#else
-  xConfirmPara    ( m_uiMultiviewResPredMode > 1,                                     "MultiviewResPred must be less than or equal to 1" );
-  xConfirmPara    ( m_uiMultiviewResPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewResPred > 0 requires PredDepthMapGen > 0" );
-#endif
-#endif
-  if( m_bUsingDepthMaps )
-  {
-    xConfirmPara  ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews,         "Number of DepthInputFiles must be greater than or equal to NumberOfViews" );
-    xConfirmPara  ( Int( m_pchDepthReconFileList.size() ) < m_iNumberOfViews,         "Number of DepthReconFiles must be greater than or equal to NumberOfViews" );
-
-#if HHI_VSO
-    if( m_bUseVSO )
-    {
-      xConfirmPara( m_pchCameraParameterFile    == 0                             ,   "CameraParameterFile must be given");
-      xConfirmPara(   m_pchVSOConfig            == 0                             ,   "VSO Setup string must be given");
-      xConfirmPara( m_pchBaseViewCameraNumbers  == 0                             ,   "BaseViewCameraNumbers must be given" );
-      xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size(),   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
-      xConfirmPara( m_uiVSOMode > 4 ,                                                "VSO Mode must be less than 5");
-    }
-#endif
-  }
+  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.");
+  xConfirmPara(  m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
+
+#if H_3D_ARP
+  xConfirmPara( ( 0 != m_uiUseAdvResPred ) &&  ( 1 != m_uiUseAdvResPred ), "UseAdvResPred must be 0 or 1." );
+#endif
 #if ADAPTIVE_QP_SELECTION
-  xConfirmPara( m_bUseAdaptQpSelect == true && m_aiQP[0] < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
-  xConfirmPara( m_bUseAdaptQpSelect == true && m_aiQP[1] < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
-  xConfirmPara( m_bUseAdaptQpSelect == true && (m_iChromaQpOffset !=0 || m_iChromaQpOffset2nd != 0 ),  "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
+#if H_MV
+  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
+  {
+    xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP[layer] < 0,                                     "AdaptiveQpSelection must be disabled when QP < 0.");
+  }
+#else
+  xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
+#endif
+  xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ),               "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
 #endif
 
@@ -971,27 +1433,43 @@
   }
 
-  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 (m_iSliceMode==3)
-  {
-    xConfirmPara( m_iSliceGranularity > 0 ,      "When SliceMode == 3 is chosen, the SliceGranularity must be 0" );
-  }
-  xConfirmPara( m_iEntropySliceMode < 0 || m_iEntropySliceMode > 2, "EntropySliceMode exceeds supported range (0 to 2)" );
-  if (m_iEntropySliceMode!=0)
-  {
-    xConfirmPara( m_iEntropySliceArgument < 1 ,         "EntropySliceArgument should be larger than or equal to 1" );
-  }
-  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" );
-
-  bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
-  xConfirmPara( tileFlag && m_iEntropySliceMode,            "Tile and Entropy Slice can not be applied together");
+  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");
-  xConfirmPara( m_iWaveFrontSynchro && m_iEntropySliceMode, "Wavefront and Entropy Slice can not be applied together");  
-
+
+  //TODO:ChromaFmt assumes 4:2:0 below
+  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");
+
+#if H_3D
+  xConfirmPara( m_pchCameraParameterFile    == 0                ,   "CameraParameterFile must be given");
+  xConfirmPara( m_pchBaseViewCameraNumbers  == 0                ,   "BaseViewCameraNumbers must be given" );
+  xConfirmPara( ((UInt) m_numberOfLayers >> 1 ) != m_cCameraData.getBaseViewNumbers().size(),   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
+  xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
+#if H_3D_VSO
+    if( m_bUseVSO )
+    {
+      xConfirmPara(   m_pchVSOConfig            == 0                             ,   "VSO Setup string must be given");
+      xConfirmPara( m_uiVSOMode > 4 ,                                                "VSO Mode must be less than 5");
+    }
+#endif
+#endif
   // max CU width and height should be power of 2
   UInt ui = m_uiMaxCUWidth;
@@ -1009,35 +1487,17 @@
       xConfirmPara( ui != 1 , "Height should be 2^n");
   }
-  
-  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
-  xConfirmPara( m_iWaveFrontFlush < 0, "WaveFrontFlush cannot be negative" );
-  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
-  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
-
-#undef xConfirmPara
-  if (check_failed)
-  {
-    exit(EXIT_FAILURE);
-  }
-
-  xCheckCodingStructureMvc();
-}
-
-Void TAppEncCfg::xCheckCodingStructureMvc()
-{
-  bool check_failed = false; /* abort if there is a fatal configuration problem */
-#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
-
-  // validate that POC of same frame is identical across multiple views
+
+#if H_MV
+  // validate that POC of same frame is identical across multiple layers
   Bool bErrorMvePoc = false;
-  if( m_iNumberOfViews > 1 )
-  {
-    for( Int k = 1; k < m_iNumberOfViews; k++ )
+  if( m_numberOfLayers > 1 )
+  {
+    for( Int k = 1; k < m_numberOfLayers; k++ )
     {
       for( Int i = 0; i < MAX_GOP; i++ )
       {
-        if( m_GOPListsMvc[k][i].m_POC != m_GOPListsMvc[0][i].m_POC )
+        if( m_GOPListMvc[k][i].m_POC != m_GOPListMvc[0][i].m_POC )
         {
-          printf( "\nError: Frame%d_v%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListsMvc[k][i].m_POC, i );
+          printf( "\nError: Frame%d_l%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListMvc[k][i].m_POC, i );
           bErrorMvePoc = true;
         }
@@ -1045,5 +1505,5 @@
     }
   }
-  xConfirmPara( bErrorMvePoc,  "Invalid inter-view POC structure given" );
+  xConfirmPara( bErrorMvePoc,  "Invalid inter-layer POC structure given" );
 
   // validate that baseview has no inter-view refs 
@@ -1051,36 +1511,37 @@
   for( Int i = 0; i < MAX_GOP; i++ )
   {
-    if( m_GOPListsMvc[0][i].m_numInterViewRefPics != 0 )
-    {
-      printf( "\nError: Frame%d inter_view refs not available in view 0\n", i );
+    if( m_GOPListMvc[0][i].m_numActiveRefLayerPics != 0 )
+    {
+      printf( "\nError: Frame%d inter_layer refs not available in layer 0\n", i );
       bErrorIvpBase = true;
     }
   }
-  xConfirmPara( bErrorIvpBase, "Inter-view refs not possible in base view" );
+  xConfirmPara( bErrorIvpBase, "Inter-layer refs not possible in base layer" );
 
   // validate inter-view refs
   Bool bErrorIvpEnhV = false;
-  if( m_iNumberOfViews > 1 )
-  {
-    for( Int k = 1; k < m_iNumberOfViews; k++ )
+  if( m_numberOfLayers > 1 )
+  {
+    for( Int layer = 1; layer < m_numberOfLayers; layer++ )
     {
       for( Int i = 0; i < MAX_GOP+1; i++ )
       {
-        for( Int j = 0; j < m_GOPListsMvc[k][i].m_numInterViewRefPics; j++ )
+        GOPEntry gopEntry = m_GOPListMvc[layer][i];  
+        for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
         {
-          Int iAbsViewId = m_GOPListsMvc[k][i].m_interViewRefs[j] + k;
-          if( iAbsViewId < 0 || iAbsViewId >= k )
+          Int ilPredLayerIdc = gopEntry.m_interLayerPredLayerIdc[j];
+          if( ilPredLayerIdc < 0 || ilPredLayerIdc >= m_directRefLayers[layer].size() )
           {
-            printf( "\nError: inter-view ref pic %d is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefs[j], i, k );
+            printf( "\nError: inter-layer ref idc %d is not available for Frame%d_l%d\n", gopEntry.m_interLayerPredLayerIdc[j], i, layer );
             bErrorIvpEnhV = true;
           }
-          if( m_GOPListsMvc[k][i].m_interViewRefPosL0[j] < 0 || m_GOPListsMvc[k][i].m_interViewRefPosL0[j] > m_GOPListsMvc[k][i].m_numRefPicsActive )
+          if( gopEntry.m_interViewRefPosL[0][j] < -1 || gopEntry.m_interViewRefPosL[0][j] > gopEntry.m_numRefPicsActive )
           {
-            printf( "\nError: inter-view ref pos %d on L0 is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefPosL0[j], i, k );
+            printf( "\nError: inter-layer ref pos %d on L0 is not available for Frame%d_l%d\n", gopEntry.m_interViewRefPosL[0][j], i, layer );
             bErrorIvpEnhV = true;
           }
-          if( m_GOPListsMvc[k][i].m_interViewRefPosL1[j] < 0 || m_GOPListsMvc[k][i].m_interViewRefPosL1[j] > m_GOPListsMvc[k][i].m_numRefPicsActive )
+          if( gopEntry.m_interViewRefPosL[1][j] < -1  || gopEntry.m_interViewRefPosL[1][j] > gopEntry.m_numRefPicsActive )
           {
-            printf( "\nError: inter-view ref pos %d on L1 is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefPosL1[j], i, k );
+            printf( "\nError: inter-layer ref pos %d on L1 is not available for Frame%d_l%d\n", gopEntry.m_interViewRefPosL[1][j], i, layer );
             bErrorIvpEnhV = true;
           }
@@ -1088,69 +1549,63 @@
         if( i == MAX_GOP ) // inter-view refs at I pic position in base view
         {
-          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'B' && m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'P' && m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'I' )
+          if( gopEntry.m_sliceType != 'B' && gopEntry.m_sliceType != 'P' && gopEntry.m_sliceType != 'I' )
           {
-            printf( "\nError: slice type of FrameI_v%d must be equal to B or P or I\n", k );
+            printf( "\nError: slice type of FrameI_l%d must be equal to B or P or I\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListsMvc[k][MAX_GOP].m_POC != 0 )
+          if( gopEntry.m_POC != 0 )
           {
-            printf( "\nError: POC %d not possible for FrameI_v%d, must be 0\n", m_GOPListsMvc[k][MAX_GOP].m_POC, k );
+            printf( "\nError: POC %d not possible for FrameI_l%d, must be 0\n", gopEntry.m_POC, layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListsMvc[k][MAX_GOP].m_temporalId != 0 )
+          if( gopEntry.m_temporalId != 0 )
           {
-            printf( "\nWarning: Temporal id of FrameI_v%d must be 0 (cp. I-frame in base view)\n", k );
-            m_GOPListsMvc[k][MAX_GOP].m_temporalId = 0;
+            printf( "\nWarning: Temporal id of FrameI_l%d must be 0 (cp. I-frame in base layer)\n", layer );
+            gopEntry.m_temporalId = 0;
           }
 
-          if( !(m_GOPListsMvc[k][MAX_GOP].m_refPic) )
+          if( gopEntry.m_numRefPics != 0 )
           {
-            printf( "\nWarning: FrameI_v%d must be ref pic (cp. I-frame in base view)\n", k );
-            m_GOPListsMvc[k][MAX_GOP].m_refPic = true;
+            printf( "\nWarning: temporal references not possible for FrameI_l%d\n", layer );
+            for( Int j = 0; j < m_GOPListMvc[layer][MAX_GOP].m_numRefPics; j++ )
+            {
+              gopEntry.m_referencePics[j] = 0;
+            }
+            gopEntry.m_numRefPics = 0;
           }
 
-          if( m_GOPListsMvc[k][MAX_GOP].m_numRefPics != 0 )
+          if( gopEntry.m_interRPSPrediction )
           {
-            printf( "\nWarning: temporal references not possible for FrameI_v%d\n", k );
-            for( Int j = 0; j < m_GOPListsMvc[k][MAX_GOP].m_numRefPics; j++ )
-            {
-              m_GOPListsMvc[k][MAX_GOP].m_referencePics[j] = 0;
-            }
-            m_GOPListsMvc[k][MAX_GOP].m_numRefPics = 0;
-          }
-
-          if( m_GOPListsMvc[k][MAX_GOP].m_interRPSPrediction )
-          {
-            printf( "\nError: inter RPS prediction not possible for FrameI_v%d, must be 0\n", k );
+            printf( "\nError: inter RPS prediction not possible for FrameI_l%d, must be 0\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics != 0 )
+          if( gopEntry.m_sliceType == 'I' && gopEntry.m_numActiveRefLayerPics != 0 )
           {
-            printf( "\nError: inter-view prediction not possible for FrameI_v%d with slice type I, #IV_ref_pics must be 0\n", k );
+            printf( "\nError: inter-layer prediction not possible for FrameI_l%d with slice type I, #IL_ref_pics must be 0\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListsMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics )
+          if( gopEntry.m_numRefPicsActive > gopEntry.m_numActiveRefLayerPics )
           {
-            m_GOPListsMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics;
+            gopEntry.m_numRefPicsActive = gopEntry.m_numActiveRefLayerPics;
           }
 
-          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'P' )
+          if( gopEntry.m_sliceType == 'P' )
           {
-            if( m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
+            if( gopEntry.m_numActiveRefLayerPics < 1 )
             {
-              printf( "\nError: #IV_ref_pics must be at least one for FrameI_v%d with slice type P\n", k );
+              printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type P\n", layer );
               bErrorIvpEnhV = true;
             }
             else
             {
-              for( Int j = 0; j < m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics; j++ )
+              for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
               {
-                if( m_GOPListsMvc[k][MAX_GOP].m_interViewRefPosL1[j] != 0 )
+                if( gopEntry.m_interViewRefPosL[1][j] != -1 )
                 {
-                  printf( "\nError: inter-view ref pos %d on L1 not possible for FrameI_v%d with slice type P\n", m_GOPListsMvc[k][MAX_GOP].m_interViewRefPosL1[j], k );
+                  printf( "\nError: inter-layer ref pos %d on L1 not possible for FrameI_l%d with slice type P\n", gopEntry.m_interViewRefPosL[1][j], layer );
                   bErrorIvpEnhV = true;
                 }
@@ -1159,7 +1614,7 @@
           }
 
-          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
+          if( gopEntry.m_sliceType == 'B' && gopEntry.m_numActiveRefLayerPics < 1 )
           {
-            printf( "\nError: #IV_ref_pics must be at least one for FrameI_v%d with slice type B\n", k );
+            printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type B\n", layer );
             bErrorIvpEnhV = true;
           }
@@ -1168,312 +1623,467 @@
     }
   }
-  xConfirmPara( bErrorIvpEnhV, "Invalid inter-view coding structure for enhancement views given" );
+  xConfirmPara( bErrorIvpEnhV, "Invalid inter-layer coding structure for enhancement layers given" );
 
   // validate temporal coding structure
   if( !bErrorMvePoc && !bErrorIvpBase && !bErrorIvpEnhV )
   {
-    for( Int viewId = 0; viewId < m_iNumberOfViews; viewId++ )
-    {
-      Bool verifiedGOP = false;
-      Bool errorGOP    = false;
-      Int  checkGOP    = 1;
-      Int  numRefs     = 1;
-      Int refList[MAX_NUM_REF_PICS+1];
-      refList[0] = 0;
-      Bool isOK[MAX_GOP];
-      for( Int i = 0; i < MAX_GOP; i++ ) { isOK[i] = false; }
-      Int numOK = 0;
-      m_extraRPSs[viewId] = 0;
-      //start looping through frames in coding order until we can verify that the GOP structure is correct.
-      while( !verifiedGOP && !errorGOP )
-      {
-        Int curGOP = (checkGOP-1)%m_iGOPSize;
-        Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPListsMvc[viewId][curGOP].m_POC;    
-        if( m_GOPListsMvc[viewId][curGOP].m_POC < 0 )
+    for( Int layer = 0; layer < m_numberOfLayers; layer++ )
+    {
+      GOPEntry* m_GOPList            = m_GOPListMvc           [layer]; // It is not a member, but this name helps avoiding code duplication !!!
+      Int&      m_extraRPSs          = m_extraRPSsMvc         [layer]; // It is not a member, but this name helps avoiding code duplication !!!
+      Int&      m_maxTempLayer       = m_maxTempLayerMvc      [layer]; // It is not a member, but this name helps avoiding code duplication !!!
+      Int*      m_maxDecPicBuffering = m_maxDecPicBufferingMvc[layer]; // It is not a member, but this name helps avoiding code duplication !!!
+      Int*      m_numReorderPics     = m_numReorderPicsMvc    [layer]; // It is not a member, but this name helps avoiding code duplication !!!
+#endif
+  /* 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 (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;
+  }
+  
+  Bool verifiedGOP=false;
+  Bool errorGOP=false;
+  Int checkGOP=1;
+  Int numRefs = 1;
+  Int refList[MAX_NUM_REF_PICS+1];
+  refList[0]=0;
+  Bool isOK[MAX_GOP];
+  for(Int i=0; i<MAX_GOP; i++) 
+  {
+    isOK[i]=false;
+  }
+  Int numOK=0;
+  xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" );
+
+  for(Int i=0; i<m_iGOPSize; i++)
+  {
+    if(m_GOPList[i].m_POC==m_iGOPSize)
+    {
+      xConfirmPara( m_GOPList[i].m_temporalId!=0 , "The last frame in each GOP must have temporal ID = 0 " );
+    }
+  }
+  
+#if H_MV
+  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable[layer]) )
+#else
+  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
+#endif
+  {
+    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)" );
+    }
+  }
+  m_extraRPSs=0;
+  //start looping through frames in coding order until we can verify that the GOP structure is correct.
+  while(!verifiedGOP&&!errorGOP) 
+  {
+    Int curGOP = (checkGOP-1)%m_iGOPSize;
+    Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPList[curGOP].m_POC;    
+    if(m_GOPList[curGOP].m_POC<0) 
+    {
+#if H_MV
+      printf("\nError: found fewer Reference Picture Sets than GOPSize for layer %d\n", layer );
+#else
+      printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
+#endif
+      errorGOP=true;
+    }
+    else 
+    {
+      //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
+      Bool beforeI = false;
+      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
+      {
+        Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
+        if(absPOC < 0)
         {
-          printf( "\nError: found fewer Reference Picture Sets than GOPSize for view %d\n", viewId );
-          errorGOP = true;
+          beforeI=true;
         }
         else 
         {
-          //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
-          Bool beforeI = false;
-          for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ ) 
+          Bool found=false;
+          for(Int j=0; j<numRefs; j++) 
           {
-            Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
-            if( absPOC < 0 )
+            if(refList[j]==absPOC) 
             {
-              beforeI = true;
-            }
-            else 
-            {
-              Bool found = false;
-              for( Int j = 0; j < numRefs; j++ )
+              found=true;
+              for(Int k=0; k<m_iGOPSize; k++)
               {
-                if( refList[j] == absPOC ) 
+                if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize)
                 {
-                  found = true;
-                  for( Int k = 0; k < m_iGOPSize; k++ )
+                  if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId)
                   {
-                    if( absPOC%m_iGOPSize == m_GOPListsMvc[viewId][k].m_POC%m_iGOPSize )
-                    {
-                      m_GOPListsMvc[viewId][curGOP].m_usedByCurrPic[i] = (m_GOPListsMvc[viewId][k].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId);
-                    }
+                    m_GOPList[k].m_refPic = true;
                   }
+                  m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId;
                 }
-              }
-              if( !found )
-              {
-                printf("\nError: ref pic %d is not available for GOP frame %d of view %d\n", m_GOPListsMvc[viewId][curGOP].m_referencePics[i], curGOP+1, viewId );
-                errorGOP = true;
               }
             }
           }
-          if( !beforeI && !errorGOP )
+          if(!found)
           {
-            //all ref frames were present
-            if( !isOK[curGOP] ) 
+#if H_MV
+            printf("\nError: ref pic %d is not available for GOP frame %d of layer %d\n", m_GOPList[curGOP].m_referencePics[i], curGOP+1, layer);
+#else
+            printf("\nError: ref pic %d is not available for GOP frame %d\n",m_GOPList[curGOP].m_referencePics[i],curGOP+1);
+#endif
+            errorGOP=true;
+          }
+        }
+      }
+      if(!beforeI&&!errorGOP)
+      {
+        //all ref frames were present
+        if(!isOK[curGOP]) 
+        {
+          numOK++;
+          isOK[curGOP]=true;
+          if(numOK==m_iGOPSize)
+          {
+            verifiedGOP=true;
+          }
+        }
+      }
+      else 
+      {
+        //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
+        m_GOPList[m_iGOPSize+m_extraRPSs]=m_GOPList[curGOP];
+        Int newRefs=0;
+        for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
+        {
+          Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
+          if(absPOC>=0)
+          {
+            m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i];
+            m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i];
+            newRefs++;
+          }
+        }
+        Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive;
+        
+        for(Int offset = -1; offset>-checkGOP; offset--)
+        {
+          //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
+          Int offGOP = (checkGOP-1+offset)%m_iGOPSize;
+          Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC;
+          if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId)
+          {
+            Bool newRef=false;
+            for(Int i=0; i<numRefs; i++)
             {
-              numOK++;
-              isOK[curGOP] = true;
-              if( numOK == m_iGOPSize )
+              if(refList[i]==offPOC)
               {
-                verifiedGOP = true;
+                newRef=true;
               }
             }
-          }
-          else 
-          {
-            //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
-            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]] = m_GOPListsMvc[viewId][curGOP];
-            Int newRefs = 0;
-            for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ )
+            for(Int i=0; i<newRefs; i++) 
             {
-              Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
-              if( absPOC >= 0 )
+              if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC)
               {
-                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[newRefs] = m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
-                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[newRefs] = m_GOPListsMvc[viewId][curGOP].m_usedByCurrPic[i];
-                newRefs++;
+                newRef=false;
               }
             }
-            Int numPrefRefs = m_GOPListsMvc[viewId][curGOP].m_numRefPicsActive;
-
-            for( Int offset = -1; offset > -checkGOP; offset-- )
+            if(newRef) 
             {
-              //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
-              Int offGOP =  (checkGOP - 1 + offset)%m_iGOPSize;
-              Int offPOC = ((checkGOP - 1 + offset)/m_iGOPSize) * m_iGOPSize + m_GOPListsMvc[viewId][offGOP].m_POC;
-              if( offPOC >= 0 && m_GOPListsMvc[viewId][offGOP].m_refPic && m_GOPListsMvc[viewId][offGOP].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId )
+              Int insertPoint=newRefs;
+              //this picture can be added, find appropriate place in list and insert it.
+              if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId)
               {
-                Bool newRef = false;
-                for( Int i = 0; i < numRefs; i++ )
+                m_GOPList[offGOP].m_refPic = true;
+              }
+              for(Int j=0; j<newRefs; j++)
+              {
+                if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0)
                 {
-                  if( refList[i] == offPOC )
-                  {
-                    newRef = true;
-                  }
-                }
-                for( Int i = 0; i < newRefs; i++ ) 
-                {
-                  if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[i] == (offPOC - curPOC) )
-                  {
-                    newRef = false;
-                  }
-                }
-                if( newRef ) 
-                {
-                  Int insertPoint = newRefs;
-                  //this picture can be added, find appropriate place in list and insert it.
-                  for( Int j = 0; j < newRefs; j++ )
-                  {
-                    if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] < (offPOC - curPOC) || 
-                        m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] > 0 )
-                    {
-                      insertPoint = j;
-                      break;
-                    }
-                  }
-                  Int prev = offPOC - curPOC;
-                  Int prevUsed = (m_GOPListsMvc[viewId][offGOP].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId);
-                  for( Int j = insertPoint; j < newRefs+1; j++ )
-                  {
-                    Int newPrev = m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j];
-                    Int newUsed = m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j];
-                    m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] = prev;
-                    m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j] = prevUsed;
-                    prevUsed = newUsed;
-                    prev = newPrev;
-                  }
-                  newRefs++;
+                  insertPoint = j;
+                  break;
                 }
               }
-              if( newRefs >= numPrefRefs )
+              Int prev = offPOC-curPOC;
+              Int prevUsed = m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId;
+              for(Int j=insertPoint; j<newRefs+1; j++)
               {
-                break;
+                Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j];
+                Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j];
+                m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev;
+                m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed;
+                prevUsed=newUsed;
+                prev=newPrev;
+              }
+              newRefs++;
+            }
+          }
+          if(newRefs>=numPrefRefs)
+          {
+            break;
+          }
+        }
+        m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs;
+        m_GOPList[m_iGOPSize+m_extraRPSs].m_POC = curPOC;
+        if (m_extraRPSs == 0)
+        {
+          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0;
+          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0;
+        }
+        else
+        {
+          Int rIdx =  m_iGOPSize + m_extraRPSs - 1;
+          Int refPOC = m_GOPList[rIdx].m_POC;
+          Int refPics = m_GOPList[rIdx].m_numRefPics;
+          Int newIdc=0;
+          for(Int i = 0; i<= refPics; i++) 
+          {
+            Int deltaPOC = ((i != refPics)? m_GOPList[rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
+            Int absPOCref = refPOC+deltaPOC;
+            Int refIdc = 0;
+            for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics; j++)
+            {
+              if ( (absPOCref - curPOC) == m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j])
+              {
+                if (m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j])
+                {
+                  refIdc = 1;
+                }
+                else
+                {
+                  refIdc = 2;
+                }
               }
             }
-            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefPics = newRefs;
-            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_POC = curPOC;
-            if( m_extraRPSs[viewId] == 0 )
-            {
-              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_interRPSPrediction = 0;
-              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefIdc = 0;
-            }
-            else
-            {
-              Int rIdx =  m_iGOPSize + m_extraRPSs[viewId] - 1;
-              Int refPOC = m_GOPListsMvc[viewId][rIdx].m_POC;
-              Int refPics = m_GOPListsMvc[viewId][rIdx].m_numRefPics;
-              Int newIdc = 0;
-              for( Int i = 0; i <= refPics; i++ )
-              {
-                Int deltaPOC = ((i != refPics)? m_GOPListsMvc[viewId][rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
-                Int absPOCref = refPOC + deltaPOC;
-                Int refIdc = 0;
-                for( Int j = 0; j < m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefPics; j++ )
-                {
-                  if( (absPOCref - curPOC) == m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] )
-                  {
-                    if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j] )
-                    {
-                      refIdc = 1;
-                    }
-                    else
-                    {
-                      refIdc = 2;
-                    }
-                  }
-                }
-                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_refIdc[newIdc] = refIdc;
-                newIdc++;
-              }
-              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_interRPSPrediction = 1;  
-              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefIdc = newIdc;
-              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_deltaRPS = refPOC - m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_POC; 
-              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_deltaRIdxMinus1 = 0; 
-            }
-            curGOP = m_iGOPSize + m_extraRPSs[viewId];
-            m_extraRPSs[viewId]++;
+            m_GOPList[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc;
+            newIdc++;
           }
-          numRefs = 0;
-          for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ )
-          {
-            Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
-            if( absPOC >= 0 )
-            {
-              refList[numRefs] = absPOC;
-              numRefs++;
-            }
-          }
-          refList[numRefs] = curPOC;
+          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1;  
+          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; 
+        }
+        curGOP=m_iGOPSize+m_extraRPSs;
+        m_extraRPSs++;
+      }
+      numRefs=0;
+      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
+      {
+        Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
+        if(absPOC >= 0) 
+        {
+          refList[numRefs]=absPOC;
           numRefs++;
         }
-        checkGOP++;
-      }
-      xConfirmPara( errorGOP, "Invalid GOP structure given" );
-      m_maxTempLayer[viewId] = 1;
-      for( Int i = 0; i < m_iGOPSize; i++ ) 
-      {
-        if( m_GOPListsMvc[viewId][i].m_temporalId >= m_maxTempLayer[viewId] )
+      }
+      refList[numRefs]=curPOC;
+      numRefs++;
+    }
+    checkGOP++;
+  }
+  xConfirmPara(errorGOP,"Invalid GOP structure given");
+  m_maxTempLayer = 1;
+  for(Int i=0; i<m_iGOPSize; i++) 
+  {
+    if(m_GOPList[i].m_temporalId >= m_maxTempLayer)
+    {
+      m_maxTempLayer = m_GOPList[i].m_temporalId+1;
+    }
+    xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P', "Slice type must be equal to B or P");
+  }
+  for(Int i=0; i<MAX_TLAYER; i++)
+  {
+    m_numReorderPics[i] = 0;
+    m_maxDecPicBuffering[i] = 1;
+  }
+  for(Int i=0; i<m_iGOPSize; i++) 
+  {
+    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
+    {
+      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
+    }
+    Int highestDecodingNumberWithLowerPOC = 0; 
+    for(Int j=0; j<m_iGOPSize; j++)
+    {
+      if(m_GOPList[j].m_POC <= m_GOPList[i].m_POC)
+      {
+        highestDecodingNumberWithLowerPOC = j;
+      }
+    }
+    Int numReorder = 0;
+    for(Int j=0; j<highestDecodingNumberWithLowerPOC; j++)
+    {
+      if(m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId && 
+        m_GOPList[j].m_POC > m_GOPList[i].m_POC)
+      {
+        numReorder++;
+      }
+    }    
+    if(numReorder > m_numReorderPics[m_GOPList[i].m_temporalId])
+    {
+      m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder;
+    }
+  }
+  for(Int i=0; i<MAX_TLAYER-1; i++) 
+  {
+    // a lower layer can not have higher value of m_numReorderPics than a higher layer
+    if(m_numReorderPics[i+1] < m_numReorderPics[i])
+    {
+      m_numReorderPics[i+1] = m_numReorderPics[i];
+    }
+    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
+    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
+    {
+      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
+    }
+    // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
+    if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
+    {
+      m_maxDecPicBuffering[i+1] = m_maxDecPicBuffering[i];
+    }
+  }
+
+
+  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
+  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
+  {
+    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
+  }
+
+  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)))
         {
-          m_maxTempLayer[viewId] = m_GOPListsMvc[viewId][i].m_temporalId + 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);
         }
-        xConfirmPara( m_GOPListsMvc[viewId][i].m_sliceType != 'B' && m_GOPListsMvc[viewId][i].m_sliceType != 'P', "Slice type must be equal to B or P" );
-      }
-
-      for( Int i = 0; i < MAX_TLAYER; i++ )
-      {
-        m_numReorderPics[viewId][i] = 0;
-        m_maxDecPicBuffering[viewId][i] = 0;
-      }
-      for( Int i = 0; i < m_iGOPSize; i++ ) 
-      {
-        if( m_GOPListsMvc[viewId][i].m_numRefPics > m_maxDecPicBuffering[viewId][m_GOPListsMvc[viewId][i].m_temporalId] )
+      }
+      else // not uniform spacing
+      {
+        if(m_iNumColumnsMinus1<1)
         {
-          m_maxDecPicBuffering[viewId][m_GOPListsMvc[viewId][i].m_temporalId] = m_GOPListsMvc[viewId][i].m_numRefPics;
+          maxTileWidth = m_iSourceWidth;
         }
-        Int highestDecodingNumberWithLowerPOC = 0; 
-        for( Int j = 0; j < m_iGOPSize; j++ )
+        else
         {
-          if( m_GOPListsMvc[viewId][j].m_POC <= m_GOPListsMvc[viewId][i].m_POC )
+          Int accColumnWidth = 0;
+          for(Int col=0; col<(m_iNumColumnsMinus1); col++)
           {
-            highestDecodingNumberWithLowerPOC = j;
+            maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth;
+            accColumnWidth += m_pColumnWidth[col];
           }
+          maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
         }
-        Int numReorder = 0;
-        for( Int j = 0; j < highestDecodingNumberWithLowerPOC; j++ )
+        if(m_iNumRowsMinus1<1)
         {
-          if( m_GOPListsMvc[viewId][j].m_temporalId <= m_GOPListsMvc[viewId][i].m_temporalId && 
-              m_GOPListsMvc[viewId][j].m_POC        >  m_GOPListsMvc[viewId][i].m_POC )
+          maxTileHeight = m_iSourceHeight;
+        }
+        else
+        {
+          Int accRowHeight = 0;
+          for(Int row=0; row<(m_iNumRowsMinus1); row++)
           {
-            numReorder++;
+            maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight;
+            accRowHeight += m_pRowHeight[row];
           }
-        }    
-        if( numReorder > m_numReorderPics[viewId][m_GOPListsMvc[viewId][i].m_temporalId] )
-        {
-          m_numReorderPics[viewId][m_GOPListsMvc[viewId][i].m_temporalId] = numReorder;
+          maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
         }
       }
-      for( Int i = 0; i < MAX_TLAYER-1; i++ ) 
-      {
-        // a lower layer can not have higher value of m_numReorderPics than a higher layer
-        if( m_numReorderPics[viewId][i+1] < m_numReorderPics[viewId][i] )
-        {
-          m_numReorderPics[viewId][i+1] = m_numReorderPics[viewId][i];
-        }
-        // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
-        if( m_numReorderPics[viewId][i] > m_maxDecPicBuffering[viewId][i] )
-        {
-          m_maxDecPicBuffering[viewId][i] = m_numReorderPics[viewId][i];
-        }
-        // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
-        if( m_maxDecPicBuffering[viewId][i+1] < m_maxDecPicBuffering[viewId][i] )
-        {
-          m_maxDecPicBuffering[viewId][i+1] = m_maxDecPicBuffering[viewId][i];
-        }
-      }
-      // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
-      if( m_numReorderPics[viewId][MAX_TLAYER-1] > m_maxDecPicBuffering[viewId][MAX_TLAYER-1] )
-      {
-        m_maxDecPicBuffering[viewId][MAX_TLAYER-1] = m_numReorderPics[viewId][MAX_TLAYER-1];
-      }
-
-      xConfirmPara( m_bUseLComb == false && m_numReorderPics[viewId][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.
-    }
-  }
+      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;
+    }
+  }
+  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
+  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
+  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
+
+  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
+
+  if (m_toneMappingInfoSEIEnabled)
+  {
+    xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
+    xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
+    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
+    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
+    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
+    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
+    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
+  }
+
+#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)
+  {
+    Int numLCUInWidth  = (m_iSourceWidth  / m_uiMaxCUWidth) + (( m_iSourceWidth  %  m_uiMaxCUWidth ) ? 1 : 0);
+    Int numLCUInHeight = (m_iSourceHeight / m_uiMaxCUHeight)+ (( m_iSourceHeight %  m_uiMaxCUHeight) ? 1 : 0);
+    Int numLCUInPic    =  numLCUInWidth * numLCUInHeight;
+
+    xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" );
+
+    m_iMaxDeltaQP       = MAX_DELTA_QP;
+    m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
+  }
+#endif
+
+  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue, "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0");
+
+  xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
+  if (m_framePackingSEIEnabled)
+  {
+    xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5");
+  }
+
+#if H_MV
+  }
+  }
+#endif
 #undef xConfirmPara
-  if( check_failed )
+  if (check_failed)
   {
     exit(EXIT_FAILURE);
   }
-}
-
-template <class T>
-Void
-TAppEncCfg::xCleanUpVector( std::vector<T>& rcVec, const T& rcInvalid )
-{
-  Int iFirstInv = (Int)rcVec.size();
-  for( Int iIdx = 0; iIdx < (Int)rcVec.size(); iIdx++ )
-  {
-    if( rcVec[ iIdx ] == rcInvalid )
-    {
-      iFirstInv = iIdx;
-      break;
-    }
-  }
-  while( (Int)rcVec.size() > iFirstInv )
-  {
-    rcVec.pop_back();
-  }
-}
-
-Void
-TAppEncCfg::xCleanUpVectors()
-{
-  xCleanUpVector( m_pchInputFileList,       (char*)0 );
-  xCleanUpVector( m_pchDepthInputFileList,  (char*)0 );
-  xCleanUpVector( m_pchReconFileList,       (char*)0 );
-  xCleanUpVector( m_pchDepthReconFileList,  (char*)0 );
 }
 
@@ -1495,31 +2105,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
-
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-  g_iDeltaDCsQuantOffset = g_uiBitIncrement - 2;
-#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;
 }
 
@@ -1527,30 +2115,36 @@
 {
   printf("\n");
-  for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
-  {
-    printf("Texture Input File %i            : %s\n", iCounter, m_pchInputFileList[iCounter]);
-  }
-  if( m_bUsingDepthMaps )
-  {
-    for( Int iCounter = 0; iCounter < m_iNumberOfViews; iCounter++)
-    {
-      printf("Depth Input File %i              : %s\n", iCounter, m_pchDepthInputFileList[iCounter]);
-    }
-  }
-  printf("Bitstream File                  : %s\n", m_pchBitstreamFile      );
-  for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
-  {
-    printf("Texture Reconstruction File %i   : %s\n", iCounter, m_pchReconFileList[iCounter]);
-  }
-  if( m_bUsingDepthMaps )
-  {
-    for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
-    {
-      printf("Depth Reconstruction File %i     : %s\n", iCounter, m_pchDepthReconFileList[iCounter]);
-    }
-  }
-  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate );
+#if H_MV
+  for( Int layer = 0; layer < m_numberOfLayers; layer++)
+  {
+    printf("Input File %i                 : %s\n", layer, m_pchInputFileList[layer]);
+  }
+#else
+  printf("Input          File          : %s\n", m_pchInputFile          );
+#endif
+  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
+#if H_MV
+  for( Int layer = 0; layer < m_numberOfLayers; layer++)
+  {
+    printf("Reconstruction File %i        : %s\n", layer, m_pchReconFileList[layer]);
+  }
+#else
+  printf("Reconstruction File          : %s\n", m_pchReconFile          );
+#endif
+#if H_MV
+  xPrintParaVector( "ViewId", m_viewId ); 
+#endif
+#if H_3D
+  xPrintParaVector( "DepthFlag", m_depthFlag ); 
+  printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision);
+#endif
+#if H_MV  
+  xPrintParaVector( "QP"               , m_fQP                ); 
+  xPrintParaVector( "LoopFilterDisable", m_bLoopFilterDisable ); 
+  xPrintParaVector( "SAO"              , m_bUseSAO            ); 
+#endif
+  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("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 );
@@ -1559,221 +2153,152 @@
   printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
   printf("Motion search range          : %d\n", m_iSearchRange );
-#if DV_V_RESTRICTION_B0037
-  printf("Disp search range restriction: %d\n", m_bUseDisparitySearchRangeRestriction );
-  printf("Vertical disp search range   : %d\n", m_iVerticalDisparitySearchRange );
-#endif
   printf("Intra period                 : %d\n", m_iIntraPeriod );
   printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
-  printf("QP Texture                   : %5.2f\n", m_adQP[0] );
-  if( m_bUsingDepthMaps )
-  {
-    printf("QP Depth                     : %5.2f\n", m_adQP[ m_adQP.size()  < 2 ? 0 : 1] );
-  }
+#if !H_MV
+  printf("QP                           : %5.2f\n", m_fQP );
+#endif
   printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
 
-  printf("Chroma Qp Offset             : %d\n", m_iChromaQpOffset   );
-  printf("Chroma Qp Offset 2nd         : %d\n", m_iChromaQpOffset2nd);
+  printf("Cb QP Offset                 : %d\n", m_cbQpOffset   );
+  printf("Cr QP Offset                 : %d\n", m_crQpOffset);
 
   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 );
-  if((m_uiMaxCUWidth >> m_uiMaxCUDepth) == 4)
-  {
-    printf("DisableInter4x4              : %d\n", m_bDisInter4x4);  
-  }
-
-printf("Loop Filter Disabled         : %d %d\n", m_abLoopFilterDisable[0] ? 1 : 0,  m_abLoopFilterDisable[1] ? 1 : 0 );
+  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)
+  {
+    printf("TargetBitrate                : %d\n", m_targetBitrate);
+    printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
+  }
+#endif
+  printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
+#if H_3D
+  printf("BaseViewCameraNumbers        : %s\n", m_pchBaseViewCameraNumbers ); 
   printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision);
-
-#if HHI_VSO
+#if H_3D_VSO
   printf("Force use of Lambda Scale    : %d\n", m_bForceLambdaScaleVSO );
 
   if ( m_bUseVSO )
-  {
+  {    
     printf("VSO Lambda Scale             : %5.2f\n", m_dLambdaScaleVSO );
     printf("VSO Mode                     : %d\n",    m_uiVSOMode       );
     printf("VSO Config                   : %s\n",    m_pchVSOConfig    );
-#if HHI_VSO_DIST_INT
     printf("VSO Negative Distortion      : %d\n",    m_bAllowNegDist ? 1 : 0);
-#endif
-#if HHI_VSO_LS_TABLE_M23714
-    printf("VSO LS Table                 : %d\n",    m_bVSOLSTable ? 1 : 0);    
-#endif
-#if SAIT_VSO_EST_A0033
-    printf("VSO Estimated VSD            : %d\n",    m_bUseEstimatedVSD ? 1 : 0);        
-#endif
-#if LGE_VSO_EARLY_SKIP_A0093
-    printf("VSO Early Skip               : %d\n",    m_bVSOEarlySkip ? 1 : 0);    
-#endif
-   
-  }
-#endif
-#if HHI_INTERVIEW_SKIP
-    printf("InterView Skip:              : %d\n",    m_bInterViewSkip ? 1:0 );
-    printf("InterView Skip Lambda Scale  : %f\n",    m_dInterViewSkipLambdaScale );
-#endif
-
+    printf("VSO LS Table                 : %d\n",    m_bVSOLSTable ? 1 : 0);
+    printf("VSO Estimated VSD            : %d\n",    m_bUseEstimatedVSD ? 1 : 0);
+    printf("VSO Early Skip               : %d\n",    m_bVSOEarlySkip ? 1 : 0);   
+    if ( m_bUseWVSO )
+    printf("Dist. Weights (VSO/VSD/SAD)  : %d/%d/%d\n ", m_iVSOWeight, m_iVSDWeight, m_iDWeight );
+  }
+#endif //HHI_VSO
+#endif //H_3D
   printf("\n");
-  
-  printf("TOOL CFG General: ");  
-  printf("ALFMNF:%d ", m_iALFMaxNumberFilters);
-  printf("ALFInSlice:%d ", m_bALFParamInSlice);
-  printf("ALFPicEnc:%d ", m_bALFPicBasedEncode);
-  printf("IBD:%d ", !!g_uiBitIncrement);
+#if H_MV
+  printf("TOOL CFG General: ");
+#else
+  printf("TOOL CFG: ");
+#endif
+  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_useRDOQ            );
+  printf("RDQTS:%d ", m_useRDOQTS        );
+  printf("RDpenalty:%d ", m_rdPenalty  );
   printf("SQP:%d ", m_uiDeltaQpRD         );
   printf("ASR:%d ", m_bUseASR             );
-  printf("LComb:%d ", m_bUseLComb         );
-  printf("LCMod:%d ", m_bLCMod         );
   printf("FEN:%d ", m_bUseFastEnc         );
   printf("ECU:%d ", m_bUseEarlyCU         );
   printf("FDM:%d ", m_useFastDecisionForMerge );
   printf("CFM:%d ", m_bUseCbfFastMode         );
+  printf("ESD:%d ", m_useEarlySkipDetection  );
   printf("RQT:%d ", 1     );
-  printf("LMC:%d ", m_bUseLMChroma        ); 
-  printf("Slice: G=%d M=%d ", m_iSliceGranularity, m_iSliceMode);
-  if (m_iSliceMode!=0)
-  {
-    printf("A=%d ", m_iSliceArgument);
-  }
-  printf("EntropySlice: M=%d ",m_iEntropySliceMode);
-  if (m_iEntropySliceMode!=0)
-  {
-    printf("A=%d ", m_iEntropySliceArgument);
+  printf("TransformSkip:%d ",     m_useTransformSkip              );
+  printf("TransformSkipFast:%d ", m_useTransformSkipFast       );
+  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);
+#if !H_MV
+  printf("SAO:%d ", (m_bUseSAO)?(1):(0));
+#endif
   printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
-#if LGE_SAO_MIGRATION_D0091
   printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0));
-#else
-  printf("SAOInterleaving:%d ", (m_saoInterleavingFlag)?(1):(0));
-#endif
-#if LOSSLESS_CODING
+
   printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 );
-#endif  
-  printf("WPP:%d ", (Int)m_bUseWeightPred);
-  printf("WPB:%d ", m_uiBiPredIdc);
-  printf("TileLocationInSliceHdr:%d ", m_iTileLocationInSliceHeaderFlag);
-  printf("TileMarker:%d", m_iTileMarkerFlag);
-  if (m_iTileMarkerFlag)
-  {
-    printf("[%d] ", m_iMaxTileMarkerEntryPoints);
-  }
-  else
-  {
-    printf(" ");
-  }
-  printf(" WaveFrontSynchro:%d WaveFrontFlush:%d WaveFrontSubstreams:%d",
-          m_iWaveFrontSynchro, m_iWaveFrontFlush, m_iWaveFrontSubstreams);
+  printf("WPP:%d ", (Int)m_useWeightedPred);
+  printf("WPB:%d ", (Int)m_useWeightedBiPred);
+  printf("PME:%d ", m_log2ParallelMergeLevel);
+  printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d",
+          m_iWaveFrontSynchro, m_iWaveFrontSubstreams);
   printf(" ScalingList:%d ", m_useScalingListId );
-
-#if !TMVP_DEPTH_SWITCH
-  printf("TMVP:%d ", m_enableTMVP     );
-#endif
-
+  printf("TMVPMode:%d ", m_TMVPModeId     );
 #if ADAPTIVE_QP_SELECTION
-  printf("AQpS:%d", m_bUseAdaptQpSelect   );
-#endif
-
-  printf(" SignBitHidingFlag:%d SignBitHidingThreshold:%d", m_signHideFlag, m_signHidingThreshold);
-  printf("\n");
-  printf("TOOL CFG VIDEO  : ");
-  printf("ALF:%d ", (m_abUseALF [0] ? 1 : 0) );
-  printf("SAO:%d ", (m_abUseSAO [0] ? 1 : 0));
-  printf("RDQ:%d ", (m_abUseRDOQ[0] ? 1 : 0) );
-#if TMVP_DEPTH_SWITCH
-  printf("TMVP:%d ", (m_enableTMVP[0] ? 1 : 0) );
-#endif
-#if LGE_ILLUCOMP_B0045
-#if LGE_ILLUCOMP_DEPTH_C0046
-  printf("IlluCompEnable: %d %d", m_abUseIC[0] ? 1 : 0, m_abUseIC[1] ? 1 : 0);
-#else
-  printf("IlluCompEnable: %d ", m_bUseIC);
-#endif
-#endif
-#if INTER_VIEW_VECTOR_SCALING_C0115
-  printf("IVSEnable: %d ", m_bUseIVS);
-#endif
-#if QC_ARP_D0177
-  printf(" ARP:%d  " , m_nUseAdvResPred  );
-#endif
-  printf("\n");
-
-  printf("TOOL CFG DEPTH  : ");
-  printf("ALF:%d ", (m_abUseALF [1] ? 1 : 0));
-  printf("SAO:%d ", (m_abUseSAO [1] ? 1 : 0));
-  printf("RDQ:%d ", (m_abUseRDOQ[1] ? 1 : 0));
-#if TMVP_DEPTH_SWITCH
-  printf("TMVP:%d ", (m_enableTMVP[1] ? 1 : 0) );
-#endif
-#if FLEX_CODING_ORDER_M23723
-  printf("FCO:%d ",   (m_b3DVFlexOrder ? 1: 0));
-
-  if(m_b3DVFlexOrder)
-  {
-    printf("CodingOrder: %s ", m_pchMVCJointCodingOrder);
-  }
-#endif
-#if HHI_VSO
-  printf("VSO:%d ", m_bUseVSO             );
-#endif
-#if LGE_WVSO_A0119
-  printf("WVSO:%d ", m_bUseWVSO );
-#endif
-#if H3D_QTL
-  printf("QTLPC:%d ", m_bUseQTLPC);
-#endif
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-  printf("DMM:%d ", m_bUseDMM );
-#endif
-#if HHI_MPI
-  printf("MVI:%d ", m_bUseMVI ? 1 : 0 );
-#endif
-#if RWTH_SDC_DLT_B0036
-  printf("SDC:%d ", m_bUseSDC ? 1 : 0 );
-  printf("DLT:%d ", m_bUseDLT ? 1 : 0 );
-#endif
-
-#if MTK_D0156
-  printf("BVSP:%d ", m_bUseVSPCompensation ? 1 : 0 );
-  printf("DoNBDV:%d ",  m_bUseDVPRefine ? 1 : 0 );
-#endif
-
-#if LGE_WVSO_A0119
-  if ( m_bUseWVSO )
-    printf("\nVSO : VSD : SAD weight = %d : %d : %d ", m_iVSOWeight, m_iVSDWeight, m_iDWeight );
-#endif
-  printf("\n\n");
-  
+  printf("AQpS:%d ", m_bUseAdaptQpSelect   );
+#endif
+
+  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
+  printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
+#if H_3D_VSO
+  printf("VSO:%d ", m_bUseVSO   );
+  printf("WVSO:%d ", m_bUseWVSO );  
+#endif
+#if H_3D_QTLPC
+  printf("QTL:%d ", m_bUseQTL);
+  printf("PC:%d " , m_bUsePC );
+#endif
+#if H_3D_IV_MERGE
+  printf("IvMvPred:%d ", m_ivMvPredFlag );
+#endif
+#if H_3D_ARP
+  printf(" ARP:%d  ", m_uiUseAdvResPred  );
+#endif
+#if H_3D_IC
+  printf( "IlluCompEnable: %d %d ", m_abUseIC[0] ? 1 : 0, m_abUseIC[1] ? 1 : 0 );
+#endif
+#if H_3D_NBDV_REF
+  printf("DepthRefinement:%d ", m_depthRefinementFlag );  
+#endif
+#if H_3D_VSP
+  printf("ViewSynthesisPred:%d ", m_viewSynthesisPredFlag );
+#endif
+#if H_3D_TMVP
+  printf("IvMvScaling:%d ", m_ivMvScalingFlag ? 1 : 0  );
+#endif
+#if H_3D_DIM
+  printf("DMM:%d ", m_useDMM );
+  printf("RBC:%d ", m_useRBC );
+  printf("SDC:%d ", m_useSDC );
+  printf("DLT:%d ", m_useDLT );
+#endif
+#if LGE_INTER_SDC_E0156
+  printf( "interSDC: %d ", m_bDepthInterSDCFlag ? 1 : 0 );
+#endif
+  printf("\n\n");  
+
   fflush(stdout);
 }
 
-Void TAppEncCfg::xPrintUsage()
-{
-  printf( "          <name> = ALF - adaptive loop filter\n");
-  printf( "                   IBD - bit-depth increasement\n");
-  printf( "                   GPB - generalized B instead of P in low-delay mode\n");
-  printf( "                   HAD - hadamard ME for fractional-pel\n");
-  printf( "                   SRD - SBAC based RD estimation\n");
-  printf( "                   RDQ - RDOQ\n");
-  printf( "                   LDC - low-delay mode\n");
-  printf( "                   NRF - non-reference frame marking in last layer\n");
-  printf( "                   BQP - hier-P style QP assignment in low-delay mode\n");
-  printf( "                   PAD - automatic source padding of multiple of 16\n");
-  printf( "                   ASR - adaptive motion search range\n");
-  printf( "                   FEN - fast encoder setting\n");  
-  printf( "                   ECU - Early CU setting\n");
-  printf( "                   CFM - Cbf fast mode setting\n");
-  printf( "                   LMC - intra chroma prediction based on luma\n");
-  printf( "\n" );
-  printf( "  Example 1) TAppEncoder.exe -c test.cfg -q 32 -g 8 -f 9 -s 64 -h 4\n");
-  printf("              -> QP 32, hierarchical-B GOP 8, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n");
-  printf( "  Example 2) TAppEncoder.exe -c test.cfg -q 32 -g 4 -f 9 -s 64 -h 4 -1 LDC\n");
-  printf("              -> QP 32, hierarchical-P GOP 4, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n");
-}
-
-Bool confirmPara(Bool bflag, const char* message)
+Bool confirmPara(Bool bflag, const Char* message)
 {
   if (!bflag)
@@ -1784,68 +2309,3 @@
 }
 
-/* helper function */
-/* for handling "-1/-0 FOO" */
-void translateOldStyleCmdline(const char* value, po::Options& opts, const std::string& arg)
-{
-  const char* argv[] = {arg.c_str(), value};
-  /* replace some short names with their long name varients */
-  if (arg == "LDC")
-  {
-    argv[0] = "LowDelayCoding";
-  }
-  else if (arg == "RDQ")
-  {
-    argv[0] = "RDOQ";
-  }
-  else if (arg == "HAD")
-  {
-    argv[0] = "HadamardME";
-  }
-  else if (arg == "SRD")
-  {
-    argv[0] = "SBACRD";
-  }
-  else if (arg == "IBD")
-  {
-    argv[0] = "BitIncrement";
-  }
-  /* issue a warning for change in FEN behaviour */
-  if (arg == "FEN")
-  {
-    /* xxx todo */
-  }
-  po::storePair(opts, argv[0], argv[1]);
-}
-
-void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg)
-{
-  if (arg == "IBD")
-  {
-    translateOldStyleCmdline("4", opts, arg);
-    return;
-  }
-  translateOldStyleCmdline("1", opts, arg);
-}
-
-void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg)
-{
-  translateOldStyleCmdline("0", opts, arg);
-}
-
-Void TAppEncCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName)
-{
-  size_t iInLength     = strlen(pchInputFileName);
-  size_t iAppendLength = strlen(pchStringToAppend);
-
-  rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1);
-  Char* pCDot = strrchr(pchInputFileName,'.');
-  pCDot = pCDot ? pCDot : pchInputFileName + iInLength;
-  size_t iCharsToDot = pCDot - pchInputFileName ;
-  size_t iCharsToEnd = iInLength - iCharsToDot;
-  strncpy(rpchOutputFileName                            ,  pchInputFileName            , iCharsToDot  );
-  strncpy(rpchOutputFileName+ iCharsToDot               ,  pchStringToAppend           , iAppendLength);
-  strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength ,  pchInputFileName+iCharsToDot, iCharsToEnd  );
-  rpchOutputFileName[iInLength+iAppendLength] = '\0';
-}
-
 //! \}
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 443)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 608)
@@ -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,12 +42,10 @@
 
 #include "TLibEncoder/TEncCfg.h"
+#include <sstream>
+#if H_3D
 #include "TAppCommon/TAppComCamPara.h"
-#include "TLibRenderer/TRenTop.h"
 #include "TLibRenderer/TRenModel.h"
 #include "TLibRenderer/TRenModSetupStrParser.h"
-
-#include <sstream>
-#include <vector>
-
+#endif
 //! \ingroup TAppEncoder
 //! \{
@@ -62,60 +60,124 @@
 protected:
   // file I/O
+#if H_MV
   std::vector<char*>     m_pchInputFileList;                  ///< source file names
-  std::vector<char*>     m_pchDepthInputFileList;             ///< source depth file names
+#else
+  Char*     m_pchInputFile;                                   ///< source file name
+#endif
+  Char*     m_pchBitstreamFile;                               ///< output bitstream file
+#if H_MV
   std::vector<char*>     m_pchReconFileList;                  ///< output reconstruction file names
-  std::vector<char*>     m_pchDepthReconFileList;             ///< output depth reconstruction file names
-  char*     m_pchBitstreamFile;                               ///< output bitstream file
+  Int                    m_numberOfLayers;                    ///< number of Layers to Encode
+#if H_3D
+  Int                    m_iNumberOfViews;                    ///< number of Layers that are views
+#endif
+#else
+  Char*     m_pchReconFile;                                   ///< output reconstruction file
+#endif
+  #if H_MV
+// VPS specification
+  std::vector< std::vector<Int> > m_dimIds;                   ///< dimension ids ( pointers to m_viewId and m_depthFlag 
+  std::vector<Int>       m_viewId;                            ///< view id
+#if H_3D
+  std::vector<Int>       m_depthFlag;                         ///< depth flag
+#endif
+  std::vector<Int>       m_layerIdInNuh;                      ///< layer Id in Nuh for each layer 
+  Bool                   m_splittingFlag;                     ///< Splitting Flag
+  Int                    m_scalabilityMask;                   ///< Mask indicating scalabilities, 1: texture; 3: texture + depth                                                                
+  std::vector<Int>       m_dimensionIdLen;                    ///< Length of scalability dimension s 
+  
+// layer sets   
+  Int                    m_vpsNumLayerSets;                   ///< Number of layer sets
+  std::vector< std::vector<Int> > m_layerIdsInSets;           ///< LayerIds in vps of layer set 
+  Bool                   m_defaultOneTargetOutputLayerFlag;   ///< Output highest layer of layer sets by default  
+  std::vector<Int>       m_outputLayerSetIdx;                 ///< Indices of layer sets used as additional output layer sets  
+  std::vector< std::vector<Int> > m_layerIdsInAddOutputLayerSet; ///< LayerIds in vps of additional output layers
+  std::vector<Int>       m_profileLevelTierIdx;               ///< Indices of of profile level tier
+  
+  // Dependencies
+  std::vector< std::vector<Int> > m_directRefLayers;          ///< LayerIds of direct reference layers
+  std::vector< std::vector<Int> > m_dependencyTypes;          ///< Dependency types of direct reference layers
+
+#if H_3D_IV_MERGE
+  Bool                   m_ivMvPredFlag;                      ///< Interview motion vector prediction 
+#endif
+#if H_3D_ARP                                                  /// < flag and number of weighting factors in ARP
+  UInt                   m_uiUseAdvResPred;
+  UInt                   m_uiARPStepNum;
+#endif
+#if H_3D_IC
+  vector<Bool> m_abUseIC;                                    ///< flag for using illumination compensation for inter-view prediction
+#endif
+#if H_3D_NBDV_REF
+  Bool m_depthRefinementFlag;  
+#endif
+#if H_3D_VSP
+  Bool m_viewSynthesisPredFlag;
+#endif
+#if H_3D_TMVP
+  Bool m_ivMvScalingFlag; 
+#endif
+#endif
   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
   
-  Int       m_iNumberOfViews;                                 ///< number Views to Encode
-  Bool      m_bUsingDepthMaps;
-  
-#if FLEX_CODING_ORDER_M23723
-  Char*  m_pchMVCJointCodingOrder;      ///<  texture-depth coding order
-  Bool    m_b3DVFlexOrder;    ///<  flexible coding order flag
-#endif
-
+  // profile/level
+  Profile::Name m_profile;
+  Level::Tier   m_levelTier;
+  Level::Name   m_level;
+  Bool m_progressiveSourceFlag;
+  Bool m_interlacedSourceFlag;
+  Bool m_nonPackedConstraintFlag;
+  Bool m_frameOnlyConstraintFlag;
+  
   // coding structure
   Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
   Int       m_iDecodingRefreshType;                           ///< random access type
   Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
-  Int       m_extraRPSs[MAX_VIEW_NUM];
-  GOPEntryMvc m_GOPListsMvc[MAX_VIEW_NUM][MAX_GOP+1];
-  Int       m_numReorderPics[MAX_VIEW_NUM][MAX_TLAYER];       ///< total number of reorder pictures
-  Int       m_maxDecPicBuffering[MAX_VIEW_NUM][MAX_TLAYER];   ///< total number of reference pictures needed for decoding
-  Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
-  Bool      m_bLCMod;                                         ///< flag for specifying whether the combined reference list for uni-prediction in B-slices is uploaded explicitly
-  Bool      m_bDisInter4x4;
-  Bool      m_enableNSQT;                                     ///< flag for enabling NSQT
+#if H_MV
+  Int       m_extraRPSsMvc[MAX_NUM_LAYERS];                       ///< extra RPSs added to handle CRA for each layer
+  std::vector< GOPEntry* >  m_GOPListMvc;                            ///< the coding structure entries from the config file for each layer 
+  Int       m_numReorderPicsMvc[MAX_NUM_LAYERS][MAX_TLAYER];      ///< total number of reorder pictures for each layer
+  Int       m_maxDecPicBufferingMvc[MAX_NUM_LAYERS][MAX_TLAYER];  ///< total number of reference pictures needed for decoding for each layer
+#else
+  Int       m_extraRPSs;                                      ///< extra RPSs added to handle CRA
+  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
+  Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
+  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of pictures in the decoded picture buffer
+  #endif
+  Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
+  Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
   Bool      m_enableAMP;
   // coding quality
-  std::vector<Double>  m_adQP;                                ///< QP value of key-picture (floating point) [0] video, [1] depth
-  std::vector<Int>     m_aiQP;                                ///< QP value of key-picture (integer) [0] video, [1] depth
-#if QC_MVHEVC_B0046
-  std::vector<Int>     m_aiVId;                                ///< view id
-#endif
-  Int       m_aiTLayerQPOffset[MAX_TLAYER];                   ///< QP offset corresponding to temporal layer depth
-  char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
+#if H_MV
+  std::vector<Double>  m_fQP;                                 ///< QP value of key-picture (floating point) for each layer
+  std::vector<Int>     m_iQP;                                 ///< QP value of key-picture (integer) for each layer
+#else
+  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
+  Int       m_iQP;                                            ///< QP value of key-picture (integer)
+#endif
+  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
+#if H_MV
+  std::vector<Int*> m_aidQP;                                    ///< array of slice QP values for each layer
+#else
   Int*      m_aidQP;                                          ///< array of slice QP values
-  Int*      m_aidQPdepth;                                     ///< array of depth slice QP values
+#endif
   Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
   UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
   Int       m_iMaxCuDQPDepth;                                 ///< Max. depth for a minimum CuDQPSize (0:default)
 
-  Int       m_iChromaQpOffset;                                 ///< ChromaQpOffset    (0:default) 
-  Int       m_iChromaQpOffset2nd;                              ///< ChromaQpOffset2nd (0:default)
+  Int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default) 
+  Int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
 
 #if ADAPTIVE_QP_SELECTION
@@ -126,5 +188,9 @@
   Int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
   
-  Int       m_maxTempLayer[MAX_VIEW_NUM];                     ///< Max temporal layer
+#if H_MV
+  Int       m_maxTempLayerMvc[MAX_NUM_LAYER_IDS];             ///< Max temporal layer for each layer
+#else
+  Int       m_maxTempLayer;                                  ///< Max temporal layer
+#endif
 
   // coding unit (CU) definition
@@ -141,50 +207,36 @@
   
   // 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)
-#if LOSSLESS_CODING
   Bool      m_useLossless;                                    ///< flag for using lossless coding
-#endif
-  vector<Bool> m_abUseSAO;
-#if LGE_ILLUCOMP_B0045
-#if LGE_ILLUCOMP_DEPTH_C0046
-  vector<Bool> m_abUseIC;                                    ///< flag for using illumination compensation for inter-view prediction
-#else
-  Bool      m_bUseIC;                                     ///< flag for using illumination compensation for inter-view prediction
-#endif
-#endif
-#if INTER_VIEW_VECTOR_SCALING_C0115
-  Bool      m_bUseIVS;                                        ///< flag for using inter-view vector scaling
+#if H_MV
+  std::vector<Bool> m_bUseSAO; 
+#else
+  Bool      m_bUseSAO; 
 #endif
   Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
-#if LGE_SAO_MIGRATION_D0091
   Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
   Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
-#else
-  Bool      m_saoInterleavingFlag;                            ///< SAO interleaving flag
-#endif
   // coding tools (loop filter)
-  vector<Bool> m_abUseALF;                                    ///< flag for using adaptive loop filter [0] - video, [1] - depth
-  Int       m_iALFEncodePassReduction;                        //!< ALF encoding pass, 0 = original 16-pass, 1 = 1-pass, 2 = 2-pass
-  
-  Int       m_iALFMaxNumberFilters;                           ///< ALF Max Number Filters in one picture
-  Bool      m_bALFParamInSlice;
-  Bool      m_bALFPicBasedEncode;
-
-  vector<Bool> m_abLoopFilterDisable;                         ///< flag for using deblocking filter filter [0] - video, [1] - depth
-  Bool      m_loopFilterOffsetInAPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = APS
+#if H_MV
+  std::vector<Bool> m_bLoopFilterDisable;                     ///< flag for using deblocking filter for each layer
+#else
+  Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
+#endif
+  Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
   Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
   Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
   Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
+  Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
  
-  Bool      m_bUseLMChroma;                                  ///< JL: Chroma intra prediction based on luma signal
-
   // coding tools (PCM)
   Bool      m_usePCM;                                         ///< flag for using IPCM
@@ -197,142 +249,191 @@
   Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
   Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
-vector<Bool> m_abUseRDOQ;                                   ///< flag for using RD optimized quantization [0]-video, [1]-depth
+  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
+  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
+  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) 
   Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
   Int       m_iSearchRange;                                   ///< ME search range
-#if DV_V_RESTRICTION_B0037
-  Bool      m_bUseDisparitySearchRangeRestriction;            ///< restrict vertical search range for inter-view prediction
-  Int       m_iVerticalDisparitySearchRange;                  ///< ME vertical search range for inter-view prediction 
-#endif
   Int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
   Bool      m_bUseFastEnc;                                    ///< flag for using fast encoder setting
-#if HHI_INTERVIEW_SKIP
-  Bool      m_bInterViewSkip;                            ///< usage of interview skip mode ( do not transmit residual)
-#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
-  Double    m_dInterViewSkipLambdaScale;                 ///< lambda scale for interview skip
-#endif
-#endif
   Bool      m_bUseEarlyCU;                                    ///< flag for using Early CU setting
-
-#if DEPTH_MAP_GENERATION
-  UInt      m_uiPredDepthMapGeneration;                       ///< using of (virtual) depth maps for texture coding
-#endif
-#if H3D_IVMP
-  UInt      m_uiMultiviewMvPredMode;                          ///< usage of predictors for multi-view mv prediction
-  UInt      m_uiMultiviewMvRegMode;                           ///< regularization for multiview motion vectors
-  Double    m_dMultiviewMvRegLambdaScale;                     ///< lambda scale for multiview motion vectors regularization
-#endif
-#if H3D_IVRP 
-#if QC_ARP_D0177
-  UInt      m_nUseAdvResPred;
-#else
-  UInt      m_uiMultiviewResPredMode;          ///< using multiview residual prediction
-#endif
-#endif
-
-  Bool      m_useFastDecisionForMerge;         ///< flag for using Fast Decision Merge RD-Cost 
-  Bool      m_bUseCbfFastMode;                 ///< flag for using Cbf Fast PU Mode Decision
-  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_iEntropySliceMode;               ///< 0: Disable all entropy slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based entropy slice
-  Int       m_iEntropySliceArgument;           ///< If m_iEntropySliceMode==1, m_iEntropySliceArgument=max. # of largest coding units. If m_iEntropySliceMode==2, m_iEntropySliceArgument=max. # of bins.
-
-  Int       m_iSliceGranularity;               ///< 0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.
-  Bool      m_bLFCrossSliceBoundaryFlag;       ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
-  Int       m_iTileBehaviorControlPresentFlag; //!< 1: tile behavior control parameters are in PPS 0: tile behavior control parameters are not in PPS
-  Bool      m_bLFCrossTileBoundaryFlag;        //!< 1: Cross-tile-boundary in-loop filtering 0: non-cross-tile-boundary in-loop filtering
-  Int       m_iColumnRowInfoPresent;
+  Bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost 
+  Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
+  Bool      m_useEarlySkipDetection;                         ///< flag for using Early SKIP Detection
+  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;
-  Int       m_iTileLocationInSliceHeaderFlag; //< enable(1)/disable(0) transmitssion of tile location in slice header
-  Int       m_iTileMarkerFlag;              //< enable(1)/disable(0) transmitssion of light weight tile marker
-  Int       m_iMaxTileMarkerEntryPoints;    //< maximum number of tile markers allowed in a slice (controls degree of parallelism)
-  Double    m_dMaxTileMarkerOffset;         //< Calculated offset. Light weight tile markers will be transmitted for TileIdx= Offset, 2*Offset, 3*Offset ... 
-
+  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.
-  Int       m_iWaveFrontFlush; //< enable(1)/disable(0) the CABAC flush at the end of each line of LCUs.
   Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
 
   Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
   
-  bool m_pictureDigestEnabled; ///< enable(1)/disable(0) md5 computation and SEI signalling
-
+  Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
+  Int       m_recoveryPointSEIEnabled;
+  Int       m_bufferingPeriodSEIEnabled;
+  Int       m_pictureTimingSEIEnabled;
+  Bool      m_toneMappingInfoSEIEnabled;
+  Int       m_toneMapId;
+  Bool      m_toneMapCancelFlag;
+  Bool      m_toneMapPersistenceFlag;
+  Int       m_toneMapCodedDataBitDepth;
+  Int       m_toneMapTargetBitDepth;
+  Int       m_toneMapModelId; 
+  Int       m_toneMapMinValue;
+  Int       m_toneMapMaxValue;
+  Int       m_sigmoidMidpoint;
+  Int       m_sigmoidWidth;
+  Int       m_numPivots;
+  Int       m_cameraIsoSpeedIdc;
+  Int       m_cameraIsoSpeedValue;
+  Int       m_exposureCompensationValueSignFlag;
+  Int       m_exposureCompensationValueNumerator;
+  Int       m_exposureCompensationValueDenomIdc;
+  Int       m_refScreenLuminanceWhite;
+  Int       m_extendedRangeWhiteLevel;
+  Int       m_nominalBlackLevelLumaCodeValue;
+  Int       m_nominalWhiteLevelLumaCodeValue;
+  Int       m_extendedWhiteLevelLumaCodeValue;
+  Int*      m_startOfCodedInterval;
+  Int*      m_codedPivotValue;
+  Int*      m_targetPivotValue;
+  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;
+  Int       m_SOPDescriptionSEIEnabled;
+  Int       m_scalableNestingSEIEnabled;
   // weighted prediction
-  Bool      m_bUseWeightPred;                                 ///< Use of explicit Weighting Prediction for P_SLICE
-  UInt      m_uiBiPredIdc;                                    ///< Use of Bi-Directional Weighting Prediction (B_SLICE): explicit(1) or implicit(2)
-
-#if TMVP_DEPTH_SWITCH
-  vector<Bool> m_enableTMVP;                                  ///< Enable TMVP [0] video, [1] depth
-#else
-  Bool      m_enableTMVP;
-#endif
-
+  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
+  UInt      m_maxNumMergeCand;                                ///< Max number of merge candidates
+
+  Int       m_TMVPModeId;
   Int       m_signHideFlag;
-  Int       m_signHidingThreshold;
-#if HHI_MPI
-  Bool      m_bUseMVI;  ///< flag for using Motion Vector Inheritance for depth map coding
-#endif
-#if RWTH_SDC_DLT_B0036
-  Bool      m_bUseDLT;
-  Bool      m_bUseSDC;
-#endif
-
+#if RATE_CONTROL_LAMBDA_DOMAIN
+  Bool      m_RCEnableRateControl;                ///< enable rate control or not
+  Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
+#if M0036_RC_IMPROVEMENT
+  Int       m_RCKeepHierarchicalBit;              ///< 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation
+#else
+  Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
+#endif
+  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
-
-  // camera parameter
+  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.
+
+  Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
+  Bool      m_useStrongIntraSmoothing;                        ///< enable strong intra smoothing for 32x32 blocks where the reference samples are flat
+  Int       m_activeParameterSetsSEIEnabled;
+
+  Bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
+  Bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
+  Int       m_aspectRatioIdc;                                 ///< aspect_ratio_idc
+  Int       m_sarWidth;                                       ///< horizontal size of the sample aspect ratio
+  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 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
+  Bool      m_videoFullRangeFlag;                             ///< Indicates the black level and range of luma and chroma signals
+  Bool      m_colourDescriptionPresentFlag;                   ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present
+  Int       m_colourPrimaries;                                ///< Indicates chromaticity coordinates of the source primaries
+  Int       m_transferCharacteristics;                        ///< Indicates the opto-electronic transfer characteristics of the source
+  Int       m_matrixCoefficients;                             ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries
+  Bool      m_chromaLocInfoPresentFlag;                       ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present
+  Int       m_chromaSampleLocTypeTopField;                    ///< Specifies the location of chroma samples for top field
+  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
+
+#if H_3D
+  // Camera parameters
   Char*     m_pchCameraParameterFile;                         ///< camera parameter file
   Char*     m_pchBaseViewCameraNumbers;
-#if !QC_MVHEVC_B0046
   TAppComCamPara m_cCameraData;
-#endif
   Int       m_iCodedCamParPrecision;                          ///< precision for coding of camera parameters
-
-#if HHI_VSO
+#if H_3D_VSO
   Char*     m_pchVSOConfig;
   Bool      m_bUseVSO;                                    ///< flag for using View Synthesis Optimization
-#if HHI_VSO_LS_TABLE_M23714
   Bool      m_bVSOLSTable;                                ///< Depth QP dependent Lagrange parameter optimization (m23714)
-#endif
-#if LGE_VSO_EARLY_SKIP_A0093
   Bool      m_bVSOEarlySkip;                              ///< Early skip of VSO computation (JCT3V-A0093 modification 4)
-#endif
+
   //// Used for development by GT, might be removed later
   Double    m_dLambdaScaleVSO;                            ///< Scaling factor for Lambda in VSO mode
   Bool      m_bForceLambdaScaleVSO;                       ///< Use Lambda Scale for depth even if VSO is turned off
-#if HHI_VSO_DIST_INT
   Bool      m_bAllowNegDist;                              ///< Allow negative distortion in VSO
-#endif
   UInt      m_uiVSOMode;                                  ///< Number of VSO Mode, 1 = , 2 = simple, org vs. ren, 3 = simple, ren vs. ren, 4 = full  
-#endif
-#if SAIT_VSO_EST_A0033
+
+  // SAIT_VSO_EST_A0033
   Bool      m_bUseEstimatedVSD;                           ///< Flag for using model based VSD estimation instead of VSO for some encoder decisions (JCT3V-A0033 modification 3)  
-#endif
-#if LGE_WVSO_A0119
+
+  // LGE_WVSO_A0119
   Bool      m_bUseWVSO;                                    ///< flag for using View Synthesis Optimization  
   Int       m_iVSOWeight;
   Int       m_iVSDWeight;
   Int       m_iDWeight;
-#endif
-  // coding tools (depth intra modes)
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-  Bool      m_bUseDMM;                                        ///< flag for using DMM
-#endif
-
-#if H3D_QTL
-  Bool      m_bUseQTLPC;                                      ///< flag for using depth QuadTree Limitation + Predictive Coding
-#endif
-
-#if MTK_D0156
-
-#if MERL_VSP_COMPENSATION_C0152
-  Bool      m_bUseVSPCompensation;
-#endif
-
-  Bool      m_bUseDVPRefine;
-#endif
-
+
+  // Ren Model String
+  TRenModSetupStrParser       m_cRenModStrParser;
+#endif
+#if H_3D_DIM
+  Bool      m_useDMM;                                        ///< flag for using DMM
+  Bool      m_useRBC;                                        ///< flag for using RBC
+  Bool      m_useSDC;                                        ///< flag for using SDC
+  Bool      m_useDLT;                                        ///< flag for using DLT
+#endif
+#if H_3D_QTLPC
+  Bool      m_bUseQTL;                                        ///< flag for using depth QuadTree Limitation
+  Bool      m_bUsePC;                                         ///< flag for using Predictive Coding with QTL
+#endif
+#if LGE_INTER_SDC_E0156
+  Bool m_bDepthInterSDCFlag;                                ///< flag for inter SDC of depth map coding
+#endif
+#endif
   // internal member functions
   Void  xSetGlobal      ();                                   ///< set global variables
@@ -340,21 +441,45 @@
   Void  xPrintParameter ();                                   ///< print configuration values
   Void  xPrintUsage     ();                                   ///< print usage
-  
-  Void  xCleanUpVectors ();                                   ///< clean up vector sizes
-  Void  xInitCameraPars ();                                   ///< init camera parameters
-
-
-  // set MVD Parameters and LUTs
-  Void xSetShiftParameters();
-  Void xGetShiftParameter( UInt uiSourceView, UInt uiTargetView, bool bExternal, double& rdScale, double& rdOffset ); ///< Get one Shift Parameters
-
-  Void  xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char* & rpchOutputFileName);
-
-  Void  xCheckCodingStructureMvc();                           ///< validate and configure inter-view coding structure
-
-  template <class T> Void xCleanUpVector( std::vector<T>& rcVec, const T& rcInvalid );
-#if HHI_VSO
-  // Ren Model String
-  TRenModSetupStrParser       m_cRenModStrParser;
+#if H_MV
+  template <typename T>
+  Void xResizeVector(  std::vector<T> & rpcVector )
+  {
+    for( Int layer = 0; rpcVector.size() < m_numberOfLayers; layer++ )
+    {
+      assert( rpcVector.size() > 0 );
+      rpcVector.push_back( rpcVector[layer] );      
+    }
+
+    for( ; rpcVector.size() > m_numberOfLayers; )
+    {      
+      rpcVector.pop_back( );      
+    }
+  }
+
+  template <typename T>
+  Void xPrintParaVector( std::string description, std::vector<T> & rpcVector )
+  {
+    Int iSpace = max(1, ENC_CFG_CONSOUT_SPACE - (Int) description.length() ); 
+    
+    for ( Int i = 0; i < iSpace; i++ ) 
+      description.append( " " ); 
+      
+    description.append( ":" ); 
+    printf( "%s", description.c_str() ); 
+
+    for(Int i=0;i<rpcVector.size();i++)                
+      xPrintVectorElem( rpcVector[i] );
+
+    printf("\n");
+  }
+  
+  Void xPrintVectorElem( UInt   elem ) { printf(" %d"   , elem            );};
+  Void xPrintVectorElem( Int    elem ) { printf(" %d"   , elem            );};
+  
+  Void xPrintVectorElem( Double elem ) { printf(" %5.2f", elem            );};  
+  Void xPrintVectorElem( Bool   elem ) { printf(" %d"   , ( elem ? 1 : 0 ));};
+#endif
+#if H_MV
+  Int   getGOPSize() { return m_iGOPSize; }
 #endif
 public:
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 443)
+++ trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 608)
@@ -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.
  *
@@ -57,4 +57,7 @@
 TAppEncTop::TAppEncTop()
 {
+#if !H_MV
+  m_iFrameRcvd = 0;
+#endif
   m_totalBytes = 0;
   m_essentialBytes = 0;
@@ -67,692 +70,448 @@
 Void TAppEncTop::xInitLibCfg()
 {
-#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
-#if !QC_MVHEVC_B0046
-  UInt layerId = 0;
-#endif
-  // TODO: fix the assumption here that the temporal structures are all equal across all layers???
-  m_cVPS.setMaxTLayers( m_maxTempLayer[0] );
-#if QC_MVHEVC_B0046
-  m_cVPS.setMaxLayers( m_iNumberOfViews );
-#else
-  m_cVPS.setMaxLayers( m_iNumberOfViews * (m_bUsingDepthMaps ? 2:1) );
-#endif
+#if H_MV
+  TComVPS& vps = m_vps;   
+#else
+  TComVPS vps;
+#endif
+  
+#if H_MV
+  Int maxTempLayer = -1; 
+  for (Int j = 0; j < m_numberOfLayers; j++)
+  {
+    maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer ); 
+  }
+
+  vps.setMaxTLayers                       ( maxTempLayer );
+  if ( maxTempLayer )
+  {
+    vps.setTemporalNestingFlag(true);
+  }
+  vps.setMaxLayers( m_numberOfLayers );
   for(Int i = 0; i < MAX_TLAYER; i++)
   {
-    m_cVPS.setNumReorderPics( m_numReorderPics[0][i], i );
-    m_cVPS.setMaxDecPicBuffering( m_maxDecPicBuffering[0][i], i );
-  }
-#endif
-  
-  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-  {
-    m_frameRcvd.push_back(0);
-    m_acTEncTopList.push_back(new TEncTop); 
+    Int maxNumReOrderPics  = 0; 
+    Int maxDecPicBuffering = 0;
+    for (Int j = 0; j < m_numberOfLayers; j++)
+    {
+      maxNumReOrderPics  = max( maxNumReOrderPics,  m_numReorderPicsMvc    [ j ][ i ] );     
+      maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] );     
+    }
+
+    vps.setNumReorderPics                 ( maxNumReOrderPics  ,i );
+    vps.setMaxDecPicBuffering             ( maxDecPicBuffering ,i );
+  }
+#else
+  vps.setMaxTLayers                       ( m_maxTempLayer );
+  if (m_maxTempLayer == 1)
+  {
+    vps.setTemporalNestingFlag(true);
+  }
+  vps.setMaxLayers                        ( 1 );
+  for(Int i = 0; i < MAX_TLAYER; i++)
+  {
+    vps.setNumReorderPics                 ( m_numReorderPics[i], i );
+    vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
+  }
+#endif
+#if H_MV
+  xSetLayerIds             ( vps );   
+  xSetDimensionIdAndLength ( vps );
+  xSetDependencies( vps );
+  xSetProfileTierLevel     ( vps ); 
+  xSetLayerSets            ( vps ); 
+#if H_3D
+  vps.initViewIndex(); 
+  xSetVPSExtension2        ( vps ); 
+  m_ivPicLists.setVPS      ( &vps ); 
+#endif
+
+  for(Int layer = 0; layer < m_numberOfLayers; layer++)
+  {
+    m_frameRcvd                 .push_back(0);
+    m_acTEncTopList             .push_back(new TEncTop); 
     m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
     m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
-    m_picYuvRec.push_back(new TComList<TComPicYuv*>) ;
-
-    m_acTEncTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
-    m_acTEncTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
-    m_acTEncTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
-    m_acTEncTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
-    m_acTEncTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
-    m_acTEncTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
-    m_acTEncTopList[iViewIdx]->setCropRight                    ( m_cropRight );
-    m_acTEncTopList[iViewIdx]->setCropTop                      ( m_cropTop );
-    m_acTEncTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
-    m_acTEncTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
-    m_acTEncTopList[iViewIdx]->setViewId                       ( iViewIdx );
-    m_acTEncTopList[iViewIdx]->setIsDepth                      ( false );
-#if QC_MVHEVC_B0046
-    m_acTEncTopList[iViewIdx]->setLayerId                      ( iViewIdx );
-    m_cVPS.setViewId                                           ( m_aiVId[ iViewIdx ], iViewIdx );
-#else
-    m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
-#if VIDYO_VPS_INTEGRATION
-    layerId = iViewIdx * (m_bUsingDepthMaps ? 2:1);
-    m_acTEncTopList[iViewIdx]->setLayerId                      ( layerId );
-    m_cVPS.setDepthFlag                                        ( false, layerId );
-    m_cVPS.setViewId                                           ( iViewIdx, layerId );
-    m_cVPS.setViewOrderIdx                                     ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId );
-    // TODO: set correct dependentFlag and dependentLayer
-    m_cVPS.setDependentFlag                                    ( iViewIdx ? true:false, layerId );
-    m_cVPS.setDependentLayer                                   ( layerId - (m_bUsingDepthMaps ? 2:1), layerId );
-#if INTER_VIEW_VECTOR_SCALING_C0115
-    m_cVPS.setIVScalingFlag                                    ( m_bUseIVS );
-#endif
-#endif
+    m_picYuvRec                 .push_back(new TComList<TComPicYuv*>) ;
+
+    m_ivPicLists.push_back( m_acTEncTopList[ layer ]->getListPic()  ); 
+    TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ];  // It is not a member, but this name helps avoiding code duplication !!!
     
-    m_acTEncTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
-    m_acTEncTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
-    m_acTEncTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
-    m_acTEncTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
-#endif   
-
+    m_cTEncTop.setLayerIdInVps                 ( layer ); 
+    m_cTEncTop.setLayerId                      ( vps.getLayerIdInNuh( layer ) );    
+    m_cTEncTop.setViewId                       ( vps.getViewId      ( layer ) );
+#if H_3D
+    Bool isDepth = ( vps.getDepthId     ( layer ) != 0 ) ;
+    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   ( layer ) );
+    m_cTEncTop.setIsDepth                      ( isDepth );
+    //====== Camera Parameters =========
+    m_cTEncTop.setCameraParameters             ( &m_cCameraData );     
+    m_cTEncTop.setCamParPrecision              ( isDepth ? false : m_cCameraData.getCamParsCodedPrecision  () );
+    m_cTEncTop.setCamParInSliceHeader          ( isDepth ? 0     : m_cCameraData.getVaryingCameraParameters() );
+    m_cTEncTop.setCodedScale                   ( isDepth ? 0     : m_cCameraData.getCodedScale             () );
+    m_cTEncTop.setCodedOffset                  ( isDepth ? 0     : m_cCameraData.getCodedOffset            () );
+#if H_3D_VSO
+    //====== VSO =========
+    m_cTEncTop.setRenderModelParameters        ( &m_cRenModStrParser ); 
+    m_cTEncTop.setForceLambdaScaleVSO          ( isDepth ? m_bForceLambdaScaleVSO : false );
+    m_cTEncTop.setLambdaScaleVSO               ( isDepth ? m_dLambdaScaleVSO      : 1     );
+    m_cTEncTop.setVSOMode                      ( isDepth ? m_uiVSOMode            : 0     );
+
+    m_cTEncTop.setAllowNegDist                 ( isDepth ? m_bAllowNegDist        : false );
+
+    // SAIT_VSO_EST_A0033
+    m_cTEncTop.setUseEstimatedVSD              ( isDepth ? m_bUseEstimatedVSD     : false );
+
+    // LGE_WVSO_A0119
+    m_cTEncTop.setUseWVSO                      ( isDepth ? m_bUseWVSO             : false );   
+    m_cTEncTop.setVSOWeight                    ( isDepth ? m_iVSOWeight           : 0     );
+    m_cTEncTop.setVSDWeight                    ( isDepth ? m_iVSDWeight           : 0     );
+    m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
+#endif // H_3D_VSO
+#if H_3D_ARP
+    //====== Advanced Inter-view Residual Prediction =========
+    m_cTEncTop.setUseAdvRP                     ( ( isDepth || 0==layer ) ? 0 : m_uiUseAdvResPred );
+    m_cTEncTop.setARPStepNum                   ( ( isDepth || 0==layer ) ? 1 : H_3D_ARP_WFNR     );
+#endif
+#if H_3D_IC
+    m_cTEncTop.setUseIC                        ( vps.getViewIndex( layer ) == 0 ? false : m_abUseIC[isDepth ? 1 : 0] );
+#endif
+  //========== Depth intra modes ==========
+#if H_3D_DIM
+    m_cTEncTop.setUseDMM                       ( isDepth ? m_useDMM               : false );
+    m_cTEncTop.setUseRBC                       ( isDepth ? m_useRBC               : false );
+    m_cTEncTop.setUseSDC                       ( isDepth ? m_useSDC               : false );
+    m_cTEncTop.setUseDLT                       ( isDepth ? m_useDLT               : false );
+#endif
+#if H_3D_QTLPC
+    m_cTEncTop.setUseQTL                       ( isDepth ? m_bUseQTL               : false );
+    m_cTEncTop.setUsePC                        ( isDepth ? m_bUsePC                : false );
+#endif
+    //====== Depth Inter SDC =========
+#if LGE_INTER_SDC_E0156
+    m_cTEncTop.setInterSDCEnable               ( isDepth ? m_bDepthInterSDCFlag    : false );
+#endif
+#endif // H_3D
+
+    m_cTEncTop.setIvPicLists                   ( &m_ivPicLists ); 
+#endif // H_MV
+  m_cTEncTop.setVPS(&vps);
+
+  m_cTEncTop.setProfile(m_profile);
+  m_cTEncTop.setLevel(m_levelTier, m_level);
+  m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
+  m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
+  m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
+  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
+  
+  m_cTEncTop.setFrameRate                    ( m_iFrameRate );
+  m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
+  m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
+  m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
+  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
+  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
+  
   //====== Coding Structure ========
-    m_acTEncTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
-    m_acTEncTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
-    m_acTEncTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
-    m_acTEncTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
-    m_acTEncTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
-    for(Int i = 0; i < MAX_TLAYER; i++)
-    {
-      m_acTEncTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
-      m_acTEncTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
-    }
-    for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
-    {
-      m_acTEncTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
-    }
-    m_acTEncTopList[iViewIdx]->setQP                           ( m_aiQP[0] );
-  
-    m_acTEncTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
-    m_acTEncTopList[iViewIdx]->setPad                          ( m_aiPad );
-    
-    m_acTEncTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
-
-    m_acTEncTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
-  
-    m_acTEncTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
-    m_acTEncTopList[iViewIdx]->setUseAMP( m_enableAMP );
+  m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
+  m_cTEncTop.setDecodingRefreshType          ( m_iDecodingRefreshType );
+  m_cTEncTop.setGOPSize                      ( m_iGOPSize );
+#if H_MV
+  m_cTEncTop.setGopList                      ( m_GOPListMvc[layer] );
+  m_cTEncTop.setExtraRPSs                    ( m_extraRPSsMvc[layer] );
+  for(Int i = 0; i < MAX_TLAYER; i++)
+  {
+    m_cTEncTop.setNumReorderPics             ( m_numReorderPicsMvc[layer][i], i );
+    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBufferingMvc[layer][i], i );
+  }
+#else
+  m_cTEncTop.setGopList                      ( m_GOPList );
+  m_cTEncTop.setExtraRPSs                    ( m_extraRPSs );
+  for(Int i = 0; i < MAX_TLAYER; i++)
+  {
+    m_cTEncTop.setNumReorderPics             ( m_numReorderPics[i], i );
+    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
+  }
+#endif
+  for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
+  {
+    m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
+  }
+#if H_MV
+  m_cTEncTop.setQP                           ( m_iQP[layer] );
+#else
+  m_cTEncTop.setQP                           ( m_iQP );
+#endif
+
+  m_cTEncTop.setPad                          ( m_aiPad );
+
+#if H_MV
+  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayerMvc[layer] );
+#else
+  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
+#endif
+  m_cTEncTop.setUseAMP( m_enableAMP );
   
   //===== Slice ========
   
   //====== Loop/Deblock Filter ========
-    m_acTEncTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[0]       );
-    m_acTEncTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
-    m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
-    m_acTEncTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
-    m_acTEncTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
+#if H_MV
+  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable[layer]);
+#else
+  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
+#endif
+  m_cTEncTop.setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
+  m_cTEncTop.setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
+  m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
+  m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
+  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
 
   //====== Motion search ========
-    m_acTEncTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
-    m_acTEncTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
-    m_acTEncTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
-#if DV_V_RESTRICTION_B0037
-    m_acTEncTopList[iViewIdx]->setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction );
-    m_acTEncTopList[iViewIdx]->setVerticalDisparitySearchRange( m_iVerticalDisparitySearchRange );
-#endif
+  m_cTEncTop.setFastSearch                   ( m_iFastSearch  );
+  m_cTEncTop.setSearchRange                  ( m_iSearchRange );
+  m_cTEncTop.setBipredSearchRange            ( m_bipredSearchRange );
+
   //====== Quality control ========
-    m_acTEncTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
-    m_acTEncTopList[iViewIdx]->setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
-
-    m_acTEncTopList[iViewIdx]->setChromaQpOffset               ( m_iChromaQpOffset     );
-    m_acTEncTopList[iViewIdx]->setChromaQpOffset2nd            ( m_iChromaQpOffset2nd  );
+  m_cTEncTop.setMaxDeltaQP                   ( m_iMaxDeltaQP  );
+  m_cTEncTop.setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
+
+  m_cTEncTop.setChromaCbQpOffset               ( m_cbQpOffset     );
+  m_cTEncTop.setChromaCrQpOffset            ( m_crQpOffset  );
 
 #if ADAPTIVE_QP_SELECTION
-    m_acTEncTopList[iViewIdx]->setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
-#endif
-
-#if LOSSLESS_CODING
-    Int lowestQP;
-    lowestQP =  - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
-    if ((m_iMaxDeltaQP == 0 ) && (m_aiQP[0] == lowestQP) && (m_useLossless == true))
-    {
-      m_bUseAdaptiveQP = false;
-    }
-#endif
-
-    m_acTEncTopList[iViewIdx]->setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
-    m_acTEncTopList[iViewIdx]->setQPAdaptationRange            ( m_iQPAdaptationRange );
-  
-#if HHI_VSO
-    //====== VSO =========
-    m_acTEncTopList[iViewIdx]->setForceLambdaScaleVSO          ( false );
-    m_acTEncTopList[iViewIdx]->setLambdaScaleVSO               ( 1     );
-    m_acTEncTopList[iViewIdx]->setVSOMode                      ( 0     );
-    m_acTEncTopList[iViewIdx]->setUseVSO                       ( false ); 
-#if SAIT_VSO_EST_A0033
-    m_acTEncTopList[iViewIdx]->setUseEstimatedVSD              ( false );
-#endif
-#if LGE_WVSO_A0119
-    m_acTEncTopList[iViewIdx]->setUseWVSO                      ( false ); 
-#endif
-#endif
-
-#if DEPTH_MAP_GENERATION
-    m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration       ( m_uiPredDepthMapGeneration );
-    m_acTEncTopList[iViewIdx]->setPdmPrecision                 ( (UInt)m_cCameraData.getPdmPrecision     () );
-    m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta             (       m_cCameraData.getPdmScaleNomDelta () );
-    m_acTEncTopList[iViewIdx]->setPdmOffset                    (       m_cCameraData.getPdmOffset        () );
-#endif
-#if H3D_IVMP
-    m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode          ( m_uiMultiviewMvPredMode );
-    m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode           ( iViewIdx ? m_uiMultiviewMvRegMode       : 0   );
-    m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 );
-#endif
-#if H3D_IVRP
-#if QC_ARP_D0177
-    m_acTEncTopList[iViewIdx]->setUseAdvRP                     ( iViewIdx ? m_nUseAdvResPred             : 0   );
-    m_acTEncTopList[iViewIdx]->setARPStepNum                   ( iViewIdx ? QC_ARP_WFNR                  : 1   );
-#else
-    m_acTEncTopList[iViewIdx]->setMultiviewResPredMode         ( m_uiMultiviewResPredMode );
-#endif
-#endif
-#if MTK_D0156
-#if MERL_VSP_COMPENSATION_C0152
-    m_acTEncTopList[iViewIdx]->setUseVSPCompensation           ( iViewIdx ? m_bUseVSPCompensation : 0 );
-#endif
-    m_acTEncTopList[iViewIdx]->setUseDVPRefine                  ( iViewIdx ? m_bUseDVPRefine : 0 );
-#endif
-
+  m_cTEncTop.setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
+#endif
+
+  Int lowestQP;
+  lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
+
+#if H_MV
+  if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layer] == lowestQP) && (m_useLossless == true))
+#else
+  if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
+#endif
+  {
+    m_bUseAdaptiveQP = false;
+  }
+  m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
+  m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
+  
   //====== Tool list ========
-    m_acTEncTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
-    m_acTEncTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
-    m_acTEncTopList[iViewIdx]->setUseASR                       ( m_bUseASR      );
-    m_acTEncTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
-    m_acTEncTopList[iViewIdx]->setUseALF                       ( m_abUseALF[0]  );
-    m_acTEncTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
-#if LOSSLESS_CODING
-    m_acTEncTopList[iViewIdx]->setUseLossless                  ( m_useLossless );
-#endif
-    m_acTEncTopList[iViewIdx]->setALFMaxNumberFilters          ( m_iALFMaxNumberFilters ) ;
-
-    m_acTEncTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
-    m_acTEncTopList[iViewIdx]->setLCMod                        ( m_bLCMod         );
-    m_acTEncTopList[iViewIdx]->setdQPs                         ( m_aidQP        );
-    m_acTEncTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[0] );
-    m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
-    m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
-    m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
-    m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
-    m_acTEncTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
-    m_acTEncTopList[iViewIdx]->setUseEarlyCU                   ( m_bUseEarlyCU  ); 
-    m_acTEncTopList[iViewIdx]->setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
-    m_acTEncTopList[iViewIdx]->setUseCbfFastMode               ( m_bUseCbfFastMode  );
-#if HHI_INTERVIEW_SKIP
-    m_acTEncTopList[iViewIdx]->setInterViewSkip            ( iViewIdx>0 ? m_bInterViewSkip : false );
-#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
-    m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx>0 ? (UInt)m_dInterViewSkipLambdaScale : 1 );
-#endif
-#endif
-    m_acTEncTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
-    m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
-    m_acTEncTopList[iViewIdx]->setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
-    m_acTEncTopList[iViewIdx]->setUsePCM                       ( m_usePCM );
-    m_acTEncTopList[iViewIdx]->setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
+  m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
+  m_cTEncTop.setDeltaQpRD                    ( m_uiDeltaQpRD  );
+  m_cTEncTop.setUseASR                       ( m_bUseASR      );
+  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
+  m_cTEncTop.setUseLossless                  ( m_useLossless );
+#if H_MV
+  m_cTEncTop.setdQPs                         ( m_aidQP[layer]   );
+#else
+  m_cTEncTop.setdQPs                         ( m_aidQP        );
+#endif
+  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
+  m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
+  m_cTEncTop.setRDpenalty                 ( m_rdPenalty );
+  m_cTEncTop.setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
+  m_cTEncTop.setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
+  m_cTEncTop.setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
+  m_cTEncTop.setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
+  m_cTEncTop.setUseFastEnc                   ( m_bUseFastEnc  );
+  m_cTEncTop.setUseEarlyCU                   ( m_bUseEarlyCU  ); 
+  m_cTEncTop.setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
+  m_cTEncTop.setUseCbfFastMode            ( m_bUseCbfFastMode  );
+  m_cTEncTop.setUseEarlySkipDetection            ( m_useEarlySkipDetection );
+
+  m_cTEncTop.setUseTransformSkip             ( m_useTransformSkip      );
+  m_cTEncTop.setUseTransformSkipFast         ( m_useTransformSkipFast  );
+  m_cTEncTop.setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
+  m_cTEncTop.setPCMLog2MinSize          ( m_uiPCMLog2MinSize);
+  m_cTEncTop.setUsePCM                       ( m_usePCM );
+  m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
+  m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
+  
 
   //====== Weighted Prediction ========
-    m_acTEncTopList[iViewIdx]->setUseWP                        ( m_bUseWeightPred      );
-    m_acTEncTopList[iViewIdx]->setWPBiPredIdc                  ( m_uiBiPredIdc         );
+  m_cTEncTop.setUseWP                   ( m_useWeightedPred      );
+  m_cTEncTop.setWPBiPred                ( m_useWeightedBiPred   );
+  //====== Parallel Merge Estimation ========
+  m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
+
   //====== Slice ========
-    m_acTEncTopList[iViewIdx]->setSliceMode                    ( m_iSliceMode                );
-    m_acTEncTopList[iViewIdx]->setSliceArgument                ( m_iSliceArgument            );
-
-  //====== Entropy Slice ========
-    m_acTEncTopList[iViewIdx]->setEntropySliceMode             ( m_iEntropySliceMode         );
-    m_acTEncTopList[iViewIdx]->setEntropySliceArgument         ( m_iEntropySliceArgument     );
-    int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
-    if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
-    {
-      m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
-    }
-    if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
-    {
-      m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
-    }
-    if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
-    {
-      m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument );
-    }
-    m_acTEncTopList[iViewIdx]->setSliceGranularity        ( m_iSliceGranularity         );
-    if(m_iSliceMode == 0 )
-    {
-      m_bLFCrossSliceBoundaryFlag = true;
-    }
-    m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
-    m_acTEncTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[0]     );
-#if LGE_ILLUCOMP_B0045
-#if LGE_ILLUCOMP_DEPTH_C0046
-    m_acTEncTopList[iViewIdx]->setUseIC                ( m_abUseIC[0]      );
-#else
-    m_acTEncTopList[iViewIdx]->setUseIC                ( m_bUseIC          );
-#endif
-#endif
-#if INTER_VIEW_VECTOR_SCALING_C0115
-    m_acTEncTopList[iViewIdx]->setUseIVS               ( m_bUseIVS          );
-#endif
-    m_acTEncTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
-#if LGE_SAO_MIGRATION_D0091
-    m_acTEncTopList[iViewIdx]->setSaoLcuBoundary (m_saoLcuBoundary);
-    m_acTEncTopList[iViewIdx]->setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
-#else
-    m_acTEncTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag);
-#endif
-    m_acTEncTopList[iViewIdx]->setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
-    m_acTEncTopList[iViewIdx]->setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
-
-    m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
-
-    m_acTEncTopList[iViewIdx]->setColumnRowInfoPresent       ( m_iColumnRowInfoPresent );
-    m_acTEncTopList[iViewIdx]->setUniformSpacingIdr          ( m_iUniformSpacingIdr );
-    m_acTEncTopList[iViewIdx]->setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
-    m_acTEncTopList[iViewIdx]->setNumRowsMinus1              ( m_iNumRowsMinus1 );
-    if(m_iUniformSpacingIdr==0)
-    {
-      m_acTEncTopList[iViewIdx]->setColumnWidth              ( m_pchColumnWidth );
-      m_acTEncTopList[iViewIdx]->setRowHeight                ( m_pchRowHeight );
-    }
-    m_acTEncTopList[iViewIdx]->xCheckGSParameters();
-    m_acTEncTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag );
-    m_acTEncTopList[iViewIdx]->setTileMarkerFlag              ( m_iTileMarkerFlag );
-    m_acTEncTopList[iViewIdx]->setMaxTileMarkerEntryPoints    ( m_iMaxTileMarkerEntryPoints );
-  
-    Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
-    m_dMaxTileMarkerOffset    = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints;
-    m_acTEncTopList[iViewIdx]->setMaxTileMarkerOffset         ( m_dMaxTileMarkerOffset );
-    m_acTEncTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
-    if(uiTilesCount == 1)
-    {
-      m_bLFCrossTileBoundaryFlag = true; 
-    }
-    m_acTEncTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
-    m_acTEncTopList[iViewIdx]->setWaveFrontSynchro           ( m_iWaveFrontSynchro );
-    m_acTEncTopList[iViewIdx]->setWaveFrontFlush             ( m_iWaveFrontFlush );
-    m_acTEncTopList[iViewIdx]->setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
-#if TMVP_DEPTH_SWITCH
-    m_acTEncTopList[iViewIdx]->setEnableTMVP                 ( m_enableTMVP[0] );
-#else
-    m_acTEncTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP );
-#endif
-    m_acTEncTopList[iViewIdx]->setUseScalingListId           ( m_useScalingListId  );
-    m_acTEncTopList[iViewIdx]->setScalingListFile            ( m_scalingListFile   );
-    m_acTEncTopList[iViewIdx]->setSignHideFlag(m_signHideFlag);
-    m_acTEncTopList[iViewIdx]->setTSIG(m_signHidingThreshold);
-
-    if(uiTilesCount > 1)
-    {
-      m_bALFParamInSlice = false;
-      m_bALFPicBasedEncode = true;
-    }
-    m_acTEncTopList[iViewIdx]->setALFParamInSlice              ( m_bALFParamInSlice);
-    m_acTEncTopList[iViewIdx]->setALFPicBasedEncode            ( m_bALFPicBasedEncode);
-
-    //====== Depth tools ========
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-    m_acTEncTopList[iViewIdx]->setUseDMM                     ( false );
-#endif
-#if H3D_QTL
-    m_acTEncTopList[iViewIdx]->setUseQTLPC                   ( false );
-#endif
-#if HHI_MPI
-    m_acTEncTopList[iViewIdx]->setUseMVI( false );
-#endif
-#if RWTH_SDC_DLT_B0036
-    m_acTEncTopList[iViewIdx]->setUseDLT                      ( false );
-    m_acTEncTopList[iViewIdx]->setUseSDC                      ( false );
-#endif
-  }
-  if( m_bUsingDepthMaps )
-  {
-    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-    {
-
-#if FLEX_CODING_ORDER_M23723
-      // Detect whether depth comes before than texture for this view
-      Bool isDepthFirst = false;
-      if ( m_b3DVFlexOrder )
+  m_cTEncTop.setSliceMode               ( m_sliceMode                );
+  m_cTEncTop.setSliceArgument           ( m_sliceArgument            );
+
+  //====== Dependent Slice ========
+  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;
+  }
+  m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
+#if H_MV
+  m_cTEncTop.setUseSAO ( m_bUseSAO[layer] );
+#else
+  m_cTEncTop.setUseSAO ( m_bUseSAO );
+#endif
+  m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
+
+  m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
+  m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
+  m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
+  m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
+
+  m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
+  m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
+  m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
+  m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
+  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
+  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
+  m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
+  m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
+  m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
+  m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
+  m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
+  m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
+  m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
+  m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
+  m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
+  m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
+  m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
+  m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
+  m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
+  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
+  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
+  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
+  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
+  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
+  m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
+  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
+  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
+  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
+  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
+  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.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
+  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
+  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
+  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
+  m_cTEncTop.setNumRowsMinus1              ( m_iNumRowsMinus1 );
+  if(m_iUniformSpacingIdr==0)
+  {
+    m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
+    m_cTEncTop.setRowHeight                ( m_pRowHeight );
+  }
+  m_cTEncTop.xCheckGSParameters();
+  Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
+  if(uiTilesCount == 1)
+  {
+    m_bLFCrossTileBoundaryFlag = true; 
+  }
+  m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
+  m_cTEncTop.setWaveFrontSynchro           ( m_iWaveFrontSynchro );
+  m_cTEncTop.setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
+  m_cTEncTop.setTMVPModeId ( m_TMVPModeId );
+  m_cTEncTop.setUseScalingListId           ( m_useScalingListId  );
+  m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
+  m_cTEncTop.setSignHideFlag(m_signHideFlag);
+#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);
+  m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
+  m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
+  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); 
+  m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
+  m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
+  m_cTEncTop.setSarWidth( m_sarWidth );
+  m_cTEncTop.setSarHeight( m_sarHeight );
+  m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag );
+  m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag );
+  m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag );
+  m_cTEncTop.setVideoFormat( m_videoFormat );
+  m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag );
+  m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag );
+  m_cTEncTop.setColourPrimaries( m_colourPrimaries );
+  m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics );
+  m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients );
+  m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag );
+  m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField );
+  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 H_MV
+  }
+#endif
+#if H_3D_VSO
+  if ( m_bUseVSO )
+  {
+    if ( m_uiVSOMode == 4 )
+    {
+#if H_3D_VSO_EARLY_SKIP
+      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
+#else
+      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
+#endif
+      for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
       {
-        for ( Int ii=1; ii<12; ii+=2 )
+        TEncTop* pcEncTop =  m_acTEncTopList[ layer ]; 
+        Int iViewNum      = pcEncTop->getViewIndex(); 
+        Int iContent      = pcEncTop->getIsDepth() ? 1 : 0; 
+        Int iNumOfModels  = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
+
+        Bool bUseVSO      = (iNumOfModels != 0);
+
+        pcEncTop->setUseVSO( bUseVSO );
+        pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
+
+        for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
         {
-          Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
-          if ( iViewIdxCfg == iViewIdx )
-          {
-            if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
-            {
-              isDepthFirst = true;
-            }
-            else
-            {
-              assert(m_pchMVCJointCodingOrder[ii-1]=='T');
-            }
-            break;
-          }
-        }
+          Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
+
+          m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
+          m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
+        }            
       }
-#endif
-
-      m_depthFrameRcvd.push_back(0);
-      m_acTEncDepthTopList.push_back(new TEncTop); 
-      m_acTVideoIOYuvDepthInputFileList.push_back(new TVideoIOYuv);
-      m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv);
-      m_picYuvDepthRec.push_back(new TComList<TComPicYuv*>) ;
-
-      m_acTEncDepthTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
-      m_acTEncDepthTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
-      m_acTEncDepthTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
-      m_acTEncDepthTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
-      m_acTEncDepthTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
-      m_acTEncDepthTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
-      m_acTEncDepthTopList[iViewIdx]->setCropRight                    ( m_cropRight );
-      m_acTEncDepthTopList[iViewIdx]->setCropTop                      ( m_cropTop );
-      m_acTEncDepthTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
-      m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
-      m_acTEncDepthTopList[iViewIdx]->setViewId                       ( iViewIdx );
-      m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
-#if QC_MVHEVC_B0046
-      m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( iViewIdx );
-#else
-      m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
-#endif
-#if VIDYO_VPS_INTEGRATION
-      layerId = iViewIdx * 2 + 1;
-      m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( layerId );
-      m_cVPS.setDepthFlag                                             ( true, layerId );
-      m_cVPS.setViewId                                                ( iViewIdx, layerId );
-      m_cVPS.setViewOrderIdx                                          ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId );
-      m_cVPS.setDependentFlag                                         ( true, layerId );
-      m_cVPS.setDependentLayer                                        ( layerId-1, layerId);
-#endif
-#if FCO_FIX_SPS_CHANGE
-      m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
-      m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
-      m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
-      m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
-#else
-      m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( 0 );
-      m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( false );
-      m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( 0 );
-      m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( 0 );
-#endif
-
-      //====== Coding Structure ========
-      m_acTEncDepthTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
-      m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
-      m_acTEncDepthTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
-      m_acTEncDepthTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
-      m_acTEncDepthTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
-      for(Int i = 0; i < MAX_TLAYER; i++)
-      {
-        m_acTEncDepthTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
-        m_acTEncDepthTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
-      }
-      for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
-      {
-        m_acTEncDepthTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
-      }
-      m_acTEncDepthTopList[iViewIdx]->setQP                           ( m_aiQP[1] );
-
-      m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
-      m_acTEncDepthTopList[iViewIdx]->setPad                          ( m_aiPad );
-
-      m_acTEncDepthTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
-
-      m_acTEncDepthTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
-
-      m_acTEncDepthTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
-      m_acTEncDepthTopList[iViewIdx]->setUseAMP( m_enableAMP );
-
-      //===== Slice ========
-
-      //====== Loop/Deblock Filter ========
-      m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[1]   );
-      m_acTEncDepthTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
-      m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
-      m_acTEncDepthTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
-      m_acTEncDepthTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
-
-      //====== Motion search ========
-      m_acTEncDepthTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
-      m_acTEncDepthTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
-      m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
-#if DV_V_RESTRICTION_B0037
-      m_acTEncDepthTopList[iViewIdx]->setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction );
-      m_acTEncDepthTopList[iViewIdx]->setVerticalDisparitySearchRange( m_iVerticalDisparitySearchRange );
-#endif
-      //====== Quality control ========
-      m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
-      m_acTEncDepthTopList[iViewIdx]->setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
-
-      m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset               ( m_iChromaQpOffset     );
-      m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset2nd            ( m_iChromaQpOffset2nd  );
-
-#if ADAPTIVE_QP_SELECTION
-      m_acTEncDepthTopList[iViewIdx]->setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
-#endif
-
-      m_acTEncDepthTopList[iViewIdx]->setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
-      m_acTEncDepthTopList[iViewIdx]->setQPAdaptationRange            ( m_iQPAdaptationRange );
-
-      //====== Tool list ========
-      m_acTEncDepthTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
-      m_acTEncDepthTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
-      m_acTEncDepthTopList[iViewIdx]->setUseASR                       ( m_bUseASR      );
-      m_acTEncDepthTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
-      m_acTEncDepthTopList[iViewIdx]->setUseALF                       ( m_abUseALF[1]  );
-      m_acTEncDepthTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
-#if LOSSLESS_CODING
-      m_acTEncDepthTopList[iViewIdx]->setUseLossless                  ( m_useLossless );
-#endif
-      m_acTEncDepthTopList[iViewIdx]->setALFMaxNumberFilters          ( m_iALFMaxNumberFilters ) ;
-
-      m_acTEncDepthTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
-      m_acTEncDepthTopList[iViewIdx]->setLCMod                        ( m_bLCMod       );
-      m_acTEncDepthTopList[iViewIdx]->setdQPs                         ( m_aidQPdepth   );
-      m_acTEncDepthTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[1] );
-      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
-      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
-      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
-      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
-      m_acTEncDepthTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
-      m_acTEncDepthTopList[iViewIdx]->setUseEarlyCU                   ( m_bUseEarlyCU  ); 
-      m_acTEncDepthTopList[iViewIdx]->setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
-      m_acTEncDepthTopList[iViewIdx]->setUseCbfFastMode               ( m_bUseCbfFastMode  );
-#if HHI_INTERVIEW_SKIP
-      m_acTEncDepthTopList[iViewIdx]->setInterViewSkip            ( 0 );
-#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
-      m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 );
-#endif
-#endif
-      m_acTEncDepthTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
-      m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
-      m_acTEncDepthTopList[iViewIdx]->setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
-      m_acTEncDepthTopList[iViewIdx]->setUsePCM                       ( m_usePCM );
-      m_acTEncDepthTopList[iViewIdx]->setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
-      //====== VSO ========
-#if HHI_VSO
-      m_acTEncDepthTopList[iViewIdx]->setUseVSO                       ( m_bUseVSO      ); //GT: might be enabled/disabled later for VSO Mode 4
-      m_acTEncDepthTopList[iViewIdx]->setForceLambdaScaleVSO          ( m_bForceLambdaScaleVSO );
-      m_acTEncDepthTopList[iViewIdx]->setLambdaScaleVSO               ( m_dLambdaScaleVSO );
-#if HHI_VSO_DIST_INT
-      m_acTEncDepthTopList[iViewIdx]->setAllowNegDist                 ( m_bAllowNegDist );
-#endif
-      m_acTEncDepthTopList[iViewIdx]->setVSOMode                      ( m_uiVSOMode );
-
-#if SAIT_VSO_EST_A0033
-      m_acTEncDepthTopList[iViewIdx]->setUseEstimatedVSD              ( m_bUseEstimatedVSD );
-#endif
-#if LGE_WVSO_A0119
-      m_acTEncDepthTopList[iViewIdx]->setUseWVSO                      ( m_bUseWVSO         );
-#endif
-#endif
-
-#if DEPTH_MAP_GENERATION
-      m_acTEncDepthTopList[iViewIdx]->setPredDepthMapGeneration       ( 0 );
-#endif
-#if H3D_IVMP
-      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvPredMode          ( 0 );
-      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegMode           ( 0 );
-      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( 0.0 );
-#endif
-#if H3D_IVRP 
-#if QC_ARP_D0177
-    m_acTEncDepthTopList[iViewIdx]->setUseAdvRP                          ( 0 );
-    m_acTEncDepthTopList[iViewIdx]->setARPStepNum                        ( 1 );
-#else
-    m_acTEncDepthTopList[iViewIdx]->setMultiviewResPredMode         ( 0 );
-#endif
-#endif
-#if MTK_D0156
-
-#if MERL_VSP_COMPENSATION_C0152
-      m_acTEncDepthTopList[iViewIdx]->setUseVSPCompensation           ( iViewIdx ? true : false );
-#endif
-
-      m_acTEncDepthTopList[iViewIdx]->setUseDVPRefine                 ( iViewIdx ? true : false );
-#endif
-
-      //====== Weighted Prediction ========
-      m_acTEncDepthTopList[iViewIdx]->setUseWP                        ( m_bUseWeightPred      );
-      m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc                  ( m_uiBiPredIdc         );
-      //====== Slice ========
-      m_acTEncDepthTopList[iViewIdx]->setSliceMode                    ( m_iSliceMode                );
-      m_acTEncDepthTopList[iViewIdx]->setSliceArgument                ( m_iSliceArgument            );
-
-      //====== Entropy Slice ========
-      m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode             ( m_iEntropySliceMode         );
-      m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument         ( m_iEntropySliceArgument     );
-      int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
-      if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
-      {
-        m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
-      }
-      if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
-      {
-        m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
-      }
-      if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
-      {
-        m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument );
-      }
-      m_acTEncDepthTopList[iViewIdx]->setSliceGranularity        ( m_iSliceGranularity         );
-      if(m_iSliceMode == 0 )
-      {
-        m_bLFCrossSliceBoundaryFlag = true;
-      }
-      m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
-      m_acTEncDepthTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[1]     );
-#if LGE_ILLUCOMP_B0045
-#if LGE_ILLUCOMP_DEPTH_C0046
-      m_acTEncDepthTopList[iViewIdx]->setUseIC                ( m_abUseIC[1] );
-#else
-      m_acTEncDepthTopList[iViewIdx]->setUseIC                ( false     );
-#endif
-#endif
-#if INTER_VIEW_VECTOR_SCALING_C0115
-     m_acTEncDepthTopList[iViewIdx]->setUseIVS                ( m_bUseIVS );
-#endif
-      m_acTEncDepthTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
-#if LGE_SAO_MIGRATION_D0091
-      m_acTEncDepthTopList[iViewIdx]->setSaoLcuBoundary (m_saoLcuBoundary);
-      m_acTEncDepthTopList[iViewIdx]->setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
-#else
-      m_acTEncDepthTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag);
-#endif
-      m_acTEncDepthTopList[iViewIdx]->setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
-      m_acTEncDepthTopList[iViewIdx]->setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
-
-      m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
-
-      m_acTEncDepthTopList[iViewIdx]->setColumnRowInfoPresent       ( m_iColumnRowInfoPresent );
-      m_acTEncDepthTopList[iViewIdx]->setUniformSpacingIdr          ( m_iUniformSpacingIdr );
-      m_acTEncDepthTopList[iViewIdx]->setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
-      m_acTEncDepthTopList[iViewIdx]->setNumRowsMinus1              ( m_iNumRowsMinus1 );
-      if(m_iUniformSpacingIdr==0)
-      {
-        m_acTEncDepthTopList[iViewIdx]->setColumnWidth              ( m_pchColumnWidth );
-        m_acTEncDepthTopList[iViewIdx]->setRowHeight                ( m_pchRowHeight );
-      }
-      m_acTEncDepthTopList[iViewIdx]->xCheckGSParameters();
-      m_acTEncDepthTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag );
-      m_acTEncDepthTopList[iViewIdx]->setTileMarkerFlag              ( m_iTileMarkerFlag );
-      m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerEntryPoints    ( m_iMaxTileMarkerEntryPoints );
-
-      Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
-      m_dMaxTileMarkerOffset    = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints;
-      m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerOffset         ( m_dMaxTileMarkerOffset );
-      m_acTEncDepthTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
-      if(uiTilesCount == 1)
-      {
-        m_bLFCrossTileBoundaryFlag = true; 
-      }
-      m_acTEncDepthTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
-      m_acTEncDepthTopList[iViewIdx]->setWaveFrontSynchro           ( m_iWaveFrontSynchro );
-      m_acTEncDepthTopList[iViewIdx]->setWaveFrontFlush             ( m_iWaveFrontFlush );
-      m_acTEncDepthTopList[iViewIdx]->setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
-#if TMVP_DEPTH_SWITCH
-      m_acTEncDepthTopList[iViewIdx]->setEnableTMVP                 ( m_enableTMVP[1] );
-#else
-      m_acTEncDepthTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP );
-#endif
-      m_acTEncDepthTopList[iViewIdx]->setUseScalingListId           ( m_useScalingListId  );
-      m_acTEncDepthTopList[iViewIdx]->setScalingListFile            ( m_scalingListFile   );
-      m_acTEncDepthTopList[iViewIdx]->setSignHideFlag(m_signHideFlag);
-      m_acTEncDepthTopList[iViewIdx]->setTSIG(m_signHidingThreshold);
-
-      if(uiTilesCount > 1)
-      {
-        m_bALFParamInSlice = false;
-        m_bALFPicBasedEncode = true;
-      }
-      m_acTEncDepthTopList[iViewIdx]->setALFParamInSlice              ( m_bALFParamInSlice);
-      m_acTEncDepthTopList[iViewIdx]->setALFPicBasedEncode            ( m_bALFPicBasedEncode);
-
-  //====== Depth tools ========
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-    m_acTEncDepthTopList[iViewIdx]->setUseDMM                     ( m_bUseDMM );
-#endif
-#if FLEX_CODING_ORDER_M23723 && HHI_DMM_PRED_TEX
-    m_acTEncDepthTopList[iViewIdx]->setUseDMM34( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseDMM );
-#endif
-
-#if H3D_QTL
-    m_acTEncDepthTopList[iViewIdx]->setUseQTLPC                   (m_bUseQTLPC);
-#endif
-#if HHI_MPI
-#if FLEX_CODING_ORDER_M23723
-    m_acTEncDepthTopList[iViewIdx]->setUseMVI( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseMVI );
-#else
-     m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
-#endif
-#endif
-#if RWTH_SDC_DLT_B0036
-      m_acTEncDepthTopList[iViewIdx]->setUseDLT                   ( m_bUseDLT );
-      m_acTEncDepthTopList[iViewIdx]->setUseSDC                   ( m_bUseSDC );
-#endif
-    }
-  }
-
-#if H3D_IVMP
-  else if( m_uiMultiviewMvRegMode )
-  {
-    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-    {
-      m_acTVideoIOYuvDepthInputFileList.push_back( new TVideoIOYuv );
-    }
-  }
-#endif
-
-#if HHI_VSO
-  if ( m_bUseVSO )
-  {
-    if ( m_uiVSOMode == 4 )
-    {
-#if LGE_VSO_EARLY_SKIP_A0093
-      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
-#else
-      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
-#endif
-
-      for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ )
-      {
-        for (Int iContent = 0; iContent < 2; iContent++ )
-        {
-          Int iNumOfModels   = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
-          Bool bUseVSO = (iNumOfModels != 0);
-
-          TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum];
-          pcEncTop->setUseVSO( bUseVSO );
-          pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
-
-          for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
-          {
-            Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
-
-            m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
-            m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
-          }
-        }
-      }
     }
     else
@@ -760,131 +519,82 @@
       AOT(true);
     }
-#if LGE_WVSO_A0119 
-    for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ )
-    {
-      for (Int iContent = 0; iContent < 2; iContent++ )
-      {
-        TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum]; 
-        pcEncTop->setUseWVSO  ( m_bUseWVSO );
-        pcEncTop->setVSOWeight( m_iVSOWeight );
-        pcEncTop->setVSDWeight( m_iVSDWeight );
-        pcEncTop->setDWeight  ( m_iDWeight );
-      }
-    }
-#endif
-  }
-#endif
-
-#if HHI_INTERVIEW_SKIP
-  m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 );
-#endif
-
+  }
+#endif
 }
 
 Void TAppEncTop::xCreateLib()
 {
-  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-  {
-    m_acTVideoIOYuvInputFileList[iViewIdx]->open( m_pchInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
-    m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
-
-    if (m_pchReconFileList[iViewIdx])
-      m_acTVideoIOYuvReconFileList[iViewIdx]->open(m_pchReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
-    m_acTEncTopList[iViewIdx]->create();
-    if( m_bUsingDepthMaps )
-    {
-      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
-      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
-
-      if (m_pchDepthReconFileList[iViewIdx])
-        m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open(m_pchDepthReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
-      m_acTEncDepthTopList[iViewIdx]->create();
-    }
-#if H3D_IVMP
-    else if( m_uiMultiviewMvRegMode )
-    {
-      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
-      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
-    }
-#endif
-  }
+#if H_MV
+  // initialize global variables
+  initROM();
+#if H_3D_DIM_DMM
+  initWedgeLists( true );
+#endif
+
+  for( Int layer=0; layer < m_numberOfLayers; layer++)
+  {
+    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
+    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
+
+    if (m_pchReconFileList[layer])
+    {
+      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
+    }
+    m_acTEncTopList[layer]->create();
+  }
+#else
+  // Video I/O
+  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_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
+  
+  // Neo Decoder
+  m_cTEncTop.create();
+#endif
 }
 
 Void TAppEncTop::xDestroyLib()
 {
+#if H_MV
+  // destroy ROM
+  destroyROM();
+
+  for(Int layer=0; layer<m_numberOfLayers; layer++)
+  {
+    m_acTVideoIOYuvInputFileList[layer]->close();
+    m_acTVideoIOYuvReconFileList[layer]->close();
+    delete m_acTVideoIOYuvInputFileList[layer] ; 
+    m_acTVideoIOYuvInputFileList[layer] = NULL;
+    delete m_acTVideoIOYuvReconFileList[layer] ; 
+    m_acTVideoIOYuvReconFileList[layer] = NULL;
+    m_acTEncTopList[layer]->deletePicBuffer();
+    m_acTEncTopList[layer]->destroy();
+    delete m_acTEncTopList[layer] ; 
+    m_acTEncTopList[layer] = NULL;
+    delete m_picYuvRec[layer] ; 
+    m_picYuvRec[layer] = NULL;
+  }
+#else
   // Video I/O
-  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-  {
-    m_acTVideoIOYuvInputFileList[iViewIdx]->close();
-    m_acTVideoIOYuvReconFileList[iViewIdx]->close();
-    delete m_acTVideoIOYuvInputFileList[iViewIdx] ; 
-    m_acTVideoIOYuvInputFileList[iViewIdx] = NULL;
-    delete m_acTVideoIOYuvReconFileList[iViewIdx] ; 
-    m_acTVideoIOYuvReconFileList[iViewIdx] = NULL;
-    m_acTEncTopList[iViewIdx]->deletePicBuffer();
-    m_acTEncTopList[iViewIdx]->destroy();
-    delete m_acTEncTopList[iViewIdx] ; 
-    m_acTEncTopList[iViewIdx] = NULL;
-    delete m_picYuvRec[iViewIdx] ; 
-    m_picYuvRec[iViewIdx] = NULL;
-
-    if( iViewIdx < Int( m_acTVideoIOYuvDepthInputFileList.size() ) && m_acTVideoIOYuvDepthInputFileList[iViewIdx] )
-    {
-      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->close( );
-      delete m_acTVideoIOYuvDepthInputFileList[iViewIdx];
-      m_acTVideoIOYuvDepthInputFileList[iViewIdx] = NULL;
-    }
-    if( iViewIdx < Int( m_acTVideoIOYuvDepthReconFileList.size() ) && m_acTVideoIOYuvDepthReconFileList[iViewIdx] )
-    {
-      m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close () ;
-      delete m_acTVideoIOYuvDepthReconFileList[iViewIdx];
-      m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL;
-    }
-    if( iViewIdx < Int( m_acTEncDepthTopList.size() ) && m_acTEncDepthTopList[iViewIdx] )
-    {
-      m_acTEncDepthTopList[iViewIdx]->deletePicBuffer();
-      m_acTEncDepthTopList[iViewIdx]->destroy();
-      delete m_acTEncDepthTopList[iViewIdx];
-      m_acTEncDepthTopList[iViewIdx] = NULL;
-    }
-    if( iViewIdx < Int( m_picYuvDepthRec.size() ) && m_picYuvDepthRec[iViewIdx] )
-    {
-      delete m_picYuvDepthRec[iViewIdx] ; 
-      m_picYuvDepthRec[iViewIdx] = NULL;
-    }
-  }
+  m_cTVideoIOYuvInputFile.close();
+  m_cTVideoIOYuvReconFile.close();
+  
+  // Neo Decoder
+  m_cTEncTop.destroy();
+#endif
 }
 
 Void TAppEncTop::xInitLib()
 {
-  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-  {
-    m_acTEncTopList[iViewIdx]->init( this );
-#if QC_MVHEVC_B0046
-  //set setNumDirectRefLayer
-  Int iNumDirectRef = m_acTEncTopList[iViewIdx]->getSPS()->getNumberOfUsableInterViewRefs();
-  m_acTEncTopList[iViewIdx]->getEncTop()->getVPS()->setNumDirectRefLayer(iNumDirectRef, iViewIdx);
-  for(Int iNumIvRef = 0; iNumIvRef < iNumDirectRef; iNumIvRef ++)
-  {
-    Int iLayerId = m_acTEncTopList[iViewIdx]->getSPS()->getUsableInterViewRef(iNumIvRef);
-    m_acTEncTopList[iViewIdx]->getEncTop()->getVPS()->setDirectRefLayerId( iLayerId + iViewIdx, iViewIdx, iNumIvRef);
-  }
-#endif
-  }
-  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-  {
-    m_acTEncTopList[iViewIdx]->setTEncTopList( &m_acTEncTopList  );
-  }
-  if ( m_bUsingDepthMaps )
-  {
-    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-    {
-      m_acTEncDepthTopList[iViewIdx]->init( this );
-    }
-    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
-    {
-      m_acTEncDepthTopList[iViewIdx]->setTEncTopList( &m_acTEncDepthTopList  );
-    }
-  }
+#if H_MV
+  for(Int layer=0; layer<m_numberOfLayers; layer++)
+  {
+    m_acTEncTopList[layer]->init( );
+  }
+#else
+  m_cTEncTop.init();
+#endif
 }
 
@@ -911,11 +621,6 @@
 
   TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
-  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
-#if !QC_MVHEVC_B0046
-  TComPicYuv*       pcPdmDepthOrg    = new TComPicYuv;
-#endif
   TComPicYuv*       pcPicYuvRec = NULL;
-  TComPicYuv*       pcDepthPicYuvRec = NULL;
-
+  
   // initialize internal class & member variables
   xInitLibCfg();
@@ -924,89 +629,58 @@
   
   // main encoder loop
+#if H_MV
   Bool  allEos = false;
   std::vector<Bool>  eos ;
-  std::vector<Bool>  depthEos ;
+  std::vector<Bool>  flush ;  
+  
+  Int gopSize    = 1;
   Int maxGopSize = 0;
-  Int gopSize = 1;
-  
+  maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize());  
+  
+  for(Int layer=0; layer < m_numberOfLayers; layer++ )
+  {
+    eos  .push_back( false );
+    flush.push_back( false );
+  }
+#else
+  Int   iNumEncoded = 0;
+  Bool  bEos = false;
+#endif
+ 
   list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
-  maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize());   
-
-  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
-  {
-    eos.push_back( false );
-    depthEos.push_back( false );
-    
-#if RWTH_SDC_DLT_B0036
-    if( m_bUsingDepthMaps && m_bUseDLT )
-      xAnalyzeInputBaseDepth(iViewIdx, m_iIntraPeriod);
-#endif
-  }
 
   // allocate original YUV buffer
   pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
-  pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
-
-#if H3D_IVMP
-  if( m_uiMultiviewMvRegMode )
-  {
-    pcPdmDepthOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
-  }
-#endif
-
+  
+#if H_MV
   while ( !allEos )
   {
-    for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
+    for(Int layer=0; layer < m_numberOfLayers; layer++ )
     {
       Int frmCnt = 0;
-      while ( !eos[iViewIdx] && !(frmCnt == gopSize))
+      while ( !eos[layer] && !(frmCnt == gopSize))
       {
         // get buffers
-        xGetBuffer(pcPicYuvRec, iViewIdx, false);
+        xGetBuffer(pcPicYuvRec, layer);
 
         // read input YUV file
-        m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad );
-      
-#if H3D_IVMP
-        if( m_uiMultiviewMvRegMode && iViewIdx )
+        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, m_aiPad );
+        m_acTEncTopList             [layer]->initNewPic( pcPicYuvOrg );
+
+        // increase number of received frames
+        m_frameRcvd[layer]++;
+        
+        frmCnt++;
+
+        eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded);
+        allEos = allEos||eos[layer];
+
+        // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
+        if (m_acTVideoIOYuvInputFileList[layer]->isEof())
         {
-          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps );
-        }
-#endif
-
-#if H3D_IVMP
-        m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg, ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) );
-#else
-        m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg );
-#endif
-
-        // increase number of received frames
-        m_frameRcvd[iViewIdx]++;
-        frmCnt++;
-        // check end of file
-        eos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
-        eos[iViewIdx] = ( m_frameRcvd[iViewIdx] == m_iFrameToBeEncoded ?    true : eos[iViewIdx]   );
-        allEos = allEos|eos[iViewIdx] ; 
-      }
-      if( m_bUsingDepthMaps )
-      {
-        Int frmCntDepth = 0;
-        while ( !depthEos[iViewIdx] && !(frmCntDepth == gopSize))
-        {
-          // get buffers
-          xGetBuffer(pcDepthPicYuvRec, iViewIdx, true);
-
-          // read input YUV file
-          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad );
-
-          m_acTEncDepthTopList[iViewIdx]->initNewPic( pcDepthPicYuvOrg );
-
-          // increase number of received frames
-          m_depthFrameRcvd[iViewIdx]++;
-          frmCntDepth++;
-          // check end of file
-          depthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
-          depthEos[iViewIdx] = ( m_depthFrameRcvd[iViewIdx] == m_iFrameToBeEncoded ?    true : depthEos[iViewIdx]   );
-          allEos = allEos|depthEos[iViewIdx] ; 
+          flush          [layer] = true;
+          eos            [layer] = true;
+          m_frameRcvd    [layer]--;
+          m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]);
         }
       }
@@ -1014,245 +688,99 @@
     for ( Int gopId=0; gopId < gopSize; gopId++ )
     {
-      Int  iNumEncoded = 0;
-
-#if !QC_MVHEVC_B0046
+#if H_3D
       UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
-      if ( iNextPoc < m_iFrameToBeEncoded )
+      if ( iNextPoc < m_framesToBeEncoded )
       {
         m_cCameraData.update( iNextPoc );
       }
 #endif
-
-
-#if FLEX_CODING_ORDER_M23723
-      if (m_b3DVFlexOrder)
+      for(Int layer=0; layer < m_numberOfLayers; layer++ )
       {
-        Int  iNumDepthEncoded = 0;
-        iNumEncoded = 0;
-        Int i=0;
-        Int iViewIdx=0;
-        Int iNumberofDepthViews = m_bUsingDepthMaps?m_iNumberOfViews:0;
-        for (Int j=0; j < (m_iNumberOfViews+ iNumberofDepthViews); j++ )
-        {
-          if (m_pchMVCJointCodingOrder[i]=='T')
+#if H_3D_VSO        
+          if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
           {
-
-            i++;
-            assert(isdigit(m_pchMVCJointCodingOrder[i]));
-            iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
-#if (FCO_FIX && MERL_VSP_C0152)
-            Int iCurPoc = m_acTEncTopList[iViewIdx]->getFrameId(gopId);
-            if( iCurPoc < m_acTEncTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
-            {
-              TComPic* pcBaseTxtPic   = getPicFromView(  0, m_acTEncTopList[iViewIdx]->getFrameId(gopId), false ); //get base view reconstructed texture
-              TComPic* pcBaseDepthPic = getPicFromView(  0, m_acTEncTopList[iViewIdx]->getFrameId(gopId), true );  //get base view reconstructed depth
-              TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder();
-              pEncSlice->setRefPicBaseTxt(pcBaseTxtPic);
-              pEncSlice->setRefPicBaseDepth(pcBaseDepthPic);
-            }
-            setBWVSPLUT( iViewIdx, gopId, false);            
-#endif
-
-            m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId );
-            xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false);
-            outputAccessUnits.clear();
-            i++;
+            m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() );
+            m_acTEncTopList[layer]  ->setDispCoeff( m_cCameraData.getDispCoeff() );
           }
-          else if ( m_pchMVCJointCodingOrder[i] == 'D')
-          {
-
-            i++;
-            if( m_bUsingDepthMaps )
-            {
-              assert(isdigit(m_pchMVCJointCodingOrder[i]));
-              iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
-
-#if SAIT_VSO_EST_A0033
-              if( m_bUseVSO && iNextPoc < m_iFrameToBeEncoded )
-              {
-                m_cCameraData.xSetDispCoeff( iNextPoc, iViewIdx );
-                m_acTEncDepthTopList[iViewIdx]->setDispCoeff( m_cCameraData.getDispCoeff() );
-              }
-#endif
-#if (FCO_FIX && MERL_VSP_C0152)
-              Int iCurPocDepth = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId);
-              if( iCurPocDepth < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
-              {
-                TComPic* pcBaseDepthPic = getPicFromView(  0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true );
-                TEncSlice* pcSlice = (TEncSlice*) m_acTEncDepthTopList[iViewIdx]->getSliceEncoder();
-                pcSlice->setRefPicBaseDepth(pcBaseDepthPic);
-              }
-              setBWVSPLUT( iViewIdx, gopId, true);
-#endif
-              m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId );
-              xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true);
-              outputAccessUnits.clear();
-              i++;
-            }
-          }
-        }
+#endif
+        Int   iNumEncoded = 0;
+
+        // call encoding function for one frame          
+        m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId );        
+        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer);
+        outputAccessUnits.clear();
       }
-      else
-      {
-
-#endif
-      for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
-      {
-#if SAIT_VSO_EST_A0033
-        if( m_bUseVSO && iNextPoc < m_iFrameToBeEncoded )
-        {
-          m_cCameraData.xSetDispCoeff( iNextPoc, iViewIdx );
-          m_acTEncDepthTopList[iViewIdx]->setDispCoeff( m_cCameraData.getDispCoeff() );
-        }
-#endif
-        iNumEncoded = 0;
-
-#if MERL_VSP_C0152
-#if MERL_VSP_C0152_BugFix_ForNoDepthCase
-        if(m_bUsingDepthMaps) // VSP can be used only when depth is available as input
-        {
-#endif
-        Int iCurPoc = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId);
-        if( iCurPoc < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
-        {
-          TComPic* pcBaseTxtPic   = getPicFromView(  0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), false ); //get base view reconstructed texture
-          TComPic* pcBaseDepthPic = getPicFromView(  0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true );  //get base view reconstructed depth
-          TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder();
-          pEncSlice->setRefPicBaseTxt(pcBaseTxtPic);
-          pEncSlice->setRefPicBaseDepth(pcBaseDepthPic);
-#if MERL_VSP_NBDV_RefVId_Fix_D0166
-          for (Int refViewId=0; refViewId < iViewIdx; refViewId++ )
-          {
-            pEncSlice->setListDepthPic(m_acTEncDepthTopList[refViewId]->getListPic(), refViewId ); // The list will store only the depth pictures
-            setBWVSPLUT(refViewId, iViewIdx, gopId, false);
-          } 
-#endif
-        }
-#if !MERL_VSP_NBDV_RefVId_Fix_D0166
-        setBWVSPLUT( iViewIdx, gopId, false);
-#endif
-#endif
-
-#if MERL_VSP_C0152_BugFix_ForNoDepthCase
-        }
-        else
-        {
-          Int iCurPoc = m_acTEncTopList[iViewIdx]->getFrameId(gopId);
-          if( iCurPoc < m_acTEncTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
-          {
-            TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder();
-            pEncSlice->setRefPicBaseTxt(NULL);//Initialize the base view reconstructed texture buffer
-            pEncSlice->setRefPicBaseDepth(NULL);//Initialize the base view reconstructed depth buffer
-          }
-        }
-#endif
-
-        // call encoding function for one frame
-        m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId );
-        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false);
-        outputAccessUnits.clear();
-        if( m_bUsingDepthMaps )
-        {
-          Int  iNumDepthEncoded = 0;
-#if MERL_VSP_C0152
-        Int iCurPocDepth = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId);
-        if( iCurPocDepth < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
-        {
-          TComPic* pcBaseDepthPic = getPicFromView(  0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true );
-          TEncSlice* pcSlice = (TEncSlice*) m_acTEncDepthTopList[iViewIdx]->getSliceEncoder();
-          pcSlice->setRefPicBaseDepth(pcBaseDepthPic);
-#if  MERL_VSP_NBDV_RefVId_Fix_D0166
-          for (Int refViewId=0; refViewId < iViewIdx; refViewId++ )
-          {
-            pcSlice->setListDepthPic(m_acTEncDepthTopList[refViewId]->getListPic(), refViewId ); // The list will store only the depth pictures
-            setBWVSPLUT( refViewId, iViewIdx, gopId, true);
-          } 
-#endif
-        }
-#if !MERL_VSP_NBDV_RefVId_Fix_D0166
-        setBWVSPLUT( iViewIdx, gopId, true);
-#endif
-#endif
-
-          // call encoding function for one depth frame
-          m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId );
-          xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true);
-          outputAccessUnits.clear();
-        }
-      }
- 
-#if FLEX_CODING_ORDER_M23723
-      }
-#endif
-
-#if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP
-      for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
-      {
-        if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] )
-        {
-          m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
-        }
-        if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] )
-        {
-          m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
-        }
-      }
-#endif
-      for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
-      {
-        m_acTEncTopList[iViewIdx]->compressMotion( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
-        if( m_bUsingDepthMaps )
-        {
-          m_acTEncDepthTopList[iViewIdx]->compressMotion( m_acTEncDepthTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
-        }
-      }
     }
     gopSize = maxGopSize;
   }
+  for(Int layer=0; layer < m_numberOfLayers; layer++ )
+  {
+    m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded() );
+  }
+#else
+  while ( !bEos )
+  {
+    // get buffers
+    xGetBuffer(pcPicYuvRec);
+
+    // read input YUV file
+    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
+
+    // increase number of received frames
+    m_iFrameRcvd++;
+
+    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, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
+    
+    // write bistream to file if necessary
+    if ( iNumEncoded > 0 )
+    {
+      xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits);
+      outputAccessUnits.clear();
+    }
+  }
+
+  m_cTEncTop.printSummary();
+#endif
+
   // delete original YUV buffer
   pcPicYuvOrg->destroy();
   delete pcPicYuvOrg;
   pcPicYuvOrg = NULL;
-  pcDepthPicYuvOrg->destroy();
-  delete pcDepthPicYuvOrg;
-  pcDepthPicYuvOrg = NULL;
-  
-#if !QC_MVHEVC_B0046
-  if ( pcPdmDepthOrg != NULL && m_uiMultiviewMvRegMode )
-  {
-    pcPdmDepthOrg->destroy();
-    delete pcPdmDepthOrg;     
-    pcPdmDepthOrg = NULL; 
-  };
-#endif
-  
-  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
-  {
-    m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded());
-    if ( m_bUsingDepthMaps )
-    {
-      m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded());
-    }
-  }
+  
+#if !H_MV
+  // delete used buffers in encoder class
+  m_cTEncTop.deletePicBuffer();
+#endif
 
   // delete buffers & classes
   xDeleteBuffer();
   xDestroyLib();
+  
+  printRateSummary();
+
+#if H_3D_REN_MAX_DEV_OUT
+  Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation(); 
+
+  if ( !(dMaxDispDiff < 0) )
+  {  
+    printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff );
+  }
+#endif
 
   return;
 }
-
-TEncTop*  TAppEncTop::getTEncTop( Int viewId, Bool isDepth )    
-{ 
-  if ( isDepth )  
-  {
-    return m_acTEncDepthTopList[viewId]; 
-  } 
-  else
-  { 
-    return m_acTEncTopList[viewId]; 
-  } 
-}
-
 
 // ====================================================================================================================
@@ -1266,107 +794,97 @@
  .
  */
-Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, Bool isDepth)
+#if H_MV
+Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
+#else
+Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
+#endif
 {
   assert( m_iGOPSize > 0 );
   
-  if( !isDepth )
-  {
-    if ( m_picYuvRec[iViewIdx]->size() == (UInt)m_iGOPSize )
-    {
-      rpcPicYuvRec = m_picYuvRec[iViewIdx]->popFront();
-    }
-    else
-    {
-      rpcPicYuvRec = new TComPicYuv; 
-      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
-    }
-    m_picYuvRec[iViewIdx]->pushBack( rpcPicYuvRec );
+  // org. buffer
+#if H_MV
+  if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize )
+  {
+    rpcPicYuvRec = m_picYuvRec[layer]->popFront();
+#else
+  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
+  {
+    rpcPicYuvRec = m_cListPicYuvRec.popFront();
+#endif
+
   }
   else
   {
-    if ( m_picYuvDepthRec[iViewIdx]->size() == (UInt)m_iGOPSize )
-    {
-      rpcPicYuvRec = m_picYuvDepthRec[iViewIdx]->popFront();
-    }
-    else
-    {
-      rpcPicYuvRec = new TComPicYuv; 
-      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
-    }
-    m_picYuvDepthRec[iViewIdx]->pushBack( rpcPicYuvRec );
-  }
+    rpcPicYuvRec = new TComPicYuv;
+    
+    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
+
+  }
+#if H_MV
+  m_picYuvRec[layer]->pushBack( rpcPicYuvRec );
+#else
+  m_cListPicYuvRec.pushBack( rpcPicYuvRec );
+#endif
 }
 
 Void TAppEncTop::xDeleteBuffer( )
 {
-  for(Int iViewIdx=0; iViewIdx<m_picYuvRec.size(); iViewIdx++)
-  {
-    if(m_picYuvRec[iViewIdx])
-    {
-      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[iViewIdx]->begin();
-      Int iSize = Int( m_picYuvRec[iViewIdx]->size() );
-      for ( Int i = 0; i < iSize; i++ )
-      {
-        TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
-        if(pcPicYuvRec)
-        {
-          pcPicYuvRec->destroy();
-          delete pcPicYuvRec; 
-          pcPicYuvRec = NULL;
-        }
-      }
-    } 
-  }
-  for(Int iViewIdx=0; iViewIdx<m_picYuvDepthRec.size(); iViewIdx++)
-  {
-    if(m_picYuvDepthRec[iViewIdx])
-    {
-      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvDepthRec[iViewIdx]->begin();
-      Int iSize = Int( m_picYuvDepthRec[iViewIdx]->size() );
-      for ( Int i = 0; i < iSize; i++ )
-      {
-        TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
-        if(pcPicYuvRec)
-        {
-          pcPicYuvRec->destroy();
-          delete pcPicYuvRec; 
-          pcPicYuvRec = NULL;
-        }
-      } 
-    }
-  }
+#if H_MV
+  for(Int layer=0; layer<m_picYuvRec.size(); layer++)
+  {
+    if(m_picYuvRec[layer])
+    {
+      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[layer]->begin();
+      Int iSize = Int( m_picYuvRec[layer]->size() );
+#else
+  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
+  
+  Int iSize = Int( m_cListPicYuvRec.size() );
+#endif
+
+  for ( Int i = 0; i < iSize; i++ )
+  {
+    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
+    pcPicYuvRec->destroy();
+    delete pcPicYuvRec; pcPicYuvRec = NULL;
+  }
+
+#if H_MV
+    }
+  }
+#endif  
 }
 
 /** \param iNumEncoded  number of encoded frames
  */
-Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, Int iViewIdx, Bool isDepth )
+#if H_MV
+Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId)
+#else
+Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
+#endif
 {
   Int i;
   
+#if H_MV
   if( iNumEncoded > 0 )
   {
-    TComList<TComPicYuv*>::iterator iterPicYuvRec = !isDepth ? m_picYuvRec[iViewIdx]->end() : m_picYuvDepthRec[iViewIdx]->end();
-  
-    for ( i = 0; i < iNumEncoded; i++ )
-    {
-      --iterPicYuvRec;
-    }
-  
-    for ( i = 0; i < iNumEncoded; i++ )
-    {
-      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
-      if( !isDepth )
+    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
+#else
+  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
+  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
+#endif
+
+  for ( i = 0; i < iNumEncoded; i++ )
+  {
+    --iterPicYuvRec;
+  }
+  
+  for ( i = 0; i < iNumEncoded; i++ )
+  {
+    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
+#if H_MV
+      if (m_pchReconFileList[layerId])
       {
-        if (m_pchReconFileList[iViewIdx])
-        {
-          m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
-        }
-      }
-      else
-      {
-        if (m_pchDepthReconFileList[iViewIdx])
-        {
-          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
-        }
+        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
       }
     }
@@ -1381,37 +899,24 @@
     }
   }
-}
-
-
-TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon )
-{
-  TComPic*    pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth);
-  TComPicYuv* pcPicYuv = NULL;
-
-  if (pcPic != NULL)
-  {
-    if( bRecon )
-    {
-      if ( pcPic->getReconMark() )
-      {
-        pcPicYuv = pcPic->getPicYuvRec();
-      }
-    }
-    else
-    {
-      pcPicYuv = pcPic->getPicYuvOrg();
-    }
-  };
-
-  return pcPicYuv;
-};
+#else
+    if (m_pchReconFile)
+    {
+      m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
+    }
+
+    const AccessUnit& au = *(iterBitstream++);
+    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
+    rateStatsAccum(au, stats);
+  }
+#endif
+}
 
 /**
  *
  */
-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++)
@@ -1419,16 +924,23 @@
     switch ((*it_au)->m_nalUnitType)
     {
-    case NAL_UNIT_CODED_SLICE:
-#if !QC_REM_IDV_B0046
-    case NAL_UNIT_CODED_SLICE_IDV:
-#endif
-    case NAL_UNIT_CODED_SLICE_TLA:
+    case NAL_UNIT_CODED_SLICE_TRAIL_R:
+    case NAL_UNIT_CODED_SLICE_TRAIL_N:
+    case NAL_UNIT_CODED_SLICE_TLA_R:
+    case NAL_UNIT_CODED_SLICE_TSA_N:
+    case NAL_UNIT_CODED_SLICE_STSA_R:
+    case NAL_UNIT_CODED_SLICE_STSA_N:
+    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
+    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
+    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
+    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
+    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
     case NAL_UNIT_CODED_SLICE_CRA:
-    case NAL_UNIT_CODED_SLICE_IDR:
+    case NAL_UNIT_CODED_SLICE_RADL_N:
+    case NAL_UNIT_CODED_SLICE_RADL_R:
+    case NAL_UNIT_CODED_SLICE_RASL_N:
+    case NAL_UNIT_CODED_SLICE_RASL_R:
+    case NAL_UNIT_VPS:
     case NAL_UNIT_SPS:
     case NAL_UNIT_PPS:
-#if VIDYO_VPS_INTEGRATION
-    case NAL_UNIT_VPS:
-#endif
       m_essentialBytes += *it_stats;
       break;
@@ -1441,137 +953,12 @@
 }
 
-#if HHI_INTERVIEW_SKIP
-Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap )
-{
-  AOT( iViewIdx <= 0);
-  AOT( iViewIdx >= m_iNumberOfViews );
-  AOF( m_cCameraData.getCurFrameId() == iPoc );
-  Int iViewSIdx      = m_cCameraData.getBaseId2SortedId()[iViewIdx];
-  Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0];
-
-  AOT( iViewSIdx == iFirstViewSIdx );
-
-  Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx);
-
-  m_cUsedPelsRenderer.setShiftLUTs(
-      m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
-      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
-      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
-      m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
-      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
-      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
-      -1
-      );
-
-  TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true );
-  AOF( pcPicYuvDepth);
-
-  m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft );
-}
-#endif
-#if HHI_VSO
-Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset )
-{
-  m_cRendererModel.setupPart( iHorOffset, Min( g_uiMaxCUHeight, m_iSourceHeight - iHorOffset ) ); 
-  Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ];
-
-  // setup base views
-  Int iNumOfBV = m_cRenModStrParser.getNumOfBaseViewsForView( iEncViewSIdx, iEncContent );
-
-  for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ )
-  {
-    Int iBaseViewSIdx;
-    Int iVideoDistMode;
-    Int iDepthDistMode;
-
-    m_cRenModStrParser.getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode );
-
-    AOT( iVideoDistMode < 0 || iVideoDistMode > 2 );
-
-    Int iBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iBaseViewSIdx ];
-
-    TComPicYuv* pcPicYuvVideoRec  = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, true  );
-    TComPicYuv* pcPicYuvDepthRec  = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , true  );
-    TComPicYuv* pcPicYuvVideoOrg  = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, false );
-    TComPicYuv* pcPicYuvDepthOrg  = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , false );
-
-    TComPicYuv* pcPicYuvVideoRef  = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg  : NULL;
-    TComPicYuv* pcPicYuvDepthRef  = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg  : NULL;
-
-    TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg  : pcPicYuvVideoRec;
-    TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg  : pcPicYuvDepthRec;
-
-    AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) );
-    AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) );
-    AOT( pcPicYuvDepthTest == NULL );
-    AOT( pcPicYuvVideoTest == NULL );
-
-    m_cRendererModel.setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef );
-  }
-
-  m_cRendererModel.setErrorMode( iEncViewSIdx, iEncContent, 0 );
-  // setup virtual views
-  Int iNumOfSV  = m_cRenModStrParser.getNumOfModelsForView( iEncViewSIdx, iEncContent );
-  for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ )
-  {
-    Int iOrgRefBaseViewSIdx;
-    Int iLeftBaseViewSIdx;
-    Int iRightBaseViewSIdx;
-    Int iSynthViewRelNum;
-    Int iModelNum;
-    Int iBlendMode;
-    m_cRenModStrParser.getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum );
-
-    Int iLeftBaseViewIdx    = -1;
-    Int iRightBaseViewIdx   = -1;
-
-    TComPicYuv* pcPicYuvOrgRef  = NULL;
-    Int**      ppiShiftLUTLeft  = NULL;
-    Int**      ppiShiftLUTRight = NULL;
-    Int**      ppiBaseShiftLUTLeft  = NULL;
-    Int**      ppiBaseShiftLUTRight = NULL;
-
-
-    Int        iDistToLeft      = -1;
-
-    Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum );
-
-    if ( iLeftBaseViewSIdx != -1 )
-    {
-      iLeftBaseViewIdx   = m_cCameraData.getBaseSortedId2Id()   [ iLeftBaseViewSIdx ];
-      ppiShiftLUTLeft    = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx  ][ iSynthViewIdx  ];
-    }
-
-    if ( iRightBaseViewSIdx != -1 )
-    {
-      iRightBaseViewIdx  = m_cCameraData.getBaseSortedId2Id()   [iRightBaseViewSIdx ];
-      ppiShiftLUTRight   = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ];
-    }
-
-    if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 )
-    {
-      iDistToLeft    = m_cCameraData.getRelDistLeft(  iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx);
-      ppiBaseShiftLUTLeft  = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx  ][ iRightBaseViewIdx ];
-      ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx  ];
-
-    }
-
-    if ( iOrgRefBaseViewSIdx != -1 )
-    {
-      pcPicYuvOrgRef = xGetPicYuvFromView( m_cCameraData.getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , iPoc, false, false );
-      AOF ( pcPicYuvOrgRef );
-    }
-
-    m_cRendererModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
-  }
-}
-#endif
-
-
-
-/*
 void TAppEncTop::printRateSummary()
 {
-  double time = (double) m_iFrameRcvd / m_iFrameRate;
+#if H_MV
+  Double time = (Double) m_frameRcvd[0] / m_iFrameRate;
+  printf("\n");
+#else
+  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
+#endif
   printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
 #if VERBOSE_RATE
@@ -1579,39 +966,7 @@
 #endif
 }
-*/
-
-std::vector<TComPic*> TAppEncTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps )
-{
-  std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL );
-  for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ )
-  {
-    TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth );
-    assert( pcRefPic != NULL );
-    apcRefPics[k] = pcRefPic;
-  }
-  return apcRefPics;
-}
-
-TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth )
-{
-  assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) );
-
-  TComList<TComPic*>* apcListPic = (isDepth ?  m_acTEncDepthTopList[viewIdx] : m_acTEncTopList[viewIdx])->getListPic() ;
-
-  TComPic* pcPic = NULL;
-  for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++)
-  {
-    if( (*it)->getPOC() == poc )
-    {
-      pcPic = *it ;
-      break ;
-    }
-  }
-
-  return pcPic;
-};
-  
-#if RWTH_SDC_DLT_B0036
-Void TAppEncTop::xAnalyzeInputBaseDepth(Int iViewIdx, UInt uiNumFrames)
+
+#if H_3D_DIM_DLT
+Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps)
 {
   TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
@@ -1621,9 +976,9 @@
   TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
   
-  UInt uiMaxDepthValue = g_uiIBDI_MAX;
+  UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1);
   
   Bool abValidDepths[256];
   
-  depthVideoFile->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
+  depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
   
   // initialize boolean array
@@ -1639,5 +994,5 @@
   for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
   {
-    depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad, false );
+    depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad );
     
     // check all pixel values
@@ -1655,4 +1010,5 @@
   
   depthVideoFile->close();
+  delete depthVideoFile; 
   
   pcDepthPicYuvOrg->destroy();
@@ -1660,72 +1016,234 @@
   
   // convert boolean array to idx2Depth LUT
-  UInt* auiIdx2DepthValue = (UInt*) calloc(uiMaxDepthValue, sizeof(UInt));
-  UInt uiNumDepthValues = 0;
-  for(UInt p=0; p<=uiMaxDepthValue; p++)
+  Int* aiIdx2DepthValue = (Int*) calloc(uiMaxDepthValue, sizeof(Int));
+  Int iNumDepthValues = 0;
+  for(Int p=0; p<=uiMaxDepthValue; p++)
   {
     if( abValidDepths[p] == true)
     {
-      auiIdx2DepthValue[uiNumDepthValues++] = p;
-    }
-  }
-  
-  if( uiNumFrames == 0 || ceil(Log2(uiNumDepthValues)) == ceil(Log2(g_uiIBDI_MAX)) )
+      aiIdx2DepthValue[iNumDepthValues++] = p;
+    }
+  }
+  
+  if( uiNumFrames == 0 || numBitsForValue(iNumDepthValues) == g_bitDepthY )
   {
     // don't use DLT
-    m_acTEncDepthTopList[iViewIdx]->setUseDLT(false);
-    m_acTEncDepthTopList[iViewIdx]->getSPS()->setUseDLT(false);
+    vps->setUseDLTFlag(layer, false);
   }
   
   // assign LUT
-  if( m_acTEncDepthTopList[iViewIdx]->getUseDLT() )
-    m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs(auiIdx2DepthValue, uiNumDepthValues);
-  else
-    m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs();
+  if( vps->getUseDLTFlag(layer) )
+    vps->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues);
   
   // free temporary memory
-  free(auiIdx2DepthValue);
-}
-#endif
-
-#if MERL_VSP_C0152
-
-Void TAppEncTop::setBWVSPLUT(
-#if MERL_VSP_NBDV_RefVId_Fix_D0166
-        Int iNeighborViewId,
-#endif
-        Int iCodedViewIdx, Int gopId, Bool isDepth)
-{
-  //first view does not have VSP 
-  if((iCodedViewIdx == 0)) return;
-
-  AOT( iCodedViewIdx <= 0);
-  AOT( iCodedViewIdx >= m_iNumberOfViews );
-#if !MERL_VSP_NBDV_RefVId_Fix_D0166
-  Int iNeighborViewId = 0;
-#endif
-  //setting look-up table
-  Int* piShiftLUT = m_cCameraData.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0];
-
-  if(isDepth)
-  {
-    TEncSlice* pcEncSlice = (TEncSlice*) m_acTEncDepthTopList[iCodedViewIdx]->getSliceEncoder();
-#if MERL_VSP_NBDV_RefVId_Fix_D0166
-    pcEncSlice->setBWVSPLUTParam(  piShiftLUT, LOG2_DISP_PREC_LUT, iNeighborViewId );
-#else
-    pcEncSlice->setBWVSPLUTParam(  piShiftLUT, LOG2_DISP_PREC_LUT );
-#endif
-  }
-  else
-  {
-    TEncSlice* pcEncSlice = (TEncSlice*) m_acTEncTopList[iCodedViewIdx]->getSliceEncoder();
-#if MERL_VSP_NBDV_RefVId_Fix_D0166
-    pcEncSlice->setBWVSPLUTParam(  piShiftLUT, LOG2_DISP_PREC_LUT, iNeighborViewId );
-#else
-    pcEncSlice->setBWVSPLUTParam(  piShiftLUT, LOG2_DISP_PREC_LUT );
-#endif
-  }
-
-}
-#endif
-
+  free(aiIdx2DepthValue);
+}
+#endif
+
+#if H_MV
+Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps )
+{   
+  vps.setScalabilityMask( m_scalabilityMask ); 
+  for( Int dim = 0; dim < m_dimIds.size(); dim++ )
+  {
+    vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
+    for( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
+    {        
+      vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] );        
+    }  
+  }
+}
+
+Void TAppEncTop::xSetDependencies( TComVPS& vps )
+{
+  // Direct dependency flags + dependency types
+  for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ )
+  {
+    for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ )
+    {
+      vps.setDirectDependencyFlag( depLayer, refLayer, false); 
+      vps.setDirectDependencyType( depLayer, refLayer,    -1 ); 
+    }
+    }
+  for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ )
+  {
+    Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); 
+    assert(  numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); 
+    for( Int i = 0; i < numRefLayers; i++ )
+    {
+      Int refLayer = m_directRefLayers[depLayer][i]; 
+      vps.setDirectDependencyFlag( depLayer, refLayer, true); 
+      vps.setDirectDependencyType( depLayer, refLayer,m_dependencyTypes[depLayer][i]); 
+    }
+  }
+
+  // Max temporal id for inter layer reference pictures
+  for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++)
+    {
+    Int maxTid = -1; 
+    for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++)
+      {
+      for( Int i = 0; i < getGOPSize(); i++ ) 
+      {        
+        GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][i];
+        GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][i];
+        
+        for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
+        {        
+          if ( m_directRefLayers[ curLayerIdInVps ][ geCur.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps )
+          {
+            maxTid = std::max( maxTid, geRef.m_temporalId ); 
+          }
+        }
+      }
+    }
+    vps.setMaxTidIlRefPicPlus1( refLayerIdInVps, maxTid + 1 );
+  }
+
+  // Max one active ref layer flag
+  Bool maxOneActiveRefLayerFlag = true;  
+  for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; currLayerIdInVps++)
+  {
+    for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) 
+    {        
+      GOPEntry ge =  m_GOPListMvc[currLayerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
+      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); 
+    }            
+}
+
+  vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag );
+  vps.setRefLayers(); 
+}; 
+
+Void TAppEncTop::xSetLayerIds( TComVPS& vps )
+{
+  vps.setSplittingFlag     ( m_splittingFlag );
+
+  Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 ); 
+  Int  maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ; 
+
+  vps.setVpsMaxLayerId( maxNuhLayerId ); 
+  vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); 
+
+  for (Int layer = 0; layer < m_numberOfLayers; layer++ )
+  {
+    vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer ); 
+    vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer ); 
+  }
+}
+
+Int TAppEncTop::xGetMax( std::vector<Int>& vec )
+{
+  Int maxVec = 0; 
+  for ( Int i = 0; i < vec.size(); i++)    
+    maxVec = max( vec[i], maxVec ); 
+  return maxVec;
+}
+
+Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps )
+{ 
+  const Int vpsNumProfileTierLevelMinus1 = 0; //TBD
+  vps.setVpsNumProfileTierLevelMinus1( vpsNumProfileTierLevelMinus1 ); 
+  
+  for (Int i = 0; i <= vps.getVpsNumProfileTierLevelMinus1(); i++ )
+  {
+    vps.setVpsProfilePresentFlag( i, true ); 
+  }
+}
+
+
+Void TAppEncTop::xSetLayerSets( TComVPS& vps )
+{   
+  // Layer sets
+  vps.setVpsNumLayerSetsMinus1   ( m_vpsNumLayerSets - 1 ); 
+  vps.setVpsNumberLayerSetsMinus1( vps.getVpsNumLayerSetsMinus1() ); 
+    
+  for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
+  {
+    for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ )
+    {
+      vps.setLayerIdIncludedFlag( false, lsIdx, layerId ); 
+    }
+    for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++)
+    {       
+      vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) ); 
+    } 
+  }
+
+  Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); 
+  // Additional output layer sets + profileLevelTierIdx
+  vps.setDefaultOneTargetOutputLayerFlag   ( m_defaultOneTargetOutputLayerFlag ); 
+  vps.setMoreOutputLayerSetsThanDefaultFlag( numAddOuputLayerSets       != 0 );   
+  vps.setNumAddOutputLayerSetsMinus1       ( numAddOuputLayerSets - 1        ); 
+
+  for (Int lsIdx = 1; lsIdx < m_vpsNumLayerSets; lsIdx++)
+  {
+    vps.setProfileLevelTierIdx( lsIdx, m_profileLevelTierIdx[ lsIdx ] ); 
+  }
+
+  for (Int addOutLs = 0; addOutLs < numAddOuputLayerSets; addOutLs++ )
+  {
+    vps.setProfileLevelTierIdx( m_vpsNumLayerSets + addOutLs, m_profileLevelTierIdx[ addOutLs ] ); 
+
+    Int refLayerSetIdx = m_outputLayerSetIdx[ addOutLs ];     
+    vps.setOutputLayerSetIdxMinus1( m_vpsNumLayerSets + addOutLs, refLayerSetIdx - 1 ); 
+
+    for (Int i = 0; i < m_layerIdsInSets[ refLayerSetIdx].size(); i++ )
+    {
+      Bool outputLayerFlag = false; 
+      for (Int j = 0; j < m_layerIdsInAddOutputLayerSet[ addOutLs ].size(); j++ )
+      {
+        if (  m_layerIdsInAddOutputLayerSet[addOutLs][ j ] == m_layerIdsInSets[ refLayerSetIdx][ i ] )
+        {
+          outputLayerFlag = true; 
+          break; 
+        }
+      }
+      vps.setOutputLayerFlag( m_vpsNumLayerSets + addOutLs, i, outputLayerFlag );       
+    }
+  }
+}
+#endif
+#if H_3D
+Void TAppEncTop::xSetVPSExtension2( TComVPS& vps )
+{
+  for ( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
+  {
+    Bool isDepth      = ( vps.getDepthId( layer ) == 1 ) ;
+    Bool isLayerZero  = ( layer == 0 ); 
+
+#if H_3D_ARP
+    vps.setUseAdvRP        ( layer, ( isDepth || isLayerZero ) ? 0 : m_uiUseAdvResPred );
+    vps.setARPStepNum      ( layer, ( isDepth || isLayerZero ) ? 1 : H_3D_ARP_WFNR     );
+#endif  
+
+#if H_3D_DIM
+    vps.setVpsDepthModesFlag( layer, isDepth && !isLayerZero && (m_useDMM || m_useRBC || m_useSDC || m_useDLT ) );
+#if H_3D_DIM_DLT
+    vps.setUseDLTFlag( layer , isDepth && m_useDLT );
+    if( vps.getUseDLTFlag( layer ) )
+    {
+      xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod, 24), &vps);
+    }
+#endif
+#endif
+
+#if H_3D_IV_MERGE
+    vps.setIvMvPredFlag         ( layer, !isLayerZero && !isDepth && m_ivMvPredFlag ); 
+#endif
+#if H_3D_NBDV_REF
+    vps.setDepthRefinementFlag  ( layer, !isLayerZero && !isDepth && m_depthRefinementFlag );         
+#endif
+#if H_3D_VSP
+    vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && m_viewSynthesisPredFlag );         
+#endif      
+#if LGE_INTER_SDC_E0156
+    vps.setInterSDCFlag( layer, !isLayerZero && isDepth && m_bDepthInterSDCFlag );
+#endif
+  }  
+#if H_3D_TMVP
+  vps.setIvMvScalingFlag( m_ivMvScalingFlag );   
+#endif
+}
+#endif
 //! \}
Index: trunk/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 443)
+++ trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 608)
@@ -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.
  *
@@ -46,6 +46,5 @@
 #include "TLibCommon/AccessUnit.h"
 #include "TAppEncCfg.h"
-#include "TLibCommon/TComDepthMapGenerator.h"
-#if HHI_VSO || HHI_INTERVIEW_SKIP
+#if H_3D
 #include "../../Lib/TLibRenderer/TRenTop.h"
 #endif
@@ -63,41 +62,31 @@
 private:
   // class interface
-  std::vector<TEncTop*>      m_acTEncTopList ;
-  std::vector<TEncTop*>      m_acTEncDepthTopList ;
+#if H_MV
+  std::vector<TEncTop*>      m_acTEncTopList ;              ///< encoder class per layer 
   std::vector<TVideoIOYuv*>  m_acTVideoIOYuvInputFileList;  ///< input YUV file
-  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvDepthInputFileList;
   std::vector<TVideoIOYuv*>  m_acTVideoIOYuvReconFileList;  ///< output reconstruction file
-  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvDepthReconFileList;
+  
+  std::vector<TComList<TComPicYuv*>*>  m_picYuvRec;         ///< list of reconstruction YUV files
 
-  std::vector< TComList<TComPicYuv*>* >  m_picYuvRec;       ///< list of reconstruction YUV files
-  std::vector< TComList<TComPicYuv*>* >  m_picYuvDepthRec;         
+  std::vector<Int>           m_frameRcvd;                   ///< number of received frames 
 
-  std::vector<Int>           m_frameRcvd;                  ///< number of received frames
-  std::vector<Int>           m_depthFrameRcvd;   
-
-  unsigned                   m_essentialBytes;
-  unsigned                   m_totalBytes;
-
-#if DEPTH_MAP_GENERATION
-#if VIDYO_VPS_INTEGRATION
-  TComVPSAccess               m_cVPSAccess;
-#endif
-  TComSPSAccess               m_cSPSAccess;
-  TComAUPicAccess             m_cAUPicAccess;
+  TComPicLists               m_ivPicLists;                  ///< picture buffers of encoder instances
+  TComVPS                    m_vps;                         ///< vps
+#else
+  TEncTop                    m_cTEncTop;                    ///< encoder class
+  TVideoIOYuv                m_cTVideoIOYuvInputFile;       ///< input YUV file
+  TVideoIOYuv                m_cTVideoIOYuvReconFile;       ///< output reconstruction file
+  
+  TComList<TComPicYuv*>      m_cListPicYuvRec;              ///< list of reconstruction YUV files
+  
+  Int                        m_iFrameRcvd;                  ///< number of received frames
 #endif
 
-#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
-  TComVPS                     m_cVPS;
-#endif
-  
-#if HHI_VSO
+  UInt m_essentialBytes;
+  UInt m_totalBytes;
+#if H_3D_VSO
   TRenTop                     m_cRendererTop; 
   TRenModel                   m_cRendererModel;   
 #endif
-
-#if HHI_INTERVIEW_SKIP
-  TRenTop  m_cUsedPelsRenderer;                               ///< renderer for used pels map
-#endif
-
 protected:
   // initialization
@@ -108,68 +97,45 @@
   
   /// obtain required buffers
-  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec, Int iViewIdx, Bool isDepth);
-  
+#if H_MV
+  Void  xGetBuffer(TComPicYuv*& rpcPicYuvRec, UInt layer);
+#else
+  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec);
+#endif
+
   /// delete allocated buffers
   Void  xDeleteBuffer     ();
   
   // file I/O
-  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, Int iViewIdx, Bool isDepth); ///< write bitstream to file
-  void rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& stats);
-  // void printRateSummary();
-  
-  TComPic* xGetPicFromView( Int viewId, Int iPoc, Bool isDepth );
-  TComPicYuv* xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon );
-  
+#if H_MV
+  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId); ///< write bitstream to file
+#else
+  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<UInt>& stats);
+  void printRateSummary();
+
+#if H_MV
+  Void xSetLayerIds               ( TComVPS& vps );  
+  Void xSetDimensionIdAndLength   ( TComVPS& vps );
+  Void xSetDependencies           ( TComVPS& vps );
+  Void xSetLayerSets              ( TComVPS& vps );
+  Void xSetProfileTierLevel       ( TComVPS& vps );
+  Int  xGetMax( std::vector<Int>& vec);
+#endif
+#if H_3D
+  Void xSetVPSExtension2( TComVPS& vps );
+#endif
+#if H_3D_DIM_DLT
+  Void  xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps);
+#endif
 public:
   TAppEncTop();
   virtual ~TAppEncTop();
-
-
+  
   Void        encode      ();                               ///< main encoding function
-  TEncTop*    getTEncTop( Int viewId, Bool isDepth );   
-
-  std::vector<TComPic*> getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps );
-  TComPic*              getPicFromView     ( Int viewId, Int poc, Bool isDepth ) { return xGetPicFromView( viewId, poc, isDepth ); }
-  TComPicYuv*           getPicYuvFromView  ( Int iViewIdx, Int iPoc, bool bDepth, Bool bRecon ) { return xGetPicYuvFromView( iViewIdx, iPoc, bDepth, bRecon ); }
-
-#if HHI_INTERVIEW_SKIP
-  Void                  getUsedPelsMap   ( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedPelsMap );
-#endif
-#if HHI_VSO
-  Void                  setupRenModel    ( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset );
-#endif
-  
-#if QC_MVHEVC_B0046
-  TComVPS*          getVPS()  { return &m_cVPS; }
-#endif
-#if VIDYO_VPS_INTEGRATION
-  TComVPS*          getVPS()  { return &m_cVPS; }
-  TComVPSAccess*    getVPSAccess  () { return &m_cVPSAccess;   }
-#endif
-  
-#if DEPTH_MAP_GENERATION
-  TComSPSAccess*    getSPSAccess  () { return &m_cSPSAccess;   }
-  TComAUPicAccess*  getAUPicAccess() { return &m_cAUPicAccess; }
-#endif
-
-#if HHI_VSO
-  TRenModel* getRenModel    () { return  &m_cRendererModel ; }; 
-#endif
-
-#if HHI_VSO
-private:
-  Void  xStoreVSORefPicsInBuffer();                                                   ///< read in External Ref pic from file and store in buffer
-#endif
-  
-#if RWTH_SDC_DLT_B0036
-  Void  xAnalyzeInputBaseDepth(Int iViewIdx, UInt uiNumFrames);
-#endif
-
-#if MERL_VSP_C0152
-#if MERL_VSP_NBDV_RefVId_Fix_D0166
-  Void setBWVSPLUT( Int refViewIdx, Int iCodedViewIdx, Int gopId, Bool isDepth);
+#if H_MV
+  TEncTop*    getTEncTop( UInt layer ) { return  m_acTEncTopList[layer]; }  ///< return pointer to encoder class for specific layer
 #else
-  Void setBWVSPLUT( Int iCodedViewIdx, Int gopId, Bool isDepth);
-#endif
+  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 443)
+++ trunk/source/App/TAppEncoder/encmain.cpp	(revision 608)
@@ -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
@@ -52,5 +57,9 @@
   // print information
   fprintf( stdout, "\n" );
+#if H_MV
   fprintf( stdout, "3D-HTM Software: Encoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION );  
+#else
+  fprintf( stdout, "HM software: Encoder Version [%s]", NV_VERSION );
+#endif
   fprintf( stdout, NVM_ONOS );
   fprintf( stdout, NVM_COMPILEDBY );
@@ -62,7 +71,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;
   }
