Index: trunk/source/Lib/TLibDecoder/AnnexBread.h
===================================================================
--- trunk/source/Lib/TLibDecoder/AnnexBread.h	(revision 649)
+++ trunk/source/Lib/TLibDecoder/AnnexBread.h	(revision 713)
@@ -65,5 +65,5 @@
   , m_Input(istream)
   {
-    istream.exceptions(std::istream::eofbit);
+    istream.exceptions(std::istream::eofbit | std::istream::badbit);
   }
 
Index: trunk/source/Lib/TLibDecoder/SEIread.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/SEIread.cpp	(revision 649)
+++ trunk/source/Lib/TLibDecoder/SEIread.cpp	(revision 713)
@@ -93,4 +93,9 @@
     fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n");
     break;
+#if Q0074_SEI_COLOR_MAPPING
+  case SEI::COLOR_MAPPING_INFO:
+    fprintf( g_hTrace, "===========Color Mapping Info SEI message ===========\n");
+    break;
+#endif
   case SEI::SOP_DESCRIPTION:
     fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
@@ -280,4 +285,10 @@
       xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize);
       break;
+#if Q0074_SEI_COLOR_MAPPING
+    case SEI::COLOR_MAPPING_INFO:
+      sei = new SEIColorMappingInfo;
+      xParseSEIColorMappingInfo((SEIColorMappingInfo&) *sei, payloadSize);
+      break;
+#endif
     case SEI::SOP_DESCRIPTION:
       sei = new SEISOPDescription;
@@ -518,21 +529,16 @@
 {
   UInt val; 
-  READ_CODE(4, val, "active_vps_id");      sei.activeVPSId = val; 
-  READ_FLAG( val, "full_random_access_flag");  sei.m_fullRandomAccessFlag = val ? true : false;
-  READ_FLAG( val, "no_param_set_update_flag"); sei.m_noParamSetUpdateFlag = val ? true : false;
+  READ_CODE(4, val, "active_video_parameter_set_id");   sei.activeVPSId = val; 
+  READ_FLAG(   val, "self_contained_cvs_flag");         sei.m_selfContainedCvsFlag = val ? true : false;
+  READ_FLAG(   val, "no_parameter_set_update_flag");    sei.m_noParameterSetUpdateFlag = val ? true : false;
   READ_UVLC(   val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val;
 
-  sei.activeSeqParamSetId.resize(sei.numSpsIdsMinus1 + 1);
+  sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
   for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
   {
-    READ_UVLC(val, "active_seq_param_set_id");  sei.activeSeqParamSetId[i] = val; 
-  }
-
-  UInt uibits = m_pcBitstream->getNumBitsUntilByteAligned(); 
-  
-  while(uibits--)
-  {
-    READ_FLAG(val, "alignment_bit");
-  }
+    READ_UVLC(val, "active_seq_parameter_set_id");      sei.activeSeqParameterSetId[i] = val; 
+  }
+
+  xParseByteAlign();
 }
 
@@ -812,8 +818,13 @@
     case 4:
       {
-        READ_CODE( 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedValue = val;
-        if( sei.m_cameraIsoSpeedValue == 255) //Extended_ISO
+        READ_CODE( 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedIdc = val;
+        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
         {
           READ_CODE( 32,   val,   "camera_iso_speed_value" );            sei.m_cameraIsoSpeedValue = val;
+        }
+        READ_CODE( 8, val, "exposure_index_idc" );                       sei.m_exposureIndexIdc = val;
+        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
+        {
+          READ_CODE( 32,   val,   "exposure_index_value" );              sei.m_exposureIndexValue = val;
         }
         READ_FLAG( val, "exposure_compensation_value_sign_flag" );       sei.m_exposureCompensationValueSignFlag = val;
@@ -837,4 +848,91 @@
   xParseByteAlign();
 }
+
+#if Q0074_SEI_COLOR_MAPPING
+Void SEIReader::xParseSEIColorMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/)
+{
+  UInt  uiVal;
+  Int   iVal;
+
+  READ_UVLC( uiVal, "colour_map_id" );          sei.m_colorMapId = uiVal;
+  READ_FLAG( uiVal, "colour_map_cancel_flag" ); sei.m_colorMapCancelFlag = uiVal;
+  if( !sei.m_colorMapCancelFlag ) 
+  {
+    READ_FLAG( uiVal, "colour_map_persistence_flag" );                sei.m_colorMapPersistenceFlag = uiVal;
+    READ_FLAG( uiVal, "colour_map_video_signal_type_present_flag" );  sei.m_colorMap_video_signal_type_present_flag = uiVal;
+    if ( sei.m_colorMap_video_signal_type_present_flag ) {
+      READ_FLAG( uiVal,     "colour_map_video_full_range_flag" );     sei.m_colorMap_video_full_range_flag = uiVal;
+      READ_CODE( 8, uiVal,  "colour_map_primaries" );                 sei.m_colorMap_primaries = uiVal;
+      READ_CODE( 8, uiVal,  "colour_map_transfer_characteristics" );  sei.m_colorMap_transfer_characteristics = uiVal;
+      READ_CODE( 8, uiVal,  "colour_map_matrix_coeffs" );             sei.m_colorMap_matrix_coeffs = uiVal;
+    }
+  }
+
+  READ_CODE( 5, uiVal,  "colour_map_coded_data_bit_depth" );  sei.m_colour_map_coded_data_bit_depth = uiVal;
+  READ_CODE( 5, uiVal,  "colour_map_target_bit_depth" );      sei.m_colour_map_target_bit_depth = uiVal;
+  READ_UVLC( uiVal, "colour_map_model_id" );                  sei.m_colorMapModelId = uiVal;
+
+  assert( sei.m_colorMapModelId == 0 );
+  
+  for( Int i=0 ; i<3 ; i++ )
+  {
+    READ_CODE( 8, uiVal, "num_input_pivots_minus1[i]" ); sei.m_num_input_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ;
+    sei.m_coded_input_pivot_value[i]   = new Int[ sei.m_num_input_pivots[i] ];
+    sei.m_target_input_pivot_value[i]  = new Int[ sei.m_num_input_pivots[i] ];
+    if( uiVal > 0 )
+    {
+      for ( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ )
+      {
+        READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_input_pivot_value[i][j]" );  sei.m_coded_input_pivot_value[i][j] = uiVal;
+        READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_input_pivot_value[i][j]" ); sei.m_target_input_pivot_value[i][j] = uiVal;
+      }
+    }
+    else
+    {
+      sei.m_coded_input_pivot_value[i][0]  = 0;
+      sei.m_target_input_pivot_value[i][0] = 0;
+      sei.m_coded_input_pivot_value[i][1]  = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ;
+      sei.m_target_input_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ;
+    }
+  }
+
+  READ_FLAG( uiVal,           "matrix_flag" ); sei.m_matrix_flag = uiVal;
+  if( sei.m_matrix_flag )
+  {
+    READ_CODE( 4, uiVal,         "log2_matrix_denom" ); sei.m_log2_matrix_denom = uiVal;
+    for ( Int i=0 ; i<3 ; i++ )
+    {
+      for ( Int j=0 ; j<3 ; j++ )
+      {
+        READ_SVLC( iVal,        "matrix_coef[i][j]" ); sei.m_matrix_coef[i][j] = iVal;
+      }
+    }
+  }
+
+  for ( Int i=0 ; i<3 ; i++ )
+  {
+    READ_CODE( 8, uiVal, "num_output_pivots_minus1[i]" ); sei.m_num_output_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ;
+    sei.m_coded_output_pivot_value[i]   = new Int[ sei.m_num_output_pivots[i] ];
+    sei.m_target_output_pivot_value[i]  = new Int[ sei.m_num_output_pivots[i] ];
+    if( uiVal > 0 )
+    {
+      for ( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ )
+      {
+        READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_output_pivot_value[i][j]" );  sei.m_coded_output_pivot_value[i][j] = uiVal;
+        READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_output_pivot_value[i][j]" ); sei.m_target_output_pivot_value[i][j] = uiVal;
+      }
+    }
+    else
+    {
+      sei.m_coded_output_pivot_value[i][0]  = 0;
+      sei.m_target_output_pivot_value[i][0] = 0;
+      sei.m_coded_output_pivot_value[i][1]  = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ;
+      sei.m_target_output_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ;
+    }
+  }
+
+  xParseByteAlign();
+}
+#endif
 
 Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize)
Index: trunk/source/Lib/TLibDecoder/SEIread.h
===================================================================
--- trunk/source/Lib/TLibDecoder/SEIread.h	(revision 649)
+++ trunk/source/Lib/TLibDecoder/SEIread.h	(revision 713)
@@ -90,4 +90,7 @@
   Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize);
   Void xParseSEIToneMappingInfo       (SEIToneMappingInfo& sei, UInt payloadSize);
+#if Q0074_SEI_COLOR_MAPPING
+  Void xParseSEIColorMappingInfo      (SEIColorMappingInfo& sei, UInt payloadSize);
+#endif
   Void xParseSEISOPDescription        (SEISOPDescription &sei, UInt payloadSize);
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 649)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 713)
@@ -39,4 +39,7 @@
 #include "SEIread.h"
 #include "TDecSlice.h"
