From 3cd754bd677243010548d4df298f7ed8e14fbc59 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 12 May 2017 02:41:51 +0200 Subject: [PATCH] Fixed down channelizer by dividing by 2 at each filter stage --- sdrbase/dsp/downchannelizer.cpp | 36 +++++++++++++++++++++++++++++++-- sdrbase/dsp/downchannelizer.h | 3 +++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/sdrbase/dsp/downchannelizer.cpp b/sdrbase/dsp/downchannelizer.cpp index 4adb43628..73131b7b9 100644 --- a/sdrbase/dsp/downchannelizer.cpp +++ b/sdrbase/dsp/downchannelizer.cpp @@ -77,6 +77,8 @@ void DownChannelizer::feed(const SampleVector::const_iterator& begin, const Samp if(stage == m_filterStages.end()) { + s.m_real /= (1<<(m_filterStages.size())); + s.m_imag /= (1<<(m_filterStages.size())); m_sampleBuffer.push_back(s); } } @@ -172,6 +174,8 @@ void DownChannelizer::applyConfiguration() m_mutex.unlock(); + //debugFilterChain(); + m_currentOutputSampleRate = m_inputSampleRate / (1 << m_filterStages.size()); qDebug() << "DownChannelizer::applyConfiguration in=" << m_inputSampleRate @@ -189,7 +193,9 @@ void DownChannelizer::applyConfiguration() #ifdef USE_SSE4_1 DownChannelizer::FilterStage::FilterStage(Mode mode) : m_filter(new IntHalfbandFilterEO1), - m_workFunction(0) + m_workFunction(0), + m_mode(mode), + m_sse(true) { switch(mode) { case ModeCenter: @@ -208,7 +214,9 @@ DownChannelizer::FilterStage::FilterStage(Mode mode) : #else DownChannelizer::FilterStage::FilterStage(Mode mode) : m_filter(new IntHalfbandFilterDB), - m_workFunction(0) + m_workFunction(0), + m_mode(mode), + m_sse(false) { switch(mode) { case ModeCenter: @@ -286,3 +294,27 @@ void DownChannelizer::freeFilterChain() delete *it; m_filterStages.clear(); } + +void DownChannelizer::debugFilterChain() +{ + qDebug("DownChannelizer::debugFilterChain: %lu stages", m_filterStages.size()); + + for(FilterStages::iterator it = m_filterStages.begin(); it != m_filterStages.end(); ++it) + { + switch ((*it)->m_mode) + { + case FilterStage::ModeCenter: + qDebug("DownChannelizer::debugFilterChain: center %s", (*it)->m_sse ? "sse" : "no_sse"); + break; + case FilterStage::ModeLowerHalf: + qDebug("DownChannelizer::debugFilterChain: lower %s", (*it)->m_sse ? "sse" : "no_sse"); + break; + case FilterStage::ModeUpperHalf: + qDebug("DownChannelizer::debugFilterChain: upper %s", (*it)->m_sse ? "sse" : "no_sse"); + break; + default: + qDebug("DownChannelizer::debugFilterChain: none %s", (*it)->m_sse ? "sse" : "no_sse"); + break; + } + } +} diff --git a/sdrbase/dsp/downchannelizer.h b/sdrbase/dsp/downchannelizer.h index d17810e73..271e152a5 100644 --- a/sdrbase/dsp/downchannelizer.h +++ b/sdrbase/dsp/downchannelizer.h @@ -81,6 +81,8 @@ protected: IntHalfbandFilterDB* m_filter; #endif WorkFunction m_workFunction; + Mode m_mode; + bool m_sse; FilterStage(Mode mode); ~FilterStage(); @@ -105,6 +107,7 @@ protected: bool signalContainsChannel(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd) const; Real createFilterChain(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd); void freeFilterChain(); + void debugFilterChain(); signals: void inputSampleRateChanged();