Index: trunk/source/Lib/TLibDecoder/SEIread.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/SEIread.cpp	(revision 622)
+++ trunk/source/Lib/TLibDecoder/SEIread.cpp	(revision 655)
@@ -315,4 +315,5 @@
 
   /* restore primary bitstream for sei_message */
+  getBitstream()->deleteFifo();
   delete getBitstream();
   setBitstream(bs);
Index: trunk/source/Lib/TLibDecoder/SyntaxElementParser.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/SyntaxElementParser.cpp	(revision 622)
+++ trunk/source/Lib/TLibDecoder/SyntaxElementParser.cpp	(revision 655)
@@ -58,9 +58,9 @@
   if (length < 10)
   {
-    fprintf( g_hTrace, "%-50s u(%d)  : %d\n", pSymbolName, length, rValue ); 
+    fprintf( g_hTrace, "%-50s u(%d)  : %u\n", pSymbolName, length, rValue ); 
   }
   else
   {
-    fprintf( g_hTrace, "%-50s u(%d) : %d\n", pSymbolName, length, rValue ); 
+    fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 
   }
   fflush ( g_hTrace );
@@ -77,5 +77,5 @@
 #endif
   fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
-  fprintf( g_hTrace, "%-50s ue(v) : %d\n", pSymbolName, rValue ); 
+  fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 
   fflush ( g_hTrace );
 }
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 655)
@@ -330,5 +330,4 @@
     }
   }
-#if H_MV5
 #if H_MV
   if ( pcPPS->getLayerId() > 0 )
@@ -344,5 +343,4 @@
   {  
 #endif
-#endif
   READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" );           pcPPS->setScalingListPresentFlag( uiCode ? true : false );
   if(pcPPS->getScalingListPresentFlag ())
@@ -350,8 +348,6 @@
     parseScalingList( pcPPS->getScalingList() );
   }
-#if H_MV5
-#if H_MV
-  }
-#endif
+#if H_MV
+  }
 #endif
 
@@ -430,10 +426,4 @@
   {
     Window &defDisp = pcVUI->getDefaultDisplayWindow();
-#if !H_MV5
-    READ_UVLC(   uiCode, "def_disp_win_left_offset" );                defDisp.setWindowLeftOffset  ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) );
-    READ_UVLC(   uiCode, "def_disp_win_right_offset" );               defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) );
-    READ_UVLC(   uiCode, "def_disp_win_top_offset" );                 defDisp.setWindowTopOffset   ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) );
-    READ_UVLC(   uiCode, "def_disp_win_bottom_offset" );              defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) );
-#else
 #if H_MV
     defDisp.setScaledFlag( false ); 
@@ -448,5 +438,4 @@
     READ_UVLC(   uiCode, "def_disp_win_bottom_offset" );              defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) );
 #endif
-#endif
   }
   TimingInfo *timingInfo = pcVUI->getTimingInfo();
@@ -471,12 +460,4 @@
   {
     READ_FLAG(   uiCode, "tiles_fixed_structure_flag");               pcVUI->setTilesFixedStructureFlag(uiCode);
-#if !H_MV5
-#if H_MV
-    if ( pcSPS->getLayerId() > 0 )
-    {
-      READ_FLAG( uiCode, "tile_boundaries_aligned_flag" ); pcVUI->setTileBoundariesAlignedFlag( uiCode == 1 );
-    }
-#endif
-#endif
     READ_FLAG(   uiCode, "motion_vectors_over_pic_boundaries_flag");  pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode);
     READ_FLAG(   uiCode, "restricted_ref_pic_lists_flag");            pcVUI->setRestrictedRefPicListsFlag(uiCode);
@@ -597,5 +578,4 @@
   READ_UVLC(     uiCode, "sps_seq_parameter_set_id" );           pcSPS->setSPSId( uiCode );
   assert(uiCode <= 15);
-#if H_MV5
 #if H_MV
   if ( pcSPS->getLayerId() > 0 )
@@ -606,5 +586,4 @@
   if ( pcSPS->getUpdateRepFormatFlag() )
   { 
-#endif
 #endif
   READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
@@ -619,8 +598,6 @@
   READ_UVLC (    uiCode, "pic_width_in_luma_samples" );          pcSPS->setPicWidthInLumaSamples ( uiCode    );
   READ_UVLC (    uiCode, "pic_height_in_luma_samples" );         pcSPS->setPicHeightInLumaSamples( uiCode    );
-#if H_MV5
-#if H_MV
-  }
-#endif
+#if H_MV
+  }
 #endif
   READ_FLAG(     uiCode, "conformance_window_flag");
@@ -628,5 +605,4 @@
   {
     Window &conf = pcSPS->getConformanceWindow();
-#if H_MV5
 #if H_MV
     // Needs to be scaled later, when ChromaFormatIdc is known. 
@@ -642,17 +618,9 @@
     READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
 #endif
-#else
-    READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
-    READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
-    READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
-    READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
-#endif
-  }
-
-#if H_MV5
+  }
+
 #if H_MV
   if ( pcSPS->getUpdateRepFormatFlag() )
   { 
-#endif
 #endif
   READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
@@ -665,8 +633,6 @@
   pcSPS->setBitDepthC( uiCode + 8 );
   pcSPS->setQpBDOffsetC( (Int) (6*uiCode) );
-#if H_MV5
-#if H_MV
-  }
-#endif
+#if H_MV
+  }
 #endif
 
@@ -692,9 +658,5 @@
     pcSPS->setNumReorderPics(uiCode, i);
 #if H_MV
-#if H_MV5
     READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
-#else
-    READ_UVLC ( uiCode, "sps_max_latency_increase[i]");
-#endif
 #else
     READ_UVLC ( uiCode, "sps_max_latency_increase_plus1");