+#if Q0048_CGS_3D_ASYMLUT
+#include "../TLibCommon/TCom3DAsymLUT.h"
+#endif
 
 //! \ingroup TLibDecoder
@@ -175,5 +178,9 @@
 }
 
-Void TDecCavlc::parsePPS(TComPPS* pcPPS)
+Void TDecCavlc::parsePPS(TComPPS* pcPPS
+#if Q0048_CGS_3D_ASYMLUT
+  , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID
+#endif
+  )
 {
 #if ENC_DEC_TRACE
@@ -348,4 +355,14 @@
       READ_FLAG( uiCode, "poc_reset_info_present_flag" );
       pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false);
+#if Q0048_CGS_3D_ASYMLUT
+      READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 
+      pcPPS->setCGSFlag( uiCode );
+      if( pcPPS->getCGSFlag() )
+      {
+        xParse3DAsymLUT( pc3DAsymLUT );
+        pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() );
+        pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() );
+      }
+#endif
 #endif
     }
@@ -599,5 +616,9 @@
   else
   {
+#if REP_FORMAT_FIX
+    pcSPS->setUpdateRepFormatFlag( false );
+#else
     pcSPS->setUpdateRepFormatFlag( true );
+#endif
   }
 #if O0096_REP_FORMAT_INDEX
@@ -681,9 +702,9 @@
     for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
     {
-      READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1");
+      READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]");
       pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
-      READ_UVLC ( uiCode, "sps_num_reorder_pics" );
+      READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" );
       pcSPS->setNumReorderPics(uiCode, i);
-      READ_UVLC ( uiCode, "sps_max_latency_increase_plus1");
+      READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
       pcSPS->setMaxLatencyIncrease( uiCode, i );
 
@@ -887,5 +908,5 @@
   READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
 #endif
-  READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode <= 6);
+  READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER);
   READ_FLAG(     uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
   assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
@@ -973,8 +994,16 @@
     }
   }
-  READ_FLAG( uiCode,  "vps_extension_flag" );
-  if (uiCode)
-  {
+
 #if VPS_EXTNS
+  READ_FLAG( uiCode,  "vps_extension_flag" );      pcVPS->setVpsExtensionFlag( uiCode ? true : false );
+
+  // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1.
+  if( pcVPS->getMaxLayers() > 1 )
+  {
+    assert( pcVPS->getVpsExtensionFlag() == true );
+  }
+
+  if( pcVPS->getVpsExtensionFlag()  )
+  {
     while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
     {
@@ -990,11 +1019,20 @@
       }
     }
-#else
+  }
+  else
+  {
+    // set default parameters when syntax elements are not present
+    defaultVPSExtension(pcVPS);    
+  }
+#else
+  READ_FLAG( uiCode,  "vps_extension_flag" );
+  if (uiCode)
+  {
     while ( xMoreRbspData() )
     {
       READ_FLAG( uiCode, "vps_extension_data_flag");
     }
-#endif
-  }
+  }
+#endif
 
   return;
@@ -1129,19 +1167,20 @@
 #endif
 #if VPS_TSLAYERS
-    READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false);
-    if (vps->getMaxTSLayersPresentFlag())
-    {
-        for(i = 0; i < vps->getMaxLayers(); i++)
-        {
-            READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode);
-        }
-    }
-    else
-    {
-        for( i = 0; i < vps->getMaxLayers(); i++)
-        {
-            vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
-        }
-    }
+  READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false);
+
+  if (vps->getMaxTSLayersPresentFlag())
+  {
+    for(i = 0; i < vps->getMaxLayers(); i++)
+    {
+      READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode);
+    }
+  }
+  else
+  {
+    for( i = 0; i < vps->getMaxLayers(); i++)
+    {
+      vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
+    }
+  }
 #endif
 #if N0120_MAX_TID_REF_PRESENT_FLAG
@@ -1250,13 +1289,32 @@
   }
 #else
+
+#if Q0165_NUM_ADD_OUTPUT_LAYER_SETS
+  if( vps->getNumLayerSets() > 1 )
+  {
+    READ_UVLC( uiCode, "num_add_output_layer_sets" );            vps->setNumAddOutputLayerSets( uiCode );
+    READ_CODE( 2, uiCode, "default_target_output_layer_idc" );   vps->setDefaultTargetOutputLayerIdc( uiCode );
+  }
+  else
+  {
+    vps->setNumAddOutputLayerSets( 0 );
+  }
+#else
   READ_UVLC( uiCode, "num_add_output_layer_sets" );          vps->setNumAddOutputLayerSets( uiCode );
+#endif
+
+  // The value of num_add_output_layer_sets shall be in the range of 0 to 1023, inclusive.
+  assert( vps->getNumAddOutputLayerSets() >= 0 && vps->getNumAddOutputLayerSets() < 1024 );
+
   Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets();
 #endif
 
 #if P0295_DEFAULT_OUT_LAYER_IDC
+#if !Q0165_NUM_ADD_OUTPUT_LAYER_SETS
   if( numOutputLayerSets > 1 )
   {
     READ_CODE( 2, uiCode, "default_target_output_layer_idc" );   vps->setDefaultTargetOutputLayerIdc( uiCode );
   }
+#endif
   vps->setNumOutputLayerSets( numOutputLayerSets );
 
@@ -1330,4 +1388,8 @@
       vps->setAltOuputLayerFlag(i, uiCode ? true : false);
     }
+#if Q0165_OUTPUT_LAYER_SET
+    assert( NumOutputLayersInOutputLayerSet[i]>0 );
+#endif
+
 #endif
   }
@@ -1431,4 +1493,53 @@
 
 #if REPN_FORMAT_IN_VPS
+#if Q0195_REP_FORMAT_CLEANUP
+  READ_UVLC( uiCode, "vps_num_rep_formats_minus1" );
+  vps->setVpsNumRepFormats( uiCode + 1 );
+
+  // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
+  assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 );
+
+  for(i = 0; i < vps->getVpsNumRepFormats(); i++)
+  {
+    // Read rep_format_structures
+    parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 );
+  }
+
+  // Default assignment for layer 0
+  vps->setVpsRepFormatIdx( 0, 0 );
+
+  if( vps->getVpsNumRepFormats() > 1 )
+  {
+    READ_FLAG( uiCode, "rep_format_idx_present_flag");
+    vps->setRepFormatIdxPresentFlag( uiCode ? true : false );
+  }
+  else
+  {
+    // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0
+    vps->setRepFormatIdxPresentFlag( false );
+  }
+
+  if( vps->getRepFormatIdxPresentFlag() )
+  {
+    for(i = 1; i < vps->getMaxLayers(); i++)
+    {
+      Int numBits = 1;
+      while ((1 << numBits) < (vps->getVpsNumRepFormats()))
+      {
+        numBits++;
+      }
+      READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" );
+      vps->setVpsRepFormatIdx( i, uiCode );
+    }
+  }
+  else
+  {
+    // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min (i, vps_num_rep_formats_minus1)
+    for(i = 1; i < vps->getMaxLayers(); i++)
+    {
+      vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats()-1 ) );
+    }
+  }
+#else
   READ_FLAG( uiCode, "rep_format_idx_present_flag");
   vps->setRepFormatIdxPresentFlag( uiCode ? true : false );
@@ -1453,8 +1564,12 @@
     vps->setVpsNumRepFormats( vps->getMaxLayers() );
   }
+
+  // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
+  assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 );
+
   for(i = 0; i < vps->getVpsNumRepFormats(); i++)
   {
     // Read rep_format_structures
-    parseRepFormat( vps->getVpsRepFormat(i) );
+    parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 );
   }
 
@@ -1498,4 +1613,5 @@
     }
   }
+#endif
 #endif
 #if RESOLUTION_BASED_DPB
@@ -1578,4 +1694,8 @@
 #if P0307_VPS_NON_VUI_EXTENSION
   READ_UVLC( uiCode,           "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode);
+
+  // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive.
+  assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 );
+
 #if P0307_VPS_NON_VUI_EXT_UPDATE
   Int nonVuiExtByte = uiCode;
@@ -1620,31 +1740,156 @@
 #endif
   }
