[x265] [PATCH] zone: Fix BufferRate mismatch and log unclipped BufferFillFinal into csv

Snehaa Giridharan snehaa at multicorewareinc.com
Wed Mar 18 14:35:01 CET 2020


# HG changeset patch
# User Snehaa Giridharan <snehaa at multicorewareinc.com>
# Date 1575548701 -19800
#      Thu Dec 05 17:55:01 2019 +0530
# Node ID 1010e8e347a292c4e6651a7ae374fd5ef039724b
# Parent  ce3a4929efca3034bce12b7449d73ed2e03f9b4d
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

diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
--- a/doc/reST/cli.rst
+++ b/doc/reST/cli.rst
@@ -107,6 +107,9 @@

  **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.

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -29,7 +29,7 @@
 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"
diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp
--- a/source/encoder/api.cpp
+++ b/source/encoder/api.cpp
@@ -1294,6 +1294,8 @@
                     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 @@
         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)
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -3012,6 +3012,8 @@
             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;
diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp
+++ b/source/encoder/ratecontrol.cpp
@@ -2745,7 +2745,9 @@
         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 @@
             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);
diff --git a/source/encoder/ratecontrol.h b/source/encoder/ratecontrol.h
--- a/source/encoder/ratecontrol.h
+++ b/source/encoder/ratecontrol.h
@@ -157,6 +157,7 @@
     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 */
diff --git a/source/x265.h b/source/x265.h
--- a/source/x265.h
+++ b/source/x265.h
@@ -304,6 +304,7 @@
     double           totalFrameTime;
     double           vmafFrameScore;
     double           bufferFillFinal;
+    double           unclippedBufferFillFinal;
 } x265_frame_stats;

 typedef struct x265_ctu_info_t

-- 
*Thanks and Regards,*
*Snehaa.G*

<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=5d1cffcc-cd7a-478a-8410-76188ea236f6>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=5d1cffcc-cd7a-478a-8410-76188ea236f6>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20200318/3d8d15f4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Fix BufferRate mismatch and log unclipped BufferFillFinal into csv.diff
Type: application/octet-stream
Size: 5752 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20200318/3d8d15f4/attachment-0001.obj>


More information about the x265-devel mailing list