[x265] [PATCH 1 of 9] pcs: update design to have 'm_achivedFps' for every PCS Instance

praveen at multicorewareinc.com praveen at multicorewareinc.com
Thu Nov 17 16:21:50 CET 2016


# HG changeset patch
# User Praveen Tiwari <praveen at multicorewareinc.com>
# Date 1479128885 -19800
#      Mon Nov 14 18:38:05 2016 +0530
# Branch stable
# Node ID 8defd4e7b2e4875247e4ec95e0dd3b9630983526
# Parent  bdf273f9521784ceeda868222d415303a0bcf58b
pcs: update design to have 'm_achivedFps' for every PCS Instance

diff -r bdf273f95217 -r 8defd4e7b2e4 source/api-uhdkit.cpp
--- a/source/api-uhdkit.cpp	Tue Nov 08 14:20:24 2016 +0530
+++ b/source/api-uhdkit.cpp	Mon Nov 14 18:38:05 2016 +0530
@@ -206,8 +206,6 @@
             return -1;
         if (numEncoded > 0)
         {
-            uhdkitEnc->m_achievedFps = numEncoded * 1000000.0 / (double)(endTime - startTime);
-            uhdkitEnc->m_achievedFps = uhdkitEnc->m_achievedFps / uhdkitEnc->m_param->gops; // Achieved fps for each gop encoder
             uhdkitEnc->m_encodedFrameCount += numEncoded;
             controllerIndex = ((uhdkitEnc->m_encodedFrameCount - 1) / uhdkitEnc->m_param->x265Param->keyframeMax) % uhdkitEnc->m_param->gops;
             X265_CHECK(controllerIndex >= 0 && controllerIndex < uhdkitEnc->m_param->gops, "Invalid controllerIndex: %d, must be between 0 and %d\n", controllerIndex, uhdkitEnc->m_param->gops);
diff -r bdf273f95217 -r 8defd4e7b2e4 source/pcs/api-pcs.cpp
--- a/source/pcs/api-pcs.cpp	Tue Nov 08 14:20:24 2016 +0530
+++ b/source/pcs/api-pcs.cpp	Mon Nov 14 18:38:05 2016 +0530
@@ -211,6 +211,7 @@
     m_pcsParam->statusPrintInterval  = param->statusPrintInterval;
     m_curTimeStamp = m_lastTimeStamp = X265_NS::x265_mdate();
     m_framesWindow = 1;
+    m_achievedFps = 0.0;
     m_outFrameCountOfLastAccumulatorReset = 0;
     time(&m_lastStatusOutputTime);
 
@@ -289,11 +290,11 @@
         int64_t elapsedEncTime = m_curTimeStamp - m_lastTimeStamp;
         int controllerIndex = ((uhdkitEnc->m_encodedFrameCount - 1) / uhdkitEnc->m_param->x265Param->keyframeMax) % uhdkitEnc->m_param->gops;
         X265_CHECK(controllerIndex >= 0 && controllerIndex < uhdkitEnc->m_param->gops, "Invalid controllerIndex: %d, must be between 0 and %d\n", controllerIndex, uhdkitEnc->m_param->gops);
-        if (((m_bScenecut == 1) && elapsedEncTime > 0) || elapsedEncTime >= 300000 || uhdkitEnc->m_achievedFps < m_pcsParam->fpsSetPoint)
+        if (((m_bScenecut == 1) && elapsedEncTime > 0) || elapsedEncTime >= 300000 || m_achievedFps < m_pcsParam->fpsSetPoint)
         {
             // Don't allow outrageously high frame rate measurements to skew the controller.
-            uhdkitEnc->m_achievedFps = X265_MIN(uhdkitEnc->m_achievedFps, 4 * m_pcsParam->fpsSetPoint);
-            error = (m_pcsParam->fpsSetPoint - uhdkitEnc->m_achievedFps) / m_pcsParam->fpsSetPoint;
+            m_achievedFps = X265_MIN(m_achievedFps, 4 * m_pcsParam->fpsSetPoint);
+            error = (m_pcsParam->fpsSetPoint - m_achievedFps) / m_pcsParam->fpsSetPoint;
 
             if (m_pcsParam->integralReset > 0)
             {
@@ -308,7 +309,7 @@
             {
                 double lowerBound = (m_pcsParam->fpsSetPoint * SATURATION_RANGE_MIN) / 100.0;       /* Lower bound, 3% of set-point */
                 double upperBound = (m_pcsParam->fpsSetPoint * SATURATION_RANGE_MAX) / 100.0;       /* Upper bound, 10% of set-point */
-                double fpsDiff = (uhdkitEnc->m_achievedFps - m_pcsParam->fpsSetPoint);
+                double fpsDiff =    (m_achievedFps - m_pcsParam->fpsSetPoint);
                 resetErrorAccumulater = (fpsDiff >= lowerBound && fpsDiff <= upperBound) || m_bScenecut; /* Steady state, or scenecut */
             }
 
@@ -388,7 +389,7 @@
         m_outFrameCountOfLastAccumulatorReset = uhdkitEnc->m_encodedFrameCount;
         m_lastTimeStamp = m_curTimeStamp;
         if (uhdkitEnc->m_reconfigParam->logLevel == UHDKIT_LOG_INFO)
-            uhdkit_pcs_printStatus(&uhdkitEnc->m_reconfigParam[controllerIndex], uhdkitEnc->m_achievedFps);
+            uhdkit_pcs_printStatus(&uhdkitEnc->m_reconfigParam[controllerIndex], m_achievedFps);
     }
     return true;
 }
@@ -398,6 +399,11 @@
     m_bScenecut = pic->frameData.bScenecut;
 }
 