@@ -736,5 +698,4 @@
   if(pcSPS->getScalingListFlag())
   {
-#if H_MV5
 #if H_MV
     if ( pcSPS->getLayerId() > 0 )
@@ -750,5 +711,4 @@
     {    
 #endif
-#endif
     READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" );                 pcSPS->setScalingListPresentFlag ( uiCode );
     if(pcSPS->getScalingListPresentFlag ())
@@ -756,8 +716,6 @@
       parseScalingList( pcSPS->getScalingList() );
     }
-#if H_MV5
-#if H_MV
-    }
-#endif
+#if H_MV
+    }
 #endif
   }
@@ -814,84 +772,4 @@
   if (uiCode)
   {
-#if !H_MV5
-#if !H_MV
-    while ( xMoreRbspData() )
-    {
-      READ_FLAG( uiCode, "sps_extension_data_flag");
-    }
-#else
-    READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" );    pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false);
-    ////   sps_extension_vui_parameters( )
-    if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() )
-    {  
-      READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); 
-      for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) 
-      {  
-        READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); 
-        if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) 
-        {  
-          READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); 
-          if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) )  
-          {
-            READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); 
-          }
-        }  
-      }  
-    }
-
-#if H_3D_QTLPC
-    if( depthFlag )
-    {
-      READ_FLAG( uiCode, "use_qtl_flag" );
-      pcSPS->setUseQTL( uiCode );
-      READ_FLAG( uiCode, "use_pc_flag" );
-      pcSPS->setUsePC( uiCode );
-    }
-#endif
-    ////   sps_extension_vui_parameters( ) END
-    READ_UVLC( uiCode, "sps_shvc_reserved_zero_idc" ); 
-    READ_FLAG( uiCode, "sps_extension2_flag");
-    if ( uiCode )
-    {
-#if !H_3D
-      while ( xMoreRbspData() )
-      {
-        READ_FLAG( uiCode, "sps_extension_data_flag");
-      }
-#else
-      
-      UInt uiCamParPrecision = 0; 
-      Bool bCamParSlice      = false; 
-      if ( !depthFlag )
-      {      
-        READ_UVLC( uiCamParPrecision, "cp_precision" );
-        READ_FLAG( uiCode, "cp_in_slice_header_flag" );    bCamParSlice = ( uiCode == 1 );
-        if( !bCamParSlice )
-        {       
-          for( UInt uiBaseIndex = 0; uiBaseIndex < viewIndex; uiBaseIndex++ )
-          {
-            Int iCode; 
-            READ_SVLC( iCode, "cp_scale" );                m_aaiTempScale  [ uiBaseIndex ][ viewIndex ]   = iCode;
-            READ_SVLC( iCode, "cp_off" );                  m_aaiTempOffset [ uiBaseIndex ][ viewIndex ]   = iCode;
-            READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale  [ viewIndex   ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ];
-            READ_SVLC( iCode, "cp_inv_off_plus_off" );     m_aaiTempOffset [ viewIndex   ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ];
-          }
-        }
-      }
-      pcSPS->initCamParaSPS( viewIndex, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset );
-      READ_FLAG( uiCode, "sps_extension3_flag");
-      if ( uiCode )
-      {
-        while ( xMoreRbspData() )
-        {
-          READ_FLAG( uiCode, "sps_extension_data_flag");
-        }
-      }
-#endif // !H_3D
-    }
-#endif // !H_MV
-  }
-}
-#else 
 #if H_MV
     parseSPSExtension( pcSPS ); 
@@ -918,6 +796,6 @@
   }
 }
