Index: branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 438)
+++ branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 446)
@@ -79,4 +79,9 @@
   m_aidQP = NULL;
 #endif
+#if J0149_TONE_MAPPING_SEI
+  m_startOfCodedInterval = NULL;
+  m_codedPivotValue = NULL;
+  m_targetPivotValue = NULL;
+#endif
 }
 
@@ -102,9 +107,26 @@
     delete[] m_aidQP;
   }
+#endif
+#if J0149_TONE_MAPPING_SEI
+  if ( m_startOfCodedInterval )
+  {
+    delete[] m_startOfCodedInterval;
+    m_startOfCodedInterval = NULL;
+  }
+   if ( m_codedPivotValue )
+  {
+    delete[] m_codedPivotValue;
+    m_codedPivotValue = NULL;
+  }
+  if ( m_targetPivotValue )
+  {
+    delete[] m_targetPivotValue;
+    m_targetPivotValue = NULL;
+  }
+#endif
+#if !H_MV
   free(m_pchInputFile);
 #endif
-
   free(m_pchBitstreamFile);
-
 #if H_MV
   for(Int i = 0; i< m_pchReconFileList.size(); i++ )
@@ -116,10 +138,8 @@
   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++ )
@@ -131,4 +151,15 @@
     }
   }
+#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 ); 
 #endif
 }
@@ -300,11 +331,8 @@
   string cfg_InputFile;
 #endif
-
   string cfg_BitstreamFile;
-
 #if !H_MV
   string cfg_ReconFile;
 #endif
-
 #if H_MV
   vector<Int>   cfg_dimensionLength; 
@@ -316,9 +344,13 @@
 #endif 
 #endif
-
   string cfg_dQPFile;
   string cfg_ColumnWidth;
   string cfg_RowHeight;
   string cfg_ScalingListFile;
+#if J0149_TONE_MAPPING_SEI
+  string cfg_startOfCodedInterval;
+  string cfg_codedPivotValue;
+  string cfg_targetPivotValue;
+#endif
 #if SIGNAL_BITRATE_PICRATE_IN_VPS
   string cfg_bitRateInfoPresentFlag;
@@ -335,5 +367,4 @@
   
   // 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")
@@ -341,7 +372,5 @@
   ("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")
@@ -349,5 +378,4 @@
   ("ReconFile,o",           cfg_ReconFile,     string(""), "Reconstructed YUV output file name")
 #endif
-
 #if H_MV
   ("NumberOfLayers",        m_numberOfLayers     , 1,                     "Number of layers")
@@ -365,5 +393,4 @@
   ("SplittingFlag",         m_splittingFlag      , false                , "Splitting Flag")    
 #endif
-
   ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
   ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
@@ -387,5 +414,4 @@
 
   // 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)")
@@ -417,5 +443,7 @@
   ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
   ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
+#if !L0034_COMBINED_LIST_CLEANUP
   ("ListCombination,-lc",     m_bUseLComb,               true, "Combined reference list for uni-prediction estimation in B-slices")
+#endif
   // motion options
   ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
@@ -473,4 +501,7 @@
   ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0 )
   ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false )
+#if L0386_DB_METRIC
+  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
+#endif
 
   // Coding tools
@@ -591,4 +622,36 @@
   ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
   ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
+#if J0149_TONE_MAPPING_SEI
+  ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false, "Control generation of Tone Mapping SEI messages")
+  ("SEIToneMapId",                             m_toneMapId,                        0, "Specifies Id of Tone Mapping SEI message for a given session")
+  ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false, "Indicates that Tone Mapping SEI message cancels the persistance or follows")
+  ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true, "Specifies the persistence of the Tone Mapping SEI message")
+  ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
+  ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8, "Specifies Output BitDepth of Tome mapping function")
+  ("SEIToneMapModelId",                        m_toneMapModelId,                   0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
+                                                                                      "\t0:  linear mapping with clipping\n"
+                                                                                      "\t1:  sigmoidal mapping\n"
+                                                                                      "\t2:  user-defined table mapping\n"
+                                                                                      "\t3:  piece-wise linear mapping\n"
+                                                                                      "\t4:  luminance dynamic range information ")
+  ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0, "Specifies the minimum value in mode 0")
+  ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023, "Specifies the maxmum value in mode 0")
+  ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512, "Specifies the centre point in mode 1")
+  ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
+  ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""), "Array of user-defined mapping table")
+  ("SEIToneMapNumPivots",                             m_numPivots,                                0, "Specifies the number of pivot points in mode 3")
+  ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
+  ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
+  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0, "Indicates the camera ISO speed for daylight illumination")
+  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
+  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0, "Specifies the sign of ExposureCompensationValue")
+  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0, "Specifies the numerator of ExposureCompensationValue")
+  ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2, "Specifies the denominator of ExposureCompensationValue")
+  ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350, "Specifies reference screen brightness setting in units of candela per square metre")
+  ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800, "Indicates the luminance dynamic range")
+  ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16, "Specifies luma sample value of the nominal black level assigned decoded pictures")
+  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
+  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
+#endif
   ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
   ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
