Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_2view+depth_AllIntra.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_2view+depth_AllIntra.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_2view+depth_AllIntra.cfg	(revision 854)
@@ -30,17 +30,17 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 3           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set
 
-DefaultOneTargetOutputLayerFlag: 0          # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2           # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3         # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0           # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 2           # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3         # Indices in VPS of output layers in additional output layer set
 ProfileLevelTierIdx           : 0 0 0 0     # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 1           # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_3view+depth_AllIntra.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_3view+depth_AllIntra.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_3view+depth_AllIntra.cfg	(revision 854)
@@ -34,22 +34,22 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 5           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 4 5     # LayerIds in vps of layer set
-LayerIdsInSet_4               : 0 1 2 3 4 5 # LayerIds in vps of layer set
-
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set
+LayerIdsInSet_3               : 0 1 4 5     # Indices in VPS of layers in layer set
+LayerIdsInSet_4               : 0 1 2 3 4 5 # Indices in VPS of layers in layer set
+
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # Indices in VPS of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 4 5          # Indices in VPS of additional output layers
 ProfileLevelTierIdx           : 0 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             : 1           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 1           # Indices in VPS of direct reference layers 
+DirectRefLayers_4             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_5             : 1           # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/fco/baseCfg_3view+depth.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/fco/baseCfg_3view+depth.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/fco/baseCfg_3view+depth.cfg	(revision 854)
@@ -34,22 +34,22 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 5           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 4 5     # LayerIds in vps of layer set
-LayerIdsInSet_4               : 0 1 2 3 4 5 # LayerIds in vps of layer set
-
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set
+LayerIdsInSet_3               : 0 1 4 5     # Indices in VPS of layers in layer set
+LayerIdsInSet_4               : 0 1 2 3 4 5 # Indices in VPS of layers in layer set
+
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # Indices in VPS of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 4 5          # Indices in VPS of additional output layers
 ProfileLevelTierIdx           : 0 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             : 0           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 1           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_4             : 1           # Indices in VPS of direct reference layers 
+DirectRefLayers_5             : 0           # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/ibp/gopCfg_IBP_3view+depth.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/ibp/gopCfg_IBP_3view+depth.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/ibp/gopCfg_IBP_3view+depth.cfg	(revision 854)
@@ -12,21 +12,21 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 4           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2 3 4 5 # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set
+LayerIdsInSet_3               : 0 1 2 3 4 5 # Indices in VPS of layers in layer set
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # Indices in VPS of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 4 5          # Indices in VPS of additional output layers
 ProfileLevelTierIdx           : 0 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             : 0 2         # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             : 1 3         # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 1           # Indices in VPS of direct reference layers 
+DirectRefLayers_4             : 0 2         # Indices in VPS of direct reference layers 
+DirectRefLayers_5             : 1 3         # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/ibp/gopCfg_IBP_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/ibp/gopCfg_IBP_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/ibp/gopCfg_IBP_3view.cfg	(revision 854)
@@ -13,13 +13,13 @@
 LayerIdsInSet_2               : 0 1 2        # LayerIdcs in vps of layer set
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set
 ProfileLevelTierIdx           : 0 0 0 0 0    # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0 1         # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0 1         # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             : 2 2         # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_ILP_on_IRAP_3view+depth.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_ILP_on_IRAP_3view+depth.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_ILP_on_IRAP_3view+depth.cfg	(revision 854)
@@ -3,21 +3,21 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 4           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2 3 4 5 # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set
+LayerIdsInSet_3               : 0 1 2 3 4 5 # Indices in VPS of layers in layer set
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # Indices in VPS of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 4 5          # Indices in VPS of additional output layers
 ProfileLevelTierIdx           : 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             : 0 2         # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             : 1 3         # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 1           # Indices in VPS of direct reference layers 
+DirectRefLayers_4             : 0 2         # Indices in VPS of direct reference layers 
+DirectRefLayers_5             : 1 3         # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_2view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_2view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_2view.cfg	(revision 854)
@@ -1,15 +1,15 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 4            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1            # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 1            # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set
 ProfileLevelTierIdx           : 0 0 0        # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             :             # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             :             # Indices in VPS of direct reference layers 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_3view+depth.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_3view+depth.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_3view+depth.cfg	(revision 854)
@@ -1,21 +1,21 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 4           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2 3 4 5 # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set
+LayerIdsInSet_3               : 0 1 2 3 4 5 # Indices in VPS of layers in layer set
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # Indices in VPS of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 4 5          # Indices in VPS of additional output layers
 ProfileLevelTierIdx           : 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             :             # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_3             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_4             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_5             :             # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/misc/gopCfg_NoIv_3view.cfg	(revision 854)
@@ -1,18 +1,18 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 4            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 2          # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2        # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set
+LayerIdsInSet_2               : 0 2          # Indices in VPS of layers in layer set
+LayerIdsInSet_3               : 0 1 2        # Indices in VPS of layers in layer set
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set
 ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             :             # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             :             # Indices in VPS of direct reference layers 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/rc/baseCfg_3view+depth_rate_control.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/rc/baseCfg_3view+depth_rate_control.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/rc/baseCfg_3view+depth_rate_control.cfg	(revision 854)
@@ -34,22 +34,22 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 5           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 4 5     # LayerIds in vps of layer set
-LayerIdsInSet_4               : 0 1 2 3 4 5 # LayerIds in vps of layer set
-
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set
+LayerIdsInSet_3               : 0 1 4 5     # Indices in VPS of layers in layer set
+LayerIdsInSet_4               : 0 1 2 3 4 5 # Indices in VPS of layers in layer set
+
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # Indices in VPS of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 4 5          # Indices in VPS of additional output layers
 ProfileLevelTierIdx           : 0 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             : 1           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 1           # Indices in VPS of direct reference layers 
+DirectRefLayers_4             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_5             : 1           # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_2view+depth.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_2view+depth.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_2view+depth.cfg	(revision 854)
@@ -34,5 +34,5 @@
 LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
 
-DefaultOneTargetOutputLayerFlag: 0          # Output highest layer of layer sets by default
+DefaultTargetOutputLayerIdc: 0          # Output highest layer of layer sets by default
 OutputLayerSetIdx             : 2           # Indices of layer sets used as additional output layer sets
 LayerIdsInAddOutputLayerSet_0 : 2 3         # LayerIds in vps of additional output layers
@@ -40,7 +40,7 @@
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 1           # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_2view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_2view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_2view.cfg	(revision 854)
@@ -26,14 +26,16 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 2            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1            # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-ProfileLevelTierIdx           : 0 0 0        # Indices to profile level tier (TBD) per output layer set
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+
+OutputLayerSetIdx             : 1            # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
+
+ProfileLevelTierIdx           : 0 0 0        # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg	(revision 854)
@@ -34,22 +34,23 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 5           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 4 5     # LayerIds in vps of layer set
-LayerIdsInSet_4               : 0 1 2 3 4 5 # LayerIds in vps of layer set
-
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set 1
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set 2
+LayerIdsInSet_3               : 0 1 4 5     # Indices in VPS of layers in layer set 3
+LayerIdsInSet_4               : 0 1 2 3 4 5 # Indices in VPS of layers in layer set 4
+
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 4 5          # Indices in VPS of output layers in additional output layer set 1
+
 ProfileLevelTierIdx           : 0 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             : 1           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 1           # Indices in VPS of direct reference layers 
+DirectRefLayers_4             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_5             : 1           # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_3view.cfg	(revision 854)
@@ -27,18 +27,20 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 4            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 2          # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2        # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 1
+LayerIdsInSet_2               : 0 2          # Indices in VPS of layers in layer set 2
+LayerIdsInSet_3               : 0 1 2        # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set 1
+
 ProfileLevelTierIdx           : 0 0 0 0 0 0   # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/3D-HEVC/fullCfg.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/3D-HEVC/fullCfg.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/3D-HEVC/fullCfg.cfg	(revision 854)
@@ -36,24 +36,32 @@
 ViewId                        : 1 0 2       # ViewId per ViewOrderIndex (m)
 
-#======== VPS/ Layer sets ================
 VpsNumLayerSets               : 5           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 4 5     # LayerIds in vps of layer set
-LayerIdsInSet_4               : 0 1 2 3 4 5 # LayerIds in vps of layer set
-
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+LayerIdsInSet_0               : 0           # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1         # Indices in VPS of layers in layer set 1
+LayerIdsInSet_2               : 0 1 2 3     # Indices in VPS of layers in layer set 2
+LayerIdsInSet_3               : 0 1 4 5     # Indices in VPS of layers in layer set 3
+LayerIdsInSet_4               : 0 1 2 3 4 5 # Indices in VPS of layers in layer set 4
+
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+
+LayerIdsInDefOutputLayerSet_0 :              # Indices in VPS of output layers in layer set 0 (when DefaultTargetOutputLayerIdc is equal to 2)
+LayerIdsInDefOutputLayerSet_1 :              # Indices in VPS of output layers in layer set 1 (when DefaultTargetOutputLayerIdc is equal to 2)
+LayerIdsInDefOutputLayerSet_2 :              # Indices in VPS of output layers in layer set 2 (when DefaultTargetOutputLayerIdc is equal to 2)
+LayerIdsInDefOutputLayerSet_3 :              # Indices in VPS of output layers in layer set 3 (when DefaultTargetOutputLayerIdc is equal to 2)
+LayerIdsInDefOutputLayerSet_4 :              # Indices in VPS of output layers in layer set 4 (when DefaultTargetOutputLayerIdc is equal to 2)
+
+
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 4 5          # Indices in VPS of output layers in additional output layer set 1
+
 ProfileLevelTierIdx           : 0 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             : 1           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_3             : 1           # Indices in VPS of direct reference layers 
+DirectRefLayers_4             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_5             : 1           # Indices in VPS of direct reference layers 
 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_IBP_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_IBP_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_IBP_3view.cfg	(revision 854)
@@ -9,17 +9,18 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 3            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIdcs in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIdcs in vps of layer set
-LayerIdsInSet_2               : 0 1 2        # LayerIdcs in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 1
+LayerIdsInSet_2               : 0 1 2        # Indices in VPS of layers in layer set 2
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set 1
+
 ProfileLevelTierIdx           : 0 0 0 0 0    # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0 1         # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0 1         # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             : 2 2         # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: anches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_ILP_on_IRAP_3view+depth.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_ILP_on_IRAP_3view+depth.cfg	(revision 853)
+++ 	(revision )
@@ -1,92 +1,0 @@
-# Inter layer prediction only at IRAP pictures
-#
-#======== VPS/ Layer sets ================
-VpsNumLayerSets               : 4           # Number of layer sets    
-LayerIdsInSet_0               : 0           # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1         # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 1 2 3     # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2 3 4 5 # LayerIds in vps of layer set
-
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
-ProfileLevelTierIdx           : 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
-
-#======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_3             : 1           # LayerIds in vps of direct reference layers 
-DirectRefLayers_4             : 0 2         # LayerIds in vps of direct reference layers 
-DirectRefLayers_5             : 1 3         # LayerIds in vps of direct reference layers 
-
-DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
-DependencyTypes_2             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
-DependencyTypes_3             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
-DependencyTypes_4             : 2 2         # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
-DependencyTypes_5             : 2 2         # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
-
-
-#                           QPfactor      betaOffsetDiv2   #ref_pics_active  reference pictures     deltaRPS     reference idcs          ilPredLayerIdc       refLayerPicPosIl_L1
-#         Type  POC QPoffset     tcOffsetDiv2      temporal_id      #ref_pics                 predict     #ref_idcs        #ActiveRefLayerPics     refLayerPicPosIl_L0     collocatedRefLayerIdx
-Frame1:     B    8     1     0.442    0        0        0        4      4     -8 -10 -12 -16     0                                 0
-Frame2:     B    4     2     0.3536   0        0        0        2      3     -4 -6  4           1     4     5     1 1 0 0 1       0
-Frame3:     B    2     3     0.3536   0        0        0        2      4     -2 -4  2 6         1     2     4     1 1 1 1         0
-Frame4:     B    1     4     0.68     0        0        0        2      4     -1  1  3 7         1     1     5     1 0 1 1 1       0
-Frame5:     B    3     4     0.68     0        0        0        2      4     -1 -3  1 5         1    -2     5     1 1 1 1 0       0
-Frame6:     B    6     3     0.3536   0        0        0        2      4     -2 -4 -6 2         1    -3     5     1 1 1 1 0       0
-Frame7:     B    5     4     0.68     0        0        0        2      4     -1 -5  1 3         1     1     5     1 0 1 1 1       0
-Frame8:     B    7     4     0.68     0        0        0        2      4     -1 -3 -7 1         1    -2     5     1 1 1 1 0       0
-    
-FrameI_l1:  I    0     0     0.442    0        0        0        0      0                        0                                 0             
-Frame1_l1:  B    8     1     0.442    0        0        0        4      4     -8 -10 -12 -16     0                                 0             
-Frame2_l1:  B    4     2     0.3536   0        0        0        2      3     -4 -6  4           1     4     5     1 1 0 0 1       0             
-Frame3_l1:  B    2     3     0.3536   0        0        0        2      4     -2 -4  2 6         1     2     4     1 1 1 1         0             
-Frame4_l1:  B    1     4     0.68     0        0        0        2      4     -1  1  3 7         1     1     5     1 0 1 1 1       0             
-Frame5_l1:  B    3     4     0.68     0        0        0        2      4     -1 -3  1 5         1    -2     5     1 1 1 1 0       0             
-Frame6_l1:  B    6     3     0.3536   0        0        0        2      4     -2 -4 -6 2         1    -3     5     1 1 1 1 0       0             
-Frame7_l1:  B    5     4     0.68     0        0        0        2      4     -1 -5  1 3         1     1     5     1 0 1 1 1       0             
-Frame8_l1:  B    7     4     0.68     0        0        0        2      4     -1 -3 -7 1         1    -2     5     1 1 1 1 0       0             
-
-FrameI_l2:  P    0     3     0.442    0        0        0        1      0                        0                                 1            0         0          -1        -1  
-Frame1_l2:  B    8     4     0.442    0        0        0        4      4     -8 -10 -12 -16     0                                 0
-Frame2_l2:  B    4     5     0.3536   0        0        0        3      3     -4 -6  4           1     4     5     1 1 0 0 1       0
-Frame3_l2:  B    2     6     0.3536   0        0        0        3      4     -2 -4  2 6         1     2     4     1 1 1 1         0
-Frame4_l2:  B    1     7     0.68     0        0        0        3      4     -1  1  3 7         1     1     5     1 0 1 1 1       0
-Frame5_l2:  B    3     7     0.68     0        0        0        3      4     -1 -3  1 5         1    -2     5     1 1 1 1 0       0
-Frame6_l2:  B    6     6     0.3536   0        0        0        3      4     -2 -4 -6 2         1    -3     5     1 1 1 1 0       0
-Frame7_l2:  B    5     7     0.68     0        0        0        3      4     -1 -5  1 3         1     1     5     1 0 1 1 1       0
-Frame8_l2:  B    7     7     0.68     0        0        0        3      4     -1 -3 -7 1         1    -2     5     1 1 1 1 0       0
-
-FrameI_l3:  P    0     3     0.442    0        0        0        1      0                        0                                 1            0         0          -1        -1  
-Frame1_l3:  B    8     4     0.442    0        0        0        4      4     -8 -10 -12 -16     0                                 0  
-Frame2_l3:  B    4     5     0.3536   0        0        0        3      3     -4 -6  4           1     4     5     1 1 0 0 1       0  
-Frame3_l3:  B    2     6     0.3536   0        0        0        3      4     -2 -4  2 6         1     2     4     1 1 1 1         0  
-Frame4_l3:  B    1     7     0.68     0        0        0        3      4     -1  1  3 7         1     1     5     1 0 1 1 1       0  
-Frame5_l3:  B    3     7     0.68     0        0        0        3      4     -1 -3  1 5         1    -2     5     1 1 1 1 0       0  
-Frame6_l3:  B    6     6     0.3536   0        0        0        3      4     -2 -4 -6 2         1    -3     5     1 1 1 1 0       0  
-Frame7_l3:  B    5     7     0.68     0        0        0        3      4     -1 -5  1 3         1     1     5     1 0 1 1 1       0  
-Frame8_l3:  B    7     7     0.68     0        0        0        3      4     -1 -3 -7 1         1    -2     5     1 1 1 1 0       0  
-
-FrameI_l4:  P    0     3     0.442    0        0        0        1      0                        0                                 1            0         0          -1        -1
-Frame1_l4:  B    8     4     0.442    0        0        0        4      4     -8 -10 -12 -16     0                                 0  
-Frame2_l4:  B    4     5     0.3536   0        0        0        3      3     -4 -6  4           1     4     5     1 1 0 0 1       0  
-Frame3_l4:  B    2     6     0.3536   0        0        0        3      4     -2 -4  2 6         1     2     4     1 1 1 1         0  
-Frame4_l4:  B    1     7     0.68     0        0        0        3      4     -1  1  3 7         1     1     5     1 0 1 1 1       0  
-Frame5_l4:  B    3     7     0.68     0        0        0        3      4     -1 -3  1 5         1    -2     5     1 1 1 1 0       0  
-Frame6_l4:  B    6     6     0.3536   0        0        0        3      4     -2 -4 -6 2         1    -3     5     1 1 1 1 0       0  
-Frame7_l4:  B    5     7     0.68     0        0        0        3      4     -1 -5  1 3         1     1     5     1 0 1 1 1       0  
-Frame8_l4:  B    7     7     0.68     0        0        0        3      4     -1 -3 -7 1         1    -2     5     1 1 1 1 0       0  
-
-FrameI_l5:  P    0     3     0.442    0        0        0        1      0                        0                                 1            0         0          -1        -1  
-Frame1_l5:  B    8     4     0.442    0        0        0        4      4     -8 -10 -12 -16     0                                 0    
-Frame2_l5:  B    4     5     0.3536   0        0        0        3      3     -4 -6  4           1     4     5     1 1 0 0 1       0    
-Frame3_l5:  B    2     6     0.3536   0        0        0        3      4     -2 -4  2 6         1     2     4     1 1 1 1         0    
-Frame4_l5:  B    1     7     0.68     0        0        0        3      4     -1  1  3 7         1     1     5     1 0 1 1 1       0    
-Frame5_l5:  B    3     7     0.68     0        0        0        3      4     -1 -3  1 5         1    -2     5     1 1 1 1 0       0    
-Frame6_l5:  B    6     6     0.3536   0        0        0        3      4     -2 -4 -6 2         1    -3     5     1 1 1 1 0       0    
-Frame7_l5:  B    5     7     0.68     0        0        0        3      4     -1 -5  1 3         1     1     5     1 0 1 1 1       0    
-Frame8_l5:  B    7     7     0.68     0        0        0        3      4     -1 -3 -7 1         1    -2     5     1 1 1 1 0       0    
-
-### DO NOT ADD ANYTHING BELOW THIS LINE ###
-### DO NOT DELETE THE EMPTY LINE BELOW ###
Index: /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_IPB_on_IRAP_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_IPB_on_IRAP_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_IPB_on_IRAP_3view.cfg	(revision 854)
@@ -3,18 +3,19 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 4            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 2          # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2        # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 1
+LayerIdsInSet_2               : 0 2          # Indices in VPS of layers in layer set 2
+LayerIdsInSet_3               : 0 1 2        # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set 1
+
 ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0 1         # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0 1         # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             : 2 2         # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_NoIv_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_NoIv_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_NoIv_3view.cfg	(revision 854)
@@ -1,18 +1,20 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 4            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 2          # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2        # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 1            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_2               : 2            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_3               : 0 1          # Indices in VPS of layers in layer set 1
+LayerIdsInSet_4               : 0 2          # Indices in VPS of layers in layer set 2
+LayerIdsInSet_5               : 1 2          # Indices in VPS of layers in layer set 2
+LayerIdsInSet_6               : 0 1 2        # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
-ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+
+OutputLayerSetIdx             :              # Indices of layer sets used to derive additional output layer sets
+
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             :             # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             :             # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             :             # Indices in VPS of direct reference layers 
+DirectRefLayers_2             :             # Indices in VPS of direct reference layers 
 DependencyTypes_1             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             :             # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_PIP_on_IRAP_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_PIP_on_IRAP_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/gopCfg_PIP_on_IRAP_3view.cfg	(revision 854)
@@ -3,18 +3,19 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 4            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 2          # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2        # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 1
+LayerIdsInSet_2               : 0 2          # Indices in VPS of layers in layer set 2
+LayerIdsInSet_3               : 0 1 2        # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set 1
+
 ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/layerwise_startup_IBP_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/layerwise_startup_IBP_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/MV-HEVC/NonCTC/layerwise_startup_IBP_3view.cfg	(revision 854)
@@ -9,17 +9,17 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 3            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIdcs in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIdcs in vps of layer set
-LayerIdsInSet_2               : 0 1 2        # LayerIdcs in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 1
+LayerIdsInSet_3               : 0 1 2        # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set 1
 ProfileLevelTierIdx           : 0 0 0 0 0    # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0 1         # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0 1         # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             : 2 2         # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/MV-HEVC/baseCfg_2view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/baseCfg_2view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/MV-HEVC/baseCfg_2view.cfg	(revision 854)
@@ -25,14 +25,15 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 2            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of Layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of Layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1            # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+
+OutputLayerSetIdx             : 1            # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
 ProfileLevelTierIdx           : 0 0 0        # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 
Index: /branches/HTM-10.0-dev0/cfg/MV-HEVC/baseCfg_3view.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/baseCfg_3view.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/MV-HEVC/baseCfg_3view.cfg	(revision 854)
@@ -27,18 +27,20 @@
 #======== VPS / Layer sets ================
 VpsNumLayerSets               : 4            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds in vps of layer set
-LayerIdsInSet_1               : 0 1          # LayerIds in vps of layer set
-LayerIdsInSet_2               : 0 2          # LayerIds in vps of layer set
-LayerIdsInSet_3               : 0 1 2        # LayerIds in vps of layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 1
+LayerIdsInSet_2               : 0 2          # Indices in VPS of layers in layer set 2
+LayerIdsInSet_3               : 0 1 2        # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set 1
+
 ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