-}
-#endif
+  else
+  {
+    // set default values for VPS VUI
+    defaultVPSVUI( vps );
+  }
+}
+
+Void TDecCavlc::defaultVPSExtension( TComVPS* vps )
+{
+  // set default parameters when they are not present
+  Int i, j;
+
+  // When layer_id_in_nuh[ i ] is not present, the value is inferred to be equal to i.
+  for(i = 0; i < vps->getMaxLayers(); i++)
+  {
+    vps->setLayerIdInNuh(i, i);
+    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
+  }
+
+  // When not present, sub_layers_vps_max_minus1[ i ] is inferred to be equal to vps_max_sub_layers_minus1.
+  for( i = 0; i < vps->getMaxLayers(); i++)
+  {
+    vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
+  }
+
+  // When not present, max_tid_il_ref_pics_plus1[ i ][ j ] is inferred to be equal to 7.
+  for( i = 0; i < vps->getMaxLayers() - 1; i++ )
+  {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+    for( j = i + 1; j < vps->getMaxLayers(); j++ )
+    {
+      vps->setMaxTidIlRefPicsPlus1(i, j, 7);
+    }
+#else
+    vps->setMaxTidIlRefPicsPlus1(i, 7);
+#endif
+  }
+  
+  // When not present, the value of num_add_output_layer_sets is inferred to be equal to 0.
+  // NumOutputLayerSets = num_add_output_layer_sets + vps_num_layer_sets_minus1 + 1
+  vps->setNumOutputLayerSets( vps->getNumLayerSets() );
+
+  // For i in the range of 0 to NumOutputLayerSets-1, inclusive, the variable LayerSetIdxForOutputLayerSet[ i ] is derived as specified in the following: 
+  // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : output_layer_set_idx_minus1[ i ] + 1
+  for( i = 1; i < vps->getNumOutputLayerSets(); i++ )
+  {
+    vps->setOutputLayerSetIdx( i, i );
+    Int lsIdx = vps->getOutputLayerSetIdx(i);
+
+    for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ )
+    {
+    vps->setOutputLayerFlag(i, j, 1);
+    }
+  }
+
+  // The value of sub_layer_dpb_info_present_flag[ i ][ 0 ] for any possible value of i is inferred to be equal to 1
+  // When not present, the value of sub_layer_dpb_info_present_flag[ i ][ j ] for j greater than 0 and any possible value of i, is inferred to be equal to be equal to 0.
+  for( i = 1; i < vps->getNumOutputLayerSets(); i++ )
+  {
+    vps->setSubLayerDpbInfoPresentFlag( i, 0, true );
+  }
+  
+  // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1.
+  vps->setVpsNumRepFormats( vps->getMaxLayers() );
+
+  // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0
+  vps->setRepFormatIdxPresentFlag( false );
+
+  if( !vps->getRepFormatIdxPresentFlag() )
+  {
+    // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min(i, vps_num_rep_formats_minus1). 
+    for(i = 1; i < vps->getMaxLayers(); i++)
+    {
+      vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats() - 1 ) );
+    }
+  }
+
+  // vps_poc_lsb_aligned_flag
+  // When not present, vps_poc_lsb_aligned_flag is inferred to be equal to 0.
+  
+#if O0062_POC_LSB_NOT_PRESENT_FLAG
+  // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0.
+  for(i = 1; i< vps->getMaxLayers(); i++)
+  {
+    vps->setPocLsbNotPresentFlag(i, 0);
+  }
+#endif
+
+  // set default values for VPS VUI
+  defaultVPSVUI( vps );
+}
+
+Void TDecCavlc::defaultVPSVUI( TComVPS* vps )
+{
+#if N0147_IRAP_ALIGN_FLAG
+  // When not present, the value of all_layers_idr_aligned_flag is inferred to be equal to 0.
+  vps->setCrossLayerIrapAlignFlag( false );
+#endif
+
+#if M0040_ADAPTIVE_RESOLUTION_CHANGE
+  // When single_layer_for_non_irap_flag is not present, it is inferred to be equal to 0.
+  vps->setSingleLayerForNonIrapFlag( false );
+#endif
+
+#if HIGHER_LAYER_IRAP_SKIP_FLAG
+  // When higher_layer_irap_skip_flag is not present it is inferred to be equal to 0
+  vps->setHigherLayerIrapSkipFlag( false );
+#endif
+}
+#endif
+
 #if REPN_FORMAT_IN_VPS
-Void  TDecCavlc::parseRepFormat      ( RepFormat *repFormat )
+Void  TDecCavlc::parseRepFormat( RepFormat *repFormat, RepFormat *repFormatPrev )
 {
   UInt uiCode;
-#if REPN_FORMAT_CONTROL_FLAG
-  READ_FLAG ( uiCode, "chroma_and_bit_depth_vps_present_flag");   repFormat->setChromaAndBitDepthVpsPresentFlag(uiCode ? true : false); 
-  READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" );          repFormat->setPicWidthVpsInLumaSamples ( uiCode );
-  READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" );         repFormat->setPicHeightVpsInLumaSamples( uiCode );
+#if REPN_FORMAT_CONTROL_FLAG  
+  READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" );        repFormat->setPicWidthVpsInLumaSamples ( uiCode );
+  READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" );       repFormat->setPicHeightVpsInLumaSamples( uiCode );
+  READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" );    repFormat->setChromaAndBitDepthVpsPresentFlag( uiCode ? true : false ); 
+
+  if( !repFormatPrev )
+  {
+    // The value of chroma_and_bit_depth_vps_present_flag of the first rep_format( ) syntax structure in the VPS shall be equal to 1
+    assert( repFormat->getChromaAndBitDepthVpsPresentFlag() );
+  }
 
   if( repFormat->getChromaAndBitDepthVpsPresentFlag() )
   {
+    READ_CODE( 2, uiCode, "chroma_format_vps_idc" );
 #if AUXILIARY_PICTURES
-    READ_CODE( 2, uiCode, "chroma_format_idc" );               repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) );
-#else
-    READ_CODE( 2, uiCode, "chroma_format_idc" );               repFormat->setChromaFormatVpsIdc( uiCode );
+    repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) );
+#else
+    repFormat->setChromaFormatVpsIdc( uiCode );
 #endif
 
     if( repFormat->getChromaFormatVpsIdc() == 3 )
     {
-      READ_FLAG( uiCode, "separate_colour_plane_flag");        repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false);
-    }
-
-
-    READ_CODE( 4, uiCode, "bit_depth_luma_minus8" );           repFormat->setBitDepthVpsLuma  ( uiCode + 8 );
-    READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" );         repFormat->setBitDepthVpsChroma( uiCode + 8 );
+      READ_FLAG( uiCode, "separate_colour_plane_vps_flag" );       repFormat->setSeparateColourPlaneVpsFlag( uiCode ? true : false );
+    }
+
+    READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" );           repFormat->setBitDepthVpsLuma  ( uiCode + 8 );
+    READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" );         repFormat->setBitDepthVpsChroma( uiCode + 8 );
+  }
+  else if( repFormatPrev )
+  {
+    // chroma_and_bit_depth_vps_present_flag equal to 0 specifies that the syntax elements, chroma_format_vps_idc, separate_colour_plane_vps_flag, bit_depth_vps_luma_minus8, and 
+    // bit_depth_vps_chroma_minus8 are not present and inferred from the previous rep_format( ) syntax structure in the VPS.
+
+    repFormat->setChromaFormatVpsIdc        ( repFormatPrev->getChromaFormatVpsIdc() );
+    repFormat->setSeparateColourPlaneVpsFlag( repFormatPrev->getSeparateColourPlaneVpsFlag() );
+    repFormat->setBitDepthVpsLuma           ( repFormatPrev->getBitDepthVpsLuma() );
+    repFormat->setBitDepthVpsChroma         ( repFormatPrev->getBitDepthVpsChroma() );
   }
 #else 
@@ -1700,5 +1945,5 @@
     READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]");  vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false );
 #if DPB_PARAMS_MAXTLAYERS
-      for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++)
+    for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++)
 #else
     for(Int j = 0; j <= vps->getMaxTLayers(); j++)
@@ -1820,5 +2065,5 @@
         if( parseFlag && vps->getBitRatePresentVpsFlag() )
         {
-          READ_FLAG( uiCode,        "bit_rate_present_vps_flag[i][j]" );  vps->setBitRatePresentFlag( i, j, uiCode ? true : false );
+          READ_FLAG( uiCode,        "bit_rate_present_flag[i][j]" );  vps->setBitRatePresentFlag( i, j, uiCode ? true : false );
         }
         else
@@ -1828,5 +2073,5 @@
         if( parseFlag && vps->getPicRatePresentVpsFlag() )
         {
-          READ_FLAG( uiCode,        "pic_rate_present_vps_flag[i][j]" );  vps->setPicRatePresentFlag( i, j, uiCode ? true : false );
+          READ_FLAG( uiCode,        "pic_rate_present_flag[i][j]" );  vps->setPicRatePresentFlag( i, j, uiCode ? true : false );
         }
         else
@@ -1868,5 +2113,4 @@
     vps->setNumVideoSignalInfo(vps->getMaxLayers());
   }
-
 
   for(i = 0; i < vps->getNumVideoSignalInfo(); i++)
@@ -1954,4 +2198,10 @@
 #if HIGHER_LAYER_IRAP_SKIP_FLAG
   READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false);
+
+  // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0
+  if( !vps->getSingleLayerForNonIrapFlag() )
+  {
+    assert( !vps->getHigherLayerIrapSkipFlag() );
+  }
 #endif
 #endif
@@ -2102,8 +2352,9 @@
   if( rpcSlice->getRapPicFlag())
   {
-#if !NO_OUTPUT_OF_PRIOR_PICS
-    READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored
-#else
-    READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  rpcSlice->setNoOutputOfPriorPicsFlag( uiCode ? true : false );
+    READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored -- updated already
+#if SETTING_NO_OUT_PIC_PRIOR
+    rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false);
+#else
+    rpcSlice->setNoOutputPicPrior( false );
 #endif
   }
