Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 474)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 475)
@@ -79,14 +79,26 @@
 }
 #if SVC_UPSAMPLING
+#if AUXILIARY_PICTURES
+Void TComPic::create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
+                      Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual)
+#else
 Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
                       Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual)
-
+#endif
 {
   m_apcPicSym     = new TComPicSym;  m_apcPicSym   ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
   if (!bIsVirtual)
   {
+#if AUXILIARY_PICTURES
+    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
+#else
     m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
-  }
+#endif
+  }
+#if AUXILIARY_PICTURES
+  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
+#else
   m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
+#endif
 
   for( Int i = 0; i < MAX_LAYERS; i++ )
@@ -94,5 +106,9 @@
     if( m_bSpatialEnhLayer[i] )
     {
+#if AUXILIARY_PICTURES
+      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
+#else
       m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
+#endif
     }
   }
@@ -407,5 +423,10 @@
   {
     m_pNDBFilterYuvTmp = new TComPicYuv();
+#if AUXILIARY_PICTURES
+    m_pNDBFilterYuvTmp->create(picWidth, picHeight, getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
+#else
     m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
+#endif
+
   }
 
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.h	(revision 474)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPic.h	(revision 475)
@@ -102,4 +102,13 @@
   virtual ~TComPic();
   
+#if AUXILIARY_PICTURES
+#if SVC_UPSAMPLING
+  Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, 
+                        Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false );
+#else
+  Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, 
+                        Int *numReorderPics, Bool bIsVirtual = false );                        
+#endif
+#else
 #if SVC_UPSAMPLING
   Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, 
@@ -108,4 +117,5 @@
   Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, 
                         Int *numReorderPics, Bool bIsVirtual = false );                        
+#endif
 #endif
   virtual Void  destroy();
@@ -166,4 +176,7 @@
   
   Int           getStride()           { return m_apcPicYuv[1]->getStride(); }
+#if AUXILIARY_PICTURES
+  ChromaFormat  getChromaFormat() const { return m_apcPicYuv[1]->getChromaFormat(); }
+#endif
   Int           getCStride()          { return m_apcPicYuv[1]->getCStride(); }
   
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 474)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 475)
@@ -67,8 +67,16 @@
 {
 }
+#if AUXILIARY_PICTURES
+#if SVC_UPSAMPLING
+Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
+#else
+Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
+#endif
+#else
 #if SVC_UPSAMPLING
 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
 #else
 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
+#endif
 #endif
 {
@@ -86,4 +94,7 @@
   m_iCuWidth        = uiMaxCUWidth;
   m_iCuHeight       = uiMaxCUHeight;
+#if AUXILIARY_PICTURES
+  m_chromaFormatIDC = chromaFormatIDC;
+#endif
 
   Int numCuInWidth  = m_iPicWidth  / m_iCuWidth  + (m_iPicWidth  % m_iCuWidth  != 0);
@@ -239,4 +250,18 @@
 }
 
+#if AUXILIARY_PICTURES
+Void TComPicYuv::convertToMonochrome()
+{
+  Int numPix = ((m_iPicWidth >> 1) + (m_iChromaMarginX << 1)) * ((m_iPicHeight >> 1) + (m_iChromaMarginY << 1));
+  Pel grayVal = (1 << (g_bitDepthC - 1));
+
+  for (UInt i = 0; i < numPix; i++)
+  {
+    m_apiPicBufU[i] = grayVal;
+    m_apiPicBufV[i] = grayVal;
+  }
+}
+#endif
+
 Void TComPicYuv::extendPicBorder ()
 {
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.h	(revision 474)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.h	(revision 475)
@@ -75,4 +75,7 @@
   Int   m_iPicWidth;            ///< Width of picture
   Int   m_iPicHeight;           ///< Height of picture
+#if AUXILIARY_PICTURES
+  ChromaFormat m_chromaFormatIDC; ////< Chroma Format
+#endif
   
   Int   m_iCuWidth;             ///< Width of Coding Unit (CU)
@@ -108,4 +111,11 @@
   //  Memory management
   // ------------------------------------------------------------------------------------------------
+#if AUXILIARY_PICTURES
+#if SVC_UPSAMPLING
+  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
+#else
+  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
+#endif  
+#else
 #if SVC_UPSAMPLING
   Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
@@ -113,4 +123,5 @@
   Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
 #endif  
+#endif
   
   Void  destroy     ();
@@ -125,4 +136,7 @@
   Int   getWidth    ()     { return  m_iPicWidth;    }
   Int   getHeight   ()     { return  m_iPicHeight;   }
+#if AUXILIARY_PICTURES
+  ChromaFormat  getChromaFormat   ()                     const { return m_chromaFormatIDC; }
+#endif
   
 #if SVC_EXTENSION
@@ -184,4 +198,8 @@
 #endif
 
+#if AUXILIARY_PICTURES
+  Void convertToMonochrome();
+#endif
+
   // Set border extension flag
   Void  setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 474)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 475)
@@ -1840,5 +1840,29 @@
   return retVal;
 }
+#if AUXILIARY_PICTURES
+ChromaFormat TComSlice::getChromaFormatIdc()
+#else
 UInt TComSlice::getChromaFormatIdc()