-DirectRefLayers_1             : 0           # LayerIds in vps of direct reference layers 
-DirectRefLayers_2             : 0           # LayerIds in vps of direct reference layers 
+DirectRefLayers_1             : 0           # Indices in VPS of direct reference layers 
+DirectRefLayers_2             : 0           # Indices in VPS of direct reference layers 
 DependencyTypes_1             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
 DependencyTypes_2             : 2           # Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion
Index: /branches/HTM-10.0-dev0/cfg/MV-HEVC/fullCfg.cfg
===================================================================
--- /branches/HTM-10.0-dev0/cfg/MV-HEVC/fullCfg.cfg	(revision 853)
+++ /branches/HTM-10.0-dev0/cfg/MV-HEVC/fullCfg.cfg	(revision 854)
@@ -31,15 +31,22 @@
 #======== VPS/ Layer sets ================
 VpsNumLayerSets               : 4            # Number of layer sets    
-LayerIdsInSet_0               : 0            # LayerIds of Layer set
-LayerIdsInSet_1               : 0 1          # LayerIds of Layer set
-LayerIdsInSet_2               : 0 2          # LayerIds of Layer set
-LayerIdsInSet_3               : 0 1 2        # LayerIds of Layer set
+LayerIdsInSet_0               : 0            # Indices in VPS of layers in layer set 0
+LayerIdsInSet_1               : 0 1          # Indices in VPS of layers in layer set 1
+LayerIdsInSet_2               : 0 2          # Indices in VPS of layers in layer set 2
+LayerIdsInSet_3               : 0 1 2        # Indices in VPS of layers in layer set 3
 
-DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
-OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
-LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
+DefaultTargetOutputLayerIdc   : 0            # Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet
+LayerIdsInDefOutputLayerSet_0 :              # Indices in VPS of output layers in layer set 0 (when DefaultTargetOutputLayerIdc is equal to 2)
+LayerIdsInDefOutputLayerSet_1 :              # Indices in VPS of output layers in layer set 1 (when DefaultTargetOutputLayerIdc is equal to 2)
+LayerIdsInDefOutputLayerSet_2 :              # Indices in VPS of output layers in layer set 2 (when DefaultTargetOutputLayerIdc is equal to 2)
+LayerIdsInDefOutputLayerSet_3 :              # Indices in VPS of output layers in layer set 3 (when DefaultTargetOutputLayerIdc is equal to 2)
+
+
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used to derive additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # Indices in VPS of output layers in additional output layer set 0
+LayerIdsInAddOutputLayerSet_1 : 2            # Indices in VPS of output layers in additional output layer set 1
+
+
 ProfileLevelTierIdx           : 0 0 0 0      # Indices to profile level tier (TBD)
-
 #======== Unit definition ================
 MaxCUWidth                    : 64          # Maximum coding unit width in pixel
Index: /branches/HTM-10.0-dev0/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/App/TAppDecoder/TAppDecTop.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/App/TAppDecoder/TAppDecTop.cpp	(revision 854)
@@ -140,5 +140,7 @@
     AOF( m_pScaleOffsetFile ); 
   }
+#if !FIX_CAM_PARS_COLLECTOR
   m_cCamParsCollector.init( m_pScaleOffsetFile );
+#endif
 #endif
   InputByteStream bytestream(bitstreamFile);
@@ -207,5 +209,16 @@
       read(nalu, nalUnit);
 #if H_MV      
+#if H_MV_FIX_VPS_LAYER_ID_NOT_EQUAL_ZERO
+      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) 
+          || !isNaluWithinTargetDecLayerIdSet(&nalu)
+          || nalu.m_layerId > MAX_NUM_LAYER_IDS-1
+          || (nalu.m_nalUnitType == NAL_UNIT_VPS && nalu.m_layerId > 0)           
+#if H_MV_HLS_7_MISC_P0130_EOS
+          || (nalu.m_nalUnitType == NAL_UNIT_EOB && nalu.m_layerId > 0)           
+#endif
+         ) 
+#else
       if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) || nalu.m_layerId > MAX_NUM_LAYER_IDS-1 ) 
+#endif
       {
         bNewPicture = false;
@@ -235,6 +248,23 @@
           }
 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+          if ( m_targetOptLayerSetIdx < 0 || m_targetOptLayerSetIdx >= vps->getNumOutputLayerSets() )
+          {
+            fprintf(stderr, "\ntarget output layer set index must be in the range of 0 to %d, inclusive \n", vps->getNumOutputLayerSets() - 1 );            
+            exit(EXIT_FAILURE);
+          }
+#endif
           m_targetDecLayerIdSet = vps->getTargetDecLayerIdList( m_targetOptLayerSetIdx ); 
         }
+
+#if FIX_CAM_PARS_COLLECTOR
+#if H_3D
+        if (nalu.m_nalUnitType == NAL_UNIT_VPS )
+        {        
+          
+          m_cCamParsCollector.init( m_pScaleOffsetFile, m_tDecTop[decIdx]->getPrefetchedVPS() );
+        }       
+#endif
+#endif
         bNewPicture       = ( newSliceDiffLayer || newSliceDiffPoc ) && !sliceSkippedFlag; 
         if ( nalu.isSlice() && firstSlice && !sliceSkippedFlag )        
Index: /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 854)
@@ -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")
   
@@ -604,9 +614,14 @@
 
   // 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       ")
@@ -1408,5 +1423,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" );
 
Index: /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 853)
+++ /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 854)
@@ -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;
Index: /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 854)
@@ -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
@@ -1491,4 +1494,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 )
 {
@@ -1503,5 +1577,4 @@
     std::vector<Int> targetDecLayerIdList = vps.getTargetDecLayerIdList( i ); 
     dpbSize->setSubLayerFlagInfoPresentFlag( i, m_subLayerFlagInfoPresentFlag );
-
     if ( dpbSize->getSubLayerFlagInfoPresentFlag( i ) )
     {
@@ -1546,5 +1619,5 @@
   }  
 }
-
+#endif
 
 Void TAppEncTop::xSetLayerSets( TComVPS& vps )
@@ -1552,5 +1625,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++ )
@@ -1569,10 +1644,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++)
   {
@@ -1612,4 +1742,5 @@
   }
   vps.deriveTargetLayerIdLists(); 
+#endif
 }
 
@@ -1618,10 +1749,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, 
@@ -1630,5 +1767,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 );
@@ -1636,5 +1775,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++ ) 
@@ -1754,4 +1897,10 @@
     pcVPSVUI->setVpsVuiBspHrdPresentFlag( false ); // TBD
   }
+#if H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG
+  else
+  {
+    pcVPSVUI->setCrossLayerIrapAlignedFlag   ( false   );
+  }
+#endif
 }
 #endif
Index: /branches/HTM-10.0-dev0/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 854)
@@ -60,5 +60,5 @@
 
 #if H_MV
-#define NV_VERSION        "10.0"                ///< Current software version
+#define NV_VERSION        "10.0"              ///< Current software version
 #define HM_VERSION        "13.0"                ///< 
 #else
Index: /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRom.h
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRom.h	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRom.h	(revision 854)
@@ -219,5 +219,5 @@
  extern UInt64 g_stopAtCounter;         // Counter to set breakpoint. 
  extern Bool   g_traceCopyBack;         // Output samples on copy back  
- extern Bool   g_decTraceDispDer;       // Trace derived disparity vectors (decoder only) 
+ extern Bool   g_decTraceDispDer; // Trace derived disparity vectors (decoder only) 
  extern Bool   g_decTraceMvFromMerge;   // Trace motion vectors obtained from merge (decoder only) 
  extern Bool   g_stopAtPos;             // Stop at position
@@ -230,4 +230,5 @@
 #define DTRACE_PU_S(x)             writeToTraceFile( x,   g_tracePU );
 #define DTRACE_TU_S(x)             writeToTraceFile( x,   g_traceTU );
+
 
  Void           writeToTraceFile( const Char* symbolName, Int val, Bool doIt );
Index: /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp	(revision 854)
@@ -41,4 +41,5 @@
 #include <stdio.h>
 #include <math.h>
+
 //! \ingroup TLibCommon
 //! \{
Index: /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 854)
@@ -103,5 +103,7 @@
 , m_isDepth                       (false)
 #endif
+#if !H_MV_HLS7_GEN
 , m_pocResetFlag                  (false)
+#endif
 #if H_MV
 , m_crossLayerBlaFlag             (false)
@@ -1032,5 +1034,7 @@
 #if H_MV
   // Additional slice header syntax elements 
+#if !H_MV_HLS7_GEN
   m_pocResetFlag               = pSrc->m_pocResetFlag; 
+#endif
   m_discardableFlag            = pSrc->m_discardableFlag; 
   m_interLayerPredEnabledFlag  = pSrc->m_interLayerPredEnabledFlag; 
@@ -1707,11 +1711,15 @@
     }
   } 
-
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   m_vpsNumberLayerSetsMinus1     = -1; 
+#endif
   m_vpsNumProfileTierLevelMinus1 = -1; 
     
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   for ( Int i = 0; i < MAX_VPS_PROFILE_TIER_LEVEL; i++)
   {
+#if !H_MV_HLS_7_VPS_P0048_14
     m_profileRefMinus1[ i ] = -1; 
+#endif
   }
     
@@ -1719,4 +1727,8 @@
   m_numAddOutputLayerSetsMinus1        = -1;   
   m_defaultOneTargetOutputLayerIdc     = 0; 
+#else
+  m_numAddOutputLayerSets              = -1;   
+  m_defaultTargetOutputLayerIdc     = 0; 
+#endif
   
   for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++)
@@ -1728,6 +1740,11 @@
       m_outputLayerFlag[i][j] = false; 
     }
-  }
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    m_altOutputLayerFlag[ i ]       = false; 
+#endif
+  }
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   m_altOutputLayerFlag       = false; 
+#endif
   m_maxOneActiveRefLayerFlag = false; 
   m_directDepTypeLenMinus2   = 0;         
@@ -1735,5 +1752,7 @@
 
   m_avcBaseLayerFlag = false;
+#if !H_MV_HLS7_GEN
   m_vpsVuiOffset     = 0; 
+#endif
   m_splittingFlag    = false;
   
@@ -1749,5 +1768,7 @@
   {
     m_vpsProfilePresentFlag   [i] = false;
+#if !H_MV_HLS_7_VPS_P0048_14
     m_profileRefMinus1[i] = 0;
+#endif
     m_outputLayerSetIdxMinus1       [i] = 0;
     for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ )
@@ -2060,4 +2081,7 @@
 Int    TComVPS::getNumOutputLayerSets() 
 {
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  return getNumAddOutputLayerSets() + getVpsNumLayerSetsMinus1() + 1; 
+#else
   Int numOutputLayerSets = getVpsNumberLayerSetsMinus1( ) + 1; 
   if ( getMoreOutputLayerSetsThanDefaultFlag( ) )
@@ -2066,4 +2090,5 @@
 }
   return numOutputLayerSets; 
+#endif
 }
 
@@ -2113,8 +2138,29 @@
 }
 
-Void TComVPS::deriveTargetLayerIdLists()
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+Void TComVPS::initTargetLayerIdLists()
 {
   m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); 
   m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); 
+}
+
+Void TComVPS::deriveTargetLayerIdList( Int i )
+{  
+  Int lsIdx = getLayerSetIdxForOutputLayerSet( i );     
+  
+  for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ )
+  {
+    m_targetDecLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); 
+    if( getOutputLayerFlag( i, j  ))
+    {
+      m_targetOptLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] );
+    }
+  }  
+}
+#else
+Void TComVPS::deriveTargetLayerIdLists()
+{
+  m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); 
+  m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); 
 
   for (Int targetOptLayerSetIdx = 0; targetOptLayerSetIdx < getNumOutputLayerSets(); targetOptLayerSetIdx++ )
@@ -2133,4 +2179,6 @@
   }
 }
+#endif
+
 #endif // H_MV
 
@@ -2385,4 +2433,12 @@
 {
   m_scalingList = new TComScalingList;
+
+#if H_MV_HLS_7_GEN_P0166_PPS_EXTENSION  
+  for( Int i = 0; i < PS_EX_T_MAX_NUM; i++ ) 
+  {
+    m_ppsExtensionTypeFlag[ i ] = false;
+  }
+#endif
+
 }
 
@@ -2903,4 +2959,7 @@
     // Consider to check here: 
     // "If the current picture is a RADL picture, there shall be no entry in the RefPicSetInterLayer0 and RefPicSetInterLayer1 that is a RASL picture. "    
+#if H_MV_HLS7_GEN
+    // "There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1".    
+#endif
   }
 }
@@ -3077,5 +3136,9 @@
   Int numActiveRefLayerPics; 
 
+#if H_MV_HLS_7_MISC_P0079_18
+  if( getLayerId() == 0 || getNumRefLayerPics() ==  0 )
+#else
   if( getLayerId() == 0 || getVPS()->getNumDirectRefLayers( getLayerId() ) ==  0 )
+#endif
   {
     numActiveRefLayerPics = 0; 
@@ -3091,5 +3154,9 @@
   else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 )
   {
+#if H_MV_HLS_7_MISC_P0079_18
+    numActiveRefLayerPics = 1; 
+#else
     numActiveRefLayerPics = getRefLayerPicFlag( 0 ) ? 1 : 0; 
+#endif
   }
   else
@@ -3749,4 +3816,7 @@
 {
   m_crossLayerIrapAlignedFlag = true; 
+#if H_MV_HLS_7_MISC_P0068_21
+  m_allLayersIdrAlignedFlag   = false; 
+#endif
   m_bitRatePresentVpsFlag = false;
   m_picRatePresentVpsFlag = false;
@@ -3775,4 +3845,7 @@
       m_minHorizontalCtuOffsetPlus1 [i][j] = -1;
     }
+#if H_MV_HLS_7_MISC_P0182_13
+    m_baseLayerParameterSetCompatibilityFlag[i] = false;
+#endif
   }
   for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ )
Index: /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 854)
@@ -473,4 +473,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;
@@ -481,4 +484,10 @@
   Int  m_constantPicRateIdc          [MAX_VPS_OP_SETS_PLUS1][MAX_TLAYER];
   Int  m_avgPicRate                  [MAX_VPS_OP_SETS_PLUS1][MAX_TLAYER];
+#if H_MV_HLS_7_VPS_P0076_15
+  Bool m_videoSignalInfoIdxPresentFlag;
+  Int  m_vpsNumVideoSignalInfoMinus1;
+  TComVideoSignalInfo* m_videoSignalInfo[MAX_NUM_VIDEO_SIGNAL_INFO];   
+  Int  m_vpsVideoSignalInfoIdx       [MAX_NUM_VIDEO_SIGNAL_INFO];
+#endif
   Bool m_tilesNotInUseFlag;
   Bool m_tilesInUseFlag              [MAX_NUM_LAYERS];
