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