Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 833)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 872)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
+* Copyright (c) 2010-2014, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -388,7 +388,17 @@
   ("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")  
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  ("DefaultTargetOutputLayerIdc"     , m_defaultTargetOutputLayerIdc     , 0, "Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet")
+#else
   ("DefaultOneTargetOutputLayerFlag"  , m_defaultOneTargetOutputLayerIdc  , 0, "Output highest layer of layer sets by default")
+#endif
   ("OutputLayerSetIdx",     m_outputLayerSetIdx  , std::vector<Int>(0,0), "Indices of layer sets used as additional output layer sets")  
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  ("LayerIdsInAddOutputLayerSet_%d", m_layerIdsInAddOutputLayerSet      , std::vector<Int>(0,0), MAX_VPS_ADD_OUTPUT_LAYER_SETS, "Indices in VPS of output layers in additional output layer set")  
+  ("LayerIdsInDefOutputLayerSet_%d", m_layerIdsInDefOutputLayerSet      , std::vector<Int>(0,0), MAX_VPS_OP_SETS_PLUS1, "Indices in VPS of output layers in layer set")  
+#else
   ("LayerIdsInAddOutputLayerSet_%d", m_layerIdsInAddOutputLayerSet      , std::vector<Int>(1,0), MAX_VPS_ADD_OUTPUT_LAYER_SETS, "LayerIds of additional output layers")  
+#endif
   ("ProfileLevelTierIdx",   m_profileLevelTierIdx, std::vector<Int>(1,0), "Indices to profile level tier")
   
@@ -444,8 +454,9 @@
   ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs")
   ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
+#if H_MV  
   // Coding structure parameters
-#if H_MV  
   ("IntraPeriod,-ip",         m_iIntraPeriod,std::vector<Int>(1,-1), "Intra period in frames, (-1: only first frame), per layer")
 #else
+  // Coding structure paramters
 ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
 #endif