@@ -611,4 +674,10 @@
   ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0, "Control generation of gradual decoding refresh information SEI message")
   ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0, "Control generation of decoding unit information SEI message.")
+#if L0208_SOP_DESCRIPTION_SEI
+  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
+#endif
 #if SIGNAL_BITRATE_PICRATE_IN_VPS
   ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0, "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
@@ -624,4 +693,29 @@
   ("ConstantPicRateIdc",           cfg_constantPicRateIdc,            string(""), "List of constant picture rate IDCs; include non-negative number even if corresponding flag is 0")
 #endif
+#if H_3D
+  ("CameraParameterFile,cpf", m_pchCameraParameterFile,    (Char *) 0, "Camera Parameter File Name")
+  ("BaseViewCameraNumbers" ,  m_pchBaseViewCameraNumbers,  (Char *) 0, "Numbers of base views")
+  ("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")
+  ("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" )      
+  ("VSOEarlySkip",                    m_bVSOEarlySkip           , true          , "Early skip of VSO computation if synthesis error assumed to be zero" )      
+  
+  ("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 //HHI_VSO
+#endif //H_3D
   ;
   
@@ -661,5 +755,4 @@
   }
 #endif
-
   po::setDefaults(opts);
   const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
@@ -681,15 +774,11 @@
    */
   /* 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());
   
@@ -755,5 +844,4 @@
   free ( pRowHeight   ); 
 #endif
-
 #if SIGNAL_BITRATE_PICRATE_IN_VPS
   readBoolString(cfg_bitRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_bitRateInfoPresentFlag, "bit rate info. present flag" );
@@ -839,4 +927,19 @@
 #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
 
@@ -914,9 +1017,156 @@
   m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
 
+#if J0149_TONE_MAPPING_SEI
+  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
+  {
+    Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str());
+    Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str());
+    Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str());
+    if( m_toneMapModelId == 2 && pcStartOfCodedInterval )
+    {
+      char *startOfCodedInterval;
+      UInt num = 1u<< m_toneMapTargetBitDepth;
+      m_startOfCodedInterval = new Int[num];
+      ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num );
+      startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
+      int i = 0;
+      while( startOfCodedInterval && ( i < num ) )
+      {
+        m_startOfCodedInterval[i] = atoi( startOfCodedInterval );
+        startOfCodedInterval = strtok(NULL, " .");
+        i++;
+      }
+    } 
+    else
+    {
+      m_startOfCodedInterval = NULL;
+    }
+    if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) )
+    {
+      if( pcCodedPivotValue && pcTargetPivotValue )
+      {
+        char *codedPivotValue;
+        char *targetPivotValue;
+        m_codedPivotValue = new Int[m_numPivots];
+        m_targetPivotValue = new Int[m_numPivots];
+        ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) );
+        ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) );
+        codedPivotValue = strtok(pcCodedPivotValue, " .");
+        int i=0;
+        while(codedPivotValue&&i<m_numPivots)
+        {
+          m_codedPivotValue[i] = atoi( codedPivotValue );
+          codedPivotValue = strtok(NULL, " .");
+          i++;
+        }
+        i=0;
+        targetPivotValue = strtok(pcTargetPivotValue, " .");
+        while(targetPivotValue&&i<m_numPivots)
+        {
+          m_targetPivotValue[i]= atoi( targetPivotValue );
+          targetPivotValue = strtok(NULL, " .");
+          i++;
+        }
+      }
+    }
+    else
+    {
+      m_codedPivotValue = NULL;
+      m_targetPivotValue = NULL;
+    }
+  }
+#endif
+#if H_3D
+  // set global varibles
+  xSetGlobal();
+#if H_3D_VSO
+// Table base optimization 
+  // Q&D
+  Double adLambdaScaleTable[] = 
+  {  0.031250, 0.031639, 0.032029, 0.032418, 0.032808, 0.033197, 0.033586, 0.033976, 0.034365, 0.034755, 
+     0.035144, 0.035533, 0.035923, 0.036312, 0.036702, 0.037091, 0.037480, 0.037870, 0.038259, 0.038648, 
+     0.039038, 0.039427, 0.039817, 0.040206, 0.040595, 0.040985, 0.041374, 0.041764, 0.042153, 0.042542, 
+     0.042932, 0.043321, 0.043711, 0.044100, 0.044194, 0.053033, 0.061872, 0.070711, 0.079550, 0.088388, 
+     0.117851, 0.147314, 0.176777, 0.235702, 0.294628, 0.353553, 0.471405, 0.589256, 0.707107, 0.707100, 
+     0.753550, 0.800000  
+  }; 
+  if ( 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 ), 
+                                      g_bitDepthY,
+                                (UInt)m_iCodedCamParPrecision,
+                                      m_FrameSkip,
+                                (UInt)m_framesToBeEncoded,
+                                      m_pchCameraParameterFile,
+                                      m_pchBaseViewCameraNumbers,
+                                      NULL,
+                                      m_cRenModStrParser.getSynthViews(),
+                                      LOG2_DISP_PREC_LUT );
+}
+else if ( m_bUseVSO && m_uiVSOMode != 4 )
+{
+  m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
+                                      g_bitDepthY,
+                                (UInt)m_iCodedCamParPrecision,
+                                      m_FrameSkip,
+                                (UInt)m_framesToBeEncoded,
+                                      m_pchCameraParameterFile,
+                                      m_pchBaseViewCameraNumbers,
+                                      m_pchVSOConfig,
+                                      NULL,
+                                      LOG2_DISP_PREC_LUT );
+}
+else
+{
+  m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
+    g_bitDepthY,
+    (UInt) m_iCodedCamParPrecision,
+    m_FrameSkip,
+    (UInt) m_framesToBeEncoded,
+    m_pchCameraParameterFile,
+    m_pchBaseViewCameraNumbers,
+    NULL,
+    NULL,
+    LOG2_DISP_PREC_LUT );
+}
+#else
+  m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
+    g_bitDepthY,
+    (UInt) m_iCodedCamParPrecision,
+    m_FrameSkip,
+    (UInt) m_framesToBeEncoded,
+    m_pchCameraParameterFile,
+    m_pchBaseViewCameraNumbers,
+    NULL,
+    NULL,
+    LOG2_DISP_PREC_LUT );
+#endif
+  m_cCameraData.check( false, true );
+#endif
   // check validity of input parameters
   xCheckParameter();
-  
+
+#if !H_3D
   // set global varibles
   xSetGlobal();
+#endif
   
   // print-out parameters
@@ -1013,5 +1263,4 @@
   xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
   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");
@@ -1026,6 +1275,7 @@
   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 ) )
@@ -1037,6 +1287,6 @@
  for( Int dim = 0; dim < m_dimIds.size(); dim++ )
  {
-   xConfirmPara( m_dimIds[dim].size() < m_numberOfLayers,  "DimensionId must be given for all layers and all dimensions. ");
-   xConfirmPara( m_dimIds[dim][0] != 0,                    "DimensionId of layer 0 must be 0 in all dimensions. " );
+   xConfirmPara( m_dimIds[dim].size() < m_numberOfLayers,  "DimensionId must be given for all layers and all dimensions. ");   
+   xConfirmPara( ( dim != viewDimPosition ) &&  (m_dimIds[dim][0] != 0), "DimensionId of layer 0 must be 0. " );
    xConfirmPara( m_dimensionIdLen[dim] < 1 || m_dimensionIdLen[dim] > 8, "DimensionIdLen must be greater than 0 and less than 9 in all dimensions. " ); 
    for( Int i = 1; i < m_numberOfLayers; i++ )
@@ -1073,9 +1323,10 @@
      {
        Bool inc = m_dimIds[ lastDiff ][ i ] > m_dimIds[ lastDiff ][ j ]; 
-       if ( !inc )
+       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( !inc,  "DimensionIds shall be increasing within one dimension. " );
+       xConfirmPara( shallBeButIsNotIncreasing && ( lastDiff != viewDimPosition ),  "DimensionIds shall be increasing within one dimension. " );
      }
    }
@@ -1083,6 +1334,4 @@
 
 #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" );
@@ -1185,4 +1434,17 @@
   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;
@@ -1348,5 +1610,4 @@
       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 */
