[x265] [PATCH 2 of 3] rc: don't update predictors from previous frames, after reset at scenecut

Deepthi Nandakumar deepthi at multicorewareinc.com
Wed Sep 23 10:54:46 CEST 2015


This patch does not apply.

On Tue, Sep 22, 2015 at 11:50 AM, <aarthi at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Aarthi Thirumalai
> # Date 1442909407 -19800
> #      Tue Sep 22 13:40:07 2015 +0530
> # Node ID 5a3c92b92a049f49e7712ad3d2ba458937e0c55d
> # Parent  819f8cf72d15c6a3dba77383881b8f4c1140542c
> rc: don't update predictors from previous frames, after reset at scenecut.
>
> diff -r 819f8cf72d15 -r 5a3c92b92a04 source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp    Tue Sep 22 13:33:13 2015 +0530
> +++ b/source/encoder/ratecontrol.cpp    Tue Sep 22 13:40:07 2015 +0530
> @@ -182,6 +182,7 @@
>      m_finalFrameCount = 0;
>      m_numEntries = 0;
>      m_isSceneTransition = false;
> +    m_lastPredictorReset = 0;
>      if (m_param->rc.rateControlMode == X265_RC_CRF)
>      {
>          m_param->rc.qp = (int)m_param->rc.rfConstant;
> @@ -961,10 +962,11 @@
>          copyRceData(rce, &m_rce2Pass[rce->poc]);
>      }
>      rce->isActive = true;
> -    bool isframeAfterKeyframe = m_sliceType != I_SLICE &&
> m_curSlice->m_refFrameList[0][0]->m_encData->m_slice->m_sliceType ==
> I_SLICE;
> +    bool isRefFrameScenecut = m_sliceType!= I_SLICE &&
> m_curSlice->m_refFrameList[0][0]->m_lowres.bScenecut == 1;
>      if (curFrame->m_lowres.bScenecut)
>      {
>          m_isSceneTransition = true;
> +        m_lastPredictorReset = rce->encodeOrder;
>          /* Frame Predictors and Row predictors used in vbv */
>          for (int i = 0; i < 4; i++)
>          {
> @@ -974,10 +976,20 @@
>              m_pred[i].offset = 0.0;
>          }
>          m_pred[0].coeff = m_pred[3].coeff = 0.75;
>
+        if (m_param->rc.qCompress >= 0.8) // when tuned for grain
> +        {
> +            m_pred[1].coeff = 0.75;
> +            m_pred[0].coeff = m_pred[3].coeff = 0.50;
> +        }
>

You need another module initPredictor, which can be called from init() and
ratecontrolStart.


>      }
> -    else if (m_sliceType != B_SLICE && !isframeAfterKeyframe)
> +    else if (m_sliceType != B_SLICE && !isRefFrameScenecut)
>          m_isSceneTransition = false;
>
> +    if (rce->encodeOrder < m_lastPredictorReset +
> m_param->frameNumThreads)
> +    {
> +        rce->rowPreds[0][0].count = 0;
> +    }
> +
>      rce->bLastMiniGopBFrame = curFrame->m_lowres.bLastMiniGopBFrame;
>      rce->bufferRate = m_bufferRate;
>      rce->rowCplxrSum = 0.0;
> @@ -2149,7 +2161,7 @@
>  {
>      int predType = rce->sliceType;
>      predType = rce->sliceType == B_SLICE && rce->keptAsRef ? 3 : predType;
> -    if (rce->lastSatd >= m_ncu)
> +    if (rce->lastSatd >= m_ncu && rce->encodeOrder >=
> m_lastPredictorReset)
>          updatePredictor(&m_pred[predType], x265_qp2qScale(rce->qpaRc),
> (double)rce->lastSatd, (double)bits);
>      if (!m_isVbv)
>          return;
> @@ -2205,6 +2217,7 @@
>          }
>          else
>              curEncData.m_avgQpAq = curEncData.m_avgQpRc;
> +        rce->qpAq = curEncData.m_avgQpAq;
>

rce->qpAq is not used anywhere at this point. Is this a bug?


>      }
>
>      if (m_isAbr)
> diff -r 819f8cf72d15 -r 5a3c92b92a04 source/encoder/ratecontrol.h
> --- a/source/encoder/ratecontrol.h      Tue Sep 22 13:33:13 2015 +0530
> +++ b/source/encoder/ratecontrol.h      Tue Sep 22 13:40:07 2015 +0530
> @@ -173,6 +173,7 @@
>      int     m_numBframesInPattern;
>      bool    m_isPatternPresent;
>      bool    m_isSceneTransition;
> +    int     m_lastPredictorReset;
>
>      /* a common variable on which rateControlStart, rateControlEnd and
> rateControUpdateStats waits to
>       * sync the calls to these functions. For example
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20150923/1e3dd5c1/attachment.html>


More information about the x265-devel mailing list