diff --git a/YUViewLib/src/common/Error.h b/YUViewLib/src/common/Error.h new file mode 100644 index 000000000..8c884a417 --- /dev/null +++ b/YUViewLib/src/common/Error.h @@ -0,0 +1,41 @@ +/* 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 + +class NotImplemented : public std::logic_error +{ +public: + NotImplemented() : std::logic_error("Function not yet implemented"){}; +}; diff --git a/YUViewLib/src/common/Typedef.h b/YUViewLib/src/common/Typedef.h index 8c3023270..d1b4e5ad7 100644 --- a/YUViewLib/src/common/Typedef.h +++ b/YUViewLib/src/common/Typedef.h @@ -274,6 +274,21 @@ template struct Range } }; +struct Position +{ + Position() = default; + Position(int x, int y) + { + this->x = x; + this->y = y; + } + + int x{}; + int y{}; + + bool operator!=(const Position &other) const { return this->x != other.x || this->y != other.y; } +}; + struct Ratio { int num{}; diff --git a/YUViewLib/src/decoder/decoderBase.cpp b/YUViewLib/src/decoder/decoderBase.cpp index 22688152e..6550b16a8 100644 --- a/YUViewLib/src/decoder/decoderBase.cpp +++ b/YUViewLib/src/decoder/decoderBase.cpp @@ -32,9 +32,11 @@ #include "decoderBase.h" +#include #include #include + namespace decoder { diff --git a/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp b/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp index 10df6a6e8..9ca5a6d99 100644 --- a/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp +++ b/YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp @@ -31,6 +31,7 @@ */ #include "FFmpegVersionHandler.h" +#include #include #include diff --git a/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp b/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp index 796f2e36b..a353a80e9 100644 --- a/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp +++ b/YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp @@ -204,9 +204,9 @@ playlistItemCompressedVideo::playlistItemCompressedVideo(const QString &compress // Is this file RGB or YUV? this->rawFormat = this->inputFileFFmpegLoading->getRawFormat(); DEBUG_COMPRESSED("playlistItemCompressedVideo::playlistItemCompressedVideo Raw format " - << (this->rawFormat == raw_YUV ? "YUV" - : this->rawFormat == video::RawFormat::RGB ? "RGB" - : "Unknown")); + << (this->rawFormat == raw_YUV + ? "YUV" + : this->rawFormat == video::RawFormat::RGB ? "RGB" : "Unknown")); if (this->rawFormat == video::RawFormat::YUV) formatYuv = this->inputFileFFmpegLoading->getPixelFormatYUV(); else if (this->rawFormat == video::RawFormat::RGB) @@ -681,8 +681,8 @@ void playlistItemCompressedVideo::loadRawData(int frameIdx, bool caching) { // In this scenario, we can read and push AVPackets // from the FFmpeg file and pass them to the FFmpeg decoder directly. - auto pkt = caching ? this->inputFileFFmpegCaching->getNextPacket(repushData) - : this->inputFileFFmpegLoading->getNextPacket(repushData); + auto pkt = caching ? this->inputFileFFmpegCaching->getNextPacket(repushData) + : this->inputFileFFmpegLoading->getNextPacket(repushData); repushData = false; if (pkt) DEBUG_COMPRESSED("playlistItemCompressedVideo::loadRawData retrived packet PTS " diff --git a/YUViewLib/src/playlistitem/playlistItemCompressedVideo.h b/YUViewLib/src/playlistitem/playlistItemCompressedVideo.h index b2bf20b28..cfd7aae7f 100644 --- a/YUViewLib/src/playlistitem/playlistItemCompressedVideo.h +++ b/YUViewLib/src/playlistitem/playlistItemCompressedVideo.h @@ -42,8 +42,6 @@ #include "playlistItemWithVideo.h" -class videoHandler; - /* This playlist item encapsulates all compressed video sequences. * We can read the data from a plain binary file (we support various raw annexB formats) or we can * use ffmpeg to read from a container. For decoding, a range of different decoders is available. diff --git a/YUViewLib/src/playlistitem/playlistItemDifference.cpp b/YUViewLib/src/playlistitem/playlistItemDifference.cpp index 18e95d750..c51f9c188 100644 --- a/YUViewLib/src/playlistitem/playlistItemDifference.cpp +++ b/YUViewLib/src/playlistitem/playlistItemDifference.cpp @@ -44,15 +44,15 @@ #define DEBUG_DIFF(fmt, ...) ((void)0) #endif -#define DIFFERENCE_INFO_TEXT \ - "Please drop two video item's onto this difference item to calculate the difference." +constexpr auto DIFFERENCE_INFO_TEXT = + "Please drop two video item's onto this difference item to calculate the difference."; playlistItemDifference::playlistItemDifference() : playlistItemContainer("Difference Item") { - setIcon(0, functionsGui::convertIcon(":img_difference.png")); + this->setIcon(0, functionsGui::convertIcon(":img_difference.png")); // Enable dropping for difference objects. The user can drop the two items to calculate the // difference from. - setFlags(flags() | Qt::ItemIsDropEnabled); + this->setFlags(this->flags() | Qt::ItemIsDropEnabled); this->prop.propertiesWidgetTitle = "Difference Properties"; @@ -61,10 +61,10 @@ playlistItemDifference::playlistItemDifference() : playlistItemContainer("Differ this->frameLimitsMax = false; this->infoText = DIFFERENCE_INFO_TEXT; - connect(&difference, - &video::videoHandlerDifference::signalHandlerChanged, - this, - &playlistItemDifference::SignalItemChanged); + this->connect(&this->difference, + &video::videoHandlerDifference::signalHandlerChanged, + this, + &playlistItemDifference::SignalItemChanged); } /* For a difference item, the info list is just a list of the names of the @@ -74,20 +74,18 @@ InfoData playlistItemDifference::getInfo() const { InfoData info("Difference Info"); - if (childCount() >= 1) - info.items.append(InfoItem(QString("File 1"), getChildPlaylistItem(0)->properties().name)); - if (childCount() >= 2) - info.items.append(InfoItem(QString("File 2"), getChildPlaylistItem(1)->properties().name)); + if (this->childCount() >= 1) + info.items.append( + InfoItem(QString("File 1"), this->getChildPlaylistItem(0)->properties().name)); + if (this->childCount() >= 2) + info.items.append( + InfoItem(QString("File 2"), this->getChildPlaylistItem(1)->properties().name)); // Report the position of the first difference in coding order - difference.reportFirstDifferencePosition(info.items); + this->difference.reportFirstDifferencePosition(info.items); - // Report MSE - for (int i = 0; i < difference.differenceInfoList.length(); i++) - { - InfoItem p = difference.differenceInfoList[i]; - info.items.append(p); - } + for (const auto &item : this->difference.differenceInfoList) + info.items.append(item); return info; } @@ -99,35 +97,35 @@ void playlistItemDifference::drawItem(QPainter *painter, { DEBUG_DIFF("playlistItemDifference::drawItem frameIdx %d %s", frameIdx, - childLlistUpdateRequired ? "childLlistUpdateRequired" : ""); - if (childLlistUpdateRequired) + this->childLlistUpdateRequired ? "childLlistUpdateRequired" : ""); + if (this->childLlistUpdateRequired) { // Update the 'childList' and connect the signals/slots - updateChildList(); + this->updateChildList(); // Update the items in the difference item video::FrameHandler *childVideo0 = nullptr; video::FrameHandler *childVideo1 = nullptr; if (childCount() >= 1) - childVideo0 = getChildPlaylistItem(0)->getFrameHandler(); + childVideo0 = this->getChildPlaylistItem(0)->getFrameHandler(); if (childCount() >= 2) - childVideo1 = getChildPlaylistItem(1)->getFrameHandler(); + childVideo1 = this->getChildPlaylistItem(1)->getFrameHandler(); - difference.setInputVideos(childVideo0, childVideo1); + this->difference.setInputVideos(childVideo0, childVideo1); - if (childCount() > 2) - infoText = "More than two items are not supported.\n" DIFFERENCE_INFO_TEXT; + if (this->childCount() > 2) + infoText = "More than two items are not supported.\n" + QString(DIFFERENCE_INFO_TEXT); else infoText = DIFFERENCE_INFO_TEXT; } - if (childCount() != 2 || !difference.inputsValid()) + if (this->childCount() != 2 || !this->difference.inputsValid()) // Draw the emptyText playlistItem::drawItem(painter, -1, zoomFactor, drawRawData); else { // draw the videoHandler - difference.drawDifferenceFrame(painter, frameIdx, zoomFactor, drawRawData); + this->difference.drawDifferenceFrame(painter, frameIdx, zoomFactor, drawRawData); } } @@ -138,13 +136,11 @@ ItemLoadingState playlistItemDifference::needsLoading(int frameIdx, bool loadRaw QSize playlistItemDifference::getSize() const { - if (!difference.inputsValid()) - { + if (!this->difference.inputsValid()) // Return the size of the empty text. return playlistItemContainer::getSize(); - } - auto s = difference.getFrameSize(); + auto s = this->difference.getFrameSize(); return QSize(s.width, s.height); } @@ -152,12 +148,12 @@ void playlistItemDifference::createPropertiesWidget() { Q_ASSERT_X(!this->propertiesWidget, "createPropertiesWidget", "Properties widget already exists"); - preparePropertiesWidget(QStringLiteral("playlistItemDifference")); + this->preparePropertiesWidget(QStringLiteral("playlistItemDifference")); // On the top level everything is layout vertically - QVBoxLayout *vAllLaout = new QVBoxLayout(propertiesWidget.data()); + auto vAllLaout = new QVBoxLayout(this->propertiesWidget.data()); - QFrame *line = new QFrame; + auto line = new QFrame; line->setObjectName(QStringLiteral("line")); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); @@ -187,7 +183,7 @@ void playlistItemDifference::savePlaylist(QDomElement &root, const QDir &playlis playlistItemDifference * playlistItemDifference::newPlaylistItemDifference(const YUViewDomElement &root) { - playlistItemDifference *newDiff = new playlistItemDifference(); + auto newDiff = new playlistItemDifference(); // Load properties from the parent classes newDiff->difference.loadPlaylist(root); @@ -211,7 +207,7 @@ ValuePairListSets playlistItemDifference::getPixelValues(const QPoint &pixelPos, { newSet.append("Item B", getChildPlaylistItem(1)->getFrameHandler()->getPixelValues(pixelPos, frameIdx)); - newSet.append("Diff (A-B)", difference.getPixelValues(pixelPos, frameIdx, nullptr)); + newSet.append("Diff (A-B)", this->difference.getPixelValues(pixelPos, frameIdx, nullptr)); } return newSet; @@ -222,18 +218,18 @@ void playlistItemDifference::loadFrame(int frameIdx, bool loadRawData, bool emitSignals) { - if (childCount() != 2 || !difference.inputsValid()) + if (this->childCount() != 2 || !this->difference.inputsValid()) return; - auto state = difference.needsLoading(frameIdx, loadRawData); + const auto state = this->difference.needsLoading(frameIdx, loadRawData); if (state == ItemLoadingState::LoadingNeeded) { // Load the requested current frame DEBUG_DIFF("playlistItemDifference::loadFrame loading difference for frame %d", frameIdx); - isDifferenceLoading = true; + this->isDifferenceLoading = true; // Since every playlist item can have it's own relative indexing, we need two frame indices - difference.loadFrameDifference(frameIdx); - isDifferenceLoading = false; + this->difference.loadFrameDifference(frameIdx); + this->isDifferenceLoading = false; if (emitSignals) emit SignalItemChanged(true, RECACHE_NONE); } @@ -248,16 +244,19 @@ void playlistItemDifference::loadFrame(int frameIdx, DEBUG_DIFF("playlistItemDifference::loadFrame loading difference into double buffer %d %s", nextFrameIdx, playing ? "(playing)" : ""); - isDifferenceLoadingToDoubleBuffer = true; - difference.loadFrameDifference(frameIdx, true); - isDifferenceLoadingToDoubleBuffer = false; + this->isDifferenceLoadingToDoubleBuffer = true; + this->difference.loadFrameDifference(frameIdx, true); + this->isDifferenceLoadingToDoubleBuffer = false; if (emitSignals) emit signalItemDoubleBufferLoaded(); } } } -bool playlistItemDifference::isLoading() const { return this->isDifferenceLoading; } +bool playlistItemDifference::isLoading() const +{ + return this->isDifferenceLoading; +} bool playlistItemDifference::isLoadingDoubleBuffer() const { @@ -268,6 +267,6 @@ void playlistItemDifference::childChanged(bool redraw, recacheIndicator recache) { // One of the child items changed and needs to redraw. This means that the difference is out of // date and has to be recalculated. - difference.invalidateAllBuffers(); + this->difference.invalidateAllBuffers(); playlistItemContainer::childChanged(redraw, recache); } \ No newline at end of file diff --git a/YUViewLib/src/playlistitem/playlistItemImageFile.cpp b/YUViewLib/src/playlistitem/playlistItemImageFile.cpp index 40195fa58..6eb88a7be 100644 --- a/YUViewLib/src/playlistitem/playlistItemImageFile.cpp +++ b/YUViewLib/src/playlistitem/playlistItemImageFile.cpp @@ -32,14 +32,15 @@ #include "playlistItemImageFile.h" +#include +#include +#include