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

DATV demod: make sure that when baseband rate changes the channelizer is reconfigured to get all available bandwidth

This commit is contained in:
f4exb 2018-02-25 03:22:30 +01:00
parent 916a284b48
commit e53da4e9a8
3 changed files with 320 additions and 325 deletions

View File

@ -29,7 +29,6 @@
#include "dsp/threadedbasebandsamplesink.h" #include "dsp/threadedbasebandsamplesink.h"
#include "device/devicesourceapi.h" #include "device/devicesourceapi.h"
const QString DATVDemod::m_channelIdURI = "sdrangel.channel.demoddatv"; const QString DATVDemod::m_channelIdURI = "sdrangel.channel.demoddatv";
const QString DATVDemod::m_channelId = "DATVDemod"; const QString DATVDemod::m_channelId = "DATVDemod";
@ -40,10 +39,10 @@ DATVDemod::DATVDemod(DeviceSourceAPI *deviceAPI) :
ChannelSinkAPI(m_channelIdURI), ChannelSinkAPI(m_channelIdURI),
m_blnNeedConfigUpdate(false), m_blnNeedConfigUpdate(false),
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
m_objRegisteredDATVScreen(NULL), m_objRegisteredDATVScreen(0),
m_objRegisteredVideoRender(NULL), m_objRegisteredVideoRender(0),
m_objVideoStream(NULL), m_objVideoStream(0),
m_objRenderThread(NULL), m_objRenderThread(0),
m_blnRenderingVideo(false), m_blnRenderingVideo(false),
m_enmModulation(BPSK /*DATV_FM1*/), m_enmModulation(BPSK /*DATV_FM1*/),
m_objSettingsMutex(QMutex::NonRecursive) m_objSettingsMutex(QMutex::NonRecursive)
@ -65,14 +64,12 @@ DATVDemod::DATVDemod(DeviceSourceAPI *deviceAPI) :
m_deviceAPI->addChannelAPI(this); m_deviceAPI->addChannelAPI(this);
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged())); connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
} }
DATVDemod::~DATVDemod() DATVDemod::~DATVDemod()
{ {
m_blnInitialized = false; m_blnInitialized = false;
if (m_objRenderThread != NULL) if (m_objRenderThread != NULL)
{ {
if (m_objRenderThread->isRunning()) if (m_objRenderThread->isRunning())
@ -115,7 +112,6 @@ DATVideostream * DATVDemod::SetVideoRender(DATVideoRender *objScreen)
return m_objVideoStream; return m_objVideoStream;
} }
bool DATVDemod::PlayVideo(bool blnStartStop) bool DATVDemod::PlayVideo(bool blnStartStop)
{ {
@ -154,7 +150,8 @@ bool DATVDemod::PlayVideo(bool blnStartStop)
return true; return true;
} }
void DATVDemod::configure(MessageQueue* objMessageQueue, void DATVDemod::configure(
MessageQueue* objMessageQueue,
int intRFBandwidth, int intRFBandwidth,
int intCenterFrequency, int intCenterFrequency,
dvb_version enmStandard, dvb_version enmStandard,
@ -169,11 +166,25 @@ void DATVDemod::configure(MessageQueue* objMessageQueue,
bool blnResample, bool blnResample,
bool blnViterbi) bool blnViterbi)
{ {
Message* msgCmd = MsgConfigureDATVDemod::create(intRFBandwidth,intCenterFrequency,enmStandard, enmModulation, enmFEC, intSymbolRate, intNotchFilters, blnAllowDrift,blnFastLock,blnHDLC,blnHardMetric,blnResample, blnViterbi); Message* msgCmd = MsgConfigureDATVDemod::create(
intRFBandwidth,
intCenterFrequency,
enmStandard,
enmModulation,
enmFEC,
intSymbolRate,
intNotchFilters,
blnAllowDrift,
blnFastLock,
blnHDLC,
blnHardMetric,
blnResample,
blnViterbi);
objMessageQueue->push(msgCmd); objMessageQueue->push(msgCmd);
} }
void DATVDemod::InitDATVParameters(int intMsps, void DATVDemod::InitDATVParameters(
int intMsps,
int intRFBandwidth, int intRFBandwidth,
int intCenterFrequency, int intCenterFrequency,
dvb_version enmStandard, dvb_version enmStandard,
@ -234,7 +245,6 @@ void DATVDemod::InitDATVParameters(int intMsps,
<< " - Resample: " << blnResample << " - Resample: " << blnResample
<< " - Viterbi: " << blnViterbi; << " - Viterbi: " << blnViterbi;
m_objSettingsMutex.unlock(); m_objSettingsMutex.unlock();
m_blnNeedConfigUpdate = true; m_blnNeedConfigUpdate = true;
@ -393,7 +403,6 @@ void DATVDemod::CleanUpDATVFramework()
p_locktime = 0; p_locktime = 0;
r_sync_mpeg = 0; r_sync_mpeg = 0;
// DEINTERLEAVING // DEINTERLEAVING
p_rspackets = 0; p_rspackets = 0;
r_deinter = 0; r_deinter = 0;
@ -403,22 +412,18 @@ void DATVDemod::CleanUpDATVFramework()
p_rtspackets = 0; p_rtspackets = 0;
r_rsdec = 0; r_rsdec = 0;
//BER ESTIMATION //BER ESTIMATION
p_vber = 0; p_vber = 0;
r_vber = 0; r_vber = 0;
// DERANDOMIZATION // DERANDOMIZATION
p_tspackets = 0; p_tspackets = 0;
r_derand = 0; r_derand = 0;
//OUTPUT : To remove //OUTPUT : To remove
r_stdout = 0; r_stdout = 0;
r_videoplayer = 0; r_videoplayer = 0;
//CONSTELLATION //CONSTELLATION
r_scope_symbols = 0; r_scope_symbols = 0;
} }
@ -485,7 +490,6 @@ void DATVDemod::InitDATVFramework()
m_objCfg.resample = m_objRunning.blnResample; m_objCfg.resample = m_objRunning.blnResample;
m_objCfg.viterbi = m_objRunning.blnViterbi; m_objCfg.viterbi = m_objRunning.blnViterbi;
// Min buffer size for baseband data // Min buffer size for baseband data
// scopes: 1024 // scopes: 1024
// ss_estimator: 1024 // ss_estimator: 1024
@ -517,7 +521,6 @@ void DATVDemod::InitDATVFramework()
m_lngExpectedReadIQ = BUF_BASEBAND; m_lngExpectedReadIQ = BUF_BASEBAND;
CleanUpDATVFramework(); CleanUpDATVFramework();
m_objScheduler = new scheduler(); m_objScheduler = new scheduler();
@ -536,7 +539,6 @@ void DATVDemod::InitDATVFramework()
p_preprocessed = p_autonotched; p_preprocessed = p_autonotched;
} }
// FREQUENCY CORRECTION // FREQUENCY CORRECTION
if (m_objCfg.Fderot) if (m_objCfg.Fderot)
@ -584,7 +586,6 @@ void DATVDemod::InitDATVFramework()
p_resampled = new pipebuf<cf32>(m_objScheduler, "resampled", BUF_BASEBAND); p_resampled = new pipebuf<cf32>(m_objScheduler, "resampled", BUF_BASEBAND);
#if 1 // Cut in middle of roll-off region #if 1 // Cut in middle of roll-off region
float Fcut = (m_objCfg.Fm / 2) * (1 + m_objCfg.rolloff / 2) / m_objCfg.Fs; float Fcut = (m_objCfg.Fm / 2) * (1 + m_objCfg.rolloff / 2) / m_objCfg.Fs;
#else // Cut at beginning of roll-off region #else // Cut at beginning of roll-off region
@ -615,7 +616,6 @@ void DATVDemod::InitDATVFramework()
//Resampling FS //Resampling FS
// Generic constellation receiver // Generic constellation receiver
p_symbols = new pipebuf<softsymbol>(m_objScheduler, "PSK soft-symbols", BUF_SYMBOLS); p_symbols = new pipebuf<softsymbol>(m_objScheduler, "PSK soft-symbols", BUF_SYMBOLS);
@ -637,7 +637,6 @@ void DATVDemod::InitDATVFramework()
case SAMP_RRC: case SAMP_RRC:
{ {
if (m_objCfg.rrc_steps == 0) if (m_objCfg.rrc_steps == 0)
{ {
// At least 64 discrete sampling points between symbols // At least 64 discrete sampling points between symbols
@ -663,7 +662,7 @@ void DATVDemod::InitDATVFramework()
{ {
if (m_objCfg.constellation != cstln_lut<256>::QPSK && m_objCfg.constellation != cstln_lut<256>::BPSK) if (m_objCfg.constellation != cstln_lut<256>::QPSK && m_objCfg.constellation != cstln_lut<256>::BPSK)
{ {
fprintf(stderr, "Warning: non-standard constellation for DVB-S\n"); qWarning("DATVDemod::InitDATVFramework: non-standard constellation for DVB-S");
} }
} }
@ -671,7 +670,7 @@ void DATVDemod::InitDATVFramework()
{ {
// For DVB-S2 testing only. // For DVB-S2 testing only.
// Constellation should be determined from PL signalling. // Constellation should be determined from PL signalling.
fprintf(stderr, "DVB-S2: Testing symbol sampler only.\n"); qWarning("DATVDemod::InitDATVFramework: DVB-S2: Testing symbol sampler only.");
} }
m_objDemodulator->cstln = make_dvbs2_constellation(m_objCfg.constellation, m_objCfg.fec); m_objDemodulator->cstln = make_dvbs2_constellation(m_objCfg.constellation, m_objCfg.fec);
@ -710,7 +709,6 @@ void DATVDemod::InitDATVFramework()
r_resample->freq_tol = m_objCfg.Fm / (m_objCfg.Fs * decim) * 0.1; r_resample->freq_tol = m_objCfg.Fm / (m_objCfg.Fs * decim) * 0.1;
} }
if (r_cnr) if (r_cnr)
{ {
r_cnr->freq_tap = &m_objDemodulator->freq_tap; r_cnr->freq_tap = &m_objDemodulator->freq_tap;
@ -752,7 +750,6 @@ void DATVDemod::InitDATVFramework()
r_deconv->fastlock = m_objCfg.fastlock; r_deconv->fastlock = m_objCfg.fastlock;
} }
if (m_objCfg.hdlc) if (m_objCfg.hdlc)
{ {
p_descrambled = new pipebuf<u8>(m_objScheduler, "descrambled", BUF_MPEGBYTES); p_descrambled = new pipebuf<u8>(m_objScheduler, "descrambled", BUF_MPEGBYTES);
@ -787,7 +784,6 @@ void DATVDemod::InitDATVFramework()
p_rspackets = new pipebuf<rspacket<u8> >(m_objScheduler, "RS-enc packets", BUF_PACKETS); p_rspackets = new pipebuf<rspacket<u8> >(m_objScheduler, "RS-enc packets", BUF_PACKETS);
r_deinter = new deinterleaver<u8>(m_objScheduler, *p_mpegbytes, *p_rspackets); r_deinter = new deinterleaver<u8>(m_objScheduler, *p_mpegbytes, *p_rspackets);
// REED-SOLOMON // REED-SOLOMON
p_vbitcount = new pipebuf<int>(m_objScheduler, "Bits processed", BUF_PACKETS); p_vbitcount = new pipebuf<int>(m_objScheduler, "Bits processed", BUF_PACKETS);
@ -795,10 +791,8 @@ void DATVDemod::InitDATVFramework()
p_rtspackets = new pipebuf<tspacket>(m_objScheduler, "rand TS packets", BUF_PACKETS); p_rtspackets = new pipebuf<tspacket>(m_objScheduler, "rand TS packets", BUF_PACKETS);
r_rsdec = new rs_decoder<u8, 0>(m_objScheduler, *p_rspackets, *p_rtspackets, p_vbitcount, p_verrcount); r_rsdec = new rs_decoder<u8, 0>(m_objScheduler, *p_rspackets, *p_rtspackets, p_vbitcount, p_verrcount);
// BER ESTIMATION // BER ESTIMATION
p_vber = new pipebuf<float>(m_objScheduler, "VBER", BUF_SLOW); p_vber = new pipebuf<float>(m_objScheduler, "VBER", BUF_SLOW);
r_vber = new rate_estimator<float>(m_objScheduler, *p_verrcount, *p_vbitcount, *p_vber); r_vber = new rate_estimator<float>(m_objScheduler, *p_verrcount, *p_vbitcount, *p_vber);
r_vber->sample_size = m_objCfg.Fm / 2; // About twice per second, depending on CR r_vber->sample_size = m_objCfg.Fm / 2; // About twice per second, depending on CR
@ -808,13 +802,11 @@ void DATVDemod::InitDATVFramework()
r_vber->sample_size = 50000; r_vber->sample_size = 50000;
} }
// DERANDOMIZATION // DERANDOMIZATION
p_tspackets = new pipebuf<tspacket>(m_objScheduler, "TS packets", BUF_PACKETS); p_tspackets = new pipebuf<tspacket>(m_objScheduler, "TS packets", BUF_PACKETS);
r_derand = new derandomizer(m_objScheduler, *p_rtspackets, *p_tspackets); r_derand = new derandomizer(m_objScheduler, *p_rtspackets, *p_tspackets);
// OUTPUT // OUTPUT
r_videoplayer = new datvvideoplayer<tspacket>(m_objScheduler, *p_tspackets, m_objVideoStream); r_videoplayer = new datvvideoplayer<tspacket>(m_objScheduler, *p_tspackets, m_objVideoStream);
@ -830,7 +822,6 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
fftfilt::cmplx *objRF; fftfilt::cmplx *objRF;
int intRFOut; int intRFOut;
#ifdef EXTENDED_DIRECT_SAMPLE #ifdef EXTENDED_DIRECT_SAMPLE
qint16 * ptrBufferToRelease=NULL; qint16 * ptrBufferToRelease=NULL;
@ -860,7 +851,6 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
fltQ = it->imag(); fltQ = it->imag();
#endif #endif
//********** demodulation ********** //********** demodulation **********
if ((m_blnDVBInitialized == false) || (m_blnNeedConfigUpdate == true)) if ((m_blnDVBInitialized == false) || (m_blnNeedConfigUpdate == true))
@ -911,7 +901,6 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
} }
} }
//********** demodulation ********** //********** demodulation **********
} }
@ -939,24 +928,21 @@ void DATVDemod::stop()
bool DATVDemod::handleMessage(const Message& cmd) bool DATVDemod::handleMessage(const Message& cmd)
{ {
qDebug() << "DATVDemod::handleMessage";
if (DownChannelizer::MsgChannelizerNotification::match(cmd)) if (DownChannelizer::MsgChannelizerNotification::match(cmd))
{ {
DownChannelizer::MsgChannelizerNotification& objNotif = (DownChannelizer::MsgChannelizerNotification&) cmd; DownChannelizer::MsgChannelizerNotification& objNotif = (DownChannelizer::MsgChannelizerNotification&) cmd;
qDebug() << "DATVDemod::handleMessage: MsgChannelizerNotification:" << " intMsps: " << objNotif.getSampleRate();
if (m_objRunning.intMsps != objNotif.getSampleRate()) if (m_objRunning.intMsps != objNotif.getSampleRate())
{ {
m_objRunning.intMsps = objNotif.getSampleRate(); m_objRunning.intMsps = objNotif.getSampleRate();
m_objRunning.intSampleRate = m_objRunning.intMsps; m_objRunning.intSampleRate = m_objRunning.intMsps;
printf("Sample Rate: %d\r\n",m_objRunning.intSampleRate ); qDebug("DATVDemod::handleMessage: Sample Rate: %d", m_objRunning.intSampleRate);
ApplySettings(); ApplySettings();
} }
qDebug() << "DATVDemod::handleMessage: MsgChannelizerNotification:"
<< " intMsps: " << m_objRunning.intMsps;
return true; return true;
} }
else if (MsgConfigureChannelizer::match(cmd)) else if (MsgConfigureChannelizer::match(cmd))
@ -964,34 +950,28 @@ bool DATVDemod::handleMessage(const Message& cmd)
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd; MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
m_channelizer->configure(m_channelizer->getInputMessageQueue(), qDebug() << "DATVDemod::handleMessage: MsgConfigureChannelizer:"
m_channelizer->getInputSampleRate(), << " sampleRate: " << m_channelizer->getInputSampleRate()
cfg.getCenterFrequency());
//m_objRunning.intCenterFrequency);
qDebug() << "DATVDemod::handleMessage: MsgConfigureChannelizer: sampleRate: " << m_channelizer->getInputSampleRate()
<< " centerFrequency: " << cfg.getCenterFrequency(); << " centerFrequency: " << cfg.getCenterFrequency();
m_channelizer->configure(m_channelizer->getInputMessageQueue(), m_channelizer->getInputSampleRate(), cfg.getCenterFrequency());
//m_objRunning.intCenterFrequency);
//<< " centerFrequency: " << m_objRunning.intCenterFrequency; //<< " centerFrequency: " << m_objRunning.intCenterFrequency;
return true; return true;
} }
else if (MsgConfigureDATVDemod::match(cmd)) else if (MsgConfigureDATVDemod::match(cmd))
{ {
qDebug() << "DATVDemod::handleMessage: MsgConfigureDATVDemod";
MsgConfigureDATVDemod& objCfg = (MsgConfigureDATVDemod&) cmd; MsgConfigureDATVDemod& objCfg = (MsgConfigureDATVDemod&) cmd;
if ((objCfg.m_objMsgConfig.blnAllowDrift != m_objRunning.blnAllowDrift) || (objCfg.m_objMsgConfig.intRFBandwidth != m_objRunning.intRFBandwidth)
if((objCfg.m_objMsgConfig.blnAllowDrift != m_objRunning.blnAllowDrift) || (objCfg.m_objMsgConfig.intCenterFrequency != m_objRunning.intCenterFrequency) || (objCfg.m_objMsgConfig.blnFastLock != m_objRunning.blnFastLock)
|| (objCfg.m_objMsgConfig.intRFBandwidth != m_objRunning.intRFBandwidth) || (objCfg.m_objMsgConfig.blnHardMetric != m_objRunning.blnHardMetric) || (objCfg.m_objMsgConfig.blnHDLC != m_objRunning.blnHDLC)
|| (objCfg.m_objMsgConfig.intCenterFrequency != m_objRunning.intCenterFrequency) || (objCfg.m_objMsgConfig.blnResample != m_objRunning.blnResample) || (objCfg.m_objMsgConfig.blnViterbi != m_objRunning.blnViterbi)
|| (objCfg.m_objMsgConfig.blnFastLock != m_objRunning.blnFastLock) || (objCfg.m_objMsgConfig.enmFEC != m_objRunning.enmFEC) || (objCfg.m_objMsgConfig.enmModulation != m_objRunning.enmModulation)
|| (objCfg.m_objMsgConfig.blnHardMetric != m_objRunning.blnHardMetric) || (objCfg.m_objMsgConfig.enmStandard != m_objRunning.enmStandard) || (objCfg.m_objMsgConfig.intNotchFilters != m_objRunning.intNotchFilters)
|| (objCfg.m_objMsgConfig.blnHDLC != m_objRunning.blnHDLC)
|| (objCfg.m_objMsgConfig.blnResample != m_objRunning.blnResample)
|| (objCfg.m_objMsgConfig.blnViterbi != m_objRunning.blnViterbi)
|| (objCfg.m_objMsgConfig.enmFEC != m_objRunning.enmFEC)
|| (objCfg.m_objMsgConfig.enmModulation != m_objRunning.enmModulation)
|| (objCfg.m_objMsgConfig.enmStandard != m_objRunning.enmStandard)
|| (objCfg.m_objMsgConfig.intNotchFilters != m_objRunning.intNotchFilters)
|| (objCfg.m_objMsgConfig.intSymbolRate != m_objRunning.intSymbolRate)) || (objCfg.m_objMsgConfig.intSymbolRate != m_objRunning.intSymbolRate))
{ {
m_objRunning.blnAllowDrift = objCfg.m_objMsgConfig.blnAllowDrift; m_objRunning.blnAllowDrift = objCfg.m_objMsgConfig.blnAllowDrift;
@ -1011,7 +991,11 @@ bool DATVDemod::handleMessage(const Message& cmd)
ApplySettings(); ApplySettings();
} }
return true;
}
else if (DSPSignalNotification::match(cmd))
{
qDebug() << "DATVDemod::handleMessage: DSPSignalNotification";
return true; return true;
} }
else else
@ -1030,7 +1014,8 @@ void DATVDemod::ApplySettings()
//m_objSettingsMutex.lock(); //m_objSettingsMutex.lock();
InitDATVParameters(m_objRunning.intMsps, InitDATVParameters(
m_objRunning.intMsps,
m_objRunning.intRFBandwidth, m_objRunning.intRFBandwidth,
m_objRunning.intCenterFrequency, m_objRunning.intCenterFrequency,
m_objRunning.enmStandard, m_objRunning.enmStandard,
@ -1053,3 +1038,10 @@ int DATVDemod::GetSampleRate()
return m_objRunning.intMsps; return m_objRunning.intMsps;
} }
void DATVDemod::channelSampleRateChanged()
{
qDebug("DATVDemod::channelSampleRateChanged");
// reconfigure to get full available bandwidth
m_channelizer->configure(m_channelizer->getInputMessageQueue(), m_channelizer->getInputSampleRate(), m_channelizer->getRequestedCenterFrequency());
// TODO: forward to GUI if necessary
}

View File

@ -496,6 +496,8 @@ private:
void ApplySettings(); void ApplySettings();
private slots:
void channelSampleRateChanged();
}; };
#endif // INCLUDE_DATVDEMOD_H #endif // INCLUDE_DATVDEMOD_H

View File

@ -68,6 +68,7 @@ public:
void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency); void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency);
int getInputSampleRate() const { return m_inputSampleRate; } int getInputSampleRate() const { return m_inputSampleRate; }
int getRequestedCenterFrequency() const { return m_requestedCenterFrequency; }
virtual void start(); virtual void start();
virtual void stop(); virtual void stop();