2017-03-05 21:39:34 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef PLUGINS_CHANNELTX_MODATV_ATVMOD_H_
|
|
|
|
#define PLUGINS_CHANNELTX_MODATV_ATVMOD_H_
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QMutex>
|
|
|
|
|
2017-03-10 08:28:04 -05:00
|
|
|
#include <vector>
|
|
|
|
|
2017-03-08 02:36:28 -05:00
|
|
|
#include <opencv2/core/core.hpp>
|
|
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "dsp/basebandsamplesource.h"
|
|
|
|
#include "dsp/nco.h"
|
|
|
|
#include "dsp/interpolator.h"
|
|
|
|
#include "dsp/movingaverage.h"
|
2017-03-15 00:24:02 -04:00
|
|
|
#include "dsp/fftfilt.h"
|
2017-03-05 21:39:34 -05:00
|
|
|
#include "util/message.h"
|
|
|
|
|
|
|
|
class ATVMod : public BasebandSampleSource {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef enum
|
|
|
|
{
|
2017-03-06 12:40:14 -05:00
|
|
|
ATVStdPAL625,
|
2017-03-19 22:35:27 -04:00
|
|
|
ATVStdPAL525,
|
2017-04-02 16:32:08 -04:00
|
|
|
ATVStd405,
|
2017-04-02 21:17:37 -04:00
|
|
|
ATVStdShortInterleaved,
|
|
|
|
ATVStdShort,
|
2017-04-03 12:37:26 -04:00
|
|
|
ATVStdHLeap,
|
2017-03-05 21:39:34 -05:00
|
|
|
} ATVStd;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ATVModInputUniform,
|
2017-03-06 19:38:19 -05:00
|
|
|
ATVModInputHBars,
|
|
|
|
ATVModInputVBars,
|
2017-03-08 13:04:10 -05:00
|
|
|
ATVModInputChessboard,
|
2017-03-06 19:38:19 -05:00
|
|
|
ATVModInputHGradient,
|
2017-03-07 19:35:18 -05:00
|
|
|
ATVModInputVGradient,
|
|
|
|
ATVModInputImage,
|
2017-03-10 13:06:51 -05:00
|
|
|
ATVModInputVideo,
|
|
|
|
ATVModInputCamera
|
2017-03-05 21:39:34 -05:00
|
|
|
} ATVModInput;
|
|
|
|
|
2017-03-07 13:19:54 -05:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ATVModulationAM,
|
2017-03-15 00:05:42 -04:00
|
|
|
ATVModulationFM,
|
|
|
|
ATVModulationUSB,
|
2017-03-15 21:45:51 -04:00
|
|
|
ATVModulationLSB,
|
|
|
|
ATVModulationVestigialUSB,
|
|
|
|
ATVModulationVestigialLSB
|
2017-03-07 13:19:54 -05:00
|
|
|
} ATVModulation;
|
|
|
|
|
2017-03-07 19:35:18 -05:00
|
|
|
class MsgConfigureImageFileName : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const QString& getFileName() const { return m_fileName; }
|
|
|
|
|
|
|
|
static MsgConfigureImageFileName* create(const QString& fileName)
|
|
|
|
{
|
|
|
|
return new MsgConfigureImageFileName(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_fileName;
|
|
|
|
|
|
|
|
MsgConfigureImageFileName(const QString& fileName) :
|
|
|
|
Message(),
|
|
|
|
m_fileName(fileName)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-08 20:09:31 -05:00
|
|
|
class MsgConfigureVideoFileName : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const QString& getFileName() const { return m_fileName; }
|
|
|
|
|
|
|
|
static MsgConfigureVideoFileName* create(const QString& fileName)
|
|
|
|
{
|
|
|
|
return new MsgConfigureVideoFileName(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_fileName;
|
|
|
|
|
|
|
|
MsgConfigureVideoFileName(const QString& fileName) :
|
|
|
|
Message(),
|
|
|
|
m_fileName(fileName)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-09 17:17:14 -05:00
|
|
|
class MsgConfigureVideoFileSourceSeek : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getPercentage() const { return m_seekPercentage; }
|
|
|
|
|
|
|
|
static MsgConfigureVideoFileSourceSeek* create(int seekPercentage)
|
|
|
|
{
|
|
|
|
return new MsgConfigureVideoFileSourceSeek(seekPercentage);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_seekPercentage; //!< percentage of seek position from the beginning 0..100
|
|
|
|
|
|
|
|
MsgConfigureVideoFileSourceSeek(int seekPercentage) :
|
|
|
|
Message(),
|
|
|
|
m_seekPercentage(seekPercentage)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgConfigureVideoFileSourceStreamTiming : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static MsgConfigureVideoFileSourceStreamTiming* create()
|
|
|
|
{
|
|
|
|
return new MsgConfigureVideoFileSourceStreamTiming();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
MsgConfigureVideoFileSourceStreamTiming() :
|
|
|
|
Message()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportVideoFileSourceStreamTiming : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getFrameCount() const { return m_frameCount; }
|
|
|
|
|
|
|
|
static MsgReportVideoFileSourceStreamTiming* create(int frameCount)
|
|
|
|
{
|
|
|
|
return new MsgReportVideoFileSourceStreamTiming(frameCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_frameCount;
|
|
|
|
|
|
|
|
MsgReportVideoFileSourceStreamTiming(int frameCount) :
|
|
|
|
Message(),
|
|
|
|
m_frameCount(frameCount)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportVideoFileSourceStreamData : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getFrameRate() const { return m_frameRate; }
|
|
|
|
quint32 getVideoLength() const { return m_videoLength; }
|
|
|
|
|
|
|
|
static MsgReportVideoFileSourceStreamData* create(int frameRate,
|
|
|
|
quint32 recordLength)
|
|
|
|
{
|
|
|
|
return new MsgReportVideoFileSourceStreamData(frameRate, recordLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_frameRate;
|
|
|
|
int m_videoLength; //!< Video length in frames
|
|
|
|
|
|
|
|
MsgReportVideoFileSourceStreamData(int frameRate,
|
|
|
|
int videoLength) :
|
|
|
|
Message(),
|
|
|
|
m_frameRate(frameRate),
|
|
|
|
m_videoLength(videoLength)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-10 13:06:51 -05:00
|
|
|
class MsgConfigureCameraIndex : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getIndex() const { return m_index; }
|
|
|
|
|
|
|
|
static MsgConfigureCameraIndex* create(int index)
|
|
|
|
{
|
|
|
|
return new MsgConfigureCameraIndex(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_index;
|
|
|
|
|
|
|
|
MsgConfigureCameraIndex(int index) :
|
|
|
|
Message(),
|
|
|
|
m_index(index)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-24 14:06:29 -04:00
|
|
|
class MsgConfigureCameraData : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getIndex() const { return m_index; }
|
|
|
|
float getManualFPS() const { return m_manualFPS; }
|
|
|
|
bool getManualFPSEnable() const { return m_manualFPSEnable; }
|
|
|
|
|
|
|
|
static MsgConfigureCameraData* create(
|
|
|
|
int index,
|
|
|
|
float manualFPS,
|
|
|
|
bool manualFPSEnable)
|
|
|
|
{
|
|
|
|
return new MsgConfigureCameraData(index, manualFPS, manualFPSEnable);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_index;
|
|
|
|
float m_manualFPS;
|
|
|
|
bool m_manualFPSEnable;
|
|
|
|
|
|
|
|
MsgConfigureCameraData(int index, float manualFPS, bool manualFPSEnable) :
|
|
|
|
Message(),
|
|
|
|
m_index(index),
|
|
|
|
m_manualFPS(manualFPS),
|
|
|
|
m_manualFPSEnable(manualFPSEnable)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-10 13:06:51 -05:00
|
|
|
class MsgReportCameraData : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getdeviceNumber() const { return m_deviceNumber; }
|
2017-03-11 00:57:22 -05:00
|
|
|
float getFPS() const { return m_fps; }
|
2017-03-24 13:40:15 -04:00
|
|
|
float getFPSManual() const { return m_fpsManual; }
|
|
|
|
bool getFPSManualEnable() const { return m_fpsManualEnable; }
|
2017-03-10 13:06:51 -05:00
|
|
|
int getWidth() const { return m_width; }
|
|
|
|
int getHeight() const { return m_height; }
|
2017-03-11 21:51:22 -05:00
|
|
|
int getStatus() const { return m_status; }
|
2017-03-10 13:06:51 -05:00
|
|
|
|
|
|
|
static MsgReportCameraData* create(
|
|
|
|
int deviceNumber,
|
2017-03-11 21:51:22 -05:00
|
|
|
float fps,
|
2017-03-24 13:40:15 -04:00
|
|
|
float fpsManual,
|
|
|
|
bool fpsManualEnable,
|
2017-03-10 13:06:51 -05:00
|
|
|
int width,
|
2017-03-11 21:51:22 -05:00
|
|
|
int height,
|
|
|
|
int status)
|
2017-03-10 13:06:51 -05:00
|
|
|
{
|
|
|
|
return new MsgReportCameraData(
|
|
|
|
deviceNumber,
|
|
|
|
fps,
|
2017-03-24 13:40:15 -04:00
|
|
|
fpsManual,
|
|
|
|
fpsManualEnable,
|
2017-03-10 13:06:51 -05:00
|
|
|
width,
|
2017-03-11 21:51:22 -05:00
|
|
|
height,
|
|
|
|
status);
|
2017-03-10 13:06:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_deviceNumber;
|
2017-03-11 00:57:22 -05:00
|
|
|
float m_fps;
|
2017-03-24 13:40:15 -04:00
|
|
|
float m_fpsManual;
|
|
|
|
bool m_fpsManualEnable;
|
2017-03-10 13:06:51 -05:00
|
|
|
int m_width;
|
|
|
|
int m_height;
|
2017-03-11 21:51:22 -05:00
|
|
|
int m_status;
|
2017-03-10 13:06:51 -05:00
|
|
|
|
|
|
|
MsgReportCameraData(
|
|
|
|
int deviceNumber,
|
2017-03-11 00:57:22 -05:00
|
|
|
float fps,
|
2017-03-24 13:40:15 -04:00
|
|
|
float fpsManual,
|
|
|
|
bool fpsManualEnable,
|
2017-03-10 13:06:51 -05:00
|
|
|
int width,
|
2017-03-11 21:51:22 -05:00
|
|
|
int height,
|
|
|
|
int status) :
|
2017-03-10 13:06:51 -05:00
|
|
|
Message(),
|
|
|
|
m_deviceNumber(deviceNumber),
|
|
|
|
m_fps(fps),
|
2017-03-24 13:40:15 -04:00
|
|
|
m_fpsManual(fpsManual),
|
|
|
|
m_fpsManualEnable(fpsManualEnable),
|
2017-03-10 13:06:51 -05:00
|
|
|
m_width(width),
|
2017-03-11 21:51:22 -05:00
|
|
|
m_height(height),
|
|
|
|
m_status(status)
|
2017-03-10 13:06:51 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-12 10:10:59 -04:00
|
|
|
class MsgConfigureOverlayText : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const QString& getOverlayText() const { return m_overlayText; }
|
|
|
|
|
|
|
|
static MsgConfigureOverlayText* create(const QString& overlayText)
|
|
|
|
{
|
|
|
|
return new MsgConfigureOverlayText(overlayText);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_overlayText;
|
|
|
|
|
|
|
|
MsgConfigureOverlayText(const QString& overlayText) :
|
|
|
|
Message(),
|
|
|
|
m_overlayText(overlayText)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgConfigureShowOverlayText : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getShowOverlayText() const { return m_showOverlayText; }
|
|
|
|
|
|
|
|
static MsgConfigureShowOverlayText* create(bool showOverlayText)
|
|
|
|
{
|
|
|
|
return new MsgConfigureShowOverlayText(showOverlayText);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_showOverlayText;
|
|
|
|
|
|
|
|
MsgConfigureShowOverlayText(bool showOverlayText) :
|
|
|
|
Message(),
|
|
|
|
m_showOverlayText(showOverlayText)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-19 22:35:27 -04:00
|
|
|
class MsgReportEffectiveSampleRate : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getSampleRate() const { return m_sampleRate; }
|
2017-03-22 06:48:39 -04:00
|
|
|
uint32_t gatNbPointsPerLine() const { return m_nbPointsPerLine; }
|
2017-03-19 22:35:27 -04:00
|
|
|
|
2017-03-22 06:48:39 -04:00
|
|
|
static MsgReportEffectiveSampleRate* create(int sampleRate, uint32_t nbPointsPerLine)
|
2017-03-19 22:35:27 -04:00
|
|
|
{
|
2017-03-22 06:48:39 -04:00
|
|
|
return new MsgReportEffectiveSampleRate(sampleRate, nbPointsPerLine);
|
2017-03-19 22:35:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_sampleRate;
|
2017-03-22 06:48:39 -04:00
|
|
|
uint32_t m_nbPointsPerLine;
|
2017-03-19 22:35:27 -04:00
|
|
|
|
2017-03-22 06:48:39 -04:00
|
|
|
MsgReportEffectiveSampleRate(
|
|
|
|
int sampleRate,
|
|
|
|
uint32_t nbPointsPerLine) :
|
2017-03-19 22:35:27 -04:00
|
|
|
Message(),
|
2017-03-22 06:48:39 -04:00
|
|
|
m_sampleRate(sampleRate),
|
|
|
|
m_nbPointsPerLine(nbPointsPerLine)
|
2017-03-19 22:35:27 -04:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
ATVMod();
|
|
|
|
~ATVMod();
|
|
|
|
|
|
|
|
void configure(MessageQueue* messageQueue,
|
|
|
|
Real rfBandwidth,
|
2017-03-16 05:11:03 -04:00
|
|
|
Real rfOppBandwidth,
|
2017-03-05 21:39:34 -05:00
|
|
|
ATVStd atvStd,
|
2017-03-20 22:56:01 -04:00
|
|
|
int nbLines,
|
|
|
|
int fps,
|
2017-03-05 21:39:34 -05:00
|
|
|
ATVModInput atvModInput,
|
|
|
|
Real uniformLevel,
|
2017-03-07 13:19:54 -05:00
|
|
|
ATVModulation atvModulation,
|
2017-03-09 18:30:15 -05:00
|
|
|
bool videoPlayLoop,
|
|
|
|
bool videoPlay,
|
2017-03-11 02:21:26 -05:00
|
|
|
bool cameraPLay,
|
2017-03-19 05:49:02 -04:00
|
|
|
bool channelMute,
|
2017-03-21 16:59:44 -04:00
|
|
|
bool invertedVideo,
|
2017-03-21 18:29:42 -04:00
|
|
|
float rfScaling,
|
2017-03-22 08:10:42 -04:00
|
|
|
float fmExcursion,
|
|
|
|
bool forceDecimator);
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
virtual void pull(Sample& sample);
|
|
|
|
virtual void pullAudio(int nbSamples); // this is used for video signal actually
|
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& cmd);
|
|
|
|
|
2017-03-21 07:16:43 -04:00
|
|
|
int getEffectiveSampleRate() const { return m_tvSampleRate; };
|
2017-03-05 21:39:34 -05:00
|
|
|
Real getMagSq() const { return m_movingAverage.average(); }
|
2017-03-11 00:57:22 -05:00
|
|
|
void getCameraNumbers(std::vector<int>& numbers);
|
2017-03-10 08:28:04 -05:00
|
|
|
|
2017-03-26 17:47:21 -04:00
|
|
|
static void getBaseValues(int outputSampleRate, int linesPerSecond, int& sampleRateUnits, uint32_t& nbPointsPerRateUnit);
|
2017-03-19 22:35:27 -04:00
|
|
|
static float getRFBandwidthDivisor(ATVModulation modulation);
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
signals:
|
|
|
|
/**
|
|
|
|
* Level changed
|
|
|
|
* \param rmsLevel RMS level in range 0.0 - 1.0
|
|
|
|
* \param peakLevel Peak level in range 0.0 - 1.0
|
|
|
|
* \param numSamples Number of audio samples analyzed
|
|
|
|
*/
|
|
|
|
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
|
|
|
|
|
|
|
|
private:
|
|
|
|
class MsgConfigureATVMod : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
Real getRFBandwidth() const { return m_rfBandwidth; }
|
2017-03-16 05:11:03 -04:00
|
|
|
Real getRFOppBandwidth() const { return m_rfOppBandwidth; }
|
2017-03-05 21:39:34 -05:00
|
|
|
ATVStd getATVStd() const { return m_atvStd; }
|
|
|
|
ATVModInput getATVModInput() const { return m_atvModInput; }
|
2017-03-20 22:56:01 -04:00
|
|
|
int getNbLines() const { return m_nbLines; }
|
|
|
|
int getFPS() const { return m_fps; }
|
2017-03-05 21:39:34 -05:00
|
|
|
Real getUniformLevel() const { return m_uniformLevel; }
|
2017-03-07 13:19:54 -05:00
|
|
|
ATVModulation getModulation() const { return m_atvModulation; }
|
2017-03-09 18:30:15 -05:00
|
|
|
bool getVideoPlayLoop() const { return m_videoPlayLoop; }
|
|
|
|
bool getVideoPlay() const { return m_videoPlay; }
|
2017-03-11 02:21:26 -05:00
|
|
|
bool getCameraPlay() const { return m_cameraPlay; }
|
2017-03-14 13:59:49 -04:00
|
|
|
bool getChannelMute() const { return m_channelMute; }
|
2017-03-19 05:49:02 -04:00
|
|
|
bool getInvertedVideo() const { return m_invertedVideo; }
|
2017-03-21 16:59:44 -04:00
|
|
|
float getRFScaling() const { return m_rfScaling; }
|
2017-03-21 18:29:42 -04:00
|
|
|
float getFMExcursion() const { return m_fmExcursion; }
|
2017-03-22 08:10:42 -04:00
|
|
|
bool getForceDecimator() const { return m_forceDecimator; }
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
static MsgConfigureATVMod* create(
|
|
|
|
Real rfBandwidth,
|
2017-03-16 05:11:03 -04:00
|
|
|
Real rfOppBandwidth,
|
2017-03-05 21:39:34 -05:00
|
|
|
ATVStd atvStd,
|
2017-03-20 22:56:01 -04:00
|
|
|
int nbLines,
|
|
|
|
int fps,
|
2017-03-05 21:39:34 -05:00
|
|
|
ATVModInput atvModInput,
|
2017-03-07 13:19:54 -05:00
|
|
|
Real uniformLevel,
|
2017-03-09 18:30:15 -05:00
|
|
|
ATVModulation atvModulation,
|
|
|
|
bool videoPlayLoop,
|
2017-03-11 02:21:26 -05:00
|
|
|
bool videoPlay,
|
2017-03-14 13:59:49 -04:00
|
|
|
bool cameraPlay,
|
2017-03-19 05:49:02 -04:00
|
|
|
bool channelMute,
|
2017-03-21 16:59:44 -04:00
|
|
|
bool invertedVideo,
|
2017-03-21 18:29:42 -04:00
|
|
|
float rfScaling,
|
2017-03-22 08:10:42 -04:00
|
|
|
float fmExcursion,
|
|
|
|
bool forceDecimator)
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-03-09 18:30:15 -05:00
|
|
|
return new MsgConfigureATVMod(
|
|
|
|
rfBandwidth,
|
2017-03-16 05:11:03 -04:00
|
|
|
rfOppBandwidth,
|
2017-03-09 18:30:15 -05:00
|
|
|
atvStd,
|
2017-03-20 22:56:01 -04:00
|
|
|
nbLines,
|
|
|
|
fps,
|
2017-03-09 18:30:15 -05:00
|
|
|
atvModInput,
|
|
|
|
uniformLevel,
|
|
|
|
atvModulation,
|
|
|
|
videoPlayLoop,
|
2017-03-11 02:21:26 -05:00
|
|
|
videoPlay,
|
2017-03-14 13:59:49 -04:00
|
|
|
cameraPlay,
|
2017-03-19 05:49:02 -04:00
|
|
|
channelMute,
|
2017-03-21 16:59:44 -04:00
|
|
|
invertedVideo,
|
2017-03-21 18:29:42 -04:00
|
|
|
rfScaling,
|
2017-03-22 08:10:42 -04:00
|
|
|
fmExcursion,
|
|
|
|
forceDecimator);
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-03-07 13:19:54 -05:00
|
|
|
Real m_rfBandwidth;
|
2017-03-16 05:11:03 -04:00
|
|
|
Real m_rfOppBandwidth;
|
2017-03-07 13:19:54 -05:00
|
|
|
ATVStd m_atvStd;
|
2017-03-20 22:56:01 -04:00
|
|
|
int m_nbLines;
|
|
|
|
int m_fps;
|
2017-03-07 13:19:54 -05:00
|
|
|
ATVModInput m_atvModInput;
|
|
|
|
Real m_uniformLevel;
|
|
|
|
ATVModulation m_atvModulation;
|
2017-03-09 18:30:15 -05:00
|
|
|
bool m_videoPlayLoop;
|
|
|
|
bool m_videoPlay;
|
2017-03-11 02:21:26 -05:00
|
|
|
bool m_cameraPlay;
|
2017-03-14 13:59:49 -04:00
|
|
|
bool m_channelMute;
|
2017-03-19 05:49:02 -04:00
|
|
|
bool m_invertedVideo;
|
2017-03-21 16:59:44 -04:00
|
|
|
float m_rfScaling;
|
2017-03-21 18:29:42 -04:00
|
|
|
float m_fmExcursion;
|
2017-03-22 08:10:42 -04:00
|
|
|
bool m_forceDecimator;
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
MsgConfigureATVMod(
|
|
|
|
Real rfBandwidth,
|
2017-03-16 05:11:03 -04:00
|
|
|
Real rfOppBandwidth,
|
2017-03-05 21:39:34 -05:00
|
|
|
ATVStd atvStd,
|
2017-03-20 22:56:01 -04:00
|
|
|
int nbLines,
|
|
|
|
int fps,
|
2017-03-05 21:39:34 -05:00
|
|
|
ATVModInput atvModInput,
|
2017-03-07 13:19:54 -05:00
|
|
|
Real uniformLevel,
|
2017-03-09 18:30:15 -05:00
|
|
|
ATVModulation atvModulation,
|
|
|
|
bool videoPlayLoop,
|
2017-03-11 02:21:26 -05:00
|
|
|
bool videoPlay,
|
2017-03-14 13:59:49 -04:00
|
|
|
bool cameraPlay,
|
2017-03-19 05:49:02 -04:00
|
|
|
bool channelMute,
|
2017-03-21 16:59:44 -04:00
|
|
|
bool invertedVideo,
|
2017-03-21 18:29:42 -04:00
|
|
|
float rfScaling,
|
2017-03-22 08:10:42 -04:00
|
|
|
float fmExcursion,
|
|
|
|
bool forceDecimator) :
|
2017-03-05 21:39:34 -05:00
|
|
|
Message(),
|
|
|
|
m_rfBandwidth(rfBandwidth),
|
2017-03-16 05:11:03 -04:00
|
|
|
m_rfOppBandwidth(rfOppBandwidth),
|
2017-03-05 21:39:34 -05:00
|
|
|
m_atvStd(atvStd),
|
2017-03-20 22:56:01 -04:00
|
|
|
m_nbLines(nbLines),
|
|
|
|
m_fps(fps),
|
2017-03-05 21:39:34 -05:00
|
|
|
m_atvModInput(atvModInput),
|
2017-03-07 13:19:54 -05:00
|
|
|
m_uniformLevel(uniformLevel),
|
2017-03-09 18:30:15 -05:00
|
|
|
m_atvModulation(atvModulation),
|
|
|
|
m_videoPlayLoop(videoPlayLoop),
|
2017-03-11 02:21:26 -05:00
|
|
|
m_videoPlay(videoPlay),
|
2017-03-14 13:59:49 -04:00
|
|
|
m_cameraPlay(cameraPlay),
|
2017-03-19 05:49:02 -04:00
|
|
|
m_channelMute(channelMute),
|
2017-03-21 16:59:44 -04:00
|
|
|
m_invertedVideo(invertedVideo),
|
2017-03-21 18:29:42 -04:00
|
|
|
m_rfScaling(rfScaling),
|
2017-03-22 08:10:42 -04:00
|
|
|
m_fmExcursion(fmExcursion),
|
|
|
|
m_forceDecimator(forceDecimator)
|
2017-03-05 21:39:34 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-03-11 00:57:22 -05:00
|
|
|
struct ATVCamera
|
2017-03-10 13:06:51 -05:00
|
|
|
{
|
|
|
|
cv::VideoCapture m_camera; //!< camera object
|
|
|
|
cv::Mat m_videoframeOriginal; //!< camera non resized image
|
|
|
|
cv::Mat m_videoFrame; //!< displayable camera frame
|
|
|
|
int m_cameraNumber; //!< camera device number
|
|
|
|
float m_videoFPS; //!< camera FPS rate
|
2017-03-24 13:40:15 -04:00
|
|
|
float m_videoFPSManual; //!< camera FPS rate manually set
|
|
|
|
bool m_videoFPSManualEnable; //!< Enable camera FPS rate manual set value
|
2017-03-10 13:06:51 -05:00
|
|
|
int m_videoWidth; //!< camera frame width
|
|
|
|
int m_videoHeight; //!< camera frame height
|
|
|
|
float m_videoFx; //!< camera horizontal scaling factor
|
|
|
|
float m_videoFy; //!< camera vertictal scaling factor
|
|
|
|
float m_videoFPSq; //!< camera FPS sacaling factor
|
2017-03-24 13:40:15 -04:00
|
|
|
float m_videoFPSqManual; //!< camera FPS sacaling factor manually set
|
2017-03-11 02:21:26 -05:00
|
|
|
float m_videoFPSCount; //!< camera FPS fractional counter
|
|
|
|
int m_videoPrevFPSCount; //!< camera FPS previous integer counter
|
2017-03-10 13:06:51 -05:00
|
|
|
|
|
|
|
ATVCamera() :
|
|
|
|
m_cameraNumber(-1),
|
2017-03-11 00:57:22 -05:00
|
|
|
m_videoFPS(25.0f),
|
2017-03-24 13:40:15 -04:00
|
|
|
m_videoFPSManual(20.0f),
|
|
|
|
m_videoFPSManualEnable(false),
|
2017-03-10 13:06:51 -05:00
|
|
|
m_videoWidth(1),
|
|
|
|
m_videoHeight(1),
|
|
|
|
m_videoFx(1.0f),
|
|
|
|
m_videoFy(1.0f),
|
2017-03-11 02:21:26 -05:00
|
|
|
m_videoFPSq(1.0f),
|
2017-03-24 13:40:15 -04:00
|
|
|
m_videoFPSqManual(1.0f),
|
2017-03-11 02:21:26 -05:00
|
|
|
m_videoFPSCount(0.0f),
|
|
|
|
m_videoPrevFPSCount(0)
|
2017-03-10 13:06:51 -05:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
struct Config
|
|
|
|
{
|
2017-03-07 13:19:54 -05:00
|
|
|
int m_outputSampleRate; //!< sample rate from channelizer
|
|
|
|
qint64 m_inputFrequencyOffset; //!< offset from baseband center frequency
|
2017-03-16 05:11:03 -04:00
|
|
|
Real m_rfBandwidth; //!< Bandwidth of modulated signal or direct sideband for SSB / vestigial SSB
|
|
|
|
Real m_rfOppBandwidth; //!< Bandwidth of opposite sideband for vestigial SSB
|
2017-03-07 13:19:54 -05:00
|
|
|
ATVStd m_atvStd; //!< Standard
|
2017-03-20 22:56:01 -04:00
|
|
|
int m_nbLines; //!< Number of lines per full frame
|
|
|
|
int m_fps; //!< Number of frames per second
|
2017-03-07 13:19:54 -05:00
|
|
|
ATVModInput m_atvModInput; //!< Input source type
|
|
|
|
Real m_uniformLevel; //!< Percentage between black and white for uniform screen display
|
|
|
|
ATVModulation m_atvModulation; //!< RF modulation type
|
2017-03-09 18:30:15 -05:00
|
|
|
bool m_videoPlayLoop; //!< Play video in a loop
|
|
|
|
bool m_videoPlay; //!< True to play video and false to pause
|
2017-03-11 02:21:26 -05:00
|
|
|
bool m_cameraPlay; //!< True to play camera video and false to pause
|
2017-03-14 13:59:49 -04:00
|
|
|
bool m_channelMute; //!< Mute channel baseband output
|
2017-03-19 05:49:02 -04:00
|
|
|
bool m_invertedVideo; //!< True if video signal is inverted before modulation
|
2017-03-21 16:59:44 -04:00
|
|
|
float m_rfScalingFactor; //!< Scaling factor from +/-1 to +/-2^15
|
2017-03-21 18:29:42 -04:00
|
|
|
float m_fmExcursion; //!< FM excursion factor relative to full bandwidth
|
2017-03-22 08:10:42 -04:00
|
|
|
bool m_forceDecimator; //!< Forces decimator even when channel and source sample rates are equal
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
Config() :
|
|
|
|
m_outputSampleRate(-1),
|
|
|
|
m_inputFrequencyOffset(0),
|
|
|
|
m_rfBandwidth(0),
|
2017-03-16 05:11:03 -04:00
|
|
|
m_rfOppBandwidth(0),
|
2017-03-05 21:39:34 -05:00
|
|
|
m_atvStd(ATVStdPAL625),
|
2017-03-20 22:56:01 -04:00
|
|
|
m_nbLines(625),
|
|
|
|
m_fps(25),
|
2017-03-06 19:38:19 -05:00
|
|
|
m_atvModInput(ATVModInputHBars),
|
2017-03-07 13:19:54 -05:00
|
|
|
m_uniformLevel(0.5f),
|
2017-03-09 18:30:15 -05:00
|
|
|
m_atvModulation(ATVModulationAM),
|
|
|
|
m_videoPlayLoop(false),
|
2017-03-11 02:21:26 -05:00
|
|
|
m_videoPlay(false),
|
2017-03-14 13:59:49 -04:00
|
|
|
m_cameraPlay(false),
|
2017-03-15 22:23:58 -04:00
|
|
|
m_channelMute(false),
|
2017-03-21 16:59:44 -04:00
|
|
|
m_invertedVideo(false),
|
2017-03-21 18:29:42 -04:00
|
|
|
m_rfScalingFactor(29204.0f), // -1dB
|
2017-03-22 08:10:42 -04:00
|
|
|
m_fmExcursion(0.5f), // half bandwidth
|
|
|
|
m_forceDecimator(false)
|
2017-03-05 21:39:34 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
Config m_config;
|
|
|
|
Config m_running;
|
|
|
|
|
|
|
|
NCO m_carrierNco;
|
|
|
|
Complex m_modSample;
|
2017-03-07 13:19:54 -05:00
|
|
|
float m_modPhasor; //!< For FM modulation
|
2017-03-05 21:39:34 -05:00
|
|
|
Interpolator m_interpolator;
|
|
|
|
Real m_interpolatorDistance;
|
|
|
|
Real m_interpolatorDistanceRemain;
|
|
|
|
int m_tvSampleRate; //!< sample rate for generating signal
|
2017-03-22 06:48:39 -04:00
|
|
|
uint32_t m_pointsPerLine; //!< Number of points per full line
|
2017-03-05 21:39:34 -05:00
|
|
|
uint32_t m_pointsPerSync; //!< number of line points for the horizontal sync
|
|
|
|
uint32_t m_pointsPerBP; //!< number of line points for the back porch
|
2017-03-06 12:40:14 -05:00
|
|
|
uint32_t m_pointsPerImgLine; //!< number of line points for the image line
|
2017-03-05 21:39:34 -05:00
|
|
|
uint32_t m_pointsPerFP; //!< number of line points for the front porch
|
|
|
|
uint32_t m_pointsPerFSync; //!< number of line points for the field first sync
|
2017-03-06 19:38:19 -05:00
|
|
|
uint32_t m_pointsPerHBar; //!< number of line points for a bar of the bar chart
|
|
|
|
uint32_t m_linesPerVBar; //!< number of lines for a bar of the bar chart
|
2017-03-05 21:39:34 -05:00
|
|
|
uint32_t m_pointsPerTU; //!< number of line points per time unit
|
|
|
|
uint32_t m_nbLines; //!< number of lines per complete frame
|
2017-03-08 13:04:10 -05:00
|
|
|
uint32_t m_nbLines2; //!< same number as above (non interlaced) or half the number above (interlaced)
|
|
|
|
uint32_t m_nbImageLines; //!< number of image lines excluding synchronization lines
|
|
|
|
uint32_t m_nbImageLines2; //!< same number as above (non interlaced) or half the number above (interlaced)
|
2017-03-05 21:39:34 -05:00
|
|
|
uint32_t m_nbHorizPoints; //!< number of line points per horizontal line
|
2017-04-02 16:19:18 -04:00
|
|
|
uint32_t m_nbSyncLinesHeadE; //!< number of header sync lines on even frame
|
|
|
|
uint32_t m_nbSyncLinesHeadO; //!< number of header sync lines on odd frame
|
|
|
|
uint32_t m_nbSyncLinesBottom;//!< number of sync lines at bottom
|
|
|
|
uint32_t m_nbLongSyncLines; //!< number of whole long sync lines for vertical synchronization
|
|
|
|
uint32_t m_nbHalfLongSync; //!< number of half long sync / equalization lines
|
|
|
|
uint32_t m_nbWholeEqLines; //!< number of whole equalizing lines
|
|
|
|
bool m_singleLongSync; //!< single or double long sync per long sync line
|
2017-03-08 13:04:10 -05:00
|
|
|
uint32_t m_nbBlankLines; //!< number of lines in a frame (full or half) that are blanked (black) at the top of the image
|
2017-04-02 16:19:18 -04:00
|
|
|
float m_blankLineLvel; //!< video level of blank lines
|
2017-03-08 13:04:10 -05:00
|
|
|
float m_hBarIncrement; //!< video level increment at each horizontal bar increment
|
|
|
|
float m_vBarIncrement; //!< video level increment at each vertical bar increment
|
2017-04-02 14:23:21 -04:00
|
|
|
bool m_interleaved; //!< true if image is interlaced (2 half frames per frame)
|
2017-03-08 13:04:10 -05:00
|
|
|
bool m_evenImage; //!< in interlaced mode true if this is an even image
|
2017-03-05 21:39:34 -05:00
|
|
|
QMutex m_settingsMutex;
|
|
|
|
int m_horizontalCount; //!< current point index on line
|
|
|
|
int m_lineCount; //!< current line index in frame
|
2017-03-08 20:09:31 -05:00
|
|
|
float m_fps; //!< resulting frames per second
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
MovingAverage<Real> m_movingAverage;
|
|
|
|
quint32 m_levelCalcCount;
|
|
|
|
Real m_peakLevel;
|
|
|
|
Real m_levelSum;
|
|
|
|
|
2017-03-12 10:10:59 -04:00
|
|
|
cv::Mat m_imageFromFile; //!< original image not resized not overlaid by text
|
|
|
|
cv::Mat m_imageOriginal; //!< original not resized image
|
2017-03-08 19:00:46 -05:00
|
|
|
cv::Mat m_image; //!< resized image for transmission at given rate
|
2017-03-08 13:04:10 -05:00
|
|
|
bool m_imageOK;
|
2017-03-08 02:36:28 -05:00
|
|
|
|
2017-03-08 20:09:31 -05:00
|
|
|
cv::VideoCapture m_video; //!< current video capture
|
2017-03-10 13:06:51 -05:00
|
|
|
cv::Mat m_videoframeOriginal; //!< current frame from video
|
|
|
|
cv::Mat m_videoFrame; //!< current displayable video frame
|
2017-03-09 13:07:45 -05:00
|
|
|
float m_videoFPS; //!< current video FPS rate
|
|
|
|
int m_videoWidth; //!< current video frame width
|
|
|
|
int m_videoHeight; //!< current video frame height
|
|
|
|
float m_videoFx; //!< current video horizontal scaling factor
|
|
|
|
float m_videoFy; //!< current video vertictal scaling factor
|
|
|
|
float m_videoFPSq; //!< current video FPS sacaling factor
|
|
|
|
float m_videoFPSCount; //!< current video FPS fractional counter
|
|
|
|
int m_videoPrevFPSCount; //!< current video FPS previous integer counter
|
2017-03-09 17:17:14 -05:00
|
|
|
int m_videoLength; //!< current video length in frames
|
2017-03-09 20:32:49 -05:00
|
|
|
bool m_videoEOF; //!< current video has reached end of file
|
2017-03-08 20:09:31 -05:00
|
|
|
bool m_videoOK;
|
|
|
|
|
2017-03-10 08:28:04 -05:00
|
|
|
std::vector<ATVCamera> m_cameras; //!< vector of available cameras
|
2017-03-10 13:06:51 -05:00
|
|
|
int m_cameraIndex; //!< curent camera index in list of available cameras
|
2017-03-10 08:28:04 -05:00
|
|
|
|
2017-03-12 10:10:59 -04:00
|
|
|
std::string m_overlayText;
|
|
|
|
bool m_showOverlayText;
|
|
|
|
|
2017-03-16 05:11:03 -04:00
|
|
|
// Used for standard SSB
|
2017-03-15 00:24:02 -04:00
|
|
|
fftfilt* m_SSBFilter;
|
|
|
|
Complex* m_SSBFilterBuffer;
|
|
|
|
int m_SSBFilterBufferIndex;
|
2017-03-16 05:11:03 -04:00
|
|
|
|
|
|
|
// Used for vestigial SSB with asymmetrical filtering (needs double sideband scheme)
|
|
|
|
fftfilt* m_DSBFilter;
|
|
|
|
Complex* m_DSBFilterBuffer;
|
2017-03-15 21:45:51 -04:00
|
|
|
int m_DSBFilterBufferIndex;
|
2017-03-16 05:11:03 -04:00
|
|
|
|
2017-03-15 00:24:02 -04:00
|
|
|
static const int m_ssbFftLen;
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
static const float m_blackLevel;
|
|
|
|
static const float m_spanLevel;
|
|
|
|
static const int m_levelNbSamples;
|
2017-03-14 03:08:48 -04:00
|
|
|
static const int m_nbBars; //!< number of bars in bar or chessboard patterns
|
|
|
|
static const int m_cameraFPSTestNbFrames; //!< number of frames for camera FPS test
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
void apply(bool force = false);
|
|
|
|
void pullFinalize(Complex& ci, Sample& sample);
|
|
|
|
void pullVideo(Real& sample);
|
|
|
|
void calculateLevel(Real& sample);
|
|
|
|
void modulateSample();
|
2017-03-15 01:10:39 -04:00
|
|
|
Complex& modulateSSB(Real& sample);
|
2017-03-15 21:45:51 -04:00
|
|
|
Complex& modulateVestigialSSB(Real& sample);
|
2017-03-26 18:00:24 -04:00
|
|
|
void applyStandard();
|
2017-03-08 17:48:14 -05:00
|
|
|
void openImage(const QString& fileName);
|
2017-03-08 20:09:31 -05:00
|
|
|
void openVideo(const QString& fileName);
|
2017-03-08 19:00:46 -05:00
|
|
|
void resizeImage();
|
2017-03-09 13:07:45 -05:00
|
|
|
void calculateVideoSizes();
|
|
|
|
void resizeVideo();
|
2017-03-09 17:17:14 -05:00
|
|
|
void seekVideoFileStream(int seekPercentage);
|
2017-03-10 08:28:04 -05:00
|
|
|
void scanCameras();
|
|
|
|
void releaseCameras();
|
2017-03-10 13:06:51 -05:00
|
|
|
void calculateCamerasSizes();
|
|
|
|
void resizeCameras();
|
2017-03-11 02:21:26 -05:00
|
|
|
void resizeCamera();
|
2017-03-12 10:10:59 -04:00
|
|
|
void mixImageAndText(cv::Mat& image);
|
2017-03-05 21:39:34 -05:00
|
|
|
|
2017-04-03 12:37:26 -04:00
|
|
|
inline void pullImageLine(Real& sample, bool noHSync = false)
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
|
|
|
if (m_horizontalCount < m_pointsPerSync) // sync pulse
|
|
|
|
{
|
2017-04-03 12:37:26 -04:00
|
|
|
sample = noHSync ? m_blackLevel : 0.0f; // ultra-black
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
|
|
|
else if (m_horizontalCount < m_pointsPerSync + m_pointsPerBP) // back porch
|
|
|
|
{
|
2017-03-06 12:40:14 -05:00
|
|
|
sample = m_blackLevel; // black
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
2017-03-06 12:40:14 -05:00
|
|
|
else if (m_horizontalCount < m_pointsPerSync + m_pointsPerBP + m_pointsPerImgLine)
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
|
|
|
int pointIndex = m_horizontalCount - (m_pointsPerSync + m_pointsPerBP);
|
2017-04-02 16:19:18 -04:00
|
|
|
int oddity = m_lineCount < m_nbLines2 + 1 ? 0 : 1;
|
|
|
|
int iLine = oddity == 0 ? m_lineCount : m_lineCount - m_nbLines2 - 1;
|
|
|
|
int iLineImage = iLine - m_nbBlankLines - (oddity == 0 ? m_nbSyncLinesHeadE : m_nbSyncLinesHeadO);
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
switch(m_running.m_atvModInput)
|
|
|
|
{
|
2017-03-06 19:38:19 -05:00
|
|
|
case ATVModInputHBars:
|
|
|
|
sample = (pointIndex / m_pointsPerHBar) * m_hBarIncrement + m_blackLevel;
|
2017-03-05 21:39:34 -05:00
|
|
|
break;
|
2017-03-06 19:38:19 -05:00
|
|
|
case ATVModInputVBars:
|
|
|
|
sample = (iLine / m_linesPerVBar) * m_vBarIncrement + m_blackLevel;
|
|
|
|
break;
|
2017-03-08 13:04:10 -05:00
|
|
|
case ATVModInputChessboard:
|
2017-03-07 16:55:11 -05:00
|
|
|
sample = (((iLine / m_linesPerVBar)*5 + (pointIndex / m_pointsPerHBar)) % 2) * m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
|
|
|
|
break;
|
2017-03-06 19:38:19 -05:00
|
|
|
case ATVModInputHGradient:
|
2017-03-06 12:40:14 -05:00
|
|
|
sample = (pointIndex / (float) m_pointsPerImgLine) * m_spanLevel + m_blackLevel;
|
2017-03-05 21:39:34 -05:00
|
|
|
break;
|
2017-03-06 19:38:19 -05:00
|
|
|
case ATVModInputVGradient:
|
|
|
|
sample = ((iLine -5) / (float) m_nbImageLines2) * m_spanLevel + m_blackLevel;
|
|
|
|
break;
|
2017-03-08 13:04:10 -05:00
|
|
|
case ATVModInputImage:
|
2017-03-11 18:29:10 -05:00
|
|
|
if (!m_imageOK || (iLineImage < -oddity) || m_image.empty())
|
2017-03-08 17:26:58 -05:00
|
|
|
{
|
|
|
|
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-09 13:07:45 -05:00
|
|
|
unsigned char pixv;
|
|
|
|
|
2017-04-02 14:23:21 -04:00
|
|
|
if (m_interleaved) {
|
2017-03-09 13:07:45 -05:00
|
|
|
pixv = m_image.at<unsigned char>(2*iLineImage + oddity, pointIndex); // row (y), col (x)
|
|
|
|
} else {
|
|
|
|
pixv = m_image.at<unsigned char>(iLineImage, pointIndex); // row (y), col (x)
|
|
|
|
}
|
|
|
|
|
2017-03-08 17:26:58 -05:00
|
|
|
sample = (pixv / 256.0f) * m_spanLevel + m_blackLevel;
|
|
|
|
}
|
|
|
|
break;
|
2017-03-09 13:07:45 -05:00
|
|
|
case ATVModInputVideo:
|
2017-03-11 18:29:10 -05:00
|
|
|
if (!m_videoOK || (iLineImage < -oddity) || m_videoFrame.empty())
|
2017-03-09 13:07:45 -05:00
|
|
|
{
|
|
|
|
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned char pixv;
|
|
|
|
|
2017-04-02 14:23:21 -04:00
|
|
|
if (m_interleaved) {
|
2017-03-10 13:06:51 -05:00
|
|
|
pixv = m_videoFrame.at<unsigned char>(2*iLineImage + oddity, pointIndex); // row (y), col (x)
|
2017-03-09 13:07:45 -05:00
|
|
|
} else {
|
2017-03-10 13:06:51 -05:00
|
|
|
pixv = m_videoFrame.at<unsigned char>(iLineImage, pointIndex); // row (y), col (x)
|
2017-03-09 13:07:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
sample = (pixv / 256.0f) * m_spanLevel + m_blackLevel;
|
|
|
|
}
|
|
|
|
break;
|
2017-03-11 02:21:26 -05:00
|
|
|
case ATVModInputCamera:
|
2017-03-11 18:29:10 -05:00
|
|
|
if ((iLineImage < -oddity) || (m_cameraIndex < 0))
|
2017-03-11 02:21:26 -05:00
|
|
|
{
|
|
|
|
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ATVCamera& camera = m_cameras[m_cameraIndex];
|
|
|
|
|
|
|
|
if (camera.m_videoFrame.empty())
|
|
|
|
{
|
|
|
|
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned char pixv;
|
|
|
|
|
2017-04-02 14:23:21 -04:00
|
|
|
if (m_interleaved) {
|
2017-03-11 02:21:26 -05:00
|
|
|
pixv = camera.m_videoFrame.at<unsigned char>(2*iLineImage + oddity, pointIndex); // row (y), col (x)
|
|
|
|
} else {
|
|
|
|
pixv = camera.m_videoFrame.at<unsigned char>(iLineImage, pointIndex); // row (y), col (x)
|
|
|
|
}
|
|
|
|
|
|
|
|
sample = (pixv / 256.0f) * m_spanLevel + m_blackLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2017-03-05 21:39:34 -05:00
|
|
|
case ATVModInputUniform:
|
|
|
|
default:
|
|
|
|
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // front porch
|
|
|
|
{
|
|
|
|
sample = m_blackLevel; // black
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-03 11:23:20 -04:00
|
|
|
inline void pullVSyncLineLongPulses(Real& sample)
|
|
|
|
{
|
|
|
|
int halfIndex = m_horizontalCount % (m_nbHorizPoints/2);
|
|
|
|
|
|
|
|
if (halfIndex < (m_nbHorizPoints/2) - m_pointsPerSync) // ultra-black
|
|
|
|
{
|
|
|
|
sample = 0.0f;
|
|
|
|
}
|
|
|
|
else // black
|
|
|
|
{
|
|
|
|
if (m_singleLongSync && (m_horizontalCount < m_nbHorizPoints/2)) {
|
|
|
|
sample = 0.0f;
|
|
|
|
} else {
|
|
|
|
sample = m_blackLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void pullVSyncLineEqualizingPulses(Real& sample)
|
|
|
|
{
|
|
|
|
if (m_horizontalCount < m_pointsPerSync)
|
|
|
|
{
|
|
|
|
sample = 0.0f; // ultra-black
|
|
|
|
}
|
|
|
|
else if (m_horizontalCount < (m_nbHorizPoints/2))
|
|
|
|
{
|
|
|
|
sample = m_blackLevel; // black
|
|
|
|
}
|
|
|
|
else if (m_horizontalCount < (m_nbHorizPoints/2) + m_pointsPerFSync)
|
|
|
|
{
|
|
|
|
sample = 0.0f; // ultra-black
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sample = m_blackLevel; // black
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void pullVSyncLineEqualizingThenLongPulses(Real& sample)
|
|
|
|
{
|
|
|
|
if (m_horizontalCount < m_pointsPerSync)
|
|
|
|
{
|
|
|
|
sample = 0.0f; // ultra-black
|
|
|
|
}
|
|
|
|
else if (m_horizontalCount < (m_nbHorizPoints/2))
|
|
|
|
{
|
|
|
|
sample = m_blackLevel; // black
|
|
|
|
}
|
|
|
|
else if (m_horizontalCount < m_nbHorizPoints - m_pointsPerSync)
|
|
|
|
{
|
|
|
|
sample = 0.0f; // ultra-black
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sample = m_blackLevel; // black
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void pullVSyncLineLongThenEqualizingPulses(Real& sample)
|
|
|
|
{
|
|
|
|
if (m_horizontalCount < (m_nbHorizPoints/2) - m_pointsPerSync)
|
|
|
|
{
|
|
|
|
sample = 0.0f; // ultra-black
|
|
|
|
}
|
|
|
|
else if (m_horizontalCount < (m_nbHorizPoints/2))
|
|
|
|
{
|
|
|
|
sample = m_blackLevel; // black
|
|
|
|
}
|
|
|
|
else if (m_horizontalCount < (m_nbHorizPoints/2) + m_pointsPerFSync)
|
|
|
|
{
|
|
|
|
sample = 0.0f; // ultra-black
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sample = m_blackLevel; // black
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-06 12:40:14 -05:00
|
|
|
inline void pullVSyncLine(Real& sample)
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-04-02 16:19:18 -04:00
|
|
|
if (m_lineCount < m_nbLines2 + 1) // even
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-04-02 16:19:18 -04:00
|
|
|
int fieldLine = m_lineCount;
|
|
|
|
|
|
|
|
if (fieldLine < m_nbLongSyncLines) // 0,1: Whole line "long" pulses
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-04-03 11:23:20 -04:00
|
|
|
pullVSyncLineLongPulses(sample);
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
2017-04-02 16:19:18 -04:00
|
|
|
else if (fieldLine < m_nbLongSyncLines + m_nbHalfLongSync) // long pulse then equalizing pulse
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-04-03 11:23:20 -04:00
|
|
|
pullVSyncLineLongThenEqualizingPulses(sample);
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
2017-04-02 16:19:18 -04:00
|
|
|
else if (fieldLine < m_nbLongSyncLines + m_nbHalfLongSync + m_nbWholeEqLines) // Whole line equalizing pulses
|
2017-03-06 12:40:14 -05:00
|
|
|
{
|
2017-04-03 11:23:20 -04:00
|
|
|
pullVSyncLineEqualizingPulses(sample);
|
2017-03-06 12:40:14 -05:00
|
|
|
}
|
2017-04-02 16:19:18 -04:00
|
|
|
else if (fieldLine > m_nbLines2 - m_nbHalfLongSync) // equalizing pulse then long pulse
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-04-03 11:23:20 -04:00
|
|
|
pullVSyncLineEqualizingThenLongPulses(sample);
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
2017-04-02 16:19:18 -04:00
|
|
|
else if (fieldLine > m_nbLines2 - m_nbHalfLongSync - m_nbWholeEqLines) // Whole line equalizing pulses
|
|
|
|
{
|
2017-04-03 11:23:20 -04:00
|
|
|
pullVSyncLineEqualizingPulses(sample);
|
2017-04-02 16:19:18 -04:00
|
|
|
}
|
|
|
|
else // black images
|
|
|
|
{
|
|
|
|
if (m_horizontalCount < m_pointsPerSync)
|
|
|
|
{
|
|
|
|
sample = 0.0f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sample = m_blankLineLvel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // odd
|
|
|
|
{
|
|
|
|
int fieldLine = m_lineCount - m_nbLines2 - 1;
|
|
|
|
|
|
|
|
if (fieldLine < m_nbLongSyncLines) // 0,1: Whole line "long" pulses
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-04-03 11:23:20 -04:00
|
|
|
pullVSyncLineLongPulses(sample);
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
2017-04-02 16:19:18 -04:00
|
|
|
else if (fieldLine < m_nbLongSyncLines + m_nbWholeEqLines) // Whole line equalizing pulses
|
|
|
|
{
|
2017-04-03 11:23:20 -04:00
|
|
|
pullVSyncLineEqualizingPulses(sample);
|
2017-04-02 16:19:18 -04:00
|
|
|
}
|
|
|
|
else if (fieldLine > m_nbLines2 - 1 - m_nbWholeEqLines - m_nbHalfLongSync) // Whole line equalizing pulses
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-04-03 11:23:20 -04:00
|
|
|
pullVSyncLineEqualizingPulses(sample);
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
2017-03-08 17:26:58 -05:00
|
|
|
else // black images
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-03-08 17:26:58 -05:00
|
|
|
if (m_horizontalCount < m_pointsPerSync)
|
|
|
|
{
|
|
|
|
sample = 0.0f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-02 16:19:18 -04:00
|
|
|
sample = m_blankLineLvel;
|
2017-03-08 17:26:58 -05:00
|
|
|
}
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* PLUGINS_CHANNELTX_MODATV_ATVMOD_H_ */
|