@@ -492,6 +503,4 @@
   ("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
@@ -539,5 +548,4 @@
   ("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:"
@@ -559,6 +567,4 @@
   ("PCMInputBitDepthFlag",     m_bPCMInputBitDepthFlag,     true)
   ("PCMFilterDisableFlag",     m_bPCMFilterDisableFlag,    false)
-
-  ("LosslessCuEnabled",        m_useLossless, false)
 
   ("WeightedPredP,-wpP",          m_useWeightedPred,               false,      "Use weighted prediction in P slices")
@@ -590,12 +596,7 @@
   ("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" )
@@ -610,26 +611,17 @@
   ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
 #endif
-#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")
-
-#if KWU_RC_VIEWRC_E0227
-  ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
-  ("TargetBitAssign, -ta", m_viewWiseRateCtrl, false, "View-wise rate control on/off")
-#endif
-#if KWU_RC_MADPRED_E0227
-  ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
-#endif
-#endif
-
 #if H_MV
 
   // DBP Size
+#if !H_MV_HLS_7_FIX_SET_DPB_SIZE
   ("SubLayerFlagInfoPresentFlag",  m_subLayerFlagInfoPresentFlag , false                                           , "SubLayerFlagInfoPresentFlag")
+#endif
   // VPS VUI
   ("VpsVuiPresentFlag"           , m_vpsVuiPresentFlag           , false                                           , "VpsVuiPresentFlag           ")
   ("CrossLayerPicTypeAlignedFlag", m_crossLayerPicTypeAlignedFlag, false                                           , "CrossLayerPicTypeAlignedFlag")  // Could actually be derived by the encoder
   ("CrossLayerIrapAlignedFlag"   , m_crossLayerIrapAlignedFlag   , false                                           , "CrossLayerIrapAlignedFlag   ")  // Could actually be derived by the encoder
+#if H_MV_HLS_7_MISC_P0068_21
+  ("AllLayersIdrAlignedFlag"     , m_allLayersIdrAlignedFlag     , false                                           , "CrossLayerIrapAlignedFlag   ")  // Could actually be derived by the encoder
+#endif
   ("BitRatePresentVpsFlag"       , m_bitRatePresentVpsFlag       , false                                           , "BitRatePresentVpsFlag       ")
   ("PicRatePresentVpsFlag"       , m_picRatePresentVpsFlag       , false                                           , "PicRatePresentVpsFlag       ")
@@ -653,5 +645,5 @@
 
   ("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")
+  ("CUTransquantBypassFlagForce", m_CUTransquantBypassFlagForce, false, "Force transquant bypass mode, 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")
@@ -745,4 +737,13 @@
   ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
   ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
+#if H_MV_HLS_7_SEI_P0204_26
+  ("SubBitstreamPropSEIEnabled",              m_subBistreamPropSEIEnabled,    false                     ,"Enable signaling of sub-bitstream property SEI message")
+  ("SEISubBitstreamNumAdditionalSubStreams",  m_sbPropNumAdditionalSubStreams,0, "Number of substreams for which additional information is signalled")
+  ("SEISubBitstreamSubBitstreamMode",         m_sbPropSubBitstreamMode,       std::vector< Int  >(1,0)  ,"Specifies mode of generation of the i-th sub-bitstream (0 or 1)")
+  ("SEISubBitstreamOutputLayerSetIdxToVps",   m_sbPropOutputLayerSetIdxToVps, std::vector< Int  >(1,0)  ,"Specifies output layer set index of the i-th sub-bitstream ")
+  ("SEISubBitstreamHighestSublayerId",        m_sbPropHighestSublayerId,      std::vector< Int  >(1,0)  ,"Specifies highest TemporalId of the i-th sub-bitstream")
+  ("SEISubBitstreamAvgBitRate",               m_sbPropAvgBitRate,             std::vector< Int  >(1,0)  ,"Specifies average bit rate of the i-th sub-bitstream")
+  ("SEISubBitstreamMaxBitRate",               m_sbPropMaxBitRate,             std::vector< Int  >(1,0)  ,"Specifies maximum bit rate of the i-th sub-bitstream")
+#endif
 #if H_3D
   ("CameraParameterFile,cpf", m_pchCameraParameterFile,    (Char *) 0, "Camera Parameter File Name")
@@ -1431,5 +1432,38 @@
   }
 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  xConfirmPara( m_defaultTargetOutputLayerIdc < 0 || m_defaultTargetOutputLayerIdc > 2, "Default target output layer idc must greater than or equal to 0 and less than or equal to 2." );  
+
+  if( m_defaultTargetOutputLayerIdc != 2 )
+  {
+    Bool anyDefaultOutputFlag = false;   
+    for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++)
+    { 
+      anyDefaultOutputFlag = anyDefaultOutputFlag || ( m_layerIdsInDefOutputLayerSet[lsIdx].size() != 0 );
+    }    
+    printf( "\nWarning: Ignoring LayerIdsInDefOutputLayerSet parameters, since defaultTargetOuputLayerIdc is not equal 2.\n" );    
+  }
+  else  
+  {  
+    for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++)
+    { 
+      for (Int i = 0; i < m_layerIdsInDefOutputLayerSet[ lsIdx ].size(); i++)
+      {
+        Bool inLayerSetFlag = false; 
+        for (Int j = 0; j < m_layerIdsInSets[ lsIdx].size(); j++ )
+        {
+          if ( m_layerIdsInSets[ lsIdx ][ j ] == m_layerIdsInDefOutputLayerSet[ lsIdx ][ i ] )
+          {
+            inLayerSetFlag = true; 
+            break; 
+          }        
+        }
+        xConfirmPara( !inLayerSetFlag, "All output layers of a output layer set must be included in corresponding layer set.");
+      }
+    }
+  }
+#else
   xConfirmPara( m_defaultOneTargetOutputLayerIdc < 0 || m_defaultOneTargetOutputLayerIdc > 1, "Default one target output layer idc must be equal to 0 or equal to 1" );
