[x265] [x265 - PATCH] vbv: fix incorrect target fill
Aruna Matheswaran
aruna at multicorewareinc.com
Thu Oct 1 15:52:12 CEST 2020
Pushed to Release_3.5
On Wed, Sep 30, 2020 at 11:44 PM Aruna Matheswaran <
aruna at multicorewareinc.com> wrote:
> From e56e88cc54e6c5fc8c8997937e3b46744e9de66a Mon Sep 17 00:00:00 2001
> From: Aruna <aruna at multicorewareinc.com>
> Date: Wed, 30 Sep 2020 23:38:34 +0530
> Subject: [PATCH] vbv: fix incorrect target fill
>
> ---
> source/encoder/ratecontrol.cpp | 8 +++++---
> source/encoder/ratecontrol.h | 2 ++
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/source/encoder/ratecontrol.cpp
> b/source/encoder/ratecontrol.cpp
> index 4e7d52419..515d9e543 100644
> --- a/source/encoder/ratecontrol.cpp
> +++ b/source/encoder/ratecontrol.cpp
> @@ -356,6 +356,8 @@ bool RateControl::init(const SPS& sps)
> m_bufferFillFinal = m_bufferSize * m_param->rc.vbvBufferInit;
> m_bufferFillActual = m_bufferFillFinal;
> m_bufferExcess = 0;
> + m_minBufferFill = m_param->minVbvFullness / 100;
> + m_maxBufferFill = 1 - (m_param->maxVbvFullness / 100);
> m_initVbv = true;
> }
>
> @@ -2380,7 +2382,7 @@ double RateControl::clipQscale(Frame* curFrame,
> RateControlEntry* rce, double q)
> {
> finalDur = x265_clip3(0.4, 1.0, totalDuration);
> }
> - targetFill = X265_MIN(m_bufferFill + totalDuration *
> m_vbvMaxRate * 0.5, m_bufferSize * ((m_param->minVbvFullness / 100) *
> finalDur));
> + targetFill = X265_MIN(m_bufferFill + totalDuration *
> m_vbvMaxRate * 0.5, m_bufferSize * (1 - m_minBufferFill * finalDur));
> if (bufferFillCur < targetFill)
> {
> q *= 1.01;
> @@ -2389,7 +2391,7 @@ double RateControl::clipQscale(Frame* curFrame,
> RateControlEntry* rce, double q)
> }
> /* Try to get the buffer not more than 80% filled,
> but don't set an impossible goal. */
>
> - targetFill = x265_clip3(m_bufferSize *
> ((m_param->maxVbvFullness / 100) * finalDur), m_bufferSize, m_bufferFill -
> totalDuration * m_vbvMaxRate * 0.5);
> + targetFill = x265_clip3(m_bufferSize * (1 -
> m_maxBufferFill * finalDur), m_bufferSize, m_bufferFill - totalDuration *
> m_vbvMaxRate * 0.5);
> if ((m_isCbr || m_2pass) && bufferFillCur >
> targetFill && !m_isSceneTransition)
> {
> q /= 1.01;
> @@ -2406,7 +2408,7 @@ double RateControl::clipQscale(Frame* curFrame,
> RateControlEntry* rce, double q)
> /* Fallback to old purely-reactive algorithm: no lookahead. */
> if ((m_sliceType == P_SLICE || m_sliceType == B_SLICE ||
> (m_sliceType == I_SLICE && m_lastNonBPictType ==
> I_SLICE)) &&
> - m_bufferFill / m_bufferSize < (m_param->minVbvFullness /
> 100))
> + m_bufferFill / m_bufferSize < m_minBufferFill)
> {
> q /= x265_clip3(0.5, 1.0, 2.0 * m_bufferFill /
> m_bufferSize);
> }
> diff --git a/source/encoder/ratecontrol.h b/source/encoder/ratecontrol.h
> index 809e0c620..449cb218b 100644
> --- a/source/encoder/ratecontrol.h
> +++ b/source/encoder/ratecontrol.h
> @@ -164,6 +164,8 @@ public:
> double m_avgPFrameQp;
> double m_bufferFillActual;
> double m_bufferExcess;
> + double m_minBufferFill;
> + double m_maxBufferFill;
> bool m_isFirstMiniGop;
> Predictor m_pred[4]; /* Slice predictors to preidct bits for
> each Slice type - I,P,Bref and B */
> int64_t m_leadingNoBSatd;
> --
> 2.20.1.windows.1
>
>
> --
> Regards,
> *Aruna Matheswaran,*
> Video Codec Engineer,
> Media & AI analytics BU,
>
>
>
>
--
Regards,
*Aruna Matheswaran,*
Video Codec Engineer,
Media & AI analytics BU,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20201001/d6592cb6/attachment.html>
More information about the x265-devel
mailing list