@@ -2305,5 +2556,5 @@
         else
         {
-          uiCode = 0;
+          uiCode = 0;       
         }
         *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode));
@@ -2453,6 +2704,11 @@
             for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 
             {
+#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
+              if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
+                (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
+#else 
               if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
                 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
+#endif 
               {          
                 rpcSlice->setActiveNumILRRefIdx(1);
@@ -2487,6 +2743,11 @@
         {
 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS
+#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
+          if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
+            (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  rpcSlice->getTLayer()) )
+#else
           if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) >  rpcSlice->getTLayer()) &&
              (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  rpcSlice->getTLayer()) )
+#endif 
         {
 #endif
@@ -2514,6 +2775,11 @@
       for(i = 0, numRefLayerPics = 0;  i < rpcSlice->getNumILRRefIdx(); i++ ) 
       {
+#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
+        if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
+          (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
+#else 
         if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
            (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
+#endif 
         {          
           refLayerPicIdc[ numRefLayerPics++ ] = i;
@@ -2560,4 +2826,7 @@
       {
         format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc();
+#if Q0195_REP_FORMAT_CLEANUP
+         assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check
+#endif
       }
 #else
@@ -3468,4 +3737,65 @@
 }
 
+#if Q0048_CGS_3D_ASYMLUT
+Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
+{
+  UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit;
+  READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" ); 
+  READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" );     
+  READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" );
+  Int iInputBitDepthCDelta;
+  READ_SVLC(iInputBitDepthCDelta, "cm_input_bit_depth_chroma delta");
+  READ_CODE( 3 , uiOutputBitDepthM8 , "cm_output_bit_depth_minus8" ); 
+  Int iOutputBitDepthCDelta;
+  READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta");
+  READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" );
+  pc3DAsymLUT->destroy();
+  pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 ,  uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, uiOutputBitDepthM8 + 8 , uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta ,uiCurPartNumLog2 );
+  pc3DAsymLUT->setResQuantBit( uiResQaunBit );
+
+  xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
+}
+
+Void TDecCavlc::xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
+{
+  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
+  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
+    READ_FLAG( uiOctantSplit , "split_octant_flag" );
+  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
+  if( uiOctantSplit )
+  {
+    Int nHalfLength = nLength >> 1;
+    for( Int l = 0 ; l < 2 ; l++ )
+    {
+      for( Int m = 0 ; m < 2 ; m++ )
+      {
+        for( Int n = 0 ; n < 2 ; n++ )
+        {
+          xParse3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
+        }
+      }
+    }
+  }
+  else
+  {
+    for( Int l = 0 ; l < nYPartNum ; l++ )
+    {
+      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
+      {
+        UInt uiCodeVertex = 0;
+        Int deltaY = 0 , deltaU = 0 , deltaV = 0;
+        READ_FLAG( uiCodeVertex , "coded_vertex_flag" );
+        if( uiCodeVertex )
+        {
+          READ_SVLC( deltaY , "resY" );
+          READ_SVLC( deltaU , "resU" );
+          READ_SVLC( deltaV , "resV" );
+        }
+        pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV );
+      }
+    }
+  }
+}
+#endif
 //! \}
 
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 649)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 713)
@@ -46,4 +46,7 @@
 #include "SyntaxElementParser.h"
 
+#if Q0048_CGS_3D_ASYMLUT
+class TCom3DAsymLUT;
+#endif
 //! \ingroup TLibDecoder
 //! \{
@@ -75,11 +78,13 @@
 #if VPS_EXTNS
   Void  parseVPSExtension   ( TComVPS* pcVPS );
+  Void  defaultVPSExtension ( TComVPS* pcVPS );
 #endif
 
 #if VPS_VUI
   Void  parseVPSVUI   ( TComVPS* pcVPS );
+  Void  defaultVPSVUI ( TComVPS* pcVPS );
 #endif 
 #if REPN_FORMAT_IN_VPS
-  Void  parseRepFormat      ( RepFormat *repFormat );
+  Void  parseRepFormat      ( RepFormat *repFormat, RepFormat *repFormatPrev );
 #endif
 #if VPS_DPB_SIZE_TABLE
@@ -95,5 +100,9 @@
   Void  parseSPS            ( TComSPS* pcSPS );
 #endif //SVC_EXTENSION
-  Void  parsePPS            ( TComPPS* pcPPS);
+  Void  parsePPS            ( TComPPS* pcPPS
+#if Q0048_CGS_3D_ASYMLUT
+    , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID
+#endif
+    );
   Void  parseVUI            ( TComVUI* pcVUI, TComSPS* pcSPS );
   Void  parseSEI            ( SEIMessages& );
@@ -135,4 +144,9 @@
 protected:
   Bool  xMoreRbspData();
+
+#if Q0048_CGS_3D_ASYMLUT
+  Void xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
+  Void xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
+#endif
 };
 
Index: trunk/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 649)
+++ trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 713)
@@ -73,4 +73,11 @@
     m_ppcCU     [ui]->setLayerId(layerId);
   }
+  
+#if LAYER_CTB
+  memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) );
+  memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) );
+  memcpy(g_auiLayerRasterToPelX[m_layerId],  g_auiRasterToPelX,  sizeof( g_auiRasterToPelX ) );
+  memcpy(g_auiLayerRasterToPelY[m_layerId],  g_auiRasterToPelY,  sizeof( g_auiRasterToPelY ) );
+#endif
 }
 #else
@@ -715,5 +722,5 @@
 {
   UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
-  UInt  uiNumPart     = pcCU->getNumPartInter();
+  UInt  uiNumPart     = pcCU->getNumPartitions();
   UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
   
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 649)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 713)
@@ -49,4 +49,7 @@
 class TDecCavlc;
 class ParameterSetManagerDecoder;
+#if Q0048_CGS_3D_ASYMLUT
+class TCom3DAsymLUT;
+#endif
 
 //! \ingroup TLibDecoder
@@ -71,5 +74,9 @@
   virtual Void  parseSPS                  ( TComSPS* pcSPS )                                      = 0;
 #endif
-  virtual Void  parsePPS                  ( TComPPS* pcPPS )                                      = 0;
+  virtual Void  parsePPS                  ( TComPPS* pcPPS 
+#if Q0048_CGS_3D_ASYMLUT
+    , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID
+#endif
+    )                                      = 0;
 
   virtual Void parseSliceHeader          ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)       = 0;
@@ -138,5 +145,10 @@
   Void    decodeSPS                   ( TComSPS* pcSPS     )    { m_pcEntropyDecoderIf->parseSPS(pcSPS);                    }
 #endif
-  Void    decodePPS                   ( TComPPS* pcPPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS);                    }
+
+#if Q0048_CGS_3D_ASYMLUT
+  Void    decodePPS                   ( TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT, Int nLayerID )    { m_pcEntropyDecoderIf->parsePPS(pcPPS, pc3DAsymLUT , nLayerID );                     }
+#else
+  Void    decodePPS                   ( TComPPS* pcPPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS );  }
+#endif
   Void    decodeSliceHeader           ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)  { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager);         }
 
Index: trunk/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 649)
+++ trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 713)
@@ -248,5 +248,9 @@
   }
 
+#if SETTING_PIC_OUTPUT_MARK
+  rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false);
+#else
   rpcPic->setOutputMark(true);
+#endif
   rpcPic->setReconMark(true);
 }
Index: trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 649)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 713)
@@ -81,5 +81,9 @@
   Void  parseSPS                  ( TComSPS* /*pcSPS*/ ) {}
 #endif
-  Void  parsePPS                  ( TComPPS* /*pcPPS*/ ) {}
+  Void  parsePPS                  ( TComPPS* /*pcPPS*/ 
+#if Q0048_CGS_3D_ASYMLUT
+    , TCom3DAsymLUT * /*pc3DAsymLUT*/ , Int /*nLayerID*/
+#endif
+    ) {}
 
   Void  parseSliceHeader          ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/) {}
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 649)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 713)
@@ -79,14 +79,25 @@
   m_prevSliceSkipped = false;
   m_skippedPOC = 0;
+#if SETTING_NO_OUT_PIC_PRIOR
+  m_bFirstSliceInBitstream  = true;
+  m_lastPOCNoOutputPriorPics = -1;
+  m_craNoRaslOutputFlag = false;
+  m_isNoOutputPriorPics = false;
+#endif
 #if NO_CLRAS_OUTPUT_FLAG
   m_noClrasOutputFlag          = false;
   m_layerInitializedFlag       = false;
-  m_firstPicInLayerDecodedFlag = false;
-  m_noOutputOfPriorPicsFlags   = false;
-  m_bRefreshPending            = false;
+  m_firstPicInLayerDecodedFlag = false;  
 #endif
 #if RESOLUTION_BASED_DPB
   m_subDpbIdx = -1;
 #endif
+#if Q0048_CGS_3D_ASYMLUT
+  m_pColorMappedPic = NULL;
+#endif
+
+#if Q0074_SEI_COLOR_MAPPING
+  m_ColorMapping = new TDecColorMapping();
+#endif
 }
 
