Index: branches/SHM-4.1-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-4.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 543)
+++ branches/SHM-4.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 544)
@@ -1171,5 +1171,9 @@
   vps->setNumOutputLayerSets(vps->getNumLayerSets());
   vps->setNumProfileTierLevel(vps->getNumLayerSets());
+#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
+  vps->setDefaultOneTargetOutputLayerIdc(1);
+#else
   vps->setDefaultOneTargetOutputLayerFlag(true);
+#endif
   for(i = 1; i < vps->getNumLayerSets(); i++)
   {
Index: branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 543)
+++ branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 544)
@@ -2038,5 +2038,9 @@
 , m_moreOutputLayerSetsThanDefaultFlag (false)
 , m_numAddOutputLayerSets     (0)
+#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
+, m_defaultOneTargetOutputLayerIdc     (0)
+#else
 , m_defaultOneTargetOutputLayerFlag    (false)
+#endif
 #if VPS_VUI_BITRATE_PICRATE
 , m_bitRatePresentVpsFlag     (false)
@@ -2048,5 +2052,9 @@
 #endif
 #if VIEW_ID_RELATED_SIGNALING 
+#if O0109_VIEW_ID_LEN
+, m_viewIdLen                (0)
+#else
 , m_viewIdLenMinus1           (0)
+#endif
 #endif
 #if VPS_VUI_OFFSET
Index: branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 543)
+++ branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 544)
@@ -540,5 +540,9 @@
   Bool       m_moreOutputLayerSetsThanDefaultFlag;
   Int        m_numAddOutputLayerSets;
+#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
+  UInt       m_defaultOneTargetOutputLayerIdc;
+#else
   Bool       m_defaultOneTargetOutputLayerFlag;
+#endif
   Int        m_profileLevelTierIdx[64];     
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
@@ -622,5 +626,9 @@
 #endif
 #if VIEW_ID_RELATED_SIGNALING 
+#if O0109_VIEW_ID_LEN
+  Int         m_viewIdLen;
+#else
   Int         m_viewIdLenMinus1;
+#endif
   Int         m_viewIdVal                [MAX_LAYERS];
 #endif
@@ -642,4 +650,9 @@
   Int     m_numSubDpbs                  [MAX_VPS_OP_LAYER_SETS_PLUS1];
 #endif
+
+#if O0109_MOVE_VPS_VUI_FLAG
+  Bool       m_vpsVuiPresentFlag;
+#endif
+
 #endif //SVC_EXTENSION
 #if VPS_VUI_OFFSET
@@ -814,7 +827,11 @@
   Void   setNumAddOutputLayerSets(Int x)                         { m_numAddOutputLayerSets = x   ; }
 
+#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
+  UInt   getDefaultOneTargetOutputLayerIdc()                 { return m_defaultOneTargetOutputLayerIdc;}
+  Void   setDefaultOneTargetOutputLayerIdc(UInt x)           { m_defaultOneTargetOutputLayerIdc= x    ;}
+#else
   Bool   getDefaultOneTargetOutputLayerFlag()                 { return m_defaultOneTargetOutputLayerFlag;}
   Void   setDefaultOneTargetOutputLayerFlag(Bool x)           { m_defaultOneTargetOutputLayerFlag= x    ;}
-
+#endif
   Int    getProfileLevelTierIdx(Int i)                        { return m_profileLevelTierIdx[i]; }
   Void   setProfileLevelTierIdx(Int i, Int x)                 { m_profileLevelTierIdx[i] = x   ; }
@@ -949,6 +966,11 @@
 #endif
 #if VIEW_ID_RELATED_SIGNALING
+#if O0109_VIEW_ID_LEN
+  Void    setViewIdLen( Int  val )                                   { m_viewIdLen = val; } 
+  Int     getViewIdLen(  )                                           { return m_viewIdLen; } 
+#else
   Void    setViewIdLenMinus1( Int  val )                                   { m_viewIdLenMinus1 = val; } 
   Int     getViewIdLenMinus1(  )                                           { return m_viewIdLenMinus1; } 