-#endif
-#if H_MV5
+
+#if H_MV
 Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS )
 {
@@ -972,9 +850,5 @@
   READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
 #if H_MV
-#if H_MV5
   READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayersMinus1( uiCode  );
-#else
-  READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayers( uiCode + 1 );
-#endif
 #else
   READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
@@ -1061,223 +935,4 @@
   if (uiCode)
   {
-#if !H_MV5
-#if H_MV
-    m_pcBitstream->readOutTrailingBits();
-
-    READ_FLAG( uiCode, "avc_base_layer_flag" );                     pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false );
-    READ_FLAG( uiCode, "splitting_flag" );                          pcVPS->setSplittingFlag( uiCode == 1 ? true : false );
-
-    for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ )
-    {
-      READ_FLAG( uiCode,  "scalability_mask[i]" );                  pcVPS->setScalabilityMask( sIdx, uiCode == 1 ? true : false );      
-    }
-
-    for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ )
-    {
-        READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" );       pcVPS->setDimensionIdLen( sIdx, uiCode + 1 );
-    }
-
-    if ( pcVPS->getSplittingFlag() )
-      {
-      pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1, pcVPS->inferLastDimsionIdLenMinus1() );       
-      }
-
-    READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" );           pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false );
-
-    for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ )
-    {
-      if ( pcVPS->getVpsNuhLayerIdPresentFlag() && ( i > 0 ) )
-      {
-        READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" );                pcVPS->setLayerIdInNuh( i, uiCode );
-      }
-      else
-      {
-        pcVPS->setLayerIdInNuh( i, i );; 
-    }
-
-      pcVPS->setLayerIdInVps( pcVPS->getLayerIdInNuh( i ), i ); 
-    
-      for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) 
-    {
-        if ( !pcVPS->getSplittingFlag() )
-      {
-          READ_CODE( pcVPS->getDimensionIdLen( j ), uiCode, "dimension_id[i][j]" );  pcVPS->setDimensionId( i, j, uiCode );
-        }
-        else
-        {
-          pcVPS->setDimensionId( i, j, pcVPS->inferDimensionId( i, j)  );
-        }
-      }
-    }
-
-
-    for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ )
-    {
-      for( Int j = 0; j < i; j++ )
-      {
-        READ_FLAG( uiCode, "direct_dependency_flag[i][j]" );             pcVPS->setDirectDependencyFlag( i, j, uiCode );
-      }
-    }
-
-    for( Int i = 0; i < pcVPS->getMaxLayers() - 1; i++ )
-    {
-      READ_CODE( 3, uiCode,       "max_tid_il_ref_pics_plus1[i]" );      pcVPS->setMaxTidIlRefPicPlus1( i , uiCode ); 
-    }
-
-    READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1"      );  pcVPS->setVpsNumberLayerSetsMinus1    ( uiCode ); 
-    READ_CODE( 6,  uiCode, "vps_num_profile_tier_level_minus1" );  pcVPS->setVpsNumProfileTierLevelMinus1( uiCode );
-
-    for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ )
-    {
-      READ_FLAG(  uiCode, "vps_profile_present_flag[i]" );    pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 );
-      if( !pcVPS->getVpsProfilePresentFlag( i ) )
-      {
-        READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); pcVPS->setProfileRefMinus1( i, uiCode );
-      }
-      parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1);
-      if( !pcVPS->getVpsProfilePresentFlag( i ) )
-      {
-        TComPTL temp = *pcVPS->getPTL( i );
-        *pcVPS->getPTL( i ) = *pcVPS->getPTL( pcVPS->getProfileRefMinus1( i ) + 1 );
-        pcVPS->getPTL( i )->copyLevelFrom( &temp );
-      }
-    }
-
-    Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1; 
-
-    READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); pcVPS->setMoreOutputLayerSetsThanDefaultFlag( uiCode == 1 );
-
-    if ( pcVPS->getMoreOutputLayerSetsThanDefaultFlag( ) )
-    {
-      READ_CODE( 10, uiCode, "num_add_output_layer_sets_minus1"      ); pcVPS->setNumAddOutputLayerSetsMinus1( uiCode );
-      numOutputLayerSets += ( pcVPS->getNumAddOutputLayerSetsMinus1( ) + 1); 
-    }
-
-    if( numOutputLayerSets > 1)
-    {
-      READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); pcVPS->setDefaultOneTargetOutputLayerFlag(  uiCode == 1); 
-    }  
-
-    for( Int i = 1; i < numOutputLayerSets; i++ )
-    {
-      if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) )
-      {        
-        READ_UVLC( uiCode,      "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); 
-        for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ )
-        {
-          READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); 
-        }        
-      }
-      if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
-      {      
-        READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" );   pcVPS->setProfileLevelTierIdx( i , uiCode ); 
-      }
-    }
-
-    READ_FLAG( uiCode , "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag( uiCode == 1 ); 
-    READ_UVLC( uiCode,  "direct_dep_type_len_minus2"); pcVPS->setDirectDepTypeLenMinus2 ( uiCode ); 
-
-    for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ )
-    {
-      for( Int j = 0; j < i; j++ )
-      {
-        if (pcVPS->getDirectDependencyFlag( i, j) )
-        {        
-          READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2,  uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode);
-        }
-      }
-    }
-
-    READ_FLAG ( uiCode,                    "vps_shvc_reserved_zero_flag" ); 
-
-#if H_3D    
-    READ_FLAG( uiCode,  "vps_extension2_flag" );
-    if (uiCode)
-    {
-      m_pcBitstream->readOutTrailingBits();
-
-      for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ )
-      {
-
-#if H_3D_ARP
-        pcVPS->setUseAdvRP  ( i, 0 );
-        pcVPS->setARPStepNum( i, 1 );
-#endif  
-        if ( i != 0 )
-        {
-          if( !( pcVPS->getDepthId( i ) == 1 ) )
-          {
-#if H_3D_IV_MERGE
-                READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
-#endif
-#if H_3D_ARP
-                READ_FLAG( uiCode, "iv_res_pred_flag[i]"  );  pcVPS->setUseAdvRP  ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 );
-
-#endif
-#if H_3D_NBDV_REF
-                READ_FLAG( uiCode, "depth_refinement_flag[i]");    pcVPS->setDepthRefinementFlag  ( i, uiCode == 1 ? true : false );
-#endif
-#if H_3D_VSP
-                READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false );
-#endif
-          }
-          else
-          {
-
-            READ_FLAG( uiCode, "vps_depth_modes_flag[i]" );             pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false );
-            //          READ_FLAG( uiCode, "lim_qt_pred_flag[i]");                  pcVPS->setLimQtPreFlag     ( i, uiCode == 1 ? true : false ); 
-#if H_3D_DIM_DLT
-            if( pcVPS->getVpsDepthModesFlag( i ) )
-            {
-              READ_FLAG( uiCode, "dlt_flag[i]" );                       pcVPS->setUseDLTFlag( i, uiCode == 1 ? true : false );
-            }
-            if( pcVPS->getUseDLTFlag( i ) )
-            {
-              // decode mapping
-              UInt uiNumDepthValues;
-              // parse number of values in DLT
-              READ_UVLC(uiNumDepthValues, "num_depth_values_in_dlt[i]");
-
-              // parse actual DLT values
-              Int* aiIdx2DepthValue = (Int*) calloc(uiNumDepthValues, sizeof(Int));
-              for(Int d=0; d<uiNumDepthValues; d++)
-              {
-                READ_UVLC(uiCode, "dlt_depth_value[i][d]");
-                aiIdx2DepthValue[d] = (Int)uiCode;
-              }
-
-              pcVPS->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues);
-
-              // clean memory
-              free(aiIdx2DepthValue);
-            }
-#endif
-#if LGE_INTER_SDC_E0156
-            READ_FLAG( uiCode, "depth_inter_SDC_flag" );              pcVPS->setInterSDCFlag( i, uiCode ? true : false );
-#endif
-          }
-        }
-      }
-      READ_FLAG( uiCode, "iv_mv_scaling_flag");                       pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); 
-    }
-#endif
-    pcVPS->checkVPSExtensionSyntax(); 
-
-    pcVPS->setRefLayers(); 
-
-#else
-    while ( xMoreRbspData() )
-    {
-      READ_FLAG( uiCode, "vps_extension_data_flag");
-    }
-#endif    
-  }
-
-#if H_3D
-  pcVPS->initViewIndex(); 
-#endif
-  return;
-}
-#else
 #if H_MV
     m_pcBitstream->readOutTrailingBits();