+#endif
   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" );
 
@@ -2021,5 +2055,5 @@
       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");
+    xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P'&&m_GOPList[i].m_sliceType!='I', "Slice type must be equal to B or P or I");
   }
   for(Int i=0; i<MAX_TLAYER; i++)
@@ -2172,5 +2206,4 @@
   }
 
-#if RATE_CONTROL_LAMBDA_DOMAIN
   if ( m_RCEnableRateControl )
   {
@@ -2185,19 +2218,4 @@
     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" );
-
-#if !KWU_FIX_URQ
-    m_iMaxDeltaQP       = MAX_DELTA_QP;
-#endif
-    m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
-  }
-#endif
 #if H_MV
   // VPS VUI
@@ -2223,5 +2241,5 @@
 #endif
 
-  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue, "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0");
+  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
 
   xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
@@ -2233,4 +2251,23 @@
 #if H_MV
   }
+  }
+#endif
+#if H_MV_HLS_7_SEI_P0204_26
+  // Check input parameters for Sub-bitstream property SEI message
+  if( m_subBistreamPropSEIEnabled )
+  {
+    xConfirmPara( 
+      (this->m_sbPropNumAdditionalSubStreams != m_sbPropAvgBitRate.size() )
+      || (this->m_sbPropNumAdditionalSubStreams != m_sbPropHighestSublayerId.size() )
+      || (this->m_sbPropNumAdditionalSubStreams != m_sbPropMaxBitRate.size() )
+      || (this->m_sbPropNumAdditionalSubStreams != m_sbPropOutputLayerSetIdxToVps.size() )
+      || (this->m_sbPropNumAdditionalSubStreams != m_sbPropSubBitstreamMode.size()), "Some parameters of some sub-bitstream not defined");
+
+    for( Int i = 0; i < m_sbPropNumAdditionalSubStreams; i++ )
+    {
+      xConfirmPara( m_sbPropSubBitstreamMode[i] < 0 || m_sbPropSubBitstreamMode[i] > 1, "Mode value should be 0 or 1" );
+      xConfirmPara( m_sbPropHighestSublayerId[i] < 0 || m_sbPropHighestSublayerId[i] > MAX_TLAYER-1, "Maximum sub-layer ID out of range" );
+      xConfirmPara( m_sbPropOutputLayerSetIdxToVps[i] < 0 || m_sbPropOutputLayerSetIdxToVps[i] >= MAX_VPS_OUTPUTLAYER_SETS, "OutputLayerSetIdxToVps should be within allowed range" );
+    }
   }
 #endif
@@ -2343,5 +2380,4 @@
   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)
@@ -2373,31 +2409,4 @@
 #endif
   }
-#else
-  printf("RateControl                  : %d\n", m_enableRateCtrl);
-  if(m_enableRateCtrl)
-  {
-    printf("TargetBitrate                : %d\n", m_targetBitrate);
-    printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
-
-#if KWU_RC_MADPRED_E0227
-    printf("Depth based MAD prediction   : %d\n", m_depthMADPred);
-#endif
-#if KWU_RC_VIEWRC_E0227
-    printf("View-wise Rate control       : %d\n", m_viewWiseRateCtrl);
-    if(m_viewWiseRateCtrl)
-    {
-
-      printf("ViewWiseTargetBits           : ");
-      for (Int i = 0 ; i < m_iNumberOfViews ; i++)
-        printf("%d ", m_viewTargetBits[i]);
-      printf("\n");
-    }
-    else
-    {
-      printf("TargetBitrate                : %d\n", m_targetBitrate );
-    }
-#endif
-  }
-#endif
   printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
 #if H_3D
@@ -2429,5 +2438,4 @@
   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        );
@@ -2458,7 +2466,12 @@
 #endif
   printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
