[x265] [PATCH] wavefront: fix for triggering rows for multiple slices when wpp is enabled
ashok at multicorewareinc.com
ashok at multicorewareinc.com
Thu Sep 21 16:46:47 CEST 2017
# HG changeset patch
# User Ashok Kumar Mishra <ashok at multicorewareinc.com>
# Date 1505220183 -19800
# Tue Sep 12 18:13:03 2017 +0530
# Node ID 71f700844b0b2a9120bfd8a2d1f13e219aa20677
# Parent 1a7edb6fd9932b09c2b5646c7dcc820a51795827
wavefront: fix for triggering rows for multiple slices when wpp is enabled
It is required to trigger alternative rows in slices for encoding when wpp is enabled.
diff -r 1a7edb6fd993 -r 71f700844b0b source/common/wavefront.cpp
--- a/source/common/wavefront.cpp Thu Jun 29 13:13:56 2017 +0530
+++ b/source/common/wavefront.cpp Tue Sep 12 18:13:03 2017 +0530
@@ -43,11 +43,17 @@
if (m_externalDependencyBitmap)
memset((void*)m_externalDependencyBitmap, 0, sizeof(uint32_t) * m_numWords);
+ m_row_to_idx = X265_MALLOC(uint32_t, m_numRows);
+ m_idx_to_row = X265_MALLOC(uint32_t, m_numRows);
+
return m_internalDependencyBitmap && m_externalDependencyBitmap;
}
WaveFront::~WaveFront()
{
+ x265_free((void*)m_row_to_idx);
+ x265_free((void*)m_idx_to_row);
+
x265_free((void*)m_internalDependencyBitmap);
x265_free((void*)m_externalDependencyBitmap);
}
diff -r 1a7edb6fd993 -r 71f700844b0b source/common/wavefront.h
--- a/source/common/wavefront.h Thu Jun 29 13:13:56 2017 +0530
+++ b/source/common/wavefront.h Tue Sep 12 18:13:03 2017 +0530
@@ -52,6 +52,10 @@
int m_numRows;
+protected:
+ uint32_t *m_row_to_idx;
+ uint32_t *m_idx_to_row;
+
public:
WaveFront()
diff -r 1a7edb6fd993 -r 71f700844b0b source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Thu Jun 29 13:13:56 2017 +0530
+++ b/source/encoder/frameencoder.cpp Tue Sep 12 18:13:03 2017 +0530
@@ -701,6 +701,24 @@
{
m_rows[m_sliceBaseRow[sliceId]].active = true;
}
+ if (m_param->bEnableWavefront)
+ {
+ int i = 0;
+ for (uint32_t rowInSlice = 0; rowInSlice < m_sliceGroupSize; rowInSlice++)
+ {
+ for (uint32_t sliceId = 0; sliceId < m_param->maxSlices; sliceId++)
+ {
+ const uint32_t sliceStartRow = m_sliceBaseRow[sliceId];
+ const uint32_t sliceEndRow = m_sliceBaseRow[sliceId + 1] - 1;
+ const uint32_t row = sliceStartRow + rowInSlice;
+ if (row > sliceEndRow)
+ continue;
+ m_row_to_idx[row] = i;
+ m_idx_to_row[i] = row;
+ i += 1;
+ }
+ }
+ }
if (m_param->bEnableWavefront)
{
@@ -735,11 +753,11 @@
}
}
- enableRowEncoder(row); /* clear external dependency for this row */
+ enableRowEncoder(m_row_to_idx[row]); /* clear external dependency for this row */
if (!rowInSlice)
{
m_row0WaitTime = x265_mdate();
- enqueueRowEncoder(row); /* clear internal dependency, start wavefront */
+ enqueueRowEncoder(m_row_to_idx[row]); /* clear internal dependency, start wavefront */
}
tryWakeOne();
} // end of loop rowInSlice
@@ -1196,8 +1214,8 @@
if (ATOMIC_INC(&m_activeWorkerCount) == 1 && m_stallStartTime)
m_totalNoWorkerTime += x265_mdate() - m_stallStartTime;
- const uint32_t realRow = row >> 1;
- const uint32_t typeNum = row & 1;
+ const uint32_t realRow = m_idx_to_row[row >> 1];
+ const uint32_t typeNum = m_idx_to_row[row & 1];
if (!typeNum)
processRowEncoder(realRow, m_tld[threadId]);
@@ -1207,7 +1225,7 @@
// NOTE: Active next row
if (realRow != m_sliceBaseRow[m_rows[realRow].sliceId + 1] - 1)
- enqueueRowFilter(realRow + 1);
+ enqueueRowFilter(m_row_to_idx[realRow + 1]);
}
if (ATOMIC_DEC(&m_activeWorkerCount) == 0)
@@ -1649,7 +1667,7 @@
m_rows[row + 1].completed + 2 <= curRow.completed)
{
m_rows[row + 1].active = true;
- enqueueRowEncoder(row + 1);
+ enqueueRowEncoder(m_row_to_idx[row + 1]);
tryWakeOne(); /* wake up a sleeping thread or set the help wanted flag */
}
}
@@ -1736,11 +1754,11 @@
{
if (rowInSlice >= m_filterRowDelay)
{
- enableRowFilter(row - m_filterRowDelay);
+ enableRowFilter(m_row_to_idx[row - m_filterRowDelay]);
/* NOTE: Activate filter if first row (row 0) */
if (rowInSlice == m_filterRowDelay)
- enqueueRowFilter(row - m_filterRowDelay);
+ enqueueRowFilter(m_row_to_idx[row - m_filterRowDelay]);
tryWakeOne();
}
@@ -1748,7 +1766,7 @@
{
for (uint32_t i = endRowInSlicePlus1 - m_filterRowDelay; i < endRowInSlicePlus1; i++)
{
- enableRowFilter(i);
+ enableRowFilter(m_row_to_idx[i]);
}
tryWakeOne();
}
@@ -1756,7 +1774,7 @@
// handle specially case - single row slice
if (bFirstRowInSlice & bLastRowInSlice)
{
- enqueueRowFilter(row);
+ enqueueRowFilter(m_row_to_idx[row]);
tryWakeOne();
}
}
More information about the x265-devel
mailing list