Re: [x265] [PATCH] Re-evaluate vbv lookahead in the encode that uses
On Thu, Aug 31, 2017 at 4:31 PM,wrote: > # HG changeset patch > # User Bhavna Hariharan > # 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.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); > }
[x265] [PATCH] Re-evaluate vbv lookahead in the encode that uses
# HG changeset patch # User Bhavna Hariharan# 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. 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.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(cuGeom.absPartIdx); @@ -2367,7 +2363,7 @@ checkDQP(mode, cuGeom); } -if (m_param->interRefine < 2 || parentCTU.isIntra(cuGeom.absPartIdx)) +if (m_param->interRefine < 2) { if (m_bTryLossless) tryLossless(cuGeom); @@ -2379,10 +2375,11 @@ checkDQPForSplitPred(*md.bestMode, cuGeom); } -if