Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1536)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1537)
@@ -205,4 +205,7 @@
 
 #define U0132_TARGET_BITS_SATURATION                      1 ///< Rate control with target bits saturation method
+#ifdef  U0132_TARGET_BITS_SATURATION
+#define V0078_ADAPTIVE_LOWER_BOUND                        1 ///< Target bits saturation with adaptive lower bound
+#endif
 
 // ====================================================================================================================
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp	(revision 1536)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp	(revision 1537)
@@ -82,4 +82,5 @@
 }
 
+
 Void TDecGop::destroy()
 {
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1536)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1537)
@@ -2304,8 +2304,15 @@
         estimatedCpbFullness -= m_pcRateCtrl->getBufferingRate();
         // prevent underflow
+#if V0078_ADAPTIVE_LOWER_BOUND
+        if (estimatedCpbFullness - estimatedBits < m_pcRateCtrl->getRCPic()->getLowerBound())
+        {
+          estimatedBits = max(200, estimatedCpbFullness - m_pcRateCtrl->getRCPic()->getLowerBound());
+        }
+#else
         if (estimatedCpbFullness - estimatedBits < (Int)(m_pcRateCtrl->getCpbSize()*0.1f))
         {
           estimatedBits = max(200, estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.1f));
         }
+#endif
 
         m_pcRateCtrl->getRCPic()->setTargetBits(estimatedBits);
@@ -2350,8 +2357,15 @@
             estimatedCpbFullness -= m_pcRateCtrl->getBufferingRate();
             // prevent underflow
+#if V0078_ADAPTIVE_LOWER_BOUND
+            if (estimatedCpbFullness - bits < m_pcRateCtrl->getRCPic()->getLowerBound())
+            {
+              bits = estimatedCpbFullness - m_pcRateCtrl->getRCPic()->getLowerBound();
+            }
+#else
             if (estimatedCpbFullness - bits < (Int)(m_pcRateCtrl->getCpbSize()*0.1f))
             {
               bits = estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.1f);
             }
+#endif
           }
 #endif
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncRateCtrl.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncRateCtrl.cpp	(revision 1536)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncRateCtrl.cpp	(revision 1537)
@@ -546,4 +546,44 @@
 }
 
+#if V0078_ADAPTIVE_LOWER_BOUND
+Int TEncRCPic::xEstPicLowerBound(TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP)
+{
+  Int lowerBound = 0;
+  Int GOPbitsLeft = encRCGOP->getBitsLeft();
+
+  const Int nextPicPosition = (encRCGOP->getNumPic() - encRCGOP->getPicLeft() + 1) % encRCGOP->getNumPic();
+  const Int nextPicRatio = encRCSeq->getBitRatio(nextPicPosition);
+
+  Int totalPicRatio = 0;
+  for (Int i = nextPicPosition; i < encRCGOP->getNumPic(); i++)
+  {
+    totalPicRatio += encRCSeq->getBitRatio(i);
+  }
+
+  if (nextPicPosition == 0)
+  {
+    GOPbitsLeft = encRCGOP->getTargetBits();
+  }
+  else
+  {
+    GOPbitsLeft -= m_targetBits;
+  }
+
+  lowerBound = Int(((Double)GOPbitsLeft) * nextPicRatio / totalPicRatio);
+
+  if (lowerBound < 100)
+  {
+    lowerBound = 100;   // at least allocate 100 bits for one picture
+  }
+
+  if (m_encRCSeq->getFramesLeft() > 16)
+  {
+    lowerBound = Int(g_RCWeightPicRargetBitInBuffer * lowerBound + g_RCWeightPicTargetBitInGOP * m_encRCGOP->getTargetBitInGOP(nextPicPosition));
+  }
+
+  return lowerBound;
+}
+#endif
+
 Void TEncRCPic::addToPictureLsit( list<TEncRCPic*>& listPreviousPictures )
 {
@@ -586,4 +626,7 @@
   Int picWidthInLCU  = ( picWidth  % LCUWidth  ) == 0 ? picWidth  / LCUWidth  : picWidth  / LCUWidth  + 1;
   Int picHeightInLCU = ( picHeight % LCUHeight ) == 0 ? picHeight / LCUHeight : picHeight / LCUHeight + 1;
+#if V0078_ADAPTIVE_LOWER_BOUND
+  m_lowerBound       = xEstPicLowerBound( encRCSeq, encRCGOP );
+#endif
 
   m_LCULeft         = m_numberOfLCU;
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncRateCtrl.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncRateCtrl.h	(revision 1536)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncRateCtrl.h	(revision 1537)
@@ -247,4 +247,7 @@
   Int xEstPicTargetBits( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP );
   Int xEstPicHeaderBits( list<TEncRCPic*>& listPreviousPictures, Int frameLevel );
+#if V0078_ADAPTIVE_LOWER_BOUND
+  Int xEstPicLowerBound( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP );
+#endif
 
 public:
@@ -262,4 +265,7 @@
   Int  getBitsCoded()                                     { return m_targetBits - m_estHeaderBits - m_bitsLeft; }
   Int  getLCUCoded()                                      { return m_numberOfLCU - m_LCULeft; }
+#if V0078_ADAPTIVE_LOWER_BOUND
+  Int  getLowerBound()                                    { return m_lowerBound; }
+#endif
   TRCLCU* getLCU()                                        { return m_LCUs; }
   TRCLCU& getLCU( Int LCUIdx )                            { return m_LCUs[LCUIdx]; }
@@ -290,4 +296,7 @@
   Int m_estHeaderBits;
   Int m_estPicQP;
+#if V0078_ADAPTIVE_LOWER_BOUND
+  Int m_lowerBound;
+#endif
   Double m_estPicLambda;
 
