Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 855)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 856)
@@ -115,4 +115,9 @@
   ("TarDecLayerIdSetFile,l", cfg_TargetDecLayerIdSetFile, string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
   ("RespectDefDispWindow,w", m_respectDefDispWindow, 0, "Only output content inside the default display window\n")
+#if Q0074_COLOUR_REMAPPING_SEI
+  ("SEIColourRemappingInfo", m_colourRemapSEIEnabled, false, "Control handling of Colour Remapping Information SEI messages\n"
+                                              "\t1: apply colour remapping on decoded pictures if available in the bitstream\n"
+                                              "\t0: ignore SEI message")
+#endif
   ;
   po::setDefaults(opts);
Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 855)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 856)
@@ -69,4 +69,7 @@
   Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
   Int           m_decodedPictureHashSEIEnabled;       ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
+#if Q0074_COLOUR_REMAPPING_SEI
+  Bool          m_colourRemapSEIEnabled;              ///< Enable the Colour Remapping Information SEI message if available (remapping decoded pictures)
+#endif
 
 #if SVC_EXTENSION
@@ -98,4 +101,7 @@
   , m_iMaxTemporalLayer(-1)
   , m_decodedPictureHashSEIEnabled(0)
+#if Q0074_COLOUR_REMAPPING_SEI
+  , m_colourRemapSEIEnabled(0)
+#endif
 #if SVC_EXTENSION
   , m_tgtLayerId(0)
Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 855)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 856)
@@ -568,4 +568,7 @@
     m_acTDecTop[layer].init();
     m_acTDecTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
+#if Q0074_COLOUR_REMAPPING_SEI
+    m_acTDecTop[layer].setColourRemappingInfoSEIEnabled(m_colourRemapSEIEnabled);
+#endif
     m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
 #if OUTPUT_LAYER_SET_INDEX
@@ -573,8 +576,10 @@
 #endif
   }
-
 #else
   m_cTDecTop.init();
   m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
+#if Q0074_COLOUR_REMAPPING_SEI
+  m_cTDecTop.setColourRemappingInfoSEIEnabled(m_colourRemapSEIEnabled);
+#endif
 #endif
 }
@@ -675,11 +680,4 @@
           TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
           TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
-#if Q0074_SEI_COLOR_MAPPING
-          if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
-          {
-            pPicCYuvRecTop = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0, layerId );
-            pPicCYuvRecBot = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1, layerId );
-          }
-#endif
 #if REPN_FORMAT_IN_VPS
           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
@@ -710,11 +708,4 @@
           TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
           TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
-#if Q0074_SEI_COLOR_MAPPING
-          if ( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
-          {
-            pPicCYuvRecTop = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0 );
-            pPicCYuvRecBot = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1 );
-          }
-#endif
           m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
@@ -791,11 +782,4 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
           TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
-#if Q0074_SEI_COLOR_MAPPING
-          if ( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
-          {
-            pPicCYuvRec = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerId );
-          }
-#endif
-
 #if REPN_FORMAT_IN_VPS
           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
@@ -898,11 +882,4 @@
           TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
           TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
-#if Q0074_SEI_COLOR_MAPPING
-          if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
-          {
-            pPicCYuvRecTop = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0, layerId );
-            pPicCYuvRecBot = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1, layerId );
-          }
-#endif
 #if REPN_FORMAT_IN_VPS
           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
@@ -933,11 +910,4 @@
           TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
           TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
-#if Q0074_SEI_COLOR_MAPPING
-          if( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
-          {
-            pPicCYuvRecTop = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0 );
-            pPicCYuvRecBot = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1 );
-          }
-#endif
           m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
@@ -1017,10 +987,4 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
           TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
-#if Q0074_SEI_COLOR_MAPPING
-          if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
-          {
-            pPicCYuvRec = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerId );
-          }
-#endif
 #if REPN_FORMAT_IN_VPS
           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
@@ -1049,10 +1013,4 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
           TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
-#if Q0074_SEI_COLOR_MAPPING
-          if( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
-          {
-            pPicCYuvRec = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRec );
-          }
-#endif
           m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
@@ -1137,7 +1095,4 @@
 #endif
     TComPicYuv* pPicCYuvRec = pic->getPicYuvRec();
-#if Q0074_SEI_COLOR_MAPPING
-    pPicCYuvRec = m_acTDecTop[layerIdx].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerIdx );
-#endif
     m_acTVideoIOYuvReconFile[layerIdx].write( pPicCYuvRec,
       conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 855)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 856)
@@ -91,4 +91,13 @@
   m_codedPivotValue = NULL;
   m_targetPivotValue = NULL;
+#if Q0074_COLOUR_REMAPPING_SEI
+  for( Int c=0 ; c<3 ; c++)
+  {
+    m_colourRemapSEIPreLutCodedValue[c]   = NULL;
+    m_colourRemapSEIPreLutTargetValue[c]  = NULL;
+    m_colourRemapSEIPostLutCodedValue[c]  = NULL;
+    m_colourRemapSEIPostLutTargetValue[c] = NULL;
+  }
+#endif
 }
 #endif
@@ -128,4 +137,25 @@
   free(m_pchReconFile);
   free(m_pchdQPFile);
+#if Q0074_COLOUR_REMAPPING_SEI
+  for( Int c=0 ; c<3 ; c++)
+  {
+    if ( m_colourRemapSEIPreLutCodedValue[c] )
+    {
+      delete[] m_colourRemapSEIPreLutCodedValue[c];
+    }
+    if ( m_colourRemapSEIPreLutTargetValue[c] )
+    {
+      delete[] m_colourRemapSEIPreLutTargetValue[c];
+    }
+    if ( m_colourRemapSEIPostLutCodedValue[c] )
+    {
+      delete[] m_colourRemapSEIPostLutCodedValue[c];
+    }
+    if ( m_colourRemapSEIPostLutTargetValue[c] )
+    {
+      delete[] m_colourRemapSEIPostLutTargetValue[c];
+    }
+  }
+#endif
 #endif
   free(m_scalingListFile);
@@ -335,8 +365,4 @@
   string* cfg_ReconFile      [MAX_LAYERS];
   Double* cfg_fQP            [MAX_LAYERS];
-#if Q0074_SEI_COLOR_MAPPING
-  string* cfg_seiColorMappingFile[MAX_LAYERS];
-#endif
-
 #if REPN_FORMAT_IN_VPS
   Int*    cfg_repFormatIdx  [MAX_LAYERS];
@@ -448,4 +474,7 @@
 #endif
   Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS]; 
+#if Q0074_COLOUR_REMAPPING_SEI
+  string* cfg_colourRemapSEIFile[MAX_LAYERS];
+#endif
   for(UInt layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -453,4 +482,7 @@
     cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
     cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
+#if Q0074_COLOUR_REMAPPING_SEI
+    cfg_colourRemapSEIFile[layer] = &m_acLayerCfg[layer].m_colourRemapSEIFile;
+#endif
 #if REPN_FORMAT_IN_VPS
     cfg_repFormatIdx[layer] = &m_acLayerCfg[layer].m_repFormatIdx;
@@ -461,7 +493,4 @@
     cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod; 
     cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
-#if Q0074_SEI_COLOR_MAPPING
-    cfg_seiColorMappingFile[layer] = &m_acLayerCfg[layer].m_cSeiColorMappingFile;
-#endif
 #if LAYER_CTB
     // coding unit (CU) definition
@@ -562,4 +591,7 @@
   string cfg_ReconFile;
   string cfg_dQPFile;
+#if Q0074_COLOUR_REMAPPING_SEI
+  string cfg_colourRemapSEIFile;
+#endif
 #endif //SVC_EXTENSION
   string cfgColumnWidth;
@@ -573,4 +605,5 @@
   string cfg_kneeSEIOutputKneePointValue;
 #endif
+
   po::Options opts;
   opts.addOptions()
@@ -665,4 +698,7 @@
   ("VertPhasePositionEnableFlag%d", cfg_vertPhasePositionEnableFlagPtr,string(""), MAX_LAYERS, "VertPhasePositionEnableFlag for layer %d")
 #endif
+#if Q0074_COLOUR_REMAPPING_SEI
+  ("SEIColourRemappingInfoFile%d", cfg_colourRemapSEIFile, string(""), MAX_LAYERS, "Colour Remapping Information SEI parameters file name for layer %d")
+#endif
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
   ("InputBitDepth%d",       cfg_InputBitDepthY,    8, MAX_LAYERS, "Bit-depth of input file for layer %d")
@@ -691,7 +727,4 @@
 #endif
   ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
-#if Q0074_SEI_COLOR_MAPPING
-  ("SEIColorMappingFile%d", cfg_seiColorMappingFile, string(""), MAX_LAYERS, "File Containing SEI Color Mapping data")
-#endif
 #else //SVC_EXTENSION
   ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
@@ -724,4 +757,7 @@
   ("ConfWinBottom",         m_confWinBottom,          0, "Bottom offset for window conformance mode 3")
   ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
+#if Q0074_COLOUR_REMAPPING_SEI
+  ("SEIColourRemappingInfoFile", cfg_colourRemapSEIFile, string(""), "Colour Remapping Information SEI parameters file name")
+#endif
 #endif //SVC_EXTENSION
   ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
@@ -1171,5 +1207,9 @@
   m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
   m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
-#endif //SVC_EXTENSION 
+#if Q0074_COLOUR_REMAPPING_SEI
+  m_colourRemapSEIFile = cfg_colourRemapSEIFile.empty() ? NULL : strdup(cfg_colourRemapSEIFile.c_str());
+#endif
+#endif //SVC_EXTENSION
+
 
   Char* pColumnWidth = cfgColumnWidth.empty() ? NULL: strdup(cfgColumnWidth.c_str());
@@ -1953,5 +1993,163 @@
   }
 #endif