-  printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0));
-
-  printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 );
+  if (m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce)
+  {
+    printf("TransQuantBypassEnabled: =1 ");
+  }
+  else
+  {
+    printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnableFlag)? 1:0 );
+  }
   printf("WPP:%d ", (Int)m_useWeightedPred);
   printf("WPB:%d ", (Int)m_useWeightedBiPred);
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 833)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 872)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
+* Copyright (c) 2010-2014, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -89,7 +89,14 @@
   Int                    m_vpsNumLayerSets;                   ///< Number of layer sets
   std::vector< std::vector<Int> > m_layerIdsInSets;           ///< LayerIds in vps of layer set 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  Int                    m_defaultTargetOutputLayerIdc;       ///< Specifies output layers of layer sets, 0: output all layers, 1: output highest layers, 2: specified by LayerIdsInDefOuputLayerSet
+#else
   Int                    m_defaultOneTargetOutputLayerIdc;    ///< Output highest layer of layer sets by default when equal to 1
+#endif
   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
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  std::vector< std::vector<Int> > m_layerIdsInDefOutputLayerSet; ///< Indices in vps of output layers in layer sets
+#endif
   std::vector<Int>       m_profileLevelTierIdx;               ///< Indices of of profile level tier
   
@@ -99,5 +106,7 @@
 
   // DBP Size
+#if !H_MV_HLS_7_FIX_SET_DPB_SIZE
   Bool m_subLayerFlagInfoPresentFlag;
+#endif
 
   // VPS VUI
@@ -105,4 +114,7 @@
   Bool m_crossLayerPicTypeAlignedFlag;
   Bool m_crossLayerIrapAlignedFlag;
+#if H_MV_HLS_7_MISC_P0068_21
+  Bool m_allLayersIdrAlignedFlag;
+#endif
   Bool m_bitRatePresentVpsFlag;
   Bool m_picRatePresentVpsFlag;
@@ -259,6 +271,5 @@
   Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
 
-  // coding tool (lossless)
-  Bool      m_useLossless;                                    ///< flag for using lossless coding
+  // coding tool (SAO)
 #if H_MV
   std::vector<Bool> m_bUseSAO; 
@@ -268,5 +279,4 @@
   Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
   Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
-  Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
   // coding tools (loop filter)
 #if H_MV
@@ -288,5 +298,4 @@
 
   // coding tools (encoder-only parameters)
-  Bool      m_bUseSBACRD;                                     ///< flag for using RD optimization based on SBAC
   Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
   Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
@@ -372,12 +381,7 @@
   Int       m_TMVPModeId;
   Int       m_signHideFlag;
-#if RATE_CONTROL_LAMBDA_DOMAIN
   Bool      m_RCEnableRateControl;                ///< enable rate control or not
   Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
-#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
@@ -392,22 +396,9 @@
   UInt       m_depthMADPred;
 #endif
-#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
-
-#if KWU_RC_VIEWRC_E0227
-  vector<Int>     m_viewTargetBits;
-  Bool      m_viewWiseRateCtrl;                              ///< Flag for using view-wise rate control
-#endif
-#if KWU_RC_MADPRED_E0227
-  UInt       m_depthMADPred;
-#endif
-#endif
   Int       m_useScalingListId;                               ///< using quantization matrix
   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_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true.
 
   Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
@@ -449,5 +440,13 @@
   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_MV_HLS_7_SEI_P0204_26
+  Bool              m_subBistreamPropSEIEnabled;
+  Int               m_sbPropNumAdditionalSubStreams;
+  std::vector<Int>  m_sbPropSubBitstreamMode;
+  std::vector<Int>  m_sbPropOutputLayerSetIdxToVps;
+  std::vector<Int>  m_sbPropHighestSublayerId;
+  std::vector<Int>  m_sbPropAvgBitRate;
+  std::vector<Int>  m_sbPropMaxBitRate;
+#endif
 #if H_3D
   // Camera parameters
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 833)
+++ trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 872)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
+* Copyright (c) 2010-2014, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -127,4 +127,7 @@
   xSetRepFormat            ( vps ); 
   xSetLayerSets            ( vps ); 
