Merge branch 'master' into rational_slider

This commit is contained in:
ThomasWilshaw
2021-04-14 12:08:58 +01:00
committed by GitHub
61 changed files with 853 additions and 5364 deletions
@@ -21,7 +21,6 @@
#include "colormanager.h"
#include <QDir>
#include <QFloat16>
#include <QStandardPaths>
#include "common/define.h"
+2
View File
@@ -61,6 +61,7 @@ void NodeGraph::childEvent(QChildEvent *event)
connect(node, &Node::ValueChanged, this, &NodeGraph::ValueChanged);
emit NodeAdded(node);
emit node->AddedToGraph(this);
} else if (event->type() == QEvent::ChildRemoved) {
@@ -72,6 +73,7 @@ void NodeGraph::childEvent(QChildEvent *event)
disconnect(node, &Node::ValueChanged, this, &NodeGraph::ValueChanged);
emit NodeRemoved(node);
emit node->RemovedFromGraph(this);
}
}
+5 -4
View File
@@ -1245,7 +1245,7 @@ bool Node::AreLinked(Node *a, Node *b)
return a->links_.contains(b);
}
void Node::AddInput(const QString &id, NodeValue::Type type, const QVariant &default_value, Node::InputFlags flags)
void Node::InsertInput(const QString &id, NodeValue::Type type, const QVariant &default_value, Node::InputFlags flags, int index)
{
if (id.isEmpty()) {
qWarning() << "Rejected adding input with an empty ID on node" << this->id();
@@ -1264,8 +1264,8 @@ void Node::AddInput(const QString &id, NodeValue::Type type, const QVariant &def
i.flags = flags;
i.array_size = 0;
input_ids_.append(id);
input_data_.append(i);
input_ids_.insert(index, id);
input_data_.insert(index, i);
if (!standard_immediates_.value(id, nullptr)) {
standard_immediates_.insert(id, CreateImmediate(id));
@@ -2294,7 +2294,7 @@ void NodeSetPositionAndShiftSurroundingsCommand::redo()
// Start moving other nodes
foreach (Node* surrounding, node_->parent()->nodes()) {
if (bounding_rect.contains(surrounding->GetPosition()) && surrounding != node_) {
if (bounding_rect.contains(surrounding->GetPosition()) && surrounding != node_ && surrounding != ignore_node_) {
QPointF new_pos = surrounding->GetPosition();
qreal move_rate = 0.50;
@@ -2306,6 +2306,7 @@ void NodeSetPositionAndShiftSurroundingsCommand::redo()
new_pos.setY(new_pos.y() + move_rate);
auto sur_command = new NodeSetPositionAndShiftSurroundingsCommand(surrounding, new_pos, true);
sur_command->SetIgnoreNode(node_);
sur_command->redo();
commands_.append(sur_command);
}
+30 -2
View File
@@ -799,7 +799,23 @@ protected:
};
void AddInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags = InputFlags(kInputFlagNormal));
void InsertInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags, int index);
void PrependInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags = InputFlags(kInputFlagNormal))
{
InsertInput(id, type, default_value, flags, 0);
}
void PrependInput(const QString& id, NodeValue::Type type, InputFlags flags = InputFlags(kInputFlagNormal))
{
PrependInput(id, type, QVariant(), flags);
}
void AddInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags = InputFlags(kInputFlagNormal))
{
InsertInput(id, type, default_value, flags, input_ids_.size());
}
void AddInput(const QString& id, NodeValue::Type type, InputFlags flags = InputFlags(kInputFlagNormal))
{
AddInput(id, type, QVariant(), flags);
@@ -926,6 +942,10 @@ signals:
void InputDataTypeChanged(const QString& id, NodeValue::Type type);
void AddedToGraph(NodeGraph* graph);
void RemovedFromGraph(NodeGraph* graph);
private:
class ArrayInsertCommand : public UndoCommand
{
@@ -1331,7 +1351,8 @@ public:
NodeSetPositionAndShiftSurroundingsCommand(Node* node, const QPointF& pos, bool move_dependencies_relatively) :
node_(node),
position_(pos),
move_dependencies_(move_dependencies_relatively)
move_dependencies_(move_dependencies_relatively),
ignore_node_(nullptr)
{}
virtual ~NodeSetPositionAndShiftSurroundingsCommand() override
@@ -1353,6 +1374,11 @@ public:
}
}
void SetIgnoreNode(Node* n)
{
ignore_node_ = n;
}
private:
Node* node_;
@@ -1362,6 +1388,8 @@ private:
QVector<UndoCommand*> commands_;
Node* ignore_node_;
};
class NodeSetPositionAsChildCommand : public UndoCommand
+9 -7
View File
@@ -160,13 +160,15 @@ public:
static Type TypeFromString(const QString& s)
{
if (s.at(1) == ':') {
if (s.at(0) == 'v') {
// Video stream
return Track::kVideo;
} else if (s.at(0) == 'a') {
// Audio stream
return Track::kAudio;
if (s.size() >= 3) {
if (s.at(1) == ':') {
if (s.at(0) == 'v') {
// Video stream
return Track::kVideo;
} else if (s.at(0) == 'a') {
// Audio stream
return Track::kAudio;
}
}
}
+48 -57
View File
@@ -39,7 +39,8 @@ const uint64_t ViewerOutput::kVideoParamEditMask = VideoParamEdit::kWidthHeight
ViewerOutput::ViewerOutput(bool create_default_streams) :
video_frame_cache_(this),
audio_playback_cache_(this),
cache_enabled_(true)
video_cache_enabled_(true),
audio_cache_enabled_(true)
{
AddInput(kVideoParamsInput, NodeValue::kVideoParams, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | kInputFlagArray));
SetInputProperty(kVideoParamsInput, QStringLiteral("mask"), QVariant::fromValue(kVideoParamEditMask));
@@ -54,6 +55,7 @@ ViewerOutput::ViewerOutput(bool create_default_streams) :
if (create_default_streams) {
AddStream(Track::kVideo, QVariant());
AddStream(Track::kAudio, QVariant());
set_default_parameters();
}
}
@@ -196,7 +198,7 @@ void ViewerOutput::set_default_parameters()
void ViewerOutput::ShiftVideoCache(const rational &from, const rational &to)
{
if (cache_enabled_) {
if (video_cache_enabled_) {
video_frame_cache_.Shift(from, to);
}
@@ -205,7 +207,7 @@ void ViewerOutput::ShiftVideoCache(const rational &from, const rational &to)
void ViewerOutput::ShiftAudioCache(const rational &from, const rational &to)
{
if (cache_enabled_) {
if (audio_cache_enabled_) {
audio_playback_cache_.Shift(from, to);
}
@@ -222,18 +224,16 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from,
{
Q_UNUSED(element)
if (cache_enabled_) {
if (from == kTextureInput || from == kSamplesInput
|| from == kVideoParamsInput || from == kAudioParamsInput) {
TimeRange invalidated_range(qMax(rational(), range.in()),
qMin(GetLength(), range.out()));
if ((video_cache_enabled_ && (from == kTextureInput || from == kVideoParamsInput))
|| (audio_cache_enabled_ && (from == kSamplesInput || from == kAudioParamsInput))) {
TimeRange invalidated_range(qMax(rational(), range.in()),
qMin(GetLength(), range.out()));
if (invalidated_range.in() != invalidated_range.out()) {
if (from == kTextureInput || from == kVideoParamsInput) {
video_frame_cache_.Invalidate(invalidated_range, job_time);
} else {
audio_playback_cache_.Invalidate(invalidated_range, job_time);
}
if (invalidated_range.in() != invalidated_range.out()) {
if (from == kTextureInput || from == kVideoParamsInput) {
video_frame_cache_.Invalidate(invalidated_range, job_time);
} else {
audio_playback_cache_.Invalidate(invalidated_range, job_time);
}
}
}
@@ -257,11 +257,6 @@ QVector<QString> ViewerOutput::inputs_for_output(const QString &output) const
return inputs;
}
const rational& ViewerOutput::GetLength() const
{
return last_length_;
}
QVector<Track::Reference> ViewerOutput::GetEnabledStreamsAsReferences() const
{
QVector<Track::Reference> refs;
@@ -302,41 +297,21 @@ void ViewerOutput::Retranslate()
void ViewerOutput::VerifyLength()
{
NodeTraverser traverser;
rational subtitle_length;
rational video_length, audio_length, subtitle_length;
{
video_length = GetCustomLength(Track::kVideo);
if (video_length.isNull() && IsInputConnected(kTextureInput)) {
NodeValueTable t = traverser.GenerateTable(GetConnectedOutput(kTextureInput), TimeRange(0, 0));
video_length = t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
}
if (cache_enabled_) {
video_frame_cache_.SetLength(video_length);
}
video_length_ = VerifyLengthInternal(Track::kVideo);
if (video_cache_enabled_) {
video_frame_cache_.SetLength(video_length_);
}
{
audio_length = GetCustomLength(Track::kAudio);
if (audio_length.isNull() && IsInputConnected(kSamplesInput)) {
NodeValueTable t = traverser.GenerateTable(GetConnectedOutput(kSamplesInput), TimeRange(0, 0));
audio_length = t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
}
if (cache_enabled_) {
audio_playback_cache_.SetLength(audio_length);
}
audio_length_ = VerifyLengthInternal(Track::kAudio);
if (audio_cache_enabled_) {
audio_playback_cache_.SetLength(audio_length_);
}
{
subtitle_length = GetCustomLength(Track::kSubtitle);
}
subtitle_length = VerifyLengthInternal(Track::kSubtitle);
rational real_length = qMax(subtitle_length, qMax(video_length, audio_length));
rational real_length = qMax(subtitle_length, qMax(video_length_, audio_length_));
if (real_length != last_length_) {
last_length_ = real_length;
@@ -362,9 +337,30 @@ void ViewerOutput::InputDisconnectedEvent(const QString &input, int element, con
super::InputDisconnectedEvent(input, element, output);
}
rational ViewerOutput::GetCustomLength(Track::Type type) const
rational ViewerOutput::VerifyLengthInternal(Track::Type type) const
{
Q_UNUSED(type)
NodeTraverser traverser;
switch (type) {
case Track::kVideo:
if (IsInputConnected(kTextureInput)) {
NodeValueTable t = traverser.GenerateTable(GetConnectedOutput(kTextureInput), TimeRange(0, 0));
qDebug() << "Got video length:" << t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
return t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
}
break;
case Track::kAudio:
if (IsInputConnected(kSamplesInput)) {
NodeValueTable t = traverser.GenerateTable(GetConnectedOutput(kSamplesInput), TimeRange(0, 0));
return t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
}
break;
case Track::kNone:
case Track::kSubtitle:
case Track::kCount:
break;
}
return rational();
}
@@ -403,7 +399,7 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
}
if (frame_rate_changed) {
if (cache_enabled_) {
if (video_cache_enabled_) {
video_frame_cache_.SetTimebase(new_video_params.frame_rate_as_time_base());
}
emit FrameRateChanged(new_video_params.frame_rate());
@@ -425,7 +421,7 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
emit AudioParamsChanged();
if (cache_enabled_) {
if (audio_cache_enabled_) {
audio_playback_cache_.SetParameters(GetAudioParams());
}
@@ -529,11 +525,6 @@ int ViewerOutput::AddStream(Track::Type type, const QVariant& value)
return index;
}
void ViewerOutput::SetViewerCacheEnabled(bool e)
{
cache_enabled_ = e;
}
void ViewerOutput::InputResized(const QString &input, int old_size, int new_size)
{
if (input == kVideoParamsInput || input == kAudioParamsInput) {
+24 -6
View File
@@ -72,12 +72,24 @@ public:
VideoParams GetVideoParams(int index = 0) const
{
return GetStandardValue(kVideoParamsInput, index).value<VideoParams>();
// This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway),
// but it does suppress a warning message that we don't need
if (index < InputArraySize(kVideoParamsInput)) {
return GetStandardValue(kVideoParamsInput, index).value<VideoParams>();
} else {
return VideoParams();
}
}
AudioParams GetAudioParams(int index = 0) const
{
return GetStandardValue(kAudioParamsInput, index).value<AudioParams>();
// This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway),
// but it does suppress a warning message that we don't need
if (index < InputArraySize(kAudioParamsInput)) {
return GetStandardValue(kAudioParamsInput, index).value<AudioParams>();
} else {
return AudioParams();
}
}
void SetVideoParams(const VideoParams &video, int index = 0)
@@ -111,7 +123,9 @@ public:
VideoParams GetFirstEnabledVideoStream() const;
AudioParams GetFirstEnabledAudioStream() const;
const rational &GetLength() const;
const rational &GetLength() const { return last_length_; }
const rational &GetVideoLength() const { return video_length_; }
const rational &GetAudioLength() const { return audio_length_; }
FrameHashCache* video_frame_cache()
{
@@ -174,7 +188,7 @@ protected:
virtual void InputDisconnectedEvent(const QString &input, int element, const NodeOutput &output) override;
virtual rational GetCustomLength(Track::Type type) const;
virtual rational VerifyLengthInternal(Track::Type type) const;
virtual void ShiftVideoEvent(const rational &from, const rational &to);
@@ -188,10 +202,13 @@ protected:
int AddStream(Track::Type type, const QVariant &value);
void SetViewerCacheEnabled(bool e);
void SetViewerVideoCacheEnabled(bool e) { video_cache_enabled_ = e; }
void SetViewerAudioCacheEnabled(bool e) { audio_cache_enabled_ = e; }
private:
rational last_length_;
rational video_length_;
rational audio_length_;
FrameHashCache video_frame_cache_;
@@ -205,7 +222,8 @@ private:
TimelinePoints timeline_points_;
bool cache_enabled_;
bool video_cache_enabled_;
bool audio_cache_enabled_;
private slots:
void InputResized(const QString& input, int old_size, int new_size);
+9 -10
View File
@@ -43,14 +43,14 @@ Footage::Footage(const QString &filename) :
ViewerOutput(false),
cancelled_(nullptr)
{
AddInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
SetCacheTextures(true);
SetViewerVideoCacheEnabled(false);
PrependInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
Clear();
set_filename(filename);
SetCacheTextures(true);
SetViewerCacheEnabled(false);
}
void Footage::Retranslate()
@@ -180,7 +180,7 @@ void Footage::InputValueChangedEvent(const QString &input, int element)
}
}
rational Footage::GetCustomLength(Track::Type type) const
rational Footage::VerifyLengthInternal(Track::Type type) const
{
if (type == Track::kVideo) {
VideoParams first_stream = GetFirstEnabledVideoStream();
@@ -196,7 +196,7 @@ rational Footage::GetCustomLength(Track::Type type) const
}
}
return super::GetCustomLength(type);
return super::VerifyLengthInternal(type);
}
QString Footage::GetColorspaceToUse(const VideoParams &params) const
@@ -295,10 +295,9 @@ QString Footage::DescribeVideoStream(const VideoParams &params)
QString Footage::DescribeAudioStream(const AudioParams &params)
{
return tr("%1: Audio - %2 Channel(s), %3Hz")
.arg(QString::number(params.stream_index()),
QString::number(params.channel_count()),
QString::number(params.sample_rate()));
return tr("%1: Audio - %n Channel(s), %2Hz", nullptr, params.channel_count())
.arg(QString::number(params.stream_index()),
QString::number(params.sample_rate()));
}
void Footage::Hash(const QString& output, QCryptographicHash &hash, const rational &time) const
+2 -2
View File
@@ -58,7 +58,7 @@ public:
virtual QString Name() const override
{
return tr("Footage");
return tr("Media");
}
virtual QString id() const override
@@ -195,7 +195,7 @@ protected:
virtual void InputValueChangedEvent(const QString &input, int element) override;
virtual rational GetCustomLength(Track::Type type) const override;
virtual rational VerifyLengthInternal(Track::Type type) const override;
private:
QString GetColorspaceToUse(const VideoParams& params) const;
-6
View File
@@ -430,9 +430,6 @@ void ProjectViewModel::ConnectItem(Node *n)
connect(f, &Folder::BeginRemoveItem, this, &ProjectViewModel::FolderBeginRemoveItem);
connect(f, &Folder::EndRemoveItem, this, &ProjectViewModel::FolderEndRemoveItem);
connect(f, &Folder::BeginInsertItem, this, &ProjectViewModel::ItemAdded);
connect(f, &Folder::BeginRemoveItem, this, &ProjectViewModel::ItemRemoved);
foreach (Node* c, f->children()) {
ConnectItem(c);
}
@@ -450,9 +447,6 @@ void ProjectViewModel::DisconnectItem(Node *n)
disconnect(f, &Folder::BeginRemoveItem, this, &ProjectViewModel::FolderBeginRemoveItem);
disconnect(f, &Folder::EndRemoveItem, this, &ProjectViewModel::FolderEndRemoveItem);
disconnect(f, &Folder::BeginInsertItem, this, &ProjectViewModel::ItemAdded);
disconnect(f, &Folder::BeginRemoveItem, this, &ProjectViewModel::ItemRemoved);
foreach (Node* c, f->children()) {
DisconnectItem(c);
}
-5
View File
@@ -104,11 +104,6 @@ public:
*/
QModelIndex CreateIndexFromItem(Node *item, int column = 0);
signals:
void ItemAdded(Node* node);
void ItemRemoved(Node* node);
private:
/**
* @brief Retrieve the index of `item` in its parent
+1 -1
View File
@@ -107,7 +107,7 @@ void Sequence::Retranslate()
}
}
rational Sequence::GetCustomLength(Track::Type type) const
rational Sequence::VerifyLengthInternal(Track::Type type) const
{
if (!track_lists_.isEmpty()) {
switch (type) {
+1 -1
View File
@@ -103,7 +103,7 @@ protected:
virtual void InputDisconnectedEvent(const QString &input, int element, const NodeOutput &output) override;
virtual rational GetCustomLength(Track::Type type) const override;
virtual rational VerifyLengthInternal(Track::Type type) const override;
signals:
void TrackAdded(Track* track);
+17 -5
View File
@@ -382,14 +382,26 @@ NodeValueTable NodeValueTable::Merge(QList<NodeValueTable> tables)
NodeValueTable merged_table;
// Slipstreams all tables together
foreach (const NodeValueTable& t, tables) {
if (row >= t.Count()) {
continue;
while (true) {
bool all_merged = true;
foreach (const NodeValueTable& t, tables) {
if (row < t.Count()) {
all_merged = false;
} else {
continue;
}
int row_index = t.Count() - 1 - row;
merged_table.Prepend(t.at(row_index));
}
int row_index = t.Count() - 1 - row;
row++;
merged_table.Prepend(t.at(row_index));
if (all_merged) {
break;
}
}
return merged_table;