+#endif
 
   Void    setViewIdVal( Int viewOrderIndex, Int  val )                     { m_viewIdVal[viewOrderIndex] = val; } 
@@ -989,4 +1011,10 @@
   Void    setNumSubDpbs(Int i, Int x)                   { m_numSubDpbs[i] = x;    }
 #endif
+
+#if O0109_MOVE_VPS_VUI_FLAG
+  Bool   getVpsVuiPresentFlag()                                 { return m_vpsVuiPresentFlag; }
+  Void   setVpsVuiPresentFlag(Bool x)                           { m_vpsVuiPresentFlag = x; }
+#endif
+
 #if VPS_VUI_OFFSET
   Int     getVpsVuiOffset()         { return m_vpsVuiOffset; }
Index: branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 543)
+++ branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 544)
@@ -49,4 +49,10 @@
 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
 
+#define O0109_O0199_FLAGS_TO_VUI         1      ///< JCTVC-O0109, O0199: move single_layer_for_non_irap_flag and higher_layer_flag to vps_vui
+#define O0109_VIEW_ID_LEN                1      ///< JCTVC-O0109: view_id_len_minus1 to view_id_len, and add constraint (1<<view_id_len) is greater than or equal to NumViews
+#define O0109_PROF_REF_MINUS1            1      ///< JCTVC-O0109: constraint that profile_ref_minus1[i] shall be less than or equal to i
+#define O0109_DEFAULT_ONE_OUT_LAYER_IDC  1      ///< JCTVC-O0109: default_one_target_output_layer_flag to default_one_target_output_layer_idc
+#define O0109_MOVE_VPS_VUI_FLAG          1      ///< JCTVC-O0109: move vps_vui_present_flag before vps_vui_offset
+
 #define O0194_DIFFERENT_BITDEPTH_EL_BL   1      ///< JCTVC-O0194: Support for different bitdepth values for BL and EL, add required configuration parameters (and Some bugfixes when REPN_FORMAT_IN_VPS (JCTVC-N0092) is enabled)
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
@@ -179,5 +185,5 @@
 #define RC_SHVC_HARMONIZATION            1      ///< JCTVC-M0037: rate control for SHVC
 
-#define VIEW_ID_RELATED_SIGNALING        1      ///< Introduce syntax elements view_id_len_minus1 and view_id_val
+#define VIEW_ID_RELATED_SIGNALING        1      ///< Introduce syntax elements view_id and view_id_val
 #define M0043_LAYERS_PRESENT_SEI         0      ///< JCTVC-M0043: add layers present SEI. Macro shall be equal to 0 according to the JCTVC-N0174 discussion. The code is to be removed.
 #define N0383_IL_CONSTRAINED_TILE_SETS_SEI  1
Index: branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 543)
+++ branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 544)
@@ -990,6 +990,15 @@
 
   READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false);
+
+#if O0109_MOVE_VPS_VUI_FLAG
+  READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false);
+  if ( uiCode )
+  {
+#endif
 #if VPS_VUI_OFFSET
   READ_CODE( 16, uiCode, "vps_vui_offset" );  vps->setVpsVuiOffset( uiCode );
+#endif
+#if O0109_MOVE_VPS_VUI_FLAG
+  }
 #endif
   READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false);
@@ -1051,7 +1060,20 @@
   //   However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val.
   {
+#if O0109_VIEW_ID_LEN
+    READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode );
+#else
     READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode );
-  }
-
+#endif
+  }
+
+#if O0109_VIEW_ID_LEN
+  if ( vps->getViewIdLen() > 0 )
+  {
+    for(  i = 0; i < vps->getNumViews(); i++ )
+    {
+      READ_CODE( vps->getViewIdLen( ), uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode );
+    }
+  }
+#else
   for(  i = 0; i < vps->getNumViews(); i++ )
   {
@@ -1059,4 +1081,5 @@
   }
 #endif
