zhongfuqiang上传最新代码20250325
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// FFmpegDecoder.cpp
|
||||
#include "FFmpegDecoder.h"
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
FFmpegDecoder::FFmpegDecoder(QObject* parent) :
|
||||
QThread(parent),
|
||||
@@ -37,6 +39,9 @@ FFmpegDecoder::~FFmpegDecoder()
|
||||
|
||||
void FFmpegDecoder::processVideo(int itemIndex)
|
||||
{
|
||||
qDebug() << "processVideo running in thread:" << QThread::currentThread();
|
||||
qDebug() << "FFmpegDecoder thread:" << this->thread();
|
||||
|
||||
QLabel* originalLabel;
|
||||
if (isBackBoardOrAllBoard) {
|
||||
originalLabel = this->videoLabel_back;
|
||||
@@ -45,8 +50,8 @@ void FFmpegDecoder::processVideo(int itemIndex)
|
||||
originalLabel = this->videoLabel;
|
||||
}
|
||||
if ((FocusWindowWidth != 0) && (FocusWindowHeight != 0)) {
|
||||
qDebug() << "------ processVideo";
|
||||
FocusWindowDialog* dialog = nullptr;
|
||||
qDebug() << "---1--- processVideo";
|
||||
/*FocusWindowDialog* dialog = nullptr;
|
||||
if (FocusWindowWidth * 16 == FocusWindowHeight * 9) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(540, 960));
|
||||
}
|
||||
@@ -68,14 +73,49 @@ void FFmpegDecoder::processVideo(int itemIndex)
|
||||
this->videoLabelTemp = dialog->videoDisplayLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
|
||||
qDebug() << "---2--- processVideo";
|
||||
if ((dialog->exec() == QDialog::Accepted) || (dialog->exec() == QDialog::Rejected)) {
|
||||
mutex.lock();
|
||||
this->videoLabelTemp = originalLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
}
|
||||
delete dialog;
|
||||
delete dialog;*/
|
||||
QMetaObject::invokeMethod(qApp, [=]() {
|
||||
FocusWindowDialog* dialog = nullptr;
|
||||
if (FocusWindowWidth * 16 == FocusWindowHeight * 9) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(540, 960));
|
||||
}
|
||||
else if (FocusWindowWidth * 9 == FocusWindowHeight * 16) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(960, 540));
|
||||
}
|
||||
else if (FocusWindowWidth * 4 == FocusWindowHeight * 3) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(480, 640));
|
||||
}
|
||||
else if (FocusWindowWidth * 3 == FocusWindowHeight * 4) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(640, 480));
|
||||
}
|
||||
else {
|
||||
qDebug() << "------ Other scaled resolutions use 480x640";
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(480, 640));
|
||||
}
|
||||
|
||||
// 设置临时视频Label
|
||||
mutex.lock();
|
||||
this->videoLabelTemp = dialog->videoDisplayLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
|
||||
connect(dialog, &QDialog::finished, this, [=](int result) {
|
||||
mutex.lock();
|
||||
this->videoLabelTemp = originalLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
dialog->deleteLater(); // 关闭后删除窗口
|
||||
});
|
||||
|
||||
dialog->open(); // **在 UI 线程执行 open(),避免阻塞**
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
else {
|
||||
qDebug() << "------ Please wait for the video to be decoded and rendered before clicking";
|
||||
@@ -192,7 +232,7 @@ void FFmpegDecoder::run()
|
||||
labelSize = currentVideoLabel->size();
|
||||
}
|
||||
mutex.unlock();
|
||||
|
||||
qWarning() << "-------currentVideoLabel";
|
||||
QImage img = avFrameToQImage(frame);
|
||||
QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
//currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
|
||||
Reference in New Issue
Block a user