-
+#if Q0074_COLOUR_REMAPPING_SEI
+#if !SVC_EXTENSION
+  // reading external Colour Remapping Information SEI message parameters from file
+  if( m_colourRemapSEIFile.c_str() )
+  {
+    FILE* fic;
+    Int retval;
+    if((fic = fopen(m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)
+    {
+      fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str());
+      exit(EXIT_FAILURE);
+    }
+
+    retval = fscanf( fic, "%d", &m_colourRemapSEIId );
+    retval = fscanf( fic, "%d", &m_colourRemapSEICancelFlag );
+    if( !m_colourRemapSEICancelFlag )
+    {
+      retval = fscanf( fic, "%d", &m_colourRemapSEIPersistenceFlag );
+      retval = fscanf( fic, "%d", &m_colourRemapSEIVideoSignalTypePresentFlag);
+      if( m_colourRemapSEIVideoSignalTypePresentFlag )
+      {
+        retval = fscanf( fic, "%d", &m_colourRemapSEIVideoFullRangeFlag  );
+        retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries );
+        retval = fscanf( fic, "%d", &m_colourRemapSEITransferCharacteristics );
+        retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoeffs );
+      }
+
+      retval = fscanf( fic, "%d", &m_colourRemapSEICodedDataBitDepth );
+      retval = fscanf( fic, "%d", &m_colourRemapSEITargetBitDepth );
+  
+      for( Int c=0 ; c<3 ; c++ )
+      {
+        retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] );
+        if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
+        {
+          m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
+          m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
+          for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
+          {
+            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] );
+            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] );
+          }
+        }
+      }
+
+      retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixPresentFlag );
+      if( m_colourRemapSEIMatrixPresentFlag )
+      {
+        retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom );
+        for( Int c=0 ; c<3 ; c++ )
+          for( Int i=0 ; i<3 ; i++ )
+            retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] );
+      }
+
+      for( Int c=0 ; c<3 ; c++ )
+      {
+        retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] );
+        if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
+        {
+          m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
+          m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
+          for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
+          {
+            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] );
+            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] );
+          }
+        }
+      }
+    }
+
+    fclose( fic );
+    if( retval != 1 )
+    {
+      fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
+      exit(EXIT_FAILURE);
+    }
+  }
+#else
+   // Reading external Colour Remapping Information SEI message parameters from file
+  // It seems that TAppEncLayerCfg::parseCfg is not used
+  for(UInt layer = 0; layer < m_numLayers; layer++)
+  {
+    if( cfg_colourRemapSEIFile[layer]->c_str() )
+    {
+      FILE* fic;
+      Int retval;
+      if((fic = fopen(cfg_colourRemapSEIFile[layer]->c_str(),"r")) == (FILE*)NULL)
+      {
+        fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", cfg_colourRemapSEIFile[layer]->c_str());
+        exit(EXIT_FAILURE);
+      }
+
+      retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIId );
+      retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEICancelFlag );
+      if( !m_acLayerCfg[layer].m_colourRemapSEICancelFlag )
+      {
+        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag );
+        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIVideoSignalTypePresentFlag);
+        if( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalTypePresentFlag )
+        {
+          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIVideoFullRangeFlag  );
+          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPrimaries );
+          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEITransferCharacteristics );
+          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIMatrixCoeffs );
+        }
+
+        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEICodedDataBitDepth );
+        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEITargetBitDepth );
+  
+        for( Int c=0 ; c<3 ; c++ )
+        {
+          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c] );
+          if( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]>0 )
+          {
+            m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]+1];
+            m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue[c] = new Int[m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]+1];
+            for( Int i=0 ; i<=m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
+            {
+              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue[c][i] );
+              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue[c][i] );
+            }
+          }
+        }
+
+        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag );
+        if( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag )
+        {
+          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom );
+          for( Int c=0 ; c<3 ; c++ )
+            for( Int i=0 ; i<3 ; i++ )
+              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEICoeffs[c][i] );
+        }
+
+        for( Int c=0 ; c<3 ; c++ )
+        {
+          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c] );
+          if( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]>0 )
+          {
+            m_acLayerCfg[layer].m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]+1];
+            m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue[c] = new Int[m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]+1];
+            for( Int i=0 ; i<=m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
+            {
+              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutCodedValue[c][i] );
+              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue[c][i] );
+            }
+          }
+        }
+      }
+
+      fclose( fic );
+      if( retval != 1 )
+      {
+        fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
+        exit(EXIT_FAILURE);
+      }
+    }
+  }
+#endif
+#endif
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
   if (m_interLayerConstrainedTileSetsSEIEnabled)
@@ -3044,4 +3242,37 @@
   }
 #endif
+#if Q0074_COLOUR_REMAPPING_SEI
+#if !SVC_EXTENSION
+  if ( m_colourRemapSEIFile.c_str() && !m_colourRemapSEICancelFlag )
+  {
+    xConfirmPara( m_colourRemapSEICodedDataBitDepth < 8 || m_colourRemapSEICodedDataBitDepth > 16 , "colour_remap_coded_data_bit_depth shall be in the range of 8 to 16, inclusive");
+    xConfirmPara( m_colourRemapSEITargetBitDepth < 8 || (m_colourRemapSEITargetBitDepth > 16 && m_colourRemapSEITargetBitDepth < 255) , "colour_remap_target_bit_depth shall be in the range of 8 to 16, inclusive");
+    for( Int c=0 ; c<3 ; c++)
+    {
+      xConfirmPara( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
+      if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
+        for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
+        {
+          xConfirmPara( m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_colourRemapSEICodedDataBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_coded_data_bit_depth)-1, inclusive");
+          xConfirmPara( m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_colourRemapSEITargetBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
+        }
+      xConfirmPara( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
+      if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
+        for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
+        {
+          xConfirmPara( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_colourRemapSEITargetBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
+          xConfirmPara( m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_colourRemapSEITargetBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
+        }
+    }
+    if ( m_colourRemapSEIMatrixPresentFlag )
+    {
+      xConfirmPara( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
+      for( Int c=0 ; c<3 ; c++)
+        for( Int i=0 ; i<3 ; i++)
+          xConfirmPara( m_colourRemapSEICoeffs[c][i] < -32768 || m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");
+    }
+  }
+#endif
+#endif
 
 #if RC_SHVC_HARMONIZATION
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 855)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 856)
@@ -220,5 +220,5 @@
   Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
   Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
-  Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty) 
+  Int       m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty) 
   Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
   Int       m_iSearchRange;                                   ///< ME search range
@@ -250,7 +250,5 @@
   Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
 #endif
-
   Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
-  
   Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
   Int       m_recoveryPointSEIEnabled;
@@ -284,7 +282,4 @@
   Int*      m_codedPivotValue;
   Int*      m_targetPivotValue;
-#if Q0074_SEI_COLOR_MAPPING
-  Char*     m_pchSEIColorMappingFile;             ///< SEI Color Mapping File (initialized from external file)
-#endif
   Int       m_framePackingSEIEnabled;
   Int       m_framePackingSEIType;
@@ -373,4 +368,28 @@
   Int       m_elRapSliceBEnabled;
 #endif
+#if Q0074_COLOUR_REMAPPING_SEI
+#if !SVC_EXTENSION
+  string    m_colourRemapSEIFile;
+  Int       m_colourRemapSEIId;
+  Bool      m_colourRemapSEICancelFlag;
+  Bool      m_colourRemapSEIPersistenceFlag;
+  Bool      m_colourRemapSEIVideoSignalTypePresentFlag;
+  Bool      m_colourRemapSEIVideoFullRangeFlag;
+  Int       m_colourRemapSEIPrimaries;
+  Int       m_colourRemapSEITransferCharacteristics;
+  Int       m_colourRemapSEIMatrixCoeffs;
+  Int       m_colourRemapSEICodedDataBitDepth;
+  Int       m_colourRemapSEITargetBitDepth;
+  Int       m_colourRemapSEIPreLutNumValMinus1[3];
+  Int*      m_colourRemapSEIPreLutCodedValue[3];
+  Int*      m_colourRemapSEIPreLutTargetValue[3];
+  Bool      m_colourRemapSEIMatrixPresentFlag;
+  Int       m_colourRemapSEILog2MatrixDenom;
+  Int       m_colourRemapSEICoeffs[3][3];
+  Int       m_colourRemapSEIPostLutNumValMinus1[3];
+  Int*      m_colourRemapSEIPostLutCodedValue[3];
+  Int*      m_colourRemapSEIPostLutTargetValue[3];
+#endif
+#endif
   // internal member functions
 #if LAYER_CTB
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 855)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 856)
@@ -49,5 +49,17 @@
 , m_repFormatIdx (-1)
 #endif
-{
+#if Q0074_COLOUR_REMAPPING_SEI
+,  m_colourRemapSEIFile(string(""))
+#endif
+{
+#if Q0074_COLOUR_REMAPPING_SEI
+  for( Int c=0 ; c<3 ; c++)
+  {
+    m_colourRemapSEIPreLutCodedValue[c]   = NULL;
+    m_colourRemapSEIPreLutTargetValue[c]  = NULL;
+    m_colourRemapSEIPostLutCodedValue[c]  = NULL;
+    m_colourRemapSEIPostLutTargetValue[c] = NULL;
+  }
+#endif
   m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
   m_aiPad[1] = m_aiPad[0] = 0;
@@ -87,4 +99,25 @@
     delete[] m_aidQP;
   }
+#if Q0074_COLOUR_REMAPPING_SEI
+  for( Int c=0 ; c<3 ; c++)
+  {
+    if ( m_colourRemapSEIPreLutCodedValue[c] )
+    {
+      delete[] m_colourRemapSEIPreLutCodedValue[c];
+    }
+    if ( m_colourRemapSEIPreLutTargetValue[c] )
+    {
+      delete[] m_colourRemapSEIPreLutTargetValue[c];
+    }
+    if ( m_colourRemapSEIPostLutCodedValue[c] )
+    {
+      delete[] m_colourRemapSEIPostLutCodedValue[c];
+    }
+    if ( m_colourRemapSEIPostLutTargetValue[c] )
+    {
+      delete[] m_colourRemapSEIPostLutTargetValue[c];
+    }
+  }
+#endif
 }
 
@@ -114,4 +147,7 @@
   Int tmpInputChromaFormat;
   Int tmpChromaFormat;
+#endif
+#if Q0074_COLOUR_REMAPPING_SEI
+  string  cfg_colourRemapSEIFile;
 #endif
 
@@ -144,5 +180,8 @@
     ("dQPFile,m",             cfg_dQPFile, string(""), "dQP file name")
     ("QP,q",                  m_fQP,          30.0, "Qp value, if value is float, QP is switched once during encoding")
-    ;
+#if Q0074_COLOUR_REMAPPING_SEI
+    ("SEIColourRemappingInfoFile", cfg_colourRemapSEIFile, string(""), "Colour Remapping Information SEI parameters file name")
+#endif
+  ;
 
   po::setDefaults(opts);
@@ -156,4 +195,7 @@
   m_chromaFormatIDC   = ((tmpChromaFormat == 0) ? (m_InputChromaFormat) : (numberToChromaFormat(tmpChromaFormat)));
 #endif
+#if Q0074_COLOUR_REMAPPING_SEI
+  m_colourRemapSEIFile = cfg_colourRemapSEIFile.empty() ? NULL : strdup(cfg_colourRemapSEIFile.c_str());
+#endif
 
   // reading external dQP description from file
@@ -174,4 +216,82 @@
     }
   }