+#endif // view id related signaling
 #if VPS_EXTN_DIRECT_REF_LAYERS
   // For layer 0
@@ -1168,6 +1191,9 @@
     {
       READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
+#if O0109_PROF_REF_MINUS1
+      assert( vps->getProfileLayerSetRef(idx) <= idx );
+#else
       assert( vps->getProfileLayerSetRef(idx) < idx );
-
+#endif
       // Copy profile information as indicated
       vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) );
@@ -1190,5 +1216,9 @@
   if( numOutputLayerSets > 1 )
   {
+#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
+    READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" );   vps->setDefaultOneTargetOutputLayerIdc( uiCode );
+#else
     READ_FLAG( uiCode, "default_one_target_output_layer_flag" );   vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false );
+#endif
   }
   vps->setNumOutputLayerSets( numOutputLayerSets );
@@ -1218,4 +1248,24 @@
       // Assign OutputLayerFlag depending on default_one_target_output_layer_flag
       Int lsIdx = i;
+#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
+      if( vps->getDefaultOneTargetOutputLayerIdc() == 1 )
+      {
+        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
+        {
+          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)));
+        }
+      }
+      else if ( vps->getDefaultOneTargetOutputLayerIdc() == 0 )
+      {
+        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
+        {
+          vps->setOutputLayerFlag(i, j, 1);
+        }
+      }
+      else
+      {
+        // Other values of default_one_target_output_layer_idc than 0 and 1 are reserved for future use.
+      }
+#else
       if( vps->getDefaultOneTargetOutputLayerFlag() )
       {
@@ -1232,4 +1282,5 @@
         }
       }
+#endif
     }
     Int numBits = 1;
@@ -1411,4 +1462,5 @@
 #endif
 
+#if !O0109_O0199_FLAGS_TO_VUI
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false);
@@ -1417,7 +1469,12 @@
   READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false);
 #endif
-
+#endif
+
+#if O0109_MOVE_VPS_VUI_FLAG
+  if ( vps->getVpsVuiPresentFlag() )
+#else
   READ_FLAG( uiCode,  "vps_vui_present_flag" );
   if (uiCode)
+#endif
   {
 #if VPS_VUI
@@ -1596,4 +1653,14 @@
   }
 #endif
+
+#if O0109_O0199_FLAGS_TO_VUI
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false);
+#endif
+#if HIGHER_LAYER_IRAP_SKIP_FLAG
+  READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false);
+#endif
+#endif
+
 #if N0160_VUI_EXT_ILP_REF
     READ_FLAG( uiCode, "num_ilp_restricted_ref_layers" ); vps->setNumIlpRestrictedRefLayers( uiCode == 1 );
Index: branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 543)
+++ branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 544)
@@ -798,8 +798,25 @@
 
   WRITE_FLAG( vps->getAvcBaseLayerFlag(),              "avc_base_layer_flag" );
+#if O0109_MOVE_VPS_VUI_FLAG
+#if !VPS_VUI
+  WRITE_FLAG( 0,                     "vps_vui_present_flag" );
+  vps->setVpsVuiPresentFlag(false);
+#else
+  WRITE_FLAG( 1,                     "vps_vui_present_flag" );
+  vps->setVpsVuiPresentFlag(true);
+#endif
+  if ( vps->getVpsVuiPresentFlag() ) 
+  {
+#if VPS_VUI_OFFSET
+    WRITE_CODE( vps->getVpsVuiOffset(  ), 16,             "vps_vui_offset" );
+#endif
+    WRITE_FLAG( vps->getSplittingFlag(),                 "splitting_flag" );
+  }
+#else
 #if VPS_VUI_OFFSET
   WRITE_CODE( vps->getVpsVuiOffset(  ), 16,             "vps_vui_offset" );  
 #endif
   WRITE_FLAG( vps->getSplittingFlag(),                 "splitting_flag" );
