Index: branches/SHM-6-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-6-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 688)
+++ branches/SHM-6-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 694)
@@ -693,22 +693,31 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
           const Bool isTff = pcPicTop->isTopField();
+          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
 #if Q0200_CONFORMANCE_BL_SIZE
-Int xScal=1,yScal=1;
-#else
-UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
-Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
-#endif
-m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
-conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
-conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
-conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
-conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset(), isTff );
+          Int xScal=1,yScal=1;
+#else
+          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
+          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
+#endif
+          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
+            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
+            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
+            conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
+            conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset(), isTff );
 #else
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
           // Compile time bug-fix
-          m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
-#else
-          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
+#else
+          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
 #endif
             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
@@ -727,5 +736,14 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
           const Bool isTff = pcPicTop->isTopField();
-          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+          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(),
             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
@@ -800,18 +818,26 @@
           const Window &conf = pcPic->getConformanceWindow();
           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
 #if Q0200_CONFORMANCE_BL_SIZE
-Int xScal=1,yScal=1;
-#else
-UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
-Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
-#endif
-m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
-conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
-conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
-conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
-conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
-#else
-          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
+          Int xScal=1,yScal=1;
+#else
+          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
+          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
+#endif
+          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
+            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
+            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
+            conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
+            conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
+#else
+          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
@@ -827,7 +853,14 @@
         {
 #if SYNTAX_OUTPUT
+          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
+#if Q0074_SEI_COLOR_MAPPING
+          if( m_acTDecTop[layerIdx].m_ColorMapping->getColorMappingFlag() )
+          {
+            pPicCYuvRec = m_acTDecTop[layerIdx].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerIdx );
+          }
+#endif
           const Window &conf = pcPic->getConformanceWindow();
           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
-          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
+          m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
@@ -903,22 +936,31 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
           const Bool isTff = pcPicTop->isTopField();
+          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
 #if Q0200_CONFORMANCE_BL_SIZE
-Int xScal=1,yScal=1;
-#else
-UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
-Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
-#endif
-m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
-conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
-conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
-conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
-conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset(), isTff );
+          Int xScal=1,yScal=1;
+#else
+          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
+          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
+#endif
+          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
+            conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
+            conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
+            conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
+            conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset(), isTff );
 #else
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
           // Compile time bug-fix
-          m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
-#else
-          m_cTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
+#else
+          m_cTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
 #endif
             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
@@ -937,5 +979,14 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
           const Bool isTff = pcPicTop->isTopField();
-          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+          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(),
             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
@@ -1013,18 +1064,25 @@
           const Window &conf = pcPic->getConformanceWindow();
           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
 #if Q0200_CONFORMANCE_BL_SIZE
-Int xScal=1,yScal=1;
-#else
-UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
-Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
-#endif
-m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
-conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
-conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
-conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
-conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() );
-#else
-          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
+          Int xScal=1,yScal=1;
+#else
+          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
+          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
+#endif
+          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
+            conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
+            conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
+            conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
+            conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() );
+#else
+          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
@@ -1041,5 +1099,12 @@
           const Window &conf = pcPic->getConformanceWindow();
           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
-          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
+          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(),
             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
@@ -1118,13 +1183,17 @@
     Int xScal =  1, yScal = 1;
 #if REPN_FORMAT_IN_VPS && !Q0200_CONFORMANCE_BL_SIZE
-UInt chromaFormatIdc = pic->getSlice(0)->getChromaFormatIdc();
-xScal = TComSPS::getWinUnitX( chromaFormatIdc );
-yScal = TComSPS::getWinUnitY( chromaFormatIdc );
-#endif
-m_acTVideoIOYuvReconFile[layerIdx].write( pic->getPicYuvRec(),
-conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
-conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
-conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
-conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
+    UInt chromaFormatIdc = pic->getSlice(0)->getChromaFormatIdc();
+    xScal = TComSPS::getWinUnitX( chromaFormatIdc );
+    yScal = TComSPS::getWinUnitY( chromaFormatIdc );
+#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(),
+      conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
+      conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
+      conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
   }
   // update POC of display order
