Index: branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 210)
+++ branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 211)
@@ -337,4 +337,13 @@
   Int*    cfg_scaledRefLayerBottomOffset [MAX_LAYERS];
 #endif
+#if RC_SHVC_HARMONIZATION
+  Bool*   cfg_RCEnableRateControl  [MAX_LAYERS];
+  Int*    cfg_RCTargetBitRate      [MAX_LAYERS];
+  Bool*   cfg_RCKeepHierarchicalBit[MAX_LAYERS];
+  Bool*   cfg_RCLCULevelRC         [MAX_LAYERS];
+  Bool*   cfg_RCUseLCUSeparateModel[MAX_LAYERS];
+  Int*    cfg_RCInitialQP          [MAX_LAYERS];
+  Bool*   cfg_RCForceIntraQP       [MAX_LAYERS];
+#endif
   for(UInt layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -356,4 +365,13 @@
     cfg_scaledRefLayerRightOffset [layer] = &m_acLayerCfg[layer].m_scaledRefLayerRightOffset;
     cfg_scaledRefLayerBottomOffset[layer] = &m_acLayerCfg[layer].m_scaledRefLayerBottomOffset;
+#endif
+#if RC_SHVC_HARMONIZATION
+    cfg_RCEnableRateControl[layer]   = &m_acLayerCfg[layer].m_RCEnableRateControl;
+    cfg_RCTargetBitRate[layer]       = &m_acLayerCfg[layer].m_RCTargetBitrate;
+    cfg_RCKeepHierarchicalBit[layer] = &m_acLayerCfg[layer].m_RCKeepHierarchicalBit;
+    cfg_RCLCULevelRC[layer]          = &m_acLayerCfg[layer].m_RCLCULevelRC;
+    cfg_RCUseLCUSeparateModel[layer] = &m_acLayerCfg[layer].m_RCUseLCUSeparateModel;
+    cfg_RCInitialQP[layer]           = &m_acLayerCfg[layer].m_RCInitialQP;
+    cfg_RCForceIntraQP[layer]        = &m_acLayerCfg[layer].m_RCForceIntraQP;
 #endif
   }
@@ -617,4 +635,13 @@
   ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting")
 #if RATE_CONTROL_LAMBDA_DOMAIN
+#if RC_SHVC_HARMONIZATION
+  ("RateControl%d", cfg_RCEnableRateControl, false, MAX_LAYERS, "Rate control: enable rate control for layer %d")
+  ("TargetBitrate%d", cfg_RCTargetBitRate, 0, MAX_LAYERS, "Rate control: target bitrate for layer %d")
+  ("KeepHierarchicalBit%d", cfg_RCKeepHierarchicalBit, false, MAX_LAYERS, "Rate control: keep hierarchical bit allocation for layer %d")
+  ("LCULevelRateControl%d", cfg_RCLCULevelRC, true, MAX_LAYERS, "Rate control: LCU level RC")
+  ("RCLCUSeparateModel%d", cfg_RCUseLCUSeparateModel, true, MAX_LAYERS, "Rate control: Use LCU level separate R-lambda model")
+  ("InitialQP%d", cfg_RCInitialQP, 0, MAX_LAYERS, "Rate control: initial QP")
+  ("RCForceIntraQP%d", cfg_RCForceIntraQP, false, MAX_LAYERS, "Rate control: force intra QP to be equal to initial QP")
+#else
   ( "RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control" )
   ( "TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate" )
@@ -624,4 +651,5 @@
   ( "InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP" )
   ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
+#endif
 #else
   ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
@@ -1742,4 +1770,21 @@
 
 #if RATE_CONTROL_LAMBDA_DOMAIN