@@ -1305,8 +960,7 @@
 #endif
   }
-}
-#endif
-
-#if H_MV5
+  return; 
+}
+
 #if H_MV
 Void TDecCavlc::parseVPSExtension( TComVPS* pcVPS )
@@ -1640,5 +1294,5 @@
         }
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
             READ_FLAG( uiCode, "depth_inter_SDC_flag" );              pcVPS->setInterSDCFlag( i, uiCode ? true : false );
 #endif
@@ -1648,5 +1302,4 @@
   READ_FLAG( uiCode, "iv_mv_scaling_flag");                       pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); 
 }
-#endif
 #endif
 
@@ -1680,5 +1333,4 @@
 #if H_MV
   vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId());
-#if H_MV5
   assert( vps != NULL );
   
@@ -1692,13 +1344,4 @@
   rpcSlice->setIsDepth  ( vps->getDepthId  ( rpcSlice->getLayerId() ) == 1 );
 #endif
-#else
-  assert(vps!=0);
-  rpcSlice->setVPS(vps);      
-  rpcSlice->setViewId   ( vps->getViewId   ( rpcSlice->getLayerIdInVps() )      );
-#if H_3D  
-  rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerIdInVps() )      );  
-  rpcSlice->setIsDepth  ( vps->getDepthId  ( rpcSlice->getLayerIdInVps() ) == 1 );
-#endif
-#endif
 #endif
   rpcSlice->setSPS(sps);
@@ -1747,5 +1390,4 @@
   {
 #if H_MV    
-#if H_MV5
     Int esb = 0; //Don't use i, otherwise will shadow something below
     if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
@@ -1762,12 +1404,4 @@
 
     for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++)    
-#else
-    if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 )
-    {
-      READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 );
-    }
-
-    for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)    
-#endif
 #else
     for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
@@ -1808,7 +1442,7 @@
       READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb");  
       Int iPOClsb = uiCode;
-      Int iPrevPOC = rpcSlice->getPrevPOC();
+      Int iPrevPOC = rpcSlice->getPrevTid0POC();
       Int iMaxPOClsb = 1<< sps->getBitsForPOC();
-      Int iPrevPOClsb = iPrevPOC%iMaxPOClsb;
+      Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1);
       Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb;
       Int iPOCmsb;
@@ -1833,5 +1467,4 @@
       }
       rpcSlice->setPOC              (iPOCmsb+iPOClsb);
-#if H_MV5
 #if H_MV
       if ( rpcSlice->getPocResetFlag() )  
@@ -1841,5 +1474,4 @@
 
       }      
-#endif
 #endif
       TComReferencePictureSet* rps;
@@ -1941,4 +1573,10 @@
             rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt);
             rps->setCheckLTMSBPresent(j,false);  
+            
+            // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present
+            if( j == offset+(numOfLtrp-numLtrpInSPS)-1 )
+            {
+              deltaPocMSBCycleLT = 0;
+            }
           }
           prevDeltaMSB = deltaPocMSBCycleLT;
@@ -1970,5 +1608,4 @@
     }
 #if H_MV
-#if H_MV5
     Int layerId       = rpcSlice->getLayerId(); 
     if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )    {   
@@ -1989,29 +1626,4 @@
       }  
     }
-#else
-    Int layerIdInVps       = rpcSlice->getLayerIdInVps(); 
-    if( rpcSlice->getLayerId() > 0 && vps->getNumDirectRefLayers( layerIdInVps ) > 0 )
-    {   
-      READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 );
-      if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerIdInVps ) > 1 )
-      {            
-        if( !vps->getMaxOneActiveRefLayerFlag())  
-        {
-          READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode );
-        }
-        for( Int i = 0; i < rpcSlice->getNumActiveRefLayerPics(); i++ )   
-        {
-          READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( i, uiCode );
-        }
-      }  
-    }
-
-    rpcSlice->setActiveMotionPredRefLayers( );
-
-    if( vps->getNumSamplePredRefLayers( layerIdInVps ) > 0  &&  rpcSlice->getNumActiveRefLayerPics() > 0 )
-    {
-      READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode == 1 );
-    }
-#endif
 #endif
     if(sps->getUseSAO())
@@ -2155,19 +1767,4 @@
     if ( rpcSlice->getEnableTMVPFlag() )
     {
-#if !H_MV5
-#if H_MV
-      if( rpcSlice->getLayerId() > 0 && rpcSlice->getNumActiveMotionPredRefLayers() > 0 )
-      {
-        READ_FLAG( uiCode, "alt_collocated_indication_flag" ); rpcSlice->setAltCollocatedIndicationFlag( uiCode == 1 );
-      }
-
-      if( rpcSlice->getAltCollocatedIndicationFlag() && rpcSlice->getNumActiveMotionPredRefLayers() > 1 ) 
-      {          
-        READ_UVLC( uiCode, "collocated_ref_layer_idx" ); rpcSlice->setCollocatedRefLayerIdx( uiCode );
-      }      
-      else 
-      {
-#endif
-#endif
       if ( rpcSlice->getSliceType() == B_SLICE )
       {
@@ -2191,9 +1788,4 @@
         rpcSlice->setColRefIdx(0);
       }
-#if !H_MV5
-#if H_MV
-      }
-#endif
-#endif
     }
     if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) )
