Index: branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 633)
+++ branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 635)
@@ -82,4 +82,8 @@
   m_codedPivotValue = NULL;
   m_targetPivotValue = NULL;
+
+#if KWU_RC_MADPRED_E0227
+  m_uiDepthMADPred = 0;
+#endif
 }
 
@@ -594,8 +598,24 @@
   ( "InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP" )
   ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
-#else
-  ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
+
+#if KWU_RC_VIEWRC_E0227
+  ("ViewWiseTargetBits, -vtbr" ,  m_pchViewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
+  ("TargetBitAssign, -ta", m_bViewWiseRateCtrl, false, "View-wise rate control on/off")
+#endif
+#if KWU_RC_MADPRED_E0227
+  ("DepthMADPred, -dm", m_uiDepthMADPred, (UInt)0, "Depth based MAD prediction on/off")
+#endif
+#else
+  ("RateControl,-rc", m_enableRateCtrl, false, "Rate control on/off")
   ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
   ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
+
+#if KWU_RC_VIEWRC_E0227
+  ("ViewWiseTargetBits, -vtbr" ,  m_pchViewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
+  ("TargetBitAssign, -ta", m_bViewWiseRateCtrl, false, "View-wise rate control on/off")
+#endif
+#if KWU_RC_MADPRED_E0227
+  ("DepthMADPred, -dm", m_uiDepthMADPred, (UInt)0, "Depth based MAD prediction on/off")
+#endif
 #endif
 
@@ -2159,5 +2179,5 @@
     xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" );
 
-    m_iMaxDeltaQP       = MAX_DELTA_QP;
+    //m_iMaxDeltaQP       = MAX_DELTA_QP;
     m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
   }
@@ -2301,4 +2321,23 @@
     printf("InitialQP                    : %d\n", m_RCInitialQP );
     printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
+
+#if KWU_RC_MADPRED_E0227
+    printf("Depth based MAD prediction   : %d\n", m_uiDepthMADPred);
+#endif
+#if KWU_RC_VIEWRC_E0227
+    printf("View-wise Rate control       : %d\n", m_bViewWiseRateCtrl);
+    if(m_bViewWiseRateCtrl)
+    {
+
+      printf("ViewWiseTargetBits           : ");
+      for (int i = 0 ; i < m_iNumberOfViews ; i++)
+        printf("%d ", m_pchViewTargetBits[i]);
+      printf("\n");
+    }
+    else
+    {
+      printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
+    }
+#endif
   }
 #else
@@ -2308,4 +2347,23 @@
     printf("TargetBitrate                : %d\n", m_targetBitrate);
     printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
+
+#if KWU_RC_MADPRED_E0227
+    printf("Depth based MAD prediction   : %d\n", m_uiDepthMADPred);
+#endif
+#if KWU_RC_VIEWRC_E0227
+    printf("View-wise Rate control       : %d\n", m_bViewWiseRateCtrl);
+    if(m_bViewWiseRateCtrl)
+    {
+
+      printf("ViewWiseTargetBits           : ");
+      for (int i = 0 ; i < m_iNumberOfViews ; i++)
+        printf("%d ", m_pchViewTargetBits[i]);
+      printf("\n");
+    }
+    else
+    {
+      printf("TargetBitrate                : %d\n", m_targetBitrate );
+    }
+#endif
   }
 #endif
Index: branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncCfg.h	(revision 633)
+++ branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncCfg.h	(revision 635)
@@ -367,8 +367,24 @@
   Int       m_RCInitialQP;                        ///< inital QP for rate control
   Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
+
+#if KWU_RC_VIEWRC_E0227
+  vector<Int>     m_pchViewTargetBits;
+  bool      m_bViewWiseRateCtrl;                              ///< Flag for using view-wise rate control
+#endif
+#if KWU_RC_MADPRED_E0227
+  UInt       m_uiDepthMADPred;
+#endif
 #else
   Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
   Int       m_targetBitrate;                                 ///< target bitrate
   Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
+
+#if KWU_RC_VIEWRC_E0227
+  vector<Int>     m_pchViewTargetBits;
+  bool      m_bViewWiseRateCtrl;                              ///< Flag for using view-wise rate control
+#endif
+#if KWU_RC_MADPRED_E0227
+  UInt       m_uiDepthMADPred;
+#endif
 #endif
   Int       m_useScalingListId;                               ///< using quantization matrix
Index: branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncTop.cpp	(revision 633)
+++ branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncTop.cpp	(revision 635)
@@ -512,6 +512,11 @@
   m_cTEncTop.setSignHideFlag(m_signHideFlag);
 #if RATE_CONTROL_LAMBDA_DOMAIN
-  m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
+  if(!m_cTEncTop.getIsDepth())    //only for texture
+    m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
+  else
+    m_cTEncTop.setUseRateCtrl         ( 0 );
+#if !KWU_RC_VIEWRC_E0227
   m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
+#endif
   m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
   m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
@@ -519,8 +524,123 @@
   m_cTEncTop.setInitialQP           ( m_RCInitialQP );
   m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
