[x265] [PATCH] Re-evaluate vbv lookahead in the encode that uses

Pradeep Ramachandran pradeep at multicorewareinc.com
Fri Sep 1 10:42:43 CEST 2017


On Thu, Aug 31, 2017 at 4:31 PM, <bhavna at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Bhavna Hariharan <bhavna at multicorewareinc.com>
> # Date 1503468675 -19800
> #      Wed Aug 23 11:41:15 2017 +0530
> # Node ID f5d669bfb2b209f73406cede50878a06eef52fd4
> # Parent  fcd9154fa4e28ae9e3c11e16bfae20dbdb89101d
> Re-evaluate vbv lookahead in the encode that uses
> --analysis-reuse-mode load.
>

Pushed to default branch. thanks!


>
> Evaluate inter modes in encode that uses --analysis-reuse-mode load when
> intra-in-inter blocks are chosen with --refine-inter 2 in the previous
> pass.
>
> diff -r fcd9154fa4e2 -r f5d669bfb2b2 source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp       Mon Aug 21 11:50:36 2017 +0530
> +++ b/source/encoder/analysis.cpp       Wed Aug 23 11:41:15 2017 +0530
> @@ -1150,13 +1150,11 @@
>      bool chooseMerge = false;
>      bool bCtuInfoCheck = false;
>      int sameContentRef = 0;
> -    bool checkRefineInter = false;
>
>      if (m_evaluateInter)
>      {
>          if (m_param->interRefine == 2)
>          {
> -            checkRefineInter = true;
>              if (parentCTU.m_predMode[cuGeom.absPartIdx] == MODE_SKIP)
>                  skipModes = true;
>              if (parentCTU.m_partSize[cuGeom.absPartIdx] == SIZE_2Nx2N)
> @@ -1279,7 +1277,7 @@
>          md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
>          checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP], md.pred[PRED_MERGE],
> cuGeom);
>          if (m_param->rdLevel)
> -            skipModes = (m_param->bEnableEarlySkip || checkRefineInter)
> +            skipModes = (m_param->bEnableEarlySkip ||
> m_param->interRefine == 2)
>                          && md.bestMode && md.bestMode->cu.isSkipped(0);
> // TODO: sa8d threshold per depth
>      }
>
> @@ -1539,7 +1537,7 @@
>                      }
>                  }
>              }
> -            bool bTryIntra = (m_slice->m_sliceType != B_SLICE ||
> m_param->bIntraInBFrames) && cuGeom.log2CUSize != MAX_LOG2_CU_SIZE &&
> !((m_param->bCTUInfo & 4) && bCtuInfoCheck) && !checkRefineInter;
> +            bool bTryIntra = (m_slice->m_sliceType != B_SLICE ||
> m_param->bIntraInBFrames) && cuGeom.log2CUSize != MAX_LOG2_CU_SIZE &&
> !((m_param->bCTUInfo & 4) && bCtuInfoCheck);
>              if (m_param->rdLevel >= 3)
>              {
>                  /* Calculate RD cost of best inter option */
> @@ -1784,13 +1782,11 @@
>      bool skipRectAmp = false;
>      bool bCtuInfoCheck = false;
>      int sameContentRef = 0;
> -    bool checkRefineInter = false;
>
>      if (m_evaluateInter)
>      {
>          if (m_param->interRefine == 2)
>          {
> -            checkRefineInter = true;
>              if (parentCTU.m_predMode[cuGeom.absPartIdx] == MODE_SKIP)
>                  skipModes = true;
>              if (parentCTU.m_partSize[cuGeom.absPartIdx] == SIZE_2Nx2N)
> @@ -1919,7 +1915,7 @@
>          md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
>          md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);
>          checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE],
> cuGeom);
> -        skipModes = (m_param->bEnableEarlySkip || checkRefineInter) &&
> +        skipModes = (m_param->bEnableEarlySkip || m_param->interRefine ==
> 2) &&
>                      md.bestMode && !md.bestMode->cu.getQtRootCbf(0);
>          refMasks[0] = allSplitRefs;
>          md.pred[PRED_2Nx2N].cu.initSubCU(parentCTU, cuGeom, qp);
> @@ -2172,7 +2168,7 @@
>                  }
>              }
>
> -            if ((m_slice->m_sliceType != B_SLICE ||
> m_param->bIntraInBFrames) && (cuGeom.log2CUSize != MAX_LOG2_CU_SIZE) &&
> !((m_param->bCTUInfo & 4) && bCtuInfoCheck) && !checkRefineInter)
> +            if ((m_slice->m_sliceType != B_SLICE ||
> m_param->bIntraInBFrames) && (cuGeom.log2CUSize != MAX_LOG2_CU_SIZE) &&
> !((m_param->bCTUInfo & 4) && bCtuInfoCheck))
>              {
>                  if (!m_param->limitReferences || splitIntra)
>                  {
> @@ -2288,7 +2284,7 @@
>          md.bestMode = &mode;
>          mode.cu.initSubCU(parentCTU, cuGeom, qp);
>          PartSize size = (PartSize)parentCTU.m_partSize
> [cuGeom.absPartIdx];
> -        if (parentCTU.isIntra(cuGeom.absPartIdx))
> +        if (parentCTU.isIntra(cuGeom.absPartIdx) && m_param->interRefine
> < 2)
>          {
>              bool reuseModes = !((m_param->intraRefine == 3) ||
>                                  (m_param->intraRefine == 2 &&
> parentCTU.m_lumaIntraDir[cuGeom.absPartIdx] > DC_IDX));
> @@ -2299,7 +2295,7 @@
>              }
>              checkIntra(mode, cuGeom, size);
>          }
> -        else if (m_param->interRefine < 2)
> +        else if (!parentCTU.isIntra(cuGeom.absPartIdx) &&
> m_param->interRefine < 2)
>          {
>              mode.cu.copyFromPic(parentCTU, cuGeom, m_csp, false);
>              uint32_t numPU = parentCTU.getNumPartInter(cuGe
> om.absPartIdx);
> @@ -2367,7 +2363,7 @@
>                  checkDQP(mode, cuGeom);
>          }
>
> -        if (m_param->interRefine < 2 || parentCTU.isIntra(cuGeom.absPa
> rtIdx))
> +        if (m_param->interRefine < 2)
>          {
>              if (m_bTryLossless)
>                  tryLossless(cuGeom);
> @@ -2379,10 +2375,11 @@
>                  checkDQPForSplitPred(*md.bestMode, cuGeom);
>          }
>
> -        if (!parentCTU.isIntra(cuGeom.absPartIdx) && (
> m_param->interRefine > 1 || (m_param->interRefine &&
> parentCTU.m_predMode[cuGeom.absPartIdx] == MODE_SKIP  &&
> !mode.cu.isSkipped(0))))
> +        if (m_param->interRefine > 1 || (m_param->interRefine &&
> parentCTU.m_predMode[cuGeom.absPartIdx] == MODE_SKIP  &&
> !mode.cu.isSkipped(0)))
>          {
>              m_evaluateInter = 1;
>              m_param->rdLevel > 4 ? compressInterCU_rd5_6(parentCTU,
> cuGeom, qp) : compressInterCU_rd0_4(parentCTU, cuGeom, qp);
> +            m_evaluateInter = 0;
>          }
>      }
>      if (!bDecidedDepth || split)
> diff -r fcd9154fa4e2 -r f5d669bfb2b2 source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp      Mon Aug 21 11:50:36 2017 +0530
> +++ b/source/encoder/slicetype.cpp      Wed Aug 23 11:41:15 2017 +0530
> @@ -1036,6 +1036,18 @@
>           (m_param->lookaheadDepth && m_param->rc.vbvBufferSize)))
>      {
>          slicetypeAnalyse(frames, false);
> +        bool bIsVbv = m_param->rc.vbvBufferSize > 0 &&
> m_param->rc.vbvMaxBitrate > 0;
> +        if (m_param->analysisReuseMode == X265_ANALYSIS_LOAD &&
> m_param->scaleFactor && bIsVbv)
> +        {
> +            int numFrames;
> +            for (numFrames = 0; numFrames < maxSearch; numFrames++)
> +            {
> +                Lowres *fenc = frames[numFrames + 1];
> +                if (!fenc)
> +                    break;
> +            }
> +            vbvLookahead(frames, numFrames, true);
> +        }
>      }
>
>      int bframes, brefs;
> @@ -1219,6 +1231,18 @@
>
>          frames[j + 1] = NULL;
>          slicetypeAnalyse(frames, true);
> +        bool bIsVbv = m_param->rc.vbvBufferSize > 0 &&
> m_param->rc.vbvMaxBitrate > 0;
> +        if (m_param->analysisReuseMode == X265_ANALYSIS_LOAD &&
> m_param->scaleFactor && bIsVbv)
> +        {
> +            int numFrames;
> +            for (numFrames = 0; numFrames < maxSearch; numFrames++)
> +            {
> +                Lowres *fenc = frames[numFrames + 1];
> +                if (!fenc)
> +                    break;
> +            }
> +            vbvLookahead(frames, numFrames, true);
> +        }
>      }
>      m_outputLock.release();
>  }
>
> _______________________________________________
> 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/20170901/c3696c34/attachment-0001.html>


More information about the x265-devel mailing list