@@ -491,10 +500,15 @@
   Bool m_ctuBasedOffsetEnabledFlag   [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
   Int  m_minHorizontalCtuOffsetPlus1 [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
+#if !H_MV_HLS_7_VPS_P0076_15
   Bool m_videoSignalInfoIdxPresentFlag;
   Int  m_vpsNumVideoSignalInfoMinus1;
   TComVideoSignalInfo* m_videoSignalInfo[MAX_NUM_VIDEO_SIGNAL_INFO];   
   Int  m_vpsVideoSignalInfoIdx       [MAX_NUM_VIDEO_SIGNAL_INFO];
+#endif
   Bool m_vpsVuiBspHrdPresentFlag;
   TComVpsVuiBspHrdParameters* m_vpsVuiBspHrdParameters; 
+#if H_MV_HLS_7_MISC_P0182_13
+  Bool m_baseLayerParameterSetCompatibilityFlag[MAX_NUM_LAYERS];
+#endif
 
 public: 
@@ -507,4 +521,9 @@
   Bool getCrossLayerIrapAlignedFlag(  ) { return m_crossLayerIrapAlignedFlag; } 
 
+#if H_MV_HLS_7_MISC_P0068_21
+  Void setAllLayersIdrAlignedFlag( Bool flag ) { m_allLayersIdrAlignedFlag = flag; } 
+  Bool getAllLayersIdrAlignedFlag(  ) { return m_allLayersIdrAlignedFlag; } 
+#endif
+
   Void setBitRatePresentVpsFlag( Bool flag ) { m_bitRatePresentVpsFlag = flag; } 
   Bool getBitRatePresentVpsFlag(  ) { return m_bitRatePresentVpsFlag; } 
@@ -531,4 +550,18 @@
   Int  getAvgPicRate( Int i, Int j ) { return m_avgPicRate[i][j]; } 
 
+#if H_MV_HLS_7_VPS_P0076_15
+  Void setVideoSignalInfoIdxPresentFlag( Bool flag ) { m_videoSignalInfoIdxPresentFlag = flag; } 
+  Bool getVideoSignalInfoIdxPresentFlag(  ) { return m_videoSignalInfoIdxPresentFlag; } 
+
+  Void    setVideoSignalInfo( Int i, TComVideoSignalInfo* val )                        { m_videoSignalInfo[i] = val;  }  
+  TComVideoSignalInfo* getVideoSignalInfo( Int i )                                     { return m_videoSignalInfo[i]; }
+
+  Void setVpsNumVideoSignalInfoMinus1( Int  val ) { m_vpsNumVideoSignalInfoMinus1 = val; } 
+  Int  getVpsNumVideoSignalInfoMinus1(  ) { return m_vpsNumVideoSignalInfoMinus1; } 
+
+  Void setVpsVideoSignalInfoIdx( Int i, Int  val ) { m_vpsVideoSignalInfoIdx[i] = val; } 
+  Int  getVpsVideoSignalInfoIdx( Int i ) { return m_vpsVideoSignalInfoIdx[i]; } 
+#endif
+
   Void setTilesNotInUseFlag( Bool flag ) { m_tilesNotInUseFlag = flag; } 
   Bool getTilesNotInUseFlag(  ) { return m_tilesNotInUseFlag; } 
@@ -560,5 +593,5 @@
   Void setMinHorizontalCtuOffsetPlus1( Int i, Int j, Int  val ) { m_minHorizontalCtuOffsetPlus1[i][j] = val; } 
   Int  getMinHorizontalCtuOffsetPlus1( Int i, Int j ) { return m_minHorizontalCtuOffsetPlus1[i][j]; } 
-
+#if !H_MV_HLS_7_VPS_P0076_15
   Void setVideoSignalInfoIdxPresentFlag( Bool flag ) { m_videoSignalInfoIdxPresentFlag = flag; } 
   Bool getVideoSignalInfoIdxPresentFlag(  ) { return m_videoSignalInfoIdxPresentFlag; } 
@@ -572,5 +605,5 @@
   Void setVpsVideoSignalInfoIdx( Int i, Int  val ) { m_vpsVideoSignalInfoIdx[i] = val; } 
   Int  getVpsVideoSignalInfoIdx( Int i ) { return m_vpsVideoSignalInfoIdx[i]; } 
-
+#endif
   Void setVpsVuiBspHrdPresentFlag( Bool flag ) { m_vpsVuiBspHrdPresentFlag = flag; } 
   Bool getVpsVuiBspHrdPresentFlag(  ) { return m_vpsVuiBspHrdPresentFlag; }
@@ -578,4 +611,25 @@
   Void setVpsVuiBspHrdParameters( TComVpsVuiBspHrdParameters* val) {  m_vpsVuiBspHrdParameters = val; } 
   TComVpsVuiBspHrdParameters* getVpsVuiBspHrdParameters(  ) { return m_vpsVuiBspHrdParameters; }
+
+#if H_MV_HLS_7_MISC_P0182_13
+  Void setBaseLayerParameterSetCompatibilityFlag( Int i, Bool flag ) { m_baseLayerParameterSetCompatibilityFlag[i] = flag; } 
+  Bool getBaseLayerParameterSetCompatibilityFlag( Int i ) { return m_baseLayerParameterSetCompatibilityFlag[i]; } 
+#endif
+
+#if H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG
+  Void inferVpsVui( Bool encoderFlag )
+  {
+    // inference of syntax elements that differ from default inference (as done in constructor), when VPS VUI is not present
+    if (!encoderFlag )
+    {
+      setCrossLayerIrapAlignedFlag( false ); 
+    }
+    else
+    {
+      assert( !getCrossLayerIrapAlignedFlag() ); 
+    }
+
+  }
+#endif
 };
 
@@ -626,4 +680,7 @@
   Int   m_maxVpsDecPicBufferingMinus1[MAX_VPS_OUTPUTLAYER_SETS][MAX_NUM_LAYER_IDS][MAX_TLAYER];; 
   Int   m_maxVpsNumReorderPics       [MAX_VPS_OUTPUTLAYER_SETS][MAX_TLAYER];
+#if H_MV_HLS7_GEN
+  Int  m_maxVpsLayerDecPicBuffMinus1[TO_BE_SPECIFIED][TO_BE_SPECIFIED][TO_BE_SPECIFIED];
+#endif
   Int   m_maxVpsLatencyIncreasePlus1 [MAX_VPS_OUTPUTLAYER_SETS][MAX_TLAYER];
 
@@ -660,5 +717,8 @@
   Void setMaxVpsNumReorderPics( Int i, Int j, Int  val ) { m_maxVpsNumReorderPics[i][j] = val; } 
   Int  getMaxVpsNumReorderPics( Int i, Int j ) { return m_maxVpsNumReorderPics[i][j]; } 
-
+#if H_MV_HLS7_GEN
+  Void setMaxVpsLayerDecPicBuffMinus1( Int i, Int k, Int j, Int  val ) { m_maxVpsLayerDecPicBuffMinus1[i][k][j] = val; } 
+  Int  getMaxVpsLayerDecPicBuffMinus1( Int i, Int k, Int j ) { return m_maxVpsLayerDecPicBuffMinus1[i][k][j]; } 
+#endif
   Void setMaxVpsLatencyIncreasePlus1( Int i, Int j, Int  val ) { m_maxVpsLatencyIncreasePlus1[i][j] = val; } 
   Int  getMaxVpsLatencyIncreasePlus1( Int i, Int j ) { return m_maxVpsLatencyIncreasePlus1[i][j]; } 
@@ -708,5 +768,7 @@
   /// VPS EXTENSION SYNTAX ELEMENTS
   Bool        m_avcBaseLayerFlag;
+#if !H_MV_HLS7_GEN
   Int         m_vpsVuiOffset;
+#endif
   Bool        m_splittingFlag;
   Bool        m_scalabilityMaskFlag          [MAX_NUM_SCALABILITY_TYPES];
@@ -724,15 +786,30 @@
   Int         m_maxTidIlRefPicsPlus1     [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
   Bool        m_allRefLayersActiveFlag;
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   Int         m_vpsNumberLayerSetsMinus1; 
+#endif
   Int         m_vpsNumProfileTierLevelMinus1;   
   Bool        m_vpsProfilePresentFlag    [MAX_VPS_OP_SETS_PLUS1];
+
+#if !H_MV_HLS_7_VPS_P0048_14
   Int         m_profileRefMinus1         [MAX_VPS_PROFILE_TIER_LEVEL];
+#endif
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  Int         m_numAddOutputLayerSets;    
+  Int         m_defaultTargetOutputLayerIdc;
+#else  
   Bool        m_moreOutputLayerSetsThanDefaultFlag;
   Int         m_numAddOutputLayerSetsMinus1;    
   Int         m_defaultOneTargetOutputLayerIdc;
+#endif
+
   Int         m_outputLayerSetIdxMinus1  [MAX_VPS_OUTPUTLAYER_SETS];  
   Bool        m_outputLayerFlag          [MAX_VPS_OUTPUTLAYER_SETS][MAX_VPS_NUH_LAYER_ID_PLUS1];
   Int         m_profileLevelTierIdx      [MAX_VPS_OUTPUTLAYER_SETS ];
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  Bool        m_altOutputLayerFlag       [MAX_VPS_OUTPUTLAYER_SETS];
+#else
   Bool        m_altOutputLayerFlag;
+#endif
   Bool        m_repFormatIdxPresentFlag;
   Int         m_vpsNumRepFormatsMinus1;
@@ -740,4 +817,7 @@
   TComRepFormat* m_repFormat             [MAX_NUM_LAYERS]; 
   Bool        m_maxOneActiveRefLayerFlag;       
+#if H_MV_HLS7_GEN
+  Bool        m_vpsPocLsbAlignedFlag;
+#endif
   Bool        m_pocLsbNotPresentFlag     [MAX_NUM_LAYERS];
 
@@ -746,7 +826,14 @@
   Bool        m_defaultDirectDependencyFlag;
   Int         m_defaultDirectDependencyType;
+  
+#if H_MV_HLS7_GEN
+  Int         m_directDependencyType     [MAX_NUM_LAYERS] [MAX_NUM_LAYERS];
+  Int         m_vpsNonVuiExtensionLength;
+#endif
   Bool        m_vpsVuiPresentFlag;
   TComVPSVUI* m_vpsVUI; 
+#if !H_MV_HLS7_GEN
   Int         m_directDependencyType     [MAX_NUM_LAYERS] [MAX_NUM_LAYERS];
+#endif
 
   // VPS EXTENSION SEMANTICS VARIABLES
@@ -886,6 +973,8 @@
   Bool    getAvcBaseLayerFlag()                                            { return m_avcBaseLayerFlag; } 
 
+#if !H_MV_HLS7_GEN
   Void    setVpsVuiOffset( Int  val )                                      { m_vpsVuiOffset = val; } 
   Int     getVpsVuiOffset(  )                                              { return m_vpsVuiOffset; } 
+#endif
 
   Void    setSplittingFlag( Bool val )                                     { m_splittingFlag = val;  }
@@ -929,6 +1018,9 @@
   Void    setAllRefLayersActiveFlag( Bool flag )                           { m_allRefLayersActiveFlag = flag; } 
   Bool    getAllRefLayersActiveFlag(  )                                    { return m_allRefLayersActiveFlag; } 
+  
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   Void    setVpsNumberLayerSetsMinus1( Int val )                           { m_vpsNumberLayerSetsMinus1 = val;  } 
   Int     getVpsNumberLayerSetsMinus1( )                                   { return m_vpsNumberLayerSetsMinus1; } 
+#endif
   
   Void    setVpsNumProfileTierLevelMinus1( Int val )                       { m_vpsNumProfileTierLevelMinus1 = val;  } 
@@ -938,16 +1030,31 @@
   Bool    getVpsProfilePresentFlag( Int idx )                              { return m_vpsProfilePresentFlag[idx]; }
 
+#if !H_MV_HLS_7_VPS_P0048_14
   Void    setProfileRefMinus1( Int profileTierLevelIdx, Int val )          { m_profileRefMinus1[ profileTierLevelIdx ] = val;  } 
   Int     getProfileRefMinus1( Int profileTierLevelIdx )                   { return m_profileRefMinus1[ profileTierLevelIdx ]; } 
   Void    checkProfileRefMinus1( Int i )                                   { assert( getProfileRefMinus1( i ) + 1 <= i ); };  //  The value of profile_ref_minus1[ i ] + 1 shall be less than or equal to i.
+#endif
+
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   Void    setMoreOutputLayerSetsThanDefaultFlag( Bool flag )               { m_moreOutputLayerSetsThanDefaultFlag = flag; } 
   Bool    getMoreOutputLayerSetsThanDefaultFlag()                          { return m_moreOutputLayerSetsThanDefaultFlag; } 
-  
+#endif
+  
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  Void    setNumAddOutputLayerSets( Int val )                              { m_numAddOutputLayerSets = val; } 
+  Int     getNumAddOutputLayerSets( )                                      { return m_numAddOutputLayerSets; } 
+#else
   Void    setNumAddOutputLayerSetsMinus1( Int val )                        { m_numAddOutputLayerSetsMinus1 = val; } 
   Int     getNumAddOutputLayerSetsMinus1( )                                { return m_numAddOutputLayerSetsMinus1; } 
-  
+#endif
+  
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  Void    setDefaultTargetOutputLayerIdc( Int  val )                       { m_defaultTargetOutputLayerIdc = val; } 
+  Int     getDefaultTargetOutputLayerIdc(  )                               { return m_defaultTargetOutputLayerIdc; }   
+#else
   Void    setDefaultOneTargetOutputLayerIdc( Int  val )                    { m_defaultOneTargetOutputLayerIdc = val; } 
   Int     getDefaultOneTargetOutputLayerIdc(  )                            { return m_defaultOneTargetOutputLayerIdc; } 
   Void    checkDefaultOneTargetOutputLayerIdc( )                           { assert( m_defaultOneTargetOutputLayerIdc >= 0 && m_defaultOneTargetOutputLayerIdc <= 1 ); }
+#endif
   
   Void    setOutputLayerSetIdxMinus1( Int outLayerSetIdx, Int val )        { m_outputLayerSetIdxMinus1[ outLayerSetIdx ]  = val; } 
@@ -956,10 +1063,46 @@
   Void    setOutputLayerFlag( Int outLayerSetIdx, Int i, Bool flag )       { m_outputLayerFlag[ outLayerSetIdx ][ i ] = flag; } 
   Bool    getOutputLayerFlag( Int outLayerSetIdx, Int i )                  { return m_outputLayerFlag[ outLayerSetIdx ][ i ]; } 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  Bool    inferOutputLayerFlag( Int i, Int j )                             
+  { 
+    Bool outputLayerFlag; 
+    switch ( getDefaultTargetOutputLayerIdc( ) )
+    {
+    case 0:
+      outputLayerFlag = true; 
+      break; 
+    case 1:
+      outputLayerFlag = ( j == m_layerSetLayerIdList[ getLayerSetIdxForOutputLayerSet( i ) ].size() - 1 );  
+      break;
+    case 2:
+      if ( i == 0 && j == 0)
+      {     
+        outputLayerFlag = true;  // This is a software only fix for a bug in the spec. In spec outputLayerFlag neither present nor inferred. 
+      }
+      else
+      {
+        assert( 0 ); 
+      }
+      break; 
+    default:      
+      assert( 0 );
+      break; 
+    }
+    return outputLayerFlag;
+  }
+#else
   Bool    inferOutputLayerFlag( Int layerSetIdx, Int i )                   { return ( getDefaultOneTargetOutputLayerIdc( ) == 0 || ( ( getDefaultOneTargetOutputLayerIdc( ) == 1 ) && ( i == m_layerSetLayerIdList[layerSetIdx].size() - 1  ) ));  }
+#endif
 
   Void    setProfileLevelTierIdx( Int outLayerSetIdx, Int val )            { m_profileLevelTierIdx[ outLayerSetIdx ] = val; }
   Int     getProfileLevelTierIdx( Int outLayerSetIdx )                     { return m_profileLevelTierIdx[ outLayerSetIdx ]; } 
+  
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  Void    setAltOutputLayerFlag( Int i, Bool flag )                        { m_altOutputLayerFlag[i] = flag; } 
+  Bool    getAltOutputLayerFlag( Int i )                                   { return m_altOutputLayerFlag[i]; } 
+#else
   Void    setAltOutputLayerFlag( Bool flag )                               { m_altOutputLayerFlag = flag; } 
   Bool    getAltOutputLayerFlag(  )                                        { return m_altOutputLayerFlag; } 
+#endif
 
   Void    setRepFormatIdxPresentFlag( Bool flag )                          { m_repFormatIdxPresentFlag = flag; } 
@@ -977,4 +1120,9 @@
   Bool    getMaxOneActiveRefLayerFlag( )                                   { return m_maxOneActiveRefLayerFlag; } 
 
+#if H_MV_HLS7_GEN
+  Void    setVpsPocLsbAlignedFlag( Bool flag )                             { m_vpsPocLsbAlignedFlag = flag; } 
+  Bool    getVpsPocLsbAlignedFlag(  )                                      { return m_vpsPocLsbAlignedFlag; } 
+#endif
+
   Void    setDpbSize( TComDpbSize* val )                                   { assert( m_dpbSize != 0 ); m_dpbSize = val; } 
   TComDpbSize* getDpbSize( )                                               { return m_dpbSize;} 
@@ -992,4 +1140,10 @@
   Void    setDirectDependencyType( Int depLayeridInVps, Int refLayeridInVps, Int val) { m_directDependencyType[ depLayeridInVps ][ refLayeridInVps ] = val; } 
   Int     getDirectDependencyType( Int depLayeridInVps, Int refLayeridInVps)   { return m_directDependencyType[ depLayeridInVps ][ refLayeridInVps ]; } 
+
+#if H_MV_HLS7_GEN
+  Void    setVpsNonVuiExtensionLength( Int  val )                          { m_vpsNonVuiExtensionLength = val; } 
+  Int     getVpsNonVuiExtensionLength(  )                                  { return m_vpsNonVuiExtensionLength; } 
+#endif
+
   Void    setVpsVuiPresentFlag( Bool flag )                                { m_vpsVuiPresentFlag = flag; } 
   Bool    getVpsVuiPresentFlag(  )                                         { return m_vpsVuiPresentFlag; } 
@@ -1021,8 +1175,35 @@
   Bool    isOutputLayer( Int outLayerSetIdx, Int layerIdInNuh );   
   Void    deriveLayerSetLayerIdList();
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  Int     getLayerSetIdxForOutputLayerSet( Int i )                         { return ( i <= getVpsNumLayerSetsMinus1() ) ? i  : getOutputLayerSetIdxMinus1( i ) + 1 ; };
+
+  Void    initTargetLayerIdLists  ( );
+  Void    deriveTargetLayerIdList ( Int i );
+
+  std::vector<Int> getTargetDecLayerIdList( Int targetDecLayerSetIdx )     { return m_targetDecLayerIdLists[targetDecLayerSetIdx]; }; 
+  std::vector<Int> getTargetOptLayerIdList( Int targetOptLayerSetIdx )     { return m_targetOptLayerIdLists[targetOptLayerSetIdx]; }; 
+
+  Int     getNumOutputLayersInOutputLayerSet( Int i )                      { return (Int) getTargetOptLayerIdList( i ).size(); }; 
+  Int     getOlsHighestOutputLayerId( Int i )                              { return getTargetOptLayerIdList( i ).back(); };  
+#else
   Void    deriveTargetLayerIdLists();
   std::vector<Int> getTargetDecLayerIdList( Int targetOptLayerSetIdx )     { return m_targetDecLayerIdLists[targetOptLayerSetIdx]; }; 
   std::vector<Int> getTargetOptLayerIdList( Int targetOptLayerSetIdx )     { return m_targetDecLayerIdLists[targetOptLayerSetIdx]; }; 
-
+#endif
+
+#if H_MV_HLS_7_HRD_P0156_7
+  Int     getMaxSubLayersInLayerSetMinus1( Int i )
+  { 
+    Int maxSLMinus1 = 0; 
+    Int optLsIdx    = getLayerSetIdxForOutputLayerSet( i );
+    for( Int k = 0; k < getNumLayersInIdList( optLsIdx ); k++ )
+    {
+      Int lId = m_layerSetLayerIdList[optLsIdx][k];
+      maxSLMinus1 = std::max( maxSLMinus1, getSubLayersVpsMaxMinus1( getLayerIdInVps( lId ) ));
+    }
+    return maxSLMinus1; 
+  }
+#endif
 
   // inference
@@ -1049,4 +1230,7 @@
   UInt getCamParPrecision    ()  { return m_uiCamParPrecision; }
   Bool getCamParPresent      ( Int viewIndex )  { return m_bCamParPresent[viewIndex]; }
+#if FIX_CAM_PARS_COLLECTOR
+  Void setCamParPresent      ( Int viewIndex, Bool val )  { m_bCamParPresent[viewIndex] = val; }
+#endif
   Bool hasCamParInSliceHeader( Int viewIndex )  { return m_bCamParInSliceHeader[viewIndex]; }
   Void setHasCamParInSliceHeader( Int viewIndex, Bool b )  { m_bCamParInSliceHeader[viewIndex] = b; }
@@ -1753,4 +1937,11 @@
   Bool m_ppsInferScalingListFlag;
   Int  m_ppsScalingListRefLayerId;
+
+#if H_MV_HLS_7_GEN_P0166_PPS_EXTENSION
+  Bool m_ppsExtensionTypeFlag[PS_EX_T_MAX_NUM];
+#endif
+#if H_MV_HLS7_GEN
+  Bool m_pocResetInfoPresentFlag;
+#endif
 #endif
 
@@ -1894,4 +2085,15 @@
   Void setPpsScalingListRefLayerId( Int  val ) { m_ppsScalingListRefLayerId = val; } 
   Int  getPpsScalingListRefLayerId(  ) { return m_ppsScalingListRefLayerId; } 
+
+#if H_MV_HLS_7_GEN_P0166_PPS_EXTENSION
+  Void setPpsExtensionTypeFlag( Int i, Bool flag ) { m_ppsExtensionTypeFlag[i] = flag; } 
+  Bool getPpsExtensionTypeFlag( Int i ) { return m_ppsExtensionTypeFlag[i]; } 
+#endif
+
+#if H_MV_HLS7_GEN
+  Void setPocResetInfoPresentFlag( Bool flag ) { m_pocResetInfoPresentFlag = flag; } 
+  Bool getPocResetInfoPresentFlag(  ) { return m_pocResetInfoPresentFlag; } 
+#endif
+
 #endif
 };
@@ -2030,5 +2232,7 @@
 
 // Additional slice header syntax elements 
+#if !H_MV_HLS7_GEN
   Bool       m_pocResetFlag; 
+#endif
   Bool       m_crossLayerBlaFlag;
   Bool       m_discardableFlag;
@@ -2036,6 +2240,19 @@
   Int        m_numInterLayerRefPicsMinus1;
   Int        m_interLayerPredLayerIdc       [MAX_NUM_LAYERS];
+
+#if H_MV_HLS7_GEN
+  Int        m_sliceSegmentHeaderExtensionLength;
+  Int        m_pocResetIdc;
+  Int        m_pocResetPeriodId;
+  Bool       m_fullPocResetFlag;
+  Int        m_pocLsbVal;
+  Bool       m_pocMsbValPresentFlag;
+  Int        m_pocMsbVal;
+#endif
+
+#if H_3D
   Int        m_aaiCodedScale [2][MAX_NUM_LAYERS];
   Int        m_aaiCodedOffset[2][MAX_NUM_LAYERS];
+#endif
 #if H_3D_TMVP
   Int        m_aiAlterRefIdx   [2]; 
@@ -2363,6 +2580,8 @@
   }
 
+#if !H_MV_HLS7_GEN
   Void setPocResetFlag( Bool flag ) { m_pocResetFlag = flag; } 
   Bool getPocResetFlag(  ) { return m_pocResetFlag; } 
+#endif
 
   Void setDiscardableFlag( Bool flag ) { m_discardableFlag = flag; } 
@@ -2377,4 +2596,28 @@
   Void setInterLayerPredLayerIdc( Int i, Int  val ) { m_interLayerPredLayerIdc[i] = val; } 
   Int  getInterLayerPredLayerIdc( Int i ) { return m_interLayerPredLayerIdc[i]; } 
+
+#if H_MV_HLS7_GEN
+  Void setSliceSegmentHeaderExtensionLength( Int  val ) { m_sliceSegmentHeaderExtensionLength = val; } 
+  Int  getSliceSegmentHeaderExtensionLength(  ) { return m_sliceSegmentHeaderExtensionLength; } 
+
+  Void setPocResetIdc( Int  val ) { m_pocResetIdc = val; } 
+  Int  getPocResetIdc(  ) { return m_pocResetIdc; } 
+
+  Void setPocResetPeriodId( Int  val ) { m_pocResetPeriodId = val; } 
+  Int  getPocResetPeriodId(  ) { return m_pocResetPeriodId; } 
+
+  Void setFullPocResetFlag( Bool flag ) { m_fullPocResetFlag = flag; } 
+  Bool getFullPocResetFlag(  ) { return m_fullPocResetFlag; } 
+
+  Void setPocLsbVal( Int  val ) { m_pocLsbVal = val; } 
+  Int  getPocLsbVal(  ) { return m_pocLsbVal; } 
+
+  Void setPocMsbValPresentFlag( Bool flag ) { m_pocMsbValPresentFlag = flag; } 
+  Bool getPocMsbValPresentFlag(  ) { return m_pocMsbValPresentFlag; } 
+
+  Void setPocMsbVal( Int  val ) { m_pocMsbVal = val; } 
+  Int  getPocMsbVal(  ) { return m_pocMsbVal; } 
+
+#endif
 
   // Additional variables derived in slice header semantics 
@@ -2395,6 +2638,10 @@
   Void     setRefPicSetInterLayer       ( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1);
   TComPic* getPicFromRefPicSetInterLayer( Int setIdc, Int layerId );
-#endif
-
+
+#if H_MV_HLS7_GEN
+  Bool     getPocMsbValRequiredFlag( )        { return   }; 
+  UInt     getPocLsbValLen()                  { return getSPS->getBitsForPOC(); }; //log2_max_pic_order_cnt_lsb_minus4 + 4  
+#endif
+#endif
 #if MTK_DDD_G0063
   Void InitializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx );
Index: /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 854)
@@ -327,5 +327,54 @@
 ///////////////////////////////////   HTM-10.1 Integrations //////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////