+#if H_MV_HLS_7_FIX_SET_DPB_SIZE
+  xSetDpbSize              ( vps ); 
+#endif
   xSetVPSVUI               ( vps ); 
 #if H_3D
@@ -309,24 +312,11 @@
 #endif
 
-  Int lowestQP;
-  lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
-
-#if H_MV
-  if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layerIdInVps] == 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_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[layerIdInVps]   );
@@ -396,5 +386,4 @@
 
   m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
-  m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
   m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
   m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
@@ -440,4 +429,16 @@
   m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
   m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
+#if H_MV_HLS_7_SEI_P0204_26
+  m_cTEncTop.setSubBitstreamPropSEIEnabled( m_subBistreamPropSEIEnabled );
+  if( m_subBistreamPropSEIEnabled )
+  {
+    m_cTEncTop.setNumAdditionalSubStreams ( m_sbPropNumAdditionalSubStreams );
+    m_cTEncTop.setSubBitstreamMode        ( m_sbPropSubBitstreamMode );
+    m_cTEncTop.setOutputLayerSetIdxToVps  ( m_sbPropOutputLayerSetIdxToVps );
+    m_cTEncTop.setHighestSublayerId       ( m_sbPropHighestSublayerId );
+    m_cTEncTop.setAvgBitRate              ( m_sbPropAvgBitRate );
+    m_cTEncTop.setMaxBitRate              ( m_sbPropMaxBitRate );
+  }
+#endif
   m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
   m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
@@ -461,5 +462,4 @@
   m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
   m_cTEncTop.setSignHideFlag(m_signHideFlag);
-#if RATE_CONTROL_LAMBDA_DOMAIN
 #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
   if(!m_cTEncTop.getIsDepth())    //only for texture
@@ -482,10 +482,8 @@
   m_cTEncTop.setInitialQP           ( m_RCInitialQP );
   m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
-
 #if KWU_RC_MADPRED_E0227
   if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
   {
     m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
-
     if(m_cTEncTop.getUseDepthMADPred())
     {
@@ -498,5 +496,4 @@
   {
     m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
-
     if(m_iNumberOfViews == 1)
     {
@@ -552,95 +549,6 @@
   }
 #endif
-#else
-#if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
-  if(!m_cTEncTop.getIsDepth())    //only for texture
-  {
-    m_cTEncTop.setUseRateCtrl         ( m_enableRateCtrl );
-    m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
-    m_cTEncTop.setNumLCUInUnit        ( m_numLCUInUnit);
-  }
-  else
-  {
-    m_cTEncTop.setUseRateCtrl         ( 0 );
-  }
-#else
-  m_cTEncTop.setUseRateCtrl         ( m_enableRateCtrl );
-  m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
-  m_cTEncTop.setNumLCUInUnit        ( m_numLCUInUnit);
-#endif
-
-  
-#if KWU_RC_MADPRED_E0227
-  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
-  {
-    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
-
-    if(m_cTEncTop.getUseDepthMADPred())
-    {
-      m_cTEncTop.setCamParam(&m_cCameraData);
-    }
-  }
-#endif
-
-#if KWU_RC_VIEWRC_E0227
-  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
-  {
-    m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
-    if(m_iNumberOfViews == 1)
-    {
-      if(m_viewWiseRateCtrl)
-      {
-        m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
-      }
-      else
-      {
-        m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
-      }
-    }
-    else
-    {
-      if(m_viewWiseRateCtrl)
-      {
-        m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
-      }
-      else
-      {
-        if(m_iNumberOfViews == 2)
-        {
-          if(m_cTEncTop.getViewId() == 0)
-          {
-            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*80)/100 );
-          }
-          else if(m_cTEncTop.getViewId() == 1)
-          {
-            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*20)/100 );
-          }
-        }
-        else if(m_iNumberOfViews == 3)
-        {
-          if(m_cTEncTop.getViewId() == 0)
-          {
-            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*66)/100 );
-          }
-          else if(m_cTEncTop.getViewId() == 1)
-          {
-            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
-          }
-          else if(m_cTEncTop.getViewId() == 2)
-          {
-            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
-          }
-        }
-        else
-        {
-          m_cTEncTop.setTargetBitrate              ( m_targetBitrate );
-        }
-      }
-    }
-  }
-#endif
-#endif
   m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
