Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1286)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1287)
@@ -4308,14 +4308,4 @@
   g_uiMaxCUDepth = m_uiMaxCUDepth;
 #endif
-
-  // set internal bit-depth and constants
-  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
-  {
-#if O0043_BEST_EFFORT_DECODING
-    g_bitDepthInStream[channelType] = g_bitDepth[channelType] = m_internalBitDepth[channelType];
-#else
-    g_bitDepth   [channelType] = m_internalBitDepth[channelType];
-#endif
-  }
 }
 #endif
@@ -4489,5 +4479,5 @@
   printf("TOOL CFG: ");
 #if !SVC_EXTENSION
-  printf("IBD:%d ", ((g_bitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (g_bitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
+  printf("IBD:%d ", ((m_internalBitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (m_internalBitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
 #endif
   printf("HAD:%d ", m_bUseHADME           );
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1286)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1287)
@@ -217,11 +217,4 @@
   {
     //1
-    g_bitDepth[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA];
-    g_bitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
-
-    // Set this to be used in Upsampling filter in function "TComUpsampleFilter::upsampleBasePic"
-    g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_acLayerCfg[layer].m_layerId]   = g_bitDepth[CHANNEL_TYPE_LUMA];
-    g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_acLayerCfg[layer].m_layerId] = g_bitDepth[CHANNEL_TYPE_CHROMA];
-
     m_acTEncTop[layer].setInterLayerWeightedPredFlag                      ( m_useInterLayerWeightedPred );
     
@@ -475,5 +468,6 @@
     for( UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++ )
     {
-      m_acTEncTop[layer].setPCMBitDepth                                      ((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_MSBExtendedBitDepth[channelType] : m_acLayerCfg[layer].m_internalBitDepth[channelType]);
+      m_acTEncTop[layer].setBitDepth                                       ((ChannelType)channelType, m_acLayerCfg[layer].m_internalBitDepth[channelType]);
+      m_acTEncTop[layer].setPCMBitDepth                                    ((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_MSBExtendedBitDepth[channelType] : m_acLayerCfg[layer].m_internalBitDepth[channelType]);
     }
     m_acTEncTop[layer].setPCMLog2MaxSize                                   ( m_pcmLog2MaxSize);
@@ -904,9 +898,5 @@
   for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
   {
-//#if O0043_BEST_EFFORT_DECODING
-    //g_bitDepthInStream[channelType] = g_bitDepth[channelType] = m_internalBitDepth[channelType];
-//#else
-    //g_bitDepth   [channelType] = m_internalBitDepth[channelType];
-//#endif
+    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]);
     m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]);
   }
@@ -1094,9 +1084,4 @@
   {
     //2
-    for( UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
-    {
-      g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
-    }
-
 #if LAYER_CTB
     g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
@@ -1193,8 +1178,4 @@
   {
     //3
-    for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
-    {
-      g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
-    }
 #if LAYER_CTB
     g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
@@ -1233,7 +1214,4 @@
         Int layerIdx = vps->getLayerIdxInVps(m_layerSetLayerIdList[setId][i]);
         //4
-        g_bitDepth[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_LUMA];
-        g_bitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
-
         vps->setLayerIdIncludedFlag(true, setId, layerId);
       }
@@ -1250,6 +1228,4 @@
         //4
         UInt layerId = vps->getLayerIdInNuh(layerIdx);
-        g_bitDepth[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_LUMA];
-        g_bitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
 
         if (layerId <= setId)
@@ -1702,7 +1678,4 @@
   {
     //5
-    g_bitDepth[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA];
-    g_bitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
-
     // allocate original YUV buffer
     pcPicYuvOrg[layer] = new TComPicYuv;
@@ -1739,8 +1712,4 @@
       {
         //6
-        for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
-        {
-          g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
-        }
 #if LAYER_CTB
         g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
@@ -1759,5 +1728,5 @@
         if( m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400 || (m_apcTEncTop[0]->getVPS()->getScalabilityMask(AUX_ID) && (m_acLayerCfg[layer].getAuxId() == AUX_ALPHA || m_acLayerCfg[layer].getAuxId() == AUX_DEPTH)) )
         {
-          pcPicYuvOrg[layer]->convertToMonochrome();
+          pcPicYuvOrg[layer]->convertToMonochrome(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
         }
 #endif
@@ -1823,8 +1792,4 @@
       {
         //7
-        for( UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++ )
-        {
-          g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
-        }
 #if LAYER_CTB
         g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
@@ -1895,9 +1860,4 @@
     {
       //8
-      for( UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++ )
-      {
-        g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
-      }
-
       // write bistream to file if necessary
       iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
@@ -1983,5 +1943,7 @@
   for(layer = 0; layer < m_numLayers; layer++)
   {
-    m_gcAnalyzeAll[layer].printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
+    const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+
+    m_gcAnalyzeAll[layer].printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
   }
 
@@ -1989,5 +1951,7 @@
   for(layer = 0; layer < m_numLayers; layer++)
   {
-    m_gcAnalyzeI[layer].printOut('i', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
+    const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+
+    m_gcAnalyzeI[layer].printOut('i', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
   }
 
@@ -1995,5 +1959,7 @@
   for(layer = 0; layer < m_numLayers; layer++)
   {
-    m_gcAnalyzeP[layer].printOut('p', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
+    const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+
+    m_gcAnalyzeP[layer].printOut('p', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
   }
 
@@ -2001,5 +1967,7 @@
   for(layer = 0; layer < m_numLayers; layer++)
   {
-    m_gcAnalyzeB[layer].printOut('b', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
+    const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+
+    m_gcAnalyzeB[layer].printOut('b', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
   }
 
@@ -2008,4 +1976,6 @@
     for(layer = 0; layer < m_numLayers; layer++)
     {
+      const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+
       //-- interlaced summary
       m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate());
@@ -2014,5 +1984,5 @@
 
       printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
-      m_gcAnalyzeAll_in.printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
+      m_gcAnalyzeAll_in.printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
 
 #if _SUMMARY_OUT_
