mirror of https://github.com/f4exb/sdrangel.git
APT demod: send full image to GUI every 20 lines only else send an unprocessed line
This commit is contained in:
parent
054e6feaa5
commit
8d8a79e507
|
@ -45,6 +45,7 @@
|
||||||
MESSAGE_CLASS_DEFINITION(APTDemod::MsgConfigureAPTDemod, Message)
|
MESSAGE_CLASS_DEFINITION(APTDemod::MsgConfigureAPTDemod, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(APTDemod::MsgPixels, Message)
|
MESSAGE_CLASS_DEFINITION(APTDemod::MsgPixels, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(APTDemod::MsgImage, Message)
|
MESSAGE_CLASS_DEFINITION(APTDemod::MsgImage, Message)
|
||||||
|
MESSAGE_CLASS_DEFINITION(APTDemod::MsgLine, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(APTDemod::MsgResetDecoder, Message)
|
MESSAGE_CLASS_DEFINITION(APTDemod::MsgResetDecoder, Message)
|
||||||
|
|
||||||
const char * const APTDemod::m_channelIdURI = "sdrangel.channel.aptdemod";
|
const char * const APTDemod::m_channelIdURI = "sdrangel.channel.aptdemod";
|
||||||
|
|
|
@ -120,6 +120,32 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Unprocessed line to be sent to GUI
|
||||||
|
class MsgLine : public Message {
|
||||||
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
|
public:
|
||||||
|
const uchar* getLine() const { return m_line; }
|
||||||
|
int getSize() const { return m_size; }
|
||||||
|
void setSize(int size) { m_size = size;}
|
||||||
|
|
||||||
|
static MsgLine* create(uchar **line)
|
||||||
|
{
|
||||||
|
MsgLine *msg = new MsgLine();
|
||||||
|
*line = msg->m_line;
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uchar m_line[APT_PROW_WIDTH];
|
||||||
|
int m_size;
|
||||||
|
|
||||||
|
MsgLine() :
|
||||||
|
Message(),
|
||||||
|
m_size(APT_PROW_WIDTH)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
// Sent from GUI to reset decoder
|
// Sent from GUI to reset decoder
|
||||||
class MsgResetDecoder : public Message {
|
class MsgResetDecoder : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
|
@ -126,6 +126,37 @@ bool APTDemodGUI::handleMessage(const Message& message)
|
||||||
ui->imageContainer->setWindowTitle("Received image");
|
ui->imageContainer->setWindowTitle("Received image");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (APTDemod::MsgLine::match(message))
|
||||||
|
{
|
||||||
|
const APTDemod::MsgLine& lineMsg = (APTDemod::MsgLine&) message;
|
||||||
|
|
||||||
|
if (m_image.width() == 0)
|
||||||
|
{
|
||||||
|
m_image = QImage(lineMsg.getSize(), 1, QImage::Format_Grayscale8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_image = m_image.copy(0, 0, m_image.width(), m_image.height()+1); // Add a line at tne bottom
|
||||||
|
|
||||||
|
if (m_settings.m_flip)
|
||||||
|
{
|
||||||
|
m_pixmap.convertFromImage(m_image);
|
||||||
|
m_pixmap.scroll(0, 1, 0, 0, m_image.width(), m_image.height()-1); // scroll down 1 line
|
||||||
|
m_image = m_pixmap.toImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int len = std::min(m_image.width(), lineMsg.getSize());
|
||||||
|
std::copy(
|
||||||
|
lineMsg.getLine(),
|
||||||
|
lineMsg.getLine() + len,
|
||||||
|
m_image.scanLine(m_settings.m_flip ? 0 : m_image.height()-1)
|
||||||
|
);
|
||||||
|
m_pixmap.convertFromImage(m_image);
|
||||||
|
ui->image->setPixmap(m_pixmap);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if (DSPSignalNotification::match(message))
|
else if (DSPSignalNotification::match(message))
|
||||||
{
|
{
|
||||||
DSPSignalNotification& notif = (DSPSignalNotification&) message;
|
DSPSignalNotification& notif = (DSPSignalNotification&) message;
|
||||||
|
|
|
@ -157,8 +157,14 @@ void APTDemodImageWorker::resetDecoder()
|
||||||
void APTDemodImageWorker::processPixels(const float *pixels)
|
void APTDemodImageWorker::processPixels(const float *pixels)
|
||||||
{
|
{
|
||||||
std::copy(pixels, pixels + APT_PROW_WIDTH, m_image.prow[m_image.nrow]);
|
std::copy(pixels, pixels + APT_PROW_WIDTH, m_image.prow[m_image.nrow]);
|
||||||
m_image.nrow++;
|
|
||||||
|
if (m_image.nrow % 20 == 0) { // send full image only every 20 lines
|
||||||
sendImageToGUI();
|
sendImageToGUI();
|
||||||
|
} else { // else send unprocessed line just to show stg is moving
|
||||||
|
sendLineToGUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_image.nrow++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APTDemodImageWorker::sendImageToGUI()
|
void APTDemodImageWorker::sendImageToGUI()
|
||||||
|
@ -172,6 +178,40 @@ void APTDemodImageWorker::sendImageToGUI()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void APTDemodImageWorker::sendLineToGUI()
|
||||||
|
{
|
||||||
|
if (m_messageQueueToGUI)
|
||||||
|
{
|
||||||
|
float *pixels = m_image.prow[m_image.nrow];
|
||||||
|
uchar *line;
|
||||||
|
APTDemod::MsgLine *msg = APTDemod::MsgLine::create(&line);
|
||||||
|
|
||||||
|
if (m_settings.m_channels == APTDemodSettings::BOTH_CHANNELS)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < APT_IMG_WIDTH; i++) {
|
||||||
|
line[i] = roundAndClip(pixels[i]);
|
||||||
|
}
|
||||||
|
msg->setSize(APT_IMG_WIDTH);
|
||||||
|
}
|
||||||
|
else if (m_settings.m_channels == APTDemodSettings::CHANNEL_A)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < APT_CH_WIDTH; i++) {
|
||||||
|
line[i] = roundAndClip(pixels[i + APT_CHA_OFFSET]);
|
||||||
|
}
|
||||||
|
msg->setSize(APT_CH_WIDTH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < APT_CH_WIDTH; i++) {
|
||||||
|
line[i] = roundAndClip(pixels[i + APT_CHB_OFFSET]);
|
||||||
|
}
|
||||||
|
msg->setSize(APT_CH_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_messageQueueToGUI->push(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QImage APTDemodImageWorker::processImage(QStringList& imageTypes)
|
QImage APTDemodImageWorker::processImage(QStringList& imageTypes)
|
||||||
{
|
{
|
||||||
copyImage(&m_tempImage, &m_image);
|
copyImage(&m_tempImage, &m_image);
|
||||||
|
|
|
@ -104,6 +104,7 @@ private:
|
||||||
void resetDecoder();
|
void resetDecoder();
|
||||||
void processPixels(const float *pixels);
|
void processPixels(const float *pixels);
|
||||||
void sendImageToGUI();
|
void sendImageToGUI();
|
||||||
|
void sendLineToGUI();
|
||||||
void saveImageToDisk();
|
void saveImageToDisk();
|
||||||
QImage processImage(QStringList& imageTypes);
|
QImage processImage(QStringList& imageTypes);
|
||||||
QImage extractImage(QImage image);
|
QImage extractImage(QImage image);
|
||||||
|
|
Loading…
Reference in New Issue