[x265] [PATCH] stats: move FrameStats from ratecontrol.h to frame.h

Divya Manivannan divya at multicorewareinc.com
Tue Jun 9 15:10:42 CEST 2015


# HG changeset patch
# User Divya Manivannan <divya at multicorewareinc.com>
# Date 1433855003 -19800
#      Tue Jun 09 18:33:23 2015 +0530
# Node ID 15ec1081fa3d13dcd5235bc8b49d49e4478d71c8
# Parent  6538cd24ab98e36b2346298237f27198c6e5aad2
stats: move FrameStats from ratecontrol.h to frame.h

diff -r 6538cd24ab98 -r 15ec1081fa3d source/common/frame.h
--- a/source/common/frame.h	Tue Jun 09 18:15:48 2015 +0530
+++ b/source/common/frame.h	Tue Jun 09 18:33:23 2015 +0530
@@ -35,6 +35,23 @@
 class PicYuv;
 struct SPS;
 
+/* Current frame stats for 2 pass */
+struct FrameStats
+{
+    int         mvBits;    /* MV bits (MV+Ref+Block Type) */
+    int         coeffBits; /* Texture bits (DCT coefs) */
+    int         miscBits;
+
+    int         intra8x8Cnt;
+    int         inter8x8Cnt;
+    int         skip8x8Cnt;
+
+    /* CU type counts stored as percentage */
+    double      percent8x8Intra;
+    double      percent8x8Inter;
+    double      percent8x8Skip;
+};
+
 #define IS_REFERENCED(frame) (frame->m_lowres.sliceType != X265_TYPE_B) 
 
 class Frame
@@ -67,6 +84,7 @@
     Frame*                 m_prev;
     x265_param*            m_param;              // Points to the latest param set for the frame.
     x265_analysis_data     m_analysisData;
+    FrameStats             m_frameStats;          // stats of current frame for multi-pass encodes
     Frame();
 
     bool create(x265_param *param);
diff -r 6538cd24ab98 -r 15ec1081fa3d source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Tue Jun 09 18:15:48 2015 +0530
+++ b/source/encoder/frameencoder.cpp	Tue Jun 09 18:33:23 2015 +0530
@@ -59,7 +59,6 @@
     m_cuGeoms = NULL;
     m_ctuGeomMap = NULL;
     m_localTldIdx = 0;
-    memset(&m_frameStats, 0, sizeof(m_frameStats));
     memset(&m_rce, 0, sizeof(RateControlEntry));
 }
 
@@ -313,7 +312,7 @@
     m_SSDY = m_SSDU = m_SSDV = 0;
     m_ssim = 0;
     m_ssimCnt = 0;
-    memset(&m_frameStats, 0, sizeof(m_frameStats));
+    memset(&(m_frame->m_frameStats), 0, sizeof(m_frame->m_frameStats));
 
     /* Emit access unit delimiter unless this is the first frame and the user is
      * not repeating headers (since AUD is supposed to be the first NAL in the access
@@ -559,17 +558,17 @@
         // accumulate intra,inter,skip cu count per frame for 2 pass
         for (uint32_t i = 0; i < m_numRows; i++)
         {
-            m_frameStats.mvBits    += m_rows[i].rowStats.mvBits;
-            m_frameStats.coeffBits += m_rows[i].rowStats.coeffBits;
-            m_frameStats.miscBits  += m_rows[i].rowStats.miscBits;
-            totalI                 += m_rows[i].rowStats.intra8x8Cnt;
-            totalP                 += m_rows[i].rowStats.inter8x8Cnt;
-            totalSkip              += m_rows[i].rowStats.skip8x8Cnt;
+            m_frame->m_frameStats.mvBits    += m_rows[i].rowStats.mvBits;
+            m_frame->m_frameStats.coeffBits += m_rows[i].rowStats.coeffBits;
+            m_frame->m_frameStats.miscBits  += m_rows[i].rowStats.miscBits;
+            totalI                          += m_rows[i].rowStats.intra8x8Cnt;
+            totalP                          += m_rows[i].rowStats.inter8x8Cnt;
+            totalSkip                       += m_rows[i].rowStats.skip8x8Cnt;
         }
         int totalCuCount = totalI + totalP + totalSkip;
-        m_frameStats.percent8x8Intra = (double)totalI / totalCuCount;
-        m_frameStats.percent8x8Inter = (double)totalP / totalCuCount;
-        m_frameStats.percent8x8Skip  = (double)totalSkip / totalCuCount;
+        m_frame->m_frameStats.percent8x8Intra = (double)totalI / totalCuCount;
+        m_frame->m_frameStats.percent8x8Inter = (double)totalP / totalCuCount;
+        m_frame->m_frameStats.percent8x8Skip  = (double)totalSkip / totalCuCount;
     }
 
     m_bs.resetBits();
@@ -638,7 +637,7 @@
     m_endCompressTime = x265_mdate();
 
     /* rateControlEnd may also block for earlier frames to call rateControlUpdateStats */