-  m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
+  m_cTEncTop.setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce);
   m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
   m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
@@ -932,14 +840,4 @@
     }
 
-#if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_FIX_URQ
-    for(Int layer=0; layer < m_numberOfLayers; layer++ )
-    {
-      if(m_acTEncTopList[layer]->getUseRateCtrl()  && !m_acTEncTopList[layer]->getIsDepth())
-      {
-        m_acTEncTopList[layer]->getRateCtrl()->updateRCGOPStatus();
-      }
-    }
-#endif
-
     gopSize = maxGopSize;
   }
@@ -1203,5 +1101,5 @@
       rateStatsAccum(au, stats);   
     }
-#endif    
+#endif
   }
 }
@@ -1221,5 +1119,5 @@
     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_R:
     case NAL_UNIT_CODED_SLICE_TSA_N:
     case NAL_UNIT_CODED_SLICE_STSA_R:
@@ -1608,4 +1506,75 @@
 }
 
+#if H_MV_HLS_7_FIX_SET_DPB_SIZE
+Void TAppEncTop::xSetDpbSize                ( TComVPS& vps )
+{
+  // These settings need to be verified
+
+  TComDpbSize* dpbSize = vps.getDpbSize(); 
+
+  assert ( dpbSize != 0 ); 
+
+  for( Int i = 1; i < vps.getNumOutputLayerSets(); i++ )
+  {  
+    std::vector<Int> targetDecLayerIdList = vps.getTargetDecLayerIdList( i ); 
+    Bool subLayerFlagInfoPresentFlag = false; 
+
+#if H_MV_HLS_7_HRD_P0156_7
+    for( Int j = 0; j  <=  vps.getMaxSubLayersInLayerSetMinus1( i ); j++ )
+#else
+    for( Int j = 0; j  <=  vps.getMaxTLayers() - 1 ; j++ )
+#endif
+    {   
+      Bool subLayerDpbInfoPresentFlag = false; 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+      assert( vps.getNumSubDpbs( vps.getLayerSetIdxForOutputLayerSet( i ) ) == targetDecLayerIdList.size() ); 
+      for( Int k = 0; k < vps.getNumSubDpbs( vps.getLayerSetIdxForOutputLayerSet( i )); k++ )   
+#else
+      assert( vps.getNumSubDpbs( vps.getOutputLayerSetIdxMinus1( i ) + 1 ) == targetDecLayerIdList.size() ); 
+      for( Int k = 0; k < vps.getNumSubDpbs( vps.getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+#endif
+      {
+        Int layerIdInVps = vps.getLayerIdInVps( targetDecLayerIdList[k] );           
+#if H_MV_HLS7_GEN
+        // TBD. Some derivation based on output layer set might be added here. 
+#endif
+        dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 );
+        if ( j > 0 )
+        {
+          subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) != dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) );
+        }
+      }        
+
+      Int maxNumReorderPics = MIN_INT;
+      for ( Int idx = 0; idx < targetDecLayerIdList.size(); idx++ )
+      {
+        Int layerIdInVps = vps.getLayerIdInVps( targetDecLayerIdList[ idx ] ); 
+        maxNumReorderPics = std::max( maxNumReorderPics, m_numReorderPicsMvc[ layerIdInVps ][ j ] ); 
+      }
+      assert( maxNumReorderPics != MIN_INT ); 
+
+      dpbSize->setMaxVpsNumReorderPics( i, j, maxNumReorderPics );
+      if ( j > 0 )
+      {
+        subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsNumReorderPics( i, j ) != dpbSize->getMaxVpsNumReorderPics( i, j - 1 ) );
+      }
+
+      // To Be Done !
+      // dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, xx );
+      if ( j > 0 )
+      {
+        subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ) != dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1  ) );
+      }
+
+      if( j > 0 )  
+      {
+        dpbSize->setSubLayerDpbInfoPresentFlag( i, j, subLayerDpbInfoPresentFlag );
+        subLayerFlagInfoPresentFlag = subLayerFlagInfoPresentFlag || subLayerDpbInfoPresentFlag; 
+      }       
+    }  
+    dpbSize->setSubLayerFlagInfoPresentFlag( i, subLayerFlagInfoPresentFlag ); 
+  }  
+}
+#else
 Void TAppEncTop::xSetDpbSize                ( TComVPS& vps )
 {
@@ -1620,5 +1589,4 @@
     std::vector<Int> targetDecLayerIdList = vps.getTargetDecLayerIdList( i ); 
     dpbSize->setSubLayerFlagInfoPresentFlag( i, m_subLayerFlagInfoPresentFlag );
-
     if ( dpbSize->getSubLayerFlagInfoPresentFlag( i ) )
     {
@@ -1663,5 +1631,5 @@
   }  
 }
