2017-02-23 02:18:56 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 F4HKW //
|
|
|
|
// for F4EXB / SDRAngel //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "atvdemod.h"
|
|
|
|
|
|
|
|
#include <QTime>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <complex.h>
|
|
|
|
#include "audio/audiooutput.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/pidcontroller.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgConfigureATVDemod, Message)
|
|
|
|
|
2017-03-16 18:13:51 -04:00
|
|
|
const float ATVDemod::m_fltSecondToUs = 1000000.0f;
|
|
|
|
|
2017-02-23 02:18:56 -05:00
|
|
|
ATVDemod::ATVDemod() :
|
|
|
|
m_objSettingsMutex(QMutex::NonRecursive),
|
|
|
|
m_objRegisteredATVScreen(NULL),
|
|
|
|
m_intImageIndex(0),
|
|
|
|
m_intColIndex(0),
|
|
|
|
m_intRowIndex(0),
|
|
|
|
m_intSynchroPoints(0),
|
|
|
|
m_blnSynchroDetected(false),
|
2017-02-24 17:25:09 -05:00
|
|
|
m_blnLineSynchronized(false),
|
2017-02-23 02:18:56 -05:00
|
|
|
m_blnVerticalSynchroDetected(false),
|
|
|
|
m_enmModulation(ATV_FM1),
|
|
|
|
m_intRowsLimit(0),
|
|
|
|
m_blnImageDetecting(false),
|
|
|
|
m_fltEffMin(2000000000.0f),
|
|
|
|
m_fltEffMax(-2000000000.0f),
|
|
|
|
m_fltAmpMin(-2000000000.0f),
|
|
|
|
m_fltAmpMax(2000000000.0f),
|
|
|
|
m_fltAmpDelta(1.0),
|
2017-02-25 01:12:41 -05:00
|
|
|
m_fltAmpLineAverage(0.0f),
|
|
|
|
m_intNumberSamplePerTop(0)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
2017-03-05 21:36:02 -05:00
|
|
|
setObjectName("ATVDemod");
|
2017-02-23 02:18:56 -05:00
|
|
|
|
|
|
|
//*************** ATV PARAMETERS ***************
|
|
|
|
m_intNumberSamplePerLine=0;
|
|
|
|
m_intSynchroPoints=0;
|
|
|
|
m_intNumberOfLines=0;
|
|
|
|
m_intNumberOfRowsToDisplay=0;
|
|
|
|
|
2017-03-16 13:56:20 -04:00
|
|
|
m_objMagSqAverage.resize(16, 1.0);
|
|
|
|
|
2017-02-23 02:18:56 -05:00
|
|
|
memset((void*)m_fltBufferI,0,6*sizeof(float));
|
|
|
|
memset((void*)m_fltBufferQ,0,6*sizeof(float));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ATVDemod::~ATVDemod()
|
2017-02-25 01:12:41 -05:00
|
|
|
{
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ATVDemod::SetATVScreen(ATVScreen *objScreen)
|
|
|
|
{
|
2017-02-25 01:12:41 -05:00
|
|
|
m_objRegisteredATVScreen = objScreen;
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
2017-03-16 19:12:12 -04:00
|
|
|
void ATVDemod::configure(
|
|
|
|
MessageQueue* objMessageQueue,
|
|
|
|
float fltLineDurationUs,
|
|
|
|
float fltTopDurationUs,
|
|
|
|
float fltFramePerS,
|
|
|
|
float fltRatioOfRowsToDisplay,
|
|
|
|
float fltVoltLevelSynchroTop,
|
|
|
|
float fltVoltLevelSynchroBlack,
|
|
|
|
ATVModulation enmModulation,
|
|
|
|
bool blnHSync,
|
|
|
|
bool blnVSync)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
2017-03-16 19:12:12 -04:00
|
|
|
Message* msgCmd = MsgConfigureATVDemod::create(
|
|
|
|
fltLineDurationUs,
|
|
|
|
fltTopDurationUs,
|
|
|
|
fltFramePerS,
|
|
|
|
fltRatioOfRowsToDisplay,
|
|
|
|
fltVoltLevelSynchroTop,
|
|
|
|
fltVoltLevelSynchroBlack,
|
|
|
|
enmModulation,
|
|
|
|
blnHSync,
|
|
|
|
blnVSync);
|
2017-02-23 02:18:56 -05:00
|
|
|
objMessageQueue->push(msgCmd);
|
|
|
|
}
|
|
|
|
|
2017-03-16 15:57:00 -04:00
|
|
|
void ATVDemod::InitATVParameters(
|
2017-03-16 18:29:22 -04:00
|
|
|
int intSampleRate,
|
2017-03-16 18:13:51 -04:00
|
|
|
float fltLineDurationUs,
|
2017-03-16 18:29:22 -04:00
|
|
|
float fltTopDurationUs,
|
2017-03-16 19:12:12 -04:00
|
|
|
float fltFramePerS,
|
|
|
|
float fltRatioOfRowsToDisplay,
|
2017-03-16 15:57:00 -04:00
|
|
|
ATVModulation enmModulation,
|
|
|
|
bool blnHSync,
|
|
|
|
bool blnVSync)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
2017-03-16 19:12:12 -04:00
|
|
|
// float fltImagesPerSeconds = (float) intFramePerS;
|
2017-02-23 02:18:56 -05:00
|
|
|
int intNumberSamplePerLine;
|
|
|
|
int intNumberOfLines;
|
2017-03-16 18:13:51 -04:00
|
|
|
bool blnNewOpenGLScreen = false;
|
2017-02-23 02:18:56 -05:00
|
|
|
|
|
|
|
m_objSettingsMutex.lock();
|
|
|
|
|
2017-03-16 18:29:22 -04:00
|
|
|
intNumberSamplePerLine = (int) ((fltLineDurationUs * intSampleRate) / m_fltSecondToUs);
|
2017-03-16 19:12:12 -04:00
|
|
|
intNumberOfLines = (int) ((m_fltSecondToUs/fltFramePerS) /round(fltLineDurationUs));
|
2017-02-23 02:18:56 -05:00
|
|
|
|
2017-03-16 18:13:51 -04:00
|
|
|
if((intNumberSamplePerLine != m_intNumberSamplePerLine)
|
|
|
|
|| (intNumberOfLines != m_intNumberOfLines))
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
2017-03-16 18:13:51 -04:00
|
|
|
blnNewOpenGLScreen = true;
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_intNumberSamplePerLine= intNumberSamplePerLine;
|
2017-03-16 18:29:22 -04:00
|
|
|
m_intNumberSamplePerTop=(int)((fltTopDurationUs * intSampleRate) / m_fltSecondToUs);
|
2017-02-23 02:18:56 -05:00
|
|
|
m_intNumberOfLines = intNumberOfLines;
|
2017-03-16 19:12:12 -04:00
|
|
|
m_intNumberOfRowsToDisplay = (int) ((fltRatioOfRowsToDisplay * fltLineDurationUs * intSampleRate) / m_fltSecondToUs);
|
2017-02-23 02:18:56 -05:00
|
|
|
m_intRowsLimit = m_intNumberOfLines-1;
|
|
|
|
m_intImageIndex = 0;
|
|
|
|
|
|
|
|
m_enmModulation = enmModulation;
|
|
|
|
|
|
|
|
m_intColIndex=0;
|
|
|
|
m_intRowIndex=0;
|
|
|
|
m_intRowsLimit=0;
|
|
|
|
|
|
|
|
if(blnNewOpenGLScreen)
|
2017-02-25 01:12:41 -05:00
|
|
|
{
|
2017-03-16 18:13:51 -04:00
|
|
|
m_objRegisteredATVScreen->resizeATVScreen(m_intNumberSamplePerLine, m_intNumberOfLines);
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//Mise à jour de la config
|
|
|
|
m_objRunning.m_enmModulation = m_enmModulation;
|
2017-03-16 19:12:12 -04:00
|
|
|
m_objRunning.m_fltFramePerS = fltFramePerS;
|
2017-03-16 18:13:51 -04:00
|
|
|
m_objRunning.m_fltLineDurationUs = fltLineDurationUs;
|
2017-03-16 18:29:22 -04:00
|
|
|
m_objRunning.m_fltTopDurationUs = fltTopDurationUs;
|
|
|
|
m_objRunning.m_intSampleRate = intSampleRate;
|
2017-03-16 19:12:12 -04:00
|
|
|
m_objRunning.m_fltRatioOfRowsToDisplay = fltRatioOfRowsToDisplay;
|
2017-02-23 02:18:56 -05:00
|
|
|
m_objRunning.m_blnHSync = blnHSync;
|
|
|
|
m_objRunning.m_blnVSync = blnVSync;
|
|
|
|
|
2017-03-16 17:10:40 -04:00
|
|
|
m_objSettingsMutex.unlock();
|
|
|
|
|
2017-02-25 07:14:29 -05:00
|
|
|
qDebug() << "ATVDemod::InitATVParameters:"
|
2017-03-16 18:29:22 -04:00
|
|
|
<< " - Sample rate S/s: " << intSampleRate
|
2017-03-16 18:13:51 -04:00
|
|
|
<< " - Line us: " << fltLineDurationUs
|
2017-03-16 18:29:22 -04:00
|
|
|
<< " - Top us: " << fltTopDurationUs
|
2017-03-16 19:12:12 -04:00
|
|
|
<< " - Frame/s: " << fltFramePerS
|
|
|
|
<< " - Frame display ratio: " << fltRatioOfRowsToDisplay
|
2017-02-23 02:18:56 -05:00
|
|
|
<< " <=> "
|
|
|
|
<< " - Samples per Line: " << m_intNumberSamplePerLine
|
|
|
|
<< " - Samples per Top: " << m_intNumberSamplePerTop
|
|
|
|
<< " - Lines per Frame: " << m_intNumberOfLines
|
|
|
|
<< " - Rows to Display: " << m_intNumberOfRowsToDisplay
|
|
|
|
<< " - Modulation: " << ((m_enmModulation==ATV_AM)?"AM" : "FM");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
|
|
|
|
{
|
2017-03-16 19:33:14 -04:00
|
|
|
float fltDivSynchroBlack = 1.0f - m_objRunning.m_fltVoltLevelSynchroBlack;
|
2017-02-23 02:18:56 -05:00
|
|
|
float fltI;
|
|
|
|
float fltQ;
|
|
|
|
float fltNormI;
|
|
|
|
float fltNormQ;
|
|
|
|
|
|
|
|
float fltNorm=0.00f;
|
|
|
|
float fltVal;
|
|
|
|
int intVal;
|
|
|
|
|
|
|
|
qint16 * ptrBufferToRelease=NULL;
|
|
|
|
|
|
|
|
bool blnComputeImage=false;
|
|
|
|
|
|
|
|
int intSynchroTimeSamples= (3*m_intNumberSamplePerLine)/4;
|
2017-03-16 19:33:14 -04:00
|
|
|
float fltSynchroTrameLevel = 0.5f*((float)intSynchroTimeSamples) * m_objRunning.m_fltVoltLevelSynchroBlack;
|
2017-02-23 02:18:56 -05:00
|
|
|
|
|
|
|
//********** Let's rock and roll buddy ! **********
|
|
|
|
|
|
|
|
m_objSettingsMutex.lock();
|
|
|
|
|
|
|
|
|
|
|
|
//********** Accessing ATV Screen context **********
|
|
|
|
|
|
|
|
if(m_intImageIndex==0)
|
|
|
|
{
|
|
|
|
if(m_intNumberOfLines%2==1)
|
|
|
|
{
|
|
|
|
m_intRowsLimit = m_intNumberOfLines;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_intRowsLimit = m_intNumberOfLines-2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef EXTENDED_DIRECT_SAMPLE
|
|
|
|
|
|
|
|
qint16 * ptrBuffer;
|
|
|
|
qint32 intLen;
|
|
|
|
|
|
|
|
//********** Reading direct samples **********
|
|
|
|
|
|
|
|
SampleVector::const_iterator it = begin;
|
|
|
|
intLen = it->intLen;
|
|
|
|
ptrBuffer = it->ptrBuffer;
|
|
|
|
ptrBufferToRelease = ptrBuffer;
|
|
|
|
++it;
|
|
|
|
|
|
|
|
for(qint32 intInd=0; intInd<intLen-1; intInd +=2)
|
|
|
|
{
|
|
|
|
|
|
|
|
fltI= ((qint32) (*ptrBuffer)) << 4;
|
|
|
|
ptrBuffer ++;
|
|
|
|
fltQ= ((qint32) (*ptrBuffer)) << 4;
|
|
|
|
ptrBuffer ++;
|
2017-03-05 21:36:02 -05:00
|
|
|
|
2017-02-23 02:18:56 -05:00
|
|
|
#else
|
|
|
|
|
|
|
|
for (SampleVector::const_iterator it = begin; it != end; ++it /* ++it **/)
|
|
|
|
{
|
|
|
|
|
|
|
|
fltI = it->real();
|
|
|
|
fltQ = it->imag();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//********** demodulation **********
|
|
|
|
|
2017-03-16 13:56:20 -04:00
|
|
|
double magSq = fltI*fltI + fltQ*fltQ;
|
|
|
|
m_objMagSqAverage.feed(magSq);
|
|
|
|
|
|
|
|
fltNorm = sqrt(magSq);
|
2017-02-23 02:18:56 -05:00
|
|
|
|
2017-03-16 13:56:20 -04:00
|
|
|
if ((m_enmModulation == ATV_FM1) || (m_enmModulation == ATV_FM2))
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
|
|
|
//Amplitude FM
|
|
|
|
|
|
|
|
fltNormI= fltI/fltNorm;
|
|
|
|
fltNormQ= fltQ/fltNorm;
|
|
|
|
|
|
|
|
//-2 > 2 : 0 -> 1 volt
|
|
|
|
//0->0.3 synchro 0.3->1 image
|
|
|
|
|
|
|
|
if(m_enmModulation==ATV_FM1)
|
|
|
|
{
|
|
|
|
//YDiff Cd
|
|
|
|
fltVal = m_fltBufferI[0]*(fltNormQ - m_fltBufferQ[1]);
|
|
|
|
fltVal -= m_fltBufferQ[0]*(fltNormI - m_fltBufferI[1]);
|
|
|
|
|
|
|
|
fltVal += 2.0f;
|
|
|
|
fltVal /=4.0f;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//YDiff Folded
|
|
|
|
fltVal = m_fltBufferI[2]*((m_fltBufferQ[5]-fltNormQ)/16.0f + m_fltBufferQ[1] - m_fltBufferQ[3]);
|
|
|
|
fltVal -= m_fltBufferQ[2]*((m_fltBufferI[5]-fltNormI)/16.0f + m_fltBufferI[1] - m_fltBufferI[3]);
|
|
|
|
|
|
|
|
fltVal += 2.125f;
|
|
|
|
fltVal /=4.25f;
|
|
|
|
|
|
|
|
m_fltBufferI[5]=m_fltBufferI[4];
|
|
|
|
m_fltBufferQ[5]=m_fltBufferQ[4];
|
|
|
|
|
|
|
|
m_fltBufferI[4]=m_fltBufferI[3];
|
|
|
|
m_fltBufferQ[4]=m_fltBufferQ[3];
|
|
|
|
|
|
|
|
m_fltBufferI[3]=m_fltBufferI[2];
|
|
|
|
m_fltBufferQ[3]=m_fltBufferQ[2];
|
|
|
|
|
|
|
|
m_fltBufferI[2]=m_fltBufferI[1];
|
|
|
|
m_fltBufferQ[2]=m_fltBufferQ[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
m_fltBufferI[1]=m_fltBufferI[0];
|
|
|
|
m_fltBufferQ[1]=m_fltBufferQ[0];
|
|
|
|
|
|
|
|
m_fltBufferI[0]=fltNormI;
|
|
|
|
m_fltBufferQ[0]=fltNormQ;
|
|
|
|
|
|
|
|
}
|
2017-03-16 13:56:20 -04:00
|
|
|
else if (m_enmModulation == ATV_AM)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
|
|
|
//Amplitude AM
|
|
|
|
fltVal = fltNorm;
|
|
|
|
|
|
|
|
//********** Mini and Maxi Amplitude tracking **********
|
|
|
|
|
|
|
|
if(fltVal<m_fltEffMin)
|
|
|
|
{
|
|
|
|
m_fltEffMin=fltVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(fltVal>m_fltEffMax)
|
|
|
|
{
|
|
|
|
m_fltEffMax=fltVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Normalisation
|
|
|
|
fltVal -= m_fltAmpMin;
|
|
|
|
fltVal /=m_fltAmpDelta;
|
|
|
|
}
|
2017-03-16 13:56:20 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fltVal = 0.0f;
|
|
|
|
}
|
2017-02-23 02:18:56 -05:00
|
|
|
|
|
|
|
m_fltAmpLineAverage += fltVal;
|
|
|
|
|
|
|
|
//********** gray level **********
|
|
|
|
//-0.3 -> 0.7
|
2017-03-16 19:33:14 -04:00
|
|
|
intVal = (int) 255.0*(fltVal - m_objRunning.m_fltVoltLevelSynchroBlack) / fltDivSynchroBlack;
|
2017-02-23 02:18:56 -05:00
|
|
|
|
|
|
|
//0 -> 255
|
|
|
|
if(intVal<0)
|
|
|
|
{
|
|
|
|
intVal=0;
|
|
|
|
}
|
|
|
|
else if(intVal>255)
|
|
|
|
{
|
|
|
|
intVal=255;
|
|
|
|
}
|
|
|
|
|
|
|
|
//********** Filling pixels **********
|
|
|
|
|
2017-03-16 19:12:12 -04:00
|
|
|
blnComputeImage = (m_objRunning.m_fltRatioOfRowsToDisplay != 0.5f);
|
2017-02-23 02:18:56 -05:00
|
|
|
|
2017-03-16 17:10:40 -04:00
|
|
|
if (!blnComputeImage)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
2017-03-16 19:12:12 -04:00
|
|
|
blnComputeImage = ((m_intImageIndex/2) % 2 == 0);
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
2017-03-16 17:10:40 -04:00
|
|
|
if (blnComputeImage)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
|
|
|
m_objRegisteredATVScreen->setDataColor(m_intColIndex,intVal, intVal, intVal);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_intColIndex++;
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
m_blnSynchroDetected=false;
|
|
|
|
if((m_objRunning.m_blnHSync) && (m_intRowIndex>1))
|
|
|
|
{
|
|
|
|
//********** Line Synchro 0-0-0 -> 0.3-0.3 0.3 **********
|
|
|
|
if(m_blnImageDetecting==false)
|
|
|
|
{
|
|
|
|
//Floor Detection 0
|
2017-03-16 19:33:14 -04:00
|
|
|
if (fltVal <= m_objRunning.m_fltVoltLevelSynchroTop)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
|
|
|
m_intSynchroPoints ++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_intSynchroPoints=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_intSynchroPoints>=m_intNumberSamplePerTop)
|
|
|
|
{
|
|
|
|
m_blnSynchroDetected=true;
|
|
|
|
m_blnImageDetecting=true;
|
|
|
|
m_intSynchroPoints=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Image detection Sub Black 0.3
|
2017-03-16 19:33:14 -04:00
|
|
|
if (fltVal >= m_objRunning.m_fltVoltLevelSynchroBlack)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
|
|
|
m_intSynchroPoints ++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_intSynchroPoints=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_intSynchroPoints>=m_intNumberSamplePerTop)
|
|
|
|
{
|
|
|
|
m_blnSynchroDetected=false;
|
|
|
|
m_blnImageDetecting=false;
|
|
|
|
m_intSynchroPoints=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//********** Rendering if necessary **********
|
|
|
|
|
|
|
|
// Vertical Synchro : 3/4 a line necessary
|
|
|
|
if(!m_blnVerticalSynchroDetected && m_objRunning.m_blnVSync)
|
|
|
|
{
|
|
|
|
if(m_intColIndex>=intSynchroTimeSamples)
|
|
|
|
{
|
|
|
|
if(m_fltAmpLineAverage<=fltSynchroTrameLevel) //(m_fltLevelSynchroBlack*(float)(m_intColIndex-((m_intNumberSamplePerLine*12)/64)))) //75
|
|
|
|
{
|
|
|
|
m_blnVerticalSynchroDetected=true;
|
|
|
|
|
|
|
|
m_intRowIndex=m_intImageIndex%2;
|
|
|
|
|
|
|
|
if(blnComputeImage)
|
|
|
|
{
|
|
|
|
m_objRegisteredATVScreen->selectRow(m_intRowIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Horizontal Synchro
|
|
|
|
if((m_intColIndex>=m_intNumberSamplePerLine)
|
|
|
|
|| (m_blnSynchroDetected==true))
|
|
|
|
{
|
|
|
|
m_blnSynchroDetected=false;
|
|
|
|
m_blnImageDetecting=true;
|
|
|
|
|
|
|
|
m_intColIndex=0;
|
|
|
|
|
2017-02-24 17:25:09 -05:00
|
|
|
if((m_blnSynchroDetected==false) || (m_blnLineSynchronized==true))
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
2017-02-24 17:25:09 -05:00
|
|
|
//New line + Interleaving
|
|
|
|
m_intRowIndex ++;
|
|
|
|
m_intRowIndex ++;
|
|
|
|
|
|
|
|
if(m_intRowIndex<m_intNumberOfLines)
|
|
|
|
{
|
|
|
|
m_objRegisteredATVScreen->selectRow(m_intRowIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_blnLineSynchronized=false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_blnLineSynchronized=m_blnSynchroDetected;
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_fltAmpLineAverage=0.0f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
if(m_intRowIndex>=m_intRowsLimit)
|
|
|
|
{
|
|
|
|
|
|
|
|
m_blnVerticalSynchroDetected=false;
|
|
|
|
|
|
|
|
m_fltAmpLineAverage=0.0f;
|
|
|
|
|
|
|
|
//Interleave Odd/Even images
|
|
|
|
m_intRowIndex=m_intImageIndex%2;
|
|
|
|
m_intColIndex=0;
|
|
|
|
|
|
|
|
if(blnComputeImage)
|
|
|
|
{
|
|
|
|
m_objRegisteredATVScreen->selectRow(m_intRowIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Rendering when odd image processed
|
|
|
|
if(m_intImageIndex%2==1)
|
2017-02-25 01:12:41 -05:00
|
|
|
{
|
2017-02-23 02:18:56 -05:00
|
|
|
//interleave
|
|
|
|
if(blnComputeImage)
|
|
|
|
{
|
|
|
|
m_objRegisteredATVScreen->renderImage(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_intRowsLimit = m_intNumberOfLines-1;
|
|
|
|
|
|
|
|
if(m_objRunning.m_enmModulation==ATV_AM)
|
|
|
|
{
|
|
|
|
m_fltAmpMin=m_fltEffMin;
|
|
|
|
m_fltAmpMax=m_fltEffMax;
|
|
|
|
m_fltAmpDelta=m_fltEffMax-m_fltEffMin;
|
|
|
|
|
|
|
|
if(m_fltAmpDelta<=0.0)
|
|
|
|
{
|
|
|
|
m_fltAmpDelta=1.0f;
|
|
|
|
}
|
2017-03-05 21:36:02 -05:00
|
|
|
|
|
|
|
//Reset extrema
|
|
|
|
m_fltEffMin=2000000.0f;
|
|
|
|
m_fltEffMax=-2000000.0f;
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2017-02-25 01:12:41 -05:00
|
|
|
{
|
2017-02-23 02:18:56 -05:00
|
|
|
if(m_intNumberOfLines%2==1)
|
|
|
|
{
|
|
|
|
m_intRowsLimit = m_intNumberOfLines;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_intRowsLimit = m_intNumberOfLines-2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_intImageIndex ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ptrBufferToRelease!=NULL)
|
|
|
|
{
|
|
|
|
delete ptrBufferToRelease;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_objSettingsMutex.unlock();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemod::start()
|
|
|
|
{
|
2017-02-25 01:12:41 -05:00
|
|
|
//m_objTimer.start();
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemod::stop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ATVDemod::handleMessage(const Message& cmd)
|
2017-02-25 01:12:41 -05:00
|
|
|
{
|
2017-03-05 21:36:02 -05:00
|
|
|
qDebug() << "ATVDemod::handleMessage";
|
2017-02-23 02:18:56 -05:00
|
|
|
|
|
|
|
if (DownChannelizer::MsgChannelizerNotification::match(cmd))
|
2017-03-05 21:36:02 -05:00
|
|
|
{
|
2017-02-23 02:18:56 -05:00
|
|
|
DownChannelizer::MsgChannelizerNotification& objNotif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
|
|
|
|
2017-03-16 18:29:22 -04:00
|
|
|
if(m_objRunning.m_intSampleRate!=objNotif.getSampleRate())
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
2017-03-16 18:29:22 -04:00
|
|
|
m_objRunning.m_intSampleRate = objNotif.getSampleRate();
|
2017-02-23 02:18:56 -05:00
|
|
|
ApplySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "ATVDemod::handleMessage: MsgChannelizerNotification:"
|
2017-03-16 18:29:22 -04:00
|
|
|
<< " m_intMsps: " << m_objRunning.m_intSampleRate;
|
2017-02-23 02:18:56 -05:00
|
|
|
|
2017-03-05 21:36:02 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureATVDemod::match(cmd))
|
|
|
|
{
|
2017-02-23 02:18:56 -05:00
|
|
|
MsgConfigureATVDemod& objCfg = (MsgConfigureATVDemod&) cmd;
|
|
|
|
|
2017-03-16 16:07:51 -04:00
|
|
|
m_objConfig.m_enmModulation = objCfg.m_objMsgConfig.m_enmModulation;
|
|
|
|
m_objConfig.m_fltVoltLevelSynchroBlack = objCfg.m_objMsgConfig.m_fltVoltLevelSynchroBlack;
|
|
|
|
m_objConfig.m_fltVoltLevelSynchroTop = objCfg.m_objMsgConfig.m_fltVoltLevelSynchroTop;
|
2017-03-16 19:12:12 -04:00
|
|
|
m_objConfig.m_fltFramePerS = objCfg.m_objMsgConfig.m_fltFramePerS;
|
2017-03-16 18:13:51 -04:00
|
|
|
m_objConfig.m_fltLineDurationUs = objCfg.m_objMsgConfig.m_fltLineDurationUs;
|
2017-03-16 19:12:12 -04:00
|
|
|
m_objConfig.m_fltRatioOfRowsToDisplay = objCfg.m_objMsgConfig.m_fltRatioOfRowsToDisplay;
|
2017-03-16 18:29:22 -04:00
|
|
|
m_objConfig.m_fltTopDurationUs = objCfg.m_objMsgConfig.m_fltTopDurationUs;
|
2017-03-16 16:07:51 -04:00
|
|
|
m_objConfig.m_blnHSync = objCfg.m_objMsgConfig.m_blnHSync;
|
|
|
|
m_objConfig.m_blnVSync = objCfg.m_objMsgConfig.m_blnVSync;
|
|
|
|
|
2017-02-23 02:18:56 -05:00
|
|
|
if((objCfg.m_objMsgConfig.m_enmModulation != m_objRunning.m_enmModulation)
|
|
|
|
|| (objCfg.m_objMsgConfig.m_fltVoltLevelSynchroBlack != m_objRunning.m_fltVoltLevelSynchroBlack)
|
|
|
|
|| (objCfg.m_objMsgConfig.m_fltVoltLevelSynchroTop != m_objRunning.m_fltVoltLevelSynchroTop)
|
2017-03-16 19:12:12 -04:00
|
|
|
|| (objCfg.m_objMsgConfig.m_fltFramePerS != m_objRunning.m_fltFramePerS)
|
2017-03-16 18:13:51 -04:00
|
|
|
|| (objCfg.m_objMsgConfig.m_fltLineDurationUs != m_objRunning.m_fltLineDurationUs)
|
2017-03-16 19:12:12 -04:00
|
|
|
|| (objCfg.m_objMsgConfig.m_fltRatioOfRowsToDisplay != m_objRunning.m_fltRatioOfRowsToDisplay)
|
2017-03-16 18:29:22 -04:00
|
|
|
|| (objCfg.m_objMsgConfig.m_fltTopDurationUs != m_objRunning.m_fltTopDurationUs)
|
2017-02-23 02:18:56 -05:00
|
|
|
|| (objCfg.m_objMsgConfig.m_blnHSync != m_objRunning.m_blnHSync)
|
|
|
|
|| (objCfg.m_objMsgConfig.m_blnVSync != m_objRunning.m_blnVSync))
|
|
|
|
{
|
|
|
|
m_objRunning.m_enmModulation = objCfg.m_objMsgConfig.m_enmModulation;
|
2017-03-16 19:12:12 -04:00
|
|
|
m_objRunning.m_fltFramePerS = objCfg.m_objMsgConfig.m_fltFramePerS;
|
2017-03-16 18:13:51 -04:00
|
|
|
m_objRunning.m_fltLineDurationUs = objCfg.m_objMsgConfig.m_fltLineDurationUs;
|
2017-03-16 19:12:12 -04:00
|
|
|
m_objRunning.m_fltRatioOfRowsToDisplay = objCfg.m_objMsgConfig.m_fltRatioOfRowsToDisplay;
|
2017-03-16 18:29:22 -04:00
|
|
|
m_objRunning.m_fltTopDurationUs = objCfg.m_objMsgConfig.m_fltTopDurationUs;
|
2017-02-23 02:18:56 -05:00
|
|
|
m_objRunning.m_blnHSync = objCfg.m_objMsgConfig.m_blnHSync;
|
|
|
|
m_objRunning.m_blnVSync = objCfg.m_objMsgConfig.m_blnVSync;
|
|
|
|
|
|
|
|
ApplySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-05 21:36:02 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemod::ApplySettings()
|
2017-02-25 01:12:41 -05:00
|
|
|
{
|
2017-02-23 02:18:56 -05:00
|
|
|
|
2017-03-16 18:29:22 -04:00
|
|
|
if(m_objRunning.m_intSampleRate==0)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-16 19:33:14 -04:00
|
|
|
m_objRunning.m_fltVoltLevelSynchroBlack = m_objConfig.m_fltVoltLevelSynchroBlack;
|
|
|
|
m_objRunning.m_fltVoltLevelSynchroTop = m_objConfig.m_fltVoltLevelSynchroTop;
|
2017-02-23 02:18:56 -05:00
|
|
|
|
2017-03-16 15:57:00 -04:00
|
|
|
InitATVParameters(
|
2017-03-16 18:29:22 -04:00
|
|
|
m_objRunning.m_intSampleRate,
|
2017-03-16 18:13:51 -04:00
|
|
|
m_objRunning.m_fltLineDurationUs,
|
2017-03-16 18:29:22 -04:00
|
|
|
m_objRunning.m_fltTopDurationUs,
|
2017-03-16 19:12:12 -04:00
|
|
|
m_objRunning.m_fltFramePerS,
|
|
|
|
m_objRunning.m_fltRatioOfRowsToDisplay,
|
2017-03-16 15:57:00 -04:00
|
|
|
m_objRunning.m_enmModulation,
|
|
|
|
m_objRunning.m_blnHSync,
|
|
|
|
m_objRunning.m_blnVSync);
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int ATVDemod::GetSampleRate()
|
|
|
|
{
|
2017-03-16 18:29:22 -04:00
|
|
|
return m_objRunning.m_intSampleRate;
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
2017-03-05 21:36:02 -05:00
|
|
|
|