@@ -2651,5 +2243,5 @@
 }
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
 Void TDecCavlc::parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 655)
@@ -76,5 +76,4 @@
   Void  parseQtRootCbf      ( UInt uiAbsPartIdx, UInt& uiQtRootCbf );
   Void  parseVPS            ( TComVPS* pcVPS );
-#if H_MV5
 #if H_MV
   Void  parseVPSExtension   ( TComVPS* pcVPS ); 
@@ -86,10 +85,7 @@
   Void  parseSPSExtension   ( TComSPS* pcSPS );  
 #endif
-#endif
 #if H_3D
-#if H_MV5
   Void  parseVPSExtension2  ( TComVPS* pcVPS ); 
   Void  parseSPSExtension2  ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag );
-#endif
   Void  parseSPS            ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag );
 #else
@@ -117,5 +113,5 @@
   Void  parseICFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   Void  parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void  parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
Index: trunk/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 655)
@@ -458,5 +458,5 @@
   m_pcEntropyDecoder->decodeARPW    ( pcCU , uiAbsPartIdx , uiDepth );  
 #endif  
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -525,5 +525,5 @@
   {
     case MODE_INTER:
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
       if( m_ppcCU[uiDepth]->getInterSDCFlag( 0 ) )
       {
@@ -534,5 +534,5 @@
 #endif
       xReconInter( m_ppcCU[uiDepth], uiDepth );
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
       }
 #endif
@@ -578,5 +578,5 @@
 }
 
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
 Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -895,9 +895,5 @@
   // get DC prediction for each segment
   Pel apDCPredValues[2];
-#if KWU_SDC_SIMPLE_DC_E0117
   m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
-#else
-  m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride);
-#endif
   
   // reconstruct residual based on mask + DC residuals
Index: trunk/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.h	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecCu.h	(revision 655)
@@ -118,5 +118,5 @@
   Void xReconIntraSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   Void xReconInterSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 655)
@@ -650,5 +650,5 @@
 #endif
   
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   if( pcCU->getInterSDCFlag( uiAbsPartIdx ) )
   {
@@ -683,5 +683,5 @@
 }
 
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
 Void TDecEntropy::decodeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 655)
@@ -91,5 +91,5 @@
   virtual Void parseICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   virtual Void parseInterSDCFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
   virtual Void parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) = 0;
@@ -170,5 +170,5 @@
   Void decodeICFlag            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   Void decodeInterSDCFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void decodeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
Index: trunk/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 655)
@@ -158,12 +158,10 @@
     rpcPic->setNumDdvCandPics(rpcPic->getDisCandRefPictures(iColPoc));
   }
-#endif
-#if MTK_NBDV_TN_FIX_E0172 
+
   if(pcSlice->getViewIndex() && !pcSlice->getIsDepth() && !pcSlice->isIntra()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
   {
     rpcPic->checkTemporalIVRef();
   }
-#endif
-#if MTK_TEXTURE_MRGCAND_BUGFIX_E0182
+
   if(pcSlice->getIsDepth())
   {
@@ -226,5 +224,5 @@
     rpcPic->destroyNonDBFilterInfo();
   }
-#if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
+#if H_3D
   rpcPic->compressMotion(2); 
 #endif
Index: trunk/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 655)
@@ -89,7 +89,4 @@
 #if H_3D_DIM_DMM
 , m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-#if !SEC_DMM2_E0146_HHIFIX
-, m_cDmm2DataSCModel          ( 1,             1,               NUM_DMM2_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
 , m_cDmm3DataSCModel          ( 1,             1,               NUM_DMM3_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
@@ -102,5 +99,5 @@
 #endif
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
 , m_cInterSDCFlagSCModel             ( 1,             1,  NUM_INTER_SDC_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cInterSDCResidualSCModel         ( 1,             1,  NUM_INTER_SDC_RESIDUAL_CTX       , m_contextModels + m_numContextModels, m_numContextModels)
@@ -179,7 +176,4 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM1_DATA );
-#if !SEC_DMM2_E0146_HHIFIX
-  m_cDmm2DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM2_DATA );
-#endif
   m_cDmm3DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM3_DATA );
 #endif
@@ -192,5 +186,5 @@
 #endif
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   m_cInterSDCFlagSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_INTER_SDC_FLAG );
   m_cInterSDCResidualSCModel.initBuffer   ( sliceType, qp, (UChar*)INIT_INTER_SDC_RESIDUAL );
@@ -255,7 +249,4 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
-#if !SEC_DMM2_E0146_HHIFIX
-  m_cDmm2DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM2_DATA );
-#endif
   m_cDmm3DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );
 #endif
@@ -268,5 +259,5 @@
 #endif
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   m_cInterSDCFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_FLAG );
   m_cInterSDCResidualSCModel.initBuffer   ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_RESIDUAL );
@@ -444,31 +435,5 @@
   ruiTabIdx = uiIdx;
 }
-#if !SEC_DMM2_E0146_HHIFIX
-Void TDecSbac::xParseDmm2Offset( Int& riOffset )
-{
-  Int iDeltaEnd = 0;
-  if( DMM2_DELTAEND_MAX > 0 )
-  {
-    UInt uiFlag = 0;
-    m_pcTDecBinIf->decodeBin( uiFlag, m_cDmm2DataSCModel.get(0, 0, 0) );
-
-    if( uiFlag )
-    {
-      UInt uiAbsValMinus1;
-      UInt uiSymbol;
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm2DataSCModel.get(0, 0, 0) ); uiAbsValMinus1  = uiSymbol;
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm2DataSCModel.get(0, 0, 0) ); uiAbsValMinus1 |= uiSymbol << 1;
-      iDeltaEnd = uiAbsValMinus1 + 1;
-      UInt uiSign;
-      m_pcTDecBinIf->decodeBinEP( uiSign );
-      if( uiSign )
-      {
-        iDeltaEnd = -iDeltaEnd;
-      }
-    }
-  }
-  riOffset = iDeltaEnd;
-}
-#endif
+
 Void TDecSbac::xParseDmm3WedgeIdx( UInt& ruiIntraIdx, Int iNumBit )
 {
@@ -1175,12 +1140,4 @@
       pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth );
     } break;