@@ -95,4 +106,15 @@
 #if ENC_DEC_TRACE
   fclose( g_hTrace );
+#endif
+#if Q0048_CGS_3D_ASYMLUT
+  if(m_pColorMappedPic)
+  {
+    m_pColorMappedPic->destroy();
+    delete m_pColorMappedPic;
+    m_pColorMappedPic = NULL;
+  }
+#endif
+#if Q0074_SEI_COLOR_MAPPING
+  if ( m_ColorMapping )  delete m_ColorMapping;
 #endif
 }
@@ -353,5 +375,12 @@
         Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
 
-        if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths )
+        if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths
+#if Q0048_CGS_3D_ASYMLUT
+          || pcSlice->getPPS()->getCGSFlag() > 0
+#endif
+#if LAYER_CTB
+          || pcTDecTopBase->getActiveSPS()->getMaxCUWidth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUWidth() || pcTDecTopBase->getActiveSPS()->getMaxCUHeight() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUHeight() || pcTDecTopBase->getActiveSPS()->getMaxCUDepth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUDepth()
+#endif
+          )
 #else
         if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets )
@@ -503,5 +532,4 @@
 
   // Execute Deblock + Cleanup
-
   m_cGopDecoder.filterPicture(pcPic);
 
@@ -517,4 +545,22 @@
   return;
 }
+
+#if SETTING_NO_OUT_PIC_PRIOR
+Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic)
+{
+  if (!rpcListPic || !m_isNoOutputPriorPics) return;
+
+  TComList<TComPic*>::iterator  iterPic   = rpcListPic->begin();
+
+  while (iterPic != rpcListPic->end())
+  {
+    TComPic*& pcPicTmp = *(iterPic++);
+    if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC())
+    {
+      pcPicTmp->setOutputMark(false);
+    }
+  }
+}
+#endif
 
 #if EARLY_REF_PIC_MARKING
@@ -733,4 +779,49 @@
 #endif
 
+#if AVC_BASE
+  if( activeVPS->getAvcBaseLayerFlag() )
+  {
+    TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
+    if( m_layerId == 1 && pBLPic->getPicYuvRec() == NULL )
+    {
+      UInt refLayerId = 0;
+      RepFormat* repFormat = activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(refLayerId) );
+
+      Int  numReorderPics[MAX_TLAYER];
+      Window conformanceWindow;
+      Window defaultDisplayWindow;
+
+#if AUXILIARY_PICTURES
+#if SVC_UPSAMPLING
+#if AVC_SYNTAX
+      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);
+#else
+      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
+#endif
+#else
+      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, true);
+#endif
+#else
+#if SVC_UPSAMPLING
+#if AVC_SYNTAX
+      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);
+#else
+      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
+#endif
+#else
+      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
+#endif
+#endif
+      // it is needed where the VPS is accessed through the slice
+      pBLPic->getSlice(0)->setVPS( activeVPS );
+
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+      g_bitDepthYLayer[0] = repFormat->getBitDepthVpsLuma();
+      g_bitDepthCLayer[0] = repFormat->getBitDepthVpsChroma();
+#endif
+    }
+  }
+#endif
+
 #if P0312_VERT_PHASE_ADJ
   if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 )
@@ -808,4 +899,11 @@
   g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
 
+#if Q0074_SEI_COLOR_MAPPING
+  for(Int compID=0; compID<3; compID++)
+  {
+    m_ColorMapping->setColorMapping( compID ? g_bitDepthC : g_bitDepthY, compID );
+  }
+#endif
+
   for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
   {
@@ -843,9 +941,4 @@
   TComPic*&   pcPic         = m_pcPic;
 #if SVC_EXTENSION
-#if !NO_OUTPUT_OF_PRIOR_PICS
-#if NO_CLRAS_OUTPUT_FLAG
-  Bool bFirstSliceInSeq;
-#endif
-#endif
   m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) );
 #if OUTPUT_LAYER_SET_INDEX
@@ -900,18 +993,57 @@
   m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
 
-#if NO_OUTPUT_OF_PRIOR_PICS
-  // Infer the value of NoOutputOfPriorPicsFlag
-  if( m_apcSlicePilot->getRapPicFlag() )
-  {
-    if ( m_apcSlicePilot->getBlaPicFlag() || m_apcSlicePilot->getIdrPicFlag()  || 
-        (m_apcSlicePilot->getCraPicFlag() && m_bFirstSliceInSequence) ||
-        (m_apcSlicePilot->getCraPicFlag() && m_apcSlicePilot->getHandleCraAsBlaFlag()))
-    {
-      m_apcSlicePilot->setNoRaslOutputFlag( true );
+#if SETTING_NO_OUT_PIC_PRIOR
+  //For inference of NoOutputOfPriorPicsFlag
+  if (m_apcSlicePilot->getRapPicFlag())
+  {
+    if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || 
+        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) ||
+        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag()))
+    {
+      m_apcSlicePilot->setNoRaslOutputFlag(true);
+    }
+    //the inference for NoOutputPriorPicsFlag
+    if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag())
+    {
+      if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
+      {
+        m_apcSlicePilot->setNoOutputPriorPicsFlag(true);
+      }
     }
     else
     {
-      m_apcSlicePilot->setNoRaslOutputFlag( false );
-    }
+      m_apcSlicePilot->setNoOutputPriorPicsFlag(false);
+    }
+
+    if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
+    {
+      m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag();
+    }
+  }
+  if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag())
+  {
+    m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC();
+    m_isNoOutputPriorPics = true;
+  }
+  else
+  {
+    m_isNoOutputPriorPics = false;
+  }
+
+  //For inference of PicOutputFlag
+  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R)
+  {
+    if ( m_craNoRaslOutputFlag )
+    {
+      m_apcSlicePilot->setPicOutputFlag(false);
+    }
+  }
+#endif
+
+#if FIX_POC_CRA_NORASL_OUTPUT
+  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
+  {
+    Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
+    m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
   }
 #endif
@@ -967,5 +1099,5 @@
   }
 
-  m_apcSlicePilot->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_cListPic, getNoClrasOutputFlag());
+  m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag );
 #endif
 
@@ -975,9 +1107,9 @@
     if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getNoRaslOutputFlag() )
     {
-      this->setNoOutputOfPriorPicsFlags( true );
+      this->setNoOutputPriorPicsFlag( true );
     }
     else if( m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag() )
     {
-      this->setNoOutputOfPriorPicsFlags( m_apcSlicePilot->getNoOutputOfPriorPicsFlag() );
+      this->setNoOutputPriorPicsFlag( m_apcSlicePilot->getNoOutputPriorPicsFlag() );
     }
     else
@@ -985,5 +1117,5 @@
       if( this->m_ppcTDecTop[0]->getNoClrasOutputFlag() )
       {
-        this->setNoOutputOfPriorPicsFlags( true );
+        this->setNoOutputPriorPicsFlag( true );
       }
     }
@@ -1006,5 +1138,5 @@
 #else
   //we should only get a different poc for a new picture (with CTU address==0)
-  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0))
+  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))
   {
     printf ("Warning, the first slice of a picture might have been lost!\n");
@@ -1050,10 +1182,8 @@
 #endif
   }
-#if !NO_OUTPUT_OF_PRIOR_PICS
-#if NO_CLRAS_OUTPUT_FLAG
-  bFirstSliceInSeq = m_bFirstSliceInSequence;
-#endif
-#endif
   m_bFirstSliceInSequence = false;
+#if SETTING_NO_OUT_PIC_PRIOR  
+  m_bFirstSliceInBitstream  = false;
+#endif
 #if POC_RESET_FLAG
   // This operation would do the following:
@@ -1216,50 +1346,5 @@
 #endif
 
-#if !NO_OUTPUT_OF_PRIOR_PICS
-#if NO_CLRAS_OUTPUT_FLAG
-    if (m_layerId == 0 &&
-        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
-      || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
-      || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
-      || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
-      || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
-      || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))
-    {
-      if (bFirstSliceInSeq)
-      {
-        setNoClrasOutputFlag(true);
-      }
-      else if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
-            || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
-            || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP)
-      {
-        setNoClrasOutputFlag(true);
-      }
-#if O0149_CROSS_LAYER_BLA_FLAG
-      else if ((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP) &&
-               m_apcSlicePilot->getCrossLayerBLAFlag())
-      {
-        setNoClrasOutputFlag(true);
-      }
-#endif
-      else
-      {
-        setNoClrasOutputFlag(false);
-      }
-      if (getNoClrasOutputFlag())
-      {
-        for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++)
-        {
-          m_ppcTDecTop[i]->setLayerInitializedFlag(false);
-          m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false);
-        }
-      }
-    }
-#endif
-
-#if NO_CLRAS_OUTPUT_FLAG
-    m_apcSlicePilot->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_cListPic, getNoClrasOutputFlag());
-#endif
-#else
+#if NO_OUTPUT_OF_PRIOR_PICS
     if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() )
     {
@@ -1273,8 +1358,8 @@
     // Buffer initialize for prediction.
     m_cPrediction.initTempBuff();
-#if !ALIGNED_BUMPING
+#if ALIGNED_BUMPING
+    m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic);
+#else
     m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