@@ -1609,11 +1870,23 @@
   {
     m_numReorderPics[i] = 0;
+#if L0323_DPB
+    m_maxDecPicBuffering[i] = 1;
+#else
     m_maxDecPicBuffering[i] = 0;
+#endif
   }
   for(Int i=0; i<m_iGOPSize; i++) 
   {
+#if L0323_DPB
+    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
+#else
     if(m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
-    {
+#endif
+    {
+#if L0323_DPB
+      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
+#else
       m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics;
+#endif
     }
     Int highestDecodingNumberWithLowerPOC = 0; 
@@ -1646,4 +1919,11 @@
       m_numReorderPics[i+1] = m_numReorderPics[i];
     }
+#if L0323_DPB
+    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
+    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
+    {
+      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
+    }
+#else
     // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
     if(m_numReorderPics[i] > m_maxDecPicBuffering[i])
@@ -1651,4 +1931,5 @@
       m_maxDecPicBuffering[i] = m_numReorderPics[i];
     }
+#endif
     // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
     if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
@@ -1657,4 +1938,13 @@
     }
   }
+
+
+#if L0323_DPB
+  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
+  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
+  {
+    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
+  }
+#else
   // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
   if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1])
@@ -1662,4 +1952,5 @@
     m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1];
   }
+#endif
 
   if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