-#define UPDATE_HM13                       1
+
+
+// TBD
+
+// #define H_MV_HLS_7_ED_FIX_P0130_34        0 // (ED.FIX/P0130/il ref pic set no reference pic) #34 For proposal 5, delegated to editors
+// #define H_MV_HLS_7_OTHER_P0187_1          0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution 
+// #define H_MV_HLS_7_VPS_P0306_22           0 // (VPS/P0306/ue(v) coded syntax elements) #22 Several minor modifications to the VPS syntax, consistent with eliminating the previous intention to avoid ue(v) parsing in the VPS 
+// #define H_MV_HLS_7_SEI_P0133_28           0 // (SEI/P0133/Recovery point SEI) #28 Decision: Adopt change to recover point semantics only (-v3)
+// #define H_MV_HLS_7_VPS_P0125_24           0 // (VPS/P0125/VPS extension offset ) #24 Decision: Keep it as a reserved FFFF value. 
+// #define H_MV_HLS_7_VPS_P0307_23           0 // (VPS/P0307/VPS VUI extension)  #23 Decision: Adopt modification in P0307.
+// #define H_MV_HLS_7_POC_P0041_3            0 // (POC/P0041/POC reset) #3 It was remarked that we should require each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture. This was agreed. Decision: Adopt (with constraint for discardable_flag as described above) 
+// #define H_MV_HLS_7_POC_P0041_FIXES        0 // (POC/P0041/Fixes) For each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture. 
+// #define H_MV_HLS_7_SEI_P0204_26           0 // (SEI/P0204/sub-bitstream SEI) #26 Add sub-bitstream property SEI message. Decision: Adopt
+// #define H_MV_HLS_7_MISC_P0130_20          0 // (MISC/P0130/discardable not in inter-layer RPS) #20 Add constraint restricting pictures marked as discardable from being present in the temporal or inter-layer RPS,
+
+
+// #define H_MV_HLS_7_SEI_P0123_25           0 // (SEI/P0123/Alpha channel info) #25 Add alpha channel information SEI message Decision: Adopt. Constrain the bit depth indicated to be equal to the coded bit depth of the aux picture. 
+// #define H_MV_HLS_7_VPS_P0300_27           0 // Output part only. (VPS/P0300/alt output layer flag) #27 Change alt output layer flag to be signalled within the loop of output layer sets, from JCTVC-P0300-v2. Decision: Adopt. 
+// #define H_MV_HLS_7_POC_P0056_4            0 // (POC/P0056/layer tree poc) #4 Proposal 1: If the POC reset approach is adopted as the basis for multi-layer POC derivation, it is proposed to derive the POC anchor picture from the previous TID0 picture (that is not a RASL picture, a RADL picture or a sub-layer non-reference picture and not with discardable_flag equal to 1) of  the current layer or any of its reference layer. This is asserted to improve loss resilience and reduce bit rate overhead. Decision: Adopt Proposal 1 (with the suggested modifications  with text provided as P0297).
+// #define H_MV_HLS_7_HRD_P0138_6            0 // (HRD/P0138/HRD parameters for bitstreams excluding) #6 Decision: Adopt (as revised in updated contribution, with the specification of a flag in the BP SEI (HRD/P0192/sub-DPB) #12 Establish sub-DPBs based on the representation format indicated at the VPS level. It was suggested that the expressed shared capacity limit would need to be less than or equal to the sum of the individual capacity limits. Decision: Adopt as modified. Further study is encouraged on profile/level constraint selections. 
+
+
+
+
+
+#define H_MV_HLS7_GEN                          0  // General changes (not tested)
+#define H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27    1  // Output layer sets, various
+                                                  // (VPS/P0300/alt output layer flag) #27 Change alt output layer flag to be signalled within the loop of output layer sets, from JCTVC-P0300-v2. Decision: Adopt. 
+                                                  // (VPS/P0156/Num of output_layer_flag) #10 Proposal 3: The output_layer_flag[ i ][ j ] is signalled for j equal to 0 to NumLayersInIdList[ lsIdx ] inclusive. It was remarked that we might be able to just assume that the top layer is always output; however, this was not entirely clear , so the safe thing to do may be to also send the flag for this layer.
+                                                  // (VPS/P0295/Default output layer sets) #5 Discussion from (P0110). Decision: Three-state approach (text in P0295, decoder shall allow 3 to be present and shall treat 3 the same as the value 2). 
+
+
+#define H_MV_HLS_7_HRD_P0156_7                 1  // (HRD/P0156/MaxSubLayersInLayerSetMinus1) #7 Proposal 1: signal, in the VPS extension, the DPB parameters for an output layer set for sub-DPBs only up to the maximum temporal sub-layers in the corresponding layer set
+#define H_MV_HLS_7_VPS_P0048_14                1  // (VPS/P0048/profile_ref_minus1 rem) #14 Remove profile_ref_minus1 from the VPS extension, from JCTVC-P0048
+#define H_MV_HLS_7_VPS_P0076_15                1  // (VPS/P0076/video signal info move) #15 Move video signal information syntax structure earlier in the VPS VUI.
+#define H_MV_HLS_7_SPS_P0155_16_32             1  // (SPS/P0155/sps_sub_layer_ordering_info) #16, #32 Not signal the sps_max_num_reorder_pics[], sps_max_latency_increase_plus1[], and sps_max_dec_pic_buffering_minus1[] syntax elements in the SPS when nuh_layer_id > 0. 
+#define H_MV_HLS_7_GEN_P0166_PPS_EXTENSION     1  // (GEN/P0166/pps_extension) #17 Add PPS extension type flags for conditional presence of syntax extensions per extension type, aligned with the SPS extension type flags, from JCTVC-P0166. Further align the SPS extension type flags syntax between RExt and MV-HEVC/SHVC
+#define H_MV_HLS_7_FIX_SET_DPB_SIZE            1  // Fix derivation dpb size parameters
+#define H_MV_HLS_7_RESERVED_FLAGS              1  // Added flags
+                                                  // (SPS/P0312/SHVC reserved flag) The flag will be used for the syntax vert_phase_position_enable_flag in SHVC draft
+                                                  // (VPS/O0215/SHVC reserved flag): this flag will be used for the syntax cross_layer_phase_alignment_flag in SHVC draft.
+                                                  // (VPS VUI/O0199,P0312/SHVC reserved flags) the 3 reserved bits will be used for the syntaxes single_layer_for_non_irap_flag, higher_layer_irap_skip_flag and vert_phase_position_not_in_use_flag in SHVC draft.
+#define H_MV_FIX_VPS_LAYER_ID_NOT_EQUAL_ZERO   1  // Discard VPS with nuh_layer_Id > 0
+#define H_MV_HLS_7_MISC_P0130_EOS              1  // (MISC/P0130/EOS NAL layer id) #19 Require that end of bitstream NAL unit shall have nuh_layer_id equal to 0, from JCTVC-P0130. Decoders shall allow an end of bitstream NAL unit with nuh_layer_id > 0 to be present, and shall ignore the NAL unit.
+#define H_MV_HLS_7_MISC_P0182_13               1  // (MISC/P0182/BL PS Compatibility flag) #13 Define the flag (in VPS VUI) with the proposed semantics, without specifying an associated extraction process. Editors to select the position in the VPS VUI.
+#define H_MV_HLS_7_MISC_P0068_21               1  // (MISC/P0068/all irap idr flag) #21 Add flag in VUI to indicate that all IRAP pictures are IDRs and that all layer pictures in an AU are IDR aligned, from JCTVC-P0068 proposal 1.
+#define H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG               1  // Fix inference of cross_layer_irap_aligned_flag
+#define H_MV_HLS_7_MISC_P0079_18               1  // (MISC/P0079/NumActiveRefLayerPics) #18 Modification of derivation of variable NumActiveRefLayerPics.
+#define FIX_CAM_PARS_COLLECTOR                 1
+#define UPDATE_HM13                            1  // Only some parts in H_3D parts are marked! 
 #if H_3D
 #define H_3D_FIX_G0148_BRACE              1 
@@ -857,4 +906,18 @@
 #if H_MV
 
+#if H_MV_HLS_7_GEN_P0166_PPS_EXTENSION
+enum PpsExtensionTypes
+{
+  PPS_EX_T_MV      = 0,
+#if H_3D
+  PPS_EX_T_3D      = 3,
+#endif
+  PPS_EX_T_ESC     = 7,
+  PPS_EX_T_MAX_NUM = 8
+};
+
+//Below for sps, would be good if this could be aligned
+#endif
+
   enum PsExtensionTypes
   {
Index: /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 854)
@@ -366,4 +366,45 @@
 
   READ_FLAG( uiCode, "pps_extension_flag");
+#if H_MV_HLS_7_GEN_P0166_PPS_EXTENSION
+  if (uiCode)
+  {
+#if H_MV
+    for ( Int i = 0; i < PPS_EX_T_MAX_NUM; i++ )
+    {
+      READ_FLAG( uiCode, "pps_extension_type_flag" ); pcPPS->setPpsExtensionTypeFlag( i, uiCode == 1 );
+#if H_3D
+      assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_3D || i == PPS_EX_T_ESC ); 
+#else
+      assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_ESC ); 
+#endif
+    }
+    
+
+    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_MV ) )
+    {
+#if H_MV_HLS7_GEN
+      READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 );
+#endif
+    }
+
+#if H_3D
+    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_3D ) ) // This probably needs to be aligned with Rext and SHVC
+    {
+      parsePPSExtension( pcPPS, pcVPS );
+    }
+#endif
+
+    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_ESC ) )
+    {
+#endif
+      while ( xMoreRbspData() )
+      {
+        READ_FLAG( uiCode, "pps_extension_data_flag");
+      }
+#if H_MV
+    }
+#endif
+  }
+#else
   if (uiCode)
   {
@@ -382,4 +423,5 @@
 #endif
   }
+#endif
 }
 
@@ -807,4 +849,8 @@
   assert(uiCode <= 12);
 
+#if H_MV_HLS_7_SPS_P0155_16_32
+  if ( pcSPS->getLayerId() == 0 ) 
+  {  
+#endif
   UInt subLayerOrderingInfoPresentFlag;
   READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
@@ -842,4 +888,7 @@
     }
   }
+#if H_MV_HLS_7_SPS_P0155_16_32
+  }
+#endif
 
   READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" );
@@ -1004,4 +1053,7 @@
     READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); pcSPS->setScaledRefLayerRightOffset( j, iCode );
     READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); pcSPS->setScaledRefLayerBottomOffset( j, iCode );
+#if H_MV_HLS_7_RESERVED_FLAGS
+    READ_FLAG( uiCode, "sps_multilayer_ext_reserved_zero_flag[ i ]" );
+#endif
   }
 }
@@ -1039,5 +1091,7 @@
   READ_FLAG(     uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
   assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
-#if H_MV
+
+
+#if H_MV && !H_MV_HLS7_GEN
   READ_CODE( 16, uiCode,  "vps_extension_offset" );               
 #else
@@ -1154,8 +1208,11 @@
   UInt uiCode; 
   READ_FLAG( uiCode, "avc_base_layer_flag" );                     pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false );
-  READ_FLAG( uiCode, "vps_vui_present_flag" );                    pcVPS->setVpsVuiPresentFlag( uiCode == 1 );  if ( pcVPS->getVpsVuiPresentFlag() )
+#if !H_MV_HLS7_GEN
+  READ_FLAG( uiCode, "vps_vui_present_flag" );                    pcVPS->setVpsVuiPresentFlag( uiCode == 1 );
+  if ( pcVPS->getVpsVuiPresentFlag() )
   {  
   READ_CODE( 16, uiCode, "vps_vui_offset" );                      pcVPS->setVpsVuiOffset( uiCode );
   }
+#endif
 
   READ_FLAG( uiCode, "splitting_flag" );                          pcVPS->setSplittingFlag( uiCode == 1 ? true : false );
@@ -1233,5 +1290,5 @@
   if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() )
   {
-    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
     {
       READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode );    
@@ -1242,5 +1299,5 @@
   else
   {
-    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
     {
       pcVPS->setSubLayersVpsMaxMinus1( i, pcVPS->getMaxTLayers( ) - 1);    
@@ -1264,10 +1321,17 @@
 
   READ_FLAG( uiCode, "all_ref_layers_active_flag" );             pcVPS->setAllRefLayersActiveFlag( uiCode == 1 );
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1"      );  pcVPS->setVpsNumberLayerSetsMinus1    ( uiCode ); 
+#endif
+
+#if !H_MV_HLS7_GEN
   READ_CODE( 6,  uiCode, "vps_num_profile_tier_level_minus1" );  pcVPS->setVpsNumProfileTierLevelMinus1( uiCode );
-
+#else
+  READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1" );  pcVPS->setVpsNumProfileTierLevelMinus1( uiCode );  
+#endif
   for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ )
   {
     READ_FLAG(  uiCode, "vps_profile_present_flag[i]" );    pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 );
+#if !H_MV_HLS_7_VPS_P0048_14
     if( !pcVPS->getVpsProfilePresentFlag( i ) )
     {
@@ -1275,13 +1339,27 @@
       pcVPS->checkProfileRefMinus1( i );      
     }
+#endif
     parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1);
     if( !pcVPS->getVpsProfilePresentFlag( i ) )
     {
       TComPTL temp = *pcVPS->getPTL( i );
+#if H_MV_HLS_7_VPS_P0048_14
+      *pcVPS->getPTL( i ) = *pcVPS->getPTL( i - 1 );
+#else
       *pcVPS->getPTL( i ) = *pcVPS->getPTL( pcVPS->getProfileRefMinus1( i ) + 1 );
+#endif
       pcVPS->getPTL( i )->copyLevelFrom( &temp );
     }
   }
 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  READ_UVLC( uiCode, "num_add_output_layer_sets"      ); pcVPS->setNumAddOutputLayerSets( uiCode );
+  pcVPS->initTargetLayerIdLists( ); 
+  if( pcVPS->getNumOutputLayerSets() > 1)
+  {
+    READ_CODE( 2, uiCode, "default_target_output_layer_idc" ); pcVPS->setDefaultTargetOutputLayerIdc( std::min( uiCode, (UInt) 2 ) );    
+  }  
+
+#else
   Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1; 
 
@@ -1299,12 +1377,40 @@
     pcVPS->checkDefaultOneTargetOutputLayerIdc(); 
   }  
+#endif
 
   pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); 
   pcVPS->setOutputLayerSetIdxMinus1(0, -1); 
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  pcVPS->deriveTargetLayerIdList( 0 ); 
+  for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ )
+  {
+    if( i > pcVPS->getVpsNumLayerSetsMinus1( ) )    
+#else
   for( Int i = 1; i < numOutputLayerSets; i++ )
   {
     if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) )
+#endif
     {        
       READ_UVLC( uiCode,      "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    }
+
+    if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultTargetOutputLayerIdc() == 2 )
+    {       
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->getLayerSetIdxForOutputLayerSet( i ) ); j++ )
+      {
+        READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); 
+      }
+    }
+    else
+    { 
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->getLayerSetIdxForOutputLayerSet( i ) ); j++ )
+      {              
+        pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); 
+      }
+    }
+    pcVPS->deriveTargetLayerIdList( i ); 
+#else
       for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ )
       {
@@ -1320,9 +1426,17 @@
       }
     }
-
+#endif
     if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
     {      
       READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" );   pcVPS->setProfileLevelTierIdx( i , uiCode ); 
     }
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 )
+    {
+      READ_FLAG( uiCode, "alt_output_layer_flag[ i ]" ); pcVPS->setAltOutputLayerFlag( i, uiCode == 1 );
+    }
+  }
+#else
   }
   if( pcVPS->getMaxLayersMinus1() > 0 )
@@ -1330,9 +1444,18 @@
     READ_FLAG( uiCode, "alt_output_layer_flag" ); pcVPS->setAltOutputLayerFlag( uiCode == 1 );
   }
+#endif
+
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   pcVPS->deriveTargetLayerIdLists(); 
+#endif
+
   READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 );
   if ( pcVPS->getRepFormatIdxPresentFlag() )
   {
+#if H_MV_HLS7_GEN
+    READ_UVLC( 4, uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode );
+#else
     READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode );
+#endif
   }
 
@@ -1358,4 +1481,7 @@
 
   READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); 
+#if H_MV_HLS7_GEN
+  READ_FLAG( uiCode, "vps_poc_lsb_aligned_flag" ); pcVPS->setVpsPocLsbAlignedFlag( uiCode == 1 );
+#endif
   for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1366,4 +1492,7 @@
   }
 
+#if H_MV_HLS_7_RESERVED_FLAGS
+  READ_FLAG( uiCode, "vps_reserved_zero_flag" ); 
+#endif
   parseDpbSize( pcVPS ); 
 
@@ -1394,6 +1523,15 @@
   }  
 
+#if H_MV_HLS7_GEN
+  READ_UVLC( uiCode, "vps_non_vui_extension_length" ); pcVPS->setVpsNonVuiExtensionLength( uiCode ); 
+  for ( Int i = 1; i < pcVPS->getVpsNonVuiExtensionLength(); i++ )
+  {
+    READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" );
+  }
+  READ_FLAG( uiCode, "vps_vui_present_flag" );                    pcVPS->setVpsVuiPresentFlag( uiCode == 1 );  if ( pcVPS->getVpsVuiPresentFlag() )
+#endif
+#if !H_MV_HLS_7_RESERVED_FLAGS
   READ_FLAG( uiCode, "vps_shvc_reserved_zero_flag" ); 
-
+#endif
   if( pcVPS->getVpsVuiPresentFlag() )
   {
@@ -1401,4 +1539,11 @@
     parseVPSVUI( pcVPS ); 
   }     
+#if H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG
+  {
+    TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
+    assert( pcVPSVUI ); 
+    pcVPSVUI->inferVpsVui( false ); 
+  }
+#endif
 
   pcVPS->checkVPSExtensionSyntax(); 
@@ -1448,9 +1593,19 @@
     READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPSVUI->setCrossLayerIrapAlignedFlag( uiCode == 1 );
   }
+#if H_MV_HLS_7_MISC_P0068_21
+  if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) )
+  {
+    READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); pcVPSVUI->setAllLayersIdrAlignedFlag( uiCode == 1 );
+  }
+#endif
   READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); pcVPSVUI->setBitRatePresentVpsFlag( uiCode == 1 );
   READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); pcVPSVUI->setPicRatePresentVpsFlag( uiCode == 1 );
   if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
   {
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    for( Int i = 0; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
+#else
     for( Int i = 0; i  <=  pcVPS->getVpsNumberLayerSetsMinus1(); i++ )
+#endif
     {
       for( Int j = 0; j  <=  pcVPS->getMaxTLayers(); j++ ) 
@@ -1477,4 +1632,40 @@
     }
   }
+
+#if H_MV_HLS_7_VPS_P0076_15
+  READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 );
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
+  {
+    READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); pcVPSVUI->setVpsNumVideoSignalInfoMinus1( uiCode );
+  }
+  else
+  {
+    pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() ); 
+  }
+
+  for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ )
+  {
+    assert( pcVPSVUI->getVideoSignalInfo( i ) == NULL ); 
+    TComVideoSignalInfo* curVideoSignalInfo = new TComVideoSignalInfo();     
+    parseVideoSignalInfo( curVideoSignalInfo ); 
+    pcVPSVUI->setVideoSignalInfo(i, curVideoSignalInfo ); 
+  }
+
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode );
+      assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i ) >= 0 && pcVPSVUI->getVpsVideoSignalInfoIdx( i ) <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1() );
+    }
+  }
+  else
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      pcVPSVUI->setVpsVideoSignalInfoIdx( i, pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ? 0 : i ); 
+    }
+  }
+#endif
 
   READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 );
@@ -1513,4 +1704,8 @@
   }
 
+#if H_MV_HLS_7_RESERVED_FLAGS
+  READ_CODE( 3, uiCode, "vps_vui_reserved_zero_3bits" ); 
+#endif
+
   READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 );
 
@@ -1534,4 +1729,5 @@
   }
 
+#if !H_MV_HLS_7_VPS_P0076_15
   READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 );
   if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
@@ -1567,4 +1763,5 @@
     }
   }
+#endif
   READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); pcVPSVUI->setVpsVuiBspHrdPresentFlag( uiCode == 1 );
   if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
@@ -1572,4 +1769,13 @@
     parseVpsVuiBspHrdParameters( pcVPS ); 
 }
+#if H_MV_HLS_7_MISC_P0182_13
+  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) 
+    {
+      READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); pcVPSVUI->setBaseLayerParameterSetCompatibilityFlag( i, uiCode == 1 );
+    }
+  }
+#endif
 }
 
@@ -1650,6 +1856,9 @@
   {  
     READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 );
-
+#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
     {  
       if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
@@ -1659,9 +1868,22 @@
       if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
       {  
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+        for( Int k = 0; k < vps->getNumSubDpbs( vps->getLayerSetIdxForOutputLayerSet( i )); k++ )   
+#else
         for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+#endif
         {
           READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode );
         }
         READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize->setMaxVpsNumReorderPics( i, j, uiCode );
+#if H_MV_HLS7_GEN
+        if( vps->getNumSubDpbs( vps->getLayerSetIdxForOutputLayerSet( i ) ) != vps->getNumLayersInIdList( vps->getLayerSetIdxForOutputLayerSet( i ) ) ) 
+        {
+          for( Int k = 0; k < vps->getNumLayersInIdList( vps->getLayerSetIdxForOutputLayerSet( i ) ); k++ )
+          {
+            READ_UVLC( uiCode, "max_vps_layer_dec_pic_buff_minus1" ); dpbSize->setMaxVpsLayerDecPicBuffMinus1( i, k, j, uiCode );
+          }
+        }
+#endif
         READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode );
       }
@@ -1704,5 +1926,5 @@
 #if H_3D_SPIVMP
 #if SEC_SPIVMP_MCP_SIZE_G0077
-        READ_UVLC (uiCode, "log2_sub_PU_size_minus3");     pcVPS->setSubPULog2Size(i, uiCode+3); 
+        READ_UVLC (uiCode, "log2_sub_PU_size_minus3[i]");     pcVPS->setSubPULog2Size(i, uiCode+3); 
 #else
         READ_UVLC (uiCode, "log2_sub_PU_size_minus2");     pcVPS->setSubPULog2Size(i, uiCode+2); 
@@ -1761,4 +1983,8 @@
   for (UInt viewIndex=0; viewIndex<pcVPS->getNumViews(); viewIndex++)
   {
+#if FIX_CAM_PARS_COLLECTOR
+    pcVPS->setCamParPresent         ( viewIndex, false );
+    pcVPS->setHasCamParInSliceHeader( viewIndex, false );
+#endif
     READ_FLAG( uiCode, "cp_present_flag[i]" );                  bCamParPresentFlag = ( uiCode == 1);
     if ( bCamParPresentFlag )
@@ -1890,4 +2116,5 @@
     rpcSlice->checkCrossLayerBlaFlag( ); 
 
+#if !H_MV_HLS7_GEN
     if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
     {
@@ -1895,4 +2122,5 @@
       READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 );
     }
+#endif
 
     for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++)    
@@ -2492,6 +2720,6 @@
   if(pps->getSliceHeaderExtensionPresentFlag())
   {
+#if !H_MV_HLS7_GEN    
     READ_UVLC(uiCode,"slice_header_extension_length");
-
     for(Int i=0; i<uiCode; i++)
     {
@@ -2500,4 +2728,51 @@
     }
   }
+#else
+#if H_MV
+    READ_UVLC( uiCode, "slice_segment_header_extension_length" ); rpcSlice->setSliceSegmentHeaderExtensionLength( uiCode );
+    UInt posFollSliceSegHeaderExtLen = m_pcBitstream->getNumBitsRead();
+
+    if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() )
+    {
+      READ_CODE( 2, uiCode, "poc_reset_idc" ); rpcSlice->setPocResetIdc( uiCode );
+    }
+
+    if( rpcSlice->getPocResetIdc() !=  0 )
+    {
+      READ_CODE( 6, uiCode, "poc_reset_period_id" ); rpcSlice->setPocResetPeriodId( uiCode );
+    }
+    
+    if( rpcSlice->getPocResetIdc() ==  3 ) 
+    {
+      READ_FLAG( uiCode, "full_poc_reset_flag" ); rpcSlice->setFullPocResetFlag( uiCode == 1 );
+      READ_CODE( rpcSlice->getPocLsbValLen() , uiCode, "poc_lsb_val" ); rpcSlice->setPocLsbVal( uiCode );
+    }          
+
+    if( !rpcSlice->getPocMsbValRequiredFlag() &&  rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() )
+    {
+      READ_FLAG( uiCode, "poc_msb_val_present_flag" ); rpcSlice->setPocMsbValPresentFlag( uiCode == 1 );
+    }
+    
+    if( rpcSlice->getPocMsbValPresentFlag() )
+    {
+      READ_UVLC( uiCode, "poc_msb_val" ); rpcSlice->setPocMsbVal( uiCode );
+    }
+
+    while( ( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) < rpcSlice->getSliceSegmentHeaderExtensionLength() * 8 );
+    {
+     READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" );
+    }
+    assert( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) == rpcSlice->getSliceSegmentHeaderExtensionLength() * 8  ); 
+#else
+    READ_UVLC( uiCode, "slice_header_extension_length" );
+    for(Int i=0; i<uiCode; i++)
+    {
+      UInt ignore;
+      READ_CODE(8,ignore,"slice_header_extension_data_byte");
+    }
+  }
+#endif
+#endif
+
 
   m_pcBitstream->readByteAlignment();
