[x265] [PATCH] analysis: removed switch-case to read the best ref index
ashok at multicorewareinc.com
ashok at multicorewareinc.com
Tue Jun 23 17:18:02 CEST 2015
# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1435071928 -19800
# Tue Jun 23 20:35:28 2015 +0530
# Node ID b697c904e641b22aebf936cf97add00892b659e7
# Parent 235ddb72f49db458f4250e02723b54e823baa669
analysis: removed switch-case to read the best ref index
diff -r 235ddb72f49d -r b697c904e641 source/common/cudata.h
--- a/source/common/cudata.h Tue Jun 23 20:35:24 2015 +0530
+++ b/source/common/cudata.h Tue Jun 23 20:35:28 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 235ddb72f49d -r b697c904e641 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp Tue Jun 23 20:35:24 2015 +0530
+++ b/source/encoder/analysis.cpp Tue Jun 23 20:35:28 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)
@@ -1257,20 +1229,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;
}
@@ -1403,22 +1362,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 */
More information about the x265-devel
mailing list