-#else
-  m_cTEncTop.setUseRateCtrl     ( m_enableRateCtrl);
-  m_cTEncTop.setTargetBitrate   ( m_targetBitrate);
-  m_cTEncTop.setNumLCUInUnit    ( m_numLCUInUnit);
+
+#if KWU_RC_MADPRED_E0227
+  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
+  {
+    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_uiDepthMADPred       : 0);
+
+    if(m_cTEncTop.getUseDepthMADPred())
+      m_cTEncTop.setCamParam(&m_cCameraData);
+  }
+#endif
+#if KWU_RC_VIEWRC_E0227
+  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
+  {
+    m_cTEncTop.setUseViewWiseRateCtrl(m_bViewWiseRateCtrl);
+
+    if(m_iNumberOfViews == 1)
+    {
+      if(m_bViewWiseRateCtrl)
+      {
+        m_cTEncTop.setTargetBitrate(m_pchViewTargetBits[layerIdInVps>>1]);
+      }
+      else
+        m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
+    }
+    else
+    {
+      if(m_bViewWiseRateCtrl)
+      {
+        m_cTEncTop.setTargetBitrate(m_pchViewTargetBits[layerIdInVps>>1]);
+      }
+      else
+      {
+        if(m_iNumberOfViews == 2)
+        {
+          if(m_cTEncTop.getViewId() == 0)
+            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*80)/100 );
+          else if(m_cTEncTop.getViewId() == 1)
+            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*20)/100 );
+        }
+        else if(m_iNumberOfViews == 3)
+        {
+          if(m_cTEncTop.getViewId() == 0)
+            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*66)/100 );
+          else if(m_cTEncTop.getViewId() == 1)
+            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
+          else if(m_cTEncTop.getViewId() == 2)
+            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
+        }
+        else
+          m_cTEncTop.setTargetBitrate              ( m_RCTargetBitrate );
+      }
+    }
+  }
+#endif
+#else
+  if(!m_cTEncTop.getIsDepth())    //only for texture
+  {
+    m_cTEncTop.setUseRateCtrl         ( m_enableRateCtrl );
+#if !KWU_RC_VIEWRC_E0227
+    m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
+#endif
+    m_cTEncTop.setNumLCUInUnit        ( m_numLCUInUnit);
+  }
+  else
+    m_cTEncTop.setUseRateCtrl         ( 0 );
+  
+#if KWU_RC_MADPRED_E0227
+  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
+  {
+    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_uiDepthMADPred       : 0);
+
+    if(m_cTEncTop.getUseDepthMADPred())
+      m_cTEncTop.setCamParam(&m_cCameraData);
+  }
+#endif
+
+#if KWU_RC_VIEWRC_E0227
+  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
+  {
+    m_cTEncTop.setUseViewWiseRateCtrl(m_bViewWiseRateCtrl);
+    if(m_iNumberOfViews == 1)
+    {
+      if(m_bViewWiseRateCtrl)
+      {
+        m_cTEncTop.setTargetBitrate(m_pchViewTargetBits[layerIdInVps>>1]);
+      }
+      else
+        m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
+    }
+    else
+    {
+      if(m_bViewWiseRateCtrl)
+      {
+        m_cTEncTop.setTargetBitrate(m_pchViewTargetBits[layerIdInVps>>1]);
+      }
+      else
+      {
+        if(m_iNumberOfViews == 2)
+        {
+          if(m_cTEncTop.getViewId() == 0)
+            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*80)/100 );
+          else if(m_cTEncTop.getViewId() == 1)
+            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*20)/100 );
+        }
+        else if(m_iNumberOfViews == 3)
+        {
+          if(m_cTEncTop.getViewId() == 0)
+            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*66)/100 );
+          else if(m_cTEncTop.getViewId() == 1)
+            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
+          else if(m_cTEncTop.getViewId() == 2)
+            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
+        }
+        else
+          m_cTEncTop.setTargetBitrate              ( m_targetBitrate );
+      }
+    }
+  }
+#endif
 #endif
   m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
@@ -669,5 +789,9 @@
   for(Int layer=0; layer<m_numberOfLayers; layer++)
   {
+#if KWU_RC_MADPRED_E0227
+    m_acTEncTopList[layer]->init( this );
+#else
     m_acTEncTopList[layer]->init( );
+#endif
   }
 #else
@@ -789,4 +913,15 @@
       }
     }
+
+#if !RATE_CONTROL_LAMBDA_DOMAIN
+    for(Int layer=0; layer < m_numberOfLayers; layer++ )
+    {
+      if(m_acTEncTopList[layer]->getUseRateCtrl()  && !m_acTEncTopList[layer]->getIsDepth())
+      {
+        m_acTEncTopList[layer]->getRateCtrl()->updateRCGOPStatus();
+      }
+    }
+#endif
+
     gopSize = maxGopSize;
   }
Index: branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncTop.h	(revision 633)
+++ branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncTop.h	(revision 635)
@@ -50,4 +50,7 @@
 #endif
 
+#if KWU_RC_MADPRED_E0227
+class TEncTop;
+#endif
 //! \ingroup TAppEncoder
 //! \{