Index: /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 854)
@@ -37,4 +37,5 @@
 
 #include "TDecCu.h"
+
 //! \ingroup TLibDecoder
 //! \{
@@ -638,5 +639,5 @@
   
   m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
-
+  
 #if H_MV_ENC_DEC_TRAC
 #if ENC_DEC_TRACE
@@ -927,5 +928,5 @@
   }
 #endif
-
+  
 #if H_3D && UPDATE_HM13
   Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
Index: /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecGop.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecGop.cpp	(revision 854)
@@ -43,4 +43,5 @@
 #include "libmd5/MD5.h"
 #include "TLibCommon/SEI.h"
+
 #include <time.h>
 
Index: /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 854)
@@ -51,7 +51,9 @@
   m_aaiCodedOffset         = new Int* [ MAX_NUM_LAYERS ];
   m_aaiCodedScale          = new Int* [ MAX_NUM_LAYERS ];
+#if !FIX_CAM_PARS_COLLECTOR
   m_aiViewId               = new Int  [ MAX_NUM_LAYERS ];
 
   m_bViewReceived          = new Bool [ MAX_NUM_LAYERS ];
+#endif
   for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ )
   {
@@ -63,4 +65,8 @@
   m_iLog2Precision   = LOG2_DISP_PREC_LUT;
   m_uiBitDepthForLUT = 8; // fixed
+#if FIX_CAM_PARS_COLLECTOR
+  m_receivedIdc = NULL; 
+  m_vps         = NULL; 
+#endif
 }
 
@@ -74,11 +80,84 @@
   delete [] m_aaiCodedOffset;
   delete [] m_aaiCodedScale;
+#if !FIX_CAM_PARS_COLLECTOR
   delete [] m_aiViewId;  
   delete [] m_bViewReceived;
+#endif
 
   xDeleteArray( m_adBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
   xDeleteArray( m_aiBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
-}
-
+#if FIX_CAM_PARS_COLLECTOR
+  xDeleteArray( m_receivedIdc, m_uiMaxViewIndex + 1 );
+#endif
+}
+
+
+#if FIX_CAM_PARS_COLLECTOR
+Void
+CamParsCollector::init( FILE* pCodedScaleOffsetFile, TComVPS* vps)
+{
+  assert( !isInitialized() ); // Only one initialization currently supported
+  m_bInitialized            = true;
+  m_vps                     = vps; 
+  m_bCamParsVaryOverTime    = false; 
+  m_pCodedScaleOffsetFile   = pCodedScaleOffsetFile;
+  m_lastPoc                 = -1;   
+  m_firstReceivedPoc        = -2; 
+
+  m_uiMaxViewIndex            = -1; 
+  for (Int i = 0; i <= vps->getMaxLayersMinus1(); i++)
+  {
+    Int curViewIdx = m_vps->getViewIndex( m_vps->getLayerIdInNuh( i )); 
+    m_bCamParsVaryOverTime = m_bCamParsVaryOverTime || vps->hasCamParInSliceHeader( curViewIdx );
+    m_uiMaxViewIndex = std::max( m_uiMaxViewIndex, curViewIdx  ) ; 
+  }
+
+  assert( m_receivedIdc == NULL ); 
+  m_receivedIdc = new Int*[ m_uiMaxViewIndex + 1]; 
+  for (Int i = 0; i <= m_uiMaxViewIndex; i++)
+  {
+    m_receivedIdc[i] = new Int[ m_uiMaxViewIndex + 1 ]; 
+  }
+
+  xResetReceivedIdc( true ); 
+
+  for (Int viewIndex = 0; viewIndex <= m_uiMaxViewIndex ; viewIndex++ )
+  {
+    if (m_vps->getCamParPresent( viewIndex ) )
+    {    
+      if( !m_vps->hasCamParInSliceHeader( viewIndex ) ) 
+      {
+        for (Int baseViewIndex = 0; baseViewIndex < viewIndex ; baseViewIndex++ )
+        { 
+          m_receivedIdc   [ baseViewIndex ][ viewIndex ] = -1; 
+          m_aaiCodedScale [ baseViewIndex ][ viewIndex ] = m_vps->getCodedScale    (viewIndex) [ baseViewIndex ];
+          m_aaiCodedOffset[ baseViewIndex ][ viewIndex ] = m_vps->getCodedOffset   (viewIndex) [ baseViewIndex ];
+
+          m_receivedIdc   [ viewIndex ][ baseViewIndex ] = -1; 
+          m_aaiCodedScale [ viewIndex ][ baseViewIndex ] = m_vps->getInvCodedScale (viewIndex) [ baseViewIndex ];
+          m_aaiCodedOffset[ viewIndex ][ baseViewIndex ] = m_vps->getInvCodedOffset(viewIndex) [ baseViewIndex ];
+          xInitLUTs( baseViewIndex, viewIndex, m_aaiCodedScale[ baseViewIndex ][ viewIndex ], m_aaiCodedOffset[ baseViewIndex ][ viewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
+          xInitLUTs( viewIndex, baseViewIndex, m_aaiCodedScale[ viewIndex ][ baseViewIndex ], m_aaiCodedOffset[ viewIndex ][ baseViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
+        }
+      }
+    }
+  }
+}
+
+Void
+CamParsCollector::xResetReceivedIdc( Bool overWriteFlag )
+{
+  for (Int i = 0; i <= m_uiMaxViewIndex; i++)
+  {  
+    for (Int j = 0; j <= m_uiMaxViewIndex; j++)
+    {
+      if ( overWriteFlag ||  ( m_receivedIdc[i][j] != -1 ) )
+      {
+        m_receivedIdc[i][j] = 0; 
+      }      
+    }
+  }
+}
+#else
 Void
 CamParsCollector::init( FILE* pCodedScaleOffsetFile )
@@ -92,4 +171,7 @@
   m_uiMaxViewIndex             = 0;
 }
+#endif
+
+
 
 Void
@@ -124,5 +206,9 @@
   CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
 {
+#if FIX_CAM_PARS_COLLECTOR
+  Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_vps->getCamParPrecision() + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
+#else
   Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
+#endif
   Int     iLog2DivChroma = iLog2DivLuma + 1;
 
@@ -166,4 +252,5 @@
 }
 
+#if !FIX_CAM_PARS_COLLECTOR
 Void
 CamParsCollector::setSlice( TComSlice* pcSlice )
@@ -284,4 +371,76 @@
 }
 
+#else
+Void
+CamParsCollector::setSlice( TComSlice* pcSlice )
+{
+  if( pcSlice == 0 )
+  {
+    xOutput( m_lastPoc );
+    return;
+  }
+
+  if ( pcSlice->getIsDepth())
+  {
+    return;
+  }
+
+  Int curPoc = pcSlice->getPOC();
+  if( m_firstReceivedPoc == -2 )
+  {
+    m_firstReceivedPoc = curPoc; 
+  }
+
+  Bool newPocFlag = ( m_lastPoc != curPoc );  
+
+  if ( newPocFlag )
+  {    
+    if( m_lastPoc != -1 )
+    {
+      xOutput( m_lastPoc );
+    }
+
+    xResetReceivedIdc( false ); 
+    m_lastPoc = pcSlice->getPOC();
+  }
+
+  UInt uiViewIndex          = pcSlice->getViewIndex();  
+  if( m_vps->getCamParPresent( uiViewIndex ) )
+  {    
+    if( m_vps->hasCamParInSliceHeader( uiViewIndex ) ) // check consistency of slice parameters here
+    {   
+      for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ )
+      {        
+        if ( m_receivedIdc[ uiViewIndex ][ uiBaseViewIndex ] != 0 )
+        {      
+          AOF( m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedScale () [ uiBaseViewIndex ] );
+          AOF( m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedOffset() [ uiBaseViewIndex ] );
+        }
+        else
+        {          
+          m_receivedIdc   [ uiViewIndex ][ uiBaseViewIndex ]  = 1; 
+          m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ]  = pcSlice->getInvCodedScale () [ uiBaseViewIndex ];
+          m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ]  = pcSlice->getInvCodedOffset() [ uiBaseViewIndex ];
+          xInitLUTs( uiViewIndex, uiBaseViewIndex, m_aaiCodedScale[ uiViewIndex ][ uiBaseViewIndex ], m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
+        }
+        if ( m_receivedIdc[ uiBaseViewIndex ][ uiViewIndex ] != 0 )
+        {      
+          AOF( m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedScale    () [ uiBaseViewIndex ] );
+          AOF( m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedOffset   () [ uiBaseViewIndex ] );
+        }
+        else
+        {        
+          m_receivedIdc   [ uiBaseViewIndex ][ uiViewIndex ]  = 1; 
+          m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ]  = pcSlice->getCodedScale    () [ uiBaseViewIndex ];
+          m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ]  = pcSlice->getCodedOffset   () [ uiBaseViewIndex ];
+          xInitLUTs( uiBaseViewIndex, uiViewIndex, m_aaiCodedScale[ uiBaseViewIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
+        }
+      }
+    }
+  }
+}
+#endif
+
+
 #if H_3D_IV_MERGE
 Void
@@ -295,4 +454,5 @@
 #endif
 
+#if !FIX_CAM_PARS_COLLECTOR
 Bool
 CamParsCollector::xIsComplete()
@@ -307,4 +467,5 @@
   return true;
 }
+#endif
 
 Void
@@ -313,11 +474,21 @@
   if( m_pCodedScaleOffsetFile )
   {
+#if FIX_CAM_PARS_COLLECTOR
+    if( iPOC == m_firstReceivedPoc )
+#else
     if( iPOC == 0 )
+#endif
     {
       fprintf( m_pCodedScaleOffsetFile, "#  ViewIndex       ViewId\n" );
       fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" );
+#if FIX_CAM_PARS_COLLECTOR
       for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ )
       {
+        fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewIndex, m_vps->getViewIdVal( uiViewIndex ) );
+#else        
+      for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ )
+      {
         fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewIndex, m_aiViewId[ uiViewIndex ] );
+#endif
       }
       fprintf( m_pCodedScaleOffsetFile, "\n\n");
@@ -325,5 +496,9 @@
       fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" );
     }
+#if FIX_CAM_PARS_COLLECTOR
+    if( iPOC == m_firstReceivedPoc || m_bCamParsVaryOverTime  )
+#else
     if( iPOC == 0 || m_bCamParsVaryOverTime )
+#endif
     {
       Int iS = iPOC;
@@ -335,6 +510,15 @@
           if( uiViewIndex != uiBaseIndex )
           {
+#if FIX_CAM_PARS_COLLECTOR
+            if ( m_receivedIdc[uiBaseIndex][uiViewIndex] != 0 )
+            {            
+              fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
+                iS, iE, uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_vps->getCamParPrecision() );
+            }            
+#else
             fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
               iS, iE, uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_uiCamParsCodedPrecision );
+#endif
+
           }
         }
@@ -457,8 +641,30 @@
   for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 
   {
+#if H_MV_HLS_7_SPS_P0155_16_32
+    numReorderPics[temporalLayer] = ( getLayerId() == 0 ) ? pcSlice->getSPS()->getNumReorderPics(temporalLayer) : pcSlice->getVPS()->getNumReorderPics(temporalLayer);
+#else
     numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
-  }
-
+#endif
+  }
+#if H_MV_HLS_7_SPS_P0155_16_32
+  if ( getLayerId() == 0 )
+  {  
+    m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());
+  }
+  else
+  {
+    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer());
+#if H_MV_HLS7_GEN
+    TComVPS* vps         = pcSlice->getVPS();
+    TComDpbSize* dpbSize = vps->getDpbSize(); 
+    Int lsIdx            = vps->getLayerSetIdxForOutputLayerSet( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec?
+    Int layerIdx         = vps->getIdxInLayerSet     ( lsIdx, getLayerId() ); 
+    Int subDpbIdx        = dpbSize->getSubDpbAssigned( lsIdx, layerIdx ); 
+    m_iMaxRefPicNum      = dpbSize->getMaxVpsDecPicBufferingMinus1(getTargetOutputLayerSetIdx(), subDpbIdx , vps->getSubLayersVpsMaxMinus1( vps->getLayerIdInVps( getLayerId() ) ) + 1 ) + 1 ;  
+#endif    
+  }
+#else
   m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
+#endif
   if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
   {
Index: /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.h	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.h	(revision 854)
@@ -71,5 +71,10 @@
   ~CamParsCollector ();
 
+#if FIX_CAM_PARS_COLLECTOR
+  Void  init        ( FILE* pCodedScaleOffsetFile, TComVPS* vps );
+#else
   Void  init        ( FILE* pCodedScaleOffsetFile );
+#endif
+
   Void  uninit      ();
   Void  setSlice    ( TComSlice* pcSlice );
@@ -85,9 +90,13 @@
   Int getCodedScale( Int iBaseView, Int iCureView){ return m_aaiCodedScale[ iBaseView ][ iCureView ];}
   Int getCodedOffset( Int iBaseView, Int iCureView){ return m_aaiCodedOffset[ iBaseView ][ iCureView ];}
-  UInt getCamParsCodedPrecision(){ return m_uiCamParsCodedPrecision; }
+  UInt getCamParsCodedPrecision(){ return m_vps->getCamParPrecision(); }
 #endif
 
 private:
+#if FIX_CAM_PARS_COLLECTOR
+  Void xResetReceivedIdc( Bool overWriteFlag ); 
+#else
   Bool  xIsComplete ();
+#endif
   Void  xOutput     ( Int iPOC );
 
@@ -98,12 +107,26 @@
   Int**   m_aaiCodedOffset;
   Int**   m_aaiCodedScale;
+  
+#if !FIX_CAM_PARS_COLLECTOR
   Int*    m_aiViewId;  
-
+#else
+  TComVPS* m_vps; 
+  Int**    m_receivedIdc; 
+  Int      m_uiMaxViewIndex; 
+  Int      m_lastPoc; 
+  Int      m_firstReceivedPoc; 
+#endif
+
+  
+#if !FIX_CAM_PARS_COLLECTOR
   Bool*   m_bViewReceived;
   UInt    m_uiCamParsCodedPrecision;
+#endif
   Bool    m_bCamParsVaryOverTime;
+#if !FIX_CAM_PARS_COLLECTOR
   Int     m_iLastViewIndex;
   Int     m_iLastPOC;
   UInt    m_uiMaxViewIndex;
+#endif
 
 
Index: /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 854)
@@ -279,4 +279,36 @@
   WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
 
+#if H_MV_HLS_7_GEN_P0166_PPS_EXTENSION
+#if !H_MV
+  WRITE_FLAG( 0, "pps_extension_flag" );
+#else
+  WRITE_FLAG( 1, "pps_extension_flag" );
+
+  for ( Int i = 0; i < PPS_EX_T_MAX_NUM; i++ )
+  {
+    WRITE_FLAG( pcPPS->getPpsExtensionTypeFlag( i ) ? 1 : 0 , "pps_extension_type_flag" );
+#if H_3D
+    assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_3D || i == PPS_EX_T_ESC ); 
+#else
+    assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_ESC ); 
+#endif
+  }
+
+  if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_MV ) )
+  {
+#if H_MV_HLS7_GEN
+    WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag( ) ? 1 : 0 , "poc_reset_info_present_flag" );
+#endif
+  }
+
+#if H_3D
+  if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_3D ) ) // This probably needs to be aligned with Rext and SHVC
+  {
+    codePPSExtension( pcPPS ); 
+  }
+#endif
+
+#endif
+#else
 #if !H_3D
   WRITE_FLAG( 0, "pps_extension_flag" );
@@ -285,4 +317,5 @@
   codePPSExtension( pcPPS ); 
   WRITE_FLAG( 0, "pps_extension2_flag" );
+#endif
 #endif
 }
@@ -433,5 +466,5 @@
             else
             {
-              WRITE_CODE(uiNumDepthValues_coded, 8, "num_depth_values_in_dlt[layerId]");    // num_entry
+              WRITE_CODE(uiNumDepthValues_coded, 8, "num_depth_values_in_dlt[i]");    // num_entry
 
 #if !H_3D_DELTA_DLT
@@ -699,5 +732,8 @@
 #endif
   WRITE_UVLC( pcSPS->getBitsForPOC()-4,                 "log2_max_pic_order_cnt_lsb_minus4" );
-
+#if H_MV_HLS_7_SPS_P0155_16_32
+  if ( pcSPS->getLayerId() == 0 ) 
+  {  
+#endif
   const Bool subLayerOrderingInfoPresentFlag = 1;
   WRITE_FLAG(subLayerOrderingInfoPresentFlag,       "sps_sub_layer_ordering_info_present_flag");
@@ -712,4 +748,8 @@
     }
   }
+#if H_MV_HLS_7_SPS_P0155_16_32
+  }
+#endif
+
   assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() );
   
@@ -838,4 +878,7 @@
     WRITE_SVLC( pcSPS->getScaledRefLayerRightOffset( j ), "scaled_ref_layer_right_offset" );
     WRITE_SVLC( pcSPS->getScaledRefLayerBottomOffset( j ), "scaled_ref_layer_bottom_offset" );
+#if H_MV_HLS_7_RESERVED_FLAGS
+    WRITE_FLAG( 0, "sps_multilayer_ext_reserved_zero_flag[ j ]" );
+#endif
   }
 }
@@ -868,5 +911,5 @@
   WRITE_FLAG( pcVPS->getTemporalNestingFlag(),                "vps_temporal_id_nesting_flag" );
   assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
-#if H_MV
+#if H_MV && !H_MV_HLS7_GEN
   WRITE_CODE( 0xffff,                              16,        "vps_extension_offset" );
 #else
@@ -970,4 +1013,5 @@
 {
   WRITE_FLAG( pcVPS->getAvcBaseLayerFlag() ? 1 : 0,          "avc_base_layer_flag" );
+#if !H_MV_HLS7_GEN
   WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" );
   if ( pcVPS->getVpsVuiPresentFlag() )
@@ -975,4 +1019,6 @@
   WRITE_CODE( pcVPS->getVpsVuiOffset( ), 16,                 "vps_vui_offset" );  // TBD
   }
+#endif
+
   WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0,             "splitting_flag" );
   
@@ -1049,5 +1095,5 @@
   if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() )
   {
-    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
     {
       WRITE_CODE( pcVPS->getSubLayersVpsMaxMinus1( i ), 3, "sub_layers_vps_max_minus1" );
@@ -1057,5 +1103,5 @@
   else
   {
-    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
     {
       assert( pcVPS->getSubLayersVpsMaxMinus1( i ) + 1 == pcVPS->getMaxTLayers( ) );    
@@ -1079,10 +1125,18 @@
 
   WRITE_FLAG( pcVPS->getAllRefLayersActiveFlag( ) ? 1 : 0 , "all_ref_layers_active_flag" );
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   WRITE_CODE( pcVPS->getVpsNumberLayerSetsMinus1( )    , 10,    "vps_number_layer_sets_minus1"      );
+#endif
+
+#if !H_MV_HLS7_GEN
   WRITE_CODE( pcVPS->getVpsNumProfileTierLevelMinus1( ), 6,     "vps_num_profile_tier_level_minus1" );
+#else
+  WRITE_UVLC( pcVPS->getVpsNumProfileTierLevelMinus1( ), "vps_num_profile_tier_level_minus1" );
+#endif
 
   for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ )
   {
     WRITE_FLAG( pcVPS->getVpsProfilePresentFlag( i ) ? 1 : 0, "vps_profile_present_flag[i]" );
+#if !H_MV_HLS_7_VPS_P0048_14
     if( !pcVPS->getVpsProfilePresentFlag( i ) )
     {    
@@ -1090,7 +1144,21 @@
       pcVPS->checkProfileRefMinus1( i );      
     }
+#endif
     codePTL( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers() - 1 );
   }
 
+
+
+
+
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  WRITE_UVLC( pcVPS->getNumAddOutputLayerSets( ), "num_add_output_layer_sets" );
+
+  if( pcVPS->getNumOutputLayerSets() > 1)
+  {
+    WRITE_CODE( pcVPS->getDefaultTargetOutputLayerIdc( ), 2, "default_target_output_layer_idc" );
+  }  
+#else
   Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1; 
 
@@ -1108,12 +1176,40 @@
     pcVPS->checkDefaultOneTargetOutputLayerIdc(); 
   }  
+#endif
 
   assert( pcVPS->getOutputLayerFlag(0, 0) == pcVPS->inferOutputLayerFlag( 0, 0 )); 
   assert( pcVPS->getOutputLayerSetIdxMinus1( 0 ) == -1 ); 
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+
+  for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ )
+  {
+    if( i > pcVPS->getVpsNumLayerSetsMinus1( ) )    
+#else
   for( Int i = 1; i < numOutputLayerSets; i++ )
   {
     if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) )
+#endif
     {      
       WRITE_UVLC( pcVPS->getOutputLayerSetIdxMinus1( i ),      "output_layer_set_idx_minus1[i]" );
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    }
+
+    if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultTargetOutputLayerIdc() == 2 )
+    {       
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->getLayerSetIdxForOutputLayerSet( i ) ); j++ )
+      {
+        WRITE_FLAG( pcVPS->getOutputLayerFlag( i, j) ? 1 : 0, "output_layer_flag" );
+      }              
+    }
+    else
+    {
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->getLayerSetIdxForOutputLayerSet( i ) ) - 1; j++ )
+      {              
+        assert( pcVPS->getOutputLayerFlag( i , j ) == pcVPS->inferOutputLayerFlag( i, j )); 
+      }
+    }        
+
+#else
       for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1 ; j++ )
       {
@@ -1129,9 +1225,16 @@
       }
     }
-
+#endif
     if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
     {      
       WRITE_CODE( pcVPS->getProfileLevelTierIdx( i ), pcVPS->getProfileLevelTierIdxLen() ,"profile_level_tier_idx[ i ]" );   
     }
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 )
+    {
+      WRITE_FLAG( pcVPS->getAltOutputLayerFlag( i ) ? 1 : 0 , "alt_output_layer_flag[ i ]" );
+    }
+  }
+#else
   }
 