-#else
-    m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic);
 #endif
     //  Get a new picture buffer
@@ -1515,5 +1600,10 @@
         Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
         Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
-
+#if Q0200_CONFORMANCE_BL_SIZE
+        Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc();
+        const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getConformanceWindow(); 
+        widthBL  -= ( confBL.getWindowLeftOffset() + confBL.getWindowRightOffset() ) * TComSPS::getWinUnitX( chromaFormatIdc );
+        heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc );
+#endif
         Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
         Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
@@ -1525,23 +1615,46 @@
         g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
 
+#if Q0048_CGS_3D_ASYMLUT 
+        TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
+        if( pcSlice->getPPS()->getCGSFlag() )
+        {
+          if(!m_pColorMappedPic)
+          {
+            initAsymLut(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0));
+          }
+          m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),  m_pColorMappedPic );
+          pBaseColRec = m_pColorMappedPic;
+        }
+#endif
 #if SVC_UPSAMPLING
         if( pcPic->isSpatialEnhLayer(refLayerIdc) )
         {    
-/*#if O0098_SCALED_REF_LAYER_ID
-          Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
-#else
-          Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);
-#endif*/
 #if O0215_PHASE_ALIGNMENT
 #if O0194_JOINT_US_BITSHIFT
-          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
+#if Q0048_CGS_3D_ASYMLUT 
+          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
+#else
+          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
+#endif
+#else
+#if Q0048_CGS_3D_ASYMLUT 
+          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
 #else
           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
 #endif
+#endif
 #else
 #if O0194_JOINT_US_BITSHIFT
+#if Q0048_CGS_3D_ASYMLUT 
+          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
+#else
           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
+#endif
+#else
+#if Q0048_CGS_3D_ASYMLUT 
+          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
 #else
           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
+#endif
 #endif
 #endif
@@ -1755,5 +1868,9 @@
 }
 
-Void TDecTop::xDecodePPS()
+Void TDecTop::xDecodePPS(
+#if Q0048_CGS_3D_ASYMLUT
+  TCom3DAsymLUT * pc3DAsymLUT
+#endif
+  )
 {
   TComPPS* pps = new TComPPS();
@@ -1763,5 +1880,9 @@
 #endif
 
-  m_cEntropyDecoder.decodePPS( pps );
+  m_cEntropyDecoder.decodePPS( pps 
+#if Q0048_CGS_3D_ASYMLUT
+    , pc3DAsymLUT , m_layerId 
+#endif
+    );
   m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
 
@@ -1809,10 +1930,13 @@
       SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
       m_parameterSetManagerDecoder.applyPrefetchedPS();
-      assert(seiAps->activeSeqParamSetId.size()>0);
-      if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParamSetId[0] ) )
+      assert(seiAps->activeSeqParameterSetId.size()>0);
+      if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) )
       {
         printf ("Warning SPS activation with Active parameter set SEI failed");
       }
     }
+#if Q0074_SEI_COLOR_MAPPING
+    m_ColorMapping->setColorMapping( m_SEIs );
+#endif
   }
 #else
@@ -1837,6 +1961,6 @@
       SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
       m_parameterSetManagerDecoder.applyPrefetchedPS();
-      assert(seiAps->activeSeqParamSetId.size()>0);
-      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
+      assert(seiAps->activeSeqParameterSetId.size()>0);
+      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] ))
       {
         printf ("Warning SPS activation with Active parameter set SEI failed");
@@ -1897,49 +2021,12 @@
     case NAL_UNIT_SPS:
       xDecodeSPS();
-#if AVC_BASE
-      if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
-      {
-        TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
-        if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL )
-        {
-          // using EL SPS with spsId = 1
-          TComSPS* sps = m_parameterSetManagerDecoder.getPrefetchedSPS(1);
-          Int  numReorderPics[MAX_TLAYER];
-          Window &conformanceWindow = sps->getConformanceWindow();
-          Window defaultDisplayWindow = sps->getVuiParametersPresentFlag() ? sps->getVuiParameters()->getDefaultDisplayWindow() : Window();
-#if AUXILIARY_PICTURES
-#if SVC_UPSAMPLING
-#if AVC_SYNTAX
-          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
-#else
-          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
-#endif
-#else
-          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
-#endif
-#else
-#if SVC_UPSAMPLING
-#if AVC_SYNTAX
-          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
-#else
-          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
-#endif
-#else
-          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
-#endif
-#endif
-
-#if O0194_DIFFERENT_BITDEPTH_EL_BL
-          // set AVC BL bit depth, can be an input parameter from the command line
-          g_bitDepthYLayer[0] = 8;
-          g_bitDepthCLayer[0] = 8;
-#endif
-        }
-      }
-#endif
       return false;
 
     case NAL_UNIT_PPS:
-      xDecodePPS();
+      xDecodePPS(
+#if Q0048_CGS_3D_ASYMLUT
+        &m_c3DAsymLUTPPS
+#endif
+        );
       return false;
       
@@ -1997,4 +2084,6 @@
       return false;
       
+    case NAL_UNIT_FILLER_DATA:
+      return false;
       
     case NAL_UNIT_RESERVED_VCL_N10:
@@ -2017,5 +2106,4 @@
     case NAL_UNIT_RESERVED_VCL31:
       
-    case NAL_UNIT_FILLER_DATA:
     case NAL_UNIT_RESERVED_NVCL41:
     case NAL_UNIT_RESERVED_NVCL42:
@@ -2304,4 +2392,324 @@
 }
 #endif
