[x265] [PATCH 3 of 5] rc: store final cu counts in frameStats as a percentage of total # cus

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Fri Jul 11 13:12:58 CEST 2014


# HG changeset patch
# User Aarthi Thirumalai
# Date 1405076123 -19800
#      Fri Jul 11 16:25:23 2014 +0530
# Node ID 06957605a135b0bdcbf97e9479277d7e72c560c8
# Parent  a73535d798fc0e68bcc0c78705810e6a93f7fbea
rc: store final cu counts in frameStats as a percentage of total # cus

there exists a mismatch in the total no. of 16x16 blocks calculated between encoder and RC.
rate control counts no. of 16x16 blocks without considering the border extension of source pic.
keeping cu stats as percentage avoid this problem when used later in RC's 2nd pass.

diff -r a73535d798fc -r 06957605a135 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Fri Jul 11 16:17:25 2014 +0530
+++ b/source/encoder/frameencoder.cpp	Fri Jul 11 16:25:23 2014 +0530
@@ -488,8 +488,8 @@
     // frame is compressed in a wave-front pattern if WPP is enabled. Loop filter runs as a
     // wave-front behind the CU compression and reconstruction
     compressCTURows();
-
     if (m_param->rc.bStatWrite)
+    {
         // accumulate intra,inter,skip cu count per frame for 2 pass
         for (int i = 0; i < m_numRows; i++)
         {
@@ -497,7 +497,11 @@
             m_frameStats.cuCount_p += m_rows[i].m_pCuCnt;
             m_frameStats.cuCount_skip += m_rows[i].m_skipCuCnt;
         }
-
+        double totalCuCount = m_frameStats.cuCount_i + m_frameStats.cuCount_p + m_frameStats.cuCount_skip;
+        m_frameStats.cuCount_i /= totalCuCount;
+        m_frameStats.cuCount_p /= totalCuCount;
+        m_frameStats.cuCount_skip /= totalCuCount;
+    }
     if (m_sps.getUseSAO())
     {
         SAOParam* saoParam = m_frame->getPicSym()->getSaoParam();
diff -r a73535d798fc -r 06957605a135 source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h	Fri Jul 11 16:17:25 2014 +0530
+++ b/source/encoder/frameencoder.h	Fri Jul 11 16:25:23 2014 +0530
@@ -54,7 +54,7 @@
     /* Texture bits (DCT coefs) */
     int         coeffBits;
     int         miscBits;
-    /* CU type counts */
+    /* CU type counts stored as percentage */
     double      cuCount_i;
     double      cuCount_p;
     double      cuCount_skip;


More information about the x265-devel mailing list