Index: branches/SHM-6-dev/source/Lib/TLibDecoder/SEIread.cpp
===================================================================
--- branches/SHM-6-dev/source/Lib/TLibDecoder/SEIread.cpp	(revision 693)
+++ branches/SHM-6-dev/source/Lib/TLibDecoder/SEIread.cpp	(revision 694)
@@ -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;
@@ -838,4 +849,91 @@
 }
 
+#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: branches/SHM-6-dev/source/Lib/TLibDecoder/SEIread.h
===================================================================
--- branches/SHM-6-dev/source/Lib/TLibDecoder/SEIread.h	(revision 693)
+++ branches/SHM-6-dev/source/Lib/TLibDecoder/SEIread.h	(revision 694)
@@ -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: branches/SHM-6-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-6-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 693)
+++ branches/SHM-6-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 694)
@@ -96,4 +96,8 @@
   m_pColorMappedPic = NULL;
 #endif
+
+#if Q0074_SEI_COLOR_MAPPING
+  m_ColorMapping = new TDecColorMapping();
+#endif
 }
 
@@ -110,4 +114,7 @@
     m_pColorMappedPic = NULL;
   }
+#endif
+#if Q0074_SEI_COLOR_MAPPING
+  if ( m_ColorMapping )  delete m_ColorMapping;
 #endif
 }
@@ -846,4 +853,11 @@
   g_uiMaxCUDepth  = sps->getMaxCUDepth();
   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++)
@@ -1876,4 +1890,7 @@
       }
     }
+#if Q0074_SEI_COLOR_MAPPING
+    m_ColorMapping->setColorMapping( m_SEIs );
+#endif
   }
 #else
@@ -2386,4 +2403,310 @@
 }
 #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));
+
+    Bool  bScaleX = false ;
+    Bool  bScaleY = false ;
+    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: branches/SHM-6-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/SHM-6-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 693)
+++ branches/SHM-6-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 694)
@@ -64,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;
+  UChar m_colorMap_primaries;
+  UChar m_colorMap_transfer_characteristics;
+  UChar m_colorMap_matrix_coeffs;
+  UChar 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
@@ -159,4 +204,8 @@
 #endif
 public:
+#if Q0074_SEI_COLOR_MAPPING
+  TDecColorMapping* m_ColorMapping;
+#endif
+
   TDecTop();
   virtual ~TDecTop();