-
+#endif
 
 Void TAppEncTop::xSetLayerSets( TComVPS& vps )
@@ -1669,5 +1637,7 @@
   // Layer sets
   vps.setVpsNumLayerSetsMinus1   ( m_vpsNumLayerSets - 1 ); 
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   vps.setVpsNumberLayerSetsMinus1( vps.getVpsNumLayerSetsMinus1() ); 
+#endif
     
   for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
@@ -1686,10 +1656,65 @@
   Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); 
   // Additional output layer sets + profileLevelTierIdx
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  vps.setDefaultTargetOutputLayerIdc      ( m_defaultTargetOutputLayerIdc );   
+  vps.setNumAddOutputLayerSets            ( numAddOuputLayerSets          ); 
+  vps.initTargetLayerIdLists(); 
+#else
   vps.setDefaultOneTargetOutputLayerIdc   ( m_defaultOneTargetOutputLayerIdc ); 
   vps.setMoreOutputLayerSetsThanDefaultFlag( numAddOuputLayerSets       != 0 );   
   vps.setNumAddOutputLayerSetsMinus1       ( numAddOuputLayerSets - 1        ); 
-
-
-
+#endif
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  for (Int olsIdx = 0; olsIdx < m_vpsNumLayerSets + numAddOuputLayerSets; olsIdx++)
+  {
+    Int addOutLsIdx = olsIdx - m_vpsNumLayerSets;     
+    
+    vps.setOutputLayerSetIdxMinus1( olsIdx, ( ( addOutLsIdx < 0 ) ?  olsIdx  : m_outputLayerSetIdx[ addOutLsIdx ] ) - 1 ); 
+
+    std::vector<Int>& layerIdList    = m_layerIdsInSets[ vps.getLayerSetIdxForOutputLayerSet( olsIdx ) ];
+
+    if (vps.getDefaultTargetOutputLayerIdc() == 2 || addOutLsIdx >= 0 )
+    { 
+      for ( Int i = 0; i < layerIdList.size(); i++)
+      {
+        vps.setOutputLayerFlag( olsIdx, i, ( olsIdx == 0 && i == 0 ) ? vps.inferOutputLayerFlag(olsIdx, i ) : false ); // This is a software only fix for a bug in the spec. In spec outputLayerFlag neither present nor inferred for this case !
+      }
+
+      std::vector<Int>& outLayerIdList = ( addOutLsIdx >= 0 ) ? m_layerIdsInAddOutputLayerSet[addOutLsIdx] : m_layerIdsInDefOutputLayerSet[olsIdx]; 
+
+      Bool outputLayerInLayerSetFlag = false; 
+      for (Int j = 0; j < outLayerIdList.size(); j++)
+      {   
+        for (Int i = 0; i < layerIdList.size(); i++ )
+        {
+          if ( layerIdList[ i ] == outLayerIdList[ j ] )
+          {
+            vps.setOutputLayerFlag( olsIdx, i, true );       
+            outputLayerInLayerSetFlag = true; 
+            break; 
+          }
+        }
+        assert( outputLayerInLayerSetFlag ); // The output layer is not not in the layer set.
+      }
+    }
+    else
+    {
+      for ( Int i = 0; i < layerIdList.size(); i++)
+      {
+        vps.setOutputLayerFlag( olsIdx, i, vps.inferOutputLayerFlag( olsIdx, i ) );       
+      }
+    }
+
+    vps.deriveTargetLayerIdList(  olsIdx ); 
+
+    if ( olsIdx > 0 ) 
+    {
+      vps.setProfileLevelTierIdx( olsIdx, m_profileLevelTierIdx[ olsIdx ] ); 
+    }
+
+    vps.setAltOutputLayerFlag( olsIdx , false);     
+  }
+#else
   for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++)
   {
@@ -1729,4 +1754,5 @@
   }
   vps.deriveTargetLayerIdLists(); 
