[x265] [PATCH] rc: fix the average qp calculation

Divya Manivannan divya at multicorewareinc.com
Thu Apr 28 14:08:29 CEST 2016


# HG changeset patch
# User Divya Manivannan <divya at multicorewareinc.com>
# Date 1461829447 -19800
#      Thu Apr 28 13:14:07 2016 +0530
# Node ID 427d9a6c24648f28c4085e7fb9291fb767998383
# Parent  19cced21060f71e8efe5f2544ccb14f9273fd93c
rc: fix the average qp calculation

diff -r 19cced21060f -r 427d9a6c2464 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Tue Apr 26 15:06:55 2016 -0700
+++ b/source/encoder/ratecontrol.cpp	Thu Apr 28 13:14:07 2016 +0530
@@ -2444,22 +2444,25 @@
     {
         if (m_isVbv && !(m_2pass && m_param->rc.rateControlMode == X265_RC_CRF))
         {
+            double avgQpRc = 0;
             /* determine avg QP decided by VBV rate control */
             for (uint32_t i = 0; i < slice->m_sps->numCuInHeight; i++)
-                curEncData.m_avgQpRc += curEncData.m_rowStat[i].sumQpRc;
+                avgQpRc += curEncData.m_rowStat[i].sumQpRc;
 
-            curEncData.m_avgQpRc /= slice->m_sps->numCUsInFrame;
-            curEncData.m_avgQpRc = x265_clip3((double)QP_MIN, (double)QP_MAX_MAX, curEncData.m_avgQpRc);
+            avgQpRc /= slice->m_sps->numCUsInFrame;
+            curEncData.m_avgQpRc = x265_clip3((double)QP_MIN, (double)QP_MAX_MAX, avgQpRc);
             rce->qpaRc = curEncData.m_avgQpRc;
         }
 
         if (m_param->rc.aqMode)
         {
+            double avgQpAq = 0;
             /* determine actual avg encoded QP, after AQ/cutree adjustments */
             for (uint32_t i = 0; i < slice->m_sps->numCuInHeight; i++)
-                curEncData.m_avgQpAq += curEncData.m_rowStat[i].sumQpAq;
+                avgQpAq += curEncData.m_rowStat[i].sumQpAq;
 
-            curEncData.m_avgQpAq /= (slice->m_sps->numCUsInFrame * NUM_4x4_PARTITIONS);
+            avgQpAq /= (slice->m_sps->numCUsInFrame * NUM_4x4_PARTITIONS);
+            curEncData.m_avgQpAq = avgQpAq;
         }
         else
             curEncData.m_avgQpAq = curEncData.m_avgQpRc;


More information about the x265-devel mailing list