[x265] [PATCH] rc: bug fix to improve quality for the first I frame

Aarthi Thirumalai aarthi at multicorewareinc.com
Mon Dec 30 12:23:14 CET 2013


# HG changeset patch
# User Aarthi Thirumalai
# Date 1388400861 -19800
#      Mon Dec 30 16:24:21 2013 +0530
# Node ID 22772318aaff95a2d03ac828e1522688683e7f13
# Parent  c561cd778ef5002f4d83d8db0b2c918abe90bd09
rc: bug fix to improve quality for the first I frame.

diff -r c561cd778ef5 -r 22772318aaff source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Mon Dec 30 16:06:13 2013 +0530
+++ b/source/encoder/ratecontrol.cpp	Mon Dec 30 16:24:21 2013 +0530
@@ -495,30 +495,29 @@
             q = qp2qScale(accumPQp / accumPNorm);
             q /= fabs(cfg->param.rc.ipFactor);
         }
-        else if (framesDone > 0)
+
+        if (cfg->param.rc.rateControlMode != X265_RC_CRF)
         {
-            if (cfg->param.rc.rateControlMode != X265_RC_CRF)
+            double lqmin = 0, lqmax = 0;
+            if (totalBits == 0)
             {
-                double lqmin = 0, lqmax = 0;
-                if (totalBits == 0)
-                {
-                    lqmin = qp2qScale(ABR_INIT_QP_MIN) / lstep;
-                    lqmax = qp2qScale(ABR_INIT_QP_MAX) * lstep;
-                }
-                else
-                {
-                    lqmin = lastQScaleFor[sliceType] / lstep;
-                    lqmax = lastQScaleFor[sliceType] * lstep;
-                }
+                lqmin = qp2qScale(ABR_INIT_QP_MIN) / lstep;
+                lqmax = qp2qScale(ABR_INIT_QP_MAX) * lstep;
+            }
+            else
+            {
+                lqmin = lastQScaleFor[sliceType] / lstep;
+                lqmax = lastQScaleFor[sliceType] * lstep;
+            }
 
-                if (overflow > 1.1 && framesDone > 3)
-                    lqmax *= lstep;
-                else if (overflow < 0.9)
-                    lqmin /= lstep;
+            if (overflow > 1.1 && framesDone > 3)
+                lqmax *= lstep;
+            else if (overflow < 0.9)
+                lqmin /= lstep;
 
-                q = Clip3(lqmin, lqmax, q);
-            }
+            q = Clip3(lqmin, lqmax, q);
         }
+
         else if (cfg->param.rc.rateControlMode == X265_RC_CRF && qCompress != 1)
         {
             q = qp2qScale(ABR_INIT_QP) / fabs(cfg->param.rc.ipFactor);


More information about the x265-devel mailing list