Index: branches/SHM-4.0-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-4.0-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 468)
@@ -2,5 +2,5 @@
  * License, included below. This software may be subject to other third party
  * and contributor rights, including patent rights, and no such rights are
- * granted under this license.  
+ * granted under this license.
  *
  * Copyright (c) 2010-2013, ITU/ISO/IEC
@@ -80,5 +80,5 @@
     m_pchBitstreamFile = NULL;
   }
-#if SVC_EXTENSION   
+#if SVC_EXTENSION
   for( Int i = 0; i < m_tgtLayerId; i++ )
   {
@@ -88,5 +88,5 @@
       m_pchReconFile[i] = NULL;
     }
-  }  
+  }
 #if AVC_BASE
   if( m_pchBLReconFile )
@@ -240,5 +240,5 @@
       if ( m_pchReconFile[curLayerId] && !openedReconFile[curLayerId] )
       {
-        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }        
+        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
         if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
 
@@ -247,5 +247,5 @@
         openedReconFile[curLayerId] = true;
       }
-      if ( bNewPicture && bNewPOC && 
+      if ( bNewPicture && bNewPOC &&
            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
@@ -281,5 +281,5 @@
   }
 #endif
-  pcBLPic.destroy();  
+  pcBLPic.destroy();
 
   for(UInt layer = layerIdmin; layer <= m_tgtLayerId; layer++)
@@ -290,5 +290,5 @@
     m_acTDecTop[layer].deletePicBuffer();
   }
-  
+
   // destroy internal classes
   xDestroyDecLib();
@@ -399,5 +399,5 @@
         openedReconFile = true;
       }
-      if ( bNewPicture && 
+      if ( bNewPicture &&
            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
@@ -415,5 +415,5 @@
     }
   }
-  
+
 #if SYNTAX_OUTPUT
   if( streamSyntaxFile.is_open() )
@@ -422,9 +422,9 @@
   }
 #endif
-  
+
   xFlushOutput( pcListPic );
   // delete buffers
   m_cTDecTop.deletePicBuffer();
-  
+
   // destroy internal classes
   xDestroyDecLib();
@@ -440,5 +440,5 @@
 #if SVC_EXTENSION
   // initialize global variables
-  initROM();  
+  initROM();
 
   for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
@@ -450,5 +450,5 @@
     m_acTDecTop[layer].create();
 
-    m_acTDecTop[layer].setLayerDec(m_apcTDecTop);   
+    m_acTDecTop[layer].setLayerDec(m_apcTDecTop);
   }
 #else
@@ -479,5 +479,5 @@
     m_cTVideoIOYuvReconFile. close();
   }
-  
+
   // destroy decoder class
   m_cTDecTop.destroy();
@@ -571,5 +571,6 @@
 
 #else
-#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+          // Compile time bug-fix
           m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
 #else
@@ -732,5 +733,5 @@
   {
     return;
-  } 
+  }
   TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
 
@@ -768,5 +769,6 @@
 
 #else
-#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+          // Compile time bug-fix
           m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
 #else
@@ -926,5 +928,5 @@
         pcPic = NULL;
       }
-#endif    
+#endif
 #endif
       iterPic++;