-#if !SEC_DMM2_E0146_HHIFIX
-  case( DMM2_IDX ):
-    {
-      Int iOffset = 0;
-      xParseDmm2Offset( iOffset );
-      pcCU->setDmm2DeltaEndSubParts( iOffset, absPartIdx, depth );
-    } break;
-#endif
   case( DMM3_IDX ):
     {
@@ -1250,7 +1207,4 @@
   if( puIdx == 2 )
   {
-#if !LGE_SDC_REMOVE_DC_E0158
-    while( binNum < 2 && symbol )
-#endif
     {
       ctxDepthMode = puIdx*3 + binNum;
@@ -1260,10 +1214,5 @@
     }
          if( modeCode == 0 ) { dir = PLANAR_IDX; sdcFlag = 1;}
-#if LGE_SDC_REMOVE_DC_E0158
     else if( modeCode == 1 ) { dir = 0;          sdcFlag = 0;}
-#else
-    else if( modeCode == 2 ) { dir = 0;          sdcFlag = 0;}
-    else if( modeCode == 3 ) { dir =     DC_IDX; sdcFlag = 1;}
-#endif
   }
   else if( puIdx == 0 )
@@ -1283,108 +1232,35 @@
   else
   {
-#if ZJU_DEPTH_INTRA_MODE_E0204
-      UInt maxBinNum = 0;
-      m_pcTDecBinIf->decodeBinEP(symbol);
-      if( symbol == 1 )
-      {
-          maxBinNum = 3;
-      }
-      else
-      {
-          maxBinNum = 2;
-          symbol = 1;
-      }
-      while( binNum<maxBinNum && symbol )
-      {
-          ctxDepthMode = puIdx*3 + ( binNum >= 2 ? 2 : binNum );
-          m_pcTDecBinIf->decodeBin(symbol,m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode));
-          modeCode = (modeCode<<1)+symbol;
-          binNum++;
-      }
-      if( maxBinNum == 3 )
-      {
-          if ( modeCode == 0 )       { dir =  PLANAR_IDX;             sdcFlag = 1;}
-          else if ( modeCode == 2 )  { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
-          else if ( modeCode == 6 )  { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;}
-          else if ( modeCode == 7 )  { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
-      }
-      else
-      {
-          if ( modeCode == 0 )       { dir = 5;                       sdcFlag = 0;}
-          else if ( modeCode == 2 )  { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;}
-          else if ( modeCode == 3 )  { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;}
-      }
-#else
-    ctxDepthMode = puIdx*3 ;
-    m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
-    modeCode = (modeCode<<1) + symbol;
-    if( !symbol )
-    {
-      ctxDepthMode = puIdx*3 + 1;
-      m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
-      modeCode = (modeCode<<1) + symbol;
-      if( symbol ) 
-      { 
-        ctxDepthMode = puIdx*3 + 2;
-        m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
-        modeCode = (modeCode<<1) + symbol;
-      }
+    UInt maxBinNum = 0;
+    m_pcTDecBinIf->decodeBinEP(symbol);
+    if( symbol == 1 )
+    {
+      maxBinNum = 3;
     }
     else
     {
-      ctxDepthMode = puIdx*3 + 1;
-      m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
-      modeCode = (modeCode<<1) + symbol;
-      if( !symbol ) 
-      { 
-        ctxDepthMode = puIdx*3 + 2;
-        m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
-        modeCode = (modeCode<<1) + symbol;
-      }
-      else
-      {
-        binNum = 0;
-#if LGE_SDC_REMOVE_DC_E0158
-#if !SEC_DMM2_E0146_HHIFIX
-        while( symbol && binNum < 2 )
-#endif
-#else
-#if SEC_DMM2_E0146_HHIFIX
-        while( symbol && binNum < 2 )
-#else
-        while( symbol && binNum < 3 )
-#endif
-#endif
-        {
-          ctxDepthMode = puIdx*3 + 2;
-          m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
-          modeCode = (modeCode<<1) + symbol;
-          binNum++;
-        }
-      }
-    }
-         if( modeCode == 0  ) { dir =  PLANAR_IDX;             sdcFlag = 1;}
-    else if( modeCode == 2  ) { dir = 5;                       sdcFlag = 0;}
-    else if( modeCode == 3  ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;}
-    else if( modeCode == 4  ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
-    else if( modeCode == 5  ) { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;}
-    else if( modeCode == 6  ) { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;}
-#if LGE_SDC_REMOVE_DC_E0158
-#if SEC_DMM2_E0146_HHIFIX
-    else if( modeCode == 7 )  { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
-#else
-    else if( modeCode == 14 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
-    else if( modeCode == 15 ) { dir = (2*DMM2_IDX+DIM_OFFSET); sdcFlag = 0;}
-#endif
-#else
-    else if( modeCode == 14 ) { dir =      DC_IDX;             sdcFlag = 1;}
-#if SEC_DMM2_E0146_HHIFIX
-    else if( modeCode == 15 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
-#else
-    else if( modeCode == 30 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
-    else if( modeCode == 31 ) { dir = (2*DMM2_IDX+DIM_OFFSET); sdcFlag = 0;}
-#endif
-#endif
-#endif
+      maxBinNum = 2;
+      symbol = 1;
+    }
+    while( binNum<maxBinNum && symbol )
+    {
+      ctxDepthMode = puIdx*3 + ( binNum >= 2 ? 2 : binNum );
+      m_pcTDecBinIf->decodeBin(symbol,m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode));
+      modeCode = (modeCode<<1)+symbol;
+      binNum++;
+    }
+    if( maxBinNum == 3 )
+    {
+      if ( modeCode == 0 )       { dir =  PLANAR_IDX;             sdcFlag = 1;}
+      else if ( modeCode == 2 )  { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
+      else if ( modeCode == 6 )  { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;}
+      else if ( modeCode == 7 )  { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
+    }
+    else
+    {
+      if ( modeCode == 0 )       { dir = 5;                       sdcFlag = 0;}
+      else if ( modeCode == 2 )  { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;}
+      else if ( modeCode == 3 )  { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;}
+    }
   }
   pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth );
@@ -2338,5 +2214,5 @@
 #endif
 
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
 Void TDecSbac::parseInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
Index: trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 655)
@@ -102,7 +102,4 @@
 #if H_3D_DIM_DMM
   Void  xParseDmm1WedgeIdx   ( UInt& ruiTabIdx, Int iNumBit );
-#if !SEC_DMM2_E0146_HHIFIX
-  Void  xParseDmm2Offset     ( Int& riOffset );
-#endif
   Void  xParseDmm3WedgeIdx   ( UInt& ruiIntraIdx, Int iNumBit );
 #endif
@@ -114,5 +111,5 @@
 #endif
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   Void  parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void  parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
@@ -216,7 +213,4 @@
 #if H_3D_DIM_DMM
   ContextModel3DBuffer m_cDmm1DataSCModel;
-#if !SEC_DMM2_E0146_HHIFIX
-  ContextModel3DBuffer m_cDmm2DataSCModel;
-#endif
   ContextModel3DBuffer m_cDmm3DataSCModel;
 #endif
@@ -229,5 +223,5 @@
 #endif
 #endif
-#if LGE_INTER_SDC_E0156
+#if H_3D_INTER_SDC
   ContextModel3DBuffer m_cInterSDCFlagSCModel;
   ContextModel3DBuffer m_cInterSDCResidualSCModel;
Index: trunk/source/Lib/TLibDecoder/TDecSlice.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSlice.h	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecSlice.h	(revision 655)
@@ -65,5 +65,4 @@
   TDecEntropy*    m_pcEntropyDecoder;
   TDecCu*         m_pcCuDecoder;
-  UInt            m_uiCurrSliceIdx;
 
   TDecSbac*       m_pcBufferSbacDecoders;   ///< line to store temporary contexts, one per column of tiles.
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 655)
@@ -347,10 +347,12 @@
 #endif
 #endif
+  m_associatedIRAPType = NAL_UNIT_INVALID;
   m_pocCRA = 0;
-  m_prevRAPisBLA = false;
   m_pocRandomAccess = MAX_INT;  
   m_prevPOC                = MAX_INT;
   m_bFirstSliceInPicture    = true;
   m_bFirstSliceInSequence   = true;
+  m_prevSliceSkipped = false;
+  m_skippedPOC = 0;
 #if H_MV
   m_layerId = 0;
@@ -436,9 +438,7 @@
   Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
 
-#if H_MV5
 #if H_MV
     assert( conformanceWindow   .getScaledFlag() ); 
     assert( defaultDisplayWindow.getScaledFlag() );
-#endif
 #endif
   for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 
@@ -518,9 +518,5 @@
   m_cCuDecoder.destroy();        
 #if H_MV 
-#if H_MV5
   TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 );  
-#else
-  TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer );  
-#endif
   TComSlice::markCurrPic( pcPic ); 
   TComSlice::markIvRefPicsAsUnused   ( m_ivPicLists, targetDecLayerIdSet, m_parameterSetManagerDecoder.getActiveVPS(), m_layerId, poc ); 
@@ -591,5 +587,4 @@
   assert (sps != 0);
 
-#if H_MV5
 #if H_MV
   TComVPS* vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
@@ -599,7 +594,4 @@
   if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
 #endif
-#else
-  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
-#endif
   {
     printf ("Parameter set activation failed!");
@@ -627,11 +619,7 @@
   m_apcSlicePilot->setSPS(sps);
 #if H_MV
-#if H_MV5
   m_apcSlicePilot->setVPS(vps);  
   sps->inferRepFormat  ( vps , m_layerId ); 
   sps->inferScalingList( m_parameterSetManagerDecoder.getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); 
-#else
-  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getActiveVPS() );
-#endif
 #endif
   pps->setSPS(sps);
@@ -695,16 +683,20 @@
 
 #if H_MV
-#if H_MV5
   m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 ); 
-#else
-  m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer ); 
-#endif
   m_apcSlicePilot->setLayerId( nalu.m_layerId );
 #endif
   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
+
+  // set POC for dependent slices in skipped pictures
+  if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 
+  {
+    m_apcSlicePilot->setPOC(m_skippedPOC);
+  }
+
+  m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA);
+  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
 
 #if H_MV  
   TComVPS* vps     = m_apcSlicePilot->getVPS();