+void pcs::uhdkit_pcs_update_fps(int64_t startTime, int64_t endTime, int numEncoded)
+{
+    m_achievedFps = numEncoded * 1000000.0 / (double)(endTime - startTime);
+}
+
 int pcs::uhdkit_pcs_getControlParamValue(const x265_param *param, int index)
 {
     int controlParamValue[NUM_CONTROLLER] = { param->bEnableFastIntra, param->bEnableEarlySkip, param->bEnableRectInter,
diff -r bdf273f95217 -r 8defd4e7b2e4 source/pcs/pcs.h
--- a/source/pcs/pcs.h	Tue Nov 08 14:20:24 2016 +0530
+++ b/source/pcs/pcs.h	Mon Nov 14 18:38:05 2016 +0530
@@ -32,6 +32,7 @@
     /* variables handled by the PCS Instance */
     pcs_param*      m_pcsParam;
     pcs_controller* m_pcsController;
+    double          m_achievedFps;
     int64_t         m_curTimeStamp;
     int64_t         m_lastTimeStamp;
     time_t          m_lastStatusOutputTime;
@@ -52,6 +53,9 @@
     /* This function updates the scenecut information */
     void uhdkit_pcs_scenecut(x265_picture *pic);
 
+    /* Update achieved fps */
+    void uhdkit_pcs_update_fps(int64_t startTime, int64_t endTime, int numEncoded);
+
     /* Closes all test files */
     void uhdkit_pcs_close();
 };
diff -r bdf273f95217 -r 8defd4e7b2e4 source/uhdkit-encoder.h
--- a/source/uhdkit-encoder.h	Tue Nov 08 14:20:24 2016 +0530
+++ b/source/uhdkit-encoder.h	Mon Nov 14 18:38:05 2016 +0530
@@ -35,7 +35,6 @@
     cappedvbr *m_cappedVbr;
     x265_param* m_reconfigParam; //use if needed, for pcs
     int m_encodedFrameCount;
-    double m_achievedFps;
 
     void uhdkitPreprocess(uhdkitEncoder* uhdEnc, x265_picture&, int picWidth, int picHeight, int csp);
     uhdkitEncoder()
@@ -48,7 +47,6 @@
         m_gopParallelEncoder = NULL;
         m_cappedVbr = NULL;
         m_reconfigParam = NULL;
-        m_achievedFps = 0.0;
     }
 };
 }


More information about the x265-devel mailing list