Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/475 difference values not shown #477

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions YUViewLib/src/common/Error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* This file is part of YUView - The YUV player with advanced analytics toolset
* <https://github.com/IENT/YUView>
* 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 <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <stdexcept>

class NotImplemented : public std::logic_error
{
public:
NotImplemented() : std::logic_error("Function not yet implemented"){};
};
15 changes: 15 additions & 0 deletions YUViewLib/src/common/Typedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,21 @@ template <typename T> 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{};
Expand Down
2 changes: 2 additions & 0 deletions YUViewLib/src/decoder/decoderBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@

#include "decoderBase.h"

#include <QCoreApplication>
#include <QDir>
#include <QSettings>


namespace decoder
{

Expand Down
1 change: 1 addition & 0 deletions YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/

#include "FFmpegVersionHandler.h"
#include <QCoreApplication>
#include <QDateTime>
#include <QDir>

Expand Down
10 changes: 5 additions & 5 deletions YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 "
Expand Down
2 changes: 0 additions & 2 deletions YUViewLib/src/playlistitem/playlistItemCompressedVideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
95 changes: 47 additions & 48 deletions YUViewLib/src/playlistitem/playlistItemDifference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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);
}
}

Expand All @@ -138,26 +136,24 @@ 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);
}

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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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
{
Expand All @@ -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);
}
Loading