summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Daniel <cd@maintech.de>2013-08-07 17:10:44 +0200
committerChristian Daniel <cd@maintech.de>2013-08-07 17:10:44 +0200
commite4a5556213844917285ab79ae278279b9399deb5 (patch)
tree8fb4bacf13bc5e90a6af3b03e4c0e0b9c3b0f0ba
parentd56a349dc90a96c2a2418dc68b30173381ca0027 (diff)
use % operator instead of range checks in halfbandfilter
-rw-r--r--CMakeLists.txt3
-rw-r--r--include-gpl/dsp/inthalfbandfilter.h68
-rw-r--r--main.cpp23
-rw-r--r--sdrbase/gui/glspectrum.cpp30
4 files changed, 71 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6515b0e..d57d8bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -234,6 +234,9 @@ include_directories(
${OPENGL_INCLUDE_DIR}
)
+set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2" )
+set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse2" )
+
if(MSVC)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
diff --git a/include-gpl/dsp/inthalfbandfilter.h b/include-gpl/dsp/inthalfbandfilter.h
index 5a50556..37c4519 100644
--- a/include-gpl/dsp/inthalfbandfilter.h
+++ b/include-gpl/dsp/inthalfbandfilter.h
@@ -27,9 +27,7 @@ public:
switch(m_state) {
case 0:
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 1;
@@ -42,9 +40,7 @@ public:
doFIR(sample);
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 0;
@@ -64,9 +60,7 @@ public:
m_samples[m_ptr][1] = sample->imag();
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 1;
@@ -83,9 +77,7 @@ public:
doFIR(sample);
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 0;
@@ -105,9 +97,7 @@ public:
m_samples[m_ptr][1] = sample->real();
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 1;
@@ -124,9 +114,7 @@ public:
doFIR(sample);
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 2;
@@ -140,9 +128,7 @@ public:
m_samples[m_ptr][1] = -sample->real();
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 3;
@@ -159,9 +145,7 @@ public:
doFIR(sample);
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 0;
@@ -181,9 +165,7 @@ public:
m_samples[m_ptr][1] = -sample->real();
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 1;
@@ -200,9 +182,7 @@ public:
doFIR(sample);
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 2;
@@ -216,9 +196,7 @@ public:
m_samples[m_ptr][1] = sample->real();
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 3;
@@ -235,9 +213,7 @@ public:
doFIR(sample);
// advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER);
- if(m_ptr >= (HB_FILTERORDER + 1))
- m_ptr -= (HB_FILTERORDER + 1);
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 0;
@@ -307,12 +283,8 @@ protected:
// init read-pointer
- int a = (m_ptr + 1);
- if(a >= (HB_FILTERORDER + 1))
- a -= (HB_FILTERORDER + 1);
- int b = (m_ptr + (HB_FILTERORDER - 1));
- if(b >= (HB_FILTERORDER + 1))
- b -= (HB_FILTERORDER + 1);
+ int a = (m_ptr + 1) % (HB_FILTERORDER + 1);
+ int b = (m_ptr + (HB_FILTERORDER - 1)) % (HB_FILTERORDER + 1);
// go through samples in buffer
qint32 iAcc = 0;
@@ -325,17 +297,11 @@ protected:
qAcc += qTmp * COEFF[i];
// update read-pointer
- a = (a + 2);
- if(a >= (HB_FILTERORDER + 1))
- a -= (HB_FILTERORDER + 1);
- b = b + (HB_FILTERORDER - 1);
- if(b >= (HB_FILTERORDER + 1))
- b -= (HB_FILTERORDER + 1);
+ a = (a + 2) % (HB_FILTERORDER + 1);
+ b = (b + (HB_FILTERORDER - 1)) % (HB_FILTERORDER + 1);
}
- a = (a + HB_FILTERORDER);
- if(a >= (HB_FILTERORDER + 1))
- a -= (HB_FILTERORDER + 1);
+ a = (a + HB_FILTERORDER) % (HB_FILTERORDER + 1);
iAcc += m_samples[a][0] * (qint32)(0.5 * (1 << HB_SHIFT));
qAcc += m_samples[a][1] * (qint32)(0.5 * (1 << HB_SHIFT));
diff --git a/main.cpp b/main.cpp
index 6777a56..4ceadfb 100644
--- a/main.cpp
+++ b/main.cpp
@@ -18,6 +18,7 @@
#include <QApplication>
#include <QTextCodec>
#include <QProxyStyle>
+#include <QStyleFactory>
#include "mainwindow.h"
static int runQtApplication(int argc, char* argv[])
@@ -30,8 +31,26 @@ static int runQtApplication(int argc, char* argv[])
QCoreApplication::setOrganizationName("osmocom");
QCoreApplication::setApplicationName("SDRangelove");
- QApplication::setStyle(new QProxyStyle());
-
+ //QApplication::setStyle(new QProxyStyle());
+#if 0
+ qApp->setStyle(QStyleFactory::create("fusion"));
+
+ QPalette palette;
+ palette.setColor(QPalette::Window, QColor(53,53,53));
+ palette.setColor(QPalette::WindowText, Qt::white);
+ palette.setColor(QPalette::Base, QColor(15,15,15));
+ palette.setColor(QPalette::AlternateBase, QColor(53,53,53));
+ palette.setColor(QPalette::ToolTipBase, Qt::white);
+ palette.setColor(QPalette::ToolTipText, Qt::white);
+ palette.setColor(QPalette::Text, Qt::white);
+ palette.setColor(QPalette::Button, QColor(53,53,53));
+ palette.setColor(QPalette::ButtonText, Qt::white);
+ palette.setColor(QPalette::BrightText, Qt::red);
+
+ palette.setColor(QPalette::Highlight, QColor(142,45,197).lighter());
+ palette.setColor(QPalette::HighlightedText, Qt::black);
+ qApp->setPalette(palette);
+#endif
MainWindow w;
w.show();
diff --git a/sdrbase/gui/glspectrum.cpp b/sdrbase/gui/glspectrum.cpp
index 1ab3eb7..912d732 100644
--- a/sdrbase/gui/glspectrum.cpp
+++ b/sdrbase/gui/glspectrum.cpp
@@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
+#include <immintrin.h>
#include <QMouseEvent>
#include "gui/glspectrum.h"
@@ -296,6 +297,8 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
m_histogramHoldoffCount = m_histogramHoldoffBase;
}
+//#define NO_AVX
+#ifdef NO_AVX
for(int i = 0; i < m_fftSize; i++) {
int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0);
@@ -307,6 +310,33 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
*b += 1;
}
}
+#else
+ const __m128 refl = {m_referenceLevel,m_referenceLevel,m_referenceLevel,m_referenceLevel};
+ const __m128 power = {m_powerRange,m_powerRange,m_powerRange,m_powerRange};
+ const __m128 mul = {100.0f,100.0f,100.0f,100.0f};
+
+ for(int i = 0; i < m_fftSize; i+=4) {
+ __m128 abc = _mm_loadu_ps (&spectrum[i]);
+ abc = _mm_sub_ps(abc, refl);
+ abc = _mm_mul_ps(abc, mul);
+ abc = _mm_div_ps(abc, power);
+ abc = _mm_add_ps(abc, mul);
+ __m128i result = _mm_cvtps_epi32(abc);
+
+ for(int j = 0; j < 4; j++) {
+
+ int v = ((int*)&result)[j];
+
+ if((v >= 0) && (v <= 99)) {
+ b = m_histogram + (i+j) * 100 + v;
+ if(*b < 220)
+ *b += 4;
+ else if(*b < 239)
+ *b += 1;
+ }
+ }
+ }
+#endif
}
void GLSpectrum::initializeGL()