@@ -1736,5 +2027,7 @@
     }
   }
+#if !L0034_COMBINED_LIST_CLEANUP
   xConfirmPara( m_bUseLComb==false && m_numReorderPics[MAX_TLAYER-1]!=0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" );  // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
+#endif
   xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
   xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
@@ -1743,4 +2036,17 @@
   xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
 
+#if J0149_TONE_MAPPING_SEI
+  if (m_toneMappingInfoSEIEnabled)
+  {
+    xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
+    xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
+    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
+    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
+    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
+    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
+    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
+  }
+#endif
+
 #if RATE_CONTROL_LAMBDA_DOMAIN
   if ( m_RCEnableRateControl )
@@ -1779,5 +2085,4 @@
   }
 #endif
-
 #if H_MV
   }
@@ -1827,7 +2132,5 @@
   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++)
@@ -1838,13 +2141,11 @@
   printf("Reconstruction File          : %s\n", m_pchReconFile          );
 #endif
-
-#if H_MV
- xPrintParaVector( "ViewId", m_viewId ); 
-#endif
-
+#if H_MV
+  xPrintParaVector( "ViewId", m_viewId ); 
+#endif
 #if H_3D
- xPrintParaVector( "DepthFlag", m_depthFlag ); 
-#endif
-
+  xPrintParaVector( "DepthFlag", m_depthFlag ); 
+  printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision);
+#endif
 #if H_MV  
   xPrintParaVector( "QP"               , m_fQP                ); 
@@ -1895,7 +2196,30 @@
 #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 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    );
+    printf("VSO Negative Distortion      : %d\n",    m_bAllowNegDist ? 1 : 0);
+    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");
-  
+#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           );
@@ -1908,5 +2232,7 @@
   printf("SQP:%d ", m_uiDeltaQpRD         );
   printf("ASR:%d ", m_bUseASR             );
+#if !L0034_COMBINED_LIST_CLEANUP
   printf("LComb:%d ", m_bUseLComb         );
+#endif
   printf("FEN:%d ", m_bUseFastEnc         );
   printf("ECU:%d ", m_bUseEarlyCU         );