+#endif // O0109_MOVE_VPS_VUI_FLAG
 
   for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
@@ -847,12 +864,29 @@
   //   However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. 
   {
+#if O0109_VIEW_ID_LEN
+    WRITE_CODE( vps->getViewIdLen( ), 4, "view_id_len" );
+    assert ( vps->getNumViews() >= (1<<vps->getViewIdLen()) );
+#else
     WRITE_CODE( vps->getViewIdLenMinus1( ), 4, "view_id_len_minus1" );
-  }
-
+#endif
+  }
+
+#if O0109_VIEW_ID_LEN
+  if ( vps->getViewIdLen() > 0 )
+  {
+#endif
   for(  i = 0; i < vps->getNumViews(); i++ )
   {
+#if O0109_VIEW_ID_LEN
+    WRITE_CODE( vps->getViewIdVal( i ), vps->getViewIdLen( ), "view_id_val[i]" );
+#else
     WRITE_CODE( vps->getViewIdVal( i ), vps->getViewIdLenMinus1( ) + 1, "view_id_val[i]" );
-  }
-#endif
+#endif
+  }
+#if O0109_VIEW_ID_LEN
+  }
+#endif
+#endif // VIEW_ID_RELATED_SIGNALING
+
 #if VPS_EXTN_DIRECT_REF_LAYERS
   for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
@@ -937,5 +971,9 @@
   if( numOutputLayerSets > 1 )
   {
+#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
+    WRITE_CODE( vps->getDefaultOneTargetOutputLayerIdc(), 2, "default_one_target_output_layer_idc" );   
+#else
     WRITE_FLAG( vps->getDefaultOneTargetOutputLayerFlag(), "default_one_target_output_layer_flag" );   
+#endif
   }
 
@@ -1078,4 +1116,6 @@
 #endif
 #endif
+
+#if !O0109_O0199_FLAGS_TO_VUI
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   WRITE_FLAG(vps->getSingleLayerForNonIrapFlag(), "single_layer_for_non_irap_flag" );
@@ -1084,5 +1124,7 @@
   WRITE_FLAG(vps->getHigherLayerIrapSkipFlag(), "higher_layer_irap_skip_flag" );
 #endif
-
+#endif
+
+#if !O0109_MOVE_VPS_VUI_FLAG
 #if !VPS_VUI
   WRITE_FLAG( 0,                     "vps_vui_present_flag" );
@@ -1103,4 +1145,19 @@
   }
 #endif 
+#else
+  if(vps->getVpsVuiPresentFlag())   // Should be conditioned on the value of vps_vui_present_flag
+  {
+    while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
+    {
+      WRITE_FLAG(1,                  "vps_vui_alignment_bit_equal_to_one");
+    }
+#if VPS_VUI_OFFSET
+    Int vpsVuiOffsetValeInBits = this->m_pcBitIf->getNumberOfWrittenBits() - m_vpsVuiCounter + 16; // 2 bytes for NUH
+    assert( vpsVuiOffsetValeInBits % 8 == 0 );
+    vps->setVpsVuiOffset( vpsVuiOffsetValeInBits >> 3 );
+#endif
+    codeVPSVUI(vps);  
+  }
+#endif // 0109_MOVE_VPS_FLAG
 }
 #endif
@@ -1236,4 +1293,13 @@
     }
   }
+#endif
+
+#if O0109_O0199_FLAGS_TO_VUI
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  WRITE_FLAG(vps->getSingleLayerForNonIrapFlag(), "single_layer_for_non_irap_flag" );
+#endif
+#if HIGHER_LAYER_IRAP_SKIP_FLAG
+  WRITE_FLAG(vps->getHigherLayerIrapSkipFlag(), "higher_layer_irap_skip_flag" );
+#endif
 #endif
 #if N0160_VUI_EXT_ILP_REF
