[x265] [PATCH] analysis: removed switch-case to read the best ref index
Steve Borho
steve at borho.org
Tue May 26 14:04:48 CEST 2015
On 05/25, ashok at multicorewareinc.com wrote:
> # HG changeset patch
> # User Ashok Kumar Mishra<ashok at multicorewareinc.com>
> # Date 1432566054 -19800
> # Mon May 25 20:30:54 2015 +0530
> # Node ID 44f4024a71b921acc99d21a4e342ebe791d8128b
> # Parent 1335a2788c60d97c68d25250f847fe6a76fb0de6
> analysis: removed switch-case to read the best ref index
Two more follow-up patches for this series
1) I believe the X265_ANALYSIS_LOAD conditional can be removed from
predInterSearch() by having callers limit the refmasks passed to the
function when analysis is in load mode (removing one of the three
redudant copies of the ME logic, --pme is the other redundant copy)
2) Analysis::compressInterCU_dist() should follow the same pattern of
merge/skip, splits, then inter/intra, with only the inter/intra modes
being distributed. This will re-align pmode to work like normal
analysis and we'll be able to use the same or similar work avoidance
logic to limit refs and intra preds, etc.
> diff -r 1335a2788c60 -r 44f4024a71b9 source/common/cudata.h
> --- a/source/common/cudata.h Mon May 25 20:30:54 2015 +0530
> +++ b/source/common/cudata.h Mon May 25 20:30:54 2015 +0530
> @@ -222,6 +222,8 @@
> void getNeighbourMV(uint32_t puIdx, uint32_t absPartIdx, InterNeighbourMV* neighbours) const;
> void getIntraTUQtDepthRange(uint32_t tuDepthRange[2], uint32_t absPartIdx) const;
> void getInterTUQtDepthRange(uint32_t tuDepthRange[2], uint32_t absPartIdx) const;
> + uint32_t getBestRefIdx(uint32_t subPartIdx) const { return ((m_interDir[subPartIdx] & 1) << m_refIdx[0][subPartIdx]) |
> + (((m_interDir[subPartIdx] >> 1) & 1) << (m_refIdx[1][subPartIdx] + 16)); }
>
> uint32_t getNumPartInter() const { return nbPartsTable[(int)m_partSize[0]]; }
> bool isIntra(uint32_t absPartIdx) const { return m_predMode[absPartIdx] == MODE_INTRA; }
> diff -r 1335a2788c60 -r 44f4024a71b9 source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp Mon May 25 20:30:54 2015 +0530
> +++ b/source/encoder/analysis.cpp Mon May 25 20:30:54 2015 +0530
> @@ -853,20 +853,7 @@
> if (m_param->limitReferences & X265_REF_LIMIT_CU)
> {
> CUData& cu = md.pred[PRED_2Nx2N].cu;
> - int refMask;
> - switch (cu.m_interDir[0])
> - {
> - case 1:
> - refMask = 1 << cu.m_refIdx[0][0];
> - break;
> - case 2:
> - refMask = 1 << (cu.m_refIdx[1][0] + 16);
> - break;
> - case 3:
> - refMask = 1 << cu.m_refIdx[0][0];
> - refMask |= 1 << (cu.m_refIdx[1][0] + 16);
> - break;
> - }
> + uint32_t refMask = cu.getBestRefIdx(0);
> allSplitRefs = splitRefs[0] = splitRefs[1] = splitRefs[2] = splitRefs[3] = refMask;
> }
>
> @@ -1101,22 +1088,7 @@
> uint32_t puOffset = (g_puOffset[uint32_t(partSize)] << (g_unitSizeDepth - cu.m_cuDepth[0]) * 2) >> 4;
> refMask = 0;
> for (uint32_t puIdx = 0, subPartIdx = 0; puIdx < numPU; puIdx++, subPartIdx += puOffset)
> - {
> - uint32_t interDir = cu.m_interDir[subPartIdx];
> - switch (interDir)
> - {
> - case 1:
> - refMask |= 1 << cu.m_refIdx[0][subPartIdx];
> - break;
> - case 2:
> - refMask |= 1 << (cu.m_refIdx[1][subPartIdx] + 16);
> - break;
> - case 3:
> - refMask |= 1 << cu.m_refIdx[0][subPartIdx];
> - refMask |= 1 << (cu.m_refIdx[1][subPartIdx] + 16);
> - break;
> - }
> - }
> + refMask |= cu.getBestRefIdx(subPartIdx);
> }
>
> if (mightNotSplit)
> @@ -1254,20 +1226,7 @@
> if (m_param->limitReferences & X265_REF_LIMIT_CU)
> {
> CUData& cu = md.pred[PRED_2Nx2N].cu;
> - int refMask;
> - switch (cu.m_interDir[0])
> - {
> - case 1:
> - refMask = 1 << cu.m_refIdx[0][0];
> - break;
> - case 2:
> - refMask = 1 << (cu.m_refIdx[1][0] + 16);
> - break;
> - case 3:
> - refMask = 1 << cu.m_refIdx[0][0];
> - refMask |= 1 << (cu.m_refIdx[1][0] + 16);
> - break;
> - }
> + uint32_t refMask = cu.getBestRefIdx(0);
> allSplitRefs = splitRefs[0] = splitRefs[1] = splitRefs[2] = splitRefs[3] = refMask;
> }
>
> @@ -1390,22 +1349,7 @@
> uint32_t puOffset = (g_puOffset[uint32_t(partSize)] << (g_unitSizeDepth - cu.m_cuDepth[0]) * 2) >> 4;
> refMask = 0;
> for (uint32_t puIdx = 0, subPartIdx = 0; puIdx < numPU; puIdx++, subPartIdx += puOffset)
> - {
> - uint32_t interDir = cu.m_interDir[subPartIdx];
> - switch (interDir)
> - {
> - case 1:
> - refMask |= 1 << cu.m_refIdx[0][subPartIdx];
> - break;
> - case 2:
> - refMask |= 1 << (cu.m_refIdx[1][subPartIdx] + 16);
> - break;
> - case 3:
> - refMask |= 1 << cu.m_refIdx[0][subPartIdx];
> - refMask |= 1 << (cu.m_refIdx[1][subPartIdx] + 16);
> - break;
> - }
> - }
> + refMask |= cu.getBestRefIdx(subPartIdx);
> }
>
> /* Copy best data to encData CTU and recon */
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
--
Steve Borho
More information about the x265-devel
mailing list