[x265] [PATCH 3 of 5] Infer if currentPOC CTUInfo has changed with respect to its references
vignesh at multicorewareinc.com
vignesh at multicorewareinc.com
Tue May 9 10:44:14 CEST 2017
# HG changeset patch
# User Vignesh Vijayakumar
# Date 1491894620 -19800
# Tue Apr 11 12:40:20 2017 +0530
# Node ID 7fd517f9bbe78a0eba180a42d97bef1970af294a
# Parent cf414fc0a459dea19015ca07d130e1234890541a
Infer if currentPOC CTUInfo has changed with respect to its references
diff -r cf414fc0a459 -r 7fd517f9bbe7 source/common/frame.cpp
--- a/source/common/frame.cpp Tue Apr 11 10:48:18 2017 +0530
+++ b/source/common/frame.cpp Tue Apr 11 12:40:20 2017 +0530
@@ -52,6 +52,7 @@
m_prevCtuInfoChange = NULL;
m_addOnDepth = NULL;
m_addOnCtuInfo = NULL;
+ m_addOnPrevChange = NULL;
}
bool Frame::create(x265_param *param, float* quantOffsets)
@@ -67,10 +68,12 @@
uint32_t numCTUsInFrame = widthInCTU * heightInCTU;
CHECKED_MALLOC_ZERO(m_addOnDepth, uint8_t *, numCTUsInFrame);
CHECKED_MALLOC_ZERO(m_addOnCtuInfo, uint8_t *, numCTUsInFrame);
+ CHECKED_MALLOC_ZERO(m_addOnPrevChange, int *, numCTUsInFrame);
for (uint32_t i = 0; i < numCTUsInFrame; i++)
{
CHECKED_MALLOC_ZERO(m_addOnDepth[i], uint8_t, uint32_t(NUM_4x4_PARTITIONS));
CHECKED_MALLOC_ZERO(m_addOnCtuInfo[i], uint8_t, uint32_t(NUM_4x4_PARTITIONS));
+ CHECKED_MALLOC_ZERO(m_addOnPrevChange[i], int, uint32_t(NUM_4x4_PARTITIONS));
}
}
@@ -197,6 +200,8 @@
m_addOnDepth[i] = NULL;
X265_FREE(m_addOnCtuInfo[i]);
m_addOnCtuInfo[i] = NULL;
+ X265_FREE(m_addOnPrevChange[i]);
+ m_addOnPrevChange[i] = NULL;
}
X265_FREE(*m_ctuInfo);
*m_ctuInfo = NULL;
@@ -208,7 +213,8 @@
m_addOnDepth = NULL;
X265_FREE(m_addOnCtuInfo);
m_addOnCtuInfo = NULL;
-
+ X265_FREE(m_addOnPrevChange);
+ m_addOnPrevChange = NULL;
}
m_lowres.destroy();
X265_FREE(m_rcData);
diff -r cf414fc0a459 -r 7fd517f9bbe7 source/common/frame.h
--- a/source/common/frame.h Tue Apr 11 10:48:18 2017 +0530
+++ b/source/common/frame.h Tue Apr 11 12:40:20 2017 +0530
@@ -115,6 +115,7 @@
uint8_t** m_addOnDepth;
uint8_t** m_addOnCtuInfo;
+ int** m_addOnPrevChange;
Frame();
bool create(x265_param *param, float* quantOffsets);
diff -r cf414fc0a459 -r 7fd517f9bbe7 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp Tue Apr 11 10:48:18 2017 +0530
+++ b/source/encoder/analysis.cpp Tue Apr 11 12:40:20 2017 +0530
@@ -156,20 +156,28 @@
if (ctuTemp->ctuPartitions)
{
int32_t depthIdx = 0;
+ uint32_t maxNum8x8Partitions = 64;
uint8_t* depthInfoPtr = m_frame->m_addOnDepth[ctu.m_cuAddr];
uint8_t* contentInfoPtr = m_frame->m_addOnCtuInfo[ctu.m_cuAddr];
+ int* prevCtuInfoChangePtr = m_frame->m_addOnPrevChange[ctu.m_cuAddr];
do
{
uint8_t depth = (uint8_t)ctuTemp->ctuPartitions[depthIdx];
uint8_t content = (uint8_t)(*((int32_t *)ctuTemp->ctuInfo + depthIdx));
+ int prevCtuInfoChange = m_frame->m_prevCtuInfoChange[ctu.m_cuAddr * maxNum8x8Partitions + depthIdx];
memset(depthInfoPtr, depth, sizeof(uint8_t) * numPartition >> 2 * depth);
memset(contentInfoPtr, content, sizeof(uint8_t) * numPartition >> 2 * depth);
+ memset(prevCtuInfoChangePtr, 0, sizeof(int) * numPartition >> 2 * depth);
+ for (uint32_t l = 0; l < numPartition >> 2 * depth; l++)
+ prevCtuInfoChangePtr[l] = prevCtuInfoChange;
depthInfoPtr += ctu.m_numPartitions >> 2 * depth;
contentInfoPtr += ctu.m_numPartitions >> 2 * depth;
+ prevCtuInfoChangePtr += ctu.m_numPartitions >> 2 * depth;
depthIdx++;
} while (ctuTemp->ctuPartitions[depthIdx] != 0);
m_additionalCtuInfo = m_frame->m_addOnCtuInfo[ctu.m_cuAddr];
+ m_prevCtuInfoChange = m_frame->m_addOnPrevChange[ctu.m_cuAddr];
memcpy(ctu.m_cuDepth, m_frame->m_addOnDepth[ctu.m_cuAddr], sizeof(uint8_t) * numPartition);
//Calculate log2CUSize from depth
for (uint32_t i = 0; i < cuGeom.numPartitions; i++)
@@ -1051,6 +1059,7 @@
bool skipRectAmp = false;
bool chooseMerge = false;
bool bCtuInfoCheck = false;
+ int sameContentRef = 0;
if ((m_limitTU & X265_TU_LIMIT_NEIGH) && cuGeom.log2CUSize >= 4)
m_maxTUDepth = loadTUDepth(cuGeom, parentCTU);
@@ -1071,6 +1080,8 @@
if (m_param->bCTUInfo && depth <= parentCTU.m_cuDepth[cuGeom.absPartIdx])
{
+ if (bDecidedDepth && m_additionalCtuInfo[cuGeom.absPartIdx])
+ sameContentRef = findSameContentRefCount(parentCTU, cuGeom);
if (depth < parentCTU.m_cuDepth[cuGeom.absPartIdx])
{
mightNotSplit &= bDecidedDepth;
@@ -1639,6 +1650,7 @@
bool splitIntra = true;
bool skipRectAmp = false;
bool bCtuInfoCheck = false;
+ int sameContentRef = 0;
// avoid uninitialize value in below reference
if (m_param->limitModes)
@@ -1660,6 +1672,8 @@
uint32_t refMasks[2];
if (m_param->bCTUInfo && depth <= parentCTU.m_cuDepth[cuGeom.absPartIdx])
{
+ if (bDecidedDepth && m_additionalCtuInfo[cuGeom.absPartIdx])
+ sameContentRef = findSameContentRefCount(parentCTU, cuGeom);
if (depth < parentCTU.m_cuDepth[cuGeom.absPartIdx])
{
mightNotSplit &= bDecidedDepth;
@@ -3138,3 +3152,22 @@
normFactor(srcV, blockSizeC, ctu, qp, TEXT_CHROMA_V);
}
}
+
+int Analysis::findSameContentRefCount(const CUData& parentCTU, const CUGeom& cuGeom)
+{
+ int sameContentRef = 0;
+ int m_curPoc = parentCTU.m_slice->m_poc;
+ int prevChange = m_prevCtuInfoChange[cuGeom.absPartIdx];
+ int numPredDir = m_slice->isInterP() ? 1 : 2;
+ for (int list = 0; list < numPredDir; list++)
+ {
+ for (int i = 0; i < m_frame->m_encData->m_slice->m_numRefIdx[list]; i++)
+ {
+ int refPoc = m_frame->m_encData->m_slice->m_refFrameList[list][i]->m_poc;
+ int refPrevChange = m_frame->m_encData->m_slice->m_refFrameList[list][i]->m_addOnPrevChange[parentCTU.m_cuAddr][cuGeom.absPartIdx];
+ if ((refPoc < prevChange && refPoc < m_curPoc) || (refPoc > m_curPoc && prevChange < m_curPoc && refPrevChange > m_curPoc) || ((refPoc == prevChange) && (m_additionalCtuInfo[cuGeom.absPartIdx] == CTU_INFO_CHANGE)))
+ sameContentRef++; /* Content changed */
+ }
+ }
+ return sameContentRef;
+}
diff -r cf414fc0a459 -r 7fd517f9bbe7 source/encoder/analysis.h
--- a/source/encoder/analysis.h Tue Apr 11 10:48:18 2017 +0530
+++ b/source/encoder/analysis.h Tue Apr 11 12:40:20 2017 +0530
@@ -139,6 +139,7 @@
uint8_t* m_multipassModes;
uint8_t* m_additionalCtuInfo;
+ int* m_prevCtuInfoChange;
/* refine RD based on QP for rd-levels 5 and 6 */
void qprdRefine(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp, int32_t lqp);
@@ -192,6 +193,7 @@
else
md.bestMode = &mode;
}
+ int findSameContentRefCount(const CUData& parentCTU, const CUGeom& cuGeom);
};
struct ThreadLocalData
More information about the x265-devel
mailing list