[x265] [PATCH 03 of 13] stats: add frame statistic for average WPP benefit
Steve Borho
steve at borho.org
Wed Jan 28 21:32:18 CET 2015
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1422467508 21600
# Wed Jan 28 11:51:48 2015 -0600
# Node ID be33891b84573dc337d17fb82084aad523325fd7
# Parent e8367f5cd43fef208eee6cf4c03974d330253f4a
stats: add frame statistic for average WPP benefit
Show how many worker threads, on average, were working on each frame. Also move
the performance statistics together at the end of the CSV line in preparation
for adding a few more of them.
diff -r e8367f5cd43f -r be33891b8457 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Wed Jan 28 11:15:45 2015 -0600
+++ b/source/encoder/encoder.cpp Wed Jan 28 11:51:48 2015 -0600
@@ -214,7 +214,9 @@
if (m_param->rc.rateControlMode == X265_RC_CRF)
fprintf(m_csvfpt, "RateFactor, ");
fprintf(m_csvfpt, "Y PSNR, U PSNR, V PSNR, YUV PSNR, SSIM, SSIM (dB), "
- "Encoding time, Elapsed time, List 0, List 1\n");
+ "List 0, List 1");
+ /* detailed performance statistics */
+ fprintf(m_csvfpt, ", Wall time, Total CTU time, Avg WPP\n");
}
else
fputs(summaryCSVHeader, m_csvfpt);
@@ -1159,13 +1161,14 @@
if (m_param->bEnablePsnr)
fprintf(m_csvfpt, "%.3lf, %.3lf, %.3lf, %.3lf,", psnrY, psnrU, psnrV, psnr);
else
- fprintf(m_csvfpt, " -, -, -, -,");
+ fputs(" -, -, -, -,", m_csvfpt);
if (m_param->bEnableSsim)
- fprintf(m_csvfpt, " %.6f, %6.3f,", ssim, x265_ssim2dB(ssim));
+ fprintf(m_csvfpt, " %.6f, %6.3f", ssim, x265_ssim2dB(ssim));
else
- fprintf(m_csvfpt, " -, -,");
- fprintf(m_csvfpt, " %.3lf, %.3lf", curEncoder->m_frameTime, curEncoder->m_elapsedCompressTime);
- if (!slice->isIntra())
+ fputs(" -, -", m_csvfpt);
+ if (slice->isIntra())
+ fputs(", -, -", m_csvfpt);
+ else
{
int numLists = slice->isInterP() ? 1 : 2;
for (int list = 0; list < numLists; list++)
@@ -1179,10 +1182,14 @@
}
if (numLists == 1)
- fprintf(m_csvfpt, ", -");
+ fputs(", -", m_csvfpt);
}
+ // detailed frame statistics
+ fprintf(m_csvfpt, ", %.3lf, %.3lf", curEncoder->m_frameTime, curEncoder->m_elapsedCompressTime);
+ if (curEncoder->m_totalActiveWorkerCount)
+ fprintf(m_csvfpt, ", %.3lf", (double)curEncoder->m_totalActiveWorkerCount / curEncoder->m_activeWorkerCountSamples);
else
- fprintf(m_csvfpt, ", -, -");
+ fputs(", 1", m_csvfpt);
fprintf(m_csvfpt, "\n");
}
diff -r e8367f5cd43f -r be33891b8457 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Wed Jan 28 11:15:45 2015 -0600
+++ b/source/encoder/frameencoder.cpp Wed Jan 28 11:51:48 2015 -0600
@@ -237,6 +237,9 @@
int64_t startCompressTime = x265_mdate();
Slice* slice = m_frame->m_encData->m_slice;
+ m_totalActiveWorkerCount = 0;
+ m_activeWorkerCountSamples = 0;
+
/* 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
* unit) */
@@ -779,6 +782,10 @@
// Does all the CU analysis, returns best top level mode decision
Mode& best = tld.analysis.compressCTU(*ctu, *m_frame, m_cuGeoms[m_ctuGeomMap[cuAddr]], rowCoder);
+ // take a sample of the current active worker count
+ ATOMIC_ADD(&m_totalActiveWorkerCount, m_activeWorkerCount);
+ ATOMIC_INC(&m_activeWorkerCountSamples);
+
/* advance top-level row coder to include the context of this CTU.
* if SAO is disabled, rowCoder writes the final CTU bitstream */
rowCoder.encodeCTU(*ctu, m_cuGeoms[m_ctuGeomMap[cuAddr]]);
diff -r e8367f5cd43f -r be33891b8457 source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h Wed Jan 28 11:15:45 2015 -0600
+++ b/source/encoder/frameencoder.h Wed Jan 28 11:51:48 2015 -0600
@@ -147,6 +147,7 @@
uint64_t m_SSDU;
uint64_t m_SSDV;
double m_ssim;
+ uint64_t m_accessUnitBits;
uint32_t m_ssimCnt;
MD5Context m_state[3];
uint32_t m_crc[3];
@@ -157,8 +158,10 @@
FrameStats m_frameStats; // stats of current frame for multi-pass encodes
volatile bool m_bAllRowsStop;
volatile int m_vbvResetTriggerRow;
- volatile int m_activeWorkerCount;
- uint64_t m_accessUnitBits;
+
+ volatile int m_activeWorkerCount; // count of workers current encoding or filtering CTUs
+ volatile int m_totalActiveWorkerCount; // sum of m_activeWorkerCount sampled at end of each CTU
+ volatile int m_activeWorkerCountSamples; // count of times m_activeWorkerCount was sampled (think vbv restarts)
Encoder* m_top;
x265_param* m_param;
More information about the x265-devel
mailing list