+
+#if Q0074_COLOUR_REMAPPING_SEI
+  if( m_colourRemapSEIFile.c_str() )
+  {
+    FILE* fic;
+    Int retval;
+    if((fic = fopen(m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)
+    {
+      fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str());
+      exit(EXIT_FAILURE);
+    }
+
+    retval = fscanf( fic, "%d", &m_colourRemapSEIId );
+    retval = fscanf( fic, "%d", &m_colourRemapSEICancelFlag );
+    if( !m_colourRemapSEICancelFlag )
+    {
+      retval = fscanf( fic, "%d", &m_colourRemapSEIPersistenceFlag );
+      retval = fscanf( fic, "%d", &m_colourRemapSEIVideoSignalTypePresentFlag);
+      if( m_colourRemapSEIVideoSignalTypePresentFlag )
+      {
+        retval = fscanf( fic, "%d", &m_colourRemapSEIVideoFullRangeFlag  );
+        retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries );
+        retval = fscanf( fic, "%d", &m_colourRemapSEITransferCharacteristics );
+        retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoeffs );
+      }
+
+      retval = fscanf( fic, "%d", &m_colourRemapSEICodedDataBitDepth );
+      retval = fscanf( fic, "%d", &m_colourRemapSEITargetBitDepth );
+  
+      for( Int c=0 ; c<3 ; c++ )
+      {
+        retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] );
+        if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
+        {
+          m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
+          m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
+          for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
+          {
+            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] );
+            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] );
+          }
+        }
+      }
+
+      retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixPresentFlag );
+      if( m_colourRemapSEIMatrixPresentFlag )
+      {
+        retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom );
+        for( Int c=0 ; c<3 ; c++ )
+          for( Int i=0 ; i<3 ; i++ )
+            retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] );
+      }
+
+      for( Int c=0 ; c<3 ; c++ )
+      {
+        retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] );
+        if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
+        {
+          m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
+          m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
+          for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
+          {
+            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] );
+            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] );
+          }
+        }
+      }
+    }
+
+    fclose( fic );
+    if( retval != 1 )
+    {
+      fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
+      exit(EXIT_FAILURE);
+    }
+  }
+#endif
+
   return true;
 }
@@ -396,4 +516,38 @@
   }
 #endif