@@ -1943,11 +2269,15 @@
   printf("TMVPMode:%d ", m_TMVPModeId     );
 #if ADAPTIVE_QP_SELECTION
-  printf("AQpS:%d", m_bUseAdaptQpSelect   );
+  printf("AQpS:%d ", m_bUseAdaptQpSelect   );
 #endif
 
   printf(" SignBitHidingFlag:%d ", m_signHideFlag);
-  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
-  printf("\n\n");
-  
+  printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
+#if H_3D_VSO
+  printf("VSO:%d ", m_bUseVSO   );
+  printf("WVSO:%d ", m_bUseWVSO );  
+#endif
+  printf("\n\n");  
+
   fflush(stdout);
 }
Index: branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 438)
+++ branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 446)
@@ -43,4 +43,9 @@
 #include "TLibEncoder/TEncCfg.h"
 #include <sstream>
+#if H_3D
+#include "TAppCommon/TAppComCamPara.h"
+#include "TLibRenderer/TRenModel.h"
+#include "TLibRenderer/TRenModSetupStrParser.h"
+#endif
 //! \ingroup TAppEncoder
 //! \{
@@ -60,17 +65,16 @@
   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
   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
-
-
-  // VPS specification
-#if H_MV
+  #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
@@ -83,6 +87,4 @@
   std::vector<Int>       m_dimensionIdLen;                   ///< Length of scalability dimension s 
 #endif
-
-
   Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
   // source specification
@@ -103,5 +105,4 @@
   Level::Tier   m_levelTier;
   Level::Name   m_level;
-
 #if L0046_CONSTRAINT_FLAGS
   Bool m_progressiveSourceFlag;
@@ -124,7 +125,13 @@
   GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
   Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
+#if L0323_DPB
+  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of pictures in the decoded picture buffer
+#else
   Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
 #endif
+#endif
+#if !L0034_COMBINED_LIST_CLEANUP
   Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
+#endif
   Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
   Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
@@ -207,4 +214,7 @@
   Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
   Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
+#if L0386_DB_METRIC
+  Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
+#endif
  
   // coding tools (PCM)
@@ -256,4 +266,31 @@
   Int       m_bufferingPeriodSEIEnabled;
   Int       m_pictureTimingSEIEnabled;
+#if J0149_TONE_MAPPING_SEI
+  Bool      m_toneMappingInfoSEIEnabled;
+  Int       m_toneMapId;
+  Bool      m_toneMapCancelFlag;
+  Bool      m_toneMapPersistenceFlag;
+  Int       m_toneMapCodedDataBitDepth;
+  Int       m_toneMapTargetBitDepth;
+  Int       m_toneMapModelId; 
+  Int       m_toneMapMinValue;
+  Int       m_toneMapMaxValue;
+  Int       m_sigmoidMidpoint;
+  Int       m_sigmoidWidth;
+  Int       m_numPivots;
+  Int       m_cameraIsoSpeedIdc;
+  Int       m_cameraIsoSpeedValue;
+  Int       m_exposureCompensationValueSignFlag;
+  Int       m_exposureCompensationValueNumerator;
+  Int       m_exposureCompensationValueDenomIdc;
+  Int       m_refScreenLuminanceWhite;
+  Int       m_extendedRangeWhiteLevel;
+  Int       m_nominalBlackLevelLumaCodeValue;
+  Int       m_nominalWhiteLevelLumaCodeValue;
+  Int       m_extendedWhiteLevelLumaCodeValue;
+  Int*      m_startOfCodedInterval;
+  Int*      m_codedPivotValue;
+  Int*      m_targetPivotValue;
+#endif
   Int       m_framePackingSEIEnabled;
   Int       m_framePackingSEIType;
@@ -265,4 +302,10 @@
   Int       m_gradualDecodingRefreshInfoEnabled;
   Int       m_decodingUnitInfoSEIEnabled;
+#if L0208_SOP_DESCRIPTION_SEI
+  Int       m_SOPDescriptionSEIEnabled;
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+  Int       m_scalableNestingSEIEnabled;
+#endif
   // weighted prediction
   Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
@@ -332,4 +375,35 @@
   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;
