[x265] [PATCH] stats: move FrameStats from ratecontrol.h to framedata.h
Divya Manivannan
divya at multicorewareinc.com
Thu Jun 11 11:53:17 CEST 2015
# HG changeset patch
# User Divya Manivannan <divya at multicorewareinc.com>
# Date 1433937731 -19800
# Wed Jun 10 17:32:11 2015 +0530
# Node ID 586cb40ea52ab0a628521eb992d1723a467fe8fd
# Parent 6245476add8f0562e3ccb657f572ff94fe96adf0
stats: move FrameStats from ratecontrol.h to framedata.h
diff -r 6245476add8f -r 586cb40ea52a source/common/framedata.h
--- a/source/common/framedata.h Wed Jun 10 11:54:27 2015 +0530
+++ b/source/common/framedata.h Wed Jun 10 17:32:11 2015 +0530
@@ -34,6 +34,23 @@
class PicYuv;
class JobProvider;
+/* 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;
+};
+
/* Per-frame data that is used during encodes and referenced while the picture
* is available for reference. A FrameData instance is attached to a Frame as it
* comes out of the lookahead. Frames which are not being encoded do not have a
@@ -85,6 +102,7 @@
RCStatCU* m_cuStat;
RCStatRow* m_rowStat;
+ FrameStats m_frameStats; // stats of current frame for multi-pass encodes
double m_avgQpRc; /* avg QP as decided by rate-control */
double m_avgQpAq; /* avg QP as decided by AQ in addition to rate-control */
diff -r 6245476add8f -r 586cb40ea52a source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Wed Jun 10 11:54:27 2015 +0530
+++ b/source/encoder/frameencoder.cpp Wed Jun 10 17:32:11 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_encData->m_frameStats), 0, sizeof(m_frame->m_encData->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_encData->m_frameStats.mvBits += m_rows[i].rowStats.mvBits;
+ m_frame->m_encData->m_frameStats.coeffBits += m_rows[i].rowStats.coeffBits;
+ m_frame->m_encData->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_encData->m_frameStats.percent8x8Intra = (double)totalI / totalCuCount;
+ m_frame->m_encData->m_frameStats.percent8x8Inter = (double)totalP / totalCuCount;
+ m_frame->m_encData->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 6245476add8f -r 586cb40ea52a source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h Wed Jun 10 11:54:27 2015 +0530
+++ b/source/encoder/frameencoder.h Wed Jun 10 17:32:11 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 6245476add8f -r 586cb40ea52a source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Wed Jun 10 11:54:27 2015 +0530
+++ b/source/encoder/ratecontrol.cpp Wed Jun 10 17:32:11 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_encData->m_frameStats.coeffBits,
+ curFrame->m_encData->m_frameStats.mvBits,
+ curFrame->m_encData->m_frameStats.miscBits,
+ curFrame->m_encData->m_frameStats.percent8x8Intra * m_ncu,
+ curFrame->m_encData->m_frameStats.percent8x8Inter * m_ncu,
+ curFrame->m_encData->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 6245476add8f -r 586cb40ea52a source/encoder/ratecontrol.h
--- a/source/encoder/ratecontrol.h Wed Jun 10 11:54:27 2015 +0530
+++ b/source/encoder/ratecontrol.h Wed Jun 10 17:32:11 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