+#if Q0074_COLOUR_REMAPPING_SEI
+  if ( m_colourRemapSEIFile.c_str() && !m_colourRemapSEICancelFlag )
+  {
+    xConfirmPara( m_colourRemapSEICodedDataBitDepth < 8 || m_colourRemapSEICodedDataBitDepth > 16 , "colour_remap_coded_data_bit_depth shall be in the range of 8 to 16, inclusive");
+    xConfirmPara( m_colourRemapSEITargetBitDepth < 8 || (m_colourRemapSEITargetBitDepth > 16 && m_colourRemapSEITargetBitDepth < 255) , "colour_remap_target_bit_depth shall be in the range of 8 to 16, inclusive");
+    for( Int c=0 ; c<3 ; c++)
+    {
+      xConfirmPara( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
+      if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
+        for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
+        {
+          xConfirmPara( m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_colourRemapSEICodedDataBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_coded_data_bit_depth)-1, inclusive");
+          xConfirmPara( m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_colourRemapSEITargetBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
+        }
+      xConfirmPara( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
+      if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
+        for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
+        {
+          if( m_colourRemapSEIPreLutNumValMinus1[c]>0 || m_colourRemapSEIMatrixPresentFlag )
+            xConfirmPara( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_colourRemapSEITargetBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
+          else
+            xConfirmPara( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_colourRemapSEICodedDataBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_coded_data_bit_depth)-1, inclusive");
+          xConfirmPara( m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_colourRemapSEITargetBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
+        }
+    }
+    if( m_colourRemapSEIMatrixPresentFlag )
+    {
+      xConfirmPara( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
+      for( Int c=0 ; c<3 ; c++)
+        for( Int i=0 ; i<3 ; i++)
+          xConfirmPara( m_colourRemapSEICoeffs[c][i] < -32768 || m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");
+    }
+  }
+#endif
 
 #undef xConfirmPara
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 855)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 856)
@@ -55,7 +55,4 @@
   Int       m_numActiveRefLayers;
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  string    m_cSeiColorMappingFile;
-#endif
 
 #if LAYER_CTB
@@ -127,4 +124,26 @@
 #if REPN_FORMAT_IN_VPS
   Int       m_repFormatIdx;
+#endif
+#if Q0074_COLOUR_REMAPPING_SEI
+  string    m_colourRemapSEIFile;                           ///< Colour Remapping Information SEI message parameters file
+  Int       m_colourRemapSEIId;
+  Bool      m_colourRemapSEICancelFlag;
+  Bool      m_colourRemapSEIPersistenceFlag;
+  Bool      m_colourRemapSEIVideoSignalTypePresentFlag;
+  Bool      m_colourRemapSEIVideoFullRangeFlag;
+  Int       m_colourRemapSEIPrimaries;
+  Int       m_colourRemapSEITransferCharacteristics;
+  Int       m_colourRemapSEIMatrixCoeffs;
+  Int       m_colourRemapSEICodedDataBitDepth;
+  Int       m_colourRemapSEITargetBitDepth;
+  Int       m_colourRemapSEIPreLutNumValMinus1[3];
+  Int*      m_colourRemapSEIPreLutCodedValue[3];
+  Int*      m_colourRemapSEIPreLutTargetValue[3];
+  Bool      m_colourRemapSEIMatrixPresentFlag;
+  Int       m_colourRemapSEILog2MatrixDenom;
+  Int       m_colourRemapSEICoeffs[3][3];
+  Int       m_colourRemapSEIPostLutNumValMinus1[3];
+  Int*      m_colourRemapSEIPostLutCodedValue[3];
+  Int*      m_colourRemapSEIPostLutTargetValue[3];
 #endif
 public:
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 855)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 856)
@@ -534,6 +534,25 @@
     m_acTEncTop[layer].setKneeSEIOutputKneePoint                    ( m_kneeSEIOutputKneePoint );
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-    m_acTEncTop[layer].setColorMappingInfoSEIFile                   ( m_acLayerCfg[layer].m_cSeiColorMappingFile.empty() ? NULL : const_cast<Char *>(m_acLayerCfg[layer].m_cSeiColorMappingFile.c_str()) );
+#if Q0074_COLOUR_REMAPPING_SEI
+    m_acTEncTop[layer].setCRISEIFile                                ( const_cast<Char*>(m_acLayerCfg[layer].m_colourRemapSEIFile.c_str()) );
+    m_acTEncTop[layer].setCRISEIId                                  ( m_acLayerCfg[layer].m_colourRemapSEIId );
+    m_acTEncTop[layer].setCRISEICancelFlag                          ( m_acLayerCfg[layer].m_colourRemapSEICancelFlag );
+    m_acTEncTop[layer].setCRISEIPersistenceFlag                     ( m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag );
+    m_acTEncTop[layer].setCRISEIVideoSignalTypePresentFlag          ( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalTypePresentFlag );
+    m_acTEncTop[layer].setCRISEIVideoFullRangeFlag                  ( m_acLayerCfg[layer].m_colourRemapSEIVideoFullRangeFlag );
+    m_acTEncTop[layer].setCRISEIPrimaries                           ( m_acLayerCfg[layer].m_colourRemapSEIPrimaries );
+    m_acTEncTop[layer].setCRISEITransferCharacteristics             ( m_acLayerCfg[layer].m_colourRemapSEITransferCharacteristics );
+    m_acTEncTop[layer].setCRISEIMatrixCoeffs                        ( m_acLayerCfg[layer].m_colourRemapSEIMatrixCoeffs );
+    m_acTEncTop[layer].setCRISEICodedDataBitDepth                   ( m_acLayerCfg[layer].m_colourRemapSEICodedDataBitDepth );
+    m_acTEncTop[layer].setCRISEITargetBitDepth                      ( m_acLayerCfg[layer].m_colourRemapSEITargetBitDepth );
+    m_acTEncTop[layer].setCRISEIPreLutNumValMinus1                  ( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1 );
+    m_acTEncTop[layer].setCRISEIPreLutCodedValue                    ( m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue );
+    m_acTEncTop[layer].setCRISEIPreLutTargetValue                   ( m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue );
+    m_acTEncTop[layer].setCRISEIMatrixPresentFlag                   ( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag );
+    m_acTEncTop[layer].setCRISEILog2MatrixDenom                     ( m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom );
+    m_acTEncTop[layer].setCRISEICoeffs                              ( m_acLayerCfg[layer].m_colourRemapSEICoeffs );
+    m_acTEncTop[layer].setCRISEIPostLutNumValMinus1                 ( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1 );
+    m_acTEncTop[layer].setCRISEIPostLutCodedValue                   ( m_acLayerCfg[layer]. m_colourRemapSEIPostLutCodedValue );
+    m_acTEncTop[layer].setCRISEIPostLutTargetValue                  ( m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue );
 #endif
     m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
@@ -900,6 +919,25 @@
   m_cTEncTop.setKneeSEIOutputKneePoint      ( m_kneeSEIOutputKneePoint );
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  m_cTEncTop.setColorMappingInfoSEIFile                   ( m_pchSEIColorMappingFile );
+#if Q0074_COLOUR_REMAPPING_SEI
+  m_cTEncTop.setCRISEIFile                       ( const_cast<Char*>(m_colourRemapSEIFile.c_str()) );
+  m_cTEncTop.setCRISEIId                         ( m_colourRemapSEIId );
+  m_cTEncTop.setCRISEICancelFlag                 ( m_colourRemapSEICancelFlag );
+  m_cTEncTop.setCRISEIPersistenceFlag            ( m_colourRemapSEIPersistenceFlag );
+  m_cTEncTop.setCRISEIVideoSignalTypePresentFlag ( m_colourRemapSEIVideoSignalTypePresentFlag );
+  m_cTEncTop.setCRISEIVideoFullRangeFlag         ( m_colourRemapSEIVideoFullRangeFlag );
+  m_cTEncTop.setCRISEIPrimaries                  ( m_colourRemapSEIPrimaries );
+  m_cTEncTop.setCRISEITransferCharacteristics    ( m_colourRemapSEITransferCharacteristics );
+  m_cTEncTop.setCRISEIMatrixCoeffs               ( m_colourRemapSEIMatrixCoeffs );
+  m_cTEncTop.setCRISEICodedDataBitDepth          ( m_colourRemapSEICodedDataBitDepth );
+  m_cTEncTop.setCRISEITargetBitDepth             ( m_colourRemapSEITargetBitDepth );
+  m_cTEncTop.setCRISEIPreLutNumValMinus1         ( m_colourRemapSEIPreLutNumValMinus1 );
+  m_cTEncTop.setCRISEIPreLutCodedValue           ( m_colourRemapSEIPreLutCodedValue );
+  m_cTEncTop.setCRISEIPreLutTargetValue          ( m_colourRemapSEIPreLutTargetValue );
+  m_cTEncTop.setCRISEIMatrixPresentFlag          ( m_colourRemapSEIMatrixPresentFlag );
+  m_cTEncTop.setCRISEILog2MatrixDenom            ( m_colourRemapSEILog2MatrixDenom );
+  m_cTEncTop.setCRISEICoeffs                     ( m_colourRemapSEICoeffs );
+  m_cTEncTop.setCRISEIPostLutNumValMinus1        ( m_colourRemapSEIPostLutNumValMinus1 );
+  m_cTEncTop.setCRISEIPostLutCodedValue          ( m_colourRemapSEIPostLutCodedValue );
+  m_cTEncTop.setCRISEIPostLutTargetValue         ( m_colourRemapSEIPostLutTargetValue );
 #endif
   m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
Index: branches/SHM-dev/source/Lib/TLibCommon/SEI.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/SEI.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibCommon/SEI.h	(revision 856)
@@ -98,6 +98,6 @@
 #endif
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-    COLOR_MAPPING_INFO                   = 143,
+#if Q0074_COLOUR_REMAPPING_SEI
+    COLOUR_REMAPPING_INFO                = 143,
 #endif
 #if Q0078_ADD_LAYER_SETS
@@ -447,37 +447,31 @@
 };
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-class SEIColorMappingInfo : public SEI
-{
-public:
-  PayloadType payloadType() const { return COLOR_MAPPING_INFO; }
-  SEIColorMappingInfo() {
-  }
-  virtual ~SEIColorMappingInfo() {}
-
-  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];
+#if Q0074_COLOUR_REMAPPING_SEI
+class SEIColourRemappingInfo : public SEI
+{
+public:
+  PayloadType payloadType() const { return COLOUR_REMAPPING_INFO; }
+  SEIColourRemappingInfo() {}
+  ~SEIColourRemappingInfo() {}
+ 
+  Int   m_colourRemapId;
+  Bool  m_colourRemapCancelFlag;
+  Bool  m_colourRemapPersistenceFlag;
+  Bool  m_colourRemapVideoSignalTypePresentFlag;
+  Bool  m_colourRemapVideoFullRangeFlag;
+  Int   m_colourRemapPrimaries;
+  Int   m_colourRemapTransferCharacteristics;
+  Int   m_colourRemapMatrixCoeffs;
+  Int   m_colourRemapCodedDataBitDepth;
+  Int   m_colourRemapTargetBitDepth;
+  Int   m_preLutNumValMinus1[3];
+  std::vector<Int> m_preLutCodedValue[3];
+  std::vector<Int> m_preLutTargetValue[3];
+  Bool  m_colourRemapMatrixPresentFlag;
+  Int   m_log2MatrixDenom;
+  Int   m_colourRemapCoeffs[3][3];
+  Int   m_postLutNumValMinus1[3];
+  std::vector<Int> m_postLutCodedValue[3];
+  std::vector<Int> m_postLutTargetValue[3];
 };
 #endif
Index: branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 856)
@@ -366,5 +366,4 @@
 }
 
-#if SVC_EXTENSION
 Void TComPicYuv::dump( Char* pFileName, Bool bAdd, Int bitDepth )
 {
@@ -431,5 +430,3 @@
 }
 
-#endif
-
 //! \}
Index: branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h	(revision 856)
@@ -191,6 +191,6 @@
   Void convertToMonochrome();
 #endif
+#endif //SVC_EXTENSION
   Void dump( Char* pFileName, Bool bAdd, Int bitDepth );
-#endif //SVC_EXTENSION
 
 };// END CLASS DEFINITION TComPicYuv
Index: branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 856)
@@ -109,5 +109,5 @@
 #define R0300_CGS_RES_COEFF_CODING       1      ///< JCTVC-R0300: improved residual coefficient coding for R0151
 #endif
-#define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
+#define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediction for colour gamut scalability
 #define POC_RESET_FLAG                   0      ///< JCTVC-N0244: POC reset flag for  layer pictures.
 #define POC_RESET_IDC                    1      ///< JCTVC-P0041: Include poc_reset_idc and related derivation - eventually will replace POC_RESET_FLAG
@@ -280,5 +280,4 @@
 #define MAX_SUB_STREAMS                  1024
 #endif
-#define Q0074_SEI_COLOR_MAPPING          1      ///< JCTVC-Q0074, SEI Color Mapping
 #define LAYERS_NOT_PRESENT_SEI           1      ///< JCTVC-M0043: add layers not present SEI.
 #define N0383_IL_CONSTRAINED_TILE_SETS_SEI  1
@@ -288,4 +287,5 @@
 
 #endif // SVC_EXTENSION
+#define Q0074_COLOUR_REMAPPING_SEI       1      ///< JCTVC-Q0074, JCTVC-R0344: SEI Colour Remapping Information
 
 
Index: branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp	(revision 856)
@@ -98,7 +98,7 @@
     break;
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  case SEI::COLOR_MAPPING_INFO:
-    fprintf( g_hTrace, "===========Color Mapping Info SEI message ===========\n");
+#if Q0074_COLOUR_REMAPPING_SEI
+  case SEI::COLOUR_REMAPPING_INFO:
+    fprintf( g_hTrace, "===========Colour Remapping Information SEI message ===========\n");
     break;
 #endif
@@ -132,7 +132,9 @@
     fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n");
     break;
+#if !REMOVE_BSP_HRD_SEI
   case SEI::BSP_HRD:
     fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
     break;
+#endif
 #endif
 #if Q0078_ADD_LAYER_SETS
@@ -304,8 +306,8 @@
       break;
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-    case SEI::COLOR_MAPPING_INFO:
-      sei = new SEIColorMappingInfo;
-      xParseSEIColorMappingInfo((SEIColorMappingInfo&) *sei, payloadSize);
+#if Q0074_COLOUR_REMAPPING_SEI
+    case SEI::COLOUR_REMAPPING_INFO:
+      sei = new SEIColourRemappingInfo;
+      xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize);
       break;
 #endif
@@ -923,84 +925,81 @@
 #endif
 
