1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-05-24 19:22:27 -04:00

Optimization of current spectrum line display by just storing a pointer to the current spectrum

This commit is contained in:
f4exb 2015-07-16 08:38:33 +02:00
parent 69101c0629
commit 135170e6db
2 changed files with 15 additions and 8 deletions

View File

@ -99,7 +99,7 @@ private:
std::vector<Real> m_maxHold; std::vector<Real> m_maxHold;
bool m_displayMaxHold; bool m_displayMaxHold;
std::vector<Real> m_current; const std::vector<Real> *m_currentSpectrum;
bool m_displayCurrent; bool m_displayCurrent;
Real m_waterfallShare; Real m_waterfallShare;

View File

@ -36,6 +36,7 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_displayGridIntensity(5), m_displayGridIntensity(5),
m_invertedWaterfall(false), m_invertedWaterfall(false),
m_displayMaxHold(false), m_displayMaxHold(false),
m_currentSpectrum(0),
m_displayCurrent(false), m_displayCurrent(false),
m_leftMarginTextureAllocated(false), m_leftMarginTextureAllocated(false),
m_frequencyTextureAllocated(false), m_frequencyTextureAllocated(false),
@ -88,9 +89,9 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
((quint8*)&m_histogramPalette[i])[3] = c.alpha(); ((quint8*)&m_histogramPalette[i])[3] = c.alpha();
} }
m_current.resize(m_fftSize); //m_current.resize(m_fftSize);
m_histogramHoldoffBase = 1; // was 4 m_histogramHoldoffBase = 2; // was 4
m_histogramHoldoffCount = m_histogramHoldoffBase; m_histogramHoldoffCount = m_histogramHoldoffBase;
m_histogramLateHoldoff = 1; // was 20 m_histogramLateHoldoff = 1; // was 20
m_histogramStroke = 40; // was 4 m_histogramStroke = 40; // was 4
@ -236,9 +237,10 @@ void GLSpectrum::setDisplayMaxHold(bool display)
void GLSpectrum::setDisplayCurrent(bool display) void GLSpectrum::setDisplayCurrent(bool display)
{ {
/*
if(display && (m_current.size() < (uint)m_fftSize)) { if(display && (m_current.size() < (uint)m_fftSize)) {
m_current.resize(m_fftSize); m_current.resize(m_fftSize);
} }*/
m_displayCurrent = display; m_displayCurrent = display;
m_changesPending = true; m_changesPending = true;
@ -367,14 +369,18 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
m_histogramHoldoffCount = m_histogramHoldoffBase; m_histogramHoldoffCount = m_histogramHoldoffBase;
} }
/*
if(m_current.size() < (uint)m_fftSize) if(m_current.size() < (uint)m_fftSize)
m_current.resize(m_fftSize); m_current.resize(m_fftSize);*/
m_currentSpectrum = &spectrum;
#define NO_AVX #define NO_AVX
#ifdef NO_AVX #ifdef NO_AVX
for(int i = 0; i < m_fftSize; i++) { for(int i = 0; i < m_fftSize; i++) {
int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0); int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0);
if ((v >= 0) && (v <= 99)) {
/*
if (v < 0) { if (v < 0) {
m_current[i] = m_referenceLevel - m_powerRange; m_current[i] = m_referenceLevel - m_powerRange;
} }
@ -382,8 +388,9 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
m_current[i] = m_referenceLevel; m_current[i] = m_referenceLevel;
} }
else { else {
*/
//m_current[i] = m_referenceLevel - m_powerRange + (v * m_powerRange) / 99.0; //m_current[i] = m_referenceLevel - m_powerRange + (v * m_powerRange) / 99.0;
m_current[i] = spectrum[i]; //m_current[i] = spectrum[i];
b = m_histogram + i * 100 + v; b = m_histogram + i * 100 + v;
if(*b < 220) if(*b < 220)
*b += m_histogramStroke; // was 4 *b += m_histogramStroke; // was 4
@ -799,7 +806,7 @@ void GLSpectrum::paintGL()
} }
// paint current spectrum line on top of histogram // paint current spectrum line on top of histogram
if(m_displayCurrent) { if ((m_displayCurrent) && m_currentSpectrum) {
glPushMatrix(); glPushMatrix();
glTranslatef(m_glHistogramRect.x(), m_glHistogramRect.y(), 0); glTranslatef(m_glHistogramRect.x(), m_glHistogramRect.y(), 0);
glScalef(m_glHistogramRect.width() / (float)(m_fftSize - 1), -m_glHistogramRect.height() / m_powerRange, 1); glScalef(m_glHistogramRect.width() / (float)(m_fftSize - 1), -m_glHistogramRect.height() / m_powerRange, 1);
@ -811,7 +818,7 @@ void GLSpectrum::paintGL()
Real bottom = -m_powerRange; Real bottom = -m_powerRange;
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for(int i = 0; i < m_fftSize; i++) { for(int i = 0; i < m_fftSize; i++) {
Real v = m_current[i] - m_referenceLevel; Real v = (*m_currentSpectrum)[i] - m_referenceLevel;
if(v > 0) if(v > 0)
v = 0; v = 0;
else if(v < bottom) else if(v < bottom)