+#endif
+{
+  TComSPS *sps = getSPS();
+  TComVPS *vps = getVPS();
+#if AUXILIARY_PICTURES
+  ChromaFormat retVal;
+  UInt layerId = getLayerId();
+#else
+  UInt retVal, layerId = getLayerId();
+#endif
+  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
+  {
+    retVal = sps->getChromaFormatIdc();
+  }
+  else
+  {
+    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc();
+  }
+  return retVal;
+}
+UInt TComSlice::getBitDepthY()
 {
   TComSPS *sps = getSPS();
@@ -1847,13 +1871,13 @@
   if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
   {
-    retVal = sps->getChromaFormatIdc();
+    retVal = sps->getBitDepthY();
   }
   else
   {
-    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc();
+    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma();
   }
   return retVal;
 }
-UInt TComSlice::getBitDepthY()
+UInt TComSlice::getBitDepthC()
 {
   TComSPS *sps = getSPS();
@@ -1862,27 +1886,12 @@
   if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
   {
-    retVal = sps->getBitDepthY();
+    retVal = sps->getBitDepthC();
   }
   else
   {
-    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma();
+    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma();
   }
   return retVal;
 }
-UInt TComSlice::getBitDepthC()
-{
-  TComSPS *sps = getSPS();
-  TComVPS *vps = getVPS();
-  UInt retVal, layerId = getLayerId();
-  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
-  {
-    retVal = sps->getBitDepthC();
-  }
-  else
-  {
-    retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma();
-  }
-  return retVal;
-}
 Int TComSlice::getQpBDOffsetY()
 {
@@ -1895,5 +1904,9 @@
 
 RepFormat::RepFormat()
+#if AUXILIARY_PICTURES
+: m_chromaFormatVpsIdc          (CHROMA_420)
+#else
 : m_chromaFormatVpsIdc          (0)
+#endif
 , m_separateColourPlaneVpsFlag  (false)
 , m_picWidthVpsInLumaSamples    (0)
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 474)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 475)
@@ -436,5 +436,9 @@
 class RepFormat
 {
+#if AUXILIARY_PICTURES
+  ChromaFormat m_chromaFormatVpsIdc;
+#else
   Int  m_chromaFormatVpsIdc;
+#endif
   Bool m_separateColourPlaneVpsFlag;
   Int  m_picWidthVpsInLumaSamples;
@@ -446,6 +450,11 @@
   RepFormat();
 
+#if AUXILIARY_PICTURES
+  ChromaFormat getChromaFormatVpsIdc()        { return m_chromaFormatVpsIdc; }
+  Void setChromaFormatVpsIdc(ChromaFormat x)  { m_chromaFormatVpsIdc = x;    }
+#else
   Int  getChromaFormatVpsIdc()        { return m_chromaFormatVpsIdc; }
   Void setChromaFormatVpsIdc(Int x)   { m_chromaFormatVpsIdc = x;    }
+#endif
 
   Bool getSeparateColourPlaneVpsFlag()        { return m_separateColourPlaneVpsFlag; }
@@ -1072,5 +1081,9 @@
   Int         m_SPSId;
   Int         m_VPSId;
+#if AUXILIARY_PICTURES
+  ChromaFormat m_chromaFormatIdc;
+#else
   Int         m_chromaFormatIdc;
+#endif
 
   UInt        m_uiMaxTLayers;           // maximum number of temporal layers
@@ -1182,9 +1195,18 @@
   Int  getSPSId       ()         { return m_SPSId;          }
   Void setSPSId       (Int i)    { m_SPSId = i;             }
+#if AUXILIARY_PICTURES
+  ChromaFormat getChromaFormatIdc ()         { return m_chromaFormatIdc;       }
+#else
   Int  getChromaFormatIdc ()         { return m_chromaFormatIdc;       }
-  Void setChromaFormatIdc (Int i)    { m_chromaFormatIdc = i;          }
-
+#endif
+  Void setChromaFormatIdc (ChromaFormat i)    { m_chromaFormatIdc = i;          }
+
+#if AUXILIARY_PICTURES
+  static Int getWinUnitX (Int chromaFormatIdc) { assert (chromaFormatIdc >= 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitX[chromaFormatIdc];      }
+  static Int getWinUnitY (Int chromaFormatIdc) { assert (chromaFormatIdc >= 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitY[chromaFormatIdc];      }
+#else
   static Int getWinUnitX (Int chromaFormatIdc) { assert (chromaFormatIdc > 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitX[chromaFormatIdc];      }
   static Int getWinUnitY (Int chromaFormatIdc) { assert (chromaFormatIdc > 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitY[chromaFormatIdc];      }
+#endif
   
   // structure
@@ -2069,5 +2091,9 @@
   UInt getPicWidthInLumaSamples();
   UInt getPicHeightInLumaSamples();
+#if AUXILIARY_PICTURES
+  ChromaFormat getChromaFormatIdc();
+#else
   UInt getChromaFormatIdc();
+#endif
   UInt getBitDepthY();
   UInt getBitDepthC();
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 474)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 475)
@@ -153,4 +153,5 @@
 
 #define O0215_PHASE_ALIGNMENT            1     // JCTVC_O0215: signal a flag to specify phase alignment case, 0: zero-position-aligned, 1: central-position-aligned,
+#define AUXILIARY_PICTURES               1
 
 #else
@@ -464,4 +465,7 @@
   CHROMA_422  = 2,
   CHROMA_444  = 3
+#if AUXILIARY_PICTURES
+  ,NUM_CHROMA_FORMAT = 4
+#endif
 };
 