-#if Q0074_SEI_COLOR_MAPPING
-Void SEIReader::xParseSEIColorMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/)
+#if Q0074_COLOUR_REMAPPING_SEI
+Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& 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 );
+  READ_UVLC( uiVal, "colour_remap_id" );          sei.m_colourRemapId = uiVal;
+  READ_FLAG( uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal;
+  if( !sei.m_colourRemapCancelFlag ) 
+  {
+    READ_FLAG( uiVal, "colour_remap_persistence_flag" );                sei.m_colourRemapPersistenceFlag = uiVal;
+    READ_FLAG( uiVal, "colour_remap_video_signal_type_present_flag" );  sei.m_colourRemapVideoSignalTypePresentFlag = uiVal;
+    if ( sei.m_colourRemapVideoSignalTypePresentFlag )
+    {
+      READ_FLAG( uiVal,    "colour_remap_video_full_range_flag" );     sei.m_colourRemapVideoFullRangeFlag = uiVal;
+      READ_CODE( 8, uiVal, "colour_remap_primaries" );                 sei.m_colourRemapPrimaries = uiVal;
+      READ_CODE( 8, uiVal, "colour_remap_transfer_characteristics" );  sei.m_colourRemapTransferCharacteristics = uiVal;
+      READ_CODE( 8, uiVal, "colour_remap_matrix_coeffs" );             sei.m_colourRemapMatrixCoeffs = uiVal;
+    }
+    READ_CODE( 8, uiVal, "colour_remap_coded_data_bit_depth" );  sei.m_colourRemapCodedDataBitDepth = uiVal;
+    READ_CODE( 8, uiVal, "colour_remap_target_bit_depth" );      sei.m_colourRemapTargetBitDepth = uiVal;
   
-  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 ;
+    for( Int c=0 ; c<3 ; c++ )
+    {
+      READ_CODE( 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal;
+      sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1);
+      sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1);
+      if( uiVal> 0 )
+        for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ )
+        {
+          READ_CODE( (( sei.m_colourRemapCodedDataBitDepth   + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" );  sei.m_preLutCodedValue[c][i]  = uiVal;
+          READ_CODE( (( sei.m_colourRemapTargetBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal;
+        }
+      else // pre_lut_num_val_minus1[c] == 0
+      {
+        sei.m_preLutCodedValue[c][0]  = 0;
+        sei.m_preLutTargetValue[c][0] = 0;
+        sei.m_preLutCodedValue[c][1]  = (1 << sei.m_colourRemapCodedDataBitDepth) - 1 ;
+        sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapTargetBitDepth) - 1 ;
+      }
+    }
+
+    READ_FLAG( uiVal,      "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal;
+    if( sei.m_colourRemapMatrixPresentFlag )
+    {
+      READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal;
+      for ( Int c=0 ; c<3 ; c++ )
+        for ( Int i=0 ; i<3 ; i++ )
+        {
+          READ_SVLC( iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal;
+        }
+    }
+    else // setting default matrix (I3)
+    {
+      sei.m_log2MatrixDenom = 0;
+      for ( Int c=0 ; c<3 ; c++ )
+        for ( Int i=0 ; i<3 ; i++ )
+          sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0;
+    }
+    for( Int c=0 ; c<3 ; c++ )
+    {
+      READ_CODE( 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal;
+      sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1);
+      sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1);
+      if( uiVal > 0 )
+        for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ )
+        {
+          READ_CODE( (( sei.m_colourRemapTargetBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" );  sei.m_postLutCodedValue[c][i] = uiVal;
+          READ_CODE( (( sei.m_colourRemapTargetBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal;
+        }
+      else
+      {
+        sei.m_postLutCodedValue[c][0]  = 0;
+        sei.m_postLutTargetValue[c][0] = 0;
+        sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapTargetBitDepth) - 1;
+        sei.m_postLutCodedValue[c][1]  = (1 << sei.m_colourRemapTargetBitDepth) - 1;
+      }
     }
   }
Index: branches/SHM-dev/source/Lib/TLibDecoder/SEIread.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/SEIread.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibDecoder/SEIread.h	(revision 856)
@@ -93,6 +93,6 @@
   Void xParseSEIKneeFunctionInfo      (SEIKneeFunctionInfo& sei, UInt payloadSize);
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  Void xParseSEIColorMappingInfo      (SEIColorMappingInfo& sei, UInt payloadSize);
+#if Q0074_COLOUR_REMAPPING_SEI
+  Void xParseSEIColourRemappingInfo   (SEIColourRemappingInfo& sei, UInt payloadSize);
 #endif
   Void xParseSEISOPDescription        (SEISOPDescription &sei, UInt payloadSize);
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp	(revision 856)
@@ -54,4 +54,8 @@
 //! \{
 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI);
+#if Q0074_COLOUR_REMAPPING_SEI
+static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 );
+static std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI
+#endif
 // ====================================================================================================================
 // Constructor / destructor / initialization / destroy
@@ -252,4 +256,20 @@
     calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash);
   }
+#if Q0074_COLOUR_REMAPPING_SEI
+  if (m_colourRemapSEIEnabled)
+  {
+    SEIMessages colourRemappingInfo = getSeisByType(rpcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO );
+    const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL;
+    if (colourRemappingInfo.size() > 1)
+    {
+      printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first.");
+    }
+    applyColourRemapping(*rpcPic->getPicYuvRec(), seiColourRemappingInfo
+#if SVC_EXTENSION
+     , rpcPic->getLayerId()
+#endif
+     );
+  }
+#endif
 
 #if SETTING_PIC_OUTPUT_MARK
@@ -339,3 +359,168 @@
   }
 }
+
+#if Q0074_COLOUR_REMAPPING_SEI
+Void xInitColourRemappingLut( const Int bitDepthY, const Int bitDepthC, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI )
+{
+  for ( Int c=0 ; c<3 ; c++ )
+  {  
+    Int bitDepth = c ? bitDepthC : bitDepthY ;
+    preLut[c].resize(1 << bitDepth);
+    postLut[c].resize(1 << pCriSEI->m_colourRemapTargetBitDepth);
+    
+    Int bitDepthDiff = pCriSEI->m_colourRemapTargetBitDepth - bitDepth;
+    Int iShift1 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from bitdepth to TargetBitdepth (manage only case colourRemapTargetBitDepth>= bitdepth)
+    if( bitDepthDiff<0 )
+      printf ("Warning: CRI SEI - colourRemapTargetBitDepth (%d) <bitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapTargetBitDepth, bitDepth);
+    bitDepthDiff = pCriSEI->m_colourRemapTargetBitDepth - pCriSEI->m_colourRemapCodedDataBitDepth;
+    Int iShift2 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from codedDataBitdepth to TargetBitdepth (manage only case colourRemapTargetBitDepth>= colourRemapCodedDataBitDepth)
+    if( bitDepthDiff<0 )
+      printf ("Warning: CRI SEI - colourRemapTargetBitDepth (%d) <colourRemapCodedDataBitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapTargetBitDepth, pCriSEI->m_colourRemapCodedDataBitDepth);
+
+    //Fill preLut
+    for ( Int k=0 ; k<(1<<bitDepth) ; k++ )
+    {
+      Int iSample = k << iShift1 ;
+      for ( Int iPivot=0 ; iPivot<=pCriSEI->m_preLutNumValMinus1[c] ; iPivot++ )
+      {
+        Int iCodedPrev  = pCriSEI->m_preLutCodedValue[c][iPivot]    << iShift2; //Coded in CodedDataBitdepth
+        Int iCodedNext  = pCriSEI->m_preLutCodedValue[c][iPivot+1]  << iShift2; //Coded in CodedDataBitdepth
+        Int iTargetPrev = pCriSEI->m_preLutTargetValue[c][iPivot];              //Coded in TargetBitdepth
+        Int iTargetNext = pCriSEI->m_preLutTargetValue[c][iPivot+1];            //Coded in TargetBitdepth
+        if ( iCodedPrev <= iSample && iSample <= iCodedNext )
+        {
+          Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev);
+          preLut[c][k]  = (Int)( 0.5f + fInterpol );
+          iPivot = pCriSEI->m_preLutNumValMinus1[c] + 1;
+        }
+      }
+    }
+    
+    //Fill postLut
+    for ( Int k=0 ; k<(1<<pCriSEI->m_colourRemapTargetBitDepth) ; k++ )
+    {
+      Int iSample = k;
+      for ( Int iPivot=0 ; iPivot<=pCriSEI->m_postLutNumValMinus1[c] ; iPivot++ )
+      {
+        Int iCodedPrev  = pCriSEI->m_postLutCodedValue[c][iPivot];    //Coded in TargetBitdepth
+        Int iCodedNext  = pCriSEI->m_postLutCodedValue[c][iPivot+1];  //Coded in TargetBitdepth
+        Int iTargetPrev = pCriSEI->m_postLutTargetValue[c][iPivot];   //Coded in TargetBitdepth
+        Int iTargetNext = pCriSEI->m_postLutTargetValue[c][iPivot+1]; //Coded in TargetBitdepth
+        if ( iCodedPrev <= iSample && iSample <= iCodedNext )
+        {
+          Float fInterpol =  (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev) ;
+          postLut[c][k]  = (Int)( 0.5f + fInterpol );
+          iPivot = pCriSEI->m_postLutNumValMinus1[c] + 1;
+        }
+      }
+    }
+  }
+}
+
+static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId )
+{  
+  if( !storeCriSEI.size() )
+#if SVC_EXTENSION
+    storeCriSEI.resize(MAX_LAYERS);
+#else
+    storeCriSEI.resize(1);
+#endif
+
+  if ( pCriSEI ) //if a CRI SEI has just been retrieved, keep it in memory (persistence management)
+    storeCriSEI[layerId] = *pCriSEI;
+
+  if( !storeCriSEI[layerId].m_colourRemapCancelFlag )
+  {
+    Int iHeight  = pic.getHeight();
+    Int iWidth   = pic.getWidth();
+    Int iStride  = pic.getStride();
+    Int iCStride = pic.getCStride();
+
+    Pel *YUVIn[3], *YUVOut[3];
+    YUVIn[0] = pic.getLumaAddr();
+    YUVIn[1] = pic.getCbAddr();
+    YUVIn[2] = pic.getCrAddr();
+    
+    TComPicYuv picColourRemapped;
+#if SVC_EXTENSION
+#if AUXILIARY_PICTURES
+    picColourRemapped.create( pic.getWidth(), pic.getHeight(), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
+#else
+    picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
+#endif
+#else
+    picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
+#endif 
+    YUVOut[0] = picColourRemapped.getLumaAddr();
+    YUVOut[1] = picColourRemapped.getCbAddr();
+    YUVOut[2] = picColourRemapped.getCrAddr();
+
+#if SVC_EXTENSION
+    Int bitDepthY = g_bitDepthYLayer[layerId];
+    Int bitDepthC = g_bitDepthCLayer[layerId];
+
+    assert( g_bitDepthY == bitDepthY );
+    assert( g_bitDepthC == bitDepthC );
+#else
+    Int bitDepthY = g_bitDepthY;
+    Int bitDepthC = g_bitDepthC;
+#endif
+
+    std::vector<Int> preLut[3];
+    std::vector<Int> postLut[3];
+    xInitColourRemappingLut( bitDepthY, bitDepthC, preLut, postLut, &storeCriSEI[layerId] );
+    
+    Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1));
+
+    for( Int y = 0; y < iHeight ; y++ )
+    {
+      for( Int x = 0; x < iWidth ; x++ )
+      {
+        Int YUVPre[3], YUVMat[3];
+        YUVPre[0] = preLut[0][ YUVIn[0][x]   ];
+        YUVPre[1] = preLut[1][ YUVIn[1][x>>1] ];
+        YUVPre[2] = preLut[2][ YUVIn[2][x>>1] ];
+
+        YUVMat[0] = ( storeCriSEI[layerId].m_colourRemapCoeffs[0][0]*YUVPre[0]
+                    + storeCriSEI[layerId].m_colourRemapCoeffs[0][1]*YUVPre[1] 
+                    + storeCriSEI[layerId].m_colourRemapCoeffs[0][2]*YUVPre[2] 
+                    + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );
+        YUVMat[0] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapTargetBitDepth)-1, YUVMat[0] );
+        YUVOut[0][x] = postLut[0][ YUVMat[0] ];
+
+        if( (y&1) && (x&1) )
+        {
+          for(Int c=1 ; c<3 ; c++)
+          {
+            YUVMat[c] = ( storeCriSEI[layerId].m_colourRemapCoeffs[c][0]*YUVPre[0] 
+                        + storeCriSEI[layerId].m_colourRemapCoeffs[c][1]*YUVPre[1] 
+                        + storeCriSEI[layerId].m_colourRemapCoeffs[c][2]*YUVPre[2] 
+                        + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );
+            YUVMat[c] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapTargetBitDepth)-1, YUVMat[c] );
+            YUVOut[c][x>>1] = postLut[c][ YUVMat[c] ];   
+          }
+        }
+      }
+      YUVIn[0]  += iStride;
+      YUVOut[0] += iStride;
+      if( y&1 )
+      {
+        YUVIn[1]  += iCStride;
+        YUVIn[2]  += iCStride;
+        YUVOut[1] += iCStride;
+        YUVOut[2] += iCStride;
+      }
+    }
+
+    //Write remapped picture in decoding order
+    Char  cTemp[255];
+    sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapTargetBitDepth );
+    picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapTargetBitDepth );
+
+    picColourRemapped.destroy();
+
+    storeCriSEI[layerId].m_colourRemapCancelFlag = !storeCriSEI[layerId].m_colourRemapPersistenceFlag; //Handling persistence
+  }
+}
+#endif
 //! \}
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h	(revision 856)
@@ -82,5 +82,7 @@
   Double                m_dDecTime;
   Int                   m_decodedPictureHashSEIEnabled;  ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