+
+#if Q0048_CGS_3D_ASYMLUT
+Void TDecTop::initAsymLut(TComSlice *pcSlice)
+{
+  if(m_layerId>0)
+  {
+    if(!m_pColorMappedPic)
+    {
+      Int picWidth    = pcSlice->getPicWidthInLumaSamples();
+      Int picHeight   = pcSlice->getPicHeightInLumaSamples();
+      m_pColorMappedPic = new TComPicYuv;
+      m_pColorMappedPic->create( picWidth, picHeight, pcSlice->getChromaFormatIdc()/*CHROMA_420*/, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
+    }
+  }
+}
+#endif
+
 #endif //SVC_EXTENSION
+
+#if Q0074_SEI_COLOR_MAPPING
+TDecColorMapping::TDecColorMapping()
+{
+  m_pcColorMappingPic[0]   = NULL;
+  m_pcColorMappingPic[1]   = NULL;
+
+  m_colorMapCancelFlag  = true;
+
+  for( Int i=0 ; i<3 ; i++ )
+  {
+    m_lut1d_computed[i]             = false;
+    m_lut1d_input[i]                = NULL;
+    m_coded_input_pivot_value[i]    = NULL;
+    m_target_input_pivot_value[i]   = NULL;
+  }
+  for( Int i=0 ; i<3 ; i++ )
+  {
+    m_lut1d_output[i]               = NULL;
+    m_coded_output_pivot_value[i]   = NULL;
+    m_target_output_pivot_value[i]  = NULL;
+  }
+}
+
+TDecColorMapping::~TDecColorMapping()
+{
+  if ( m_pcColorMappingPic[0] )  delete m_pcColorMappingPic[0];
+  if ( m_pcColorMappingPic[1] )  delete m_pcColorMappingPic[1];
+
+  for( Int i=0 ; i<3 ; i++ )
+  {
+    if ( m_lut1d_input[i] )               delete  m_lut1d_input[i];
+    if ( m_coded_input_pivot_value[i] )   delete  m_coded_input_pivot_value[i];
+    if ( m_target_input_pivot_value[i] )  delete  m_target_input_pivot_value[i];
+  }
+  for( Int i=0 ; i<3 ; i++ )
+  {
+    if ( m_lut1d_output[i] )               delete  m_lut1d_output[i];
+    if ( m_coded_output_pivot_value[i] )   delete  m_coded_output_pivot_value[i];
+    if ( m_target_output_pivot_value[i] )  delete  m_target_output_pivot_value[i];
+  }
+}
+
+Void  TDecColorMapping::setColorMapping( SEIMessages m_SEIs )
+{
+  SEIMessages colorMappingInfo = getSeisByType(m_SEIs, SEI::COLOR_MAPPING_INFO) ;
+  SEIColorMappingInfo *seiColorMappingInfo = NULL;
+  if (colorMappingInfo.size() !=0)
+  {
+    seiColorMappingInfo = (SEIColorMappingInfo*)(*colorMappingInfo.begin());
+
+    m_colorMapId                              = seiColorMappingInfo->m_colorMapId;
+    m_colorMapCancelFlag                      = seiColorMappingInfo->m_colorMapCancelFlag;
+    if( !m_colorMapCancelFlag )
+    {
+      m_colorMapPersistenceFlag                 = seiColorMappingInfo->m_colorMapPersistenceFlag;
+      m_colorMap_video_signal_type_present_flag = seiColorMappingInfo->m_colorMap_video_signal_type_present_flag;
+      m_colorMap_video_full_range_flag          = seiColorMappingInfo->m_colorMap_video_full_range_flag;
+      m_colorMap_primaries                      = seiColorMappingInfo->m_colorMap_primaries;
+      m_colorMap_transfer_characteristics       = seiColorMappingInfo->m_colorMap_transfer_characteristics;
+      m_colorMap_matrix_coeffs                  = seiColorMappingInfo->m_colorMap_matrix_coeffs;
+      m_colorMapModelId                         = seiColorMappingInfo->m_colorMapModelId;
+
+      m_colour_map_coded_data_bit_depth         = seiColorMappingInfo->m_colour_map_coded_data_bit_depth;
+      m_colour_map_target_bit_depth             = seiColorMappingInfo->m_colour_map_target_bit_depth;
+
+      for( Int i=0 ; i<3 ; i++ )
+      {
+        m_num_input_pivots[i]                 = seiColorMappingInfo->m_num_input_pivots[i];
+        if ( m_coded_input_pivot_value[i] )   delete  m_coded_input_pivot_value[i];
+        if ( m_target_input_pivot_value[i] )  delete  m_target_input_pivot_value[i];
+        m_coded_input_pivot_value[i]          = new Int[ m_num_input_pivots[i] ];
+        m_target_input_pivot_value[i]         = new Int[ m_num_input_pivots[i] ];
+        for( Int j=0 ; j<m_num_input_pivots[i] ; j++ )
+        {
+          m_coded_input_pivot_value[i][j]     = seiColorMappingInfo->m_coded_input_pivot_value[i][j];
+          m_target_input_pivot_value[i][j]    = seiColorMappingInfo->m_target_input_pivot_value[i][j];
+        }
+      }
+
+      m_matrix_flag       = seiColorMappingInfo->m_matrix_flag;
+      m_log2_matrix_denom = m_matrix_flag ? (seiColorMappingInfo->m_log2_matrix_denom) : (0) ;
+      for( Int i=0 ; i<3 ; i++ )
+      {
+        for( Int j=0 ; j<3 ; j++ )
+        {
+          m_matrix_coef[i][j]  = seiColorMappingInfo->m_matrix_coef[i][j];
+        }
+      }
+
+      for( Int i=0 ; i<3 ; i++ )
+      {
+        m_num_output_pivots[i]                 = seiColorMappingInfo->m_num_output_pivots[i];
+        if ( m_coded_output_pivot_value[i] )   delete  m_coded_output_pivot_value[i];
+        if ( m_target_output_pivot_value[i] )  delete  m_target_output_pivot_value[i];
+        m_coded_output_pivot_value[i]          = new Int[ m_num_output_pivots[i] ];
+        m_target_output_pivot_value[i]         = new Int[ m_num_output_pivots[i] ];
+        for( Int j=0 ; j<m_num_output_pivots[i] ; j++ )
+        {
+          m_coded_output_pivot_value[i][j]     = seiColorMappingInfo->m_coded_output_pivot_value[i][j];
+          m_target_output_pivot_value[i][j]    = seiColorMappingInfo->m_target_output_pivot_value[i][j];
+        }
+      }
+
+      memset( m_lut1d_computed, 0, sizeof( m_lut1d_computed ) );
+    }
+  }
+
+}
+
+Void  TDecColorMapping::setColorMapping( Int bitDepth, Int iComp )
+{
+  if( !m_colorMapCancelFlag && !m_lut1d_computed[iComp] )
+  {
+
+    if ( m_lut1d_input[iComp] )   delete m_lut1d_input[iComp];
+    if ( m_lut1d_output[iComp] )  delete m_lut1d_output[iComp];
+
+    m_lut1d_input[iComp]  = new Int[ 1 << bitDepth ];
+    m_lut1d_output[iComp] = new Int[ 1 << bitDepth ];
+
+    Int iShift      = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0);
+    Int iShiftPivot = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_coded_data_bit_depth);
+
+    for( Int k=0 ; k<(1<<bitDepth) ; k++ )
+    {
+      Int iSample = k << iShift ;
+      if( m_num_input_pivots[iComp] > 1 )
+      {
+        for( Int iPivot=0 ; iPivot<m_num_input_pivots[iComp] ; iPivot++ )
+        {
+          Int iCodedPrev  = m_coded_input_pivot_value[iComp][iPivot]     << iShiftPivot;
+          Int iCodedNext  = m_coded_input_pivot_value[iComp][iPivot+1]   << iShiftPivot;
+          Int iTargetPrev = m_target_input_pivot_value[iComp][iPivot]    << iShiftPivot;
+          Int iTargetNext = m_target_input_pivot_value[iComp][iPivot+1]  << iShiftPivot;
+          if ( iCodedPrev <= iSample && iSample < iCodedNext )
+          {
+            Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;
+            m_lut1d_input[iComp][k]  = (Int)( 0.5 + fInterpol );
+            iPivot = m_num_input_pivots[iComp]; // stop
+          }
+        }
+      }
+      else
+      {
+        m_lut1d_input[iComp][k]  = k;
+      }
+    }
+
+    iShift      = ( (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0) );
+    Int iOffset = iShift ? (1 << (iShift - 1)) : (0) ;
+    iShiftPivot = (m_colour_map_target_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_target_bit_depth) ;
+    for( Int k=0 ; k<(1<<bitDepth) ; k++ )
+    {
+      Int iSample = k << iShift;
+      if ( m_num_output_pivots[iComp]>1 )
+      {
+        for( Int iPivot=0 ; iPivot<m_num_output_pivots[iComp] ; iPivot++ )
+        {
+          Int iCodedPrev  = m_coded_output_pivot_value[iComp][iPivot]     << iShiftPivot;
+          Int iCodedNext  = m_coded_output_pivot_value[iComp][iPivot+1]   << iShiftPivot;
+          Int iTargetPrev = m_target_output_pivot_value[iComp][iPivot]    << iShiftPivot;
+          Int iTargetNext = m_target_output_pivot_value[iComp][iPivot+1]  << iShiftPivot;
+          if ( iCodedPrev <= iSample && iSample < iCodedNext )
+          {
+            Float fInterpol =  (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;
+            m_lut1d_output[iComp][k]  = ( (Int)(0.5 + fInterpol) + iOffset ) >> iShift ;
+            iPivot = m_num_output_pivots[iComp]; // stop
+          }
+        }
+      }
+      else
+      {
+        m_lut1d_output[iComp][k]  = k;
+      }
+    }
+
+    m_lut1d_computed[iComp] = true;
+  }
+
+}
+
+TComPicYuv* TDecColorMapping::getColorMapping( TComPicYuv* pPicYuvRec, Int iTop, Int curlayerId )
+{
+  if( !m_colorMapCancelFlag )
+  {
+    if( !m_pcColorMappingPic[iTop] )
+    {
+      m_pcColorMappingPic[iTop] = new TComPicYuv;
+#if SVC_EXTENSION
+      m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), pPicYuvRec->getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
+#else
+      m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
+#endif
+    }
+
+    Int iHeight   = pPicYuvRec->getHeight();
+    Int iWidth    = pPicYuvRec->getWidth();
+    Int iStride   = pPicYuvRec->getStride();
+    Int iCStride  = pPicYuvRec->getCStride();
+
+    Pel* Lum0   = pPicYuvRec->getLumaAddr();
+    Pel* Cb0    = pPicYuvRec->getCbAddr();
+    Pel* Cr0    = pPicYuvRec->getCrAddr();
+    Pel* Lum1   = m_pcColorMappingPic[iTop]->getLumaAddr();
+    Pel* Cb1    = m_pcColorMappingPic[iTop]->getCbAddr();
+    Pel* Cr1    = m_pcColorMappingPic[iTop]->getCrAddr();
+
+#if SVC_EXTENSION
+    Int bitDepthY = g_bitDepthYLayer[curlayerId];
+    Int bitDepthC = g_bitDepthCLayer[curlayerId];
+
+    assert( g_bitDepthY == bitDepthY );
+    assert( g_bitDepthC == bitDepthC );
+#else
+    Int bitDepthY = g_bitDepthY;
+    Int bitDepthC = g_bitDepthC;
+#endif
+
+    Int iYShift = (m_colour_map_target_bit_depth >= bitDepthY) ? (m_colour_map_target_bit_depth - bitDepthY) : (0) ;
+    Int iCShift = (m_colour_map_target_bit_depth >= bitDepthC) ? (m_colour_map_target_bit_depth - bitDepthC) : (0) ;
+    Int offsetY = (1 << (m_log2_matrix_denom+iYShift - 1));
+    Int offsetC = (1 << (m_log2_matrix_denom+iCShift - 1));
+
+    Int   cShift  = 1 ;
+
+    //Pel*  LumPrev0 = Lum0;
+    for( Int y = 0; y < iHeight ; y++ )
+    {
+      Bool  bDoChroma = (y % 2);
+      for( Int x = 0; x < iWidth ; x++ )
+      {
+        Int s1Y = m_lut1d_input[0][ Lum0[x]   ];
+        Int s1U = m_lut1d_input[1][ Cb0[x>>1] ];
+        Int s1V = m_lut1d_input[2][ Cr0[x>>1] ];
+
+        Int s2Y, s2U, s2V;
+        if( m_matrix_flag )
+        {
+          s2Y = ( m_matrix_coef[0][0]*s1Y + m_matrix_coef[0][1]*s1U + m_matrix_coef[0][2]*s1V + offsetY ) >> ( m_log2_matrix_denom + iYShift );
+          //s2Y = ClipBD( s2Y , bitDepthY );
+          s2Y = ClipY( s2Y );
+          Lum1[x]   = m_lut1d_output[0][ s2Y ];
+        }
+        else
+        {
+          s1Y       = ( s1Y + offsetY ) >> iYShift ;
+          //s1Y = ClipBD( s1Y , bitDepthY );
+          s1Y = ClipY( s1Y );
+          Lum1[x]   = m_lut1d_output[0][ s1Y ];
+        }
+
+        if( bDoChroma && (x%2) )
+        {
+          if( m_matrix_flag )
+          {
+            //s1Y = ( m_lut1d_input[0][ Lum0[x] ] + m_lut1d_input[0][ Lum0[x+1] ] + m_lut1d_input[0][ LumPrev0[x] ] + m_lut1d_input[0][ LumPrev0[x+1] ] + 2 ) >> 2 ; 
+            //s1Y = m_lut1d_input[0][ (Lum0[x] + Lum0[x+1] + LumPrev0[x] + LumPrev0[x+1] + 2)>>2 ] ; 
+            s1Y = m_lut1d_input[0][ Lum0[x] ];
+
+            s2U = ( m_matrix_coef[1][0]*s1Y + m_matrix_coef[1][1]*s1U + m_matrix_coef[1][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;
+            s2V = ( m_matrix_coef[2][0]*s1Y + m_matrix_coef[2][1]*s1U + m_matrix_coef[2][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;
+            //s2U = ClipBD( s2U , bitDepthC );
+            //s2V = ClipBD( s2V , bitDepthC );
+            s2U = ClipC( s2U );
+            s2V = ClipC( s2V );
+            Cb1[x>>cShift] = m_lut1d_output[1][ s2U ];
+            Cr1[x>>cShift] = m_lut1d_output[2][ s2V ];
+          }
+          else
+          {
+            s1U       = ( s1U + offsetC ) >> iCShift ;
+            s1V       = ( s1V + offsetC ) >> iCShift ;
+            //s1U = ClipBD( s1U , bitDepthC );
+            //s1V = ClipBD( s1V , bitDepthC );
+            s1U = ClipC( s1U );
+            s1V = ClipC( s1V );
+            Cb1[x>>cShift] = m_lut1d_output[1][ s1U ];
+            Cr1[x>>cShift] = m_lut1d_output[2][ s1V ];
+          }
+        }
+
+      }
+
+      //LumPrev0 = Lum0;
+      Lum0  += iStride;
+      Lum1  += iStride;
+      if( bDoChroma )
+      {
+        Cb0 += iCStride;
+        Cr0 += iCStride;
+        Cb1 += iCStride;
+        Cr1 += iCStride;
+      }
+    }
+
+    return m_pcColorMappingPic[iTop];
+  }
+
+  return pPicYuvRec; 
+}
+#endif
+
 //! \}
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 649)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 713)
@@ -45,4 +45,7 @@
 #include "TLibCommon/TComTrQuant.h"
 #include "TLibCommon/SEI.h"
+#if Q0048_CGS_3D_ASYMLUT
+#include "TLibCommon/TCom3DAsymLUT.h"
+#endif
 
 #include "TDecGop.h"
@@ -61,4 +64,49 @@
 // ====================================================================================================================
 
+#if Q0074_SEI_COLOR_MAPPING
+class TDecColorMapping
+{
+  Int   m_colorMapId;
+  Bool  m_colorMapCancelFlag;
+  Bool  m_colorMapPersistenceFlag;
+  Bool  m_colorMap_video_signal_type_present_flag;
+  Bool  m_colorMap_video_full_range_flag;
+  Int   m_colorMap_primaries;
+  Int   m_colorMap_transfer_characteristics;
+  Int   m_colorMap_matrix_coeffs;
+  Int   m_colorMapModelId;
+
+  Int   m_colour_map_coded_data_bit_depth;
+  Int   m_colour_map_target_bit_depth;
+
+  Int   m_num_input_pivots[3];
+  Int*  m_coded_input_pivot_value[3];
+  Int*  m_target_input_pivot_value[3];
+  
+  Bool  m_matrix_flag;
+  Int   m_log2_matrix_denom;
+  Int   m_matrix_coef[3][3];
+
+  Int   m_num_output_pivots[3];
+  Int*  m_coded_output_pivot_value[3];
+  Int*  m_target_output_pivot_value[3];
+
+  Bool  m_lut1d_computed[3];
+  Int*  m_lut1d_input[3];
+  Int*  m_lut1d_output[3];
+  TComPicYuv* m_pcColorMappingPic[2];
+
+public:
+  TDecColorMapping();
+  ~TDecColorMapping();
+
+  Bool        getColorMappingFlag()                     { return(!m_colorMapCancelFlag);};
+
+  Void        setColorMapping( SEIMessages m_SEIs );
+  Void        setColorMapping( Int bitDepthY, Int bitDepthC );
+  TComPicYuv* getColorMapping( TComPicYuv* pPicYuvRec, Int iTop=0, Int curlayerId=0 );
+};// END CLASS DEFINITION TDecColorMapping
+#endif
+
 /// decoder class
 class TDecTop
@@ -79,4 +127,8 @@
   // functional classes
   TComPrediction          m_cPrediction;
+#if Q0048_CGS_3D_ASYMLUT
+  TCom3DAsymLUT           m_c3DAsymLUTPPS;
+  TComPicYuv*             m_pColorMappedPic;
+#endif
   TComTrQuant             m_cTrQuant;
   TDecGop                 m_cGopDecoder;
@@ -104,4 +156,10 @@
   Bool                    m_prevSliceSkipped;
   Int                     m_skippedPOC;
+#if SETTING_NO_OUT_PIC_PRIOR  
+  Bool                    m_bFirstSliceInBitstream;
+  Int                     m_lastPOCNoOutputPriorPics;
+  Bool                    m_isNoOutputPriorPics;
+  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
+#endif
 
 #if SVC_EXTENSION
@@ -114,6 +172,8 @@
 #if AVC_BASE
   fstream*                m_pBLReconFile;
+#if !REPN_FORMAT_IN_VPS
   Int                     m_iBLSourceWidth;
-  Int                     m_iBLSourceHeight;  
+  Int                     m_iBLSourceHeight;
+#endif
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
@@ -136,17 +196,18 @@
 #endif
 
-#if NO_CLRAS_OUTPUT_FLAG
+#if NO_CLRAS_OUTPUT_FLAG  
   Bool                    m_noClrasOutputFlag;
   Bool                    m_layerInitializedFlag;
   Bool                    m_firstPicInLayerDecodedFlag;
-  Bool                    m_noOutputOfPriorPicsFlags;
-
-  Bool                   m_bRefreshPending;
 #endif
 #if RESOLUTION_BASED_DPB
-  Int                    m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
-                                          // When new VPS is activated, this should be re-initialized to -1
+  Int                     m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
+                                           // When new VPS is activated, this should be re-initialized to -1
 #endif
 public:
+#if Q0074_SEI_COLOR_MAPPING
+  TDecColorMapping* m_ColorMapping;
+#endif
+
   TDecTop();
   virtual ~TDecTop();
@@ -166,5 +227,15 @@
   Void  deletePicBuffer();
 
+  
+  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
+
+
   Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
+#if SETTING_NO_OUT_PIC_PRIOR  
+  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
+  Bool  getNoOutputPriorPicsFlag ()         { return m_isNoOutputPriorPics; }
+  Void  setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; }
+#endif
+
 #if SVC_EXTENSION
 #if EARLY_REF_PIC_MARKING
