<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 24, 2014 at 5:36 AM, Min Chen <span dir="ltr"><<a href="mailto:chenm003@163.com" target="_blank">chenm003@163.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># HG changeset patch<br>
# User Min Chen <<a href="mailto:chenm003@163.com">chenm003@163.com</a>><br>
# Date 1403568362 25200<br>
# Node ID efa48bc0245bded1418db3c42b042acb9969146c<br>
# Parent 12c1d8aaa8f56a8f2de74c8ff1451d99d04c817d<br>
pass TLD into class FrameFilter<br>
<br>
diff -r 12c1d8aaa8f5 -r efa48bc0245b source/encoder/cturow.h<br>
--- a/source/encoder/cturow.h Mon Jun 23 17:03:49 2014 -0700<br>
+++ b/source/encoder/cturow.h Mon Jun 23 17:06:02 2014 -0700<br>
@@ -47,6 +47,10 @@<br>
RDCost m_rdCost;<br>
TComTrQuant m_trQuant;<br>
<br>
+ // NOTE: the maximum LCU 64x64 have 256 partitions<br>
+ bool m_edgeFilter[256];<br>
+ uint8_t m_blockingStrength[256];<br>
+<br>
void init(Encoder&);<br>
~ThreadLocalData();<br>
};<br>
diff -r 12c1d8aaa8f5 -r efa48bc0245b source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Mon Jun 23 17:03:49 2014 -0700<br>
+++ b/source/encoder/encoder.cpp Mon Jun 23 17:06:02 2014 -0700<br>
@@ -42,6 +42,7 @@<br>
#include "x265.h"<br>
<br>
using namespace x265;<br>
+ThreadLocalData* Encoder::m_threadLocalData;<br>
<br>
Encoder::Encoder()<br>
{<br>
@@ -194,9 +195,10 @@<br>
if (m_frameEncoder)<br>
{<br>
int numRows = (m_param->sourceHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
+ int numCols = (m_param->sourceWidth + g_maxCUSize - 1) / g_maxCUSize;<br>
for (int i = 0; i < m_param->frameNumThreads; i++)<br>
{<br>
- if (!m_frameEncoder[i].init(this, numRows))<br>
+ if (!m_frameEncoder[i].init(this, numRows, numCols))<br>
{<br>
x265_log(m_param, X265_LOG_ERROR, "Unable to initialize frame encoder, aborting\n");<br>
m_aborted = true;<br>
diff -r 12c1d8aaa8f5 -r efa48bc0245b source/encoder/encoder.h<br>
--- a/source/encoder/encoder.h Mon Jun 23 17:03:49 2014 -0700<br>
+++ b/source/encoder/encoder.h Mon Jun 23 17:06:02 2014 -0700<br>
@@ -175,7 +175,7 @@<br>
<br>
x265_param* m_param;<br>
RateControl* m_rateControl;<br>
- ThreadLocalData* m_threadLocalData;<br>
+ static ThreadLocalData* m_threadLocalData;<br>
<br>
bool m_bEnableRDOQ;<br>
<br>
diff -r 12c1d8aaa8f5 -r efa48bc0245b source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp Mon Jun 23 17:03:49 2014 -0700<br>
+++ b/source/encoder/frameencoder.cpp Mon Jun 23 17:06:02 2014 -0700<br>
@@ -80,15 +80,17 @@<br>
stop();<br>
}<br>
<br>
-bool FrameEncoder::init(Encoder *top, int numRows)<br>
+bool FrameEncoder::init(Encoder *top, int numRows, int numCols)<br>
{<br>
bool ok = true;<br>
<br>
m_top = top;<br>
m_param = top->m_param;<br>
m_numRows = numRows;<br>
+ m_numCols = numCols;<br>
m_filterRowDelay = (m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary) ?<br>
2 : (m_param->bEnableSAO || m_param->bEnableLoopFilter ? 1 : 0);<br>
+ m_filterRowDelayCus = m_filterRowDelay * numCols;<br>
<br>
m_rows = new CTURow[m_numRows];<br>
for (int i = 0; i < m_numRows; ++i)<br>
@@ -505,7 +507,7 @@<br>
// Extend border after whole-frame SAO is finished<br>
for (int row = 0; row < m_numRows; row++)<br>
{<br>
- m_frameFilter.processRowPost(row);<br>
+ m_frameFilter.processRowPost(row, 0);<br>
}<br>
}<br>
<br>
@@ -845,7 +847,7 @@<br>
}<br>
<br>
// setup thread-local data<br>
- ThreadLocalData& tld = threadId >= 0 ? m_top->m_threadLocalData[threadId] : m_tld;<br>
+ ThreadLocalData& tld = threadId >= 0 ? Encoder::m_threadLocalData[threadId] : m_tld;<br>
tld.m_trQuant.m_nr = &m_nr;<br>
tld.m_search.m_mref = m_mref;<br>
codeRow.setThreadLocalData(tld);<br>
@@ -856,7 +858,8 @@<br>
tld.m_cuCoder.m_log = &tld.m_cuCoder.m_sliceTypeLog[m_frame->getSlice()->getSliceType()];<br>
<br>
int64_t startTime = x265_mdate();<br>
- const uint32_t numCols = m_frame->getPicSym()->getFrameWidthInCU();<br>
+ assert(m_frame->getPicSym()->getFrameWidthInCU() == m_numCols);<br>
+ const uint32_t numCols = m_numCols;<br>
const uint32_t lineStartCUAddr = row * numCols;<br>
bool bIsVbv = m_param->rc.vbvBufferSize > 0 && m_param->rc.vbvMaxBitrate > 0;<br>
<br>
diff -r 12c1d8aaa8f5 -r efa48bc0245b source/encoder/frameencoder.h<br>
--- a/source/encoder/frameencoder.h Mon Jun 23 17:03:49 2014 -0700<br>
+++ b/source/encoder/frameencoder.h Mon Jun 23 17:06:02 2014 -0700<br>
@@ -65,15 +65,15 @@<br>
<br>
void setThreadPool(ThreadPool *p);<br>
<br>
- bool init(Encoder *top, int numRows);<br>
+ bool init(Encoder *top, int numRows, int numCols);<br>
<br>
void destroy();<br>
<br>
void processRowEncoder(int row, const int threadId);<br>
<br>
- void processRowFilter(int row)<br>
+ void processRowFilter(int row, const int threadId)<br>
{<br>
- m_frameFilter.processRow(row);<br>
+ m_frameFilter.processRow(row, threadId);<br>
}<br>
<br>
void enqueueRowEncoder(int row)<br>
@@ -108,7 +108,7 @@<br>
}<br>
else<br>
{<br>
- processRowFilter(realRow);<br>
+ processRowFilter(realRow, threadId);<br>
<br>
// NOTE: Active next row<br>
if (realRow != m_numRows - 1)<br>
@@ -154,6 +154,7 @@<br>
bool m_threadActive;<br>
<br>
int m_numRows;<br>
+ uint32_t m_numCols;<br>
CTURow* m_rows;<br>
TComSPS m_sps;<br>
TComPPS m_pps;<br>
@@ -195,6 +196,7 @@<br>
Frame* m_frame;<br>
<br>
int m_filterRowDelay;<br>
+ int m_filterRowDelayCus;<br>
Event m_completionEvent;<br>
int64_t m_totalTime;<br>
bool m_isReferenced;<br>
diff -r 12c1d8aaa8f5 -r efa48bc0245b source/encoder/framefilter.cpp<br>
--- a/source/encoder/framefilter.cpp Mon Jun 23 17:03:49 2014 -0700<br>
+++ b/source/encoder/framefilter.cpp Mon Jun 23 17:06:02 2014 -0700<br>
@@ -121,13 +121,15 @@<br>
}<br>
}<br>
<br>
-void FrameFilter::processRow(int row)<br>
+void FrameFilter::processRow(int row, const int threadId)<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
{<br>
PPAScopeEvent(Thread_filterCU);<br>
+ assert(threadId >= 0);<br>
+ ThreadLocalData& tld = Encoder::m_threadLocalData[threadId];<br>
<br>
if (!m_param->bEnableLoopFilter && !m_param->bEnableSAO)<br>
{<br>
- processRowPost(row);<br>
+ processRowPost(row, threadId);<br>
return;<br>
}<br>
<br>
@@ -146,26 +148,23 @@<br>
<br>
if (m_param->bEnableLoopFilter)<br>
{<br>
- bool edgeFilter[256]; // NOTE: the maximum LCU 64x64 have 256 partitions<br>
- uint8_t blockingStrength[256];<br>
-<br>
for (uint32_t col = 0; col < numCols; col++)<br>
{<br>
const uint32_t cuAddr = lineStartCUAddr + col;<br>
TComDataCU* cu = m_pic->getCU(cuAddr);<br>
<br>
- m_loopFilter.loopFilterCU(cu, EDGE_VER, edgeFilter, blockingStrength);<br>
+ m_loopFilter.loopFilterCU(cu, EDGE_VER, tld.m_edgeFilter, tld.m_blockingStrength);<br>
<br>
if (col > 0)<br>
{<br>
TComDataCU* cu_prev = m_pic->getCU(cuAddr - 1);<br>
- m_loopFilter.loopFilterCU(cu_prev, EDGE_HOR, edgeFilter, blockingStrength);<br>
+ m_loopFilter.loopFilterCU(cu_prev, EDGE_HOR, tld.m_edgeFilter, tld.m_blockingStrength);<br>
}<br>
}<br>
<br>
{<br>
TComDataCU* cu_prev = m_pic->getCU(lineStartCUAddr + numCols - 1);<br>
- m_loopFilter.loopFilterCU(cu_prev, EDGE_HOR, edgeFilter, blockingStrength);<br>
+ m_loopFilter.loopFilterCU(cu_prev, EDGE_HOR, tld.m_edgeFilter, tld.m_blockingStrength);<br>
}<br>
}<br>
<br>
@@ -178,7 +177,7 @@<br>
// NOTE: Delay a row because SAO decide need top row pixels at next row, is it HM's bug?<br>
if (row >= m_saoRowDelay)<br>
{<br>
- processSao(row - m_saoRowDelay);<br>
+ processSao(row - m_saoRowDelay, threadId);<br>
}<br>
}<br>
<br>
@@ -190,7 +189,7 @@<br>
<br>
if (row > 0)<br>
{<br>
- processRowPost(row - 1);<br>
+ processRowPost(row - 1, threadId);<br>
}<br>
<br>
if (row == m_numRows - 1)<br>
@@ -201,15 +200,15 @@<br>
<br>
for (int i = m_numRows - m_saoRowDelay; i < m_numRows; i++)<br>
{<br>
- processSao(i);<br>
+ processSao(i, threadId);<br>
}<br>
}<br>
<br>
- processRowPost(row);<br>
+ processRowPost(row, threadId);<br>
}<br>
}<br>
<br>
-void FrameFilter::processRowPost(int row)<br>
+void FrameFilter::processRowPost(int row, const int /*threadId*/)<br>
{<br>
const uint32_t numCols = m_pic->getPicSym()->getFrameWidthInCU();<br>
const uint32_t lineStartCUAddr = row * numCols;<br>
@@ -502,7 +501,7 @@<br>
return ssim;<br>
}<br>
<br>
-void FrameFilter::processSao(int row)<br>
+void FrameFilter::processSao(int row, const int threadId)<br></blockquote><div><br>Internal tests throw warning here:<br>D:\repo-staging\source\encoder\framefilter.cpp(504): warning C4100: 'threadId' : unreferenced formal parameter<br>
</div><div>Can be eliminated?<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
{<br>
const uint32_t numCols = m_pic->getPicSym()->getFrameWidthInCU();<br>
const uint32_t lineStartCUAddr = row * numCols;<br>
diff -r 12c1d8aaa8f5 -r efa48bc0245b source/encoder/framefilter.h<br>
--- a/source/encoder/framefilter.h Mon Jun 23 17:03:49 2014 -0700<br>
+++ b/source/encoder/framefilter.h Mon Jun 23 17:06:02 2014 -0700<br>
@@ -50,9 +50,9 @@<br>
<br>
void start(Frame *pic);<br>
<br>
- void processRow(int row);<br>
- void processRowPost(int row);<br>
- void processSao(int row);<br>
+ void processRow(int row, const int threadId);<br>
+ void processRowPost(int row, const int threadId);<br>
+ void processSao(int row, const int threadId);<br>
<br>
protected:<br>
<br>
<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>