@@ -1140,9 +1243,18 @@
     WRITE_FLAG( pcVPS->getAltOutputLayerFlag( ) ? 1 : 0 , "alt_output_layer_flag" );
   }
+#endif
+
+
+
+
 
   WRITE_FLAG( pcVPS->getRepFormatIdxPresentFlag( ) ? 1 : 0 , "rep_format_idx_present_flag" );
   if ( pcVPS->getRepFormatIdxPresentFlag() )
   {
+#if H_MV_HLS7_GEN
+    WRITE_UVLC( pcVPS->getVpsNumRepFormatsMinus1( ), "vps_num_rep_formats_minus1" );
+#else
     WRITE_CODE( pcVPS->getVpsNumRepFormatsMinus1( ), 4, "vps_num_rep_formats_minus1" );
+#endif
   }
 
@@ -1166,4 +1278,7 @@
 
   WRITE_FLAG( pcVPS->getMaxOneActiveRefLayerFlag( ) ? 1 : 0, "max_one_active_ref_layer_flag" );
+#if H_MV_HLS7_GEN
+  WRITE_FLAG( pcVPS->getVpsPocLsbAlignedFlag( ) ? 1 : 0 , "vps_poc_lsb_aligned_flag" );
+#endif
   for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1173,4 +1288,7 @@
     }
   }
+#if H_MV_HLS_7_RESERVED_FLAGS
+  WRITE_FLAG( 0, "vps_reserved_zero_flag" );
+#endif
   codeDpbSize( pcVPS ); 
 
@@ -1202,6 +1320,11 @@
     }
   }  
+#if H_MV_HLS7_GEN
+  WRITE_UVLC( 0, "vps_non_vui_extension_length" );
+  WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" );
+#endif
+#if !H_MV_HLS_7_RESERVED_FLAGS  
     WRITE_FLAG ( 0,                                      "vps_shvc_reserved_zero_flag" ); 
-
+#endif
     if( pcVPS->getVpsVuiPresentFlag() )
     {
@@ -1209,4 +1332,11 @@
       codeVPSVUI( pcVPS ); 
     }     
+#if H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG
+    {
+      TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
+      assert( pcVPSVUI ); 
+      pcVPSVUI->inferVpsVui( true ); 
+    }
+#endif
 }
 Void TEncCavlc::codeVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo )
@@ -1228,6 +1358,9 @@
   {  
     WRITE_FLAG( dpbSize->getSubLayerFlagInfoPresentFlag( i ) ? 1 : 0 , "sub_layer_flag_info_present_flag" );
-
+#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
     {  
       if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
@@ -1237,9 +1370,22 @@
       if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
       {  
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+        for( Int k = 0; k < vps->getNumSubDpbs( vps->getLayerSetIdxForOutputLayerSet( i )); k++ )   
+#else
         for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   // Preliminary fix does not match with spec
+#endif
         {
           WRITE_UVLC( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ), "max_vps_dec_pic_buffering_minus1" );
         }
         WRITE_UVLC( dpbSize->getMaxVpsNumReorderPics( i, j ), "max_vps_num_reorder_pics" );
+#if H_MV_HLS7_GEN
+        if( vps->getNumSubDpbs( vps->getLayerSetIdxForOutputLayerSet( i ) ) != vps->getNumLayersInIdList( vps->getLayerSetIdxForOutputLayerSet( i ) ) ) 
+        {
+          for( Int k = 0; k < vps->getNumLayersInIdList( vps->getLayerSetIdxForOutputLayerSet( i ) ); k++ )
+          {
+            WRITE_UVLC( dpbSize->getMaxVpsLayerDecPicBuffMinus1( i, k, j ), "max_vps_layer_dec_pic_buff_minus1" );
+          }
+        }
+#endif
         WRITE_UVLC( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ), "max_vps_latency_increase_plus1" );
       }
@@ -1248,5 +1394,9 @@
         if ( j > 0 )
         {
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+          for( Int k = 0; k < vps->getNumSubDpbs( vps->getLayerSetIdxForOutputLayerSet( i ) ); k++ )   
+#else
           for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+#endif
           {
             assert( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) == dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );
@@ -1300,10 +1450,19 @@
     WRITE_FLAG( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ? 1 : 0 , "cross_layer_irap_aligned_flag" );
   }
-
+#if H_MV_HLS_7_MISC_P0068_21
+  if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) )
+  {
+    WRITE_FLAG( pcVPSVUI->getAllLayersIdrAlignedFlag( ) ? 1 : 0 , "all_layers_idr_aligned_flag" );
+  }
+#endif
   WRITE_FLAG( pcVPSVUI->getBitRatePresentVpsFlag( ) ? 1 : 0 , "bit_rate_present_vps_flag" );
   WRITE_FLAG( pcVPSVUI->getPicRatePresentVpsFlag( ) ? 1 : 0 , "pic_rate_present_vps_flag" );
   if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
   {
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    for( Int i = 0; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
+#else
     for( Int i = 0; i  <=  pcVPS->getVpsNumberLayerSetsMinus1(); i++ )
+#endif
     {
       for( Int j = 0; j  <=  pcVPS->getMaxTLayers(); j++ ) 
@@ -1331,4 +1490,39 @@
   }
 
+#if H_MV_HLS_7_VPS_P0076_15
+  WRITE_FLAG( pcVPSVUI->getVideoSignalInfoIdxPresentFlag( ) ? 1 : 0 , "video_signal_info_idx_present_flag" );
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
+  {
+    WRITE_CODE( pcVPSVUI->getVpsNumVideoSignalInfoMinus1( ), 4, "vps_num_video_signal_info_minus1" );
+  }
+  else
+  {
+    pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() ); 
+  }
+
+  for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ )
+  {
+    assert( pcVPSVUI->getVideoSignalInfo( i ) != NULL ); 
+    TComVideoSignalInfo* curVideoSignalInfo = pcVPSVUI->getVideoSignalInfo( i ); 
+    codeVideoSignalInfo( curVideoSignalInfo );     
+
+  }
+
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      WRITE_CODE( pcVPSVUI->getVpsVideoSignalInfoIdx( i ), 4, "vps_video_signal_info_idx" );
+      assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i ) >= 0 && pcVPSVUI->getVpsVideoSignalInfoIdx( i ) <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1() );
+    }
+  }
+  else
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i  ) == ( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ? 0 : i ) ); 
+    }
+  }
+#endif
   WRITE_FLAG( pcVPSVUI->getTilesNotInUseFlag( ) ? 1 : 0 , "tiles_not_in_use_flag" );
   if( !pcVPSVUI->getTilesNotInUseFlag() ) 
@@ -1365,4 +1559,7 @@
     }
   }
+#if H_MV_HLS_7_RESERVED_FLAGS
+  WRITE_CODE( 0, 3, "vps_vui_reserved_zero_3bits" );
+#endif
   WRITE_FLAG( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ? 1 : 0 , "ilp_restricted_ref_layers_flag" );
 
@@ -1385,4 +1582,6 @@
     }
   }
+
+#if !H_MV_HLS_7_VPS_P0076_15
   WRITE_FLAG( pcVPSVUI->getVideoSignalInfoIdxPresentFlag( ) ? 1 : 0 , "video_signal_info_idx_present_flag" );
   if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
@@ -1417,4 +1616,5 @@
     }
   }
+#endif
   WRITE_FLAG( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ? 1 : 0 , "vps_vui_bsp_hrd_present_flag" );
   if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
@@ -1422,5 +1622,15 @@
     codeVpsVuiBspHrdParameters( pcVPS ); 
   }
-}
+#if H_MV_HLS_7_MISC_P0182_13
+  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) 
+    {
+      WRITE_FLAG( pcVPSVUI->getBaseLayerParameterSetCompatibilityFlag( i ) ? 1 : 0 , "base_layer_parameter_set_compatibility_flag" );
+    }
+}
+#endif
+}
+
 Void TEncCavlc::codeVpsVuiBspHrdParameters( TComVPS* pcVPS )
 {
@@ -1638,5 +1848,5 @@
     }
     pcSlice->checkCrossLayerBlaFlag( ); 
-
+#if !H_MV_HLS7_GEN
     if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
     {
@@ -1644,4 +1854,5 @@
       WRITE_FLAG( pcSlice->getPocResetFlag( ) ? 1 : 0 , "poc_reset_flag" );
     }
+#endif
 
 
@@ -2023,4 +2234,5 @@
 #endif
 
+#if !H_MV_HLS7_GEN
 #if PPS_FIX_DEPTH
   if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag() || pcSlice->getIsDepth() )
@@ -2031,4 +2243,52 @@
     WRITE_UVLC(0,"slice_header_extension_length");
   }
+#endif
+
+#if H_MV_HLS7_GEN
+#if !H_MV
+  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
+  {
+    WRITE_UVLC(0,"slice_header_extension_length");
+  }
+#else
+  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
+  {
+    WRITE_UVLC( pcSlice->getSliceSegmentHeaderExtensionLength( ), "slice_segment_header_extension_length" );
+    UInt posFollSliceSegHeaderExtLen = m_pcBitIf->getNumberOfWrittenBits();
+    if( pcSlice->getPPS()->getPocResetInfoPresentFlag() )
+    {
+      WRITE_CODE( pcSlice->getPocResetIdc( ), 2, "poc_reset_idc" );
+    }
+
+    if( pcSlice->getPocResetIdc() !=  0 )
+    {
+      WRITE_CODE( pcSlice->getPocResetPeriodId( ), 6, "poc_reset_period_id" );
+    }
+    
+    if( pcSlice->getPocResetIdc() ==  3 ) 
+    {
+      WRITE_FLAG( pcSlice->getFullPocResetFlag( ) ? 1 : 0 , "full_poc_reset_flag" );
+      WRITE_CODE( pcSlice->getPocLsbVal( ), getPocLsbValLen ), "poc_lsb_val" );
+    }              
+    
+    if( !pcSlice->getPocMsbValRequiredFlag() &&  pcSlice->getVPS()->getVpsPocLsbAlignedFlag() )
+    {
+      WRITE_FLAG( pcSlice->getPocMsbValPresentFlag( ) ? 1 : 0 , "poc_msb_val_present_flag" );
+    }
+    
+    if( pcSlice->getPocMsbValPresentFlag() )
+    {
+      WRITE_UVLC( pcSlice->getPocMsbVal( ), "poc_msb_val" );
+    }
+
+    while( ( m_pcBitIf->getNumberOfWrittenBits() - posFollSliceSegHeaderExtLen ) < pcSlice->getSliceSegmentHeaderExtensionLength() * 8 ); 
+    {
+      WRITE_FLAG( 0, "slice_segment_header_extension_data_bit" );
+    }
+
+    assert( m_pcBitIf->getNumberOfWrittenBits() - posFollSliceSegHeaderExtLen ) == pcSlice->getSliceSegmentHeaderExtensionLength() * 8  ); 
+#endif 
+
+#endif
 }
 
Index: /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 854)
@@ -40,4 +40,5 @@
 #include "TEncCu.h"
 #include "TEncAnalyze.h"
+
 #include <cmath>
 #include <algorithm>
@@ -421,5 +422,5 @@
   // get Original YUV data from picture
   m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
-  
+
 #if H_3D_QTLPC  
   Bool    bTrySplit     = true;
@@ -1198,12 +1199,12 @@
         if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
         {
-          if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer
-          {
-            m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
-          }
-          else
-          {
-            m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);
-          }
+            if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer
+            {
+              m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
+            }
+            else
+            {
+              m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);
+            }
 
 #if AMP_ENC_SPEEDUP
@@ -1236,6 +1237,6 @@
 
         rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
-        rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
-      }
+          rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
+        }
 #if H_3D_VSO // M10
       if ( m_pcRdCost->getUseVSO() )
@@ -1243,5 +1244,5 @@
       else
 #endif
-        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+      rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
 
       if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() && rpcTempCU->getSlice()->getPPS()->getUseDQP())
@@ -1251,5 +1252,5 @@
         {
           if( ( pcPic->getCU( rpcTempCU->getAddr() )->getSliceSegmentStartCU(uiBlkIdx+rpcTempCU->getZorderIdxInCU()) == rpcTempCU->getSlice()->getSliceSegmentCurStartCUAddr() ) && 
-            ( rpcTempCU->getCbf( uiBlkIdx, TEXT_LUMA ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_U ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_V ) ) )
+              ( rpcTempCU->getCbf( uiBlkIdx, TEXT_LUMA ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_U ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_V ) ) )
           {
             hasResidual = true;
@@ -1273,5 +1274,5 @@
           m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false );
           rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits
-          rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
+            rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
 #if H_3D_VSO // M11
           if ( m_pcRdCost->getUseLambdaScaleVSO())          
@@ -1279,5 +1280,5 @@
           else
 #endif
-            rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+          rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
 #endif
 
@@ -1292,9 +1293,9 @@
       }
 
-      m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
+        m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
       Bool isEndOfSlice        = rpcBestCU->getSlice()->getSliceMode()==FIXED_NUMBER_OF_BYTES
-        && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3);
+                                 && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3);
       Bool isEndOfSliceSegment = rpcBestCU->getSlice()->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES
-        && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceSegmentArgument()<<3);
+                                 && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceSegmentArgument()<<3);
       if(isEndOfSlice||isEndOfSliceSegment)
       {
@@ -1303,5 +1304,5 @@
       xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth);                                  // RD compare current larger prediction
     }                                                                                  // with sub partitioned prediction.
-  }
+    }
 
 #if H_3D_VSO // M12 
@@ -1786,7 +1787,7 @@
 #endif
 #if H_3D_ARP
-  for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
-#else
-  for( UInt ui = 0; ui < numValidMergeCand; ++ui )
+for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
+#else
+for( UInt ui = 0; ui < numValidMergeCand; ++ui )
 #endif
   {
@@ -1861,8 +1862,8 @@
 #endif
 
-    for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
-    {
-      for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
-      {      
+  for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
+  {
+    for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
+    {      
 #if H_3D_IC
         if( rpcTempCU->getSlice()->getApplyIC() && rpcTempCU->getSlice()->getIcSkipParseFlag() )
@@ -1876,167 +1877,137 @@
         if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
         {
-          if( !(bestIsSkip && uiNoResidual == 0) )
+        if( !(bestIsSkip && uiNoResidual == 0) )
+        {
+          // set MC parameters
+          rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); // interprets depth relative to LCU level
+          rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag,     0, uhDepth );
+          rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
+#if H_3D_IC
+          rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
+#endif
+#if H_3D_ARP
+          rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+#endif
+          rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level
+          rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level
+#if H_3D_VSP
+          rpcTempCU->setVSPFlagSubParts( vspFlag[uiMergeCand], 0, 0, uhDepth );
+          rpcTempCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, 0, 0, uhDepth );
+#endif
+#if MTK_DDD_G0063
+          if( rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewIndex() != 0 && iDDDCand == uiMergeCand )
           {
-            // set MC parameters
-            rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); // interprets depth relative to LCU level
-            rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag,     0, uhDepth );
-            rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
-#if H_3D_IC
-            rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
-#endif
-#if H_3D_ARP
-            rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
-#endif
-            rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level
-            rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level
-#if H_3D_VSP
-            rpcTempCU->setVSPFlagSubParts( vspFlag[uiMergeCand], 0, 0, uhDepth );
-            rpcTempCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, 0, 0, uhDepth );
-#endif
-#if MTK_DDD_G0063
-            if( rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewIndex() != 0 && iDDDCand == uiMergeCand )
-            {
               rpcTempCU->setUseDDD( true, 0, 0, uhDepth );
               rpcTempCU->setDDDepthSubParts( ucDDDepth, 0, 0, uhDepth );
+          }
+          else
+          {
+              rpcTempCU->setUseDDD( false, 0, 0, uhDepth );
+          }
+#endif
+#if H_3D_SPIVMP
+          rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
+          if (bSPIVMPFlag[uiMergeCand])
+          {
+            UInt uiSPAddr;
+            Int iWidth = rpcTempCU->getWidth(0);
+            Int iHeight = rpcTempCU->getHeight(0);
+            Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+            rpcTempCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+            for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
+            {
+              rpcTempCU->getSPAbsPartIdx(0, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
+              rpcTempCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
+              rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
+              rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
+            }
+          }
+          else
+#endif
+#if NTT_STORE_SPDV_VSP_G0148
+            {
+          if ( vspFlag[uiMergeCand] )
+          {
+            UInt partAddr;
+            Int vspSize;
+            Int width, height;
+            rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height );
+            if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
+            {
+              rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
+              rpcTempCU->setVSPFlag( partAddr, vspSize );
             }
             else
             {
-              rpcTempCU->setUseDDD( false, 0, 0, uhDepth );
+              rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
             }
-#endif
-#if H_3D_SPIVMP
-            rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
-            if (bSPIVMPFlag[uiMergeCand])
+            if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
             {
-              UInt uiSPAddr;
-              Int iWidth = rpcTempCU->getWidth(0);
-              Int iHeight = rpcTempCU->getHeight(0);
-              Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
-              rpcTempCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
-              for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
-              {
-                rpcTempCU->getSPAbsPartIdx(0, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
-                rpcTempCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
-                rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
-                rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
-              }
+              rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_1 , cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
+              rpcTempCU->setVSPFlag( partAddr, vspSize );
             }
             else
-#endif
+            {
+              rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+            }
+            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
+          }
+          else
+          {
+#endif
+            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
+            rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+            rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
 #if NTT_STORE_SPDV_VSP_G0148
+          }
+        }
+#endif
+       // do MC
+       m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+       // estimate residual and encode everything
+#if H_3D_VSO //M2
+       if( m_pcRdCost->getUseRenModel() )
+       { //Reset
+         UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
+         UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
+         Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
+         UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
+         m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+       }
+#endif
+       m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
+         m_ppcOrigYuv    [uhDepth],
+         m_ppcPredYuvTemp[uhDepth],
+         m_ppcResiYuvTemp[uhDepth],
+         m_ppcResiYuvBest[uhDepth],
+         m_ppcRecoYuvTemp[uhDepth],
+         (uiNoResidual? true:false));
+
+
+          if ( uiNoResidual == 0 && rpcTempCU->getQtRootCbf(0) == 0 )
+         {
+            // If no residual when allowing for one, then set mark to not try case where residual is forced to 0
+           mergeCandBuffer[uiMergeCand] = 1;
+         }
+
+          rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth );
+#if NTT_STORE_SPDV_VSP_G0148 // possible bug fix
+          if( rpcTempCU->getSkipFlag(0) )
+          {
+            rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
+          }
+#endif
+#if H_3D_INTER_SDC
+          TComDataCU *rpcTempCUPre = rpcTempCU;
+#endif
+          Int orgQP = rpcTempCU->getQP( 0 );
+          xCheckDQP( rpcTempCU );
+          xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
+#if H_3D_INTER_SDC
+          if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && !uiNoResidual )
+          {
+#if SEC_INTER_SDC_G0101
+            for( Int uiOffest = -2 ; uiOffest <= 2 ; uiOffest++ )
             {
-              if ( vspFlag[uiMergeCand] )
-              {
-                UInt partAddr;
-                Int vspSize;
-                Int width, height;
-                rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height );
-                if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
-                {
-                  rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
-                  rpcTempCU->setVSPFlag( partAddr, vspSize );
-                }
-                else
-                {
-                  rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-                }
-                if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
-                {
-                  rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_1 , cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
-                  rpcTempCU->setVSPFlag( partAddr, vspSize );
-                }
-                else
-                {
-                  rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-                }
-                rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
-              }
-              else
-              {
-#endif
-                rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
-                rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-                rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-#if NTT_STORE_SPDV_VSP_G0148
-              }
-            }
-#endif
-            // do MC
-            m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
-            // estimate residual and encode everything
-#if H_3D_VSO //M2
-            if( m_pcRdCost->getUseRenModel() )
-            { //Reset
-              UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
-              UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
-              Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
-              UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
-              m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-            }
-#endif
-            m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
-              m_ppcOrigYuv    [uhDepth],
-              m_ppcPredYuvTemp[uhDepth],
-              m_ppcResiYuvTemp[uhDepth],
-              m_ppcResiYuvBest[uhDepth],
-              m_ppcRecoYuvTemp[uhDepth],
-              (uiNoResidual? true:false));
-
-
-            if ( uiNoResidual == 0 && rpcTempCU->getQtRootCbf(0) == 0 )
-            {
-              // If no residual when allowing for one, then set mark to not try case where residual is forced to 0
-              mergeCandBuffer[uiMergeCand] = 1;
-            }
-
-            rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth );
-#if NTT_STORE_SPDV_VSP_G0148 // possible bug fix
-            if( rpcTempCU->getSkipFlag(0) )
-            {
-              rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
-            }
-#endif
-#if H_3D_INTER_SDC
-            TComDataCU *rpcTempCUPre = rpcTempCU;
-#endif
-            Int orgQP = rpcTempCU->getQP( 0 );
-            xCheckDQP( rpcTempCU );
-            xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
-#if H_3D_INTER_SDC
-            if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && !uiNoResidual )
-            {
-#if SEC_INTER_SDC_G0101
-              for( Int uiOffest = -2 ; uiOffest <= 2 ; uiOffest++ )
-              {
-                if( rpcTempCU != rpcTempCUPre )
-                {
-                  rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag  );
-                  rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
-                }
-                rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
-                rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
-                rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );
-#if H_3D_VSO //M2
-                if( m_pcRdCost->getUseRenModel() )
-                { //Reset
-                  UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
-                  UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
-                  Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
-                  UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
-                  m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-                }
-#endif
-                m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU, 
-                  m_ppcOrigYuv[uhDepth], 
-                  ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth], 
-                  m_ppcResiYuvTemp[uhDepth], 
-                  m_ppcRecoYuvTemp[uhDepth],
-                  uiOffest,
-                  uhDepth );
-
-                xCheckDQP( rpcTempCU );
-                xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
-              }
-#else
               if( rpcTempCU != rpcTempCUPre )
               {
@@ -2061,69 +2032,99 @@
                 ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth], 
                 m_ppcResiYuvTemp[uhDepth], 