@@ -212,7 +283,9 @@
   Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
   fstream*  getBLReconFile() { return m_pBLReconFile; }
+#if !REPN_FORMAT_IN_VPS
   Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
   Int       getBLWidth() { return  m_iBLSourceWidth; }
   Int       getBLHeight() { return  m_iBLSourceHeight; }
+#endif
 #endif
 #if REPN_FORMAT_IN_VPS
@@ -238,10 +311,4 @@
   Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
   fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
-#endif
-#if NO_OUTPUT_OF_PRIOR_PICS
-#if NO_CLRAS_OUTPUT_FLAG
-  Bool getNoOutputOfPriorPicsFlags()         { return m_noOutputOfPriorPicsFlags;}
-  Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
-#endif
 #endif
 protected:
@@ -261,5 +328,9 @@
   Void      xDecodeVPS();
   Void      xDecodeSPS();
-  Void      xDecodePPS();
+  Void      xDecodePPS(
+#if Q0048_CGS_3D_ASYMLUT
+    TCom3DAsymLUT * pc3DAsymLUT
+#endif
+    );
   Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
 
@@ -271,8 +342,7 @@
   Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
   Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
-#if !NO_OUTPUT_OF_PRIOR_PICS
-  Int  getNoOutputOfPriorPicsFlags()         { return m_noOutputOfPriorPicsFlags;}
-  Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
-#endif
+#endif
+#if Q0048_CGS_3D_ASYMLUT
+  Void initAsymLut(TComSlice *pcSlice);
 #endif
 };// END CLASS DEFINITION TDecTop
