[x265] refine initializeGeoms()
Satoshi Nakagawa
nakagawa424 at oki.com
Tue Nov 11 11:33:06 CET 2014
# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1415701819 -32400
# Tue Nov 11 19:30:19 2014 +0900
# Node ID 5638df706f0833bd211c73612ba0d4403c813d9e
# Parent 32513a4c3bd435757347e729dc14b5a1c1c6ceef
refine initializeGeoms()
diff -r 32513a4c3bd4 -r 5638df706f08 source/common/cudata.cpp
--- a/source/common/cudata.cpp Mon Nov 10 12:39:54 2014 +0900
+++ b/source/common/cudata.cpp Tue Nov 11 19:30:19 2014 +0900
@@ -2078,7 +2078,7 @@
#define CU_SET_FLAG(bitfield, flag, value) (bitfield) = ((bitfield) & (~(flag))) | ((~((value) - 1)) & (flag))
-void CUData::calcCTUGeoms(uint32_t picWidth, uint32_t picHeight, uint32_t maxCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]) const
+void CUData::calcCTUGeoms(uint32_t ctuWidth, uint32_t ctuHeight, uint32_t maxCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS])
{
// Initialize the coding blocks inside the CTB
for (uint32_t log2CUSize = g_log2Size[maxCUSize], rangeCUIdx = 0; log2CUSize >= MIN_LOG2_CU_SIZE; log2CUSize--)
@@ -2093,10 +2093,10 @@
uint32_t depthIdx = g_depthScanIdx[sbY][sbX];
uint32_t cuIdx = rangeCUIdx + depthIdx;
uint32_t childIdx = rangeCUIdx + sbWidth * sbWidth + (depthIdx << 2);
- uint32_t px = m_cuPelX + sbX * blockSize;
- uint32_t py = m_cuPelY + sbY * blockSize;
- int32_t presentFlag = px < picWidth && py < picHeight;
- int32_t splitMandatoryFlag = presentFlag && !lastLevelFlag && (px + blockSize > picWidth || py + blockSize > picHeight);
+ uint32_t px = sbX * blockSize;
+ uint32_t py = sbY * blockSize;
+ int32_t presentFlag = px < ctuWidth && py < ctuHeight;
+ int32_t splitMandatoryFlag = presentFlag && !lastLevelFlag && (px + blockSize > ctuWidth || py + blockSize > ctuHeight);
/* Offset of the luma CU in the X, Y direction in terms of pixels from the CTU origin */
uint32_t xOffset = (sbX * blockSize) >> 3;
diff -r 32513a4c3bd4 -r 5638df706f08 source/common/cudata.h
--- a/source/common/cudata.h Mon Nov 10 12:39:54 2014 +0900
+++ b/source/common/cudata.h Tue Nov 11 19:30:19 2014 +0900
@@ -158,7 +158,7 @@
CUData();
void initialize(const CUDataMemPool& dataPool, uint32_t depth, int csp, int instance);
- void calcCTUGeoms(uint32_t picWidth, uint32_t picHeight, uint32_t maxCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]) const;
+ static void calcCTUGeoms(uint32_t ctuWidth, uint32_t ctuHeight, uint32_t maxCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]);
void initCTU(const Frame& frame, uint32_t cuAddr, int qp);
void initSubCU(const CUData& ctu, const CUGeom& cuGeom);
diff -r 32513a4c3bd4 -r 5638df706f08 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Mon Nov 10 12:39:54 2014 +0900
+++ b/source/encoder/frameencoder.cpp Tue Nov 11 19:30:19 2014 +0900
@@ -138,11 +138,12 @@
}
/* Generate a complete list of unique geom sets for the current picture dimensions */
-bool FrameEncoder::initializeGeoms(const FrameData& encData)
+bool FrameEncoder::initializeGeoms()
{
/* Geoms only vary between CTUs in the presence of picture edges */
- int heightRem = m_param->sourceHeight & (m_param->maxCUSize - 1);
- int widthRem = m_param->sourceWidth & (m_param->maxCUSize - 1);
+ int maxCUSize = m_param->maxCUSize;
+ int heightRem = m_param->sourceHeight & (maxCUSize - 1);
+ int widthRem = m_param->sourceWidth & (maxCUSize - 1);
int allocGeoms = 1; // body
if (heightRem && widthRem)
allocGeoms = 4; // body, right, bottom, corner
@@ -154,33 +155,45 @@
if (!m_cuGeoms || !m_ctuGeomMap)
return false;
- CUGeom cuLocalData[CUGeom::MAX_GEOMS];
- memset(cuLocalData, 0, sizeof(cuLocalData)); // temporal fix for memcmp
+ // body
+ CUData::calcCTUGeoms(maxCUSize, maxCUSize, maxCUSize, m_cuGeoms);
+ memset(m_ctuGeomMap, 0, sizeof(uint32_t) * m_numRows * m_numCols);
+ if (allocGeoms == 1)
+ return true;
- int countGeoms = 0;
- for (uint32_t ctuAddr = 0; ctuAddr < m_numRows * m_numCols; ctuAddr++)
+ int countGeoms = 1;
+ if (widthRem)
{
- /* TODO: detach this logic from TComDataCU */
- encData.m_picCTU[ctuAddr].initCTU(*m_frame, ctuAddr, 0);
- encData.m_picCTU[ctuAddr].calcCTUGeoms(m_param->sourceWidth, m_param->sourceHeight, m_param->maxCUSize, cuLocalData);
+ // right
+ CUData::calcCTUGeoms(widthRem, maxCUSize, maxCUSize, m_cuGeoms + countGeoms * CUGeom::MAX_GEOMS);
+ for (int i = 0; i < m_numRows; i++)
+ {
+ uint32_t ctuAddr = m_numCols * (i + 1) - 1;
+ m_ctuGeomMap[ctuAddr] = countGeoms * CUGeom::MAX_GEOMS;
+ }
+ countGeoms++;
+ }
+ if (heightRem)
+ {
+ // bottom
+ CUData::calcCTUGeoms(maxCUSize, heightRem, maxCUSize, m_cuGeoms + countGeoms * CUGeom::MAX_GEOMS);
+ for (uint32_t i = 0; i < m_numCols; i++)
+ {
+ uint32_t ctuAddr = m_numCols * (m_numRows - 1) + i;
+ m_ctuGeomMap[ctuAddr] = countGeoms * CUGeom::MAX_GEOMS;
+ }
+ countGeoms++;
- m_ctuGeomMap[ctuAddr] = MAX_INT;
- for (int i = 0; i < countGeoms; i++)
+ if (widthRem)
{
- if (!memcmp(cuLocalData, m_cuGeoms + i * CUGeom::MAX_GEOMS, sizeof(CUGeom) * CUGeom::MAX_GEOMS))
- {
- m_ctuGeomMap[ctuAddr] = i * CUGeom::MAX_GEOMS;
- break;
- }
- }
+ // corner
+ CUData::calcCTUGeoms(widthRem, heightRem, maxCUSize, m_cuGeoms + countGeoms * CUGeom::MAX_GEOMS);
- if (m_ctuGeomMap[ctuAddr] == MAX_INT)
- {
- X265_CHECK(countGeoms < allocGeoms, "geometry match check failure\n");
+ uint32_t ctuAddr = m_numCols * m_numRows - 1;
m_ctuGeomMap[ctuAddr] = countGeoms * CUGeom::MAX_GEOMS;
- memcpy(m_cuGeoms + countGeoms * CUGeom::MAX_GEOMS, cuLocalData, sizeof(CUGeom) * CUGeom::MAX_GEOMS);
countGeoms++;
}
+ X265_CHECK(countGeoms == allocGeoms, "geometry match check failure\n");
}
return true;
@@ -193,7 +206,7 @@
curFrame->m_encData->m_slice->m_mref = m_mref;
if (!m_cuGeoms)
{
- if (!initializeGeoms(*curFrame->m_encData))
+ if (!initializeGeoms())
return false;
}
m_enable.trigger();
diff -r 32513a4c3bd4 -r 5638df706f08 source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h Mon Nov 10 12:39:54 2014 +0900
+++ b/source/encoder/frameencoder.h Tue Nov 11 19:30:19 2014 +0900
@@ -185,7 +185,7 @@
protected:
- bool initializeGeoms(const FrameData& encData);
+ bool initializeGeoms();
/* analyze / compress frame, can be run in parallel within reference constraints */
void compressFrame();
More information about the x265-devel
mailing list