+#if RC_SHVC_HARMONIZATION
+  for ( Int layer=0; layer<m_numLayers; layer++ )
+  {
+    if ( m_acLayerCfg[layer].m_RCEnableRateControl )
+    {
+      if ( m_acLayerCfg[layer].m_RCForceIntraQP )
+      {
+        if ( m_acLayerCfg[layer].m_RCInitialQP == 0 )
+        {
+          printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" );
+          m_acLayerCfg[layer].m_RCForceIntraQP = false;
+        }
+      }
+    }
+    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
+  }
+#else
   if ( m_RCEnableRateControl )
   {
@@ -1754,4 +1799,5 @@
     xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
   }
+#endif
 #else
   if(m_enableRateCtrl)
@@ -1869,4 +1915,5 @@
   printf("PCM sample bit depth         : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma );
 #if RATE_CONTROL_LAMBDA_DOMAIN
+#if !RC_SHVC_HARMONIZATION
   printf("RateControl                  : %d\n", m_RCEnableRateControl );
   if(m_RCEnableRateControl)
@@ -1879,4 +1926,5 @@
     printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
   }
+#endif
 #else
   printf("RateControl                  : %d\n", m_enableRateCtrl);
Index: branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 210)
+++ branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 211)
@@ -287,4 +287,5 @@
   Int       m_signHideFlag;
 #if RATE_CONTROL_LAMBDA_DOMAIN
+#if !RC_SHVC_HARMONIZATION
   Bool      m_RCEnableRateControl;                ///< enable rate control or not
   Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
@@ -294,4 +295,5 @@
   Int       m_RCInitialQP;                        ///< inital QP for rate control
   Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
+#endif
 #else
   Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
Index: branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp
===================================================================
--- branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 210)
+++ branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 211)
@@ -134,4 +134,16 @@
   printf("QP                            : %5.2f\n", m_fQP );
   printf("Intra period                  : %d\n", m_iIntraPeriod );
+#if RC_SHVC_HARMONIZATION
+  printf("RateControl                   : %d\n", m_RCEnableRateControl );
+  if(m_RCEnableRateControl)
+  {
+    printf("TargetBitrate                 : %d\n", m_RCTargetBitrate );
+    printf("KeepHierarchicalBit           : %d\n", m_RCKeepHierarchicalBit );
+    printf("LCULevelRC                    : %d\n", m_RCLCULevelRC );
+    printf("UseLCUSeparateModel           : %d\n", m_RCUseLCUSeparateModel );
+    printf("InitialQP                     : %d\n", m_RCInitialQP );
+    printf("ForceIntraQP                  : %d\n", m_RCForceIntraQP );
+  }
+#endif
   printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_cAppEncCfg->getWaveFrontSynchro(), m_iWaveFrontSubstreams);
 }
Index: branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 210)
+++ branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 211)
@@ -46,4 +46,15 @@
   Int       m_numDirectRefLayers;
 #endif
+
+#if RC_SHVC_HARMONIZATION
+  Bool      m_RCEnableRateControl;                ///< enable rate control or not
+  Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
+  Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
+  Bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control
+  Bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level
+  Int       m_RCInitialQP;                        ///< inital QP for rate control
+  Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
+#endif
+
 #if SVC_EXTENSION
   Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
@@ -98,4 +109,13 @@
   Int     getRefLayerId(Int i)        {return m_refLayerIds[i];   }
 #endif
+#if RC_SHVC_HARMONIZATION
+  Bool    getRCEnableRateControl()    {return m_RCEnableRateControl;   }
+  Int     getRCTargetBitrate()        {return m_RCTargetBitrate;       }
+  Bool    getRCKeepHierarchicalBit()  {return m_RCKeepHierarchicalBit; }
+  Bool    getRCLCULevelRC()           {return m_RCLCULevelRC;          }
+  Bool    getRCUseLCUSeparateModel()  {return m_RCUseLCUSeparateModel; }
+  Int     getRCInitialQP()            {return m_RCInitialQP;           }
+  Bool    getRCForceIntraQP()         {return m_RCForceIntraQP;        }
+#endif
 }; // END CLASS DEFINITION TAppEncLayerCfg
 
