[x265] [PATCH] RateControl : Bug fix when previous estimated frame cost is zero

sumalatha at multicorewareinc.com sumalatha at multicorewareinc.com
Tue Sep 24 08:33:41 CEST 2013


# HG changeset patch
# User sumalatha polureddy
# Date 1380004245 -19800
# Node ID 759460e7afeeb7d97ea427a702ac08eb9d8a3293
# Parent  6fa50183e0098f9e94b677ef8dc00c416f28c0f3
RateControl : Bug fix when previous estimated frame cost is zero

diff -r 6fa50183e009 -r 759460e7afee source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Tue Sep 24 11:56:43 2013 +0530
+++ b/source/encoder/ratecontrol.cpp	Tue Sep 24 12:00:45 2013 +0530
@@ -62,7 +62,7 @@
     lastNonBPictType = -1;
     baseQp = param->rc.qp;
     qp = baseQp;
-
+    lastRceq = 1; // handles the cmplxrsum when the previous frame cost is zero
     // heuristics- encoder specific
     qCompress = param->rc.qCompress; // tweak and test for x265.
     ipFactor = param->rc.ipFactor;
@@ -255,15 +255,20 @@
                 lqmax = lastQScaleFor[pictType] * 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;
-                lqmax /= pow(lstep,1/frameThreads);
+            int rfAdapt = 1;
+            if (overflow > 1.1 && framesDone > 3)
+            {
+                //Control propagation of excessive overflow / underfow 
+                if(overflow > 1.5)
+                    rfAdapt = 2;
+                lqmax *= pow(lstep, rfAdapt);
+            }
+            else if (overflow < 0.9)
+            {
+                if(overflow < 0.6)
+                    rfAdapt = 2;
+                lqmin /= pow(lstep, rfAdapt);
+                lqmax /= pow(lstep, rfAdapt / frameThreads);
             }
             q = Clip3(lqmin, lqmax, q);
         }


More information about the x265-devel mailing list