Index: branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 468)
@@ -1269,5 +1269,6 @@
   /* rules for input, output and internal bitdepths as per help text */
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
-  for(Int layer = 0; layer < MAX_LAYERS; layer++){
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
     if (!m_acLayerCfg[layer].m_internalBitDepthY) { m_acLayerCfg[layer].m_internalBitDepthY = m_acLayerCfg[layer].m_inputBitDepthY; }
     if (!m_acLayerCfg[layer].m_internalBitDepthC) { m_acLayerCfg[layer].m_internalBitDepthC = m_acLayerCfg[layer].m_internalBitDepthY; }
@@ -1541,5 +1542,6 @@
   // check range of parameters
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
-  for(UInt layer=0; layer<m_numLayers; layer++){
+  for(UInt layer=0; layer<m_numLayers; layer++)
+  {
     xConfirmPara( m_acLayerCfg[layer].m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
     xConfirmPara( m_acLayerCfg[layer].m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
@@ -2461,4 +2463,6 @@
   printf("GOP size                     : %d\n", m_iGOPSize );
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
+  printf("Input bit depth Layer0       : (Y:%d, C:%d)\n", m_acLayerCfg[0].m_inputBitDepthY   , m_acLayerCfg[0].m_inputBitDepthC    );
+  printf("Input bit depth Layer1       : (Y:%d, C:%d)\n", m_acLayerCfg[1].m_internalBitDepthY, m_acLayerCfg[1].m_internalBitDepthC );
   printf("Internal bit depth Layer0    : (Y:%d, C:%d)\n", m_acLayerCfg[0].m_internalBitDepthY, m_acLayerCfg[0].m_internalBitDepthC );
   printf("Internal bit depth Layer1    : (Y:%d, C:%d)\n", m_acLayerCfg[1].m_internalBitDepthY, m_acLayerCfg[1].m_internalBitDepthC );
@@ -2568,5 +2572,4 @@
   printf("O0194_JOINT_US_BITSHIFT: %d ", O0194_JOINT_US_BITSHIFT);
   printf("O0194_WEIGHTED_PREDICTION_CGS: %d ",O0194_WEIGHTED_PREDICTION_CGS);
-  printf("O0194_REPN_FORMAT_IN_VPS_BUGFIX: %d ",O0194_REPN_FORMAT_IN_VPS_BUGFIX);
   printf("\n\n");
   
Index: branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 467)
+++ branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 468)
@@ -173,4 +173,5 @@
   Int       m_internalBitDepthC;                            ///< bit-depth codec operates at in chroma (input/output files will be converted)
 #endif
+
   // coding tools (PCM bit-depth)
   Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
Index: branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp
===================================================================
--- branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 468)
@@ -273,5 +273,6 @@
 
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
-  for(UInt layer = 0; layer < MAX_LAYERS; layer++){
+  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
+  {
     xConfirmPara( m_iQP <  -6 * ((Int)m_cAppEncCfg->getInternalBitDepthY(layer) - 8) || m_iQP > 51,                "QP exceeds supported range (-QpBDOffsety to 51)" );
   }
Index: branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 468)
@@ -146,5 +146,5 @@
     repFormat->setChromaFormatVpsIdc        ( 1                                             );  // Need modification to change for each layer - corresponds to 420
     repFormat->setSeparateColourPlaneVpsFlag( 0                                             );  // Need modification to change for each layer
-#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
     repFormat->setBitDepthVpsLuma           ( getInternalBitDepthY(mapIdxToLayer[idx])      );  // Need modification to change for each layer
     repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC(mapIdxToLayer[idx])      );  // Need modification to change for each layer
@@ -408,5 +408,6 @@
     m_acTEncTop[layer].setWPBiPred                ( m_useWeightedBiPred   );
 #if O0194_WEIGHTED_PREDICTION_CGS
-    if (layer!=0){
+    if (layer!=0)
+    {
       // Enable weighted prediction for enhancement layer
       m_acTEncTop[layer].setUseWP                 ( true   );
@@ -884,4 +885,12 @@
   for(UInt layer=0; layer<m_numLayers; layer++)
   {
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+    //2
+    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
+    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
+
+    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
+    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
+#endif
 #if LAYER_CTB
     g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
@@ -889,12 +898,4 @@
     g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
     g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
-#endif
-#if O0194_DIFFERENT_BITDEPTH_EL_BL
-    //2
-    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
-    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
-
-    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
-    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
 #endif
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
@@ -963,4 +964,12 @@
   for(UInt layer=0; layer<m_numLayers; layer++)
   {
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+    //3
+    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
+    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
+
+    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
+    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
+#endif
 #if LAYER_CTB
     g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
@@ -968,17 +977,9 @@
     g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
     g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
-        
+
     memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) );
     memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) );
     memcpy( g_auiRasterToPelX,  g_auiLayerRasterToPelX[layer],  sizeof( g_auiRasterToPelX ) );
     memcpy( g_auiRasterToPelY,  g_auiLayerRasterToPelY[layer],  sizeof( g_auiRasterToPelY ) );
-#endif
-#if O0194_DIFFERENT_BITDEPTH_EL_BL
-    //3
-    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
-    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
-
-    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
-    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
 #endif
     m_acTEncTop[layer].init(isFieldCoding);
@@ -1307,4 +1308,12 @@
       for(UInt layer=0; layer<m_numLayers; layer++)
       {
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+        //6
+        g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
+        g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
+
+        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
+        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
+#endif
 #if LAYER_CTB
         g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
@@ -1313,12 +1322,5 @@
         g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
 #endif
-#if O0194_DIFFERENT_BITDEPTH_EL_BL
-        //6
-        g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
-        g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
-
-        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
-        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
-#endif
+
         // get buffers
         xGetBuffer(pcPicYuvRec, layer);
@@ -1388,4 +1390,12 @@
       for(UInt layer=0; layer<m_numLayers; layer++)
       {
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+        //7
+        g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
+        g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
+
+        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
+        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
+#endif
 #if LAYER_CTB
         g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
@@ -1398,12 +1408,4 @@
         memcpy( g_auiRasterToPelX,  g_auiLayerRasterToPelX[layer],  sizeof( g_auiRasterToPelX ) );
         memcpy( g_auiRasterToPelY,  g_auiLayerRasterToPelY[layer],  sizeof( g_auiRasterToPelY ) );
-#endif
-#if O0194_DIFFERENT_BITDEPTH_EL_BL
-        //7
-        g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
-        g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
-
-        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
-        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
 #endif
         // call encoding function for one frame
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 468)
@@ -279,5 +279,5 @@
 #if  N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
-  Int nShift = 20 - g_bitDepthYLayer[1];
+    Int nShift = 20 - g_bitDepthYLayer[1];
 #else
     Int nShift = US_FILTER_PREC*2 - shift1;
Index: branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 467)
+++ branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 468)
@@ -45,11 +45,8 @@
 #define RANDOM_ACCESS_SEI_FIX            1
 #if SVC_EXTENSION
