[x265] [PATCH 1 of 4] improvement by replace lock to atom operator
Min Chen
chenm003 at 163.com
Thu Aug 22 09:18:30 CEST 2013
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1377155784 -28800
# Node ID 5855cec9604808b34e8cebf7e4a159fbc2977855
# Parent 6fe2b6e1fd6f1c0ed0997a7dd0f0c38a96091f08
improvement by replace lock to atom operator
diff -r 6fe2b6e1fd6f -r 5855cec96048 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp Tue Aug 20 08:22:45 2013 -0500
+++ b/source/encoder/framefilter.cpp Thu Aug 22 15:16:24 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 5855cec96048 source/encoder/framefilter.h
--- a/source/encoder/framefilter.h Tue Aug 20 08:22:45 2013 -0500
+++ b/source/encoder/framefilter.h Thu Aug 22 15:16:24 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