-
+#if Q0074_COLOUR_REMAPPING_SEI
+  Bool                  m_colourRemapSEIEnabled;         ///< Enable/disable Colour Remapping Information SEI message acting on decoded pictures
+#endif
 #if SVC_EXTENSION
   UInt                  m_layerId;
@@ -114,4 +116,7 @@
 
   void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; }
+#if Q0074_COLOUR_REMAPPING_SEI
+  void setColourRemappingInfoSEIEnabled(Int enabled) { m_colourRemapSEIEnabled = enabled; }
+#endif
 #if SVC_EXTENSION
   TDecTop*   getLayerDec(UInt LayerId)  { return m_ppcTDecTop[LayerId]; }
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 856)
@@ -117,8 +117,4 @@
 #endif
 
-#if Q0074_SEI_COLOR_MAPPING
-  m_ColorMapping = new TDecColorMapping();
-#endif
-
 #if POC_RESET_RESTRICTIONS
   resetPocRestrictionCheckParameters();
@@ -137,11 +133,4 @@
     delete m_pColorMappedPic;
     m_pColorMappedPic = NULL;
-  }
-#endif
-#if Q0074_SEI_COLOR_MAPPING
-  if ( m_ColorMapping )
-  {
-    delete m_ColorMapping;
-    m_ColorMapping = NULL;
   }
 #endif
@@ -891,11 +880,4 @@
   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++)
@@ -2324,7 +2306,4 @@
       }
     }
-#if Q0074_SEI_COLOR_MAPPING
-    m_ColorMapping->setColorMapping( m_SEIs );
-#endif
   }
 #else
@@ -2857,305 +2836,4 @@
 #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: branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 856)
@@ -64,49 +64,4 @@
 // ====================================================================================================================
 
-#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
@@ -209,8 +164,4 @@
 #endif
 public:
-#if Q0074_SEI_COLOR_MAPPING
-  TDecColorMapping* m_ColorMapping;
-#endif
-
 #if POC_RESET_RESTRICTIONS
   static Bool                    m_checkPocRestrictionsForCurrAu;
@@ -236,4 +187,7 @@
 
   void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
+#if Q0074_COLOUR_REMAPPING_SEI
+  void setColourRemappingInfoSEIEnabled(Bool enabled)  { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); }
+#endif
 
   Void  init();
Index: branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp	(revision 856)
@@ -92,7 +92,7 @@
     break;
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  case SEI::COLOR_MAPPING_INFO:
-    fprintf( g_hTrace, "=========== Color Mapping Info SEI message ===========\n");
+#if Q0074_COLOUR_REMAPPING_SEI
+  case SEI::COLOUR_REMAPPING_INFO:
+    fprintf( g_hTrace, "=========== Colour Remapping Information SEI message ===========\n");
     break;
 #endif
@@ -126,7 +126,9 @@
     fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n");
     break;
+#if !REMOVE_BSP_HRD_SEI
   case SEI::BSP_HRD:
     fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
     break;
+#endif
 #endif
 #if Q0078_ADD_LAYER_SETS
@@ -195,7 +197,7 @@
     break;
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  case SEI::COLOR_MAPPING_INFO:
-    xWriteSEIColorMappingInfo(*static_cast<const SEIColorMappingInfo*>(&sei));
+#if Q0074_COLOUR_REMAPPING_SEI
+  case SEI::COLOUR_REMAPPING_INFO:
+    xWriteSEIColourRemappingInfo(*static_cast<const SEIColourRemappingInfo*>(&sei));
     break;
 #endif
