[x265] [PATCH 1 of 2] remove static member from class ParallelFilter
Min Chen
chenm003 at 163.com
Thu Jan 7 00:24:06 CET 2016
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1452121207 21600
# Node ID 375c1f0cfd8a69e4a118cf4e4094f871c0c3a216
# Parent 2417df96af4efcaa8c16e7138028d8b2bbb034ab
remove static member from class ParallelFilter
---
source/encoder/framefilter.cpp | 93 +++++++++++++++++++---------------------
source/encoder/framefilter.h | 22 ++++++----
2 files changed, 57 insertions(+), 58 deletions(-)
diff -r 2417df96af4e -r 375c1f0cfd8a source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp Wed Jan 06 10:02:13 2016 -0600
+++ b/source/encoder/framefilter.cpp Wed Jan 06 17:00:07 2016 -0600
@@ -35,11 +35,6 @@
static uint64_t computeSSD(pixel *fenc, pixel *rec, intptr_t stride, uint32_t width, uint32_t height);
static float calculateSSIM(pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2, uint32_t width, uint32_t height, void *buf, uint32_t& cnt);
-uint32_t FrameFilter::ParallelFilter::numCols = 0;
-uint32_t FrameFilter::ParallelFilter::numRows = 0;
-uint32_t FrameFilter::ParallelFilter::lastHeight = 0;
-uint32_t FrameFilter::ParallelFilter::lastWidth = 0;
-
void FrameFilter::destroy()
{
X265_FREE(m_ssimBuf);
@@ -94,6 +89,11 @@
for(int row = 0; row < numRows; row++)
{
+ // Setting maximum bound information
+ m_parallelFilter[row].m_numCols = numCols;
+ m_parallelFilter[row].m_numRows = numRows;
+ m_parallelFilter[row].m_lastHeight = m_lastHeight;
+ m_parallelFilter[row].m_lastWidth = (m_param->sourceWidth % g_maxCUSize) ? (m_param->sourceWidth % g_maxCUSize) : g_maxCUSize;
m_parallelFilter[row].m_param = m_param;
m_parallelFilter[row].m_row = row;
m_parallelFilter[row].m_rowAddr = row * numCols;
@@ -104,11 +104,6 @@
}
}
- // Setting maximum columns
- ParallelFilter::numCols = numCols;
- ParallelFilter::numRows = numRows;
- ParallelFilter::lastHeight = m_lastHeight;
- ParallelFilter::lastWidth = (m_param->sourceWidth % g_maxCUSize) ? (m_param->sourceWidth % g_maxCUSize) : g_maxCUSize;
}
void FrameFilter::start(Frame *frame, Entropy& initState, int qp)
@@ -235,7 +230,7 @@
m_frame->m_reconColCount[m_row].set(col);
// shortcut path for non-border area
- if ((col != 0) & (col != numCols - 1) & (m_row != 0) & (m_row != numRows - 1))
+ if ((col != 0) & (col != m_numCols - 1) & (m_row != 0) & (m_row != m_numRows - 1))
return;
PicYuv *reconPic = m_frame->m_reconPic;
@@ -258,7 +253,7 @@
int copySizeY = realW;
int copySizeC = (realW >> hChromaShift);
- if ((col == 0) | (col == numCols - 1))
+ if ((col == 0) | (col == m_numCols - 1))
{
// TODO: improve by process on Left or Right only
primitives.extendRowBorder(reconPic->getLumaAddr(m_rowAddr), stride, reconPic->m_picWidth, realH, reconPic->m_lumaMarginX);
@@ -271,7 +266,7 @@
}
// Extra Left and Right border on first and last CU
- if ((col == 0) | (col == numCols - 1))
+ if ((col == 0) | (col == m_numCols - 1))
{
copySizeY += lumaMarginX;
copySizeC += chromaMarginX;
@@ -302,7 +297,7 @@
}
// Border extend Bottom
- if (m_row == numRows - 1)
+ if (m_row == m_numRows - 1)
{
pixY += (realH - 1) * stride;
pixU += ((realH >> vChromaShift) - 1) * strideC;
@@ -386,9 +381,9 @@
m_lastCol.incr();
}
- if (colEnd == (int)numCols)
+ if (colEnd == (int)m_numCols)
{
- const uint32_t cuAddr = m_rowAddr + numCols - 1;
+ const uint32_t cuAddr = m_rowAddr + m_numCols - 1;
if (m_param->bEnableLoopFilter)
{
@@ -397,47 +392,47 @@
// When SAO Disable, setting column counter here
if ((!m_param->bEnableSAO) & (m_row >= 1))
- m_prevRow->processPostCu(numCols - 1);
+ m_prevRow->processPostCu(m_numCols - 1);
}
// TODO: move processPostCu() into processSaoUnitCu()
if (m_param->bEnableSAO)
{
// Save SAO bottom row reference pixels
- copySaoAboveRef(reconPic, cuAddr, numCols - 1);
+ copySaoAboveRef(reconPic, cuAddr, m_numCols - 1);
// SAO Decide
// NOTE: reduce condition check for 1 CU only video, Why someone play with it?
- if (numCols >= 2)
- m_sao.rdoSaoUnitCu(saoParam, m_rowAddr, numCols - 2, cuAddr - 1);
+ if (m_numCols >= 2)
+ m_sao.rdoSaoUnitCu(saoParam, m_rowAddr, m_numCols - 2, cuAddr - 1);
- if (numCols >= 1)
- m_sao.rdoSaoUnitCu(saoParam, m_rowAddr, numCols - 1, cuAddr);
+ if (m_numCols >= 1)
+ m_sao.rdoSaoUnitCu(saoParam, m_rowAddr, m_numCols - 1, cuAddr);
// Process Previous Rows SAO CU
- if (m_row >= 1 && numCols >= 3)
+ if (m_row >= 1 && m_numCols >= 3)
{
- m_prevRow->processSaoUnitCu(saoParam, numCols - 3);
- m_prevRow->processPostCu(numCols - 3);
+ m_prevRow->processSaoUnitCu(saoParam, m_numCols - 3);
+ m_prevRow->processPostCu(m_numCols - 3);
}
- if (m_row >= 1 && numCols >= 2)
+ if (m_row >= 1 && m_numCols >= 2)
{
- m_prevRow->processSaoUnitCu(saoParam, numCols - 2);
- m_prevRow->processPostCu(numCols - 2);
+ m_prevRow->processSaoUnitCu(saoParam, m_numCols - 2);
+ m_prevRow->processPostCu(m_numCols - 2);
}
- if (m_row >= 1 && numCols >= 1)
+ if (m_row >= 1 && m_numCols >= 1)
{
- m_prevRow->processSaoUnitCu(saoParam, numCols - 1);
- m_prevRow->processPostCu(numCols - 1);
+ m_prevRow->processSaoUnitCu(saoParam, m_numCols - 1);
+ m_prevRow->processPostCu(m_numCols - 1);
}
// Setting column sync counter
if (m_row >= 1)
- m_frame->m_reconColCount[m_row - 1].set(numCols - 1);
+ m_frame->m_reconColCount[m_row - 1].set(m_numCols - 1);
}
- m_lastDeblocked.set(numCols);
+ m_lastDeblocked.set(m_numCols);
}
}
@@ -466,21 +461,21 @@
m_parallelFilter[row].waitForExit();
/* Check to avoid previous row process slower than current row */
- X265_CHECK((row < 1) || m_parallelFilter[row - 1].m_lastDeblocked.get() == (int)ParallelFilter::numCols, "previous row not finish");
+ X265_CHECK((row < 1) || m_parallelFilter[row - 1].m_lastDeblocked.get() == (int)m_parallelFilter[row - 1].m_numCols, "previous row not finish");
- m_parallelFilter[row].m_allowedCol.set(ParallelFilter::numCols);
+ m_parallelFilter[row].m_allowedCol.set(m_parallelFilter[row].m_numCols);
m_parallelFilter[row].processTasks(-1);
if (row == m_numRows - 1)
{
/* TODO: Early start last row */
- if ((row >= 1) && (m_parallelFilter[row - 1].m_lastDeblocked.get() != (int)ParallelFilter::numCols))
+ if ((row >= 1) && (m_parallelFilter[row - 1].m_lastDeblocked.get() != (int)m_parallelFilter[row - 1].m_numCols))
x265_log(m_param, X265_LOG_WARNING, "detected ParallelFilter race condition on last row\n");
/* Apply SAO on last row of CUs, because we always apply SAO on row[X-1] */
if (m_param->bEnableSAO)
{
- for(uint32_t col = 0; col < ParallelFilter::numCols; col++)
+ for(uint32_t col = 0; col < m_parallelFilter[row].m_numCols; col++)
{
// NOTE: must use processSaoUnitCu(), it include TQBypass logic
m_parallelFilter[row].processSaoUnitCu(saoParam, col);
@@ -488,7 +483,7 @@
}
// Process border extension on last row
- for(uint32_t col = 0; col < ParallelFilter::numCols; col++)
+ for(uint32_t col = 0; col < m_parallelFilter[row].m_numCols; col++)
{
// m_reconColCount will be set in processPostCu()
m_parallelFilter[row].processPostCu(col);
@@ -525,14 +520,14 @@
m_frame->m_reconColCount[row].set(col);
// shortcut path for non-border area
- if ((col != 0) & (col != FrameFilter::ParallelFilter::numCols - 1) & (row != 0) & (row != FrameFilter::ParallelFilter::numRows - 1))
+ if ((col != 0) & (col != m_parallelFilter[row].m_numCols - 1) & (row != 0) & (row != m_parallelFilter[row].m_numRows - 1))
return;
PicYuv *reconPic = m_frame->m_reconPic;
- const uint32_t rowAddr = row * FrameFilter::ParallelFilter::numCols;
+ const uint32_t rowAddr = row * m_parallelFilter[row].m_numCols;
const uint32_t lineStartCUAddr = rowAddr + col;
- const int realH = FrameFilter::ParallelFilter::getCUHeight(row);
- const int realW = FrameFilter::ParallelFilter::getCUWidth(col);
+ const int realH = m_parallelFilter[row].getCUHeight(row);
+ const int realW = m_parallelFilter[row].getCUWidth(col);
const uint32_t lumaMarginX = reconPic->m_lumaMarginX;
const uint32_t lumaMarginY = reconPic->m_lumaMarginY;
@@ -549,7 +544,7 @@
int copySizeY = realW;
int copySizeC = (realW >> hChromaShift);
- if ((col == 0) | (col == FrameFilter::ParallelFilter::numCols - 1))
+ if ((col == 0) | (col == m_parallelFilter[row].m_numCols - 1))
{
// TODO: improve by process on Left or Right only
primitives.extendRowBorder(reconPic->getLumaAddr(rowAddr), stride, reconPic->m_picWidth, realH, reconPic->m_lumaMarginX);
@@ -562,7 +557,7 @@
}
// Extra Left and Right border on first and last CU
- if ((col == 0) | (col == FrameFilter::ParallelFilter::numCols - 1))
+ if ((col == 0) | (col == m_parallelFilter[row].m_numCols - 1))
{
copySizeY += lumaMarginX;
copySizeC += chromaMarginX;
@@ -593,7 +588,7 @@
}
// Border extend Bottom
- if (row == FrameFilter::ParallelFilter::numRows - 1)
+ if (row == m_parallelFilter[row].m_numRows - 1)
{
pixY += (realH - 1) * stride;
for (uint32_t y = 0; y < lumaMarginY; y++)
@@ -629,7 +624,7 @@
intptr_t stride = reconPic->m_stride;
uint32_t width = reconPic->m_picWidth - m_pad[0];
- uint32_t height = FrameFilter::ParallelFilter::getCUHeight(row);
+ uint32_t height = m_parallelFilter[row].getCUHeight(row);
uint64_t ssdY = computeSSD(fencPic->getLumaAddr(cuAddr), reconPic->getLumaAddr(cuAddr), stride, width, height);
m_frameEncoder->m_SSDY += ssdY;
@@ -669,7 +664,7 @@
}
if (m_param->decodedPictureHashSEI == 1)
{
- uint32_t height = FrameFilter::ParallelFilter::getCUHeight(row);
+ uint32_t height = m_parallelFilter[row].getCUHeight(row);
uint32_t width = reconPic->m_picWidth;
intptr_t stride = reconPic->m_stride;
@@ -695,7 +690,7 @@
}
else if (m_param->decodedPictureHashSEI == 2)
{
- uint32_t height = FrameFilter::ParallelFilter::getCUHeight(row);
+ uint32_t height = m_parallelFilter[row].getCUHeight(row);
uint32_t width = reconPic->m_picWidth;
intptr_t stride = reconPic->m_stride;
@@ -717,7 +712,7 @@
else if (m_param->decodedPictureHashSEI == 3)
{
uint32_t width = reconPic->m_picWidth;
- uint32_t height = FrameFilter::ParallelFilter::getCUHeight(row);
+ uint32_t height = m_parallelFilter[row].getCUHeight(row);
intptr_t stride = reconPic->m_stride;
uint32_t cuHeight = g_maxCUSize;
diff -r 2417df96af4e -r 375c1f0cfd8a source/encoder/framefilter.h
--- a/source/encoder/framefilter.h Wed Jan 06 10:02:13 2016 -0600
+++ b/source/encoder/framefilter.h Wed Jan 06 17:00:07 2016 -0600
@@ -61,10 +61,10 @@
class ParallelFilter : public BondedTaskGroup, public Deblock
{
public:
- static uint32_t numCols;
- static uint32_t numRows;
- static uint32_t lastHeight;
- static uint32_t lastWidth;
+ uint32_t m_numCols;
+ uint32_t m_numRows;
+ uint32_t m_lastHeight;
+ uint32_t m_lastWidth;
uint32_t m_row;
uint32_t m_rowAddr;
x265_param* m_param;
@@ -78,7 +78,11 @@
ThreadSafeInteger m_lastDeblocked; /* The column that finished all of Deblock stages */
ParallelFilter()
- : m_row(0)
+ : m_numCols(0)
+ , m_numRows(0)
+ , m_lastHeight(0)
+ , m_lastWidth(0)
+ , m_row(0)
, m_rowAddr(0)
, m_param(NULL)
, m_frame(NULL)
@@ -102,14 +106,14 @@
// Post-Process (Border extension)
void processPostCu(uint32_t col) const;
- static uint32_t getCUHeight(int rowNum)
+ uint32_t getCUHeight(int rowNum) const
{
- return (rowNum == (int)numRows - 1) ? lastHeight : g_maxCUSize;
+ return (rowNum == (int)m_numRows - 1) ? m_lastHeight : g_maxCUSize;
}
- static uint32_t getCUWidth(int colNum)
+ uint32_t getCUWidth(int colNum) const
{
- return (colNum == (int)numCols - 1) ? lastWidth : g_maxCUSize;
+ return (colNum == (int)m_numCols - 1) ? m_lastWidth : g_maxCUSize;
}
protected:
More information about the x265-devel
mailing list