-#define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
-
-#define O0194_DIFFERENT_BITDEPTH_EL_BL   1      ///< JCTVC-O0194: Support for different bitdepth values for BL and EL, add required configuration parameters
+#define O0194_DIFFERENT_BITDEPTH_EL_BL   1      ///< JCTVC-O0194: Support for different bitdepth values for BL and EL, add required configuration parameters (and Some bugfixes when REPN_FORMAT_IN_VPS (JCTVC-N0092) is enabled)
 #define O0194_JOINT_US_BITSHIFT          1      ///< JCTVC-O0194: Joint Upsampling and bit-shift
 #define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
-#define O0194_REPN_FORMAT_IN_VPS_BUGFIX  1      ///< JCTVC-O0194: Some bugfixes when REPN_FORMAT_IN_VPS (JCTVC-N0092) is enabled
-
+#define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
 #define VPS_NUH_LAYER_ID                 1      ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0
 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
Index: branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 468)
@@ -2007,5 +2007,5 @@
 
 #if REPN_FORMAT_IN_VPS
-#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
     g_bitDepthYLayer[rpcSlice->getLayerId()]     = rpcSlice->getBitDepthY();
     g_bitDepthCLayer[rpcSlice->getLayerId()]     = rpcSlice->getBitDepthC();
Index: branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCu.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCu.cpp	(revision 468)
@@ -616,5 +616,6 @@
     curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
   }
-#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+  // Bug-fix
 #if REPN_FORMAT_IN_VPS
   m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset );
@@ -776,5 +777,6 @@
   // Cb and Cr
   Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
-#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+  // Bug-fix
 #if REPN_FORMAT_IN_VPS
   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset );
@@ -792,5 +794,6 @@
 
   curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
-#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
+#if O0194_DIFFERENT_BITDEPTH_EL_BL
+  // Bug-fix
 #if REPN_FORMAT_IN_VPS
   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset );
Index: branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 468)
@@ -931,5 +931,6 @@
   }
 #if O0194_WEIGHTED_PREDICTION_CGS
-  else{
+  else
+  {
     // Calculate for the base layer to be used in EL as Inter layer reference
     xCalcACDCParamSlice(pcSlice);
Index: branches/SHM-4.0-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp
===================================================================
--- branches/SHM-4.0-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp	(revision 467)
+++ branches/SHM-4.0-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp	(revision 468)
@@ -232,5 +232,6 @@
       slice->getRefPic(eRefPicList, refIdxTemp)->getSlice(0)->getWpAcDcParam(refWeightACDCParam);
 #if O0194_WEIGHTED_PREDICTION_CGS
-      if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
+      if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(slice->getLayerId()))
+      {
         refWeightACDCParam = (wpACDCParam *)g_refWeightACDCParam;
       }
@@ -250,5 +251,6 @@
         Int64 refAC = refWeightACDCParam[comp].iAC;
 #if O0194_WEIGHTED_PREDICTION_CGS
-        if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
+        if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(slice->getLayerId()))
+        {
           refAC *= (double)currWeightACDCParam[comp].iSamples/refWeightACDCParam[comp].iSamples;
 #if O0194_JOINT_US_BITSHIFT
@@ -264,5 +266,5 @@
         Int offset = (Int)( ((currDC<<log2Denom) - ((Int64)weight * refDC) + (Int64)realOffset) >> realLog2Denom );
 #if O0194_WEIGHTED_PREDICTION_CGS
-        if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
+        if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(slice->getLayerId())){
         }
         else{
@@ -293,6 +295,5 @@
 #if O0194_WEIGHTED_PREDICTION_CGS
         // make sure the reference frames other than ILR are not using weighted prediction
-        if (!(slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)))
-        {
+        if (!(slice->getRefPic(eRefPicList, refIdxTemp)->isILR(slice->getLayerId()))){
           continue;
         }
