reimplement footage viewer in new structure

This commit is contained in:
itsmattkc
2021-02-24 22:16:08 +11:00
parent 72dd80c90c
commit 2c5aee4d2e
5 changed files with 46 additions and 14 deletions
+8 -1
View File
@@ -572,18 +572,25 @@ NodeValueTable Footage::Value(const QString &output, NodeValueDatabase &value) c
if (QFileInfo(file).exists()) {
FootageJob job(decoder_, filename(), ref.type());
rational length;
if (ref.type() == Stream::kVideo) {
VideoParams vp = GetVideoParams(ref.index());
// Ensure the colorspace is valid and not empty
vp.set_colorspace(GetColorspaceToUse(vp));
length = Timecode::timestamp_to_time(vp.duration(), vp.time_base());
job.set_video_params(vp);
} else {
job.set_audio_params(GetAudioParams(ref.index()));
AudioParams ap = GetAudioParams(ref.index());
job.set_audio_params(ap);
job.set_cache_path(project()->cache_path());
length = Timecode::timestamp_to_time(ap.duration(), ap.time_base());
}
table.Push(NodeValue::kRational, QVariant::fromValue(length), this, false, QStringLiteral("length"));
table.Push(NodeValue::kFootageJob, QVariant::fromValue(job), this);
}
+5
View File
@@ -46,6 +46,11 @@ Project::Project() :
settings_->setParent(this);
AddDefaultNode(settings_);
// Viewer node for connecting with the footage viewer
footage_viewer_ = new ViewerOutput();
footage_viewer_->setParent(this);
AddDefaultNode(footage_viewer_);
// Folder root for project
root_ = new Folder();
root_->setParent(this);
+8
View File
@@ -25,6 +25,7 @@
#include <memory>
#include "node/project/projectsettings/projectsettings.h"
#include "node/output/viewer/viewer.h"
#include "render/colormanager.h"
#include "project/item/folder/folder.h"
#include "window/mainwindow/mainwindowlayoutinfo.h"
@@ -72,6 +73,11 @@ public:
QString cache_path() const;
ViewerOutput* footage_viewer()
{
return footage_viewer_;
}
signals:
void NameChanged();
@@ -86,6 +92,8 @@ private:
ProjectSettingsNode* settings_;
ViewerOutput* footage_viewer_;
bool is_modified_;
bool autorecovery_saved_;
+24 -10
View File
@@ -46,30 +46,44 @@ Footage *FootageViewerWidget::GetFootage() const
void FootageViewerWidget::SetFootage(Footage *footage)
{
if (footage && !footage->project()) {
qCritical() << "Failed to set footage in footage viewer - footage had no project";
return;
}
if (footage_) {
cached_timestamps_.insert(footage_, GetTimestamp());
ViewerOutput* old_viewer = footage_->project()->footage_viewer();
ConnectViewerNode(nullptr);
Node::DisconnectEdge(sequence_.GetConnectedOutput(ViewerOutput::kTextureInput), NodeInput(&sequence_, ViewerOutput::kTextureInput));
Node::DisconnectEdge(sequence_.GetConnectedOutput(ViewerOutput::kSamplesInput), NodeInput(&sequence_, ViewerOutput::kSamplesInput));
if (old_viewer->IsInputConnected(ViewerOutput::kTextureInput)) {
Node::DisconnectEdge(old_viewer->GetConnectedOutput(ViewerOutput::kTextureInput), NodeInput(old_viewer, ViewerOutput::kTextureInput));
}
if (old_viewer->IsInputConnected(ViewerOutput::kSamplesInput)) {
Node::DisconnectEdge(old_viewer->GetConnectedOutput(ViewerOutput::kSamplesInput), NodeInput(old_viewer, ViewerOutput::kSamplesInput));
}
}
footage_ = footage;
if (footage_) {
ViewerOutput* new_viewer = footage_->project()->footage_viewer();
// Update sequence media name
sequence_.SetLabel(footage_->GetLabel());
new_viewer->SetLabel(footage_->GetLabel());
// Reset parameters and then attempt to set from footage
sequence_.set_default_parameters();
sequence_.set_parameters_from_footage({footage_});
new_viewer->set_default_parameters();
new_viewer->set_parameters_from_footage({footage_});
// Try to connect video stream
TryConnectingType(footage, Stream::kVideo);
TryConnectingType(footage, Stream::kAudio);
TryConnectingType(new_viewer, footage, Stream::kVideo);
TryConnectingType(new_viewer, footage, Stream::kAudio);
ConnectViewerNode(&sequence_, footage_->project()->color_manager());
ConnectViewerNode(new_viewer);
SetTimestamp(cached_timestamps_.value(footage_, 0));
} else {
@@ -124,7 +138,7 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enabl
}
}
void FootageViewerWidget::TryConnectingType(Footage *footage, Stream::Type type)
void FootageViewerWidget::TryConnectingType(ViewerOutput* viewer, Footage *footage, Stream::Type type)
{
int index = -1;
@@ -165,7 +179,7 @@ void FootageViewerWidget::TryConnectingType(Footage *footage, Stream::Type type)
input_param = ViewerOutput::kSamplesInput;
}
Node::ConnectEdge(NodeOutput(footage, s), NodeInput(&sequence_, input_param));
Node::ConnectEdge(NodeOutput(footage, s), NodeInput(viewer, input_param));
}
}
+1 -3
View File
@@ -43,12 +43,10 @@ protected:
private:
void StartFootageDragInternal(bool enable_video, bool enable_audio);
void TryConnectingType(Footage* footage, Stream::Type type);
void TryConnectingType(ViewerOutput *viewer, Footage* footage, Stream::Type type);
Footage* footage_;
Sequence sequence_;
QHash<Footage*, int64_t> cached_timestamps_;
private slots: