[x265] [PATCH] crf: bug fix. regulate qp of first frame based on ABR_INIT_QP

Aarthi Thirumalai aarthi at multicorewareinc.com
Fri Nov 22 14:59:56 CET 2013


# HG changeset patch
# User Aarthi Thirumalai
# Date 1385128779 -19800
#      Fri Nov 22 19:29:39 2013 +0530
# Node ID d31dc7679d43cbde847bbfb8745535c58122c401
# Parent  5009254d3d3ac92e90b1551444c5eb32ba2f8d31
crf: bug fix. regulate qp of first frame based on ABR_INIT_QP.

diff -r 5009254d3d3a -r d31dc7679d43 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Fri Nov 22 00:17:46 2013 -0600
+++ b/source/encoder/ratecontrol.cpp	Fri Nov 22 19:29:39 2013 +0530
@@ -190,7 +190,7 @@
     pbOffset = 6.0 * X265_LOG2(cfg->param.rc.pbFactor);
     for (int i = 0; i < 3; i++)
     {
-        lastQScaleFor[i] = qp2qScale(ABR_INIT_QP_MIN);
+        lastQScaleFor[i] = qp2qScale(cfg->param.rc.rateControlMode == X265_RC_CRF ? ABR_INIT_QP : ABR_INIT_QP_MIN);
         lmin[i] = qp2qScale(MIN_QP);
         lmax[i] = qp2qScale(MAX_QP);
     }
@@ -363,6 +363,10 @@
                 q = Clip3(lqmin, lqmax, q);
             }
         }
+        else if (cfg->param.rc.rateControlMode == X265_RC_CRF && cfg->param.rc.qCompress != 1)
+        {
+            q = qp2qScale(ABR_INIT_QP) / fabs(cfg->param.rc.ipFactor);
+        }
 
         double lmin1 = lmin[sliceType];
         double lmax1 = lmax[sliceType];


More information about the x265-devel mailing list