+  TAppComCamPara m_cCameraData;
+  Int       m_iCodedCamParPrecision;                          ///< precision for coding of camera parameters
+#if H_3D_VSO
+  Char*     m_pchVSOConfig;
+  Bool      m_bUseVSO;                                    ///< flag for using View Synthesis Optimization
+  Bool      m_bVSOLSTable;                                ///< Depth QP dependent Lagrange parameter optimization (m23714)
+  Bool      m_bVSOEarlySkip;                              ///< Early skip of VSO computation (JCT3V-A0093 modification 4)
+
+  //// 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
+  Bool      m_bAllowNegDist;                              ///< Allow negative distortion in VSO
+  UInt      m_uiVSOMode;                                  ///< Number of VSO Mode, 1 = , 2 = simple, org vs. ren, 3 = simple, ren vs. ren, 4 = full  
+
+  // 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)  
+
+  // LGE_WVSO_A0119
+  Bool      m_bUseWVSO;                                    ///< flag for using View Synthesis Optimization  
+  Int       m_iVSOWeight;
+  Int       m_iVSDWeight;
+  Int       m_iDWeight;
+
+  // Ren Model String
+  TRenModSetupStrParser       m_cRenModStrParser;
+#endif
+#endif
   // internal member functions
   Void  xSetGlobal      ();                                   ///< set global variables
@@ -337,5 +411,4 @@
   Void  xPrintParameter ();                                   ///< print configuration values
   Void  xPrintUsage     ();                                   ///< print usage
-
 #if H_MV
   template <typename T>
@@ -388,5 +461,4 @@
   Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
 #endif
-  
 #if H_MV
   Int   getGOPSize() { return m_iGOPSize; }
Index: branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 438)
+++ branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 446)
@@ -70,5 +70,9 @@
 Void TAppEncTop::xInitLibCfg()
 {
+#if H_MV
+  TComVPS& vps = m_vps;   
+#else
   TComVPS vps;
+#endif
   
 #if H_MV
@@ -111,9 +115,12 @@
   }
 #endif
-
 #if H_MV
   xSetLayerIds             ( vps );   
   xSetDimensionIdAndLength ( vps );
   xSetDirectDependencyFlags( vps );
+#if H_3D
+  vps.initViewIndex(); 
+  m_ivPicLists.setVPS      ( &vps ); 
+#endif
 
   for(Int layer = 0; layer < m_numberOfLayers; layer++)
@@ -128,18 +135,43 @@
     TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ];  // It is not a member, but this name helps avoiding code duplication !!!
     
-    m_cTEncTop.setLayerIdInVps( layer ); 
-    m_cTEncTop.setLayerId     ( vps.getLayerIdInNuh( layer ) );    
-    m_cTEncTop.setViewId      ( vps.getViewId      ( layer ) );
+    m_cTEncTop.setLayerIdInVps                 ( layer ); 
+    m_cTEncTop.setLayerId                      ( vps.getLayerIdInNuh( layer ) );    
+    m_cTEncTop.setViewId                       ( vps.getViewId      ( layer ) );
 #if H_3D
-    m_cTEncTop.setIsDepth     ( vps.getDepthId     ( layer ) != 0 );
-#endif
-    m_cTEncTop.setIvPicLists  ( &m_ivPicLists ); 
-#endif
-
+    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
+#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);
-
 #if L0046_CONSTRAINT_FLAGS
   m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
@@ -186,6 +218,7 @@
   m_cTEncTop.setQP                           ( m_iQP );
 #endif
+
   m_cTEncTop.setPad                          ( m_aiPad );
-    
+
 #if H_MV
   m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayerMvc[layer] );
@@ -207,4 +240,7 @@
   m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
   m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
+#if L0386_DB_METRIC
+  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
+#endif
 
   //====== Motion search ========
@@ -226,4 +262,5 @@
   Int lowestQP;
   lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
+
 #if H_MV
   if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layer] == lowestQP) && (m_useLossless == true))
@@ -243,5 +280,7 @@
   m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
   m_cTEncTop.setUseLossless                  ( m_useLossless );
+#if !L0034_COMBINED_LIST_CLEANUP
   m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
+#endif
 #if H_MV
   m_cTEncTop.setdQPs                         ( m_aidQP[layer]   );
@@ -321,4 +360,31 @@
   m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
   m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
