mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 12:51:49 -05:00
DATV demod: formatted code
This commit is contained in:
parent
18e20d36bf
commit
7b9cb0e9fe
@ -24,8 +24,7 @@
|
||||
#include "leansdr/framework.h"
|
||||
#include "gui/tvscreen.h"
|
||||
|
||||
namespace leansdr
|
||||
{
|
||||
namespace leansdr {
|
||||
|
||||
static const int DEFAULT_GUI_DECIMATION = 64;
|
||||
|
||||
@ -41,7 +40,13 @@ template<typename T> struct datvconstellation: runnable
|
||||
std::vector<int> cstln_rows;
|
||||
std::vector<int> cstln_cols;
|
||||
|
||||
datvconstellation(scheduler *sch, pipebuf<complex<T> > &_in, T _xymin, T _xymax, const char *_name = 0, TVScreen *objDATVScreen = 0) :
|
||||
datvconstellation(
|
||||
scheduler *sch,
|
||||
pipebuf<complex<T> > &_in,
|
||||
T _xymin,
|
||||
T _xymax,
|
||||
const char *_name = nullptr,
|
||||
TVScreen *objDATVScreen = nullptr) :
|
||||
runnable(sch, _name ? _name : _in.name),
|
||||
xymin(_xymin),
|
||||
xymax(_xymax),
|
||||
@ -57,7 +62,6 @@ template<typename T> struct datvconstellation: runnable
|
||||
void run()
|
||||
{
|
||||
//Symbols
|
||||
|
||||
while (in.readable() >= pixels_per_frame)
|
||||
{
|
||||
if ((!phase) && m_objDATVScreen)
|
||||
@ -69,17 +73,18 @@ template<typename T> struct datvconstellation: runnable
|
||||
for (; p < pend; ++p)
|
||||
{
|
||||
m_objDATVScreen->selectRow(256 * (p->re - xymin) / (xymax - xymin));
|
||||
m_objDATVScreen->setDataColor(256 - 256 * ((p->im - xymin) / (xymax - xymin)), 255, 0, 255);
|
||||
m_objDATVScreen->setDataColor(
|
||||
256 - 256 * ((p->im - xymin) / (xymax - xymin)),
|
||||
255, 0, 255);
|
||||
}
|
||||
|
||||
if (cstln && (*cstln))
|
||||
{
|
||||
// Plot constellation points
|
||||
|
||||
std::vector<int>::const_iterator row_it = cstln_rows.begin();
|
||||
std::vector<int>::const_iterator col_it = cstln_cols.begin();
|
||||
|
||||
for (; (row_it != cstln_rows.end()) && (col_it != cstln_cols.end()); ++row_it, ++col_it)
|
||||
for (;(row_it != cstln_rows.end()) && (col_it != cstln_cols.end()); ++row_it, ++col_it)
|
||||
{
|
||||
m_objDATVScreen->selectRow(*row_it);
|
||||
m_objDATVScreen->setDataColor(*col_it, 250, 250, 5);
|
||||
@ -91,8 +96,7 @@ template<typename T> struct datvconstellation: runnable
|
||||
|
||||
in.read(pixels_per_frame);
|
||||
|
||||
if (++phase >= decimation)
|
||||
{
|
||||
if (++phase >= decimation) {
|
||||
phase = 0;
|
||||
}
|
||||
}
|
||||
@ -128,6 +132,6 @@ template<typename T> struct datvconstellation: runnable
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // leansdr
|
||||
|
||||
#endif // DATVCONSTELLATION_H
|
||||
|
@ -41,8 +41,8 @@ DATVDemod::DATVDemod(DeviceSourceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_objRegisteredTVScreen(0),
|
||||
m_objRegisteredVideoRender(0),
|
||||
m_objVideoStream(NULL),
|
||||
m_objRenderThread(NULL),
|
||||
m_objVideoStream(nullptr),
|
||||
m_objRenderThread(nullptr),
|
||||
m_blnRenderingVideo(false),
|
||||
m_blnStartStopVideo(false),
|
||||
m_enmModulation(BPSK /*DATV_FM1*/),
|
||||
@ -68,13 +68,13 @@ DATVDemod::~DATVDemod()
|
||||
{
|
||||
m_blnInitialized=false;
|
||||
|
||||
if(m_objVideoStream!=NULL)
|
||||
if(m_objVideoStream!=nullptr)
|
||||
{
|
||||
//Immediately exit from DATVideoStream if waiting for data before killing thread
|
||||
m_objVideoStream->ThreadTimeOut=0;
|
||||
}
|
||||
|
||||
if(m_objRenderThread!=NULL)
|
||||
if(m_objRenderThread!=nullptr)
|
||||
{
|
||||
if(m_objRenderThread->isRunning())
|
||||
{
|
||||
@ -113,46 +113,40 @@ DATVideostream * DATVDemod::SetVideoRender(DATVideoRender *objScreen)
|
||||
bool DATVDemod::PlayVideo(bool blnStartStop)
|
||||
{
|
||||
|
||||
if(m_objVideoStream==NULL)
|
||||
{
|
||||
if (m_objVideoStream == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_objRegisteredVideoRender==NULL)
|
||||
{
|
||||
if (m_objRegisteredVideoRender == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_objRenderThread==NULL)
|
||||
{
|
||||
if (m_objRenderThread == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_blnStartStopVideo && !blnStartStop)
|
||||
{
|
||||
if (m_blnStartStopVideo && !blnStartStop) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(blnStartStop==true)
|
||||
{
|
||||
m_blnStartStopVideo=true;
|
||||
if (blnStartStop == true) {
|
||||
m_blnStartStopVideo = true;
|
||||
}
|
||||
|
||||
if(m_objRenderThread->isRunning())
|
||||
{
|
||||
if(blnStartStop==true)
|
||||
if (m_objRenderThread->isRunning())
|
||||
{
|
||||
if (blnStartStop == true) {
|
||||
m_objRenderThread->stopRendering();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m_objVideoStream->bytesAvailable()>0)
|
||||
if (m_objVideoStream->bytesAvailable() > 0)
|
||||
{
|
||||
m_objRenderThread->setStreamAndRenderer(m_objRegisteredVideoRender,m_objVideoStream);
|
||||
m_objVideoStream->MultiThreaded=true;
|
||||
m_objVideoStream->ThreadTimeOut=5000; //5000 ms
|
||||
m_objRenderThread->setStreamAndRenderer(m_objRegisteredVideoRender, m_objVideoStream);
|
||||
m_objVideoStream->MultiThreaded = true;
|
||||
m_objVideoStream->ThreadTimeOut = 5000; //5000 ms
|
||||
m_objRenderThread->start();
|
||||
}
|
||||
|
||||
@ -238,9 +232,9 @@ void DATVDemod::InitDATVParameters(int intMsps,
|
||||
|
||||
void DATVDemod::CleanUpDATVFramework(bool blnRelease)
|
||||
{
|
||||
if(blnRelease==true)
|
||||
if (blnRelease == true)
|
||||
{
|
||||
if(m_objScheduler!=NULL)
|
||||
if (m_objScheduler != nullptr)
|
||||
{
|
||||
m_objScheduler->shutdown();
|
||||
delete m_objScheduler;
|
||||
@ -248,181 +242,264 @@ void DATVDemod::CleanUpDATVFramework(bool blnRelease)
|
||||
|
||||
// NOTCH FILTER
|
||||
|
||||
if(r_auto_notch!=NULL) delete r_auto_notch;
|
||||
if(p_autonotched!=NULL) delete p_autonotched;
|
||||
|
||||
// FREQUENCY CORRECTION : DEROTATOR
|
||||
if(p_derot!=NULL) delete p_derot;
|
||||
if(r_derot!=NULL) delete r_derot;
|
||||
|
||||
// CNR ESTIMATION
|
||||
if(p_cnr!=NULL) delete p_cnr;
|
||||
if(r_cnr!=NULL) delete r_cnr;
|
||||
|
||||
//FILTERING
|
||||
if(r_resample!=NULL) delete r_resample;
|
||||
if(p_resampled!=NULL) delete p_resampled;
|
||||
if(coeffs!=NULL) delete coeffs;
|
||||
|
||||
// OUTPUT PREPROCESSED DATA
|
||||
if(sampler!=NULL) delete sampler;
|
||||
if(coeffs_sampler!=NULL) delete coeffs_sampler;
|
||||
if(p_symbols!=NULL) delete p_symbols;
|
||||
if(p_freq!=NULL) delete p_freq;
|
||||
if(p_ss!=NULL) delete p_ss;
|
||||
if(p_mer!=NULL) delete p_mer;
|
||||
if(p_sampled!=NULL) delete p_sampled;
|
||||
|
||||
//DECIMATION
|
||||
if(p_decimated!=NULL) delete p_decimated;
|
||||
if(p_decim!=NULL) delete p_decim;
|
||||
if(r_ppout!=NULL) delete r_ppout;
|
||||
|
||||
|
||||
//GENERIC CONSTELLATION RECEIVER
|
||||
if(m_objDemodulator!=NULL) delete m_objDemodulator;
|
||||
|
||||
//DECONVOLUTION AND SYNCHRONIZATION
|
||||
if(p_bytes!=NULL) delete p_bytes;
|
||||
if(r_deconv!=NULL) delete r_deconv;
|
||||
if(r!=NULL) delete r;
|
||||
if(p_descrambled!=NULL) delete p_descrambled;
|
||||
if(p_frames!=NULL) delete p_frames;
|
||||
if(r_etr192_descrambler!=NULL) delete r_etr192_descrambler;
|
||||
if(r_sync!=NULL) delete r_sync;
|
||||
if(p_mpegbytes!=NULL) delete p_mpegbytes;
|
||||
if(p_lock!=NULL) delete p_lock;
|
||||
if(p_locktime!=NULL) delete p_locktime;
|
||||
if(r_sync_mpeg!=NULL) delete r_sync_mpeg;
|
||||
|
||||
|
||||
// DEINTERLEAVING
|
||||
if(p_rspackets!=NULL) delete p_rspackets;
|
||||
if(r_deinter!=NULL) delete r_deinter;
|
||||
if(p_vbitcount!=NULL) delete p_vbitcount;
|
||||
if(p_verrcount!=NULL) delete p_verrcount;
|
||||
if(p_rtspackets!=NULL) delete p_rtspackets;
|
||||
if(r_rsdec!=NULL) delete r_rsdec;
|
||||
|
||||
//BER ESTIMATION
|
||||
if(p_vber!=NULL) delete p_vber;
|
||||
if(r_vber!=NULL) delete r_vber;
|
||||
|
||||
// DERANDOMIZATION
|
||||
if(p_tspackets!=NULL) delete p_tspackets;
|
||||
if(r_derand!=NULL) delete r_derand;
|
||||
|
||||
|
||||
//OUTPUT : To remove
|
||||
if(r_stdout!=NULL) delete r_stdout;
|
||||
if(r_videoplayer!=NULL) delete r_videoplayer;
|
||||
|
||||
//CONSTELLATION
|
||||
if(r_scope_symbols!=NULL) delete r_scope_symbols;
|
||||
|
||||
// INPUT
|
||||
//if(p_rawiq!=NULL) delete p_rawiq;
|
||||
//if(p_rawiq_writer!=NULL) delete p_rawiq_writer;
|
||||
//if(p_preprocessed!=NULL) delete p_preprocessed;
|
||||
|
||||
|
||||
if (r_auto_notch != nullptr) {
|
||||
delete r_auto_notch;
|
||||
}
|
||||
if (p_autonotched != nullptr) {
|
||||
delete p_autonotched;
|
||||
}
|
||||
|
||||
m_objScheduler=NULL;
|
||||
// FREQUENCY CORRECTION : DEROTATOR
|
||||
if (p_derot != nullptr) {
|
||||
delete p_derot;
|
||||
}
|
||||
if (r_derot != nullptr) {
|
||||
delete r_derot;
|
||||
}
|
||||
|
||||
// CNR ESTIMATION
|
||||
if (p_cnr != nullptr) {
|
||||
delete p_cnr;
|
||||
}
|
||||
if (r_cnr != nullptr) {
|
||||
delete r_cnr;
|
||||
}
|
||||
|
||||
//FILTERING
|
||||
if (r_resample != nullptr) {
|
||||
delete r_resample;
|
||||
}
|
||||
if (p_resampled != nullptr) {
|
||||
delete p_resampled;
|
||||
}
|
||||
if (coeffs != nullptr) {
|
||||
delete coeffs;
|
||||
}
|
||||
|
||||
// OUTPUT PREPROCESSED DATA
|
||||
if (sampler != nullptr) {
|
||||
delete sampler;
|
||||
}
|
||||
if (coeffs_sampler != nullptr) {
|
||||
delete coeffs_sampler;
|
||||
}
|
||||
if (p_symbols != nullptr) {
|
||||
delete p_symbols;
|
||||
}
|
||||
if (p_freq != nullptr) {
|
||||
delete p_freq;
|
||||
}
|
||||
if (p_ss != nullptr) {
|
||||
delete p_ss;
|
||||
}
|
||||
if (p_mer != nullptr) {
|
||||
delete p_mer;
|
||||
}
|
||||
if (p_sampled != nullptr) {
|
||||
delete p_sampled;
|
||||
}
|
||||
|
||||
//DECIMATION
|
||||
if (p_decimated != nullptr) {
|
||||
delete p_decimated;
|
||||
}
|
||||
if (p_decim != nullptr) {
|
||||
delete p_decim;
|
||||
}
|
||||
if (r_ppout != nullptr) {
|
||||
delete r_ppout;
|
||||
}
|
||||
|
||||
//GENERIC CONSTELLATION RECEIVER
|
||||
if (m_objDemodulator != nullptr) {
|
||||
delete m_objDemodulator;
|
||||
}
|
||||
|
||||
//DECONVOLUTION AND SYNCHRONIZATION
|
||||
if (p_bytes != nullptr) {
|
||||
delete p_bytes;
|
||||
}
|
||||
if (r_deconv != nullptr) {
|
||||
delete r_deconv;
|
||||
}
|
||||
if (r != nullptr) {
|
||||
delete r;
|
||||
}
|
||||
if (p_descrambled != nullptr) {
|
||||
delete p_descrambled;
|
||||
}
|
||||
if (p_frames != nullptr) {
|
||||
delete p_frames;
|
||||
}
|
||||
if (r_etr192_descrambler != nullptr) {
|
||||
delete r_etr192_descrambler;
|
||||
}
|
||||
if (r_sync != nullptr) {
|
||||
delete r_sync;
|
||||
}
|
||||
if (p_mpegbytes != nullptr) {
|
||||
delete p_mpegbytes;
|
||||
}
|
||||
if (p_lock != nullptr) {
|
||||
delete p_lock;
|
||||
}
|
||||
if (p_locktime != nullptr) {
|
||||
delete p_locktime;
|
||||
}
|
||||
if (r_sync_mpeg != nullptr) {
|
||||
delete r_sync_mpeg;
|
||||
}
|
||||
|
||||
// DEINTERLEAVING
|
||||
if (p_rspackets != nullptr) {
|
||||
delete p_rspackets;
|
||||
}
|
||||
if (r_deinter != nullptr) {
|
||||
delete r_deinter;
|
||||
}
|
||||
if (p_vbitcount != nullptr) {
|
||||
delete p_vbitcount;
|
||||
}
|
||||
if (p_verrcount != nullptr) {
|
||||
delete p_verrcount;
|
||||
}
|
||||
if (p_rtspackets != nullptr) {
|
||||
delete p_rtspackets;
|
||||
}
|
||||
if (r_rsdec != nullptr) {
|
||||
delete r_rsdec;
|
||||
}
|
||||
|
||||
//BER ESTIMATION
|
||||
if (p_vber != nullptr) {
|
||||
delete p_vber;
|
||||
}
|
||||
if (r_vber != nullptr) {
|
||||
delete r_vber;
|
||||
}
|
||||
|
||||
// DERANDOMIZATION
|
||||
if (p_tspackets != nullptr) {
|
||||
delete p_tspackets;
|
||||
}
|
||||
if (r_derand != nullptr) {
|
||||
delete r_derand;
|
||||
}
|
||||
|
||||
//OUTPUT : To remove
|
||||
if (r_stdout != nullptr) {
|
||||
delete r_stdout;
|
||||
}
|
||||
if (r_videoplayer != nullptr) {
|
||||
delete r_videoplayer;
|
||||
}
|
||||
|
||||
//CONSTELLATION
|
||||
if (r_scope_symbols != nullptr) {
|
||||
delete r_scope_symbols;
|
||||
}
|
||||
|
||||
// INPUT
|
||||
//if(p_rawiq!=nullptr) delete p_rawiq;
|
||||
//if(p_rawiq_writer!=nullptr) delete p_rawiq_writer;
|
||||
//if(p_preprocessed!=nullptr) delete p_preprocessed;
|
||||
}
|
||||
|
||||
m_objScheduler=nullptr;
|
||||
|
||||
// INPUT
|
||||
|
||||
p_rawiq = NULL;
|
||||
p_rawiq_writer = NULL;
|
||||
p_rawiq = nullptr;
|
||||
p_rawiq_writer = nullptr;
|
||||
|
||||
p_preprocessed = NULL;
|
||||
p_preprocessed = nullptr;
|
||||
|
||||
// NOTCH FILTER
|
||||
r_auto_notch = NULL;
|
||||
p_autonotched = NULL;
|
||||
r_auto_notch = nullptr;
|
||||
p_autonotched = nullptr;
|
||||
|
||||
// FREQUENCY CORRECTION : DEROTATOR
|
||||
p_derot = NULL;
|
||||
r_derot=NULL;
|
||||
p_derot = nullptr;
|
||||
r_derot=nullptr;
|
||||
|
||||
// CNR ESTIMATION
|
||||
p_cnr = NULL;
|
||||
r_cnr = NULL;
|
||||
p_cnr = nullptr;
|
||||
r_cnr = nullptr;
|
||||
|
||||
//FILTERING
|
||||
r_resample = NULL;
|
||||
p_resampled = NULL;
|
||||
coeffs = NULL;
|
||||
r_resample = nullptr;
|
||||
p_resampled = nullptr;
|
||||
coeffs = nullptr;
|
||||
ncoeffs=0;
|
||||
|
||||
// OUTPUT PREPROCESSED DATA
|
||||
sampler = NULL;
|
||||
coeffs_sampler=NULL;
|
||||
sampler = nullptr;
|
||||
coeffs_sampler=nullptr;
|
||||
ncoeffs_sampler=0;
|
||||
|
||||
p_symbols = NULL;
|
||||
p_freq = NULL;
|
||||
p_ss = NULL;
|
||||
p_mer = NULL;
|
||||
p_sampled = NULL;
|
||||
p_symbols = nullptr;
|
||||
p_freq = nullptr;
|
||||
p_ss = nullptr;
|
||||
p_mer = nullptr;
|
||||
p_sampled = nullptr;
|
||||
|
||||
//DECIMATION
|
||||
p_decimated = NULL;
|
||||
p_decim = NULL;
|
||||
r_ppout = NULL;
|
||||
p_decimated = nullptr;
|
||||
p_decim = nullptr;
|
||||
r_ppout = nullptr;
|
||||
|
||||
//GENERIC CONSTELLATION RECEIVER
|
||||
m_objDemodulator = NULL;
|
||||
m_objDemodulator = nullptr;
|
||||
|
||||
//DECONVOLUTION AND SYNCHRONIZATION
|
||||
p_bytes=NULL;
|
||||
r_deconv=NULL;
|
||||
r = NULL;
|
||||
p_bytes=nullptr;
|
||||
r_deconv=nullptr;
|
||||
r = nullptr;
|
||||
|
||||
p_descrambled = NULL;
|
||||
p_frames = NULL;
|
||||
r_etr192_descrambler = NULL;
|
||||
r_sync = NULL;
|
||||
p_descrambled = nullptr;
|
||||
p_frames = nullptr;
|
||||
r_etr192_descrambler = nullptr;
|
||||
r_sync = nullptr;
|
||||
|
||||
p_mpegbytes = NULL;
|
||||
p_lock = NULL;
|
||||
p_locktime = NULL;
|
||||
r_sync_mpeg = NULL;
|
||||
p_mpegbytes = nullptr;
|
||||
p_lock = nullptr;
|
||||
p_locktime = nullptr;
|
||||
r_sync_mpeg = nullptr;
|
||||
|
||||
|
||||
// DEINTERLEAVING
|
||||
p_rspackets = NULL;
|
||||
r_deinter = NULL;
|
||||
p_rspackets = nullptr;
|
||||
r_deinter = nullptr;
|
||||
|
||||
p_vbitcount = NULL;
|
||||
p_verrcount = NULL;
|
||||
p_rtspackets = NULL;
|
||||
r_rsdec = NULL;
|
||||
p_vbitcount = nullptr;
|
||||
p_verrcount = nullptr;
|
||||
p_rtspackets = nullptr;
|
||||
r_rsdec = nullptr;
|
||||
|
||||
|
||||
//BER ESTIMATION
|
||||
p_vber = NULL;
|
||||
r_vber = NULL;
|
||||
p_vber = nullptr;
|
||||
r_vber = nullptr;
|
||||
|
||||
|
||||
// DERANDOMIZATION
|
||||
p_tspackets = NULL;
|
||||
r_derand = NULL;
|
||||
p_tspackets = nullptr;
|
||||
r_derand = nullptr;
|
||||
|
||||
|
||||
//OUTPUT : To remove
|
||||
r_stdout = NULL;
|
||||
r_videoplayer = NULL;
|
||||
r_stdout = nullptr;
|
||||
r_videoplayer = nullptr;
|
||||
|
||||
|
||||
//CONSTELLATION
|
||||
r_scope_symbols = NULL;
|
||||
r_scope_symbols = nullptr;
|
||||
}
|
||||
|
||||
void DATVDemod::InitDATVFramework()
|
||||
{
|
||||
m_blnDVBInitialized=false;
|
||||
m_lngReadIQ=0;
|
||||
m_blnDVBInitialized = false;
|
||||
m_lngReadIQ = 0;
|
||||
CleanUpDATVFramework(false);
|
||||
|
||||
qDebug() << "DATVDemod::InitDATVParameters:"
|
||||
@ -447,48 +524,39 @@ void DATVDemod::InitDATVFramework()
|
||||
m_objCfg.fastlock = m_objRunning.blnFastLock;
|
||||
|
||||
m_objCfg.sampler = m_objRunning.enmFilter;
|
||||
m_objCfg.rolloff=m_objRunning.fltRollOff; //0...1
|
||||
m_objCfg.rrc_rej=(float) m_objRunning.intExcursion; //dB
|
||||
m_objCfg.rrc_steps=0; //auto
|
||||
m_objCfg.rolloff = m_objRunning.fltRollOff; //0...1
|
||||
m_objCfg.rrc_rej = (float) m_objRunning.intExcursion; //dB
|
||||
m_objCfg.rrc_steps = 0; //auto
|
||||
|
||||
switch(m_objRunning.enmModulation)
|
||||
{
|
||||
case BPSK:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::BPSK;
|
||||
break;
|
||||
|
||||
case QPSK:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::QPSK;
|
||||
break;
|
||||
|
||||
case PSK8:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::PSK8;
|
||||
break;
|
||||
|
||||
case APSK16:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::APSK16;
|
||||
break;
|
||||
|
||||
case APSK32:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::APSK32;
|
||||
break;
|
||||
|
||||
case APSK64E:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::APSK64E;
|
||||
break;
|
||||
|
||||
case QAM16:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::QAM16;
|
||||
break;
|
||||
|
||||
case QAM64:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::QAM64;
|
||||
break;
|
||||
|
||||
case QAM256:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::QAM256;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_objCfg.constellation = leansdr::cstln_lut<256>::BPSK;
|
||||
break;
|
||||
@ -541,7 +609,7 @@ void DATVDemod::InitDATVFramework()
|
||||
|
||||
// NOTCH FILTER
|
||||
|
||||
if ( m_objCfg.anf>0 )
|
||||
if (m_objCfg.anf>0)
|
||||
{
|
||||
p_autonotched = new leansdr::pipebuf<leansdr::cf32>(m_objScheduler, "autonotched", BUF_BASEBAND);
|
||||
r_auto_notch = new leansdr::auto_notch<leansdr::f32>(m_objScheduler, *p_preprocessed, *p_autonotched, m_objCfg.anf, 0);
|
||||
@ -557,7 +625,7 @@ void DATVDemod::InitDATVFramework()
|
||||
|
||||
p_cnr = new leansdr::pipebuf<leansdr::f32>(m_objScheduler, "cnr", BUF_SLOW);
|
||||
|
||||
if ( m_objCfg.cnr==true )
|
||||
if (m_objCfg.cnr == true)
|
||||
{
|
||||
r_cnr = new leansdr::cnr_fft<leansdr::f32>(m_objScheduler, *p_preprocessed, *p_cnr, m_objCfg.Fm/m_objCfg.Fs);
|
||||
r_cnr->decimation = decimation(m_objCfg.Fs, 1); // 1 Hz
|
||||
@ -586,21 +654,17 @@ void DATVDemod::InitDATVFramework()
|
||||
p_mer = new leansdr::pipebuf<leansdr::f32> (m_objScheduler, "MER", BUF_SLOW);
|
||||
p_sampled = new leansdr::pipebuf<leansdr::cf32> (m_objScheduler, "PSK symbols", BUF_BASEBAND);
|
||||
|
||||
switch ( m_objCfg.sampler )
|
||||
switch (m_objCfg.sampler)
|
||||
{
|
||||
case SAMP_NEAREST:
|
||||
sampler = new leansdr::nearest_sampler<float>();
|
||||
break;
|
||||
|
||||
case SAMP_LINEAR:
|
||||
sampler = new leansdr::linear_sampler<float>();
|
||||
break;
|
||||
|
||||
case SAMP_RRC:
|
||||
{
|
||||
|
||||
|
||||
if ( m_objCfg.rrc_steps == 0 )
|
||||
if (m_objCfg.rrc_steps == 0)
|
||||
{
|
||||
// At least 64 discrete sampling points between symbols
|
||||
m_objCfg.rrc_steps = std::max(1, (int)(64*m_objCfg.Fm / m_objCfg.Fs));
|
||||
@ -610,37 +674,43 @@ void DATVDemod::InitDATVFramework()
|
||||
float transition = (m_objCfg.Fm/2) * m_objCfg.rolloff;
|
||||
int order = m_objCfg.rrc_rej * Frrc / (22*transition);
|
||||
ncoeffs_sampler = leansdr::filtergen::root_raised_cosine(order, m_objCfg.Fm/Frrc, m_objCfg.rolloff, &coeffs_sampler);
|
||||
|
||||
sampler = new leansdr::fir_sampler<float,float>(ncoeffs_sampler, coeffs_sampler, m_objCfg.rrc_steps);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
qCritical("DATVDemod::InitDATVFramework: Interpolator not implemented");
|
||||
return;
|
||||
}
|
||||
|
||||
m_objDemodulator = new leansdr::cstln_receiver<leansdr::f32>(m_objScheduler, sampler, *p_preprocessed, *p_symbols, p_freq, p_ss, p_mer, p_sampled);
|
||||
m_objDemodulator = new leansdr::cstln_receiver<leansdr::f32>(
|
||||
m_objScheduler,
|
||||
sampler,
|
||||
*p_preprocessed,
|
||||
*p_symbols,
|
||||
p_freq,
|
||||
p_ss,
|
||||
p_mer,
|
||||
p_sampled);
|
||||
|
||||
if ( m_objCfg.standard == DVB_S )
|
||||
if (m_objCfg.standard == DVB_S)
|
||||
{
|
||||
if ( m_objCfg.constellation != leansdr::cstln_lut<256>::QPSK && m_objCfg.constellation != leansdr::cstln_lut<256>::BPSK )
|
||||
if ( m_objCfg.constellation != leansdr::cstln_lut<256>::QPSK
|
||||
&& m_objCfg.constellation != leansdr::cstln_lut<256>::BPSK )
|
||||
{
|
||||
fprintf(stderr, "Warning: non-standard constellation for DVB-S\n");
|
||||
qWarning("DATVDemod::InitDATVFramework: non-standard constellation for DVB-S");
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_objCfg.standard == DVB_S2 )
|
||||
if (m_objCfg.standard == DVB_S2)
|
||||
{
|
||||
// For DVB-S2 testing only.
|
||||
// Constellation should be determined from PL signalling.
|
||||
fprintf(stderr, "DVB-S2: Testing symbol sampler only.\n");
|
||||
qDebug("DATVDemod::InitDATVFramework: DVB-S2: Testing symbol sampler only.");
|
||||
}
|
||||
|
||||
m_objDemodulator->cstln = make_dvbs2_constellation(m_objCfg.constellation, m_objCfg.fec);
|
||||
|
||||
if ( m_objCfg.hard_metric )
|
||||
{
|
||||
if (m_objCfg.hard_metric) {
|
||||
m_objDemodulator->cstln->harden();
|
||||
}
|
||||
|
||||
@ -651,24 +721,20 @@ void DATVDemod::InitDATVFramework()
|
||||
// m_objDemodulator->set_freq(m_objCfg.Ftune/m_objCfg.Fs);
|
||||
//}
|
||||
|
||||
if ( m_objCfg.allow_drift )
|
||||
{
|
||||
if (m_objCfg.allow_drift) {
|
||||
m_objDemodulator->set_allow_drift(true);
|
||||
}
|
||||
|
||||
//******** -> if ( m_objCfg.viterbi )
|
||||
if ( m_objCfg.viterbi )
|
||||
{
|
||||
if (m_objCfg.viterbi) {
|
||||
m_objDemodulator->pll_adjustment /= 6;
|
||||
}
|
||||
|
||||
|
||||
m_objDemodulator->meas_decimation = decimation(m_objCfg.Fs, m_objCfg.Finfo);
|
||||
|
||||
// TRACKING FILTERS
|
||||
|
||||
|
||||
if ( r_cnr )
|
||||
if (r_cnr)
|
||||
{
|
||||
r_cnr->freq_tap = &m_objDemodulator->freq_tap;
|
||||
r_cnr->tap_multiplier = 1.0 / decim;
|
||||
@ -679,8 +745,7 @@ void DATVDemod::InitDATVFramework()
|
||||
if (m_objRegisteredTVScreen)
|
||||
{
|
||||
m_objRegisteredTVScreen->resizeTVScreen(256,256);
|
||||
|
||||
r_scope_symbols = new leansdr::datvconstellation<leansdr::f32>(m_objScheduler, *p_sampled, -128,128, NULL, m_objRegisteredTVScreen);
|
||||
r_scope_symbols = new leansdr::datvconstellation<leansdr::f32>(m_objScheduler, *p_sampled, -128,128, nullptr, m_objRegisteredTVScreen);
|
||||
r_scope_symbols->decimation = 1;
|
||||
r_scope_symbols->cstln = &m_objDemodulator->cstln;
|
||||
r_scope_symbols->calculate_cstln_points();
|
||||
@ -690,22 +755,20 @@ void DATVDemod::InitDATVFramework()
|
||||
|
||||
p_bytes = new leansdr::pipebuf<leansdr::u8>(m_objScheduler, "bytes", BUF_BYTES);
|
||||
|
||||
r_deconv = NULL;
|
||||
r_deconv = nullptr;
|
||||
|
||||
//******** -> if ( m_objCfg.viterbi )
|
||||
|
||||
if ( m_objCfg.viterbi )
|
||||
{
|
||||
if ( m_objCfg.fec == leansdr::FEC23 && (m_objDemodulator->cstln->nsymbols == 4 || m_objDemodulator->cstln->nsymbols == 64) )
|
||||
if (m_objCfg.viterbi)
|
||||
{
|
||||
if (m_objCfg.fec == leansdr::FEC23 && (m_objDemodulator->cstln->nsymbols == 4 || m_objDemodulator->cstln->nsymbols == 64)) {
|
||||
m_objCfg.fec = leansdr::FEC46;
|
||||
}
|
||||
|
||||
//To uncomment -> Linking Problem : undefined symbol: _ZN7leansdr21viterbi_dec_interfaceIhhiiE6updateEPiS2_
|
||||
r = new leansdr::viterbi_sync(m_objScheduler, (*p_symbols), (*p_bytes), m_objDemodulator->cstln, m_objCfg.fec);
|
||||
|
||||
if ( m_objCfg.fastlock )
|
||||
{
|
||||
if (m_objCfg.fastlock) {
|
||||
r->resync_period = 1;
|
||||
}
|
||||
}
|
||||
@ -726,21 +789,18 @@ void DATVDemod::InitDATVFramework()
|
||||
|
||||
// DEINTERLEAVING
|
||||
|
||||
p_rspackets = new leansdr::pipebuf< leansdr::rspacket<leansdr::u8> >(m_objScheduler, "RS-enc packets", BUF_PACKETS);
|
||||
p_rspackets = new leansdr::pipebuf<leansdr::rspacket<leansdr::u8> >(m_objScheduler, "RS-enc packets", BUF_PACKETS);
|
||||
r_deinter = new leansdr::deinterleaver<leansdr::u8>(m_objScheduler, *p_mpegbytes, *p_rspackets);
|
||||
|
||||
|
||||
// REED-SOLOMON
|
||||
|
||||
p_vbitcount = new leansdr::pipebuf<int>(m_objScheduler, "Bits processed", BUF_PACKETS);
|
||||
p_verrcount = new leansdr::pipebuf<int>(m_objScheduler, "Bits corrected", BUF_PACKETS);
|
||||
p_rtspackets = new leansdr::pipebuf<leansdr::tspacket>(m_objScheduler, "rand TS packets", BUF_PACKETS);
|
||||
r_rsdec = new leansdr::rs_decoder<leansdr::u8, 0> (m_objScheduler, *p_rspackets, *p_rtspackets, p_vbitcount, p_verrcount);
|
||||
|
||||
r_rsdec = new leansdr::rs_decoder<leansdr::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);
|
||||
@ -753,15 +813,13 @@ void DATVDemod::InitDATVFramework()
|
||||
*/
|
||||
|
||||
// DERANDOMIZATION
|
||||
|
||||
p_tspackets = new leansdr::pipebuf<leansdr::tspacket>(m_objScheduler, "TS packets", BUF_PACKETS);
|
||||
r_derand = new leansdr::derandomizer(m_objScheduler, *p_rtspackets, *p_tspackets);
|
||||
|
||||
|
||||
// OUTPUT
|
||||
r_videoplayer = new leansdr::datvvideoplayer<leansdr::tspacket>(m_objScheduler, *p_tspackets,m_objVideoStream);
|
||||
r_videoplayer = new leansdr::datvvideoplayer<leansdr::tspacket>(m_objScheduler, *p_tspackets, m_objVideoStream);
|
||||
|
||||
m_blnDVBInitialized=true;
|
||||
m_blnDVBInitialized = true;
|
||||
}
|
||||
|
||||
void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
|
||||
@ -812,15 +870,10 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
|
||||
|
||||
if (m_blnNeedConfigUpdate)
|
||||
{
|
||||
|
||||
m_objSettingsMutex.lock();
|
||||
|
||||
m_blnNeedConfigUpdate=false;
|
||||
|
||||
InitDATVFramework();
|
||||
|
||||
m_objSettingsMutex.unlock();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -842,8 +895,8 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
|
||||
objRF ++;
|
||||
|
||||
if (m_blnDVBInitialized
|
||||
&& (p_rawiq_writer!=NULL)
|
||||
&& (m_objScheduler!=NULL))
|
||||
&& (p_rawiq_writer!=nullptr)
|
||||
&& (m_objScheduler!=nullptr))
|
||||
{
|
||||
p_rawiq_writer->write(objIQ);
|
||||
m_lngReadIQ++;
|
||||
@ -865,12 +918,10 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
|
||||
|
||||
void DATVDemod::start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DATVDemod::stop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DATVDemod::handleMessage(const Message& cmd)
|
||||
@ -911,7 +962,7 @@ bool DATVDemod::handleMessage(const Message& cmd)
|
||||
MsgConfigureDATVDemod& objCfg = (MsgConfigureDATVDemod&) cmd;
|
||||
|
||||
|
||||
if((objCfg.m_objMsgConfig.blnAllowDrift != m_objRunning.blnAllowDrift)
|
||||
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)
|
||||
@ -971,8 +1022,7 @@ bool DATVDemod::handleMessage(const Message& cmd)
|
||||
|
||||
void DATVDemod::ApplySettings()
|
||||
{
|
||||
if(m_objRunning.intMsps==0)
|
||||
{
|
||||
if (m_objRunning.intMsps == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -998,4 +1048,3 @@ int DATVDemod::GetSampleRate()
|
||||
{
|
||||
return m_objRunning.intMsps;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,6 @@ public:
|
||||
static const QString m_channelIdURI;
|
||||
static const QString m_channelId;
|
||||
|
||||
|
||||
class MsgConfigureChannelizer : public Message
|
||||
{
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
@ -248,8 +247,7 @@ public:
|
||||
public:
|
||||
int getCenterFrequency() const { return m_centerFrequency; }
|
||||
|
||||
static MsgConfigureChannelizer* create(int centerFrequency)
|
||||
{
|
||||
static MsgConfigureChannelizer* create(int centerFrequency) {
|
||||
return new MsgConfigureChannelizer(centerFrequency);
|
||||
}
|
||||
|
||||
@ -259,7 +257,7 @@ public:
|
||||
MsgConfigureChannelizer(int centerFrequency) :
|
||||
Message(),
|
||||
m_centerFrequency(centerFrequency)
|
||||
{ }
|
||||
{}
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -309,16 +309,13 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
|
||||
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
|
||||
|
||||
resetToDefaults(); // does applySettings()
|
||||
|
||||
}
|
||||
|
||||
DATVDemodGUI::~DATVDemodGUI()
|
||||
{
|
||||
|
||||
m_deviceUISet->removeRxChannelInstance(this);
|
||||
delete m_objDATVDemod;
|
||||
delete ui;
|
||||
|
||||
}
|
||||
|
||||
void DATVDemodGUI::blockApplySettings(bool blnBlock)
|
||||
@ -350,125 +347,83 @@ void DATVDemodGUI::applySettings()
|
||||
|
||||
strStandard = ui->cmbStandard->currentText();
|
||||
|
||||
if(strStandard=="DVB-S")
|
||||
{
|
||||
if(strStandard=="DVB-S") {
|
||||
enmVersion=DVB_S;
|
||||
}
|
||||
else if (strStandard=="DVB-S2")
|
||||
{
|
||||
} else if (strStandard=="DVB-S2") {
|
||||
enmVersion=DVB_S2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
enmVersion=DVB_S;
|
||||
}
|
||||
|
||||
|
||||
//BPSK, QPSK, PSK8, APSK16, APSK32, APSK64E, QAM16, QAM64, QAM256
|
||||
|
||||
strModulation = ui->cmbModulation->currentText();
|
||||
|
||||
if(strModulation=="BPSK")
|
||||
{
|
||||
if(strModulation=="BPSK") {
|
||||
enmSelectedModulation=BPSK;
|
||||
}
|
||||
else if(strModulation=="QPSK")
|
||||
{
|
||||
else if(strModulation=="QPSK") {
|
||||
enmSelectedModulation=QPSK;
|
||||
}
|
||||
else if(strModulation=="8PSK")
|
||||
{
|
||||
else if(strModulation=="8PSK") {
|
||||
enmSelectedModulation=PSK8;
|
||||
}
|
||||
else if(strModulation=="16APSK")
|
||||
{
|
||||
else if(strModulation=="16APSK") {
|
||||
enmSelectedModulation=APSK16;
|
||||
}
|
||||
else if(strModulation=="32APSK")
|
||||
{
|
||||
else if(strModulation=="32APSK") {
|
||||
enmSelectedModulation=APSK32;
|
||||
}
|
||||
else if(strModulation=="64APSKE")
|
||||
{
|
||||
else if(strModulation=="64APSKE") {
|
||||
enmSelectedModulation=APSK64E;
|
||||
}
|
||||
else if(strModulation=="16QAM")
|
||||
{
|
||||
else if(strModulation=="16QAM") {
|
||||
enmSelectedModulation=QAM16;
|
||||
}
|
||||
else if(strModulation=="64QAM")
|
||||
{
|
||||
else if(strModulation=="64QAM") {
|
||||
enmSelectedModulation=QAM64;
|
||||
}
|
||||
else if(strModulation=="256QAM")
|
||||
{
|
||||
else if(strModulation=="256QAM") {
|
||||
enmSelectedModulation=QAM256;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
enmSelectedModulation=BPSK;
|
||||
}
|
||||
|
||||
//Viterbi only for BPSK et QPSK
|
||||
if((enmSelectedModulation!=BPSK) && (enmSelectedModulation!=QPSK))
|
||||
{
|
||||
if ((enmSelectedModulation!=BPSK) && (enmSelectedModulation!=QPSK)) {
|
||||
ui->chkViterbi->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
strFEC = ui->cmbFEC->currentText();
|
||||
|
||||
if(strFEC == "1/2")
|
||||
{
|
||||
if (strFEC == "1/2") {
|
||||
enmFEC = leansdr::FEC12;
|
||||
}
|
||||
else if(strFEC == "2/3")
|
||||
{
|
||||
} else if (strFEC == "2/3") {
|
||||
enmFEC = leansdr::FEC23;
|
||||
}
|
||||
else if(strFEC == "3/4")
|
||||
{
|
||||
} else if (strFEC == "3/4") {
|
||||
enmFEC = leansdr::FEC34;
|
||||
}
|
||||
else if(strFEC == "5/6")
|
||||
{
|
||||
} else if (strFEC == "5/6") {
|
||||
enmFEC = leansdr::FEC56;
|
||||
}
|
||||
else if(strFEC == "7/8")
|
||||
{
|
||||
} else if (strFEC == "7/8") {
|
||||
enmFEC = leansdr::FEC78;
|
||||
}
|
||||
else if(strFEC == "4/5")
|
||||
{
|
||||
} else if (strFEC == "4/5") {
|
||||
enmFEC = leansdr::FEC45;
|
||||
}
|
||||
else if(strFEC == "8/9")
|
||||
{
|
||||
} else if (strFEC == "8/9") {
|
||||
enmFEC = leansdr::FEC89;
|
||||
}
|
||||
else if(strFEC == "9/10")
|
||||
{
|
||||
} else if (strFEC == "9/10") {
|
||||
enmFEC = leansdr::FEC910;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
enmFEC = leansdr::FEC12;
|
||||
}
|
||||
|
||||
if (ui->cmbFilter->currentIndex()==0)
|
||||
{
|
||||
if (ui->cmbFilter->currentIndex() == 0) {
|
||||
enmSampler = SAMP_LINEAR;
|
||||
}
|
||||
else if(ui->cmbFilter->currentIndex()==1)
|
||||
{
|
||||
} else if (ui->cmbFilter->currentIndex() == 1) {
|
||||
enmSampler = SAMP_NEAREST;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
enmSampler = SAMP_RRC;
|
||||
}
|
||||
|
||||
|
||||
m_objDATVDemod->configure(
|
||||
m_objDATVDemod->getInputMessageQueue(),
|
||||
m_objChannelMarker.getBandwidth(),
|
||||
@ -675,7 +630,7 @@ void DATVDemodGUI::on_pushButton_3_clicked()
|
||||
|
||||
m_blnButtonPlayClicked=true;
|
||||
|
||||
if(m_objDATVDemod!=NULL)
|
||||
if(m_objDATVDemod!=nullptr)
|
||||
{
|
||||
m_objDATVDemod->PlayVideo(true);
|
||||
}
|
||||
@ -695,16 +650,11 @@ void DATVDemodGUI::on_mouseEvent(QMouseEvent* obj)
|
||||
|
||||
QString DATVDemodGUI::formatBytes(qint64 intBytes)
|
||||
{
|
||||
if(intBytes<1024)
|
||||
{
|
||||
if(intBytes<1024) {
|
||||
return QString("%1").arg(intBytes);
|
||||
}
|
||||
else if(intBytes<1024*1024)
|
||||
{
|
||||
} else if(intBytes<1024*1024) {
|
||||
return QString("%1 K").arg((float)(10*intBytes/1024)/10.0f);
|
||||
}
|
||||
else if(intBytes<1024*1024*1024)
|
||||
{
|
||||
} else if(intBytes<1024*1024*1024) {
|
||||
return QString("%1 M").arg((float)(10*intBytes/(1024*1024))/10.0f);
|
||||
}
|
||||
|
||||
@ -718,17 +668,13 @@ void DATVDemodGUI::on_StreamDataAvailable(int *intPackets, int *intBytes, int *i
|
||||
ui->lblStatus->setText(QString("Data: %1B").arg(formatBytes(*intTotalReceived)));
|
||||
m_intLastDecodedData = *intTotalReceived;
|
||||
|
||||
if((*intPercent)<100)
|
||||
{
|
||||
if((*intPercent)<100) {
|
||||
ui->prgSynchro->setValue(*intPercent);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ui->prgSynchro->setValue(100);
|
||||
}
|
||||
|
||||
m_intReadyDecodedData = *intBytes;
|
||||
|
||||
}
|
||||
|
||||
void DATVDemodGUI::on_spiBandwidth_valueChanged(int arg1)
|
||||
@ -758,10 +704,9 @@ void DATVDemodGUI::on_StreamMetaDataChanged(DataTSMetaData2 *objMetaData)
|
||||
{
|
||||
QString strMetaData="";
|
||||
|
||||
if(objMetaData!=NULL)
|
||||
if (objMetaData != nullptr)
|
||||
{
|
||||
|
||||
if(objMetaData->OK_TransportStream==true)
|
||||
if (objMetaData->OK_TransportStream == true)
|
||||
{
|
||||
strMetaData.sprintf("PID: %d - Width: %d - Height: %d\r\n%s%s\r\nCodec: %s\r\n",
|
||||
objMetaData->PID,
|
||||
@ -771,24 +716,20 @@ void DATVDemodGUI::on_StreamMetaDataChanged(DataTSMetaData2 *objMetaData)
|
||||
objMetaData->Stream.toStdString().c_str(),
|
||||
objMetaData->CodecDescription.toStdString().c_str());
|
||||
}
|
||||
ui->textEdit->setText(strMetaData);
|
||||
|
||||
ui->textEdit->setText(strMetaData);
|
||||
ui->chkData->setChecked(objMetaData->OK_Data);
|
||||
ui->chkTS->setChecked(objMetaData->OK_TransportStream);
|
||||
ui->chkVS->setChecked(objMetaData->OK_VideoStream);
|
||||
ui->chkDecoding->setChecked(objMetaData->OK_Decoding);
|
||||
|
||||
if(objMetaData->OK_Decoding==true)
|
||||
{
|
||||
if (objMetaData->OK_Decoding == true) {
|
||||
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ui->pushButton_3->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
|
||||
}
|
||||
|
||||
if(objMetaData->Height>0)
|
||||
{
|
||||
if (objMetaData->Height > 0) {
|
||||
ui->screenTV_2->setFixedWidth((int)objMetaData->Width*(270.0f/(float)objMetaData->Height));
|
||||
}
|
||||
}
|
||||
@ -806,7 +747,6 @@ void DATVDemodGUI::on_cmbFilter_currentIndexChanged(int index)
|
||||
{
|
||||
(void) index;
|
||||
displayRRCParameters((ui->cmbFilter->currentIndex()==2));
|
||||
|
||||
applySettings();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
const PluginDescriptor DATVDemodPlugin::m_ptrPluginDescriptor =
|
||||
{
|
||||
QString("DATV Demodulator"),
|
||||
QString("4.3.1"),
|
||||
QString("4.5.1"),
|
||||
QString("(c) F4HKW for SDRAngel using LeanSDR framework (c) F4DAV"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
@ -36,7 +36,7 @@ const PluginDescriptor DATVDemodPlugin::m_ptrPluginDescriptor =
|
||||
|
||||
DATVDemodPlugin::DATVDemodPlugin(QObject* ptrParent) :
|
||||
QObject(ptrParent),
|
||||
m_ptrPluginAPI(NULL)
|
||||
m_ptrPluginAPI(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class DATVDemodPlugin : public QObject, PluginInterface
|
||||
Q_PLUGIN_METADATA(IID "sdrangel.channel.demoddatv")
|
||||
|
||||
public:
|
||||
explicit DATVDemodPlugin(QObject* ptrParent = NULL);
|
||||
explicit DATVDemodPlugin(QObject* ptrParent = nullptr);
|
||||
|
||||
const PluginDescriptor& getPluginDescriptor() const;
|
||||
void initPlugin(PluginAPI* ptrPluginAPI);
|
||||
|
@ -26,15 +26,15 @@ DATVideoRender::DATVideoRender(QWidget * parent):
|
||||
|
||||
m_blnIsFFMPEGInitialized=false;
|
||||
m_blnIsOpen=false;
|
||||
m_objFormatCtx=NULL;
|
||||
m_objDecoderCtx=NULL;
|
||||
m_objSwsCtx=NULL;
|
||||
m_objFormatCtx=nullptr;
|
||||
m_objDecoderCtx=nullptr;
|
||||
m_objSwsCtx=nullptr;
|
||||
m_intVideoStreamIndex=-1;
|
||||
|
||||
m_intCurrentRenderWidth=-1;
|
||||
m_intCurrentRenderHeight=-1;
|
||||
|
||||
m_objFrame=NULL;
|
||||
m_objFrame=nullptr;
|
||||
m_intFrameCount=-1;
|
||||
}
|
||||
|
||||
@ -55,17 +55,15 @@ bool DATVideoRender::eventFilter(QObject *obj, QEvent *event)
|
||||
|
||||
void DATVideoRender::SetFullScreen(bool blnFullScreen)
|
||||
{
|
||||
if(m_blnIsFullScreen==blnFullScreen)
|
||||
{
|
||||
if (m_blnIsFullScreen == blnFullScreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(blnFullScreen==true)
|
||||
if (blnFullScreen == true)
|
||||
{
|
||||
setWindowFlags(Qt::Window);
|
||||
setWindowState(Qt::WindowFullScreen);
|
||||
show();
|
||||
|
||||
m_blnIsFullScreen=true;
|
||||
}
|
||||
else
|
||||
@ -73,7 +71,6 @@ void DATVideoRender::SetFullScreen(bool blnFullScreen)
|
||||
setWindowFlags(Qt::Widget);
|
||||
setWindowState(Qt::WindowNoState);
|
||||
show();
|
||||
|
||||
m_blnIsFullScreen=false;
|
||||
}
|
||||
}
|
||||
@ -90,18 +87,15 @@ static int64_t SeekFunction(void* opaque, int64_t offset, int whence)
|
||||
{
|
||||
QIODevice* objStream = reinterpret_cast<QIODevice*>(opaque);
|
||||
|
||||
if (whence == AVSEEK_SIZE)
|
||||
{
|
||||
if (whence == AVSEEK_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (objStream->isSequential())
|
||||
{
|
||||
if (objStream->isSequential()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (objStream->seek(offset)==false)
|
||||
{
|
||||
if (objStream->seek(offset) == false) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -131,14 +125,12 @@ bool DATVideoRender::InitializeFFMPEG()
|
||||
{
|
||||
ResetMetaData();
|
||||
|
||||
if(m_blnIsFFMPEGInitialized)
|
||||
{
|
||||
if (m_blnIsFFMPEGInitialized) {
|
||||
return false;
|
||||
}
|
||||
|
||||
avcodec_register_all();
|
||||
av_register_all();
|
||||
|
||||
av_log_set_level(AV_LOG_FATAL);
|
||||
//av_log_set_level(AV_LOG_ERROR);
|
||||
|
||||
@ -149,25 +141,25 @@ bool DATVideoRender::InitializeFFMPEG()
|
||||
|
||||
bool DATVideoRender::PreprocessStream()
|
||||
{
|
||||
AVDictionary *objOpts = NULL;
|
||||
AVCodec *objCodec = NULL;
|
||||
AVDictionary *objOpts = nullptr;
|
||||
AVCodec *objCodec = nullptr;
|
||||
|
||||
int intRet=-1;
|
||||
char *objBuffer=NULL;
|
||||
char *objBuffer=nullptr;
|
||||
|
||||
//Identify stream
|
||||
|
||||
if (avformat_find_stream_info(m_objFormatCtx, NULL) < 0)
|
||||
if (avformat_find_stream_info(m_objFormatCtx, nullptr) < 0)
|
||||
{
|
||||
avformat_close_input(&m_objFormatCtx);
|
||||
m_objFormatCtx=NULL;
|
||||
m_objFormatCtx=nullptr;
|
||||
|
||||
qDebug() << "DATVideoProcess::PreprocessStream cannot find stream info";
|
||||
return false;
|
||||
}
|
||||
|
||||
//Find video stream
|
||||
intRet = av_find_best_stream(m_objFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
|
||||
intRet = av_find_best_stream(m_objFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);
|
||||
|
||||
if (intRet < 0)
|
||||
{
|
||||
@ -191,28 +183,24 @@ bool DATVideoRender::PreprocessStream()
|
||||
MetaData.PID = m_objFormatCtx->streams[m_intVideoStreamIndex]->id;
|
||||
MetaData.CodecID = m_objDecoderCtx->codec_id;
|
||||
MetaData.OK_TransportStream = true;
|
||||
|
||||
|
||||
MetaData.Program="";
|
||||
MetaData.Stream="";
|
||||
|
||||
if(m_objFormatCtx->programs)
|
||||
{
|
||||
objBuffer=NULL;
|
||||
|
||||
objBuffer=nullptr;
|
||||
av_dict_get_string(m_objFormatCtx->programs[m_intVideoStreamIndex]->metadata,&objBuffer,':','\n');
|
||||
if(objBuffer!=NULL)
|
||||
{
|
||||
|
||||
if(objBuffer!=nullptr) {
|
||||
MetaData.Program = QString("%1").arg(objBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
objBuffer=NULL;
|
||||
objBuffer=nullptr;
|
||||
|
||||
av_dict_get_string(m_objFormatCtx->streams[m_intVideoStreamIndex]->metadata,&objBuffer,':','\n');
|
||||
|
||||
if(objBuffer!=NULL)
|
||||
{
|
||||
if (objBuffer != nullptr) {
|
||||
MetaData.Stream = QString("%1").arg(objBuffer);
|
||||
}
|
||||
|
||||
@ -220,10 +208,11 @@ bool DATVideoRender::PreprocessStream()
|
||||
|
||||
//Decoder
|
||||
objCodec = avcodec_find_decoder(m_objDecoderCtx->codec_id);
|
||||
if(objCodec==NULL)
|
||||
|
||||
if (objCodec == nullptr)
|
||||
{
|
||||
avformat_close_input(&m_objFormatCtx);
|
||||
m_objFormatCtx=NULL;
|
||||
m_objFormatCtx=nullptr;
|
||||
|
||||
qDebug() << "DATVideoProcess::PreprocessStream cannot find associated CODEC";
|
||||
return false;
|
||||
@ -234,7 +223,7 @@ bool DATVideoRender::PreprocessStream()
|
||||
if (avcodec_open2(m_objDecoderCtx, objCodec, &objOpts) < 0)
|
||||
{
|
||||
avformat_close_input(&m_objFormatCtx);
|
||||
m_objFormatCtx=NULL;
|
||||
m_objFormatCtx=nullptr;
|
||||
|
||||
qDebug() << "DATVideoProcess::PreprocessStream cannot open associated CODEC";
|
||||
return false;
|
||||
@ -246,21 +235,18 @@ bool DATVideoRender::PreprocessStream()
|
||||
if (!m_objFrame)
|
||||
{
|
||||
avformat_close_input(&m_objFormatCtx);
|
||||
m_objFormatCtx=NULL;
|
||||
m_objFormatCtx=nullptr;
|
||||
|
||||
qDebug() << "DATVideoProcess::PreprocessStream cannot allocate frame";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_intFrameCount=0;
|
||||
|
||||
|
||||
MetaData.Width=m_objDecoderCtx->width;
|
||||
MetaData.Height=m_objDecoderCtx->height;
|
||||
MetaData.BitRate= m_objDecoderCtx->bit_rate;
|
||||
MetaData.Channels=m_objDecoderCtx->channels;
|
||||
MetaData.CodecDescription= QString("%1").arg(objCodec->long_name);
|
||||
|
||||
MetaData.OK_VideoStream = true;
|
||||
|
||||
emit onMetaDataChanged(&MetaData);
|
||||
@ -271,111 +257,93 @@ bool DATVideoRender::PreprocessStream()
|
||||
bool DATVideoRender::OpenStream(DATVideostream *objDevice)
|
||||
{
|
||||
int intIOBufferSize = 32768;
|
||||
unsigned char * ptrIOBuffer = NULL;
|
||||
AVIOContext * objIOCtx = NULL;
|
||||
unsigned char * ptrIOBuffer = nullptr;
|
||||
AVIOContext * objIOCtx = nullptr;
|
||||
|
||||
if(m_blnRunning)
|
||||
{
|
||||
if(m_blnRunning) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(objDevice==NULL)
|
||||
if (objDevice == nullptr)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::OpenStream QIODevice is NULL";
|
||||
|
||||
qDebug() << "DATVideoProcess::OpenStream QIODevice is nullptr";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(m_blnIsOpen)
|
||||
if (m_blnIsOpen)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::OpenStream already open";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(objDevice->bytesAvailable()<=0)
|
||||
if (objDevice->bytesAvailable() <= 0)
|
||||
{
|
||||
|
||||
qDebug() << "DATVideoProcess::OpenStream no data available";
|
||||
|
||||
MetaData.OK_Data=false;
|
||||
MetaData.OK_Data = false;
|
||||
emit onMetaDataChanged(&MetaData);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Only once execution
|
||||
m_blnRunning=true;
|
||||
m_blnRunning = true;
|
||||
|
||||
MetaData.OK_Data=true;
|
||||
MetaData.OK_Data = true;
|
||||
emit onMetaDataChanged(&MetaData);
|
||||
|
||||
|
||||
InitializeFFMPEG();
|
||||
|
||||
|
||||
if(!m_blnIsFFMPEGInitialized)
|
||||
if (!m_blnIsFFMPEGInitialized)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::OpenStream FFMPEG not initialized";
|
||||
|
||||
m_blnRunning=false;
|
||||
m_blnRunning = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!objDevice->open(QIODevice::ReadOnly))
|
||||
if (!objDevice->open(QIODevice::ReadOnly))
|
||||
{
|
||||
qDebug() << "DATVideoProcess::OpenStream cannot open QIODevice";
|
||||
|
||||
m_blnRunning=false;
|
||||
m_blnRunning = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Connect QIODevice to FFMPEG Reader
|
||||
|
||||
m_objFormatCtx = avformat_alloc_context();
|
||||
|
||||
if(m_objFormatCtx==NULL)
|
||||
if (m_objFormatCtx == nullptr)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::OpenStream cannot alloc format FFMPEG context";
|
||||
|
||||
m_blnRunning=false;
|
||||
m_blnRunning = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
ptrIOBuffer = (unsigned char *)av_malloc(intIOBufferSize+ AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
objIOCtx = avio_alloc_context( ptrIOBuffer,
|
||||
objIOCtx = avio_alloc_context(ptrIOBuffer,
|
||||
intIOBufferSize,
|
||||
0,
|
||||
reinterpret_cast<void *>(objDevice),
|
||||
&ReadFunction,
|
||||
NULL,
|
||||
nullptr,
|
||||
&SeekFunction);
|
||||
|
||||
m_objFormatCtx->pb = objIOCtx;
|
||||
m_objFormatCtx->flags |= AVFMT_FLAG_CUSTOM_IO;
|
||||
|
||||
|
||||
if (avformat_open_input(&m_objFormatCtx, NULL , NULL, NULL) < 0)
|
||||
if (avformat_open_input(&m_objFormatCtx, nullptr , nullptr, nullptr) < 0)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::OpenStream cannot open stream";
|
||||
|
||||
m_blnRunning=false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!PreprocessStream())
|
||||
if (!PreprocessStream())
|
||||
{
|
||||
m_blnRunning=false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
m_blnIsOpen=true;
|
||||
|
||||
m_blnRunning=false;
|
||||
|
||||
return true;
|
||||
@ -390,12 +358,10 @@ bool DATVideoRender::RenderStream()
|
||||
if(!m_blnIsOpen)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::RenderStream Stream not open";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_blnRunning)
|
||||
{
|
||||
if(m_blnRunning) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -407,7 +373,6 @@ bool DATVideoRender::RenderStream()
|
||||
if (av_read_frame(m_objFormatCtx, &objPacket) < 0)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::RenderStream reading packet error";
|
||||
|
||||
m_blnRunning=false;
|
||||
return false;
|
||||
}
|
||||
@ -418,34 +383,31 @@ bool DATVideoRender::RenderStream()
|
||||
memset(m_objFrame, 0, sizeof(AVFrame));
|
||||
av_frame_unref(m_objFrame);
|
||||
|
||||
intGotFrame=0;
|
||||
intGotFrame = 0;
|
||||
|
||||
if(new_decode( m_objDecoderCtx, m_objFrame, &intGotFrame, &objPacket)<0)
|
||||
if (new_decode( m_objDecoderCtx, m_objFrame, &intGotFrame, &objPacket)<0)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::RenderStream decoding packet error";
|
||||
|
||||
m_blnRunning=false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(intGotFrame)
|
||||
if (intGotFrame)
|
||||
{
|
||||
//Rendering and RGB Converter setup
|
||||
|
||||
blnNeedRenderingSetup=(m_intFrameCount==0);
|
||||
blnNeedRenderingSetup|=(m_objSwsCtx==NULL);
|
||||
blnNeedRenderingSetup|=(m_objSwsCtx==nullptr);
|
||||
|
||||
if((m_intCurrentRenderWidth!=m_objFrame->width) || (m_intCurrentRenderHeight!=m_objFrame->height))
|
||||
{
|
||||
if ((m_intCurrentRenderWidth!=m_objFrame->width) || (m_intCurrentRenderHeight!=m_objFrame->height)) {
|
||||
blnNeedRenderingSetup=true;
|
||||
}
|
||||
|
||||
if(blnNeedRenderingSetup)
|
||||
if (blnNeedRenderingSetup)
|
||||
{
|
||||
if(m_objSwsCtx!=NULL)
|
||||
if (m_objSwsCtx != nullptr)
|
||||
{
|
||||
sws_freeContext(m_objSwsCtx);
|
||||
m_objSwsCtx=NULL;
|
||||
m_objSwsCtx=nullptr;
|
||||
}
|
||||
|
||||
//Convertisseur YUV -> RGB
|
||||
@ -461,33 +423,27 @@ bool DATVideoRender::RenderStream()
|
||||
|
||||
av_opt_set_int(m_objSwsCtx,"sws_flag", SWS_FAST_BILINEAR /* SWS_BICUBIC*/,0);
|
||||
|
||||
if(sws_init_context(m_objSwsCtx, NULL, NULL)<0)
|
||||
if (sws_init_context(m_objSwsCtx, nullptr, nullptr) < 0)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::RenderStream cannont init video data converter";
|
||||
|
||||
m_objSwsCtx=NULL;
|
||||
|
||||
m_objSwsCtx=nullptr;
|
||||
m_blnRunning=false;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if((m_intCurrentRenderHeight>0) && (m_intCurrentRenderWidth>0))
|
||||
if ((m_intCurrentRenderHeight>0) && (m_intCurrentRenderWidth>0))
|
||||
{
|
||||
//av_freep(&m_pbytDecodedData[0]);
|
||||
//av_freep(&m_pintDecodedLineSize[0]);
|
||||
}
|
||||
|
||||
if(av_image_alloc(m_pbytDecodedData, m_pintDecodedLineSize,m_objFrame->width, m_objFrame->height, AV_PIX_FMT_RGB24, 1)<0)
|
||||
if (av_image_alloc(m_pbytDecodedData, m_pintDecodedLineSize,m_objFrame->width, m_objFrame->height, AV_PIX_FMT_RGB24, 1)<0)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::RenderStream cannont init video image buffer";
|
||||
|
||||
sws_freeContext(m_objSwsCtx);
|
||||
m_objSwsCtx=NULL;
|
||||
|
||||
m_objSwsCtx=nullptr;
|
||||
m_blnRunning=false;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//Rendering device setup
|
||||
@ -507,21 +463,17 @@ bool DATVideoRender::RenderStream()
|
||||
|
||||
//Frame rendering
|
||||
|
||||
if(sws_scale(m_objSwsCtx, m_objFrame->data, m_objFrame->linesize, 0, m_objFrame->height, m_pbytDecodedData, m_pintDecodedLineSize)<0)
|
||||
if (sws_scale(m_objSwsCtx, m_objFrame->data, m_objFrame->linesize, 0, m_objFrame->height, m_pbytDecodedData, m_pintDecodedLineSize)<0)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::RenderStream error converting video frame to RGB";
|
||||
|
||||
m_blnRunning=false;
|
||||
return false;
|
||||
}
|
||||
|
||||
renderImage(m_pbytDecodedData[0]);
|
||||
|
||||
av_frame_unref(m_objFrame);
|
||||
|
||||
m_intFrameCount ++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
av_packet_unref(&objPacket);
|
||||
@ -536,29 +488,25 @@ bool DATVideoRender::RenderStream()
|
||||
bool DATVideoRender::CloseStream(QIODevice *objDevice)
|
||||
{
|
||||
|
||||
if(m_blnRunning)
|
||||
{
|
||||
if (m_blnRunning) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!objDevice)
|
||||
if (!objDevice)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::CloseStream QIODevice is NULL";
|
||||
|
||||
qDebug() << "DATVideoProcess::CloseStream QIODevice is nullptr";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!m_blnIsOpen)
|
||||
if (!m_blnIsOpen)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::CloseStream Stream not open";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!m_objFormatCtx)
|
||||
if (!m_objFormatCtx)
|
||||
{
|
||||
qDebug() << "DATVideoProcess::CloseStream FFMEG Context is not initialized";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -567,32 +515,29 @@ bool DATVideoRender::CloseStream(QIODevice *objDevice)
|
||||
|
||||
// maybe done in the avcodec_close
|
||||
// avformat_close_input(&m_objFormatCtx);
|
||||
// m_objFormatCtx=NULL;
|
||||
// m_objFormatCtx=nullptr;
|
||||
|
||||
if(m_objDecoderCtx)
|
||||
if (m_objDecoderCtx)
|
||||
{
|
||||
avcodec_close(m_objDecoderCtx);
|
||||
m_objDecoderCtx=NULL;
|
||||
m_objDecoderCtx = nullptr;
|
||||
}
|
||||
|
||||
if(m_objFrame)
|
||||
if (m_objFrame)
|
||||
{
|
||||
av_frame_unref(m_objFrame);
|
||||
av_frame_free(&m_objFrame);
|
||||
}
|
||||
|
||||
if(m_objSwsCtx!=NULL)
|
||||
if (m_objSwsCtx != nullptr)
|
||||
{
|
||||
sws_freeContext(m_objSwsCtx);
|
||||
m_objSwsCtx=NULL;
|
||||
m_objSwsCtx = nullptr;
|
||||
}
|
||||
|
||||
objDevice->close();
|
||||
|
||||
m_blnIsOpen=false;
|
||||
|
||||
m_blnRunning=false;
|
||||
|
||||
m_intCurrentRenderWidth=-1;
|
||||
m_intCurrentRenderHeight=-1;
|
||||
|
||||
@ -612,19 +557,25 @@ int DATVideoRender::new_decode(AVCodecContext *avctx, AVFrame *frame, int *got_f
|
||||
|
||||
*got_frame = 0;
|
||||
|
||||
if (pkt) {
|
||||
if (pkt)
|
||||
{
|
||||
ret = avcodec_send_packet(avctx, pkt);
|
||||
// In particular, we don't expect AVERROR(EAGAIN), because we read all
|
||||
// decoded frames with avcodec_receive_frame() until done.
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
return ret == AVERROR_EOF ? 0 : ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = avcodec_receive_frame(avctx, frame);
|
||||
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
|
||||
|
||||
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
|
||||
return ret;
|
||||
if (ret >= 0)
|
||||
}
|
||||
|
||||
if (ret >= 0) {
|
||||
*got_frame = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -66,22 +66,17 @@ struct DataTSMetaData2
|
||||
{
|
||||
PID=-1;
|
||||
CodecID=-1;
|
||||
|
||||
|
||||
Program="";
|
||||
Stream="";
|
||||
|
||||
Width=-1;
|
||||
Height=-1;
|
||||
BitRate=-1;
|
||||
Channels=-1;
|
||||
CodecDescription="";
|
||||
|
||||
OK_Data=false;
|
||||
OK_Decoding=false;
|
||||
OK_TransportStream=false;
|
||||
OK_VideoStream=false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@ -131,18 +126,16 @@ protected:
|
||||
|
||||
signals:
|
||||
void onMetaDataChanged(DataTSMetaData2 *objMetaData);
|
||||
|
||||
};
|
||||
|
||||
//To run Video Rendering with a dedicated thread
|
||||
class DATVideoRenderThread: public QThread
|
||||
{
|
||||
|
||||
public:
|
||||
DATVideoRenderThread()
|
||||
{
|
||||
m_objRenderer = NULL;
|
||||
m_objStream = NULL;
|
||||
m_objRenderer = nullptr;
|
||||
m_objStream = nullptr;
|
||||
m_blnRenderingVideo=false;
|
||||
}
|
||||
|
||||
@ -162,31 +155,25 @@ class DATVideoRenderThread: public QThread
|
||||
|
||||
void run()
|
||||
{
|
||||
if(m_blnRenderingVideo)
|
||||
{
|
||||
if (m_blnRenderingVideo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if((m_objRenderer==NULL) || (m_objStream==NULL))
|
||||
{
|
||||
if ((m_objRenderer==nullptr) || (m_objStream==nullptr)) {
|
||||
return ;
|
||||
}
|
||||
|
||||
m_blnRenderingVideo = m_objRenderer->OpenStream(m_objStream);
|
||||
|
||||
if(!m_blnRenderingVideo)
|
||||
{
|
||||
if (!m_blnRenderingVideo) {
|
||||
return;
|
||||
}
|
||||
|
||||
while((m_objRenderer->RenderStream()) && (m_blnRenderingVideo==true))
|
||||
{
|
||||
while ((m_objRenderer->RenderStream()) && (m_blnRenderingVideo == true)) {
|
||||
}
|
||||
|
||||
m_objRenderer->CloseStream(m_objStream);
|
||||
|
||||
m_blnRenderingVideo=false;
|
||||
|
||||
}
|
||||
|
||||
void stopRendering()
|
||||
|
@ -22,11 +22,11 @@ DATVideostream::DATVideostream():
|
||||
m_objMutex(QMutex::NonRecursive)
|
||||
{
|
||||
cleanUp();
|
||||
m_intTotalReceived=0;
|
||||
m_intPacketReceived=0;
|
||||
m_intTotalReceived = 0;
|
||||
m_intPacketReceived = 0;
|
||||
m_intMemoryLimit = DefaultMemoryLimit;
|
||||
MultiThreaded=false;
|
||||
ThreadTimeOut=-1;
|
||||
MultiThreaded = false;
|
||||
ThreadTimeOut = -1;
|
||||
|
||||
m_objeventLoop.connect(this,SIGNAL(onDataAvailable()), &m_objeventLoop, SLOT(quit()),Qt::QueuedConnection);
|
||||
}
|
||||
@ -39,72 +39,65 @@ DATVideostream::~DATVideostream()
|
||||
|
||||
void DATVideostream::cleanUp()
|
||||
{
|
||||
if(m_objFIFO.size()>0)
|
||||
{
|
||||
if (m_objFIFO.size() > 0) {
|
||||
m_objFIFO.clear();
|
||||
}
|
||||
|
||||
if(m_objeventLoop.isRunning())
|
||||
{
|
||||
if (m_objeventLoop.isRunning()) {
|
||||
m_objeventLoop.exit();
|
||||
}
|
||||
|
||||
m_intBytesAvailable=0;
|
||||
m_intBytesWaiting=0;
|
||||
m_intQueueWaiting=0;
|
||||
m_intPercentBuffer=0;
|
||||
m_intBytesAvailable = 0;
|
||||
m_intBytesWaiting = 0;
|
||||
m_intQueueWaiting = 0;
|
||||
m_intPercentBuffer = 0;
|
||||
}
|
||||
|
||||
bool DATVideostream::setMemoryLimit(int intMemoryLimit)
|
||||
{
|
||||
if(intMemoryLimit<=0)
|
||||
{
|
||||
if (intMemoryLimit <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_intMemoryLimit=intMemoryLimit;
|
||||
m_intMemoryLimit = intMemoryLimit;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int DATVideostream::pushData(const char * chrData, int intSize)
|
||||
{
|
||||
if(intSize<=0)
|
||||
{
|
||||
if (intSize <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_objMutex.lock();
|
||||
|
||||
m_intPacketReceived ++;
|
||||
|
||||
m_intPacketReceived++;
|
||||
m_intBytesWaiting += intSize;
|
||||
if(m_intBytesWaiting>m_intMemoryLimit)
|
||||
{
|
||||
|
||||
if (m_intBytesWaiting > m_intMemoryLimit) {
|
||||
m_intBytesWaiting -= m_objFIFO.dequeue().size();
|
||||
}
|
||||
|
||||
m_objFIFO.enqueue(QByteArray(chrData,intSize));
|
||||
m_intBytesAvailable = m_objFIFO.head().size();
|
||||
m_intTotalReceived += intSize;
|
||||
|
||||
m_intQueueWaiting=m_objFIFO.count();
|
||||
|
||||
m_objMutex.unlock();
|
||||
|
||||
if((m_objeventLoop.isRunning())
|
||||
&& (m_intQueueWaiting>=MinStackSize))
|
||||
if ((m_objeventLoop.isRunning())
|
||||
&& (m_intQueueWaiting >= MinStackSize))
|
||||
{
|
||||
emit onDataAvailable();
|
||||
}
|
||||
|
||||
if(m_intPacketReceived%MinStackSize==1)
|
||||
if (m_intPacketReceived % MinStackSize == 1)
|
||||
{
|
||||
|
||||
m_intPercentBuffer = (100*m_intBytesWaiting)/m_intMemoryLimit;
|
||||
if(m_intPercentBuffer>100)
|
||||
{
|
||||
m_intPercentBuffer=100;
|
||||
|
||||
if (m_intPercentBuffer > 100) {
|
||||
m_intPercentBuffer = 100;
|
||||
}
|
||||
|
||||
emit onDataPackets(&m_intQueueWaiting, &m_intBytesWaiting, &m_intPercentBuffer, &m_intTotalReceived);
|
||||
@ -140,42 +133,39 @@ bool DATVideostream::open(OpenMode mode)
|
||||
qint64 DATVideostream::readData(char *data, qint64 len)
|
||||
{
|
||||
QByteArray objCurrentArray;
|
||||
int intEffectiveLen=0;
|
||||
int intExpectedLen=0;
|
||||
int intThreadLoop=0;
|
||||
int intEffectiveLen = 0;
|
||||
int intExpectedLen = 0;
|
||||
int intThreadLoop = 0;
|
||||
|
||||
intExpectedLen = (int) len;
|
||||
|
||||
if(intExpectedLen<=0)
|
||||
{
|
||||
if (intExpectedLen <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(m_objeventLoop.isRunning())
|
||||
{
|
||||
if (m_objeventLoop.isRunning()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_objMutex.lock();
|
||||
|
||||
//DATA in FIFO ? -> Waiting for DATA
|
||||
if((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
|
||||
if ((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
|
||||
{
|
||||
m_objMutex.unlock();
|
||||
|
||||
if(MultiThreaded==true)
|
||||
if (MultiThreaded == true)
|
||||
{
|
||||
|
||||
intThreadLoop=0;
|
||||
while((m_objFIFO.isEmpty()) || (m_objFIFO.count()<MinStackSize))
|
||||
|
||||
while ((m_objFIFO.isEmpty()) || (m_objFIFO.count() < MinStackSize))
|
||||
{
|
||||
QThread::msleep(5);
|
||||
intThreadLoop ++;
|
||||
intThreadLoop++;
|
||||
|
||||
if(ThreadTimeOut>=0)
|
||||
{
|
||||
if(intThreadLoop*5>ThreadTimeOut)
|
||||
if (ThreadTimeOut >= 0)
|
||||
{
|
||||
if (intThreadLoop*5 > ThreadTimeOut) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -192,13 +182,13 @@ qint64 DATVideostream::readData(char *data, qint64 len)
|
||||
//Read DATA
|
||||
intEffectiveLen=m_objFIFO.head().size();
|
||||
|
||||
if(intExpectedLen<intEffectiveLen)
|
||||
if (intExpectedLen < intEffectiveLen)
|
||||
{
|
||||
//Partial Read
|
||||
objCurrentArray = m_objFIFO.head();
|
||||
memcpy((void *)data,objCurrentArray.constData(),intExpectedLen);
|
||||
m_objFIFO.head().remove(0,intExpectedLen);
|
||||
intEffectiveLen=intExpectedLen;
|
||||
intEffectiveLen = intExpectedLen;
|
||||
m_intBytesWaiting -= intExpectedLen;
|
||||
}
|
||||
else
|
||||
@ -210,7 +200,7 @@ qint64 DATVideostream::readData(char *data, qint64 len)
|
||||
}
|
||||
|
||||
m_intQueueWaiting = m_objFIFO.count();
|
||||
m_intPercentBuffer = (100*m_intBytesWaiting)/m_intMemoryLimit;
|
||||
m_intPercentBuffer = (100*m_intBytesWaiting) / m_intMemoryLimit;
|
||||
|
||||
emit onDataPackets(&m_intQueueWaiting, &m_intBytesWaiting, &m_intPercentBuffer, &m_intTotalReceived);
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
namespace leansdr
|
||||
{
|
||||
|
||||
template<typename T> struct datvvideoplayer: runnable
|
||||
{
|
||||
datvvideoplayer(scheduler *sch, pipebuf<T> &_in, DATVideostream * objVideoStream) :
|
||||
@ -33,8 +34,10 @@ template<typename T> struct datvvideoplayer: runnable
|
||||
void run()
|
||||
{
|
||||
int size = in.readable() * sizeof(T);
|
||||
if (!size)
|
||||
|
||||
if (!size) {
|
||||
return;
|
||||
}
|
||||
|
||||
int nw = m_objVideoStream->pushData((const char *) in.rd(), size);
|
||||
|
||||
@ -43,18 +46,22 @@ template<typename T> struct datvvideoplayer: runnable
|
||||
fatal("leansdr::datvvideoplayer::run: pipe");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nw < 0)
|
||||
{
|
||||
fatal("leansdr::datvvideoplayer::run: write");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nw % sizeof(T))
|
||||
{
|
||||
fatal("leansdr::datvvideoplayer::run: partial write");
|
||||
return;
|
||||
}
|
||||
|
||||
in.read(nw / sizeof(T));
|
||||
}
|
||||
|
||||
private:
|
||||
pipereader<T> in;
|
||||
DATVideostream * m_objVideoStream;
|
||||
|
Loading…
Reference in New Issue
Block a user