@@ -636,58 +638,53 @@
 }
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei)
-{
-  WRITE_UVLC( sei.m_colorMapId,                    "colour_map_id" );
-  WRITE_FLAG( sei.m_colorMapCancelFlag,            "colour_map_cancel_flag" );
-  if( !sei.m_colorMapCancelFlag ) 
-  {
-    WRITE_FLAG( sei.m_colorMapPersistenceFlag,            "colour_map_persistence_flag" );
-    WRITE_FLAG( sei.m_colorMap_video_signal_type_present_flag,            "colour_map_video_signal_type_present_flag" );
-    if ( sei.m_colorMap_video_signal_type_present_flag )
-    {
-      WRITE_FLAG( sei.m_colorMap_video_full_range_flag,       "colour_map_video_full_range_flag" );
-      WRITE_CODE( sei.m_colorMap_primaries,                 8,      "colour_map_primaries" );
-      WRITE_CODE( sei.m_colorMap_transfer_characteristics,  8,      "colour_map_transfer_characteristics" );
-      WRITE_CODE( sei.m_colorMap_matrix_coeffs,             8,      "colour_map_matrix_coeffs" );
-    }
-  }
-
-  WRITE_CODE( sei.m_colour_map_coded_data_bit_depth,  5,  "colour_map_coded_data_bit_depth" );
-  WRITE_CODE( sei.m_colour_map_target_bit_depth,  5,      "colour_map_target_bit_depth" );
-  WRITE_UVLC( sei.m_colorMapModelId,                      "colour_map_model_id" );
-
-  assert( sei.m_colorMapModelId == 0 );
-  
-  for( Int i=0 ; i<3 ; i++ )
-  {
-    WRITE_CODE( sei.m_num_input_pivots[i] - 1,         8,      "num_input_pivots_minus1[i]" );
-    for( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ )
-    {
-      WRITE_CODE( sei.m_coded_input_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_input_pivot_value[i][j]" );
-      WRITE_CODE( sei.m_target_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_input_pivot_value[i][j]" );
-    }
-  }
-
-  WRITE_FLAG( sei.m_matrix_flag,            "matrix_flag" );
-  if( sei.m_matrix_flag )
-  {
-    WRITE_CODE( sei.m_log2_matrix_denom, 4, "log2_matrix_denom" );
-    for( Int i=0 ; i<3 ; i++ )
-    {
-      for( Int j=0 ; j<3 ; j++ )
-      {
-        WRITE_SVLC( sei.m_matrix_coef[i][j],  "matrix_coef[i][j]" );
-      }
-    }
-  }
-
-  for( Int i=0 ; i<3 ; i++ )
-  {
-    WRITE_CODE( sei.m_num_output_pivots[i] - 1,         8,      "num_output_pivots_minus1[i]" );
-    for( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ )
-    {
-      WRITE_CODE( sei.m_coded_output_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_output_pivot_value[i][j]" );
-      WRITE_CODE( sei.m_target_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_output_pivot_value[i][j]" );
+#if Q0074_COLOUR_REMAPPING_SEI
+Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei)
+{
+  WRITE_UVLC( sei.m_colourRemapId,                             "colour_remap_id" );
+  WRITE_FLAG( sei.m_colourRemapCancelFlag,                     "colour_remap_cancel_flag" );
+  if( !sei.m_colourRemapCancelFlag ) 
+  {
+    WRITE_FLAG( sei.m_colourRemapPersistenceFlag,              "colour_remap_persistence_flag" );
+    WRITE_FLAG( sei.m_colourRemapVideoSignalTypePresentFlag,   "colour_remap_video_signal_type_present_flag" );
+    if ( sei.m_colourRemapVideoSignalTypePresentFlag )
+    {
+      WRITE_FLAG( sei.m_colourRemapVideoFullRangeFlag,         "colour_remap_video_full_range_flag" );
+      WRITE_CODE( sei.m_colourRemapPrimaries,               8, "colour_remap_primaries" );
+      WRITE_CODE( sei.m_colourRemapTransferCharacteristics, 8, "colour_remap_transfer_characteristics" );
+      WRITE_CODE( sei.m_colourRemapMatrixCoeffs,            8, "colour_remap_matrix_coeffs" );
+    }
+    WRITE_CODE( sei.m_colourRemapCodedDataBitDepth,         8, "colour_remap_coded_data_bit_depth" );
+    WRITE_CODE( sei.m_colourRemapTargetBitDepth,            8, "colour_remap_target_bit_depth" );
+    for( Int c=0 ; c<3 ; c++ )
+    {
+      WRITE_CODE( sei.m_preLutNumValMinus1[c],              8, "pre_lut_num_val_minus1[c]" );
+      if( sei.m_preLutNumValMinus1[c]>0 )
+        for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ )
+        {
+          WRITE_CODE( sei.m_preLutCodedValue[c][i],  (( sei.m_colourRemapCodedDataBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" );
+          WRITE_CODE( sei.m_preLutTargetValue[c][i], (( sei.m_colourRemapTargetBitDepth    + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" );
+        }
+    }
+    WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag,            "colour_remap_matrix_present_flag" );
+    if( sei.m_colourRemapMatrixPresentFlag )
+    {
+      WRITE_CODE( sei.m_log2MatrixDenom,                    4, "log2_matrix_denom" );
+      for( Int c=0 ; c<3 ; c++ )
+        for( Int i=0 ; i<3 ; i++ )
+          WRITE_SVLC( sei.m_colourRemapCoeffs[c][i],           "colour_remap_coeffs[c][i]" );
+    }
+
+    for( Int c=0 ; c<3 ; c++ )
+    {
+      WRITE_CODE( sei.m_postLutNumValMinus1[c],             8, "m_postLutNumValMinus1[c]" );
+      if( sei.m_postLutNumValMinus1[c]>0 )
+        for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ )
+        {
+          if( sei.m_preLutNumValMinus1[c]>0 || sei.m_colourRemapMatrixPresentFlag )
+            WRITE_CODE( sei.m_postLutCodedValue[c][i], (( sei.m_colourRemapTargetBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" );
+          else 
+            WRITE_CODE( sei.m_postLutCodedValue[c][i], (( sei.m_colourRemapCodedDataBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" );
+          WRITE_CODE( sei.m_postLutTargetValue[c][i], (( sei.m_colourRemapTargetBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" );
+        }
     }
   }
Index: branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.h	(revision 856)
@@ -75,6 +75,6 @@
   Void xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei);
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  Void xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei);
+#if Q0074_COLOUR_REMAPPING_SEI
+  Void xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei);
 #endif
   Void xWriteSEISOPDescription(const SEISOPDescription& sei);
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 856)
@@ -385,11 +385,30 @@
   Int*      m_kneeSEIOutputKneePoint;
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  Char*     m_seiColorMappingFile;
-#endif
 #if Q0189_TMVP_CONSTRAINTS
   Int       m_TMVPConstraintsSEIEnabled;
 #endif
 #endif //SVC_EXTENSION
+#if Q0074_COLOUR_REMAPPING_SEI
+  Char*     m_colourRemapSEIFile;          ///< SEI Colour Remapping File (initialized from external file)
+  Int       m_colourRemapSEIId;
+  Bool      m_colourRemapSEICancelFlag;
+  Bool      m_colourRemapSEIPersistenceFlag;
+  Bool      m_colourRemapSEIVideoSignalTypePresentFlag;
+  Bool      m_colourRemapSEIVideoFullRangeFlag;
+  Int       m_colourRemapSEIPrimaries;
+  Int       m_colourRemapSEITransferCharacteristics;
+  Int       m_colourRemapSEIMatrixCoeffs;
+  Int       m_colourRemapSEICodedDataBitDepth;
+  Int       m_colourRemapSEITargetBitDepth;
+  Int       m_colourRemapSEIPreLutNumValMinus1[3];
+  Int*      m_colourRemapSEIPreLutCodedValue[3];
+  Int*      m_colourRemapSEIPreLutTargetValue[3];
+  Bool      m_colourRemapSEIMatrixPresentFlag;
+  Int       m_colourRemapSEILog2MatrixDenom;
+  Int       m_colourRemapSEICoeffs[3][3];
+  Int       m_colourRemapSEIPostLutNumValMinus1[3];
+  Int*      m_colourRemapSEIPostLutCodedValue[3];
+  Int*      m_colourRemapSEIPostLutTargetValue[3];
+#endif
 
 public:
@@ -684,7 +703,45 @@
   Int*  getKneeSEIOutputKneePoint()                          { return m_kneeSEIOutputKneePoint; }
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  Void  setColorMappingInfoSEIFile( Char* nameFile )         {  m_seiColorMappingFile = nameFile; }
-  Char* getColorMappingInfoSEIFile()                         {  return m_seiColorMappingFile; }
+#if Q0074_COLOUR_REMAPPING_SEI
+  Void  setCRISEIFile( Char* pch )                           { m_colourRemapSEIFile = pch; }
+  Char* getCRISEIFile()                                      { return m_colourRemapSEIFile; }
+  Void  setCRISEIId(Int i)                                   { m_colourRemapSEIId = i; }
+  Int   getCRISEIId()                                        { return m_colourRemapSEIId; }
+  Void  setCRISEICancelFlag(Bool b)                          { m_colourRemapSEICancelFlag = b; }
+  Bool  getCRISEICancelFlag()                                { return m_colourRemapSEICancelFlag; }
+  Void  setCRISEIPersistenceFlag(Bool b)                     { m_colourRemapSEIPersistenceFlag = b; }
+  Bool  getCRISEIPersistenceFlag()                           { return m_colourRemapSEIPersistenceFlag; }
+  Void  setCRISEIVideoSignalTypePresentFlag(Bool b)          { m_colourRemapSEIVideoSignalTypePresentFlag = b; }
+  Bool  getCRISEIVideoSignalTypePresentFlag()                { return m_colourRemapSEIVideoSignalTypePresentFlag; }
+  Void  setCRISEIVideoFullRangeFlag(Bool b)                  { m_colourRemapSEIVideoFullRangeFlag = b; }
+  Bool  getCRISEIVideoFullRangeFlag()                        { return m_colourRemapSEIVideoFullRangeFlag; }
+  Void  setCRISEIPrimaries(Int i)                            { m_colourRemapSEIPrimaries = i; }
+  Int   getCRISEIPrimaries()                                 { return m_colourRemapSEIPrimaries; }  
+  Void  setCRISEITransferCharacteristics(Int i)              { m_colourRemapSEITransferCharacteristics = i; }
+  Int   getCRISEITransferCharacteristics()                   { return m_colourRemapSEITransferCharacteristics; }  
+  Void  setCRISEIMatrixCoeffs(Int i)                         { m_colourRemapSEIMatrixCoeffs = i; }
+  Int   getCRISEIMatrixCoeffs()                              { return m_colourRemapSEIMatrixCoeffs; }
+  Void  setCRISEICodedDataBitDepth(Int i)                    { m_colourRemapSEICodedDataBitDepth = i; }
+  Int   getCRISEICodedDataBitDepth()                         { return m_colourRemapSEICodedDataBitDepth; } 
+  Void  setCRISEITargetBitDepth(Int i)                       { m_colourRemapSEITargetBitDepth = i; }
+  Int   getCRISEITargetBitDepth()                            { return m_colourRemapSEITargetBitDepth; } 
+  Void  setCRISEIPreLutNumValMinus1(Int *i)                  { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutNumValMinus1[c] = i[c]; }
+  Int   getCRISEIPreLutNumValMinus1(Int i)                   { return m_colourRemapSEIPreLutNumValMinus1[i]; }
+  Void  setCRISEIPreLutCodedValue(Int **i)                   { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutCodedValue[c] = i[c]; }
+  Int*  getCRISEIPreLutCodedValue(Int i)                     { return m_colourRemapSEIPreLutCodedValue[i]; }
+  Void  setCRISEIPreLutTargetValue(Int **i)                  { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutTargetValue[c] = i[c]; }
+  Int*  getCRISEIPreLutTargetValue(Int i)                    { return m_colourRemapSEIPreLutTargetValue[i]; }
+  Void  setCRISEIMatrixPresentFlag(Bool b)                   { m_colourRemapSEIMatrixPresentFlag = b; }
+  Bool  getCRISEIMatrixPresentFlag()                         { return m_colourRemapSEIMatrixPresentFlag; }
+  Void  setCRISEILog2MatrixDenom(Int i)                      { m_colourRemapSEILog2MatrixDenom = i; }
+  Int   getCRISEILog2MatrixDenom()                           { return m_colourRemapSEILog2MatrixDenom; } 
+  Void  setCRISEICoeffs(Int i[3][3])                         { for(Int c=0 ; c<3 ; c++) for(Int j=0 ; j<3 ; j++) m_colourRemapSEICoeffs[c][j] = i[c][j]; }
+  Int*  getCRISEICoeffs(Int i)                               { return m_colourRemapSEICoeffs[i]; }
+  Void  setCRISEIPostLutNumValMinus1(Int *i)                 { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutNumValMinus1[c] = i[c]; }
+  Int   getCRISEIPostLutNumValMinus1(Int i)                  { return m_colourRemapSEIPostLutNumValMinus1[i]; }
+  Void  setCRISEIPostLutCodedValue(Int **i)                  { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutCodedValue[c] = i[c]; }
+  Int*  getCRISEIPostLutCodedValue(Int i)                    { return m_colourRemapSEIPostLutCodedValue[i]; }
+  Void  setCRISEIPostLutTargetValue(Int **i)                 { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutTargetValue[c] = i[c]; }
+  Int*  getCRISEIPostLutTargetValue(Int i)                   { return m_colourRemapSEIPostLutTargetValue[i]; }
 #endif
   Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 856)
@@ -365,85 +365,61 @@
 #endif
 
-#if Q0074_SEI_COLOR_MAPPING
-SEIColorMappingInfo*  TEncGOP::xCreateSEIColorMappingInfo( Char* file )
+#if Q0074_COLOUR_REMAPPING_SEI
+SEIColourRemappingInfo*  TEncGOP::xCreateSEIColourRemappingInfo()
 {
-  SEIColorMappingInfo *seiColorMappingInfo = new SEIColorMappingInfo();
-
-  FILE* fic = fopen( file, "r" );
-
-  Int iVal, retval;
-
-  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMapId );
-  retval = fscanf( fic, "%d", &iVal );
-  seiColorMappingInfo->m_colorMapCancelFlag = iVal;
-  if( !seiColorMappingInfo->m_colorMapCancelFlag )
-  {
-    retval = fscanf( fic, "%d", &iVal );
-    seiColorMappingInfo->m_colorMapPersistenceFlag = iVal;
-    retval = fscanf( fic, "%d", &iVal );
-    seiColorMappingInfo->m_colorMap_video_signal_type_present_flag = iVal;
-    if( seiColorMappingInfo->m_colorMap_video_signal_type_present_flag )
-    {
-      retval = fscanf( fic, "%d", &iVal );
-      seiColorMappingInfo->m_colorMap_video_full_range_flag = iVal;
-      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_primaries );
-      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_transfer_characteristics );
-      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_matrix_coeffs );
-    }
-  }
-
-  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_coded_data_bit_depth );
-  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_target_bit_depth );
-  retval = fscanf( fic, "%d", &iVal );
-  seiColorMappingInfo->m_colorMapModelId = iVal;
-
-  assert( seiColorMappingInfo->m_colorMapModelId == 0 );
-  
-  for( Int i=0 ; i<3 ; i++ )
-  {
-    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_input_pivots[i] );
-    seiColorMappingInfo->m_coded_input_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
-    seiColorMappingInfo->m_target_input_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
-    for( Int j=0 ; j<seiColorMappingInfo->m_num_input_pivots[i] ; j++ )
-    {
-      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_input_pivot_value[i][j] );
-      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_input_pivot_value[i][j] );
-    }
-  }
-
-  retval = fscanf( fic, "%d", &iVal );
-  seiColorMappingInfo->m_matrix_flag = iVal;
-  if( seiColorMappingInfo->m_matrix_flag )
-  {
-    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_log2_matrix_denom );
-    for( Int i=0 ; i<3 ; i++ )
-    {
-      for( Int j=0 ; j<3 ; j++ )
-      {
-        retval = fscanf( fic, "%d", &seiColorMappingInfo->m_matrix_coef[i][j] );
-      }
-    }
-  }
-
-  for( Int i=0 ; i<3 ; i++ )
-  {
-    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_output_pivots[i] );
-    seiColorMappingInfo->m_coded_output_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
-    seiColorMappingInfo->m_target_output_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
-    for( Int j=0 ; j<seiColorMappingInfo->m_num_output_pivots[i] ; j++ )
-    {
-      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_output_pivot_value[i][j] );
-      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_output_pivot_value[i][j] );
-    }
-  }
-
-  fclose( fic );
-
-  if( retval != 1 )
-  {
-    printf("Error: can't read color mapping information\n");
-  }
-
-  return seiColorMappingInfo;
+  SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo();
+  seiColourRemappingInfo->m_colourRemapId         = m_pcCfg->getCRISEIId();
+  seiColourRemappingInfo->m_colourRemapCancelFlag = m_pcCfg->getCRISEICancelFlag();
+  if( !seiColourRemappingInfo->m_colourRemapCancelFlag )
+  {
+    seiColourRemappingInfo->m_colourRemapPersistenceFlag            = m_pcCfg->getCRISEIPersistenceFlag();
+    seiColourRemappingInfo->m_colourRemapVideoSignalTypePresentFlag = m_pcCfg->getCRISEIVideoSignalTypePresentFlag();
+    if( seiColourRemappingInfo->m_colourRemapVideoSignalTypePresentFlag )
+    {
+      seiColourRemappingInfo->m_colourRemapVideoFullRangeFlag      = m_pcCfg->getCRISEIVideoFullRangeFlag();
+      seiColourRemappingInfo->m_colourRemapPrimaries               = m_pcCfg->getCRISEIPrimaries();
+      seiColourRemappingInfo->m_colourRemapTransferCharacteristics = m_pcCfg->getCRISEITransferCharacteristics();
+      seiColourRemappingInfo->m_colourRemapMatrixCoeffs            = m_pcCfg->getCRISEIMatrixCoeffs();
+    }
+    seiColourRemappingInfo->m_colourRemapCodedDataBitDepth = m_pcCfg->getCRISEICodedDataBitDepth();
+    seiColourRemappingInfo->m_colourRemapTargetBitDepth    = m_pcCfg->getCRISEITargetBitDepth();
+    for( Int c=0 ; c<3 ; c++ )
+    {
+      seiColourRemappingInfo->m_preLutNumValMinus1[c] = m_pcCfg->getCRISEIPreLutNumValMinus1(c);
+      if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 )
+      {
+        seiColourRemappingInfo->m_preLutCodedValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);
+        seiColourRemappingInfo->m_preLutTargetValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);
+        for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++)
+        {
+          seiColourRemappingInfo->m_preLutCodedValue[c][i]  = (m_pcCfg->getCRISEIPreLutCodedValue(c))[i];
+          seiColourRemappingInfo->m_preLutTargetValue[c][i] = (m_pcCfg->getCRISEIPreLutTargetValue(c))[i];
+        }
+      }
+    }
+    seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = m_pcCfg->getCRISEIMatrixPresentFlag();
+    if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag )
+    {
+      seiColourRemappingInfo->m_log2MatrixDenom = m_pcCfg->getCRISEILog2MatrixDenom();
+      for( Int c=0 ; c<3 ; c++ )
+        for( Int i=0 ; i<3 ; i++ )
+          seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = (m_pcCfg->getCRISEICoeffs(c))[i];
+    }
+    for( Int c=0 ; c<3 ; c++ )
+    {
+      seiColourRemappingInfo->m_postLutNumValMinus1[c] = m_pcCfg->getCRISEIPostLutNumValMinus1(c);
+      if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 )
+      {
+        seiColourRemappingInfo->m_postLutCodedValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);
+        seiColourRemappingInfo->m_postLutTargetValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);
+        for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++)
+        {
+          seiColourRemappingInfo->m_postLutCodedValue[c][i]  = (m_pcCfg->getCRISEIPostLutCodedValue(c))[i];
+          seiColourRemappingInfo->m_postLutTargetValue[c][i] = (m_pcCfg->getCRISEIPostLutTargetValue(c))[i];
+        }
+      }
+    }
+  }
+  return seiColourRemappingInfo;
 }
 #endif
@@ -532,11 +508,11 @@
   }
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  if(m_pcCfg->getColorMappingInfoSEIFile())
-  {
-    SEIColorMappingInfo *sei = xCreateSEIColorMappingInfo( m_pcCfg->getColorMappingInfoSEIFile() );
+#if Q0074_COLOUR_REMAPPING_SEI
+  if(m_pcCfg->getCRISEIFile())
+  {
+    SEIColourRemappingInfo *sei = xCreateSEIColourRemappingInfo ();
       
 #if SVC_EXTENSION
-    nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_layerId);  // temporalId = 0 ?
+    nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, sps->getLayerId());  // SEI-CRI is applied per layer
 #else
     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h	(revision 855)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h	(revision 856)
@@ -225,6 +225,6 @@
   SEIKneeFunctionInfo*    xCreateSEIKneeFunctionInfo();
 #endif
-#if Q0074_SEI_COLOR_MAPPING
-  SEIColorMappingInfo*    xCreateSEIColorMappingInfo( Char* file );
+#if Q0074_COLOUR_REMAPPING_SEI
+  SEIColourRemappingInfo* xCreateSEIColourRemappingInfo();
 #endif
 