Index: branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 210)
+++ branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 211)
@@ -343,4 +343,13 @@
     m_acTEncTop[layer].setSignHideFlag(m_signHideFlag);
 #if RATE_CONTROL_LAMBDA_DOMAIN
+#if RC_SHVC_HARMONIZATION
+    m_acTEncTop[layer].setUseRateCtrl     (m_acLayerCfg[layer].getRCEnableRateControl());
+    m_acTEncTop[layer].setTargetBitrate   (m_acLayerCfg[layer].getRCTargetBitrate());
+    m_acTEncTop[layer].setKeepHierBit     (m_acLayerCfg[layer].getRCKeepHierarchicalBit());
+    m_acTEncTop[layer].setLCULevelRC      (m_acLayerCfg[layer].getRCLCULevelRC());
+    m_acTEncTop[layer].setUseLCUSeparateModel (m_acLayerCfg[layer].getRCUseLCUSeparateModel());
+    m_acTEncTop[layer].setInitialQP           (m_acLayerCfg[layer].getRCInitialQP());
+    m_acTEncTop[layer].setForceIntraQP        (m_acLayerCfg[layer].getRCForceIntraQP());
+#else
     m_acTEncTop[layer].setUseRateCtrl         ( m_RCEnableRateControl );
     m_acTEncTop[layer].setTargetBitrate       ( m_RCTargetBitrate );
@@ -350,4 +359,5 @@
     m_acTEncTop[layer].setInitialQP           ( m_RCInitialQP );
     m_acTEncTop[layer].setForceIntraQP        ( m_RCForceIntraQP );
+#endif
 #else
     m_acTEncTop[layer].setUseRateCtrl     ( m_enableRateCtrl);
@@ -1014,4 +1024,14 @@
     }
 
+#if RC_SHVC_HARMONIZATION
+    for(UInt layer=0; layer<m_numLayers; layer++)
+    {
+      if ( m_acTEncTop[layer].getUseRateCtrl() )
+      {
+        (m_acTEncTop[layer].getRateCtrl())->initRCGOP(m_acTEncTop[layer].getNumPicRcvd());
+      }
+    }
+#endif
+
     // loop through frames in one GOP 
     for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ )
@@ -1024,4 +1044,14 @@
       }
     }
+
+#if RC_SHVC_HARMONIZATION
+    for(UInt layer=0; layer<m_numLayers; layer++)
+    {
+      if ( m_acTEncTop[layer].getUseRateCtrl() )
+      {
+        (m_acTEncTop[layer].getRateCtrl())->destroyRCGOP();
+      }
+    }
+#endif
 
     iTotalNumEncoded = 0;
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 210)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 211)
@@ -172,4 +172,5 @@
 #define RATE_CONTROL_LAMBDA_DOMAIN                  1  ///< JCTVC-K0103, rate control by R-lambda model
 #define L0033_RC_BUGFIX                             1  ///< JCTVC-L0033, bug fix for R-lambda model based rate control
+#define RC_SHVC_HARMONIZATION                       1  ///< JCTVC-M0037, rate control for SHVC
 
 #define MAX_CPB_CNT                     32  ///< Upper bound of (cpb_cnt_minus1 + 1)
Index: branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 210)
+++ branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 211)
@@ -386,8 +386,10 @@
   // compress GOP
 #if RATE_CONTROL_LAMBDA_DOMAIN
+#if !RC_SHVC_HARMONIZATION
   if ( m_RCEnableRateControl )
   {
     m_cRateCtrl.initRCGOP( m_iNumPicRcvd );
   }
+#endif
 #endif
 
@@ -396,8 +398,10 @@
 
 #if RATE_CONTROL_LAMBDA_DOMAIN
+#if !RC_SHVC_HARMONIZATION
   if ( m_RCEnableRateControl )
   {
     m_cRateCtrl.destroyRCGOP();
   }
+#endif
 #endif
   
