<div dir="ltr"># HG changeset patch<br># User Snehaa Giridharan <<a href="mailto:snehaa@multicorewareinc.com">snehaa@multicorewareinc.com</a>><br># Date 1575548701 -19800<br>#      Thu Dec 05 17:55:01 2019 +0530<br># Node ID 1010e8e347a292c4e6651a7ae374fd5ef039724b<br># Parent  ce3a4929efca3034bce12b7449d73ed2e03f9b4d<br>zone: Fix BufferRate mismatch and log unclipped BufferFillFinal into csv<br><br>This commit<br>- Fixes mismatch in BufferRate with dynamic zone reconfiguration when bufferrate varies for each zone<br>- Logs UnclippedBufferFillFinal into csv when csvloglevel greater than 1<br><br>diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst<br>--- a/doc/reST/cli.rst<br>+++ b/doc/reST/cli.rst<br>@@ -107,6 +107,9 @@<br>     <br>     **BufferFillFinal** Buffer bits available after removing the frame out of CPB.<br>       <br>+     **UnclippedBufferFillFinal** Unclipped buffer bits available after removing the frame <br>+       out of CPB only used for csv logging purpose.<br>+        <br>     **Latency** Latency in terms of number of frames between when the frame <br>     was given in and when the frame is given out.<br>        <br>diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt<br>--- a/source/CMakeLists.txt<br>+++ b/source/CMakeLists.txt<br>@@ -29,7 +29,7 @@<br> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br> # X265_BUILD must be incremented each time the public API is changed<br>-set(X265_BUILD 189)<br>+set(X265_BUILD 190)<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in">x265.def.in</a>"<br>                "${PROJECT_BINARY_DIR}/x265.def")<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in">x265_config.h.in</a>"<br>diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp<br>--- a/source/encoder/api.cpp<br>+++ b/source/encoder/api.cpp<br>@@ -1294,6 +1294,8 @@<br>                     fprintf(csvfp, "RateFactor, ");<br>                 if (param->rc.vbvBufferSize)<br>                     fprintf(csvfp, "BufferFill, BufferFillFinal, ");<br>+                if (param->rc.vbvBufferSize && param->csvLogLevel >= 2)<br>+                    fprintf(csvfp, "UnclippedBufferFillFinal, ");<br>                 if (param->bEnablePsnr)<br>                     fprintf(csvfp, "Y PSNR, U PSNR, V PSNR, YUV PSNR, ");<br>                 if (param->bEnableSsim)<br>@@ -1405,6 +1407,8 @@<br>         fprintf(param->csvfpt, "%.3lf,", frameStats->rateFactor);<br>     if (param->rc.vbvBufferSize)<br>         fprintf(param->csvfpt, "%.3lf, %.3lf,", frameStats->bufferFill, frameStats->bufferFillFinal);<br>+    if (param->rc.vbvBufferSize && param->csvLogLevel >= 2)<br>+        fprintf(param->csvfpt, "%.3lf,", frameStats->unclippedBufferFillFinal);<br>     if (param->bEnablePsnr)<br>         fprintf(param->csvfpt, "%.3lf, %.3lf, %.3lf, %.3lf,", frameStats->psnrY, frameStats->psnrU, frameStats->psnrV, frameStats->psnr);<br>     if (param->bEnableSsim)<br>diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp<br>--- a/source/encoder/encoder.cpp<br>+++ b/source/encoder/encoder.cpp<br>@@ -3012,6 +3012,8 @@<br>             frameStats->ipCostRatio = curFrame->m_lowres.ipCostRatio;<br>         frameStats->bufferFill = m_rateControl->m_bufferFillActual;<br>         frameStats->bufferFillFinal = m_rateControl->m_bufferFillFinal;<br>+        if (m_param->csvLogLevel >= 2)<br>+            frameStats->unclippedBufferFillFinal = m_rateControl->m_unclippedBufferFillFinal;<br>         frameStats->frameLatency = inPoc - poc;<br>         if (m_param->rc.rateControlMode == X265_RC_CRF)<br>             frameStats->rateFactor = curEncData.m_rateFactor;<br>diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp<br>--- a/source/encoder/ratecontrol.cpp<br>+++ b/source/encoder/ratecontrol.cpp<br>@@ -2745,7 +2745,9 @@<br>         x265_log(m_param, X265_LOG_WARNING, "poc:%d, VBV underflow (%.0f bits)\n", rce->poc, m_bufferFillFinal);<br> <br>     m_bufferFillFinal = X265_MAX(m_bufferFillFinal, 0);<br>-    m_bufferFillFinal += m_bufferRate;<br>+    m_bufferFillFinal += rce->bufferRate;<br>+    if (m_param->csvLogLevel >= 2)<br>+        m_unclippedBufferFillFinal = m_bufferFillFinal;<br> <br>     if (m_param->rc.bStrictCbr)<br>     {<br>@@ -2755,14 +2757,14 @@<br>             filler += FILLER_OVERHEAD * 8;<br>         }<br>         m_bufferFillFinal -= filler;<br>-        bufferBits = X265_MIN(bits + filler + m_bufferExcess, m_bufferRate);<br>+        bufferBits = X265_MIN(bits + filler + m_bufferExcess, rce->bufferRate);<br>         m_bufferExcess = X265_MAX(m_bufferExcess - bufferBits + bits + filler, 0);<br>         m_bufferFillActual += bufferBits - bits - filler;<br>     }<br>     else<br>     {<br>         m_bufferFillFinal = X265_MIN(m_bufferFillFinal, m_bufferSize);<br>-        bufferBits = X265_MIN(bits + m_bufferExcess, m_bufferRate);<br>+        bufferBits = X265_MIN(bits + m_bufferExcess, rce->bufferRate);<br>         m_bufferExcess = X265_MAX(m_bufferExcess - bufferBits + bits, 0);<br>         m_bufferFillActual += bufferBits - bits;<br>         m_bufferFillActual = X265_MIN(m_bufferFillActual, m_bufferSize);<br>diff --git a/source/encoder/ratecontrol.h b/source/encoder/ratecontrol.h<br>--- a/source/encoder/ratecontrol.h<br>+++ b/source/encoder/ratecontrol.h<br>@@ -157,6 +157,7 @@<br>     double m_rateFactorConstant;<br>     double m_bufferSize;<br>     double m_bufferFillFinal;  /* real buffer as of the last finished frame */<br>+    double m_unclippedBufferFillFinal; /* real unclipped buffer as of the last finished frame used to log in CSV*/<br>     double m_bufferFill;       /* planned buffer, if all in-progress frames hit their bit budget */<br>     double m_bufferRate;       /* # of bits added to buffer_fill after each frame */<br>     double m_vbvMaxRate;       /* in kbps */<br>diff --git a/source/x265.h b/source/x265.h<br>--- a/source/x265.h<br>+++ b/source/x265.h<br>@@ -304,6 +304,7 @@<br>     double           totalFrameTime;<br>     double           vmafFrameScore;<br>     double           bufferFillFinal;<br>+    double           unclippedBufferFillFinal;<br> } x265_frame_stats;<br> <br> typedef struct x265_ctu_info_t<br><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><i><font face="georgia, serif">Thanks and Regards,</font></i></div><div><i><b><font face="georgia, serif">Snehaa.G</font></b></i></div></div></div></div></div></div></div></div></div></div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tr>
        <td style="width:55px;padding-top:13px"><a href="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" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">I’m protected online with Avast Free Antivirus. <a href="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" target="_blank" style="color:#4453ea">Get it here — it’s free forever.</a>
                </td>
        </tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>