-#if H_MV5
   Int layerId  = nalu.m_layerId;   
   setViewId   ( vps->getViewId   ( layerId )      );  
@@ -714,17 +706,10 @@
   m_ivPicLists->setVPS( vps ); 
 #endif
-#else
-  Int layerIdInVps = vps->getLayerIdInVps( nalu.m_layerId );  
-  setViewId   ( vps->getViewId   ( layerIdInVps )      );  
-#if H_3D
-  setViewIndex( vps->getViewIndex( layerIdInVps )      );  
-  setIsDepth  ( vps->getDepthId  ( layerIdInVps ) == 1 );  
-  m_ivPicLists->setVPS( vps ); 
-#endif
-#endif
 #endif
     // Skip pictures due to random access
     if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
     {
+    m_prevSliceSkipped = true;
+    m_skippedPOC = m_apcSlicePilot->getPOC();
       return false;
     }
@@ -732,6 +717,11 @@
     if (isSkipPictureForBLA(iPOCLastDisplay))
     {
+    m_prevSliceSkipped = true;
+    m_skippedPOC = m_apcSlicePilot->getPOC();
       return false;
     }
+
+  // clear previous slice skipped flag
+  m_prevSliceSkipped = false;
 
   //we should only get a different poc for a new picture (with CTU address==0)
