mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 10:05:46 -05:00
DATV demod: make sure that when baseband rate changes the channelizer is reconfigured to get all available bandwidth
This commit is contained in:
parent
916a284b48
commit
e53da4e9a8
@ -29,7 +29,6 @@
|
||||
#include "dsp/threadedbasebandsamplesink.h"
|
||||
#include "device/devicesourceapi.h"
|
||||
|
||||
|
||||
const QString DATVDemod::m_channelIdURI = "sdrangel.channel.demoddatv";
|
||||
const QString DATVDemod::m_channelId = "DATVDemod";
|
||||
|
||||
@ -40,10 +39,10 @@ DATVDemod::DATVDemod(DeviceSourceAPI *deviceAPI) :
|
||||
ChannelSinkAPI(m_channelIdURI),
|
||||
m_blnNeedConfigUpdate(false),
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_objRegisteredDATVScreen(NULL),
|
||||
m_objRegisteredVideoRender(NULL),
|
||||
m_objVideoStream(NULL),
|
||||
m_objRenderThread(NULL),
|
||||
m_objRegisteredDATVScreen(0),
|
||||
m_objRegisteredVideoRender(0),
|
||||
m_objVideoStream(0),
|
||||
m_objRenderThread(0),
|
||||
m_blnRenderingVideo(false),
|
||||
m_enmModulation(BPSK /*DATV_FM1*/),
|
||||
m_objSettingsMutex(QMutex::NonRecursive)
|
||||
@ -65,14 +64,12 @@ DATVDemod::DATVDemod(DeviceSourceAPI *deviceAPI) :
|
||||
m_deviceAPI->addChannelAPI(this);
|
||||
|
||||
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
|
||||
|
||||
}
|
||||
|
||||
DATVDemod::~DATVDemod()
|
||||
{
|
||||
m_blnInitialized = false;
|
||||
|
||||
|
||||
if (m_objRenderThread != NULL)
|
||||
{
|
||||
if (m_objRenderThread->isRunning())
|
||||
@ -115,7 +112,6 @@ DATVideostream * DATVDemod::SetVideoRender(DATVideoRender *objScreen)
|
||||
return m_objVideoStream;
|
||||
}
|
||||
|
||||
|
||||
bool DATVDemod::PlayVideo(bool blnStartStop)
|
||||
{
|
||||
|
||||
@ -154,7 +150,8 @@ bool DATVDemod::PlayVideo(bool blnStartStop)
|
||||
return true;
|
||||
}
|
||||
|
||||
void DATVDemod::configure(MessageQueue* objMessageQueue,
|
||||
void DATVDemod::configure(
|
||||
MessageQueue* objMessageQueue,
|
||||
int intRFBandwidth,
|
||||
int intCenterFrequency,
|
||||
dvb_version enmStandard,
|
||||
@ -169,11 +166,25 @@ void DATVDemod::configure(MessageQueue* objMessageQueue,
|
||||
bool blnResample,
|
||||
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);
|
||||
}
|
||||
|
||||
void DATVDemod::InitDATVParameters(int intMsps,
|
||||
void DATVDemod::InitDATVParameters(
|
||||
int intMsps,
|
||||
int intRFBandwidth,
|
||||
int intCenterFrequency,
|
||||
dvb_version enmStandard,
|
||||
@ -234,7 +245,6 @@ void DATVDemod::InitDATVParameters(int intMsps,
|
||||
<< " - Resample: " << blnResample
|
||||
<< " - Viterbi: " << blnViterbi;
|
||||
|
||||
|
||||
m_objSettingsMutex.unlock();
|
||||
|
||||
m_blnNeedConfigUpdate = true;
|
||||
@ -393,7 +403,6 @@ void DATVDemod::CleanUpDATVFramework()
|
||||
p_locktime = 0;
|
||||
r_sync_mpeg = 0;
|
||||
|
||||
|
||||
// DEINTERLEAVING
|
||||
p_rspackets = 0;
|
||||
r_deinter = 0;
|
||||
@ -403,22 +412,18 @@ void DATVDemod::CleanUpDATVFramework()
|
||||
p_rtspackets = 0;
|
||||
r_rsdec = 0;
|
||||
|
||||
|
||||
//BER ESTIMATION
|
||||
p_vber = 0;
|
||||
r_vber = 0;
|
||||
|
||||
|
||||
// DERANDOMIZATION
|
||||
p_tspackets = 0;
|
||||
r_derand = 0;
|
||||
|
||||
|
||||
//OUTPUT : To remove
|
||||
r_stdout = 0;
|
||||
r_videoplayer = 0;
|
||||
|
||||
|
||||
//CONSTELLATION
|
||||
r_scope_symbols = 0;
|
||||
}
|
||||
@ -485,7 +490,6 @@ void DATVDemod::InitDATVFramework()
|
||||
m_objCfg.resample = m_objRunning.blnResample;
|
||||
m_objCfg.viterbi = m_objRunning.blnViterbi;
|
||||
|
||||
|
||||
// Min buffer size for baseband data
|
||||
// scopes: 1024
|
||||
// ss_estimator: 1024
|
||||
@ -517,7 +521,6 @@ void DATVDemod::InitDATVFramework()
|
||||
|
||||
m_lngExpectedReadIQ = BUF_BASEBAND;
|
||||
|
||||
|
||||
CleanUpDATVFramework();
|
||||
|
||||
m_objScheduler = new scheduler();
|
||||
@ -536,7 +539,6 @@ void DATVDemod::InitDATVFramework()
|
||||
p_preprocessed = p_autonotched;
|
||||
}
|
||||
|
||||
|
||||
// FREQUENCY CORRECTION
|
||||
|
||||
if (m_objCfg.Fderot)
|
||||
@ -584,7 +586,6 @@ void DATVDemod::InitDATVFramework()
|
||||
|
||||
p_resampled = new pipebuf<cf32>(m_objScheduler, "resampled", BUF_BASEBAND);
|
||||
|
||||
|
||||
#if 1 // Cut in middle of roll-off region
|
||||
float Fcut = (m_objCfg.Fm / 2) * (1 + m_objCfg.rolloff / 2) / m_objCfg.Fs;
|
||||
#else // Cut at beginning of roll-off region
|
||||
@ -615,7 +616,6 @@ void DATVDemod::InitDATVFramework()
|
||||
|
||||
//Resampling FS
|
||||
|
||||
|
||||
// Generic constellation receiver
|
||||
|
||||
p_symbols = new pipebuf<softsymbol>(m_objScheduler, "PSK soft-symbols", BUF_SYMBOLS);
|
||||
@ -637,7 +637,6 @@ void DATVDemod::InitDATVFramework()
|
||||
case SAMP_RRC:
|
||||
{
|
||||
|
||||
|
||||
if (m_objCfg.rrc_steps == 0)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
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.
|
||||
// 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);
|
||||
@ -710,7 +709,6 @@ void DATVDemod::InitDATVFramework()
|
||||
r_resample->freq_tol = m_objCfg.Fm / (m_objCfg.Fs * decim) * 0.1;
|
||||
}
|
||||
|
||||
|
||||
if (r_cnr)
|
||||
{
|
||||
r_cnr->freq_tap = &m_objDemodulator->freq_tap;
|
||||
@ -752,7 +750,6 @@ void DATVDemod::InitDATVFramework()
|
||||
r_deconv->fastlock = m_objCfg.fastlock;
|
||||
}
|
||||
|
||||
|
||||
if (m_objCfg.hdlc)
|
||||
{
|
||||
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);
|
||||
r_deinter = new deinterleaver<u8>(m_objScheduler, *p_mpegbytes, *p_rspackets);
|
||||
|
||||
|
||||
// REED-SOLOMON
|
||||
|
||||
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);
|
||||
r_rsdec = new rs_decoder<u8, 0>(m_objScheduler, *p_rspackets, *p_rtspackets, p_vbitcount, p_verrcount);
|
||||
|
||||
|
||||
// BER ESTIMATION
|
||||
|
||||
|
||||
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->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;
|
||||
}
|
||||
|
||||
|
||||
// DERANDOMIZATION
|
||||
|
||||
p_tspackets = new pipebuf<tspacket>(m_objScheduler, "TS packets", BUF_PACKETS);
|
||||
r_derand = new derandomizer(m_objScheduler, *p_rtspackets, *p_tspackets);
|
||||
|
||||
|
||||
// OUTPUT
|
||||
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;
|
||||
int intRFOut;
|
||||
|
||||
|
||||
#ifdef EXTENDED_DIRECT_SAMPLE
|
||||
|
||||
qint16 * ptrBufferToRelease=NULL;
|
||||
@ -860,7 +851,6 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
|
||||
fltQ = it->imag();
|
||||
#endif
|
||||
|
||||
|
||||
//********** demodulation **********
|
||||
|
||||
if ((m_blnDVBInitialized == false) || (m_blnNeedConfigUpdate == true))
|
||||
@ -911,7 +901,6 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//********** demodulation **********
|
||||
|
||||
}
|
||||
@ -939,24 +928,21 @@ void DATVDemod::stop()
|
||||
|
||||
bool DATVDemod::handleMessage(const Message& cmd)
|
||||
{
|
||||
qDebug() << "DATVDemod::handleMessage";
|
||||
|
||||
if (DownChannelizer::MsgChannelizerNotification::match(cmd))
|
||||
{
|
||||
DownChannelizer::MsgChannelizerNotification& objNotif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
||||
|
||||
qDebug() << "DATVDemod::handleMessage: MsgChannelizerNotification:" << " intMsps: " << objNotif.getSampleRate();
|
||||
|
||||
if (m_objRunning.intMsps != objNotif.getSampleRate())
|
||||
{
|
||||
m_objRunning.intMsps = objNotif.getSampleRate();
|
||||
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();
|
||||
}
|
||||
|
||||
qDebug() << "DATVDemod::handleMessage: MsgChannelizerNotification:"
|
||||
<< " intMsps: " << m_objRunning.intMsps;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureChannelizer::match(cmd))
|
||||
@ -964,34 +950,28 @@ bool DATVDemod::handleMessage(const Message& cmd)
|
||||
|
||||
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
|
||||
|
||||
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
||||
m_channelizer->getInputSampleRate(),
|
||||
cfg.getCenterFrequency());
|
||||
//m_objRunning.intCenterFrequency);
|
||||
|
||||
qDebug() << "DATVDemod::handleMessage: MsgConfigureChannelizer: sampleRate: " << m_channelizer->getInputSampleRate()
|
||||
qDebug() << "DATVDemod::handleMessage: MsgConfigureChannelizer:"
|
||||
<< " sampleRate: " << m_channelizer->getInputSampleRate()
|
||||
<< " centerFrequency: " << cfg.getCenterFrequency();
|
||||
|
||||
m_channelizer->configure(m_channelizer->getInputMessageQueue(), m_channelizer->getInputSampleRate(), cfg.getCenterFrequency());
|
||||
//m_objRunning.intCenterFrequency);
|
||||
//<< " centerFrequency: " << m_objRunning.intCenterFrequency;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureDATVDemod::match(cmd))
|
||||
{
|
||||
qDebug() << "DATVDemod::handleMessage: MsgConfigureDATVDemod";
|
||||
|
||||
MsgConfigureDATVDemod& objCfg = (MsgConfigureDATVDemod&) cmd;
|
||||
|
||||
|
||||
if((objCfg.m_objMsgConfig.blnAllowDrift != m_objRunning.blnAllowDrift)
|
||||
|| (objCfg.m_objMsgConfig.intRFBandwidth != m_objRunning.intRFBandwidth)
|
||||
|| (objCfg.m_objMsgConfig.intCenterFrequency != m_objRunning.intCenterFrequency)
|
||||
|| (objCfg.m_objMsgConfig.blnFastLock != m_objRunning.blnFastLock)
|
||||
|| (objCfg.m_objMsgConfig.blnHardMetric != m_objRunning.blnHardMetric)
|
||||
|| (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)
|
||||
if ((objCfg.m_objMsgConfig.blnAllowDrift != m_objRunning.blnAllowDrift) || (objCfg.m_objMsgConfig.intRFBandwidth != m_objRunning.intRFBandwidth)
|
||||
|| (objCfg.m_objMsgConfig.intCenterFrequency != m_objRunning.intCenterFrequency) || (objCfg.m_objMsgConfig.blnFastLock != m_objRunning.blnFastLock)
|
||||
|| (objCfg.m_objMsgConfig.blnHardMetric != m_objRunning.blnHardMetric) || (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))
|
||||
{
|
||||
m_objRunning.blnAllowDrift = objCfg.m_objMsgConfig.blnAllowDrift;
|
||||
@ -1011,7 +991,11 @@ bool DATVDemod::handleMessage(const Message& cmd)
|
||||
ApplySettings();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (DSPSignalNotification::match(cmd))
|
||||
{
|
||||
qDebug() << "DATVDemod::handleMessage: DSPSignalNotification";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -1030,7 +1014,8 @@ void DATVDemod::ApplySettings()
|
||||
|
||||
//m_objSettingsMutex.lock();
|
||||
|
||||
InitDATVParameters(m_objRunning.intMsps,
|
||||
InitDATVParameters(
|
||||
m_objRunning.intMsps,
|
||||
m_objRunning.intRFBandwidth,
|
||||
m_objRunning.intCenterFrequency,
|
||||
m_objRunning.enmStandard,
|
||||
@ -1053,3 +1038,10 @@ int DATVDemod::GetSampleRate()
|
||||
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
|
||||
}
|
||||
|
@ -496,6 +496,8 @@ private:
|
||||
|
||||
void ApplySettings();
|
||||
|
||||
private slots:
|
||||
void channelSampleRateChanged();
|
||||
};
|
||||
|
||||
#endif // INCLUDE_DATVDEMOD_H
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
|
||||
void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency);
|
||||
int getInputSampleRate() const { return m_inputSampleRate; }
|
||||
int getRequestedCenterFrequency() const { return m_requestedCenterFrequency; }
|
||||
|
||||
virtual void start();
|
||||
virtual void stop();
|
||||
|
Loading…
Reference in New Issue
Block a user