diff --git a/YUViewLib/src/common/Formatting.h b/YUViewLib/src/common/Formatting.h index 427014c2d..808ee7371 100644 --- a/YUViewLib/src/common/Formatting.h +++ b/YUViewLib/src/common/Formatting.h @@ -73,7 +73,7 @@ template std::string to_string(const std::vector vec) static std::ostream &operator<<(std::ostream &stream, const Size &size) { - stream << "(" << size.width << "x" << size.height << ")"; + stream << size.width << "x" << size.height; return stream; } @@ -89,13 +89,31 @@ inline std::string to_string(const bool b) return b ? "True" : "False"; } +template +static std::ostream &operator<<(std::ostream &stream, const std::optional &opt) +{ + if (opt) + stream << opt; + else + stream << "NA"; + return stream; +} + +template inline std::string to_string(const std::optional &opt) +{ + std::ostringstream stream; + stream << opt; + return stream.str(); +} + inline std::string stringReplaceAll(std::string str, char value, char replacement) { std::replace(str.begin(), str.end(), value, replacement); return str; } -inline std::string stringReplaceAll(std::string str, std::initializer_list values, char replacement) +inline std::string +stringReplaceAll(std::string str, std::initializer_list values, char replacement) { std::replace_if( str.begin(), diff --git a/YUViewLib/src/common/InfoItemAndData.h b/YUViewLib/src/common/InfoItemAndData.h index 5d52634c1..e50a291b0 100644 --- a/YUViewLib/src/common/InfoItemAndData.h +++ b/YUViewLib/src/common/InfoItemAndData.h @@ -47,6 +47,15 @@ struct InfoItem std::string description{}; InfoItem(std::string &&name, std::string &&text) : name(std::move(name)), text(std::move(text)) {} + InfoItem(std::string &&name, std::string &&text, std::string &&description) + : name(std::move(name)), text(std::move(text)), description(std::move(description)) + { + } + InfoItem(std::string_view name, std::string_view text) : name(name), text(text) {} + InfoItem(std::string_view name, std::string_view text, std::string_view description) + : name(name), text(text), description(description) + { + } }; struct InfoData diff --git a/YUViewLib/src/common/Typedef.h b/YUViewLib/src/common/Typedef.h index 02bcc203e..211b8ab78 100644 --- a/YUViewLib/src/common/Typedef.h +++ b/YUViewLib/src/common/Typedef.h @@ -279,6 +279,7 @@ struct Size { return this->width != other.width || this->height != other.height; } + explicit operator bool() const { return this->isValid(); } constexpr bool isValid() const { return this->width > 0 && this->height > 0; } unsigned width{}; unsigned height{}; @@ -345,7 +346,7 @@ Q_DECLARE_METATYPE(recacheIndicator) template struct QNonConstOverload { template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW->decltype(ptr) { return ptr; } @@ -358,7 +359,7 @@ template struct QNonConstOverload template struct QConstOverload { template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW->decltype(ptr) { return ptr; } @@ -375,7 +376,7 @@ template struct QOverload : QConstOverload, QNonCons using QNonConstOverload::of; using QNonConstOverload::operator(); template - Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW->decltype(ptr) { return ptr; } diff --git a/YUViewLib/src/filesource/FileSource.cpp b/YUViewLib/src/filesource/FileSource.cpp index 35d416214..325f76823 100644 --- a/YUViewLib/src/filesource/FileSource.cpp +++ b/YUViewLib/src/filesource/FileSource.cpp @@ -32,6 +32,7 @@ #include "FileSource.h" +#include #include #include @@ -57,7 +58,7 @@ FileSource::FileSource() &FileSource::fileSystemWatcherFileChanged); } -bool FileSource::openFile(const std::string &filePath) +bool FileSource::openFile(const std::filesystem::path &filePath) { if (!std::filesystem::is_regular_file(filePath)) return false; @@ -117,35 +118,47 @@ std::vector FileSource::getFileInfoList() const if (!this->isFileOpened) return {}; - std::vector infoList; - infoList.emplace_back("File Path", this->fullFilePath); - infoList.emplace_back("Time Modified", std::format()) + // For now we still use the QFileInfo. There is no easy cross platform formatting + // for the std::filesystem::file_time_type. This is added in C++ 20. + QFileInfo fileInfo(QString::fromStdString(this->fullFilePath.string())); + std::vector infoList; + infoList.emplace_back("File Path", this->fullFilePath); #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - auto createdtime = this->fileInfo.created().toString("yyyy-MM-dd hh:mm:ss"); + const auto createdtime = this->fileInfo.created().toString("yyyy-MM-dd hh:mm:ss"); #else - auto createdtime = this->fileInfo.birthTime().toString("yyyy-MM-dd hh:mm:ss"); + const auto createdtime = fileInfo.birthTime().toString("yyyy-MM-dd hh:mm:ss"); #endif infoList.emplace_back("Time Created", createdtime.toStdString()); infoList.emplace_back("Time Modified", - this->fileInfo.lastModified().toString("yyyy-MM-dd hh:mm:ss")); - infoList.emplace_back("Nr Bytes", QString("%1").arg(this->fileInfo.size())); + fileInfo.lastModified().toString("yyyy-MM-dd hh:mm:ss").toStdString()); + + if (const auto size = this->getFileSize()) + infoList.emplace_back("Nr Bytes", to_string(this->getFileSize())); return infoList; } -int64_t FileSource::getFileSize() const +std::optional FileSource::getFileSize() const { if (!this->isFileOpened) - return -1; + return {}; - return !isFileOpened ? -1 : fileInfo.size(); + try + { + const auto size = std::filesystem::file_size(this->fullFilePath); + return static_cast(size); + } + catch (const std::filesystem::filesystem_error &e) + { + return {}; + } } -QString FileSource::getAbsoluteFilePath() const +std::string FileSource::getAbsoluteFilePath() const { - return this->isFileOpened ? this->fileInfo.absoluteFilePath() : QString(); + return this->isFileOpened ? this->fullFilePath.string() : ""; } // If you are loading a playlist and you have an absolute path and a relative path, this function @@ -184,9 +197,9 @@ void FileSource::updateFileWatchSetting() // The addPath/removePath functions will do nothing if called twice for the same file. QSettings settings; if (settings.value("WatchFiles", true).toBool()) - fileWatcher.addPath(this->fullFilePath); + fileWatcher.addPath(QString::fromStdString(this->fullFilePath.string())); else - fileWatcher.removePath(this->fullFilePath); + fileWatcher.removePath(QString::fromStdString(this->fullFilePath.string())); } void FileSource::clearFileCache() @@ -202,7 +215,7 @@ void FileSource::clearFileCache() QMutexLocker locker(&this->readMutex); this->srcFile.close(); - LPCWSTR file = (const wchar_t *)this->fullFilePath.utf16(); + LPCWSTR file = this->fullFilePath.wstring().c_str(); HANDLE hFile = CreateFile(file, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL); CloseHandle(hFile); diff --git a/YUViewLib/src/filesource/FileSource.h b/YUViewLib/src/filesource/FileSource.h index 81c8f6b72..b4834581f 100644 --- a/YUViewLib/src/filesource/FileSource.h +++ b/YUViewLib/src/filesource/FileSource.h @@ -70,10 +70,10 @@ class FileSource : public QObject public: FileSource(); - virtual bool openFile(const std::string &filePath); + virtual bool openFile(const std::filesystem::path &filePath); virtual std::vector getFileInfoList() const; - int64_t getFileSize() const; + std::optional getFileSize() const; std::string getAbsoluteFilePath() const; QFile *getQFile() { return &this->srcFile; } bool getAndResetFileChangedFlag(); @@ -106,9 +106,9 @@ private slots: void fileSystemWatcherFileChanged(const QString &) { fileChanged = true; } protected: - std::string fullFilePath{}; - QFile srcFile; - bool isFileOpened{}; + std::filesystem::path fullFilePath{}; + QFile srcFile; + bool isFileOpened{}; private: QFileSystemWatcher fileWatcher{}; diff --git a/YUViewLib/src/filesource/FileSourceAnnexBFile.cpp b/YUViewLib/src/filesource/FileSourceAnnexBFile.cpp index cc22edf33..2d9dc6337 100644 --- a/YUViewLib/src/filesource/FileSourceAnnexBFile.cpp +++ b/YUViewLib/src/filesource/FileSourceAnnexBFile.cpp @@ -1,34 +1,34 @@ /* This file is part of YUView - The YUV player with advanced analytics toolset -* -* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY -* -* 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; either version 3 of the License, or -* (at your option) any later version. -* -* In addition, as a special exception, the copyright holders give -* permission to link the code of portions of this program with the -* OpenSSL library under certain conditions as described in each -* individual source file, and distribute linked combinations including -* the two. -* -* You must obey the GNU General Public License in all respects for all -* of the code used other than OpenSSL. If you modify file(s) with this -* exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do -* so, delete this exception statement from your version. If you delete -* this exception statement from all source files in the program, then -* also delete it here. -* -* 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 for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * + * Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * 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; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "FileSourceAnnexBFile.h" @@ -41,15 +41,21 @@ #endif const auto BUFFERSIZE = 500000; -const auto STARTCODE = QByteArrayLiteral("\x00\x00\x01"); +const auto STARTCODE = QByteArrayLiteral("\x00\x00\x01"); FileSourceAnnexBFile::FileSourceAnnexBFile() { this->fileBuffer.resize(BUFFERSIZE); } -// Open the file and fill the read buffer. -bool FileSourceAnnexBFile::openFile(const QString &fileName) +FileSourceAnnexBFile::FileSourceAnnexBFile(const std::filesystem::path &filePath) + : FileSourceAnnexBFile() +{ + this->openFile(filePath); +} + +// Open the file and fill the read buffer. +bool FileSourceAnnexBFile::openFile(const std::filesystem::path &fileName) { DEBUG_ANNEXBFILE("FileSourceAnnexBFile::openFile fileName " << fileName); @@ -68,7 +74,7 @@ bool FileSourceAnnexBFile::openFile(const QString &fileName) } bool FileSourceAnnexBFile::atEnd() const -{ +{ return this->fileBufferSize < BUFFERSIZE && this->posInBuffer >= int64_t(this->fileBufferSize); } @@ -76,12 +82,13 @@ void FileSourceAnnexBFile::seekToFirstNAL() { auto nextStartCodePos = this->fileBuffer.indexOf(STARTCODE); if (nextStartCodePos < 0) - // The first buffer does not contain a start code. This is very unusual. Use the normal getNextNALUnit to seek + // The first buffer does not contain a start code. This is very unusual. Use the normal + // getNextNALUnit to seek this->getNextNALUnit(); else { // For 0001 or 001 point to the first 0 byte - if (nextStartCodePos > 0 && this->fileBuffer.at(nextStartCodePos-1) ==(char)0) + if (nextStartCodePos > 0 && this->fileBuffer.at(nextStartCodePos - 1) == (char)0) this->posInBuffer = nextStartCodePos - 1; else this->posInBuffer = nextStartCodePos; @@ -91,7 +98,8 @@ void FileSourceAnnexBFile::seekToFirstNAL() this->nrBytesBeforeFirstNAL = this->bufferStartPosInFile + uint64_t(this->posInBuffer); } -QByteArray FileSourceAnnexBFile::getNextNALUnit(bool getLastDataAgain, pairUint64 *startEndPosInFile) +QByteArray FileSourceAnnexBFile::getNextNALUnit(bool getLastDataAgain, + pairUint64 *startEndPosInFile) { if (getLastDataAgain) return this->lastReturnArray; @@ -101,14 +109,15 @@ QByteArray FileSourceAnnexBFile::getNextNALUnit(bool getLastDataAgain, pairUint6 if (startEndPosInFile) startEndPosInFile->first = this->bufferStartPosInFile + uint64_t(this->posInBuffer); - int nextStartCodePos = -1; - int searchOffset = 3; - bool startCodeFound = false; + int nextStartCodePos = -1; + int searchOffset = 3; + bool startCodeFound = false; while (!startCodeFound) { if (this->posInBuffer < 0) { - // Part of the start code was in the last buffer (see special boundary cases below). Add those parts. + // Part of the start code was in the last buffer (see special boundary cases below). Add those + // parts. const auto nrZeroBytesMissing = std::abs(this->posInBuffer); this->lastReturnArray.append(nrZeroBytesMissing, char(0)); } @@ -117,8 +126,10 @@ QByteArray FileSourceAnnexBFile::getNextNALUnit(bool getLastDataAgain, pairUint6 if (nextStartCodePos < 0 || (uint64_t)nextStartCodePos > this->fileBufferSize) { // No start code found ... append all data in the current buffer. - this->lastReturnArray += this->fileBuffer.mid(this->posInBuffer, this->fileBufferSize - this->posInBuffer); - DEBUG_ANNEXBFILE("FileSourceHEVCAnnexBFile::getNextNALUnit no start code found - ret size " << this->lastReturnArray.size()); + this->lastReturnArray += + this->fileBuffer.mid(this->posInBuffer, this->fileBufferSize - this->posInBuffer); + DEBUG_ANNEXBFILE("FileSourceHEVCAnnexBFile::getNextNALUnit no start code found - ret size " + << this->lastReturnArray.size()); if (this->fileBufferSize < BUFFERSIZE) { @@ -129,35 +140,40 @@ QByteArray FileSourceAnnexBFile::getNextNALUnit(bool getLastDataAgain, pairUint6 return this->lastReturnArray; } - // Before we load the next bytes: The start code might be located at the boundary to the next buffer + // Before we load the next bytes: The start code might be located at the boundary to the next + // buffer const auto lastByteZero0 = this->fileBuffer.at(this->fileBufferSize - 3) == (char)0; const auto lastByteZero1 = this->fileBuffer.at(this->fileBufferSize - 2) == (char)0; const auto lastByteZero2 = this->fileBuffer.at(this->fileBufferSize - 1) == (char)0; // We have to continue searching - get the next buffer updateBuffer(); - + if (this->fileBufferSize > 2) { // Now look for the special boundary case: if (this->fileBuffer.at(0) == (char)1 && lastByteZero2 && lastByteZero1) { - // Found a start code - the 1 byte is here and the two (or three) 0 bytes were in the last buffer - startCodeFound = true; + // Found a start code - the 1 byte is here and the two (or three) 0 bytes were in the last + // buffer + startCodeFound = true; nextStartCodePos = lastByteZero0 ? -3 : -2; this->lastReturnArray.chop(lastByteZero0 ? 3 : 2); } - else if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)1 && lastByteZero2) + else if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)1 && + lastByteZero2) { - // Found a start code - the 01 bytes are here and the one (or two) 0 bytes were in the last buffer - startCodeFound = true; + // Found a start code - the 01 bytes are here and the one (or two) 0 bytes were in the + // last buffer + startCodeFound = true; nextStartCodePos = lastByteZero1 ? -2 : -1; this->lastReturnArray.chop(lastByteZero0 ? 1 : 1); } - else if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)0 && this->fileBuffer.at(2) == (char)1) + else if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)0 && + this->fileBuffer.at(2) == (char)1) { // Found a start code - the 001 bytes are here. Check the last byte of the last buffer - startCodeFound = true; + startCodeFound = true; nextStartCodePos = lastByteZero2 ? -1 : 0; if (lastByteZero2) this->lastReturnArray.chop(1); @@ -179,21 +195,24 @@ QByteArray FileSourceAnnexBFile::getNextNALUnit(bool getLastDataAgain, pairUint6 if (startEndPosInFile) startEndPosInFile->second = this->bufferStartPosInFile + nextStartCodePos; if (nextStartCodePos > int(this->posInBuffer)) - this->lastReturnArray += this->fileBuffer.mid(this->posInBuffer, nextStartCodePos - this->posInBuffer); + this->lastReturnArray += + this->fileBuffer.mid(this->posInBuffer, nextStartCodePos - this->posInBuffer); this->posInBuffer = nextStartCodePos; - DEBUG_ANNEXBFILE("FileSourceAnnexBFile::getNextNALUnit start code found - ret size " << this->lastReturnArray.size()); + DEBUG_ANNEXBFILE("FileSourceAnnexBFile::getNextNALUnit start code found - ret size " + << this->lastReturnArray.size()); return this->lastReturnArray; } QByteArray FileSourceAnnexBFile::getFrameData(pairUint64 startEndFilePos) { // Get all data for the frame (all NAL units in the raw format with start codes). - // We don't need to convert the format to the mp4 ISO format. The ffmpeg decoder can also accept raw NAL units. - // When the extradata is set as raw NAL units, the AVPackets must also be raw NAL units. + // We don't need to convert the format to the mp4 ISO format. The ffmpeg decoder can also accept + // raw NAL units. When the extradata is set as raw NAL units, the AVPackets must also be raw NAL + // units. QByteArray retArray; - + auto start = startEndFilePos.first; - auto end = startEndFilePos.second; + auto end = startEndFilePos.second; // Seek the source file to the start position this->seek(start); @@ -228,9 +247,10 @@ bool FileSourceAnnexBFile::updateBuffer() this->bufferStartPosInFile += this->fileBufferSize; this->fileBufferSize = srcFile.read(this->fileBuffer.data(), BUFFERSIZE); - this->posInBuffer = 0; + this->posInBuffer = 0; - DEBUG_ANNEXBFILE("FileSourceAnnexBFile::updateBuffer this->fileBufferSize " << this->fileBufferSize); + DEBUG_ANNEXBFILE("FileSourceAnnexBFile::updateBuffer this->fileBufferSize " + << this->fileBufferSize); return (this->fileBufferSize > 0); } @@ -247,16 +267,18 @@ bool FileSourceAnnexBFile::seek(int64_t pos) // The file is empty of there was an error reading from the file. return false; this->bufferStartPosInFile = pos; - this->posInBuffer = 0; + this->posInBuffer = 0; if (pos == 0) this->seekToFirstNAL(); else { // Check if we are at a start code position (001 or 0001) - if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)0 && this->fileBuffer.at(2) == (char)0 && this->fileBuffer.at(3) == (char)1) + if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)0 && + this->fileBuffer.at(2) == (char)0 && this->fileBuffer.at(3) == (char)1) return true; - if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)0 && this->fileBuffer.at(2) == (char)1) + if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)0 && + this->fileBuffer.at(2) == (char)1) return true; DEBUG_ANNEXBFILE("FileSourceAnnexBFile::seek could not find start code at seek position"); diff --git a/YUViewLib/src/filesource/FileSourceAnnexBFile.h b/YUViewLib/src/filesource/FileSourceAnnexBFile.h index a2d486cb0..bcb007d57 100644 --- a/YUViewLib/src/filesource/FileSourceAnnexBFile.h +++ b/YUViewLib/src/filesource/FileSourceAnnexBFile.h @@ -47,10 +47,9 @@ class FileSourceAnnexBFile : public FileSource public: FileSourceAnnexBFile(); - FileSourceAnnexBFile(const QString &filePath) : FileSourceAnnexBFile() { openFile(filePath); } - ~FileSourceAnnexBFile(){}; + FileSourceAnnexBFile(const std::filesystem::path &filePath); - bool openFile(const QString &filePath) override; + bool openFile(const std::filesystem::path &filePath) override; // Is the file at the end? bool atEnd() const override; diff --git a/YUViewLib/src/parser/AV1/ParserAV1OBU.h b/YUViewLib/src/parser/AV1/ParserAV1OBU.h index c044595a2..bc0426da1 100644 --- a/YUViewLib/src/parser/AV1/ParserAV1OBU.h +++ b/YUViewLib/src/parser/AV1/ParserAV1OBU.h @@ -50,13 +50,13 @@ class ParserAV1OBU : public Parser ~ParserAV1OBU() {} std::pair parseAndAddOBU(int obuID, - ByteVector & data, + ByteVector &data, std::shared_ptr parent, pairUint64 obuStartEndPosFile = pairUint64(-1, -1)); // So far, we only parse AV1 Obu files from the AVFormat parser so we don't need this (yet). // When parsing of raw OBU files is added, we will need this. - bool runParsingOfFile(QString) override + bool runParsingOfFile(const std::filesystem::path &) override { assert(false); return false; diff --git a/YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp b/YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp index dfcc0d9d7..1ae6eddc5 100644 --- a/YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp +++ b/YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp @@ -94,7 +94,7 @@ vector ParserAVFormat::getStreamInfo() std::string ParserAVFormat::getShortStreamDescription(const int streamIndex) const { - if (streamIndex >= this->shortStreamInfoAllStreams.size()) + if (streamIndex >= static_cast(this->shortStreamInfoAllStreams.size())) return {}; return this->shortStreamInfoAllStreams.at(streamIndex); } @@ -254,7 +254,7 @@ bool ParserAVFormat::parseExtradataMPEG2(const ByteVector &extradata) } std::map ParserAVFormat::parseByteVectorAnnexBStartCodes( - const ByteVector & data, + const ByteVector &data, const PacketDataFormat dataFormat, const BitratePlotModel::BitrateEntry packetBitrateEntry, std::shared_ptr item) @@ -265,7 +265,8 @@ std::map ParserAVFormat::parseByteVectorAnnexBStartCodes( return {}; } - auto getNextNalStart = [&data, &dataFormat](ByteVector::const_iterator searchStart) { + auto getNextNalStart = [&data, &dataFormat](ByteVector::const_iterator searchStart) + { if (dataFormat == PacketDataFormat::RawNAL) { if (std::distance(searchStart, data.end()) <= 3) @@ -352,7 +353,8 @@ bool ParserAVFormat::parseAVPacket(unsigned packetID, auto timeBase = timeBaseAllStreams[packet.getStreamIndex()]; - auto formatTimestamp = [](int64_t timestamp, AVRational timebase) -> std::string { + auto formatTimestamp = [](int64_t timestamp, AVRational timebase) -> std::string + { std::ostringstream ss; ss << timestamp << " ("; if (timestamp < 0) @@ -574,11 +576,11 @@ bool ParserAVFormat::parseAVPacket(unsigned packetID, return true; } -bool ParserAVFormat::runParsingOfFile(QString compressedFilePath) +bool ParserAVFormat::runParsingOfFile(const std::filesystem::path &compressedFilePath) { // Open the file but don't parse it yet. FileSourceFFmpegFile ffmpegFile; - if (!ffmpegFile.openFile(compressedFilePath, nullptr, nullptr, false)) + if (!ffmpegFile.openFile(QString::fromStdString(compressedFilePath), nullptr, nullptr, false)) { emit backgroundParsingDone("Error opening the ffmpeg file."); return false; diff --git a/YUViewLib/src/parser/AVFormat/ParserAVFormat.h b/YUViewLib/src/parser/AVFormat/ParserAVFormat.h index 1a3265621..8ae37f4d3 100644 --- a/YUViewLib/src/parser/AVFormat/ParserAVFormat.h +++ b/YUViewLib/src/parser/AVFormat/ParserAVFormat.h @@ -63,7 +63,7 @@ class ParserAVFormat : public Parser std::string getShortStreamDescription(const int streamIndex) const override; // This function can run in a separate thread - bool runParsingOfFile(QString compressedFilePath) override; + bool runParsingOfFile(const std::filesystem::path &compressedFilePath) override; int getVideoStreamIndex() override { return videoStreamIndex; } diff --git a/YUViewLib/src/parser/Parser.h b/YUViewLib/src/parser/Parser.h index 830632d2c..543c0832d 100644 --- a/YUViewLib/src/parser/Parser.h +++ b/YUViewLib/src/parser/Parser.h @@ -37,6 +37,7 @@ #include #include +#include #include #include "common/BitratePlotModel.h" @@ -62,8 +63,8 @@ class Parser : public QObject virtual ~Parser() = 0; QAbstractItemModel *getPacketItemModel() { return streamIndexFilter.get(); } - BitratePlotModel * getBitratePlotModel() { return bitratePlotModel.get(); } - HRDPlotModel * getHRDPlotModel(); + BitratePlotModel *getBitratePlotModel() { return bitratePlotModel.get(); } + HRDPlotModel *getHRDPlotModel(); void setRedirectPlotModel(HRDPlotModel *plotModel); void updateNumberModelItems(); @@ -74,7 +75,7 @@ class Parser : public QObject virtual unsigned int getNrStreams() = 0; // For parsing files in the background (threading) in the bitstream analysis dialog: - virtual bool runParsingOfFile(QString fileName) = 0; + virtual bool runParsingOfFile(const std::filesystem::path &fileName) = 0; int getParsingProgressPercent() { return progressPercentValue; } void setAbortParsing() { cancelBackgroundParser = true; } @@ -114,7 +115,7 @@ class Parser : public QObject private: std::unique_ptr hrdPlotModel; - HRDPlotModel * redirectPlotModel{nullptr}; + HRDPlotModel *redirectPlotModel{nullptr}; }; } // namespace parser diff --git a/YUViewLib/src/parser/ParserAnnexB.cpp b/YUViewLib/src/parser/ParserAnnexB.cpp index 80b842dc7..81ce53216 100644 --- a/YUViewLib/src/parser/ParserAnnexB.cpp +++ b/YUViewLib/src/parser/ParserAnnexB.cpp @@ -54,8 +54,7 @@ std::string ParserAnnexB::getShortStreamDescription(const int) const { std::ostringstream info; info << "Video"; - auto frameSize = this->getSequenceSizeSamples(); - if (frameSize.isValid()) + if (const auto frameSize = this->getSequenceSizeSamples()) info << " " << frameSize; return info.str(); } @@ -85,7 +84,7 @@ bool ParserAnnexB::addFrameToList(int poc, return true; } -void ParserAnnexB::logNALSize(const ByteVector & data, +void ParserAnnexB::logNALSize(const ByteVector &data, std::shared_ptr root, std::optional nalStartEndPos) { @@ -154,7 +153,7 @@ bool ParserAnnexB::parseAnnexBFile(std::unique_ptr &file, { DEBUG_ANNEXB("ParserAnnexB::parseAnnexBFile"); - auto maxPos = file->getFileSize(); + const auto fileSize = file->getFileSize(); std::unique_ptr progressDialog; int curPercentValue = 0; if (mainWindow) @@ -171,8 +170,8 @@ bool ParserAnnexB::parseAnnexBFile(std::unique_ptr &file, progressDialog->setWindowModality(Qt::WindowModal); } - stream_info.file_size = file->getFileSize(); - stream_info.parsing = true; + this->streamInfo.file_size = file->getFileSize().value_or(0); + this->streamInfo.parsing = true; emit streamInfoUpdated(); // Just push all NAL units from the annexBFile into the annexBParser @@ -185,8 +184,8 @@ bool ParserAnnexB::parseAnnexBFile(std::unique_ptr &file, { // Update the progress dialog int64_t pos = file->pos(); - if (stream_info.file_size > 0) - progressPercentValue = functions::clip((int)(pos * 100 / stream_info.file_size), 0, 100); + if (this->streamInfo.file_size > 0) + progressPercentValue = functions::clip((int)(pos * 100 / this->streamInfo.file_size), 0, 100); try { @@ -225,8 +224,8 @@ bool ParserAnnexB::parseAnnexBFile(std::unique_ptr &file, return false; int newPercentValue = 0; - if (maxPos > 0) - newPercentValue = functions::clip(int((file->pos() - maxPos) * 100 / maxPos), 0, 100); + if (fileSize) + newPercentValue = functions::clip(int((file->pos() - *fileSize) * 100 / *fileSize), 0, 100); if (newPercentValue != curPercentValue) { progressDialog->setValue(newPercentValue); @@ -272,23 +271,23 @@ bool ParserAnnexB::parseAnnexBFile(std::unique_ptr &file, if (packetModel) emit modelDataUpdated(); - stream_info.parsing = false; - stream_info.nr_nal_units = nalID; - stream_info.nr_frames = unsigned(this->frameListCodingOrder.size()); + this->streamInfo.parsing = false; + this->streamInfo.nrNalUnits = nalID; + this->streamInfo.nrFrames = unsigned(this->frameListCodingOrder.size()); emit streamInfoUpdated(); emit backgroundParsingDone(""); return !cancelBackgroundParser; } -bool ParserAnnexB::runParsingOfFile(QString compressedFilePath) +bool ParserAnnexB::runParsingOfFile(const std::filesystem::path &compressedFilePath) { DEBUG_ANNEXB("playlistItemCompressedVideo::runParsingOfFile"); auto file = std::make_unique(compressedFilePath); return this->parseAnnexBFile(file); } -vector ParserAnnexB::stream_info_type::getStreamInfo() +vector ParserAnnexB::StreamInfo::getStreamInfo() { vector infoList; infoList.push_back( @@ -302,10 +301,10 @@ vector ParserAnnexB::stream_info_type::getStreamInfo() } else { + infoList.push_back(new QTreeWidgetItem(QStringList() << "Number NAL units" + << QString::number(this->nrNalUnits))); infoList.push_back( - new QTreeWidgetItem(QStringList() << "Number NAL units" << QString::number(nr_nal_units))); - infoList.push_back( - new QTreeWidgetItem(QStringList() << "Number Frames" << QString::number(nr_frames))); + new QTreeWidgetItem(QStringList() << "Number Frames" << QString::number(this->nrFrames))); } return infoList; diff --git a/YUViewLib/src/parser/ParserAnnexB.h b/YUViewLib/src/parser/ParserAnnexB.h index 2f0d45fbc..3a1e96934 100644 --- a/YUViewLib/src/parser/ParserAnnexB.h +++ b/YUViewLib/src/parser/ParserAnnexB.h @@ -58,8 +58,8 @@ class ParserAnnexB : public Parser Q_OBJECT public: - ParserAnnexB(QObject *parent = nullptr) : Parser(parent){}; - virtual ~ParserAnnexB(){}; + ParserAnnexB(QObject *parent = nullptr) : Parser(parent) {}; + virtual ~ParserAnnexB() {}; // How many POC's have been found in the file size_t getNumberPOCs() const { return this->frameListCodingOrder.size(); } @@ -67,7 +67,7 @@ class ParserAnnexB : public Parser // Clear all knowledge about the bitstream. void clearData(); - vector getStreamInfo() override { return this->stream_info.getStreamInfo(); } + vector getStreamInfo() override { return this->streamInfo.getStreamInfo(); } unsigned int getNrStreams() override { return 1; } std::string getShortStreamDescription(const int streamIndex) const override; @@ -89,7 +89,7 @@ class ParserAnnexB : public Parser std::optional bitrateEntry; }; virtual ParseResult parseAndAddNALUnit(int nalID, - const ByteVector & data, + const ByteVector &data, std::optional bitrateEntry, std::optional nalStartEndPosFile = {}, std::shared_ptr parent = nullptr) = 0; @@ -117,8 +117,8 @@ class ParserAnnexB : public Parser FrameIndexDisplayOrder frameIndex{}; unsigned frameDistanceInCodingOrder{}; }; - auto getClosestSeekPoint(FrameIndexDisplayOrder targetFrame, FrameIndexDisplayOrder currentFrame) - -> SeekPointInfo; + auto getClosestSeekPoint(FrameIndexDisplayOrder targetFrame, + FrameIndexDisplayOrder currentFrame) -> SeekPointInfo; // Get the parameters sets as extradata. The format of this depends on the underlying codec. virtual QByteArray getExtradata() = 0; @@ -131,7 +131,7 @@ class ParserAnnexB : public Parser bool parseAnnexBFile(std::unique_ptr &file, QWidget *mainWindow = nullptr); // Called from the bitstream analyzer. This function can run in a background process. - bool runParsingOfFile(QString compressedFilePath) override; + bool runParsingOfFile(const std::filesystem::path &compressedFilePath) override; protected: struct AnnexBFrame @@ -152,23 +152,23 @@ class ParserAnnexB : public Parser bool randomAccessPoint, unsigned layerID); - static void logNALSize(const ByteVector & data, + static void logNALSize(const ByteVector &data, std::shared_ptr root, std::optional nalStartEndPos); std::optional pocOfFirstRandomAccessFrame{}; // Save general information about the file here - struct stream_info_type + struct StreamInfo { vector getStreamInfo(); - size_t file_size; - unsigned nr_nal_units{0}; - unsigned nr_frames{0}; + int64_t file_size{}; + unsigned nrNalUnits{0}; + unsigned nrFrames{0}; bool parsing{false}; }; - stream_info_type stream_info; + StreamInfo streamInfo{}; int getFramePOC(FrameIndexDisplayOrder frameIdx); diff --git a/YUViewLib/src/playlistitem/playlistItem.h b/YUViewLib/src/playlistitem/playlistItem.h index f43e0b226..c5f746363 100644 --- a/YUViewLib/src/playlistitem/playlistItem.h +++ b/YUViewLib/src/playlistitem/playlistItem.h @@ -32,7 +32,7 @@ #pragma once -#include +#include #include #include #include @@ -227,7 +227,7 @@ class playlistItem : public QObject, public QTreeWidgetItem virtual unsigned int getCachingFrameSize() const { return 0; } // Remove the frame with the given index from the cache. virtual void removeFrameFromCache(int) {} - virtual void removeAllFramesFromCache(){}; + virtual void removeAllFramesFromCache() {}; // ----- Detection of source/file change events ----- diff --git a/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp b/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp index 88864274f..6d7a93754 100644 --- a/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp +++ b/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp @@ -38,6 +38,7 @@ #include +#include #include #include #include @@ -142,9 +143,10 @@ playlistItemCompressedVideo::playlistItemCompressedVideo(const QString &compress { // Open file DEBUG_COMPRESSED("playlistItemCompressedVideo::playlistItemCompressedVideo Open annexB file"); - this->inputFileAnnexBLoading = std::make_unique(compressedFilePath); + const auto filePath = std::filesystem::path(compressedFilePath.toStdString()); + this->inputFileAnnexBLoading = std::make_unique(filePath); if (this->cachingEnabled) - this->inputFileAnnexBCaching = std::make_unique(compressedFilePath); + this->inputFileAnnexBCaching = std::make_unique(filePath); // inputFormatType a parser if (this->inputFormat == InputFormat::AnnexBHEVC) { @@ -468,49 +470,50 @@ InfoData playlistItemCompressedVideo::getInfo() const // At first append the file information part (path, date created, file size...) // info.items.append(loadingDecoder->getFileInfoList()); - info.items.append(InfoItem( - "Reader", QString::fromStdString(std::string(InputFormatMapper.getName(this->inputFormat))))); + info.items.append(InfoItem("Reader", InputFormatMapper.getName(this->inputFormat))); if (this->inputFileFFmpegLoading) { - auto l = this->inputFileFFmpegLoading->getLibraryPaths(); - if (l.length() % 3 == 0) + auto libraryPaths = this->inputFileFFmpegLoading->getLibraryPaths(); + if (libraryPaths.length() % 3 == 0) { - for (int i = 0; i < l.length() / 3; i++) - info.items.append(InfoItem(l[i * 3], l[i * 3 + 1], l[i * 3 + 2])); + for (int i = 0; i < libraryPaths.length() / 3; i++) + info.items.append(InfoItem(libraryPaths[i * 3].toStdString(), + libraryPaths[i * 3 + 1].toStdString(), + libraryPaths[i * 3 + 2].toStdString())); } } if (!this->unresolvableError) { - auto videoSize = video->getFrameSize(); info.items.append(InfoItem("Resolution", - QString("%1x%2").arg(videoSize.width).arg(videoSize.height), + to_string(video->getFrameSize()), "The video resolution in pixel (width x height)")); - auto nrFrames = + const auto nrFrames = (this->properties().startEndRange.second - this->properties().startEndRange.first) + 1; info.items.append( - InfoItem("Num POCs", QString::number(nrFrames), "The number of pictures in the stream.")); + InfoItem("Num POCs", std::to_string(nrFrames), "The number of pictures in the stream.")); if (this->decodingEnabled) { auto l = loadingDecoder->getLibraryPaths(); if (l.length() % 3 == 0) { for (int i = 0; i < l.length() / 3; i++) - info.items.append(InfoItem(l[i * 3], l[i * 3 + 1], l[i * 3 + 2])); + info.items.append(InfoItem( + l[i * 3].toStdString(), l[i * 3 + 1].toStdString(), l[i * 3 + 2].toStdString())); } - info.items.append(InfoItem("Decoder", this->loadingDecoder->getDecoderName())); - info.items.append(InfoItem("Decoder", this->loadingDecoder->getCodecName())); - info.items.append(InfoItem("Statistics", + info.items.append(InfoItem("Decoder", this->loadingDecoder->getDecoderName().toStdString())); + info.items.append(InfoItem("Decoder", this->loadingDecoder->getCodecName().toStdString())); + info.items.append(InfoItem("Statistics"sv, this->loadingDecoder->statisticsSupported() ? "Yes" : "No", "Is the decoder able to provide internals (statistics)?")); info.items.append( - InfoItem("Stat Parsing", + InfoItem("Stat Parsing"sv, this->loadingDecoder->statisticsEnabled() ? "Yes" : "No", "Are the statistics of the sequence currently extracted from the stream?")); } } if (this->decoderEngine == DecoderEngine::FFMpeg) info.items.append( - InfoItem("FFMpeg Log", "Show FFmpeg Log", "Show the log messages from FFmpeg.", true, 0)); + InfoItem("FFMpeg Log"sv, "Show FFmpeg Log", "Show the log messages from FFmpeg.")); return info; } diff --git a/YUViewLib/src/playlistitem/playlistItemDifference.cpp b/YUViewLib/src/playlistitem/playlistItemDifference.cpp index f8a524e1d..0918d4018 100644 --- a/YUViewLib/src/playlistitem/playlistItemDifference.cpp +++ b/YUViewLib/src/playlistitem/playlistItemDifference.cpp @@ -75,9 +75,9 @@ InfoData playlistItemDifference::getInfo() const InfoData info("Difference Info"); if (childCount() >= 1) - info.items.append(InfoItem(QString("File 1"), getChildPlaylistItem(0)->properties().name)); + info.items.append(InfoItem("File 1", getChildPlaylistItem(0)->properties().name.toStdString())); if (childCount() >= 2) - info.items.append(InfoItem(QString("File 2"), getChildPlaylistItem(1)->properties().name)); + info.items.append(InfoItem("File 2", getChildPlaylistItem(1)->properties().name.toStdString())); // Report the position of the first difference in coding order difference.reportFirstDifferencePosition(info.items); diff --git a/YUViewLib/src/playlistitem/playlistItemImageFile.cpp b/YUViewLib/src/playlistitem/playlistItemImageFile.cpp index 40195fa58..fa2e8491b 100644 --- a/YUViewLib/src/playlistitem/playlistItemImageFile.cpp +++ b/YUViewLib/src/playlistitem/playlistItemImageFile.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -101,7 +102,7 @@ void playlistItemImageFile::savePlaylist(QDomElement &root, const QDir &playlist */ playlistItemImageFile * playlistItemImageFile::newplaylistItemImageFile(const YUViewDomElement &root, - const QString & playlistFilePath) + const QString &playlistFilePath) { // Parse the DOM element. It should have all values of a playlistItemImageFile auto absolutePath = root.findChildValue("absolutePath"); @@ -185,20 +186,20 @@ InfoData playlistItemImageFile::getInfo() const { InfoData info("Image Info"); - info.items.append(InfoItem("File", this->properties().name)); + info.items.append(InfoItem("File", this->properties().name.toStdString())); if (frame.isFormatValid()) { - auto frameSize = frame.getFrameSize(); info.items.append(InfoItem("Resolution", - QString("%1x%2").arg(frameSize.width).arg(frameSize.height), + to_string(frame.getFrameSize()), "The video resolution in pixel (width x height)")); info.items.append(InfoItem( - "Bit depth", QString::number(frame.getImageBitDepth()), "The bit depth of the image.")); + "Bit depth", std::to_string(frame.getImageBitDepth()), "The bit depth of the image.")); } else if (isLoading()) - info.items.append(InfoItem("Status", "Loading...", "The image is being loaded. Please wait.")); + info.items.append( + InfoItem("Status"sv, "Loading...", "The image is being loaded. Please wait.")); else - info.items.append(InfoItem("Status", "Error", "There was an error loading the image.")); + info.items.append(InfoItem("Status"sv, "Error", "There was an error loading the image.")); return info; } diff --git a/YUViewLib/src/playlistitem/playlistItemImageFileSequence.cpp b/YUViewLib/src/playlistitem/playlistItemImageFileSequence.cpp index b797de2a7..b5491e98d 100644 --- a/YUViewLib/src/playlistitem/playlistItemImageFileSequence.cpp +++ b/YUViewLib/src/playlistitem/playlistItemImageFileSequence.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -91,7 +92,7 @@ bool playlistItemImageFileSequence::isImageSequence(const QString &filePath) return files.count() > 1; } -void playlistItemImageFileSequence::fillImageFileList(QStringList & imageFiles, +void playlistItemImageFileSequence::fillImageFileList(QStringList &imageFiles, const QString &filePath) { // See if the filename ends with a number @@ -170,19 +171,17 @@ InfoData playlistItemImageFileSequence::getInfo() const if (this->video->isFormatValid()) { - auto videoSize = this->video->getFrameSize(); - auto nrFrames = this->imageFiles.size(); - info.items.append(InfoItem("Num Frames", QString::number(nrFrames))); + info.items.append(InfoItem("Num Frames", std::to_string(this->imageFiles.size()))); info.items.append(InfoItem("Resolution", - QString("%1x%2").arg(videoSize.width).arg(videoSize.height), + to_string(this->video->getFrameSize()), "The video resolution in pixels (width x height)")); } else - info.items.append(InfoItem("Status", "Error", "There was an error loading the image.")); + info.items.append(InfoItem("Status"sv, "Error", "There was an error loading the image.")); if (loadPlaylistFrameMissing) info.items.append( - InfoItem("Warning", + InfoItem("Warning"sv, "Frames missing", "At least one frame could not be found when loading from playlist.")); diff --git a/YUViewLib/src/playlistitem/playlistItemOverlay.cpp b/YUViewLib/src/playlistitem/playlistItemOverlay.cpp index e3f5438b9..2966e29fa 100644 --- a/YUViewLib/src/playlistitem/playlistItemOverlay.cpp +++ b/YUViewLib/src/playlistitem/playlistItemOverlay.cpp @@ -39,8 +39,8 @@ #include #include -#include #include +#include #define PLAYLISTITEMOVERLAY_DEBUG 0 #if PLAYLISTITEMOVERLAY_DEBUG && !NDEBUG @@ -60,8 +60,13 @@ constexpr EnumMapper std::make_pair(OverlayLayoutMode::Arange, "Average"sv), std::make_pair(OverlayLayoutMode::Custom, "Custom"sv)); +std::string to_string(const QSize &size) +{ + return "(" + std::to_string(size.width()) + "," + std::to_string(size.height()) + ")"; } +} // namespace + playlistItemOverlay::playlistItemOverlay() : playlistItemContainer("Overlay Item") { this->setIcon(0, functionsGui::convertIcon(":img_overlay.png")); @@ -84,18 +89,16 @@ InfoData playlistItemOverlay::getInfo() const InfoData info("Overlay Info"); // Add the size of this playlistItemOverlay - info.items.append( - InfoItem("Overlay Size", QString("(%1,%2)").arg(getSize().width()).arg(getSize().height()))); + const auto size = this->getSize(); + info.items.append(InfoItem("Overlay Size", to_string(size))); // Add the sizes of all child items for (int i = 0; i < this->childCount(); i++) { if (auto childItem = getChildPlaylistItem(i)) { - auto childSize = childItem->getSize(); - info.items.append( - InfoItem(QString("Item %1 size").arg(i), - QString("(%1,%2)").arg(childSize.width()).arg(childSize.height()))); + const auto childSize = childItem->getSize(); + info.items.append(InfoItem("Item " + std::to_string(i) + " size", to_string(childSize))); } } return info; diff --git a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp index 0362cf1a5..08738e855 100644 --- a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp +++ b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp @@ -81,7 +81,7 @@ playlistItemRawFile::playlistItemRawFile(const QString &rawFilePath, this->prop.isFileSource = true; this->prop.propertiesWidgetTitle = "Raw File Properties"; - this->dataSource.openFile(rawFilePath); + this->dataSource.openFile(std::filesystem::path(rawFilePath.toStdString())); if (!this->dataSource.isOk()) { @@ -135,7 +135,7 @@ playlistItemRawFile::playlistItemRawFile(const QString &rawFilePath, // Load 24883200 bytes from the input and try to get the format from the correlation. QByteArray rawData; this->dataSource.readBytes(rawData, 0, 24883200); - this->video->setFormatFromCorrelation(rawData, this->dataSource.getFileSize()); + this->video->setFormatFromCorrelation(rawData, this->dataSource.getFileSize().value_or(-1)); } } else @@ -189,7 +189,7 @@ void playlistItemRawFile::updateStartEndRange() this->prop.startEndRange = indexRange(-1, -1); return; } - nrFrames = this->dataSource.getFileSize() / bpf; + nrFrames = this->dataSource.getFileSize().value_or(0) / bpf; } this->prop.startEndRange = indexRange(0, std::max(nrFrames - 1, 0)); @@ -200,13 +200,13 @@ InfoData playlistItemRawFile::getInfo() const InfoData info((rawFormat == video::RawFormat::YUV) ? "YUV File Info" : "RGB File Info"); // At first append the file information part (path, date created, file size...) - info.items.append(this->dataSource.getFileInfoList()); + for (const auto &infoItem : this->dataSource.getFileInfoList()) + info.items.append(infoItem); - auto nrFrames = + const auto nrFrames = (this->properties().startEndRange.second - this->properties().startEndRange.first + 1); - info.items.append(InfoItem("Num Frames", QString::number(nrFrames))); - info.items.append( - InfoItem("Bytes per Frame", QString("%1").arg(this->video->getBytesPerFrame()))); + info.items.append(InfoItem("Num Frames", std::to_string(nrFrames))); + info.items.append(InfoItem("Bytes per Frame", std::to_string(this->video->getBytesPerFrame()))); if (this->dataSource.isOk() && this->video->isFormatValid() && !this->isY4MFile) { @@ -215,12 +215,14 @@ InfoData playlistItemRawFile::getInfo() const // selected YUV format / width / height ... auto bpf = this->video->getBytesPerFrame(); - if ((this->dataSource.getFileSize() % bpf) != 0) + if (const auto fileSize = this->dataSource.getFileSize()) { - // Add a warning - info.items.append(InfoItem( - "Warning", "The file size and the given video size and/or raw format do not match.")); + if ((*fileSize % bpf) != 0) + info.items.append(InfoItem( + "Warning"sv, "The file size and the given video size and/or raw format do not match.")); } + else + info.items.append(InfoItem("Warning"sv, "Could not obtain file size from input.")); } return info; @@ -447,7 +449,9 @@ bool playlistItemRawFile::parseY4MFile() void playlistItemRawFile::setFormatFromFileName() { - const auto fileFormat = guessFormatFromFilename(this->dataSource.getFileInfo()); + const QFileInfo fileInfo(QString::fromStdString(this->dataSource.getAbsoluteFilePath())); + + const auto fileFormat = guessFormatFromFilename(fileInfo); if (fileFormat.frameSize.isValid()) { this->video->setFrameSize(fileFormat.frameSize); @@ -458,8 +462,8 @@ void playlistItemRawFile::setFormatFromFileName() fileFormat.bitDepth, fileFormat.packed ? video::DataLayout::Packed : video::DataLayout::Planar, - dataSource.getFileSize(), - dataSource.getFileInfo()); + this->dataSource.getFileSize().value_or(-1), + fileInfo); if (fileFormat.frameRate != -1) this->prop.frameRate = fileFormat.frameRate; } @@ -490,9 +494,10 @@ void playlistItemRawFile::createPropertiesWidget() void playlistItemRawFile::savePlaylist(QDomElement &root, const QDir &playlistDir) const { - QUrl fileURL(dataSource.getAbsoluteFilePath()); + QUrl fileURL(QString::fromStdString(dataSource.getAbsoluteFilePath())); fileURL.setScheme("file"); - auto relativePath = playlistDir.relativeFilePath(dataSource.getAbsoluteFilePath()); + auto relativePath = + playlistDir.relativeFilePath(QString::fromStdString(dataSource.getAbsoluteFilePath())); auto d = YUViewDomElement(root.ownerDocument().createElement("playlistItemRawFile")); @@ -589,7 +594,7 @@ void playlistItemRawFile::getSupportedFileExtensions(QStringList &allExtensions, void playlistItemRawFile::reloadItemSource() { // Reopen the file - this->dataSource.openFile(this->properties().name); + this->dataSource.openFile(this->properties().name.toStdString()); if (!this->dataSource.isOk()) // Opening the file failed. return; diff --git a/YUViewLib/src/playlistitem/playlistItemResample.cpp b/YUViewLib/src/playlistitem/playlistItemResample.cpp index a9e7efea1..250ea2391 100644 --- a/YUViewLib/src/playlistitem/playlistItemResample.cpp +++ b/YUViewLib/src/playlistitem/playlistItemResample.cpp @@ -71,7 +71,7 @@ InfoData playlistItemResample::getInfo() const if (this->childCount() >= 1) info.items.append( - InfoItem(QString("File 1"), this->getChildPlaylistItem(0)->properties().name)); + InfoItem("File 1", this->getChildPlaylistItem(0)->properties().name.toStdString())); return info; } diff --git a/YUViewLib/src/playlistitem/playlistItemStatisticsFile.cpp b/YUViewLib/src/playlistitem/playlistItemStatisticsFile.cpp index 8607040b5..e14c6cfbf 100644 --- a/YUViewLib/src/playlistitem/playlistItemStatisticsFile.cpp +++ b/YUViewLib/src/playlistitem/playlistItemStatisticsFile.cpp @@ -75,9 +75,9 @@ playlistItemStatisticsFile::playlistItemStatisticsFile(const QString &itemNameOr this->openStatisticsFile(); this->statisticsUIHandler.setStatisticsData(&this->statisticsData); - connect(&this->statisticsUIHandler, &stats::StatisticUIHandler::updateItem, [this](bool redraw) { - emit SignalItemChanged(redraw, RECACHE_NONE); - }); + connect(&this->statisticsUIHandler, + &stats::StatisticUIHandler::updateItem, + [this](bool redraw) { emit SignalItemChanged(redraw, RECACHE_NONE); }); } playlistItemStatisticsFile::~playlistItemStatisticsFile() @@ -96,7 +96,7 @@ InfoData playlistItemStatisticsFile::getInfo() const return this->file->getInfo(); InfoData info("Statistics File info"); - info.items.append(InfoItem("File", "No file loaded")); + info.items.append(InfoItem("File"sv, "No file loaded")); return info; } @@ -296,9 +296,8 @@ void playlistItemStatisticsFile::openStatisticsFile() this->timer.start(1000, this); this->breakBackgroundAtomic.store(false); this->backgroundParserFuture = QtConcurrent::run( - [=](stats::StatisticsFileBase *file) { - file->readFrameAndTypePositionsFromFile(std::ref(this->breakBackgroundAtomic)); - }, + [=](stats::StatisticsFileBase *file) + { file->readFrameAndTypePositionsFromFile(std::ref(this->breakBackgroundAtomic)); }, this->file.get()); DEBUG_STAT( diff --git a/YUViewLib/src/statistics/StatisticsFileBase.cpp b/YUViewLib/src/statistics/StatisticsFileBase.cpp index 0c75aad61..ba6a83be8 100644 --- a/YUViewLib/src/statistics/StatisticsFileBase.cpp +++ b/YUViewLib/src/statistics/StatisticsFileBase.cpp @@ -37,7 +37,7 @@ namespace stats StatisticsFileBase::StatisticsFileBase(const QString &filename) { - this->file.openFile(filename); + this->file.openFile(filename.toStdString()); if (!this->file.isOk()) { this->errorMessage = "Error opening file " + filename; @@ -45,25 +45,27 @@ StatisticsFileBase::StatisticsFileBase(const QString &filename) } } -StatisticsFileBase::~StatisticsFileBase() { this->abortParsingDestroy = true; } +StatisticsFileBase::~StatisticsFileBase() +{ + this->abortParsingDestroy = true; +} InfoData StatisticsFileBase::getInfo() const { InfoData info("Statistics File info"); - // Append the file information (path, date created, file size...) - info.items.append(this->file.getFileInfoList()); - info.items.append(InfoItem("Sorted by POC", this->fileSortedByPOC ? "Yes" : "No")); - info.items.append(InfoItem("Parsing:", QString("%1%...").arg(this->parsingProgress, 0, 'f', 2))); + for (const auto &infoItem : this->file.getFileInfoList()) + info.items.append(infoItem); + info.items.append(InfoItem("Sorted by POC"sv, this->fileSortedByPOC ? "Yes" : "No")); + info.items.append(InfoItem("Parsing:", std::to_string(this->parsingProgress) + "...")); if (this->blockOutsideOfFramePOC != -1) - info.items.append( - InfoItem("Warning", - QString("A block in frame %1 is outside of the given size of the statistics.") - .arg(this->blockOutsideOfFramePOC))); + info.items.append(InfoItem("Warning", + "A block in frame " + std::to_string(this->blockOutsideOfFramePOC) + + " is outside of the given size of the statistics.")); if (this->error) - info.items.append(InfoItem("Parsing Error:", this->errorMessage)); + info.items.append(InfoItem("Parsing Error:", this->errorMessage.toStdString())); return info; } -} // namespace stats \ No newline at end of file +} // namespace stats diff --git a/YUViewLib/src/statistics/StatisticsFileCSV.cpp b/YUViewLib/src/statistics/StatisticsFileCSV.cpp index 2a95df5ac..7eeeb2272 100644 --- a/YUViewLib/src/statistics/StatisticsFileCSV.cpp +++ b/YUViewLib/src/statistics/StatisticsFileCSV.cpp @@ -194,8 +194,9 @@ void StatisticsFileCSV::readFrameAndTypePositionsFromFile(std::atomic_bool &brea this->maxPOC = poc; // Update percent of file parsed - this->parsingProgress = - ((double)lineBufferStartPos * 100 / (double)inputFile.getFileSize()); + if (const auto fileSize = inputFile.getFileSize()) + this->parsingProgress = (static_cast(lineBufferStartPos) * 100 / + static_cast(*fileSize)); } } } @@ -314,9 +315,9 @@ void StatisticsFileCSV::loadStatisticData(StatisticsData &statisticsData, int po this->blockOutsideOfFramePOC = poc; auto &statTypes = statisticsData.getStatisticsTypes(); - auto statIt = std::find_if(statTypes.begin(), statTypes.end(), [type](StatisticsType &t) { - return t.typeID == type; - }); + auto statIt = std::find_if(statTypes.begin(), + statTypes.end(), + [type](StatisticsType &t) { return t.typeID == type; }); Q_ASSERT_X(statIt != statTypes.end(), Q_FUNC_INFO, "Stat type not found."); if (vectorData && statIt->hasVectorData) diff --git a/YUViewLib/src/statistics/StatisticsFileVTMBMS.cpp b/YUViewLib/src/statistics/StatisticsFileVTMBMS.cpp index 644a9b0fe..5f01aaf27 100644 --- a/YUViewLib/src/statistics/StatisticsFileVTMBMS.cpp +++ b/YUViewLib/src/statistics/StatisticsFileVTMBMS.cpp @@ -142,8 +142,9 @@ void StatisticsFileVTMBMS::readFrameAndTypePositionsFromFile(std::atomic_bool &b this->maxPOC = poc; // Update percent of file parsed - this->parsingProgress = - ((double)lineBufferStartPos * 100 / (double)inputFile.getFileSize()); + if (const auto fileSize = inputFile.getFileSize()) + this->parsingProgress = (static_cast(lineBufferStartPos) * 100 / + static_cast(*fileSize)); } } } @@ -209,9 +210,9 @@ void StatisticsFileVTMBMS::loadStatisticData(StatisticsData &statisticsData, int // prepare regex for selected type auto &statTypes = statisticsData.getStatisticsTypes(); - auto statIt = std::find_if(statTypes.begin(), statTypes.end(), [typeID](StatisticsType &t) { - return t.typeID == typeID; - }); + auto statIt = std::find_if(statTypes.begin(), + statTypes.end(), + [typeID](StatisticsType &t) { return t.typeID == typeID; }); Q_ASSERT_X(statIt != statTypes.end(), Q_FUNC_INFO, "Stat type not found."); QRegularExpression typeRegex(" " + statIt->typeName + "="); // for catching lines of the type @@ -434,11 +435,11 @@ void StatisticsFileVTMBMS::readHeaderFromFile(StatisticsData &statisticsData) // extract statistics information from header lines // match: - //# Sequence size: [832x 480] + // # Sequence size: [832x 480] QRegularExpression sequenceSizeRegex("# Sequence size: \\[([0-9]+)x *([0-9]+)\\]"); // match: - //# Block Statistic Type: MergeFlag; Flag + // # Block Statistic Type: MergeFlag; Flag QRegularExpression availableStatisticsRegex( "# Block Statistic Type: *([0-9a-zA-Z_]+); *([0-9a-zA-Z]+); *(.*)"); diff --git a/YUViewLib/src/ui/widgets/BitstreamAnalysisWidget.cpp b/YUViewLib/src/ui/widgets/BitstreamAnalysisWidget.cpp index d7ca5eb10..baf37762a 100644 --- a/YUViewLib/src/ui/widgets/BitstreamAnalysisWidget.cpp +++ b/YUViewLib/src/ui/widgets/BitstreamAnalysisWidget.cpp @@ -196,7 +196,7 @@ void BitstreamAnalysisWidget::stopAndDeleteParserBlocking() void BitstreamAnalysisWidget::backgroundParsingFunction() { if (this->parser) - this->parser->runParsingOfFile(this->currentCompressedVideo->properties().name); + this->parser->runParsingOfFile(this->currentCompressedVideo->properties().name.toStdString()); } void BitstreamAnalysisWidget::currentSelectedItemsChanged(playlistItem *item1, playlistItem *, bool) diff --git a/YUViewLib/src/ui/widgets/FileInfoWidget.cpp b/YUViewLib/src/ui/widgets/FileInfoWidget.cpp index 6dda65218..6b9f2d383 100644 --- a/YUViewLib/src/ui/widgets/FileInfoWidget.cpp +++ b/YUViewLib/src/ui/widgets/FileInfoWidget.cpp @@ -1,54 +1,67 @@ /* This file is part of YUView - The YUV player with advanced analytics toolset -* -* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY -* -* 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; either version 3 of the License, or -* (at your option) any later version. -* -* In addition, as a special exception, the copyright holders give -* permission to link the code of portions of this program with the -* OpenSSL library under certain conditions as described in each -* individual source file, and distribute linked combinations including -* the two. -* -* You must obey the GNU General Public License in all respects for all -* of the code used other than OpenSSL. If you modify file(s) with this -* exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do -* so, delete this exception statement from your version. If you delete -* this exception statement from all source files in the program, then -* also delete it here. -* -* 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 for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * + * Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * 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; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "FileInfoWidget.h" +#include #include #include -#include #include #include "QLabelElided.h" -static const char kInfoIndex[] = "fi_infoIndex"; -static const char kInfoButtonID[] = "fi_buttonID"; +namespace +{ + +constexpr auto FILEINFOWIDGET_DEFAULT_WINDOW_TITLE = "Info"; + +void clearItemsPastGivenRow(QGridLayout &grid, const int row) +{ + for (int i = row; i < grid.rowCount(); ++i) + for (int j = 0; j < grid.columnCount(); ++j) + { + auto item = grid.itemAtPosition(i, j); + if (item) + delete item->widget(); + } +} + +} // namespace /* The file info group box can display information on a file (or any other display object). * If you provide a list of QString tuples, this class will fill a grid layout with the * corresponding labels. */ -FileInfoWidget::FileInfoWidget(QWidget *parent) : - QWidget(parent), - grid(this) +FileInfoWidget::FileInfoWidget(QWidget *parent) : QWidget(parent), grid(this) { // Load the warning icon warningIcon = QPixmap(":img_warning.png"); @@ -57,37 +70,26 @@ FileInfoWidget::FileInfoWidget(QWidget *parent) : setInfo(); } -void FileInfoWidget::clear(int startRow) -{ - for (int i = startRow; i < grid.rowCount(); ++i) - for (int j = 0; j < grid.columnCount(); ++j) - { - auto item = grid.itemAtPosition(i, j); - if (item) - delete item->widget(); - } -} - // Returns a possibly new widget at given row and column, having a set column span. // Any existing widgets of other types or other span will be removed. -template static W * widgetAt(QGridLayout *grid, int row, int column, int columnSpan = 1) +template static W *widgetAt(QGridLayout *grid, int row, int column, int columnSpan = 1) { Q_ASSERT(grid->columnCount() <= 2); QPointer widgets[2]; for (int j = 0; j < grid->columnCount(); ++j) { auto item = grid->itemAtPosition(row, j); - if (item) + if (item) widgets[j] = item->widget(); } if (columnSpan == 1 && widgets[0] == widgets[1]) delete widgets[0]; if (columnSpan == 2 && widgets[0] != widgets[1]) - for (auto & w : widgets) + for (auto &w : widgets) delete w; - auto widget = qobject_cast(widgets[column]); + auto widget = qobject_cast(widgets[column]); if (!widget) { // There may be an incompatible widget there. @@ -98,33 +100,22 @@ template static W * widgetAt(QGridLayout *grid, int row, int column return widget; } -int FileInfoWidget::addInfo(const InfoData &data, int row, int infoIndex) +int FileInfoWidget::addInfoDataItemsAndGetNextRowIndex(const InfoData &data, int row) { for (auto &info : data.items) { - auto name = widgetAt(&grid, row, 0); + auto name = widgetAt(&this->grid, row, 0); if (info.name != "Warning") - name->setText(info.name); + name->setText(QString::fromStdString(info.name)); else - name->setPixmap(warningIcon); + name->setPixmap(this->warningIcon); - if (!info.button) - { - auto text = widgetAt(&grid, row, 1); - text->setText(info.text); - text->setToolTip(info.toolTip); - } - else - { - auto button = widgetAt(&grid, row, 1); - button->setText(info.text); - button->setToolTip(info.toolTip); - button->setProperty(kInfoIndex, infoIndex); - button->setProperty(kInfoButtonID, info.buttonID); - connect(button, &QPushButton::clicked, this, &FileInfoWidget::infoButtonClickedSlot, Qt::UniqueConnection); - } - grid.setRowStretch(row, 0); - ++ row; + auto textLabel = widgetAt(&this->grid, row, 1); + textLabel->setText(QString::fromStdString(info.text)); + textLabel->setToolTip(QString::fromStdString(info.description)); + + this->grid.setRowStretch(row, 0); + ++row; } return row; } @@ -132,14 +123,14 @@ int FileInfoWidget::addInfo(const InfoData &data, int row, int infoIndex) void FileInfoWidget::setInfo(const InfoData &info1, const InfoData &info2) { QString topTitle = FILEINFOWIDGET_DEFAULT_WINDOW_TITLE; - int row = 0; + int row = 0; if (!info2.isEmpty()) widgetAt(&grid, row++, 0, 2)->setText(QStringLiteral("1: %1").arg(info1.title)); - else - if (!info1.title.isEmpty()) topTitle = info1.title; + else if (!info1.title.isEmpty()) + topTitle = info1.title; - row = addInfo(info1, row, 0); + row = this->addInfoDataItemsAndGetNextRowIndex(info1, row); if (!info2.isEmpty()) { @@ -147,24 +138,16 @@ void FileInfoWidget::setInfo(const InfoData &info1, const InfoData &info2) widgetAt(&grid, row++, 0, 2)->setText(QStringLiteral("2: %2").arg(info2.title)); } - row = addInfo(info2, row, 1); + row = this->addInfoDataItemsAndGetNextRowIndex(info2, row); - clear(row); + clearItemsPastGivenRow(this->grid, row); - if (row) + if (row > 0) { - grid.setColumnStretch(1, 1); // Last column should stretch - grid.setRowStretch(row-1, 1); // Last row should stretch + grid.setColumnStretch(1, 1); // Last column should stretch + grid.setRowStretch(row - 1, 1); // Last row should stretch } - if (parentWidget()) - parentWidget()->setWindowTitle(topTitle); -} - -void FileInfoWidget::infoButtonClickedSlot() -{ - auto button = qobject_cast(QObject::sender()); - if (button) - emit infoButtonClicked(button->property(kInfoIndex).toInt(), - button->property(kInfoButtonID).toInt()); + if (this->parentWidget()) + this->parentWidget()->setWindowTitle(topTitle); } diff --git a/YUViewLib/src/ui/widgets/FileInfoWidget.h b/YUViewLib/src/ui/widgets/FileInfoWidget.h index 05ef40186..10aa2cab1 100644 --- a/YUViewLib/src/ui/widgets/FileInfoWidget.h +++ b/YUViewLib/src/ui/widgets/FileInfoWidget.h @@ -1,34 +1,34 @@ /* This file is part of YUView - The YUV player with advanced analytics toolset -* -* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY -* -* 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; either version 3 of the License, or -* (at your option) any later version. -* -* In addition, as a special exception, the copyright holders give -* permission to link the code of portions of this program with the -* OpenSSL library under certain conditions as described in each -* individual source file, and distribute linked combinations including -* the two. -* -* You must obey the GNU General Public License in all respects for all -* of the code used other than OpenSSL. If you modify file(s) with this -* exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do -* so, delete this exception statement from your version. If you delete -* this exception statement from all source files in the program, then -* also delete it here. -* -* 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 for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * + * Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * 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; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #pragma once @@ -36,10 +36,7 @@ #include #include -#include "common/FileInfo.h" - -// This is the text that will be shown in the dockWidgets title if no playlistitem is selected -#define FILEINFOWIDGET_DEFAULT_WINDOW_TITLE "Info" +#include "common/InfoItemAndData.h" class FileInfoWidget : public QWidget { @@ -58,18 +55,8 @@ class FileInfoWidget : public QWidget Q_SIGNAL void infoButtonClicked(int infoIndex, int row); private: - // Clear widgets starting at given row. - void clear(int startRow); - - // Add information at the given grid row, for a given InfoData index (0 or 1). - int addInfo(const InfoData &data, int row, int infoIndex); - - // One of the buttons in the info panel was clicked. - void infoButtonClickedSlot(); + int addInfoDataItemsAndGetNextRowIndex(const InfoData &data, int row); - // The grid layout that contains all the InfoItems QGridLayout grid; - - // The warning icon. This is shown instead of a text if the name of the InfoItem is "Warning" - QPixmap warningIcon; + QPixmap warningIcon; }; diff --git a/YUViewLib/src/video/FrameHandler.cpp b/YUViewLib/src/video/FrameHandler.cpp index 40796c8ed..21e912171 100644 --- a/YUViewLib/src/video/FrameHandler.cpp +++ b/YUViewLib/src/video/FrameHandler.cpp @@ -279,7 +279,7 @@ void FrameHandler::drawFrame(QPainter *painter, double zoomFactor, bool drawRawV void FrameHandler::drawPixelValues(QPainter *painter, const int, - const QRect & videoRect, + const QRect &videoRect, const double zoomFactor, FrameHandler *item2, const bool markDifference, @@ -424,17 +424,17 @@ QImage FrameHandler::calculateDifference(FrameHandler *item2, } } - differenceInfoList.append(InfoItem("Difference Type", "RGB")); + differenceInfoList.append(InfoItem("Difference Type"sv, "RGB")); double mse[4]; mse[0] = double(mseAdd[0]) / (width * height); mse[1] = double(mseAdd[1]) / (width * height); mse[2] = double(mseAdd[2]) / (width * height); mse[3] = mse[0] + mse[1] + mse[2]; - differenceInfoList.append(InfoItem("MSE R", QString("%1").arg(mse[0]))); - differenceInfoList.append(InfoItem("MSE G", QString("%1").arg(mse[1]))); - differenceInfoList.append(InfoItem("MSE B", QString("%1").arg(mse[2]))); - differenceInfoList.append(InfoItem("MSE All", QString("%1").arg(mse[3]))); + differenceInfoList.append(InfoItem("MSE R", std::to_string(mse[0]))); + differenceInfoList.append(InfoItem("MSE G", std::to_string(mse[1]))); + differenceInfoList.append(InfoItem("MSE B", std::to_string(mse[2]))); + differenceInfoList.append(InfoItem("MSE All", std::to_string(mse[3]))); return diffImg; } diff --git a/YUViewLib/src/video/rgb/videoHandlerRGB.cpp b/YUViewLib/src/video/rgb/videoHandlerRGB.cpp index 6ae4be830..09f574355 100644 --- a/YUViewLib/src/video/rgb/videoHandlerRGB.cpp +++ b/YUViewLib/src/video/rgb/videoHandlerRGB.cpp @@ -33,10 +33,10 @@ #include "videoHandlerRGB.h" #include -#include #include #include #include +#include #include