+#endif
 }
 
@@ -1735,10 +1761,16 @@
   vps.setVpsVuiPresentFlag( m_vpsVuiPresentFlag ); 
 
+#if H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG
+  TComVPSVUI* pcVPSVUI = vps.getVPSVUI(  ); 
+  assert( pcVPSVUI ); 
+#endif
+
   if ( m_vpsVuiPresentFlag )
   {
+#if !H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG
     TComVPSVUI* pcVPSVUI = vps.getVPSVUI(  ); 
 
     assert( pcVPSVUI ); 
-
+#endif
 
     // All this stuff could actually be derived by the encoder, 
@@ -1747,5 +1779,7 @@
     pcVPSVUI->setCrossLayerPicTypeAlignedFlag( m_crossLayerPicTypeAlignedFlag );
     pcVPSVUI->setCrossLayerIrapAlignedFlag   ( m_crossLayerIrapAlignedFlag    );
-
+#if H_MV_HLS_7_MISC_P0068_21
+    pcVPSVUI->setAllLayersIdrAlignedFlag     ( m_allLayersIdrAlignedFlag      );
+#endif
     pcVPSVUI->setBitRatePresentVpsFlag( m_bitRatePresentVpsFlag );
     pcVPSVUI->setPicRatePresentVpsFlag( m_picRatePresentVpsFlag );
@@ -1753,5 +1787,9 @@
     if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
     {
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+      for( Int i = 0; i  <=  vps.getVpsNumLayerSetsMinus1(); i++ )
+#else
       for( Int i = 0; i  <=  vps.getVpsNumberLayerSetsMinus1(); i++ )
+#endif
       {
         for( Int j = 0; j  <=  vps.getMaxTLayers(); j++ ) 
@@ -1871,4 +1909,10 @@
     pcVPSVUI->setVpsVuiBspHrdPresentFlag( false ); // TBD
   }
+#if H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG
+  else
+  {
+    pcVPSVUI->setCrossLayerIrapAlignedFlag   ( false   );
+  }
+#endif
 }
 #endif
@@ -1963,4 +2007,3 @@
 }
 #endif
-
 //! \}
Index: trunk/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 833)
+++ trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 872)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
+* Copyright (c) 2010-2014, ITU/ISO/IEC
  * All rights reserved.
  *
Index: trunk/source/App/TAppEncoder/encmain.cpp
===================================================================
--- trunk/source/App/TAppEncoder/encmain.cpp	(revision 833)
+++ trunk/source/App/TAppEncoder/encmain.cpp	(revision 872)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
+* Copyright (c) 2010-2014, ITU/ISO/IEC
  * All rights reserved.
  *