+#if J0149_TONE_MAPPING_SEI
+  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
+  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
+  m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
+  m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
+  m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
+  m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
+  m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
+  m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
+  m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
+  m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
+  m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
+  m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
+  m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
+  m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
+  m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
+  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
+  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
+  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
+  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
+  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
+  m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
+  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
+  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
+  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
+  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
+#endif
   m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
   m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
@@ -330,4 +396,10 @@
   m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
   m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
+#if L0208_SOP_DESCRIPTION_SEI
+  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
+#endif
   m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
   m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
@@ -424,9 +496,44 @@
   }
 #endif
-
-#if H_MV
-  }
-#endif
-
+#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++ )
+      {
+        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 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
+    {
+      AOT(true);
+    }
+  }
+#endif
 }
 
@@ -579,5 +686,5 @@
 
         eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded);
-        allEos = allEos|eos[layer];
+        allEos = allEos||eos[layer];
 
         // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
@@ -585,5 +692,5 @@
         {
           flush          [layer] = true;
-          eos            [layer]   = true;
+          eos            [layer] = true;
           m_frameRcvd    [layer]--;
           m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]);
@@ -593,6 +700,20 @@
     for ( Int gopId=0; gopId < gopSize; gopId++ )
     {
+#if H_3D
+      UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
+      if ( iNextPoc < m_framesToBeEncoded )
+      {
+        m_cCameraData.update( iNextPoc );
+      }
+#endif
       for(Int layer=0; layer < m_numberOfLayers; layer++ )
       {
+#if H_3D_VSO        
+          if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
+          {
+            m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() );
+            m_acTEncTopList[layer]  ->setDispCoeff( m_cCameraData.getDispCoeff() );
+          }
+#endif
         Int   iNumEncoded = 0;
 
@@ -602,5 +723,4 @@
         outputAccessUnits.clear();
       }
-
     }
     gopSize = maxGopSize;
@@ -666,21 +786,4 @@
   return;
 }
-
-#if H_3D
-TEncTop* TAppEncTop::getTEncTopView( Int viewId, Bool isDepth )
-{
-  TEncTop* encoder = NULL;
-  for( Int layer = 0; layer < m_acTEncTopList.size(); layer++ )
-  {
-    if( m_acTEncTopList[layer]->getViewId()  == viewId &&
-        m_acTEncTopList[layer]->getIsDepth() == isDepth )
-    {
-      encoder = m_acTEncTopList[layer];
-      break;
-    }
-  }
-  return encoder;
-}
-#endif
 
 // ====================================================================================================================
@@ -694,5 +797,4 @@
  .
  */
-
 #if H_MV
 Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
@@ -722,5 +824,4 @@
 
   }
-
 #if H_MV
   m_picYuvRec[layer]->pushBack( rpcPicYuvRec );
@@ -732,5 +833,4 @@
 Void TAppEncTop::xDeleteBuffer( )
 {
-
 #if H_MV
   for(Int layer=0; layer<m_picYuvRec.size(); layer++)
@@ -757,5 +857,4 @@
   }
 #endif  
-
 }
 
@@ -787,5 +886,4 @@
   {
     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
-
 #if H_MV
       if (m_pchReconFileList[layerId])
@@ -815,5 +913,4 @@
   }
 #endif
-
 }
 
@@ -832,18 +929,18 @@
     case NAL_UNIT_CODED_SLICE_TRAIL_R:
     case NAL_UNIT_CODED_SLICE_TRAIL_N:
-    case NAL_UNIT_CODED_SLICE_TLA:
+    case NAL_UNIT_CODED_SLICE_TLA_R:
     case NAL_UNIT_CODED_SLICE_TSA_N:
     case NAL_UNIT_CODED_SLICE_STSA_R:
     case NAL_UNIT_CODED_SLICE_STSA_N:
-    case NAL_UNIT_CODED_SLICE_BLA:
-    case NAL_UNIT_CODED_SLICE_BLANT:
+    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
+    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
     case NAL_UNIT_CODED_SLICE_BLA_N_LP:
