[x265] [PATCH 1 of 2] improvement by replace lock to atom operator
Min Chen
chenm003 at 163.com
Wed Aug 21 08:30:19 CEST 2013
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1377066545 -28800
# Node ID fa37e9aa306e72601a233ccf0d934a6257ab6f2c
# Parent 6fe2b6e1fd6f1c0ed0997a7dd0f0c38a96091f08
improvement by replace lock to atom operator
diff -r 6fe2b6e1fd6f -r fa37e9aa306e source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp Tue Aug 20 08:22:45 2013 -0500
+++ b/source/encoder/framefilter.cpp Wed Aug 21 14:29:05 2013 +0800
@@ -36,6 +36,7 @@
: JobProvider(pool)
, m_cfg(NULL)
, m_pic(NULL)
+ , active_lft(FALSE)
{}
void FrameFilter::destroy()
@@ -55,7 +56,9 @@
bool FrameFilter::findJob()
{
- ScopedLock self(m_lock);
+ // Check the lock
+ if (ATOMIC_CAS32(&active_lft, FALSE, TRUE) == TRUE)
+ return false;
// NOTE: only one thread can be here
if (row_done < row_ready)
@@ -63,8 +66,10 @@
// NOTE: not need atom operator here because we lock before
row_done++;
processRow(row_done);
+ active_lft = FALSE;
return true;
}
+ active_lft = FALSE;
return false;
}
@@ -91,6 +96,7 @@
m_loopFilter.setCfg(pic->getSlice()->getPPS()->getLoopFilterAcrossTilesEnabledFlag());
row_ready = -1;
row_done = -1;
+ active_lft = FALSE;
if (m_cfg->param.bEnableLoopFilter)
{
if (m_cfg->param.saoLcuBasedOptimization && m_cfg->param.saoLcuBoundary)
diff -r 6fe2b6e1fd6f -r fa37e9aa306e source/encoder/framefilter.h
--- a/source/encoder/framefilter.h Tue Aug 20 08:22:45 2013 -0500
+++ b/source/encoder/framefilter.h Wed Aug 21 14:29:05 2013 +0800
@@ -66,7 +66,7 @@
TEncCfg* m_cfg;
TComPic* m_pic;
- Lock m_lock;
+ volatile int active_lft;
public:
More information about the x265-devel
mailing list