-                m_ppcRecoYuvTemp[uhDepth], 
+                m_ppcRecoYuvTemp[uhDepth],
+                uiOffest,
                 uhDepth );
 
               xCheckDQP( rpcTempCU );
               xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
-#endif
             }
-#endif
-            rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag );
-
-            if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
+#else
+            if( rpcTempCU != rpcTempCUPre )
             {
+              rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag  );
+              rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
+            }
+            rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
+            rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
+            rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );
+#if H_3D_VSO //M2
+            if( m_pcRdCost->getUseRenModel() )
+            { //Reset
+              UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
+              UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
+              Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
+              UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
+              m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+            }
+#endif
+            m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU, 
+              m_ppcOrigYuv[uhDepth], 
+              ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth], 
+              m_ppcResiYuvTemp[uhDepth], 
+              m_ppcRecoYuvTemp[uhDepth], 
+              uhDepth );
+
+            xCheckDQP( rpcTempCU );
+            xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
+#endif
+          }
+#endif
+          rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag );
+
+      if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
+      {
 #if H_3D_INTER_SDC
-              if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) )
-              {
-                bestIsSkip = !rpcBestCU->getSDCFlag( 0 ) && ( rpcBestCU->getQtRootCbf(0) == 0 );
-              }
-              else
-              {
-#endif
-                bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
+        if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) )
+        {
+          bestIsSkip = !rpcBestCU->getSDCFlag( 0 ) && ( rpcBestCU->getQtRootCbf(0) == 0 );
+        }
+        else
+        {
+#endif
+        bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
 #if H_3D_INTER_SDC
-              }
-#endif
-            }
+        }
+#endif
+      }
+    }
+   }
+  }
+
+  if(uiNoResidual == 0 && m_pcEncCfg->getUseEarlySkipDetection())
+  {
+    if(rpcBestCU->getQtRootCbf( 0 ) == 0)
+    {
+      if( rpcBestCU->getMergeFlag( 0 ))
+      {
+        *earlyDetectionSkipMode = true;
+      }
+      else
+      {
+        Int absoulte_MV=0;
+        for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+        {
+          if ( rpcBestCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
+          {
+            TComCUMvField* pcCUMvField = rpcBestCU->getCUMvField(RefPicList( uiRefListIdx ));
+            Int iHor = pcCUMvField->getMvd( 0 ).getAbsHor();
+            Int iVer = pcCUMvField->getMvd( 0 ).getAbsVer();
+            absoulte_MV+=iHor+iVer;
           }
         }
-      }
-
-      if(uiNoResidual == 0 && m_pcEncCfg->getUseEarlySkipDetection())
-      {
-        if(rpcBestCU->getQtRootCbf( 0 ) == 0)
+
+        if(absoulte_MV == 0)
         {
-          if( rpcBestCU->getMergeFlag( 0 ))
-          {
-            *earlyDetectionSkipMode = true;
-          }
-          else
-          {
-            Int absoulte_MV=0;
-            for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
-            {
-              if ( rpcBestCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
-              {
-                TComCUMvField* pcCUMvField = rpcBestCU->getCUMvField(RefPicList( uiRefListIdx ));
-                Int iHor = pcCUMvField->getMvd( 0 ).getAbsHor();
-                Int iVer = pcCUMvField->getMvd( 0 ).getAbsVer();
-                absoulte_MV+=iHor+iVer;
-              }
-            }
-
-            if(absoulte_MV == 0)
-            {
-              *earlyDetectionSkipMode = true;
-            }
-          }
+          *earlyDetectionSkipMode = true;
         }
       }
     }
+  }
+ }
 #if H_3D_SPIVMP
-    delete[] pcMvFieldSP;
-    delete[] puhInterDirSP;
+ delete[] pcMvFieldSP;
+ delete[] puhInterDirSP;
 #endif
 #if H_3D_ARP
-  }
+ }
 #endif
 }
Index: /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 854)
@@ -49,4 +49,5 @@
 #include <time.h>
 #include <math.h>
+
 using namespace std;
 //! \ingroup TLibEncoder
Index: /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	(revision 854)
@@ -41,4 +41,5 @@
 #include <stdio.h>
 #include <math.h>
+
 //! \ingroup TLibEncoder
 //! \{
Index: /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 854)
@@ -3950,4 +3950,5 @@
         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
+
 #if NTT_STORE_SPDV_VSP_G0148
       }
@@ -4042,46 +4043,46 @@
   m_cYuvPredTemp.clear();
   rpcPredYuv->clear();
-
+  
   if ( !bUseRes )
   {
     rpcResiYuv->clear();
   }
-
+  
   rpcRecoYuv->clear();
-
+  
   TComMv        cMvSrchRngLT;
   TComMv        cMvSrchRngRB;
-
+  
   TComMv        cMvZero;
   TComMv        TempMv; //kolya
-
+  
   TComMv        cMv[2];
   TComMv        cMvBi[2];
   TComMv        cMvTemp[2][33];
-
+  
   Int           iNumPart    = pcCU->getNumPartInter();
   Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
-
+  
   TComMv        cMvPred[2][33];
-
+  
   TComMv        cMvPredBi[2][33];
   Int           aaiMvpIdxBi[2][33];
-
+  
   Int           aaiMvpIdx[2][33];
   Int           aaiMvpNum[2][33];
-
+  
   AMVPInfo aacAMVPInfo[2][33];
-
+  
   Int           iRefIdx[2]={0,0}; //If un-initialized, may cause SEGV in bi-directional prediction iterative stage.
   Int           iRefIdxBi[2];
-
+  
   UInt          uiPartAddr;
   Int           iRoiWidth, iRoiHeight;
-
+  
   UInt          uiMbBits[3] = {1, 1, 0};
-
+  
   UInt          uiLastMode = 0;
   Int           iRefStart, iRefEnd;
-
+  
   PartSize      ePartSize = pcCU->getPartitionSize( 0 );
 
@@ -4110,5 +4111,5 @@
     UInt          uiCostBi  =   MAX_UINT;
     UInt          uiCostTemp;
-
+    
     UInt          uiBits[3];
     UInt          uiBitsTemp;
@@ -4135,5 +4136,5 @@
 
     xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
-
+    
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
 
@@ -4141,5 +4142,5 @@
     pcCU->setVSPFlagSubParts( 0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr) );
 #endif
-
+    
 #if AMP_MRG
     Bool bTestNormalMC = true;
@@ -4152,17 +4153,213 @@
       bTestNormalMC = false;
     }
-
+    
     if (bTestNormalMC)
     {
 #endif
 
-      //  Uni-directional prediction
-      for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
-      {
+    //  Uni-directional prediction
+    for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
+    {
+      RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
+      
+      for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
+      {
+        uiBitsTemp = uiMbBits[iRefList];
+        if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
+        {
+          uiBitsTemp += iRefIdxTemp+1;
+          if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
+        }
+#if ZERO_MVD_EST
+        xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp, &uiZeroMvdDistTemp);
+#else
+        xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
+#endif
+        aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
+        aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
+        
+        if(pcCU->getSlice()->getMvdL1ZeroFlag() && iRefList==1 && biPDistTemp < bestBiPDist)
+        {
+          bestBiPDist = biPDistTemp;
+          bestBiPMvpL1 = aaiMvpIdx[iRefList][iRefIdxTemp];
+          bestBiPRefIdxL1 = iRefIdxTemp;
+        }
+
+        uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
+#if ZERO_MVD_EST
+        if ( iRefList == 0 || pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
+        {
+          uiZeroMvdBitsTemp = uiBitsTemp;
+          uiZeroMvdBitsTemp += 2; //zero mvd bits
+
+          m_pcRdCost->getMotionCost( 1, 0 );
+          uiZeroMvdCostTemp = uiZeroMvdDistTemp + m_pcRdCost->getCost(uiZeroMvdBitsTemp);
+
+          if (uiZeroMvdCostTemp < uiZeroMvdCost)
+          {
+            uiZeroMvdCost = uiZeroMvdCostTemp;
+            iZeroMvdDir = iRefList + 1;
+            aiZeroMvdRefIdx[iRefList] = iRefIdxTemp;
+            aiZeroMvdMvpIdx[iRefList] = aaiMvpIdx[iRefList][iRefIdxTemp];
+            auiZeroMvdBits[iRefList] = uiZeroMvdBitsTemp;
+          }          
+        }
+#endif
+        
+#if GPB_SIMPLE_UNI
+        if ( iRefList == 1 )    // list 1
+        {
+          if ( pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) >= 0 )
+          {
+            cMvTemp[1][iRefIdxTemp] = cMvTemp[0][pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
+            uiCostTemp = uiCostTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
+            /*first subtract the bit-rate part of the cost of the other list*/
+            uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )] );
+            /*correct the bit-rate part of the current ref*/
+            m_pcRdCost->setPredictor  ( cMvPred[iRefList][iRefIdxTemp] );
+            uiBitsTemp += m_pcRdCost->getBits( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() );
+            /*calculate the correct cost*/
+            uiCostTemp += m_pcRdCost->getCost( uiBitsTemp );
+          }
+          else
+          {
+            xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
+          }
+        }
+        else
+        {
+          xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
+        }
+#else
+        xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
+#endif
+        xCopyAMVPInfo(pcCU->getCUMvField(eRefPicList)->getAMVPInfo(), &aacAMVPInfo[iRefList][iRefIdxTemp]); // must always be done ( also when AMVP_MODE = AM_NONE )
+        xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
+
+        if ( iRefList == 0 )
+        {
+          uiCostTempL0[iRefIdxTemp] = uiCostTemp;
+          uiBitsTempL0[iRefIdxTemp] = uiBitsTemp;
+        }
+        if ( uiCostTemp < uiCost[iRefList] )
+        {
+          uiCost[iRefList] = uiCostTemp;
+          uiBits[iRefList] = uiBitsTemp; // storing for bi-prediction
+
+          // set motion
+          cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
+          iRefIdx[iRefList] = iRefIdxTemp;
+        }
+
+        if ( iRefList == 1 && uiCostTemp < costValidList1 && pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
+        {
+          costValidList1 = uiCostTemp;
+          bitsValidList1 = uiBitsTemp;
+
+          // set motion
+          mvValidList1     = cMvTemp[iRefList][iRefIdxTemp];
+          refIdxValidList1 = iRefIdxTemp;
+        }
+      }
+    }
+    //  Bi-directional prediction
+    if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) )
+    {
+      
+      cMvBi[0] = cMv[0];            cMvBi[1] = cMv[1];
+      iRefIdxBi[0] = iRefIdx[0];    iRefIdxBi[1] = iRefIdx[1];
+      
+      ::memcpy(cMvPredBi, cMvPred, sizeof(cMvPred));
+      ::memcpy(aaiMvpIdxBi, aaiMvpIdx, sizeof(aaiMvpIdx));
+      
+      UInt uiMotBits[2];
+
+      if(pcCU->getSlice()->getMvdL1ZeroFlag())
+      {
+        xCopyAMVPInfo(&aacAMVPInfo[1][bestBiPRefIdxL1], pcCU->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo());
+        pcCU->setMVPIdxSubParts( bestBiPMvpL1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        aaiMvpIdxBi[1][bestBiPRefIdxL1] = bestBiPMvpL1;
+        cMvPredBi[1][bestBiPRefIdxL1]   = pcCU->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo()->m_acMvCand[bestBiPMvpL1];
+
+        cMvBi[1] = cMvPredBi[1][bestBiPRefIdxL1];
+        iRefIdxBi[1] = bestBiPRefIdxL1;
+        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( cMvBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
+        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
+        TComYuv* pcYuvPred = &m_acYuvPred[1];
+        motionCompensation( pcCU, pcYuvPred, REF_PIC_LIST_1, iPartIdx );
+
+        uiMotBits[0] = uiBits[0] - uiMbBits[0];
+        uiMotBits[1] = uiMbBits[1];
+
+        if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1) > 1 )
+        {
+          uiMotBits[1] += bestBiPRefIdxL1+1;
+          if ( bestBiPRefIdxL1 == pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1)-1 ) uiMotBits[1]--;
+        }
+
+        uiMotBits[1] += m_auiMVPIdxCost[aaiMvpIdxBi[1][bestBiPRefIdxL1]][AMVP_MAX_NUM_CANDS];
+
+        uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];
+
+        cMvTemp[1][bestBiPRefIdxL1] = cMvBi[1];
+      }
+      else
+      {
+        uiMotBits[0] = uiBits[0] - uiMbBits[0];
+        uiMotBits[1] = uiBits[1] - uiMbBits[1];
+        uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];
+      }
+
+      // 4-times iteration (default)
+      Int iNumIter = 4;
+      
+      // fast encoder setting: only one iteration
+      if ( m_pcEncCfg->getUseFastEnc() || pcCU->getSlice()->getMvdL1ZeroFlag())
+      {
+        iNumIter = 1;
+      }
+      
+      for ( Int iIter = 0; iIter < iNumIter; iIter++ )
+      {
+        
+        Int         iRefList    = iIter % 2;
+        if ( m_pcEncCfg->getUseFastEnc() )
+        {
+          if( uiCost[0] <= uiCost[1] )
+          {
+            iRefList = 1;
+          }
+          else
+          {
+            iRefList = 0;
+          }
+        }
+        else if ( iIter == 0 )
+        {
+          iRefList = 0;
+        }
+        if ( iIter == 0 && !pcCU->getSlice()->getMvdL1ZeroFlag())
+        {
+          pcCU->getCUMvField(RefPicList(1-iRefList))->setAllMv( cMv[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
+          pcCU->getCUMvField(RefPicList(1-iRefList))->setAllRefIdx( iRefIdx[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
+          TComYuv*  pcYuvPred = &m_acYuvPred[1-iRefList];
+          motionCompensation ( pcCU, pcYuvPred, RefPicList(1-iRefList), iPartIdx );
+        }
         RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
 
-        for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
-        {
-          uiBitsTemp = uiMbBits[iRefList];
+        if(pcCU->getSlice()->getMvdL1ZeroFlag())
+        {
+          iRefList = 0;
+          eRefPicList = REF_PIC_LIST_0;
+        }
+
+        Bool bChanged = false;
+        
+        iRefStart = 0;
+        iRefEnd   = pcCU->getSlice()->getNumRefIdx(eRefPicList)-1;
+        
+        for ( Int iRefIdxTemp = iRefStart; iRefIdxTemp <= iRefEnd; iRefIdxTemp++ )
+        {
+          uiBitsTemp = uiMbBits[2] + uiMotBits[1-iRefList];
           if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
           {
@@ -4170,295 +4367,99 @@
             if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
           }
+          uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdxBi[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
+          // call ME
+          xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPredBi[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, true );
+          xCopyAMVPInfo(&aacAMVPInfo[iRefList][iRefIdxTemp], pcCU->getCUMvField(eRefPicList)->getAMVPInfo());
+          xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
+
+          if ( uiCostTemp < uiCostBi )
+          {
+            bChanged = true;
+            
+            cMvBi[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
+            iRefIdxBi[iRefList] = iRefIdxTemp;
+            
+            uiCostBi            = uiCostTemp;
+            uiMotBits[iRefList] = uiBitsTemp - uiMbBits[2] - uiMotBits[1-iRefList];
+            uiBits[2]           = uiBitsTemp;
+            
+            if(iNumIter!=1)
+            {
+              //  Set motion
+              pcCU->getCUMvField( eRefPicList )->setAllMv( cMvBi[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
+              pcCU->getCUMvField( eRefPicList )->setAllRefIdx( iRefIdxBi[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
+
+              TComYuv* pcYuvPred = &m_acYuvPred[iRefList];
+              motionCompensation( pcCU, pcYuvPred, eRefPicList, iPartIdx );
+            }
+          }
+        } // for loop-iRefIdxTemp
+        
+        if ( !bChanged )
+        {
+          if ( uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1] )
+          {
+            xCopyAMVPInfo(&aacAMVPInfo[0][iRefIdxBi[0]], pcCU->getCUMvField(REF_PIC_LIST_0)->getAMVPInfo());
+            xCheckBestMVP(pcCU, REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], uiBits[2], uiCostBi);
+            if(!pcCU->getSlice()->getMvdL1ZeroFlag())
+            {
+              xCopyAMVPInfo(&aacAMVPInfo[1][iRefIdxBi[1]], pcCU->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo());
+              xCheckBestMVP(pcCU, REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], uiBits[2], uiCostBi);
+            }
+          }
+          break;
+        }
+      } // for loop-iter
+    } // if (B_SLICE)
 #if ZERO_MVD_EST
-          xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp, &uiZeroMvdDistTemp);
-#else
-          xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
-#endif
-          aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
-          aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
-
-          if(pcCU->getSlice()->getMvdL1ZeroFlag() && iRefList==1 && biPDistTemp < bestBiPDist)
+    if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) )
+    {
+      m_pcRdCost->getMotionCost( 1, 0 );
+
+      for ( Int iL0RefIdxTemp = 0; iL0RefIdxTemp <= pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0)-1; iL0RefIdxTemp++ )
+      for ( Int iL1RefIdxTemp = 0; iL1RefIdxTemp <= pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1)-1; iL1RefIdxTemp++ )
+      {
+        UInt uiRefIdxBitsTemp = 0;
+        if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 1 )
+        {
+          uiRefIdxBitsTemp += iL0RefIdxTemp+1;
+          if ( iL0RefIdxTemp == pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0)-1 ) uiRefIdxBitsTemp--;
+        }
+        if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1) > 1 )
+        {
+          uiRefIdxBitsTemp += iL1RefIdxTemp+1;
+          if ( iL1RefIdxTemp == pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1)-1 ) uiRefIdxBitsTemp--;
+        }
+
+        Int iL0MVPIdx = 0;
+        Int iL1MVPIdx = 0;
+
+        for (iL0MVPIdx = 0; iL0MVPIdx < aaiMvpNum[0][iL0RefIdxTemp]; iL0MVPIdx++)
+        {
+          for (iL1MVPIdx = 0; iL1MVPIdx < aaiMvpNum[1][iL1RefIdxTemp]; iL1MVPIdx++)
           {
-            bestBiPDist = biPDistTemp;
-            bestBiPMvpL1 = aaiMvpIdx[iRefList][iRefIdxTemp];
-            bestBiPRefIdxL1 = iRefIdxTemp;
-          }
-
-          uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
-#if ZERO_MVD_EST
-          if ( iRefList == 0 || pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
-          {
-            uiZeroMvdBitsTemp = uiBitsTemp;
-            uiZeroMvdBitsTemp += 2; //zero mvd bits
-
-            m_pcRdCost->getMotionCost( 1, 0 );
-            uiZeroMvdCostTemp = uiZeroMvdDistTemp + m_pcRdCost->getCost(uiZeroMvdBitsTemp);
-
+            uiZeroMvdBitsTemp = uiRefIdxBitsTemp;
+            uiZeroMvdBitsTemp += uiMbBits[2];
+            uiZeroMvdBitsTemp += m_auiMVPIdxCost[iL0MVPIdx][aaiMvpNum[0][iL0RefIdxTemp]] + m_auiMVPIdxCost[iL1MVPIdx][aaiMvpNum[1][iL1RefIdxTemp]];
+            uiZeroMvdBitsTemp += 4; //zero mvd for both directions
+            pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( aacAMVPInfo[0][iL0RefIdxTemp].m_acMvCand[iL0MVPIdx], iL0RefIdxTemp, ePartSize, uiPartAddr, iPartIdx, 0 );
+            pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( aacAMVPInfo[1][iL1RefIdxTemp].m_acMvCand[iL1MVPIdx], iL1RefIdxTemp, ePartSize, uiPartAddr, iPartIdx, 0 );
+  
+            xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiZeroMvdDistTemp, m_pcEncCfg->getUseHADME() );
+            uiZeroMvdCostTemp = uiZeroMvdDistTemp + m_pcRdCost->getCost( uiZeroMvdBitsTemp );
             if (uiZeroMvdCostTemp < uiZeroMvdCost)
             {
               uiZeroMvdCost = uiZeroMvdCostTemp;
-              iZeroMvdDir = iRefList + 1;
-              aiZeroMvdRefIdx[iRefList] = iRefIdxTemp;
-              aiZeroMvdMvpIdx[iRefList] = aaiMvpIdx[iRefList][iRefIdxTemp];
-              auiZeroMvdBits[iRefList] = uiZeroMvdBitsTemp;
-            }          
-          }
-#endif
-
-#if GPB_SIMPLE_UNI
-          if ( iRefList == 1 )    // list 1
-          {
-            if ( pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) >= 0 )
-            {
-              cMvTemp[1][iRefIdxTemp] = cMvTemp[0][pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
-              uiCostTemp = uiCostTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
-              /*first subtract the bit-rate part of the cost of the other list*/
-              uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )] );
-              /*correct the bit-rate part of the current ref*/
-              m_pcRdCost->setPredictor  ( cMvPred[iRefList][iRefIdxTemp] );
-              uiBitsTemp += m_pcRdCost->getBits( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() );
-              /*calculate the correct cost*/
-              uiCostTemp += m_pcRdCost->getCost( uiBitsTemp );
-            }
-            else
-            {
-              xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
+              iZeroMvdDir = 3;
+              aiZeroMvdMvpIdx[0] = iL0MVPIdx;
+              aiZeroMvdMvpIdx[1] = iL1MVPIdx;
+              aiZeroMvdRefIdx[0] = iL0RefIdxTemp;
+              aiZeroMvdRefIdx[1] = iL1RefIdxTemp;
+              auiZeroMvdBits[2] = uiZeroMvdBitsTemp;
             }
           }
