[x265] [PATCH] rc: record RF details in csv for 2 pass CRF

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Tue Nov 24 19:17:58 CET 2015


# HG changeset patch
# User Aarthi Thirumalai <aarthi at multicorewareinc.com>
# Date 1448384595 -19800
#      Tue Nov 24 22:33:15 2015 +0530
# Branch stable
# Node ID d17f491e06152f4627152a36169c272651bd5e3d
# Parent  0c49c9cc75e4c1ef9534a28b49b97b9107636f5d
rc: record RF details in csv for 2 pass CRF

diff -r 0c49c9cc75e4 -r d17f491e0615 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Mon Nov 23 14:06:10 2015 +0530
+++ b/source/encoder/ratecontrol.cpp	Tue Nov 24 22:33:15 2015 +0530
@@ -1141,6 +1141,7 @@
     }
     if (!m_isAbr && m_2pass && m_param->rc.rateControlMode == X265_RC_CRF)
     {
+        rce->oldQScale = rce->qScale;
         rce->qScale = rce->newQScale;
         rce->qpaRc = curEncData.m_avgQpRc = curEncData.m_avgQpAq = x265_qScale2qp(rce->newQScale);
         m_qp = int(rce->qpaRc + 0.5);
@@ -1704,6 +1705,7 @@
             bool isFrameAfterScenecut = m_sliceType!= I_SLICE && m_curSlice->m_refPicList[0][0]->m_lowres.bScenecut;
             if (!m_2pass && m_isVbv && isFrameAfterScenecut)
                 q = x265_clip3(lqmin, lqmax, q);
+            rce->qScale = q;
         }
         m_lastQScaleFor[m_sliceType] = q;
         if ((m_curSlice->m_poc == 0 || m_lastQScaleFor[P_SLICE] < q) && !(m_2pass && !m_isVbv))
@@ -2337,10 +2339,12 @@
     {
         if (m_param->rc.rateControlMode == X265_RC_ABR && !m_param->rc.bStatRead)
             checkAndResetABR(rce, true);
+    }
 
-        if (m_param->rc.rateControlMode == X265_RC_CRF)
+     if (m_param->rc.rateControlMode == X265_RC_CRF)
         {
-            if (int(curEncData.m_avgQpRc + 0.5) == slice->m_sliceQp)
+            if ((int(curEncData.m_avgQpRc + 0.5) == slice->m_sliceQp && !m_2pass) ||
+                (rce->oldQScale == rce->qScale))
                 curEncData.m_rateFactor = m_rateFactorConstant;
             else
             {
@@ -2351,7 +2355,6 @@
                     x265_qp2qScale(int(curEncData.m_avgQpRc + 0.5) + mbtree_offset);
             }
         }
-    }
 
     if (m_isAbr && !m_isAbrReset)
     {
diff -r 0c49c9cc75e4 -r d17f491e0615 source/encoder/ratecontrol.h
--- a/source/encoder/ratecontrol.h	Mon Nov 23 14:06:10 2015 +0530
+++ b/source/encoder/ratecontrol.h	Tue Nov 24 22:33:15 2015 +0530
@@ -101,6 +101,7 @@
     double   qScale;
     double   newQScale;
     double   newQp;
+    double   oldQScale;
     int      mvBits;
     int      miscBits;
     int      coeffBits;


More information about the x265-devel mailing list