# HG changeset patch
# User Aarthi Thirumalai
# Date 1379615875 -19800
#      Fri Sep 20 00:07:55 2013 +0530
# Node ID 6832513a6e480a7b167e15f51215ea86af87c5d4
# Parent  e26b439a4031dd93f8aab60f0bdddc7f4a38ae2a
tuned up ABR logic to better adapt for frame parallelism

 Rate control needs to be more aggressive based on actual ecoded bits cost 
rather than estimated costs from
 concurrent threads .Tuned up some parameters to effect this idea.

diff -r e26b439a4031 -r 6832513a6e48 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp    Thu Sep 19 23:45:42 2013 +0530
+++ b/source/encoder/ratecontrol.cpp    Fri Sep 20 00:07:55 2013 +0530
@@ -222,7 +222,7 @@
             double iFrameDone = framesDone - frameThreads + 1;
             double timeDone = iFrameDone / framerate;
             wantedBits = timeDone * bitrate;
-            if (wantedBits > 0)
+            if (wantedBits > 0 && totalBits > 0)
             {
                 abrBuffer *= X265_MAX(1, sqrt(timeDone));
                 overflow = Clip3(.5, 2.0, 1.0 + (totalBits - wantedBits) / 
abrBuffer);
@@ -240,24 +240,31 @@
         {
             double lqmin = 0, lqmax = 0;
 
-            /* Clip the qp of 1st frame to ensure it doesnt detoriate the 
quality */
-            if (curFrame->getPOC() == 0)
+            /* Clip the qp of 1st 'N' frames running parallely to ensure it 
doesnt detoriate the quality  */
+            if (totalBits ==0)
             {
                 lqmin = qp2qScale(ABR_INIT_QP_MIN) / lstep;
                 lqmax = qp2qScale(ABR_INIT_QP_MAX) * lstep;
             }
+
             /* Asymmetric clipping, because symmetric would prevent
              * overflow control in areas of rapidly oscillating complexity */
-            else if (curFrame->getPOC() > 0)
+            else
             {
                 lqmin = lastQScaleFor[pictType] / lstep;
                 lqmax = lastQScaleFor[pictType] * lstep;
             }
-            if (overflow > 1.1 && curFrame->getPOC() > 3)
-                lqmax *= lstep;
+            /* Rate control needs to be more aggressive based on actual costs 
obtained for  previous encoded frame */
+            if (overflow > 1.1 && framesDone > 3)
+            {
+                lqmax *=  lstep ;
+                lqmin*= pow(lstep,1/frameThreads);
+            }
             else if (overflow < 0.9)
-                lqmin /= lstep;
-
+            {
+                lqmin /= lstep ;
+                lqmax /= pow(lstep,1/frameThreads);
+            }
             q = Clip3(lqmin, lqmax, q);
         }
 
_______________________________________________
x265-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/x265-devel

Reply via email to