-          else
-          {
-            xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
-          }
-#else
-          xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
-#endif
-          xCopyAMVPInfo(pcCU->getCUMvField(eRefPicList)->getAMVPInfo(), &aacAMVPInfo[iRefList][iRefIdxTemp]); // must always be done ( also when AMVP_MODE = AM_NONE )
-          xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
-
-          if ( iRefList == 0 )
-          {
-            uiCostTempL0[iRefIdxTemp] = uiCostTemp;
-            uiBitsTempL0[iRefIdxTemp] = uiBitsTemp;
-          }
-          if ( uiCostTemp < uiCost[iRefList] )
-          {
-            uiCost[iRefList] = uiCostTemp;
-            uiBits[iRefList] = uiBitsTemp; // storing for bi-prediction
-
-            // set motion
-            cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
-            iRefIdx[iRefList] = iRefIdxTemp;
-          }
-
-          if ( iRefList == 1 && uiCostTemp < costValidList1 && pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
-          {
-            costValidList1 = uiCostTemp;
-            bitsValidList1 = uiBitsTemp;
-
-            // set motion
-            mvValidList1     = cMvTemp[iRefList][iRefIdxTemp];
-            refIdxValidList1 = iRefIdxTemp;
-          }
-        }
-      }
-      //  Bi-directional prediction
-      if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) )
-      {
-
-        cMvBi[0] = cMv[0];            cMvBi[1] = cMv[1];
-        iRefIdxBi[0] = iRefIdx[0];    iRefIdxBi[1] = iRefIdx[1];
-
-        ::memcpy(cMvPredBi, cMvPred, sizeof(cMvPred));
-        ::memcpy(aaiMvpIdxBi, aaiMvpIdx, sizeof(aaiMvpIdx));
-
-        UInt uiMotBits[2];
-
-        if(pcCU->getSlice()->getMvdL1ZeroFlag())
-        {
-          xCopyAMVPInfo(&aacAMVPInfo[1][bestBiPRefIdxL1], pcCU->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo());
-          pcCU->setMVPIdxSubParts( bestBiPMvpL1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          aaiMvpIdxBi[1][bestBiPRefIdxL1] = bestBiPMvpL1;
-          cMvPredBi[1][bestBiPRefIdxL1]   = pcCU->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo()->m_acMvCand[bestBiPMvpL1];
-
-          cMvBi[1] = cMvPredBi[1][bestBiPRefIdxL1];
-          iRefIdxBi[1] = bestBiPRefIdxL1;
-          pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( cMvBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
-          pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
-          TComYuv* pcYuvPred = &m_acYuvPred[1];
-          motionCompensation( pcCU, pcYuvPred, REF_PIC_LIST_1, iPartIdx );
-
-          uiMotBits[0] = uiBits[0] - uiMbBits[0];
-          uiMotBits[1] = uiMbBits[1];
-
-          if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1) > 1 )
-          {
-            uiMotBits[1] += bestBiPRefIdxL1+1;
-            if ( bestBiPRefIdxL1 == pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1)-1 ) uiMotBits[1]--;
-          }
-
-          uiMotBits[1] += m_auiMVPIdxCost[aaiMvpIdxBi[1][bestBiPRefIdxL1]][AMVP_MAX_NUM_CANDS];
-
-          uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];
-
-          cMvTemp[1][bestBiPRefIdxL1] = cMvBi[1];
-        }
-        else
-        {
-          uiMotBits[0] = uiBits[0] - uiMbBits[0];
-          uiMotBits[1] = uiBits[1] - uiMbBits[1];
-          uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];
-        }
-
-        // 4-times iteration (default)
-        Int iNumIter = 4;
-
-        // fast encoder setting: only one iteration
-        if ( m_pcEncCfg->getUseFastEnc() || pcCU->getSlice()->getMvdL1ZeroFlag())
-        {
-          iNumIter = 1;
-        }
-
-        for ( Int iIter = 0; iIter < iNumIter; iIter++ )
-        {
-
-          Int         iRefList    = iIter % 2;
-          if ( m_pcEncCfg->getUseFastEnc() )
-          {
-            if( uiCost[0] <= uiCost[1] )
-            {
-              iRefList = 1;
-            }
-            else
-            {
-              iRefList = 0;
-            }
-          }
-          else if ( iIter == 0 )
-          {
-            iRefList = 0;
-          }
-          if ( iIter == 0 && !pcCU->getSlice()->getMvdL1ZeroFlag())
-          {
-            pcCU->getCUMvField(RefPicList(1-iRefList))->setAllMv( cMv[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
-            pcCU->getCUMvField(RefPicList(1-iRefList))->setAllRefIdx( iRefIdx[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
-            TComYuv*  pcYuvPred = &m_acYuvPred[1-iRefList];
-            motionCompensation ( pcCU, pcYuvPred, RefPicList(1-iRefList), iPartIdx );
-          }
-          RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
-
-          if(pcCU->getSlice()->getMvdL1ZeroFlag())
-          {
-            iRefList = 0;
-            eRefPicList = REF_PIC_LIST_0;
-          }
-
-          Bool bChanged = false;
-
-          iRefStart = 0;
-          iRefEnd   = pcCU->getSlice()->getNumRefIdx(eRefPicList)-1;
-
-          for ( Int iRefIdxTemp = iRefStart; iRefIdxTemp <= iRefEnd; iRefIdxTemp++ )
-          {
-            uiBitsTemp = uiMbBits[2] + uiMotBits[1-iRefList];
-            if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
-            {
-              uiBitsTemp += iRefIdxTemp+1;
-              if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
-            }
-            uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdxBi[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
-            // call ME
-            xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPredBi[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, true );
-            xCopyAMVPInfo(&aacAMVPInfo[iRefList][iRefIdxTemp], pcCU->getCUMvField(eRefPicList)->getAMVPInfo());
-            xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
-
-            if ( uiCostTemp < uiCostBi )
-            {
-              bChanged = true;
-
-              cMvBi[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
-              iRefIdxBi[iRefList] = iRefIdxTemp;
-
-              uiCostBi            = uiCostTemp;
-              uiMotBits[iRefList] = uiBitsTemp - uiMbBits[2] - uiMotBits[1-iRefList];
-              uiBits[2]           = uiBitsTemp;
-
-              if(iNumIter!=1)
-              {
-                //  Set motion
-                pcCU->getCUMvField( eRefPicList )->setAllMv( cMvBi[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
-                pcCU->getCUMvField( eRefPicList )->setAllRefIdx( iRefIdxBi[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
-
-                TComYuv* pcYuvPred = &m_acYuvPred[iRefList];
-                motionCompensation( pcCU, pcYuvPred, eRefPicList, iPartIdx );
-              }
-            }
-          } // for loop-iRefIdxTemp
-
-          if ( !bChanged )
-          {
-            if ( uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1] )
-            {
-              xCopyAMVPInfo(&aacAMVPInfo[0][iRefIdxBi[0]], pcCU->getCUMvField(REF_PIC_LIST_0)->getAMVPInfo());
-              xCheckBestMVP(pcCU, REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], uiBits[2], uiCostBi);
-              if(!pcCU->getSlice()->getMvdL1ZeroFlag())
-              {
-                xCopyAMVPInfo(&aacAMVPInfo[1][iRefIdxBi[1]], pcCU->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo());
-                xCheckBestMVP(pcCU, REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], uiBits[2], uiCostBi);
-              }
-            }
-            break;
-          }
-        } // for loop-iter
-      } // if (B_SLICE)
-#if ZERO_MVD_EST
-      if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) )
-      {
-        m_pcRdCost->getMotionCost( 1, 0 );
-
-        for ( Int iL0RefIdxTemp = 0; iL0RefIdxTemp <= pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0)-1; iL0RefIdxTemp++ )
-          for ( Int iL1RefIdxTemp = 0; iL1RefIdxTemp <= pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1)-1; iL1RefIdxTemp++ )
-          {
-            UInt uiRefIdxBitsTemp = 0;
-            if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 1 )
-            {
-              uiRefIdxBitsTemp += iL0RefIdxTemp+1;
-              if ( iL0RefIdxTemp == pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0)-1 ) uiRefIdxBitsTemp--;
-            }
-            if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1) > 1 )
-            {
-              uiRefIdxBitsTemp += iL1RefIdxTemp+1;
-              if ( iL1RefIdxTemp == pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1)-1 ) uiRefIdxBitsTemp--;
-            }
-
-            Int iL0MVPIdx = 0;
-            Int iL1MVPIdx = 0;
-
-            for (iL0MVPIdx = 0; iL0MVPIdx < aaiMvpNum[0][iL0RefIdxTemp]; iL0MVPIdx++)
-            {
-              for (iL1MVPIdx = 0; iL1MVPIdx < aaiMvpNum[1][iL1RefIdxTemp]; iL1MVPIdx++)
-              {
-                uiZeroMvdBitsTemp = uiRefIdxBitsTemp;
-                uiZeroMvdBitsTemp += uiMbBits[2];
-                uiZeroMvdBitsTemp += m_auiMVPIdxCost[iL0MVPIdx][aaiMvpNum[0][iL0RefIdxTemp]] + m_auiMVPIdxCost[iL1MVPIdx][aaiMvpNum[1][iL1RefIdxTemp]];
-                uiZeroMvdBitsTemp += 4; //zero mvd for both directions
-                pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( aacAMVPInfo[0][iL0RefIdxTemp].m_acMvCand[iL0MVPIdx], iL0RefIdxTemp, ePartSize, uiPartAddr, iPartIdx, 0 );
-                pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( aacAMVPInfo[1][iL1RefIdxTemp].m_acMvCand[iL1MVPIdx], iL1RefIdxTemp, ePartSize, uiPartAddr, iPartIdx, 0 );
-
-                xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiZeroMvdDistTemp, m_pcEncCfg->getUseHADME() );
-                uiZeroMvdCostTemp = uiZeroMvdDistTemp + m_pcRdCost->getCost( uiZeroMvdBitsTemp );
-                if (uiZeroMvdCostTemp < uiZeroMvdCost)
-                {
-                  uiZeroMvdCost = uiZeroMvdCostTemp;
-                  iZeroMvdDir = 3;
-                  aiZeroMvdMvpIdx[0] = iL0MVPIdx;
-                  aiZeroMvdMvpIdx[1] = iL1MVPIdx;
-                  aiZeroMvdRefIdx[0] = iL0RefIdxTemp;
-                  aiZeroMvdRefIdx[1] = iL1RefIdxTemp;
-                  auiZeroMvdBits[2] = uiZeroMvdBitsTemp;
-                }
-              }
-            }
-          }
-      }
+        }
+      }
+    }
 #endif
 
@@ -4476,5 +4477,5 @@
     pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-
+    
     UInt uiMEBits = 0;
     // Set Motion Field_
@@ -4488,103 +4489,103 @@
 #endif
 #if ZERO_MVD_EST
-      if (uiZeroMvdCost <= uiCostBi && uiZeroMvdCost <= uiCost[0] && uiZeroMvdCost <= uiCost[1])
-      {
-        if (iZeroMvdDir == 3)
-        {
-          uiLastMode = 2;
-
-          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( aacAMVPInfo[0][aiZeroMvdRefIdx[0]].m_acMvCand[aiZeroMvdMvpIdx[0]], aiZeroMvdRefIdx[0], ePartSize, uiPartAddr, iPartIdx, 0 );
-          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( aacAMVPInfo[1][aiZeroMvdRefIdx[1]].m_acMvCand[aiZeroMvdMvpIdx[1]], aiZeroMvdRefIdx[1], ePartSize, uiPartAddr, iPartIdx, 0 );
-
-          pcCU->setInterDirSubParts( 3, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
-
-          pcCU->setMVPIdxSubParts( aiZeroMvdMvpIdx[0], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( aaiMvpNum[0][aiZeroMvdRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPIdxSubParts( aiZeroMvdMvpIdx[1], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( aaiMvpNum[1][aiZeroMvdRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          uiMEBits = auiZeroMvdBits[2];
-        }
-        else if (iZeroMvdDir == 1)
-        {        
-          uiLastMode = 0;
-
-          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( aacAMVPInfo[0][aiZeroMvdRefIdx[0]].m_acMvCand[aiZeroMvdMvpIdx[0]], aiZeroMvdRefIdx[0], ePartSize, uiPartAddr, iPartIdx, 0 );
-
-          pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
-
-          pcCU->setMVPIdxSubParts( aiZeroMvdMvpIdx[0], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( aaiMvpNum[0][aiZeroMvdRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          uiMEBits = auiZeroMvdBits[0];
-        }
-        else if (iZeroMvdDir == 2)
-        {
-          uiLastMode = 1;
-
-          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( aacAMVPInfo[1][aiZeroMvdRefIdx[1]].m_acMvCand[aiZeroMvdMvpIdx[1]], aiZeroMvdRefIdx[1], ePartSize, uiPartAddr, iPartIdx, 0 );
-
-          pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
-
-          pcCU->setMVPIdxSubParts( aiZeroMvdMvpIdx[1], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( aaiMvpNum[1][aiZeroMvdRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          uiMEBits = auiZeroMvdBits[1];
-        }
-        else
-        {
-          assert(0);
-        }
+    if (uiZeroMvdCost <= uiCostBi && uiZeroMvdCost <= uiCost[0] && uiZeroMvdCost <= uiCost[1])
+    {
+      if (iZeroMvdDir == 3)
+      {
+        uiLastMode = 2;
+
+        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( aacAMVPInfo[0][aiZeroMvdRefIdx[0]].m_acMvCand[aiZeroMvdMvpIdx[0]], aiZeroMvdRefIdx[0], ePartSize, uiPartAddr, iPartIdx, 0 );
+        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( aacAMVPInfo[1][aiZeroMvdRefIdx[1]].m_acMvCand[aiZeroMvdMvpIdx[1]], aiZeroMvdRefIdx[1], ePartSize, uiPartAddr, iPartIdx, 0 );
+  
+        pcCU->setInterDirSubParts( 3, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
+        
+        pcCU->setMVPIdxSubParts( aiZeroMvdMvpIdx[0], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->setMVPNumSubParts( aaiMvpNum[0][aiZeroMvdRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->setMVPIdxSubParts( aiZeroMvdMvpIdx[1], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->setMVPNumSubParts( aaiMvpNum[1][aiZeroMvdRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        uiMEBits = auiZeroMvdBits[2];
+      }
+      else if (iZeroMvdDir == 1)
+      {        
+        uiLastMode = 0;
+
+        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( aacAMVPInfo[0][aiZeroMvdRefIdx[0]].m_acMvCand[aiZeroMvdMvpIdx[0]], aiZeroMvdRefIdx[0], ePartSize, uiPartAddr, iPartIdx, 0 );
+
+        pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
+        
+        pcCU->setMVPIdxSubParts( aiZeroMvdMvpIdx[0], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->setMVPNumSubParts( aaiMvpNum[0][aiZeroMvdRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        uiMEBits = auiZeroMvdBits[0];
+      }
+      else if (iZeroMvdDir == 2)
+      {
+        uiLastMode = 1;
+
+        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( aacAMVPInfo[1][aiZeroMvdRefIdx[1]].m_acMvCand[aiZeroMvdMvpIdx[1]], aiZeroMvdRefIdx[1], ePartSize, uiPartAddr, iPartIdx, 0 );
+
+        pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
+        
+        pcCU->setMVPIdxSubParts( aiZeroMvdMvpIdx[1], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->setMVPNumSubParts( aaiMvpNum[1][aiZeroMvdRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        uiMEBits = auiZeroMvdBits[1];
       }
       else
-#endif
-        if ( uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1])
-        {
-          uiLastMode = 2;
-          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMvBi[0], ePartSize, uiPartAddr, 0, iPartIdx );
-          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdxBi[0], ePartSize, uiPartAddr, 0, iPartIdx );
-          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMvBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
-          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
-
-          TempMv = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]];
-          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
-
-          TempMv = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]];
-          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
-
-          pcCU->setInterDirSubParts( 3, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
-
-          pcCU->setMVPIdxSubParts( aaiMvpIdxBi[0][iRefIdxBi[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdxBi[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPIdxSubParts( aaiMvpIdxBi[1][iRefIdxBi[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdxBi[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-
-          uiMEBits = uiBits[2];
-        }
-        else if ( uiCost[0] <= uiCost[1] )
-        {
-          uiLastMode = 0;
+      {
+        assert(0);
+      }
+    }
+    else
+#endif
+    if ( uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1])
+    {
+      uiLastMode = 2;
+            pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMvBi[0], ePartSize, uiPartAddr, 0, iPartIdx );
+            pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdxBi[0], ePartSize, uiPartAddr, 0, iPartIdx );
+            pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMvBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
+            pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
+      
+        TempMv = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]];
+            pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
+      
+        TempMv = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]];
+            pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
+      
+      pcCU->setInterDirSubParts( 3, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
+      
+      pcCU->setMVPIdxSubParts( aaiMvpIdxBi[0][iRefIdxBi[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+      pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdxBi[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+      pcCU->setMVPIdxSubParts( aaiMvpIdxBi[1][iRefIdxBi[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+      pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdxBi[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+
+      uiMEBits = uiBits[2];
+    }
+    else if ( uiCost[0] <= uiCost[1] )
+    {
+      uiLastMode = 0;
           pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
           pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
-          TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
-          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
-          pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
-
-          pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-
-          uiMEBits = uiBits[0];
-        }
-        else
-        {
-          uiLastMode = 1;
+        TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
+            pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
+      pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
+      
+      pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+      pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+
+      uiMEBits = uiBits[0];
+    }
+    else
+    {
+      uiLastMode = 1;
           pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
           pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
-          TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
-          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
-          pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
-
-          pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-
-          uiMEBits = uiBits[1];
-        }
+        TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
+            pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
+      pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
+      
+      pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+      pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+
+      uiMEBits = uiBits[1];
+    }
 #if AMP_MRG
     } // end if bTestNormalMC
@@ -4649,12 +4650,12 @@
       xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours
 #if H_3D_VSP
-        , vspFlag
-        , inheritedVSPDisInfo
+                      , vspFlag
+                      , inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
-        , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+                      , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
 #endif 
-        , numValidMergeCand
-        );
+                      , numValidMergeCand
+                      );
       if ( uiMRGCost < uiMECost )
       {
@@ -4669,12 +4670,12 @@
         if( uiMRGIndex == pcCU->getUseDDDCandIdx() )
         {
-          assert( vspFlag[uiMRGIndex]     == 0 );
-          assert( bSPIVMPFlag[uiMRGIndex] == 0 );
-          pcCU->setUseDDD( true, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
-          pcCU->setDDDepthSubParts( pcCU->getDDTmpDepth(), uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+            assert( vspFlag[uiMRGIndex]     == 0 );
+            assert( bSPIVMPFlag[uiMRGIndex] == 0 );
+            pcCU->setUseDDD( true, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+            pcCU->setDDDepthSubParts( pcCU->getDDTmpDepth(), uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         }
         else
         {
-          pcCU->setUseDDD( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+            pcCU->setUseDDD( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         }
 #endif
@@ -4704,39 +4705,39 @@
 #if NTT_STORE_SPDV_VSP_G0148
 #if H_3D_DBBP
-          if ( vspFlag[uiMRGIndex] && !pcCU->getDBBPFlag(uiPartAddr) )
+        if ( vspFlag[uiMRGIndex] && !pcCU->getDBBPFlag(uiPartAddr) )
 #else
-          if ( vspFlag[uiMRGIndex] )
-#endif
+        if ( vspFlag[uiMRGIndex] )
+#endif
+        {
+          UInt partAddrTemp;
+          Int vspSize;
+          Int width, height;
+          pcCU->getPartIndexAndSize( iPartIdx, partAddrTemp, width, height ); // true or pcCU->getTotalNumPart()==256
+          if( uiMRGInterDir & 0x01 )
           {
-            UInt partAddrTemp;
-            Int vspSize;
-            Int width, height;
-            pcCU->getPartIndexAndSize( iPartIdx, partAddrTemp, width, height ); // true or pcCU->getTotalNumPart()==256
-            if( uiMRGInterDir & 0x01 )
-            {
-              pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_0, cMRGMvField[0].getRefIdx(), vspSize );
-              pcCU->setVSPFlag( partAddrTemp, vspSize );
-            }
-            else
-            {
-              pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
-            }
-            if( uiMRGInterDir & 0x02 )
-            {
-              pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_1, cMRGMvField[1].getRefIdx(), vspSize );
-              pcCU->setVSPFlag( partAddrTemp, vspSize );
-            }
-            else
-            {
-              pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
-            }
-            pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+            pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_0, cMRGMvField[0].getRefIdx(), vspSize );
+            pcCU->setVSPFlag( partAddrTemp, vspSize );
           }
           else
+          {
+            pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
+          }
+          if( uiMRGInterDir & 0x02 )
+          {
+            pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_1, cMRGMvField[1].getRefIdx(), vspSize );
+            pcCU->setVSPFlag( partAddrTemp, vspSize );
+          }
+          else
+          {
+            pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
+          }
+          pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+        }
+        else
 #if H_3D_FIX_G0148_BRACE
           {
 #endif
 #endif
-            pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+          pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
             pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
@@ -4744,11 +4745,11 @@
           }
 #endif
-          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
-          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
-
-          pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
-          pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
+        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
+
+        pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
+        pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
       }
       else
@@ -4767,7 +4768,7 @@
         pcCU->setDvInfoSubParts(OriginalDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
 #endif
-        pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
-        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
-      }
+          pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
+          pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
+        }
 #if H_3D_SPIVMP
       delete[] pcMvFieldSP;
@@ -4778,5 +4779,5 @@
     //  MC
     motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
-
+    
   } //  end of for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ )
 
@@ -5803,6 +5804,6 @@
       dCostBest        = dCost;
       qpBest           = qp;
-      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
-    }
+        m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
+      }
 #if H_3D_VSO // M21
     if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
Index: /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 853)
+++ /branches/HTM-10.0-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 854)
@@ -668,4 +668,7 @@
   m_cSPS.setLayerId( getLayerId() );
 #endif
+#if H_MV_HLS_7_VPS_P0048_14
+ // Code below needs to be moved to VPS
+#endif
   ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
   profileTierLevel.setLevelIdc(m_level);
@@ -828,5 +831,15 @@
   m_cPPS.setPPSId( getLayerIdInVps() );
   m_cPPS.setSPSId( getLayerIdInVps() );
-#endif
+
+#if H_MV_HLS_7_GEN_P0166_PPS_EXTENSION
+#if H_MV  
+  m_cPPS.setPpsExtensionTypeFlag          ( PPS_EX_T_MV ,true ); 
+#if H_3D
+  m_cPPS.setPpsExtensionTypeFlag          ( PPS_EX_T_3D ,true ); 
+#endif
+#endif
+#endif
+#endif
+
 #if H_3D
   m_cPPS.setDLT( getDLT() );
