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

Aarthi Priya Thirumalai aarthi at multicorewareinc.com
Mon Sep 28 13:56:18 CEST 2015


No.
We will re init vbv predictors and apply the scenecut transition related
controls from the scene that begins the scene change which is signaled by
bScenecut flag.
and revert the operation at the next mini-gop.


On Mon, Sep 28, 2015 at 5:03 PM, Deepthi Nandakumar <
deepthi at multicorewareinc.com> wrote:

>
>
> On Thu, Sep 24, 2015 at 1:56 PM, <aarthi at multicorewareinc.com> wrote:
>
>> # HG changeset patch
>> # User Aarthi Thirumalai
>> # Date 1442909407 -19800
>> #      Tue Sep 22 13:40:07 2015 +0530
>> # Branch stable
>> # Node ID c44b32bc7c906456ad242dd237831ec96c1f5c3d
>> # Parent  69d55d4c53ebff6d98e4431e0f8fe6103705b8ec
>> rc: don't update predictors from previous frames, after reset at scenecut.
>>
>> diff -r 69d55d4c53eb -r c44b32bc7c90 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;
>> @@ -370,20 +371,8 @@
>>      m_accumPNorm = .01;
>>      m_accumPQp = (m_param->rc.rateControlMode == X265_RC_CRF ?
>> CRF_INIT_QP : ABR_INIT_QP_MIN) * m_accumPNorm;
>>
>> -    /* Frame Predictors and Row predictors used in vbv */
>> -    for (int i = 0; i < 4; i++)
>> -    {
>> -        m_pred[i].coeff = 1.0;
>> -        m_pred[i].count = 1.0;
>> -        m_pred[i].decay = 0.5;
>> -        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;
>> -    }
>> +    /* Frame Predictors used in vbv */
>> +    initFramePredictors();
>>      if (!m_statFileOut && (m_param->rc.bStatWrite ||
>> m_param->rc.bStatRead))
>>      {
>>          /* If the user hasn't defined the stat filename, use the default
>> value */
>> @@ -932,6 +921,24 @@
>>          return X265_TYPE_AUTO;
>>  }
>>
>> +void RateControl::initFramePredictors()
>> +{
>> +    /* Frame Predictors used in vbv */
>> +    for (int i = 0; i < 4; i++)
>> +    {
>> +        m_pred[i].coeff = 1.0;
>> +        m_pred[i].count = 1.0;
>> +        m_pred[i].decay = 0.5;
>> +        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;
>> +    }
>> +}
>> +
>>  int RateControl::rateControlStart(Frame* curFrame, RateControlEntry*
>> rce, Encoder* enc)
>>  {
>>      int orderValue = m_startEndOrder.get();
>> @@ -961,23 +968,21 @@
>>          copyRceData(rce, &m_rce2Pass[rce->poc]);
>>      }
>>      rce->isActive = true;
>> -    bool isframeAfterKeyframe = m_sliceType != I_SLICE &&
>> m_curSlice->m_refPicList[0][0]->m_encData->m_slice->m_sliceType == I_SLICE;
>> +    bool isRefFrameScenecut = m_sliceType!= I_SLICE &&
>> m_curSlice->m_refPicList[0][0]->m_lowres.bScenecut == 1;
>>      if (curFrame->m_lowres.bScenecut)
>>      {
>>
>
> This should be if (isRefFrameScenecut)?
>
>
>>          m_isSceneTransition = true;
>> -        /* Frame Predictors and Row predictors used in vbv */
>> -        for (int i = 0; i < 4; i++)
>> -        {
>> -            m_pred[i].coeff = 1.0;
>> -            m_pred[i].count = 1.0;
>> -            m_pred[i].decay = 0.5;
>> -            m_pred[i].offset = 0.0;
>> -        }
>> -        m_pred[0].coeff = m_pred[3].coeff = 0.75;
>> +        m_lastPredictorReset = rce->encodeOrder;
>> +        initFramePredictors();
>>      }
>> -    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 +2154,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;
>> diff -r 69d55d4c53eb -r c44b32bc7c90 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
>> @@ -257,6 +258,7 @@
>>      void   checkAndResetABR(RateControlEntry* rce, bool isFrameDone);
>>      double predictRowsSizeSum(Frame* pic, RateControlEntry* rce, double
>> qpm, int32_t& encodedBits);
>>      bool   initPass2();
>> +    void   initFramePredictors();
>>      double getDiffLimitedQScale(RateControlEntry *rce, double q);
>>      double countExpectedBits();
>>      bool   vbv2Pass(uint64_t allAvailableBits);
>> _______________________________________________
>> x265-devel mailing list
>> x265-devel at videolan.org
>> https://mailman.videolan.org/listinfo/x265-devel
>>
>
>
> _______________________________________________
> 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/20150928/b6e1681f/attachment.html>


More information about the x265-devel mailing list