From a31f3819ab7013ab133fe019c9dcac999abd43b9 Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Sun, 5 Feb 2023 14:25:11 +0100 Subject: [PATCH 1/3] Add a mutex to the streamInfo list --- YUViewLib/src/parser/AVFormat/AVFormat.cpp | 39 +++++++++++++--------- YUViewLib/src/parser/AVFormat/AVFormat.h | 1 + 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/YUViewLib/src/parser/AVFormat/AVFormat.cpp b/YUViewLib/src/parser/AVFormat/AVFormat.cpp index c392283b1..77db98cf4 100644 --- a/YUViewLib/src/parser/AVFormat/AVFormat.cpp +++ b/YUViewLib/src/parser/AVFormat/AVFormat.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "../AVC/AnnexBAVC.h" #include "../HEVC/AnnexBHEVC.h" @@ -68,21 +69,22 @@ QList AVFormat::getStreamInfo() // streamInfoAllStreams containse all the info for all streams. // The first QStringPairList contains the general info, next all infos for each stream follows - QList info; if (this->streamInfoAllStreams.count() == 0) - return info; + return {}; - QStringPairList generalInfo = this->streamInfoAllStreams[0]; - QTreeWidgetItem *general = new QTreeWidgetItem(QStringList() << "General"); - for (QStringPair p : generalInfo) + QList info; + std::unique_lock lock(this->streamInfoMutex); + + auto generalInfo = this->streamInfoAllStreams[0]; + auto general = new QTreeWidgetItem(QStringList() << "General"); + for (auto p : generalInfo) new QTreeWidgetItem(general, QStringList() << p.first << p.second); info.append(general); for (int i = 1; i < this->streamInfoAllStreams.count(); i++) { - QTreeWidgetItem *streamInfo = - new QTreeWidgetItem(QStringList() << QString("Stream %1").arg(i - 1)); - for (QStringPair p : this->streamInfoAllStreams[i]) + auto streamInfo = new QTreeWidgetItem(QStringList() << QString("Stream %1").arg(i - 1)); + for (auto p : this->streamInfoAllStreams[i]) new QTreeWidgetItem(streamInfo, QStringList() << p.first << p.second); info.append(streamInfo); } @@ -606,12 +608,16 @@ bool AVFormat::runParsingOfFile(QString compressedFilePath) return false; } - int max_ts = ffmpegFile->getMaxTS(); - this->videoStreamIndex = ffmpegFile->getVideoStreamIndex(); - this->framerate = ffmpegFile->getFramerate(); - this->streamInfoAllStreams = ffmpegFile->getFileInfoForAllStreams(); - this->timeBaseAllStreams = ffmpegFile->getTimeBaseAllStreams(); - this->shortStreamInfoAllStreams = ffmpegFile->getShortStreamDescriptionAllStreams(); + int max_ts = ffmpegFile->getMaxTS(); + this->videoStreamIndex = ffmpegFile->getVideoStreamIndex(); + this->framerate = ffmpegFile->getFramerate(); + + { + std::unique_lock lock(this->streamInfoMutex); + this->streamInfoAllStreams = ffmpegFile->getFileInfoForAllStreams(); + this->timeBaseAllStreams = ffmpegFile->getTimeBaseAllStreams(); + this->shortStreamInfoAllStreams = ffmpegFile->getShortStreamDescriptionAllStreams(); + } emit streamInfoUpdated(); @@ -677,7 +683,10 @@ bool AVFormat::runParsingOfFile(QString compressedFilePath) if (packetModel) emit modelDataUpdated(); - this->streamInfoAllStreams = ffmpegFile->getFileInfoForAllStreams(); + { + std::unique_lock lock(this->streamInfoMutex); + this->streamInfoAllStreams = ffmpegFile->getFileInfoForAllStreams(); + } emit streamInfoUpdated(); emit backgroundParsingDone(""); diff --git a/YUViewLib/src/parser/AVFormat/AVFormat.h b/YUViewLib/src/parser/AVFormat/AVFormat.h index e6e291295..5bd5d4d19 100644 --- a/YUViewLib/src/parser/AVFormat/AVFormat.h +++ b/YUViewLib/src/parser/AVFormat/AVFormat.h @@ -93,6 +93,7 @@ class AVFormat : public Base // When the parser is used in the bitstream analysis window, the runParsingOfFile is used and // we update this list while parsing the file. + std::mutex streamInfoMutex; QList streamInfoAllStreams; QList timeBaseAllStreams; QList shortStreamInfoAllStreams; From 84fb7469b67812ff0e6ef1d83eeccde8333c67d0 Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Sun, 5 Feb 2023 14:35:58 +0100 Subject: [PATCH 2/3] Typo --- YUViewLib/src/ui/views/PlotViewWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YUViewLib/src/ui/views/PlotViewWidget.cpp b/YUViewLib/src/ui/views/PlotViewWidget.cpp index 53ab62553..d56242e6c 100644 --- a/YUViewLib/src/ui/views/PlotViewWidget.cpp +++ b/YUViewLib/src/ui/views/PlotViewWidget.cpp @@ -99,7 +99,7 @@ void PlotViewWidget::modelNrStreamsChanged() for (unsigned int i = 0; i < model->getNrStreams(); i++) this->showStreamList.append(i); } - DEBUG_PLOT("PlotViewWidget::updateStreamInfo showStreamList " << this->showStreamList); + DEBUG_PLOT("PlotViewWidget::modelNrStreamsChanged showStreamList " << this->showStreamList); } void PlotViewWidget::zoomToFitInternal() From e466e978ac1e6a22fcb3edc30cbfc9fbe3eb88dc Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Sun, 5 Feb 2023 14:36:07 +0100 Subject: [PATCH 3/3] Move include to header --- YUViewLib/src/parser/AVFormat/AVFormat.cpp | 1 - YUViewLib/src/parser/AVFormat/AVFormat.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/YUViewLib/src/parser/AVFormat/AVFormat.cpp b/YUViewLib/src/parser/AVFormat/AVFormat.cpp index 77db98cf4..765b85549 100644 --- a/YUViewLib/src/parser/AVFormat/AVFormat.cpp +++ b/YUViewLib/src/parser/AVFormat/AVFormat.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include "../AVC/AnnexBAVC.h" #include "../HEVC/AnnexBHEVC.h" diff --git a/YUViewLib/src/parser/AVFormat/AVFormat.h b/YUViewLib/src/parser/AVFormat/AVFormat.h index 5bd5d4d19..1a123ee9b 100644 --- a/YUViewLib/src/parser/AVFormat/AVFormat.h +++ b/YUViewLib/src/parser/AVFormat/AVFormat.h @@ -38,6 +38,7 @@ #include #include +#include #include namespace parser