@@ -763,5 +753,4 @@
 #endif
   // actual decoding starts here
-#if H_MV5
 #if H_MV
    // This part needs further testing !
@@ -771,5 +760,4 @@
    }
 #endif
-#endif
   xActivateParameterSets();
 
@@ -791,13 +779,28 @@
     m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
 #if H_MV
-#if H_MV5
     m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); 
-#else
-    m_apcSlicePilot->createAndApplyIvReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer ); 
-#endif
 #endif
     //  Get a new picture buffer
     xGetNewPicBuffer (m_apcSlicePilot, pcPic);
 
+    Bool isField = false;
+    Bool isTff = false;
+    
+    if(!m_SEIs.empty())
+    {
+      // Check if any new Picture Timing SEI has arrived
+      SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING);
+      if (pictureTimingSEIs.size()>0)
+      {
+        SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
+        isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2);
+        isTff =  (pictureTiming->m_picStruct == 1);
+      }
+    }
+    
+    //Set Field/Frame coding mode
+    m_pcPic->setField(isField);
+    m_pcPic->setTopField(isTff);
+    
     // transfer any SEI messages that have been received to the picture
     pcPic->setSEIs(m_SEIs);
@@ -938,8 +941,7 @@
   if (bNextSlice)
   {
-    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic );
+    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
     // Set reference list
 #if H_MV    
-#if H_MV5
     std::vector< TComPic* > tempRefPicLists[2];
     std::vector< Bool     > usedAsLongTerm [2];
@@ -948,7 +950,4 @@
     pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr);
     pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true ); 
-#else
-    pcSlice->setRefPicList( m_cListPic, m_refPicSetInterLayer, true );    
-#endif
 #if H_3D_ARP
     pcSlice->setARPStepNum();
@@ -978,6 +977,10 @@
 #if H_3D
     pcSlice->setIvPicLists( m_ivPicLists );         
-#if H_3D_IV_MERGE    
+#if H_3D_IV_MERGE
+#if H_3D_FCO
+    //assert( !getIsDepth() );
+#else
     assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
+#endif
 #endif    
 #endif
@@ -1037,5 +1040,4 @@
       pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
     }
-    pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip());
     if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
     {
@@ -1084,11 +1086,6 @@
   TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); 
   assert( vps != 0 ); 
-#if H_MV5
   m_cEntropyDecoder.decodeSPS( sps, vps->getViewIndex( m_layerId ), ( vps->getDepthId( m_layerId ) == 1 ) );
 #else
-  Int layerIdInVPS = vps->getLayerIdInVps( m_layerId ); 
-  m_cEntropyDecoder.decodeSPS( sps, vps->getViewIndex( layerIdInVPS ), ( vps->getDepthId( layerIdInVPS ) == 1 ) );
-#endif
-#else
   m_cEntropyDecoder.decodeSPS( sps );
 #endif
@@ -1099,8 +1096,6 @@
 {
   TComPPS* pps = new TComPPS();
-#if H_MV5
 #if H_MV
   pps->setLayerId( getLayerId() ); 
-#endif
 #endif
   m_cEntropyDecoder.decodePPS( pps );
@@ -1112,5 +1107,4 @@
   if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
   {
-#if H_MV5
 #if H_MV
     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) );
@@ -1118,11 +1112,7 @@
     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
 #endif
-#else
-    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );  
-#endif
   }
   else
   {
-#if H_MV5
 #if H_MV
     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) );
@@ -1130,7 +1120,4 @@
     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
 #endif
-#else
-    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
-#endif
     SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
     if (activeParamSets.size()>0)
@@ -1139,10 +1126,6 @@
       m_parameterSetManagerDecoder.applyPrefetchedPS();
       assert(seiAps->activeSeqParamSetId.size()>0);
-#if H_MV5
 #if H_MV
       if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0], m_layerId ))
-#else
-      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
-#endif
 #else
       if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
@@ -1221,5 +1204,6 @@
 Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
 {
-  if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
+  if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && 
+       m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
   {
     iPOCLastDisplay++;
@@ -1306,5 +1290,4 @@
 }
 
-#if H_MV5
 Void TDecTop::xResetPocInPicBuffer()
 {
@@ -1324,4 +1307,3 @@
 }
 #endif
-#endif
 //! \}
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 622)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 655)
@@ -176,6 +176,6 @@
   Int                     m_iMaxRefPicNum;
   
+  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
   Int                     m_pocCRA;            ///< POC number of the latest CRA picture
-  Bool                    m_prevRAPisBLA;      ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture
   Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
 
@@ -211,4 +211,7 @@
   Bool                    m_bFirstSliceInPicture;
   Bool                    m_bFirstSliceInSequence;
+  Bool                    m_prevSliceSkipped;
+  Int                     m_skippedPOC;
+
 #if H_MV
   // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer  
@@ -216,10 +219,6 @@
   Int                     m_viewId;
   TComPicLists*           m_ivPicLists;
-#if H_MV5
   std::vector<TComPic*>   m_refPicSetInterLayer0; 
   std::vector<TComPic*>   m_refPicSetInterLayer1; 
-#else
-  std::vector<TComPic*>   m_refPicSetInterLayer; 
-#endif
 #if H_3D
   Int                     m_viewIndex; 
@@ -279,7 +278,5 @@
   TComPic*  xGetPic( Int layerId, Int poc ); 
   Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag );  
-#if H_MV5
   Void      xResetPocInPicBuffer();
-#endif
 #else
   Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
