<div dir="ltr">Pushed to Release_3.5<div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 30, 2020 at 11:44 PM Aruna Matheswaran <<a href="mailto:aruna@multicorewareinc.com">aruna@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">From e56e88cc54e6c5fc8c8997937e3b46744e9de66a Mon Sep 17 00:00:00 2001<br>From: Aruna <<a href="mailto:aruna@multicorewareinc.com" target="_blank">aruna@multicorewareinc.com</a>><br>Date: Wed, 30 Sep 2020 23:38:34 +0530<br>Subject: [PATCH] vbv: fix incorrect target fill<br><br>---<br> source/encoder/ratecontrol.cpp | 8 +++++---<br> source/encoder/ratecontrol.h | 2 ++<br> 2 files changed, 7 insertions(+), 3 deletions(-)<br><br>diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp<br>index 4e7d52419..515d9e543 100644<br>--- a/source/encoder/ratecontrol.cpp<br>+++ b/source/encoder/ratecontrol.cpp<br>@@ -356,6 +356,8 @@ bool RateControl::init(const SPS& sps)<br> m_bufferFillFinal = m_bufferSize * m_param->rc.vbvBufferInit;<br> m_bufferFillActual = m_bufferFillFinal;<br> m_bufferExcess = 0;<br>+ m_minBufferFill = m_param->minVbvFullness / 100;<br>+ m_maxBufferFill = 1 - (m_param->maxVbvFullness / 100);<br> m_initVbv = true;<br> }<br> <br>@@ -2380,7 +2382,7 @@ double RateControl::clipQscale(Frame* curFrame, RateControlEntry* rce, double q)<br> {<br> finalDur = x265_clip3(0.4, 1.0, totalDuration);<br> }<br>- targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5, m_bufferSize * ((m_param->minVbvFullness / 100) * finalDur));<br>+ targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5, m_bufferSize * (1 - m_minBufferFill * finalDur));<br> if (bufferFillCur < targetFill)<br> {<br> q *= 1.01;<br>@@ -2389,7 +2391,7 @@ double RateControl::clipQscale(Frame* curFrame, RateControlEntry* rce, double q)<br> }<br> /* Try to get the buffer not more than 80% filled, but don't set an impossible goal. */<br> <br>- targetFill = x265_clip3(m_bufferSize * ((m_param->maxVbvFullness / 100) * finalDur), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);<br>+ targetFill = x265_clip3(m_bufferSize * (1 - m_maxBufferFill * finalDur), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);<br> if ((m_isCbr || m_2pass) && bufferFillCur > targetFill && !m_isSceneTransition)<br> {<br> q /= 1.01;<br>@@ -2406,7 +2408,7 @@ double RateControl::clipQscale(Frame* curFrame, RateControlEntry* rce, double q)<br> /* Fallback to old purely-reactive algorithm: no lookahead. */<br> if ((m_sliceType == P_SLICE || m_sliceType == B_SLICE ||<br> (m_sliceType == I_SLICE && m_lastNonBPictType == I_SLICE)) &&<br>- m_bufferFill / m_bufferSize < (m_param->minVbvFullness / 100))<br>+ m_bufferFill / m_bufferSize < m_minBufferFill)<br> {<br> q /= x265_clip3(0.5, 1.0, 2.0 * m_bufferFill / m_bufferSize);<br> }<br>diff --git a/source/encoder/ratecontrol.h b/source/encoder/ratecontrol.h<br>index 809e0c620..449cb218b 100644<br>--- a/source/encoder/ratecontrol.h<br>+++ b/source/encoder/ratecontrol.h<br>@@ -164,6 +164,8 @@ public:<br> double m_avgPFrameQp;<br> double m_bufferFillActual;<br> double m_bufferExcess;<br>+ double m_minBufferFill;<br>+ double m_maxBufferFill;<br> bool m_isFirstMiniGop;<br> Predictor m_pred[4]; /* Slice predictors to preidct bits for each Slice type - I,P,Bref and B */<br> int64_t m_leadingNoBSatd;<br>-- <br>2.20.1.windows.1<br><br><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="georgia, serif">Regards,</font><div><b><font face="georgia, serif">Aruna Matheswaran,</font></b></div><div><font face="georgia, serif">Video Codec Engineer,</font></div><div><font face="georgia, serif">Media & AI analytics BU,</font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" width="96" height="36" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div></div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="georgia, serif">Regards,</font><div><b><font face="georgia, serif">Aruna Matheswaran,</font></b></div><div><font face="georgia, serif">Video Codec Engineer,</font></div><div><font face="georgia, serif">Media & AI analytics BU,</font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" width="96" height="36" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div></div></div></div></div></div></div></div></div>