changeset 12632:9879e83852b5

zone: Fix BufferRate mismatch and log unclipped BufferFillFinal into csv This commit - Fixes mismatch in BufferRate with dynamic zone reconfiguration when bufferrate varies for each zone - Logs UnclippedBufferFillFinal into csv when csvloglevel greater than 1
author Snehaa Giridharan <snehaa@multicorewareinc.com>
date Thu, 05 Dec 2019 17:55:01 +0530
parents 6cb4a24acac3
children 10e354213df2
files doc/reST/cli.rst source/CMakeLists.txt source/encoder/api.cpp source/encoder/encoder.cpp source/encoder/ratecontrol.cpp source/encoder/ratecontrol.h source/x265.h
diffstat 7 files changed, 17 insertions(+-), 4 deletions(-) [+]
line wrap: on
line diff
--- a/doc/reST/cli.rst	Thu Feb 13 10:26:47 2020 +0530
+++ b/doc/reST/cli.rst	Thu Dec 05 17:55:01 2019 +0530
@@ -107,6 +107,9 @@ Logging/Statistic Options
 	
 	**BufferFillFinal** Buffer bits available after removing the frame out of CPB.
 	
+	**UnclippedBufferFillFinal** Unclipped buffer bits available after removing the frame 
+	out of CPB only used for csv logging purpose.
+	
 	**Latency** Latency in terms of number of frames between when the frame 
 	was given in and when the frame is given out.
 	
--- a/source/CMakeLists.txt	Thu Feb 13 10:26:47 2020 +0530
+++ b/source/CMakeLists.txt	Thu Dec 05 17:55:01 2019 +0530
@@ -29,7 +29,7 @@ option(NATIVE_BUILD "Target the build CP
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 189)
+set(X265_BUILD 190)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
--- a/source/encoder/api.cpp	Thu Feb 13 10:26:47 2020 +0530
+++ b/source/encoder/api.cpp	Thu Dec 05 17:55:01 2019 +0530
@@ -1294,6 +1294,8 @@ FILE* x265_csvlog_open(const x265_param*
                     fprintf(csvfp, "RateFactor, ");
                 if (param->rc.vbvBufferSize)
                     fprintf(csvfp, "BufferFill, BufferFillFinal, ");
+                if (param->rc.vbvBufferSize && param->csvLogLevel >= 2)
+                    fprintf(csvfp, "UnclippedBufferFillFinal, ");
                 if (param->bEnablePsnr)
                     fprintf(csvfp, "Y PSNR, U PSNR, V PSNR, YUV PSNR, ");
                 if (param->bEnableSsim)
@@ -1405,6 +1407,8 @@ void x265_csvlog_frame(const x265_param*
         fprintf(param->csvfpt, "%.3lf,", frameStats->rateFactor);
     if (param->rc.vbvBufferSize)
         fprintf(param->csvfpt, "%.3lf, %.3lf,", frameStats->bufferFill, frameStats->bufferFillFinal);
+    if (param->rc.vbvBufferSize && param->csvLogLevel >= 2)
+        fprintf(param->csvfpt, "%.3lf,", frameStats->unclippedBufferFillFinal);
     if (param->bEnablePsnr)
         fprintf(param->csvfpt, "%.3lf, %.3lf, %.3lf, %.3lf,", frameStats->psnrY, frameStats->psnrU, frameStats->psnrV, frameStats->psnr);
     if (param->bEnableSsim)
--- a/source/encoder/encoder.cpp	Thu Feb 13 10:26:47 2020 +0530
+++ b/source/encoder/encoder.cpp	Thu Dec 05 17:55:01 2019 +0530
@@ -3017,6 +3017,8 @@ void Encoder::finishFrameStats(Frame* cu
             frameStats->ipCostRatio = curFrame->m_lowres.ipCostRatio;
         frameStats->bufferFill = m_rateControl->m_bufferFillActual;
         frameStats->bufferFillFinal = m_rateControl->m_bufferFillFinal;
+        if (m_param->csvLogLevel >= 2)
+            frameStats->unclippedBufferFillFinal = m_rateControl->m_unclippedBufferFillFinal;
         frameStats->frameLatency = inPoc - poc;
         if (m_param->rc.rateControlMode == X265_RC_CRF)
             frameStats->rateFactor = curEncData.m_rateFactor;
--- a/source/encoder/ratecontrol.cpp	Thu Feb 13 10:26:47 2020 +0530
+++ b/source/encoder/ratecontrol.cpp	Thu Dec 05 17:55:01 2019 +0530
@@ -2745,7 +2745,9 @@ int RateControl::updateVbv(int64_t bits,
         x265_log(m_param, X265_LOG_WARNING, "poc:%d, VBV underflow (%.0f bits)\n", rce->poc, m_bufferFillFinal);
 
     m_bufferFillFinal = X265_MAX(m_bufferFillFinal, 0);
-    m_bufferFillFinal += m_bufferRate;
+    m_bufferFillFinal += rce->bufferRate;
+    if (m_param->csvLogLevel >= 2)
+        m_unclippedBufferFillFinal = m_bufferFillFinal;
 
     if (m_param->rc.bStrictCbr)
     {
@@ -2755,14 +2757,14 @@ int RateControl::updateVbv(int64_t bits,
             filler += FILLER_OVERHEAD * 8;
         }
         m_bufferFillFinal -= filler;
-        bufferBits = X265_MIN(bits + filler + m_bufferExcess, m_bufferRate);
+        bufferBits = X265_MIN(bits + filler + m_bufferExcess, rce->bufferRate);
         m_bufferExcess = X265_MAX(m_bufferExcess - bufferBits + bits + filler, 0);
         m_bufferFillActual += bufferBits - bits - filler;
     }
     else
     {
         m_bufferFillFinal = X265_MIN(m_bufferFillFinal, m_bufferSize);
-        bufferBits = X265_MIN(bits + m_bufferExcess, m_bufferRate);
+        bufferBits = X265_MIN(bits + m_bufferExcess, rce->bufferRate);
         m_bufferExcess = X265_MAX(m_bufferExcess - bufferBits + bits, 0);
         m_bufferFillActual += bufferBits - bits;
         m_bufferFillActual = X265_MIN(m_bufferFillActual, m_bufferSize);
--- a/source/encoder/ratecontrol.h	Thu Feb 13 10:26:47 2020 +0530
+++ b/source/encoder/ratecontrol.h	Thu Dec 05 17:55:01 2019 +0530
@@ -157,6 +157,7 @@ public:
     double m_rateFactorConstant;
     double m_bufferSize;
     double m_bufferFillFinal;  /* real buffer as of the last finished frame */
+    double m_unclippedBufferFillFinal; /* real unclipped buffer as of the last finished frame used to log in CSV*/
     double m_bufferFill;       /* planned buffer, if all in-progress frames hit their bit budget */
     double m_bufferRate;       /* # of bits added to buffer_fill after each frame */
     double m_vbvMaxRate;       /* in kbps */
--- a/source/x265.h	Thu Feb 13 10:26:47 2020 +0530
+++ b/source/x265.h	Thu Dec 05 17:55:01 2019 +0530
@@ -304,6 +304,7 @@ typedef struct x265_frame_stats
     double           totalFrameTime;
     double           vmafFrameScore;
     double           bufferFillFinal;
+    double           unclippedBufferFillFinal;
 } x265_frame_stats;
 
 typedef struct x265_ctu_info_t