From 0f4e2bbaadd93182b5aeebad55d2af69e2ec9864 Mon Sep 17 00:00:00 2001 From: ChristianFeldmann Date: Sun, 7 Jul 2024 21:42:23 +0200 Subject: [PATCH 01/60] Added google test and moved a first test over (file name guessing test). --- .gitmodules | 3 + YUView.pro | 4 + YUViewLib/src/common/Formatting.h | 24 +- YUViewLib/src/common/Functions.h | 5 - YUViewLib/src/filesource/FileSource.cpp | 161 -------- YUViewLib/src/filesource/FileSource.h | 9 - .../src/filesource/GuessFormatFromName.cpp | 204 ++++++++++ .../src/filesource/GuessFormatFromName.h | 49 +++ .../src/playlistitem/playlistItemRawFile.cpp | 9 +- YUViewLib/src/video/rgb/videoHandlerRGB.cpp | 19 +- .../src/video/videoHandlerDifference.cpp | 17 +- YUViewLib/src/video/yuv/videoHandlerYUV.cpp | 377 +++++++++--------- YUViewUnitTest/YUViewUnitTest.pro | 28 +- .../filesource/filesource/Filesource.pro | 16 - .../filesource/filesource/FilesourceTest.cpp | 179 --------- .../guessFormatFromFilenameTest.cpp | 191 +++++++++ YUViewUnitTestOld/YUViewUnitTest.pro | 7 + .../filesource/filesource.pro | 0 .../filesourceAnnexB/FilesourceAnnexB.pro | 0 .../filesourceAnnexB/FilesourceAnnexBTest.cpp | 0 .../statistics/statistics.pro | 0 .../statisticsData/StatisticsDataTest.cpp | 0 .../statisticsData/StatisticsDataTest.pro | 0 .../StatisticsFileCSVTest.cpp | 0 .../StatisticsFileCSVTest.pro | 0 .../StatisticsFileVTMBMSTest.cpp | 0 .../StatisticsFileVTMBMSTest.pro | 0 .../ConversionRGBTest/ConversionRGBTest.cpp | 0 .../ConversionRGBTest/ConversionRGBTest.pro | 0 ...sue511RGBConversionInvalidMemoryAccess.cpp | 0 ...sue511RGBConversionInvalidMemoryAccess.pro | 0 .../PixelFormatRGBGuessTest.cpp | 0 .../PixelFormatRGBGuessTest.pro | 0 .../PixelFormatRGBTest/PixelFormatRGBTest.cpp | 0 .../PixelFormatRGBTest/PixelFormatRGBTest.pro | 0 .../video/rgb/rgb.pro | 0 .../video/video.pro | 0 .../PixelFormatYUVGuessTest.cpp | 0 .../PixelFormatYUVGuessTest.pro | 0 .../PixelFormatYUVTest/PixelFormatYUVTest.cpp | 0 .../PixelFormatYUVTest/PixelFormatYUVTest.pro | 0 .../video/yuv/yuv.pro | 0 submodules/googletest | 1 + .../googletest-qmake/googletest-qmake.pro | 6 + submodules/googletest-qmake/gtest/gtest.pro | 11 + .../gtest_main/gtest_main.pro | 11 + 46 files changed, 746 insertions(+), 585 deletions(-) create mode 100644 .gitmodules create mode 100644 YUViewLib/src/filesource/GuessFormatFromName.cpp create mode 100644 YUViewLib/src/filesource/GuessFormatFromName.h delete mode 100644 YUViewUnitTest/filesource/filesource/Filesource.pro delete mode 100644 YUViewUnitTest/filesource/filesource/FilesourceTest.cpp create mode 100644 YUViewUnitTest/filesource/guessFormatFromFilenameTest.cpp create mode 100644 YUViewUnitTestOld/YUViewUnitTest.pro rename {YUViewUnitTest => YUViewUnitTestOld}/filesource/filesource.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/filesource/filesourceAnnexB/FilesourceAnnexB.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/filesource/filesourceAnnexB/FilesourceAnnexBTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/statistics/statistics.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/statistics/statisticsData/StatisticsDataTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/statistics/statisticsData/StatisticsDataTest.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/statistics/statisticsFileCSV/StatisticsFileCSVTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/statistics/statisticsFileCSV/StatisticsFileCSVTest.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/statistics/statisticsFileVTMBMS/StatisticsFileVTMBMSTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/statistics/statisticsFileVTMBMS/StatisticsFileVTMBMSTest.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/ConversionRGBTest/ConversionRGBTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/ConversionRGBTest/ConversionRGBTest.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/Issue511RGBConversionInvalidMemoryAccess/Issue511RGBConversionInvalidMemoryAccess.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/Issue511RGBConversionInvalidMemoryAccess/Issue511RGBConversionInvalidMemoryAccess.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/PixelFormatRGBGuessTest/PixelFormatRGBGuessTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/PixelFormatRGBGuessTest/PixelFormatRGBGuessTest.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/PixelFormatRGBTest/PixelFormatRGBTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/PixelFormatRGBTest/PixelFormatRGBTest.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/rgb/rgb.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/video.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/yuv/PixelFormatYUVGuessTest/PixelFormatYUVGuessTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/yuv/PixelFormatYUVGuessTest/PixelFormatYUVGuessTest.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/yuv/PixelFormatYUVTest/PixelFormatYUVTest.cpp (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/yuv/PixelFormatYUVTest/PixelFormatYUVTest.pro (100%) rename {YUViewUnitTest => YUViewUnitTestOld}/video/yuv/yuv.pro (100%) create mode 160000 submodules/googletest create mode 100644 submodules/googletest-qmake/googletest-qmake.pro create mode 100644 submodules/googletest-qmake/gtest/gtest.pro create mode 100644 submodules/googletest-qmake/gtest_main/gtest_main.pro diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..71b2104a5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "submodules/googletest"] + path = submodules/googletest + url = git@github.com:google/googletest.git diff --git a/YUView.pro b/YUView.pro index b34aa2300..8723a880f 100644 --- a/YUView.pro +++ b/YUView.pro @@ -7,7 +7,11 @@ YUViewLib.subdir = YUViewLib YUViewApp.depends = YUViewLib UNITTESTS { + SUBDIRS += Googletest + Googletest.subdir = submodules/googletest-qmake + SUBDIRS += YUViewUnitTest YUViewUnitTest.subdir = YUViewUnitTest + YUViewUnitTest.depends = Googletest YUViewUnitTest.depends = YUViewLib } diff --git a/YUViewLib/src/common/Formatting.h b/YUViewLib/src/common/Formatting.h index 6681978e1..427014c2d 100644 --- a/YUViewLib/src/common/Formatting.h +++ b/YUViewLib/src/common/Formatting.h @@ -77,9 +77,31 @@ static std::ostream &operator<<(std::ostream &stream, const Size &size) return stream; } -static std::string to_string(const Size &size) +inline std::string to_string(const Size &size) { std::ostringstream stream; stream << size; return stream.str(); } + +inline std::string to_string(const bool b) +{ + return b ? "True" : "False"; +} + +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) +{ + std::replace_if( + str.begin(), + str.end(), + [&values](const char value) + { return std::find(values.begin(), values.end(), value) != values.end(); }, + replacement); + return str; +} diff --git a/YUViewLib/src/common/Functions.h b/YUViewLib/src/common/Functions.h index a06553ea6..335d47f84 100644 --- a/YUViewLib/src/common/Functions.h +++ b/YUViewLib/src/common/Functions.h @@ -67,11 +67,6 @@ QStringList toQStringList(const std::vector &stringVec); std::string toLower(std::string str); ByteVector readData(std::istream &istream, const size_t nrBytes); -inline std::string boolToString(bool b) -{ - return b ? "True" : "False"; -} - template unsigned clipToUnsigned(T val) { static_assert(std::is_signed::value, "T must must be a signed type"); diff --git a/YUViewLib/src/filesource/FileSource.cpp b/YUViewLib/src/filesource/FileSource.cpp index 7e5daf3de..336d9d1c8 100644 --- a/YUViewLib/src/filesource/FileSource.cpp +++ b/YUViewLib/src/filesource/FileSource.cpp @@ -36,7 +36,6 @@ #include #include -#include #include #include #ifdef Q_OS_WIN @@ -142,166 +141,6 @@ QString FileSource::getAbsoluteFilePath() const return this->isFileOpened ? this->fileInfo.absoluteFilePath() : QString(); } -FileSource::fileFormat_t FileSource::guessFormatFromFilename() const -{ - FileSource::fileFormat_t format; - - // We are going to check two strings (one after the other) for indicators on the frames size, fps - // and bit depth. 1: The file name, 2: The folder name that the file is contained in. - - auto dirName = this->fileInfo.absoluteDir().dirName(); - auto fileName = this->fileInfo.fileName(); - if (fileName.isEmpty()) - return format; - - for (auto const &name : {fileName, dirName}) - { - // First, we will try to get a frame size from the name - if (!format.frameSize.isValid()) - { - // The regular expressions to match. They are sorted from most detailed to least so that the - // most detailed ones are tested first. - auto regExprList = - QStringList() - << "([0-9]+)(?:x|X|\\*)([0-9]+)_([0-9]+)(?:Hz)?_([0-9]+)b?[\\._]" // Something_2160x1440_60_8_more.yuv - // or - // Something_2160x1440_60_8b.yuv - // or - // Something_2160x1440_60Hz_8_more.yuv - << "([0-9]+)(?:x|X|\\*)([0-9]+)_([0-9]+)(?:Hz)?[\\._]" // Something_2160x1440_60_more.yuv - // or Something_2160x1440_60.yuv - << "([0-9]+)(?:x|X|\\*)([0-9]+)[\\._]"; // Something_2160x1440_more.yuv or - // Something_2160x1440.yuv - - for (auto regExpStr : regExprList) - { - QRegularExpression exp(regExpStr); - auto match = exp.match(name); - if (match.hasMatch()) - { - auto widthString = match.captured(1); - auto heightString = match.captured(2); - format.frameSize = Size(widthString.toInt(), heightString.toInt()); - - auto rateString = match.captured(3); - if (!rateString.isEmpty()) - format.frameRate = rateString.toDouble(); - - auto bitDepthString = match.captured(4); - if (!bitDepthString.isEmpty()) - format.bitDepth = bitDepthString.toUInt(); - - break; // Don't check the following expressions - } - } - } - - // try resolution indicators with framerate: "1080p50", "720p24" ... - if (!format.frameSize.isValid()) - { - QRegularExpression rx1080p("1080p([0-9]+)"); - auto matchIt = rx1080p.globalMatch(name); - if (matchIt.hasNext()) - { - auto match = matchIt.next(); - format.frameSize = Size(1920, 1080); - auto frameRateString = match.captured(1); - format.frameRate = frameRateString.toInt(); - } - } - if (!format.frameSize.isValid()) - { - QRegularExpression rx720p("720p([0-9]+)"); - auto matchIt = rx720p.globalMatch(name); - if (matchIt.hasNext()) - { - auto match = matchIt.next(); - format.frameSize = Size(1280, 720); - auto frameRateString = match.captured(1); - format.frameRate = frameRateString.toInt(); - } - } - - if (!format.frameSize.isValid()) - { - // try to find resolution indicators (e.g. 'cif', 'hd') in file name - if (name.contains("_cif", Qt::CaseInsensitive)) - format.frameSize = Size(352, 288); - else if (name.contains("_qcif", Qt::CaseInsensitive)) - format.frameSize = Size(176, 144); - else if (name.contains("_4cif", Qt::CaseInsensitive)) - format.frameSize = Size(704, 576); - else if (name.contains("UHD", Qt::CaseSensitive)) - format.frameSize = Size(3840, 2160); - else if (name.contains("HD", Qt::CaseSensitive)) - format.frameSize = Size(1920, 1080); - else if (name.contains("1080p", Qt::CaseSensitive)) - format.frameSize = Size(1920, 1080); - else if (name.contains("720p", Qt::CaseSensitive)) - format.frameSize = Size(1280, 720); - } - - // Second, if we were able to get a frame size but no frame rate, we will try to get a frame - // rate. - if (format.frameSize.isValid() && format.frameRate == -1) - { - // Look for: 24fps, 50fps, 24FPS, 50FPS - QRegularExpression rxFPS("([0-9]+)fps", QRegularExpression::CaseInsensitiveOption); - auto match = rxFPS.match(name); - if (match.hasMatch()) - { - auto frameRateString = match.captured(1); - format.frameRate = frameRateString.toInt(); - } - } - if (format.frameSize.isValid() && format.frameRate == -1) - { - // Look for: 24Hz, 50Hz, 24HZ, 50HZ - QRegularExpression rxHZ("([0-9]+)HZ", QRegularExpression::CaseInsensitiveOption); - auto match = rxHZ.match(name); - if (match.hasMatch()) - { - QString frameRateString = match.captured(1); - format.frameRate = frameRateString.toInt(); - } - } - - // Third, if we were able to get a frame size but no bit depth, we try to get a bit depth. - if (format.frameSize.isValid() && format.bitDepth == 0) - { - for (unsigned bd : {8, 9, 10, 12, 16}) - { - // Look for: 10bit, 10BIT, 10-bit, 10-BIT - if (name.contains(QString("%1bit").arg(bd), Qt::CaseInsensitive) || - name.contains(QString("%1-bit").arg(bd), Qt::CaseInsensitive)) - { - format.bitDepth = bd; - break; - } - // Look for bit depths like: _16b_ .8b. -12b- - QRegularExpression exp(QString("(?:_|\\.|-)%1b(?:_|\\.|-)").arg(bd)); - auto match = exp.match(name); - if (match.hasMatch()) - { - format.bitDepth = bd; - break; - } - } - } - - // If we were able to get a frame size, try to get an indicator for packed formats - if (format.frameSize.isValid()) - { - QRegularExpression exp("(?:_|\\.|-)packed(?:_|\\.|-)"); - auto match = exp.match(name); - if (match.hasMatch()) - format.packed = true; - } - } - - return format; -} - // If you are loading a playlist and you have an absolute path and a relative path, this function // will return the absolute path (if a file with that absolute path exists) or convert the relative // path to an absolute one and return that (if that file exists). If neither exists the empty string diff --git a/YUViewLib/src/filesource/FileSource.h b/YUViewLib/src/filesource/FileSource.h index 6aa3f19c0..c877f50e5 100644 --- a/YUViewLib/src/filesource/FileSource.h +++ b/YUViewLib/src/filesource/FileSource.h @@ -86,15 +86,6 @@ class FileSource : public QObject virtual bool seek(int64_t pos) { return !this->isFileOpened ? false : this->srcFile.seek(pos); } int64_t pos() { return !this->isFileOpened ? 0 : this->srcFile.pos(); } - struct fileFormat_t - { - Size frameSize; - int frameRate{-1}; - unsigned bitDepth{}; - bool packed{false}; - }; - fileFormat_t guessFormatFromFilename() const; - // Get the file size in bytes // Read the given number of bytes starting at startPos into the QByteArray out diff --git a/YUViewLib/src/filesource/GuessFormatFromName.cpp b/YUViewLib/src/filesource/GuessFormatFromName.cpp new file mode 100644 index 000000000..c0cc9712c --- /dev/null +++ b/YUViewLib/src/filesource/GuessFormatFromName.cpp @@ -0,0 +1,204 @@ +/* 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 . + */ + +#include "GuessFormatFromName.h" + +#include +#include + +bool FileFormat::operator== (const FileFormat &rhs) const +{ + return this->frameSize == rhs.frameSize && // + this->frameRate == rhs.frameRate && // + this->bitDepth == rhs.bitDepth && // + this->packed == rhs.packed; +} + +FileFormat guessFormatFromFilename(const QFileInfo &fileInfo) +{ + FileFormat format; + + // We are going to check two strings (one after the other) for indicators on the frames size, fps + // and bit depth. 1: The file name, 2: The folder name that the file is contained in. + + const auto dirName = fileInfo.absoluteDir().dirName(); + const auto fileName = fileInfo.fileName(); + if (fileName.isEmpty()) + return format; + + for (auto const &name : {fileName, dirName}) + { + // First, we will try to get a frame size from the name + if (!format.frameSize.isValid()) + { + // The regular expressions to match. They are sorted from most detailed to least so that the + // most detailed ones are tested first. + auto regExprList = + QStringList() + << "([0-9]+)(?:x|X|\\*)([0-9]+)_([0-9]+)(?:Hz)?_([0-9]+)b?[\\._]" // Something_2160x1440_60_8_more.yuv + // or + // Something_2160x1440_60_8b.yuv + // or + // Something_2160x1440_60Hz_8_more.yuv + << "([0-9]+)(?:x|X|\\*)([0-9]+)_([0-9]+)(?:Hz)?[\\._]" // Something_2160x1440_60_more.yuv + // or Something_2160x1440_60.yuv + << "([0-9]+)(?:x|X|\\*)([0-9]+)[\\._]"; // Something_2160x1440_more.yuv or + // Something_2160x1440.yuv + + for (auto regExpStr : regExprList) + { + QRegularExpression exp(regExpStr); + auto match = exp.match(name); + if (match.hasMatch()) + { + auto widthString = match.captured(1); + auto heightString = match.captured(2); + format.frameSize = Size(widthString.toInt(), heightString.toInt()); + + auto rateString = match.captured(3); + if (!rateString.isEmpty()) + format.frameRate = rateString.toDouble(); + + auto bitDepthString = match.captured(4); + if (!bitDepthString.isEmpty()) + format.bitDepth = bitDepthString.toUInt(); + + break; // Don't check the following expressions + } + } + } + + // try resolution indicators with framerate: "1080p50", "720p24" ... + if (!format.frameSize.isValid()) + { + QRegularExpression rx1080p("1080p([0-9]+)"); + auto matchIt = rx1080p.globalMatch(name); + if (matchIt.hasNext()) + { + auto match = matchIt.next(); + format.frameSize = Size(1920, 1080); + auto frameRateString = match.captured(1); + format.frameRate = frameRateString.toInt(); + } + } + if (!format.frameSize.isValid()) + { + QRegularExpression rx720p("720p([0-9]+)"); + auto matchIt = rx720p.globalMatch(name); + if (matchIt.hasNext()) + { + auto match = matchIt.next(); + format.frameSize = Size(1280, 720); + auto frameRateString = match.captured(1); + format.frameRate = frameRateString.toInt(); + } + } + + if (!format.frameSize.isValid()) + { + // try to find resolution indicators (e.g. 'cif', 'hd') in file name + if (name.contains("_cif", Qt::CaseInsensitive)) + format.frameSize = Size(352, 288); + else if (name.contains("_qcif", Qt::CaseInsensitive)) + format.frameSize = Size(176, 144); + else if (name.contains("_4cif", Qt::CaseInsensitive)) + format.frameSize = Size(704, 576); + else if (name.contains("UHD", Qt::CaseSensitive)) + format.frameSize = Size(3840, 2160); + else if (name.contains("HD", Qt::CaseSensitive)) + format.frameSize = Size(1920, 1080); + else if (name.contains("1080p", Qt::CaseSensitive)) + format.frameSize = Size(1920, 1080); + else if (name.contains("720p", Qt::CaseSensitive)) + format.frameSize = Size(1280, 720); + } + + // Second, if we were able to get a frame size but no frame rate, we will try to get a frame + // rate. + if (format.frameSize.isValid() && format.frameRate == -1) + { + // Look for: 24fps, 50fps, 24FPS, 50FPS + QRegularExpression rxFPS("([0-9]+)fps", QRegularExpression::CaseInsensitiveOption); + auto match = rxFPS.match(name); + if (match.hasMatch()) + { + auto frameRateString = match.captured(1); + format.frameRate = frameRateString.toInt(); + } + } + if (format.frameSize.isValid() && format.frameRate == -1) + { + // Look for: 24Hz, 50Hz, 24HZ, 50HZ + QRegularExpression rxHZ("([0-9]+)HZ", QRegularExpression::CaseInsensitiveOption); + auto match = rxHZ.match(name); + if (match.hasMatch()) + { + QString frameRateString = match.captured(1); + format.frameRate = frameRateString.toInt(); + } + } + + // Third, if we were able to get a frame size but no bit depth, we try to get a bit depth. + if (format.frameSize.isValid() && format.bitDepth == 0) + { + for (unsigned bd : {8, 9, 10, 12, 16}) + { + // Look for: 10bit, 10BIT, 10-bit, 10-BIT + if (name.contains(QString("%1bit").arg(bd), Qt::CaseInsensitive) || + name.contains(QString("%1-bit").arg(bd), Qt::CaseInsensitive)) + { + format.bitDepth = bd; + break; + } + // Look for bit depths like: _16b_ .8b. -12b- + QRegularExpression exp(QString("(?:_|\\.|-)%1b(?:_|\\.|-)").arg(bd)); + auto match = exp.match(name); + if (match.hasMatch()) + { + format.bitDepth = bd; + break; + } + } + } + + // If we were able to get a frame size, try to get an indicator for packed formats + if (format.frameSize.isValid()) + { + QRegularExpression exp("(?:_|\\.|-)packed(?:_|\\.|-)"); + auto match = exp.match(name); + if (match.hasMatch()) + format.packed = true; + } + } + + return format; +} diff --git a/YUViewLib/src/filesource/GuessFormatFromName.h b/YUViewLib/src/filesource/GuessFormatFromName.h new file mode 100644 index 000000000..4c216e8ba --- /dev/null +++ b/YUViewLib/src/filesource/GuessFormatFromName.h @@ -0,0 +1,49 @@ +/* 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 . + */ + +#pragma once + +#include + +#include + +struct FileFormat +{ + Size frameSize; + int frameRate{-1}; + unsigned bitDepth{}; + bool packed{false}; + + bool operator==(const FileFormat &rhs) const; +}; + +FileFormat guessFormatFromFilename(const QFileInfo &fileInfo); diff --git a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp index 10e96bcfd..b9dc1db00 100644 --- a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp +++ b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp @@ -38,6 +38,7 @@ #include #include +#include #include // Activate this if you want to know when which buffer is loaded/converted to image and so on. @@ -58,9 +59,9 @@ constexpr auto RGBA_EXTENSIONS = {"rgba", "gbra", "bgra", "brga", "argb", "agbr" bool isInExtensions(const QString &testValue, const std::initializer_list &extensions) { const auto it = - std::find_if(extensions.begin(), extensions.end(), [testValue](const char *extension) { - return QString(extension) == testValue; - }); + std::find_if(extensions.begin(), + extensions.end(), + [testValue](const char *extension) { return QString(extension) == testValue; }); return it != extensions.end(); } @@ -443,7 +444,7 @@ bool playlistItemRawFile::parseY4MFile() void playlistItemRawFile::setFormatFromFileName() { - auto fileFormat = this->dataSource.guessFormatFromFilename(); + const auto fileFormat = guessFormatFromFilename(this->dataSource.getFileInfo()); if (fileFormat.frameSize.isValid()) { this->video->setFrameSize(fileFormat.frameSize); diff --git a/YUViewLib/src/video/rgb/videoHandlerRGB.cpp b/YUViewLib/src/video/rgb/videoHandlerRGB.cpp index c4c075d5e..481477df3 100644 --- a/YUViewLib/src/video/rgb/videoHandlerRGB.cpp +++ b/YUViewLib/src/video/rgb/videoHandlerRGB.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include