-    case NAL_UNIT_CODED_SLICE_IDR:
+    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
     case NAL_UNIT_CODED_SLICE_IDR_N_LP:
     case NAL_UNIT_CODED_SLICE_CRA:
     case NAL_UNIT_CODED_SLICE_RADL_N:
-    case NAL_UNIT_CODED_SLICE_DLP:
+    case NAL_UNIT_CODED_SLICE_RADL_R:
     case NAL_UNIT_CODED_SLICE_RASL_N:
-    case NAL_UNIT_CODED_SLICE_TFD:
+    case NAL_UNIT_CODED_SLICE_RASL_R:
     case NAL_UNIT_VPS:
     case NAL_UNIT_SPS:
@@ -861,5 +958,4 @@
 void TAppEncTop::printRateSummary()
 {
-
 #if H_MV
   Double time = (Double) m_frameRcvd[0] / m_iFrameRate;
@@ -868,5 +964,4 @@
   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
@@ -881,9 +976,9 @@
   for( Int dim = 0; dim < m_dimIds.size(); dim++ )
   {
-      vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
-      for( Int layer = 1; layer < vps.getMaxLayers(); layer++ )
-      {        
-        vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] );        
-      }  
+    vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
+    for( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
+    {        
+      vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] );        
+    }  
   }
 }
@@ -937,4 +1032,3 @@
 }
 #endif
-
 //! \}
Index: branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncTop.h	(revision 438)
+++ branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/TAppEncTop.h	(revision 446)
@@ -46,4 +46,7 @@
 #include "TLibCommon/AccessUnit.h"
 #include "TAppEncCfg.h"
+#if H_3D
+#include "../../Lib/TLibRenderer/TRenTop.h"
+#endif
 
 //! \ingroup TAppEncoder
@@ -59,5 +62,4 @@
 private:
   // class interface
-
 #if H_MV
   std::vector<TEncTop*>      m_acTEncTopList ;              ///< encoder class per layer 
@@ -70,4 +72,5 @@
 
   TComPicLists               m_ivPicLists;                  ///< picture buffers of encoder instances
+  TComVPS                    m_vps;                         ///< vps
 #else
   TEncTop                    m_cTEncTop;                    ///< encoder class
@@ -82,4 +85,8 @@
   UInt m_essentialBytes;
   UInt m_totalBytes;
+#if H_3D_VSO
+  TRenTop                     m_cRendererTop; 
+  TRenModel                   m_cRendererModel;   
+#endif
 protected:
   // initialization
@@ -91,5 +98,5 @@
   /// obtain required buffers
 #if H_MV
-  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec, UInt layer);
+  Void  xGetBuffer(TComPicYuv*& rpcPicYuvRec, UInt layer);
 #else
   Void xGetBuffer(TComPicYuv*& rpcPicYuvRec);
@@ -100,5 +107,4 @@
   
   // file I/O
-
 #if H_MV
   Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId); ///< write bitstream to file
@@ -106,5 +112,4 @@
   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();
@@ -116,5 +121,4 @@
   Int  xGetMax( std::vector<Int>& vec);
 #endif
-
 public:
   TAppEncTop();
@@ -122,14 +126,9 @@
   
   Void        encode      ();                               ///< main encoding function
-
 #if H_MV
-  TEncTop*    getTEncTopLayer(UInt layer) { return  m_acTEncTopList[layer]; }  ///< return pointer to encoder class for specific layer
-#if H_3D
-  TEncTop*    getTEncTopView( Int viewId, Bool isDepth );                      ///< return pointer to encoder class for specific view Id and texture or depth 
-#endif
+  TEncTop*    getTEncTop( UInt layer ) { return  m_acTEncTopList[layer]; }  ///< return pointer to encoder class for specific layer
 #else
   TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
 #endif
-
 };// END CLASS DEFINITION TAppEncTop
 
Index: branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/encmain.cpp
===================================================================
--- branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/encmain.cpp	(revision 438)
+++ branches/HTM-DEV-0.2-dev/source/App/TAppEncoder/encmain.cpp	(revision 446)
@@ -62,5 +62,4 @@
   fprintf( stdout, "HM software: Encoder Version [%s]", NV_VERSION );
 #endif
-
   fprintf( stdout, NVM_ONOS );
   fprintf( stdout, NVM_COMPILEDBY );