-    if (m_top->m_rateControl->rateControlEnd(m_frame, m_accessUnitBits, &m_rce, &m_frameStats) < 0)
+    if (m_top->m_rateControl->rateControlEnd(m_frame, m_accessUnitBits, &m_rce) < 0)
         m_top->m_aborted = true;
 
     /* Decrement referenced frame reference counts, allow them to be recycled */
diff -r 6538cd24ab98 -r 15ec1081fa3d source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h	Tue Jun 09 18:15:48 2015 +0530
+++ b/source/encoder/frameencoder.h	Tue Jun 09 18:33:23 2015 +0530
@@ -157,7 +157,6 @@
     uint32_t                 m_crc[3];
     uint32_t                 m_checksum[3];
     StatisticLog             m_sliceTypeLog[3];     // per-slice type CU statistics
-    FrameStats               m_frameStats;          // stats of current frame for multi-pass encodes
 
     volatile int             m_activeWorkerCount;        // count of workers currently encoding or filtering CTUs
     volatile int             m_totalActiveWorkerCount;   // sum of m_activeWorkerCount sampled at end of each CTU
diff -r 6538cd24ab98 -r 15ec1081fa3d source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Tue Jun 09 18:15:48 2015 +0530
+++ b/source/encoder/ratecontrol.cpp	Tue Jun 09 18:33:23 2015 +0530
@@ -2146,7 +2146,7 @@
 }
 
 /* After encoding one frame, update rate control state */
-int RateControl::rateControlEnd(Frame* curFrame, int64_t bits, RateControlEntry* rce, FrameStats* stats)
+int RateControl::rateControlEnd(Frame* curFrame, int64_t bits, RateControlEntry* rce)
 {
     int orderValue = m_startEndOrder.get();
     int endOrdinal = (rce->encodeOrder + m_param->frameNumThreads) * 2 - 1;
@@ -2217,12 +2217,12 @@
                     "in:%d out:%d type:%c q:%.2f q-aq:%.2f tex:%d mv:%d misc:%d icu:%.2f pcu:%.2f scu:%.2f ;\n",
                     rce->poc, rce->encodeOrder,
                     cType, curEncData.m_avgQpRc, curEncData.m_avgQpAq,
-                    stats->coeffBits,
-                    stats->mvBits,
-                    stats->miscBits,
-                    stats->percent8x8Intra * m_ncu,
-                    stats->percent8x8Inter * m_ncu,
-                    stats->percent8x8Skip  * m_ncu) < 0)
+                    curFrame->m_frameStats.coeffBits,
+                    curFrame->m_frameStats.mvBits,
+                    curFrame->m_frameStats.miscBits,
+                    curFrame->m_frameStats.percent8x8Intra * m_ncu,
+                    curFrame->m_frameStats.percent8x8Inter * m_ncu,
+                    curFrame->m_frameStats.percent8x8Skip  * m_ncu) < 0)
             goto writeFailure;
         /* Don't re-write the data in multi-pass mode. */
         if (m_param->rc.cuTree && IS_REFERENCED(curFrame) && !m_param->rc.bStatRead)
diff -r 6538cd24ab98 -r 15ec1081fa3d source/encoder/ratecontrol.h
--- a/source/encoder/ratecontrol.h	Tue Jun 09 18:15:48 2015 +0530
+++ b/source/encoder/ratecontrol.h	Tue Jun 09 18:33:23 2015 +0530
@@ -46,23 +46,6 @@
 #define MIN_AMORTIZE_FRACTION 0.2
 #define CLIP_DURATION(f) x265_clip3(MIN_FRAME_DURATION, MAX_FRAME_DURATION, f)
 
-/* Current frame stats for 2 pass */
-struct FrameStats
-{
-    int         mvBits;    /* MV bits (MV+Ref+Block Type) */
-    int         coeffBits; /* Texture bits (DCT coefs) */
-    int         miscBits;
-
-    int         intra8x8Cnt;
-    int         inter8x8Cnt;
-    int         skip8x8Cnt;
-    
-    /* CU type counts stored as percentage */
-    double      percent8x8Intra;
-    double      percent8x8Inter;
-    double      percent8x8Skip;
-};
-
 struct Predictor
 {
     double coeff;
@@ -241,7 +224,7 @@
     // to be called for each curFrame to process RateControl and set QP
     int  rateControlStart(Frame* curFrame, RateControlEntry* rce, Encoder* enc);
     void rateControlUpdateStats(RateControlEntry* rce);
-    int  rateControlEnd(Frame* curFrame, int64_t bits, RateControlEntry* rce, FrameStats* stats);
+    int  rateControlEnd(Frame* curFrame, int64_t bits, RateControlEntry* rce);
     int  rowDiagonalVbvRateControl(Frame* curFrame, uint32_t row, RateControlEntry* rce, double& qpVbv);
     int  rateControlSliceType(int frameNum);
     bool cuTreeReadFor2Pass(Frame* curFrame);


More information about the x265-devel mailing list