1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 23:55:13 -05:00

Consistant Waterfall speed.

Saves cpu at high bandwidths.
This commit is contained in:
Hexameron 2014-05-19 15:22:44 +01:00
parent fbef672cd0
commit 82047f69ce
4 changed files with 15 additions and 63 deletions

View File

@ -45,6 +45,7 @@ public:
virtual const QString& getDeviceDescription() const = 0;
virtual int getSampleRate() const = 0;
virtual int wfdecimation() const = 0;
virtual quint64 getCenterFrequency() const = 0;
virtual bool handleMessage(Message* message) = 0;

View File

@ -185,6 +185,12 @@ int RTLSDRInput::getSampleRate() const
return 1536000 / (1 << m_settings.m_decimation);
}
int RTLSDRInput::wfdecimation() const
{
// decimate waterfall more when downsampling less
return (1 << (4 - m_settings.m_decimation) ) -1;
}
quint64 RTLSDRInput::getCenterFrequency() const
{
return m_generalSettings.m_centerFrequency;

View File

@ -87,6 +87,7 @@ public:
const QString& getDeviceDescription() const;
int getSampleRate() const;
int wfdecimation() const;
quint64 getCenterFrequency() const;
bool handleMessage(Message* message);

View File

@ -196,6 +196,7 @@ void DSPEngine::imbalance(SampleVector::iterator begin, SampleVector::iterator e
it->m_imag = (it->m_imag * m_imbalance) >> 16;
}
int drop_frame = 0;
void DSPEngine::work()
{
SampleFifo* sampleFifo = m_sampleSource->getSampleFifo();
@ -210,6 +211,12 @@ void DSPEngine::work()
size_t count = sampleFifo->readBegin(sampleFifo->fill(), &part1begin, &part1end, &part2begin, &part2end);
if (m_sampleSource->wfdecimation() & drop_frame++) {
sampleFifo->readCommit(count);
samplesDone += count;
continue;
}
// first part of FIFO data
if(part1begin != part1end) {
// correct stuff
@ -239,69 +246,6 @@ void DSPEngine::work()
sampleFifo->readCommit(count);
samplesDone += count;
}
#if 0
size_t wus;
size_t maxWorkUnitSize = 0;
size_t samplesDone = 0;
wus = m_spectrum.workUnitSize();
if(wus > maxWorkUnitSize)
maxWorkUnitSize = wus;
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) {
wus = (*it)->workUnitSize();
if(wus > maxWorkUnitSize)
maxWorkUnitSize = wus;
}
while((m_sampleFifo.fill() > maxWorkUnitSize) && (m_commandQueue.countPending() == 0) && (samplesDone < m_sampleRate)) {
SampleVector::iterator part1begin;
SampleVector::iterator part1end;
SampleVector::iterator part2begin;
SampleVector::iterator part2end;
size_t count = m_sampleFifo.readBegin(m_sampleFifo.fill(), &part1begin, &part1end, &part2begin, &part2end);
// first part of FIFO data
if(part1begin != part1end) {
// correct stuff
if(m_settings.dcOffsetCorrection())
dcOffset(part1begin, part1end);
if(m_settings.iqImbalanceCorrection())
imbalance(part1begin, part1end);
// feed data to handlers
m_spectrum.feed(part1begin, part1end);
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
(*it)->feed(part1begin, part1end);
}
// second part of FIFO data (used when block wraps around)
if(part2begin != part2end) {
// correct stuff
if(m_settings.dcOffsetCorrection())
dcOffset(part2begin, part2end);
if(m_settings.iqImbalanceCorrection())
imbalance(part2begin, part2end);
// feed data to handlers
m_spectrum.feed(part2begin, part2end);
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
(*it)->feed(part1begin, part1end);
}
// adjust FIFO pointers
m_sampleFifo.readCommit(count);
samplesDone += count;
}
// check if the center frequency has changed (has to be responsive)
if(m_settings.isModifiedCenterFreq())
m_sampleSource->setCenterFrequency(m_settings.centerFreq());
// check if decimation has changed (needed to be done here, because to high a sample rate can clog the switch)
if(m_settings.isModifiedDecimation()) {
m_sampleSource->setDecimation(m_settings.decimation());
m_sampleRate = 4000000 / (1 << m_settings.decimation());
qDebug("New rate: %d", m_sampleRate);
}
#endif
}
DSPEngine::State DSPEngine::gotoIdle()