[x265] [PATCH 02 of 13] stats: keep running count of number of active worker threads per frame encoder

Steve Borho steve at borho.org
Wed Jan 28 21:32:17 CET 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1422465345 21600
#      Wed Jan 28 11:15:45 2015 -0600
# Node ID e8367f5cd43fef208eee6cf4c03974d330253f4a
# Parent  7f0b87cbad6d83a51c9cd957daac8081d772e473
stats: keep running count of number of active worker threads per frame encoder

diff -r 7f0b87cbad6d -r e8367f5cd43f source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Wed Jan 28 11:49:46 2015 -0600
+++ b/source/encoder/frameencoder.cpp	Wed Jan 28 11:15:45 2015 -0600
@@ -44,6 +44,7 @@
 {
     m_totalTime = 0;
     m_frameEncoderID = 0;
+    m_activeWorkerCount = 0;
     m_bAllRowsStop = false;
     m_vbvResetTriggerRow = -1;
     m_outStreams = NULL;
@@ -673,6 +674,8 @@
 
 void FrameEncoder::processRow(int row, int threadId)
 {
+    ATOMIC_INC(&m_activeWorkerCount);
+
     const int realRow = row >> 1;
     const int typeNum = row & 1;
 
@@ -690,6 +693,8 @@
         else
             m_completionEvent.trigger();
     }
+
+    ATOMIC_DEC(&m_activeWorkerCount);
 }
 
 // Called by worker threads
diff -r 7f0b87cbad6d -r e8367f5cd43f source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h	Wed Jan 28 11:49:46 2015 -0600
+++ b/source/encoder/frameencoder.h	Wed Jan 28 11:15:45 2015 -0600
@@ -157,6 +157,7 @@
     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;
 
     Encoder*                 m_top;


More information about the x265-devel mailing list