implement entire project in nodes

Project items are now represented directly in nodes opening up more versatility and possibilities. This is the first iteration of this and will be buggy. Need to test thoroughly.
This commit is contained in:
itsmattkc
2021-02-15 21:31:57 +11:00
parent 155470bec1
commit d7c5ac4b44
174 changed files with 3515 additions and 4658 deletions
+4 -3
View File
@@ -24,11 +24,12 @@
namespace olive {
ConformTask::ConformTask(AudioStream *stream, const AudioParams& params) :
stream_(stream),
ConformTask::ConformTask(Footage* footage, int index, const AudioParams& params) :
footage_(footage),
index_(index),
params_(params)
{
SetTitle(tr("Conforming Audio %1:%2").arg(stream_->footage()->filename(), QString::number(stream_->index())));
SetTitle(tr("Conforming Audio %1:%2").arg(footage_->filename(), QString::number(index_)));
}
bool ConformTask::Run()
+5 -3
View File
@@ -21,7 +21,7 @@
#ifndef CONFORMTASK_H
#define CONFORMTASK_H
#include "project/item/footage/audiostream.h"
#include "project/item/footage/footage.h"
#include "render/audioparams.h"
#include "task/task.h"
@@ -31,13 +31,15 @@ class ConformTask : public Task
{
Q_OBJECT
public:
ConformTask(AudioStream* stream, const AudioParams& params);
ConformTask(Footage* stream, int index, const AudioParams& params);
protected:
virtual bool Run() override;
private:
AudioStream* stream_;
Footage* footage_;
int index_;
AudioParams params_;
+1 -1
View File
@@ -25,7 +25,7 @@
namespace olive {
ExportTask::ExportTask(ViewerOutput* viewer_node,
ExportTask::ExportTask(Sequence *viewer_node,
ColorManager* color_manager,
const ExportParams& params) :
RenderTask(viewer_node, params.video_params(), params.audio_params()),
+1 -1
View File
@@ -33,7 +33,7 @@ class ExportTask : public RenderTask
{
Q_OBJECT
public:
ExportTask(ViewerOutput *viewer_node, ColorManager *color_manager, const ExportParams &params);
ExportTask(Sequence *viewer_node, ColorManager *color_manager, const ExportParams &params);
protected:
virtual bool Run() override;
+14 -10
View File
@@ -24,27 +24,31 @@
namespace olive {
PreCacheTask::PreCacheTask(VideoStream *footage, Sequence* sequence) :
RenderTask(new ViewerOutput(), sequence->video_params(), sequence->audio_params()),
footage_(footage)
PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence* sequence) :
RenderTask(new ViewerOutput(), sequence->video_params(), sequence->audio_params())
{
viewer()->set_video_params(sequence->video_params());
viewer()->set_audio_params(sequence->audio_params());
video_node_ = new MediaInput();
video_node_->SetStream(footage);
// FIXME: I've been lazy and haven't included support for anything connected to a footage input.
// At the moment, footage nodes have no connectable inputs so it's not a problem, but if
// they ever do, that needs to be addressed immediately.
Q_ASSERT(footage->inputs().isEmpty());
Node::ConnectEdge(video_node_, NodeInput(viewer(), ViewerOutput::kTextureInput));
// Copy footage node so it can precache without any modifications from the user screwing it up
footage_ = static_cast<Footage*>(footage->copy());
index_ = index;
Node::CopyInputs(footage, footage_, false);
SetTitle(tr("Pre-caching %1:%2").arg(footage->footage()->filename(),
QString::number(footage->index())));
Node::ConnectEdge(footage_, NodeInput(viewer(), ViewerOutput::kTextureInput));
SetTitle(tr("Pre-caching %1:%2").arg(footage_->filename()));
}
PreCacheTask::~PreCacheTask()
{
// We created this viewer node ourselves, so now we should delete it
delete viewer();
delete video_node_;
}
bool PreCacheTask::Run()
@@ -63,7 +67,7 @@ bool PreCacheTask::Run()
}
*/
Render(footage_->footage()->project()->color_manager(),
Render(footage_->project()->color_manager(),
video_range,
TimeRangeList(),
RenderMode::kOnline,
+3 -4
View File
@@ -21,7 +21,6 @@
#ifndef PRECACHETASK_H
#define PRECACHETASK_H
#include "node/input/media/media.h"
#include "project/item/footage/footage.h"
#include "project/item/sequence/sequence.h"
#include "task/render/render.h"
@@ -32,7 +31,7 @@ class PreCacheTask : public RenderTask
{
Q_OBJECT
public:
PreCacheTask(VideoStream* footage, Sequence* sequence);
PreCacheTask(Footage* footage, int index, Sequence* sequence);
virtual ~PreCacheTask() override;
@@ -44,9 +43,9 @@ protected:
virtual void AudioDownloaded(const TimeRange& range, SampleBufferPtr samples, qint64 job_time) override;
private:
VideoStream* footage_;
Footage* footage_;
MediaInput* video_node_;
int index_;
};
+36 -30
View File
@@ -26,6 +26,7 @@
#include "config/config.h"
#include "core.h"
#include "project/item/footage/footage.h"
#include "widget/nodeview/nodeviewundo.h"
namespace olive {
@@ -97,12 +98,11 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte
f->moveToThread(folder->thread());
f->set_name(file_info.fileName());
f->SetLabel(file_info.fileName());
// Create undoable command that adds the items to the model
parent_command->add_child(new ProjectViewModel::AddItemCommand(model_,
folder,
f));
parent_command->add_child(new NodeAddCommand(folder->parent(), f));
parent_command->add_child(new NodeEdgeAddCommand(folder, NodeInput(f, Item::kParentInput)));
// Recursively follow this path
Import(f, entry_list, counter, parent_command);
@@ -110,10 +110,11 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte
} else {
Footage* footage = Decoder::Probe(model_->project(), file_info.absoluteFilePath(),
&IsCancelled());
Footage* footage = new Footage(file_info.absoluteFilePath());
if (footage) {
footage->SetLabel(file_info.fileName());
if (footage->IsValid()) {
// Move footage to main thread
footage->moveToThread(folder->thread());
@@ -121,12 +122,13 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte
ValidateImageSequence(footage, import, i);
// Create undoable command that adds the items to the model
parent_command->add_child(new ProjectViewModel::AddItemCommand(model_,
folder,
footage));
parent_command->add_child(new NodeAddCommand(folder->parent(), footage));
parent_command->add_child(new NodeEdgeAddCommand(folder, NodeInput(footage, Item::kParentInput)));
} else {
// Add to list so we can tell the user about it later
invalid_files_.append(file_info.absoluteFilePath());
delete footage;
}
counter++;
@@ -140,13 +142,13 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte
void ProjectImportTask::ValidateImageSequence(Footage *footage, QFileInfoList& info_list, int index)
{
// Heuristically determine whether this file is part of an image sequence or not
VideoStream* video_stream = static_cast<VideoStream*>(footage->streams().first());
//
// By this point we've established that video contains a single still image stream. Now we'll
// see if it ends with numbers.
if (Decoder::GetImageSequenceDigitCount(footage->filename()) > 0
&& !image_sequence_ignore_files_.contains(footage->filename())) {
QSize dim(video_stream->width(), video_stream->height());
Stream video_stream = footage->GetStreamAt(Stream::kVideo, 0);
QSize dim(video_stream.width(), video_stream.height());
int64_t ind = Decoder::GetImageSequenceIndex(footage->filename());
@@ -156,12 +158,13 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage, QFileInfoList& i
// See if the same decoder can retrieve surrounding files
DecoderPtr decoder = Decoder::CreateFromID(footage->decoder());
Footage* previous_file = decoder->Probe(previous_img_fn, nullptr);
Footage* next_file = decoder->Probe(next_img_fn, nullptr);
Footage* previous_file = new Footage(previous_img_fn);
Footage* next_file = new Footage(next_img_fn);
// Finally see if these files have the same dimensions
if ((previous_file && CompareStillImageSize(previous_file, dim))
|| (next_file && CompareStillImageSize(next_file, dim))) {
if ((previous_file->IsValid() && CompareStillImageSize(previous_file, dim))
|| (next_file->IsValid() && CompareStillImageSize(next_file, dim))) {
// By this point, we've established this file is a still image with a number at the end of
// the filename surrounded by adjacent numbers. It could be a still image! But let's ask the
// user just in case...
@@ -202,34 +205,37 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage, QFileInfoList& i
if (is_sequence) {
// User has confirmed it is a still image, let's set it accordingly.
video_stream->set_video_type(VideoStream::kVideoTypeImageSequence);
video_stream.set_video_type(Stream::kVideoTypeImageSequence);
rational default_timebase = Config::Current()["DefaultSequenceFrameRate"].value<rational>();
video_stream->set_timebase(default_timebase);
video_stream->set_frame_rate(default_timebase.flipped());
rational default_timebase = Config::Current()[QStringLiteral("DefaultSequenceFrameRate")].value<rational>();
video_stream.set_timebase(default_timebase);
video_stream.set_frame_rate(default_timebase.flipped());
video_stream->set_start_time(start_index);
video_stream->set_duration(end_index - start_index + 1);
video_stream.set_start_time(start_index);
video_stream.set_duration(end_index - start_index + 1);
footage->SetStreamAt(Stream::kVideo, 0, video_stream);
}
}
delete previous_file;
delete next_file;
}
}
bool ProjectImportTask::ItemIsStillImageFootageOnly(Footage* footage)
{
if (footage->stream_count() != 1) {
if (footage->GetStreamCount() != 1) {
// Footage with more than one stream (usually video+audio) most likely isn't an image sequence
return false;
}
if (footage->streams().first()->type() != Stream::kVideo) {
if (footage->GetStreamAt(0).type() != Stream::kVideo) {
// Footage with no video stream definitely isn't an image sequence
return false;
}
VideoStream* video_stream = static_cast<VideoStream*>(footage->streams().first());
if (video_stream->video_type() != VideoStream::kVideoTypeStill) {
if (footage->GetStreamAt(0).video_type() != Stream::kVideoTypeStill) {
// If video type is not a still, this definitely isn't a video stream
return false;
}
@@ -243,9 +249,9 @@ bool ProjectImportTask::CompareStillImageSize(Footage* footage, const QSize &sz)
return false;
}
VideoStream* video_stream = static_cast<VideoStream*>(footage->streams().first());
Stream stream = footage->GetStreamAt(Stream::kVideo, 0);
return video_stream->width() == sz.width() && video_stream->height() == sz.height();
return stream.width() == sz.width() && stream.height() == sz.height();
}
int64_t ProjectImportTask::GetImageSequenceLimit(const QString& start_fn, int64_t start, bool up)
+17 -14
View File
@@ -37,27 +37,30 @@ ProjectLoadTask::ProjectLoadTask(const QString &filename) :
bool ProjectLoadTask::Run()
{
QFile project_file(GetFilename());
uint project_version = Core::kProjectVersion;
if (project_file.open(QFile::ReadOnly | QFile::Text)) {
QXmlStreamReader reader(&project_file);
bool ok;
uint project_version = reader.documentVersion().toUInt(&ok);
if (!ok) {
SetError(tr("Failed to determine project's version identifier."));
return false;
} else if (project_version > Core::kProjectVersion) {
// Project is newer than we support
SetError(tr("This project is newer than this version of Olive and cannot be opened."));
return false;
} else if (project_version < 210122) { // Change this if we drop support for a project version
// Project is older than we support
SetError(tr("This project is from a version of Olive that is no longer supported in this version."));
return false;
}
while (XMLReadNextStartElement(&reader)) {
if (reader.name() == QStringLiteral("olive")) {
while(XMLReadNextStartElement(&reader)) {
if (reader.name() == QStringLiteral("version")) {
project_version = reader.readElementText().toUInt();
if (project_version > Core::kProjectVersion) {
// Project is newer than we support
SetError(tr("This project is newer than this version of Olive and cannot be opened."));
return false;
} else if (project_version < 210122) { // Change this if we drop support for a project version
// Project is older than we support
SetError(tr("This project is from a version of Olive that is no longer supported in this version."));
return false;
}
} else if (reader.name() == QStringLiteral("url")) {
if (reader.name() == QStringLiteral("url")) {
project_saved_url_ = reader.readElementText();
} else if (reader.name() == QStringLiteral("project")) {
project_ = new Project();
+3 -5
View File
@@ -46,13 +46,11 @@ bool ProjectSaveTask::Run()
QXmlStreamWriter writer(&project_file);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement("olive");
// Version is stored in YYMMDD from whenever the project format was last changed
// Allows easy integer math for checking project versions.
writer.writeTextElement("version", QString::number(Core::kProjectVersion));
writer.writeStartDocument(QString::number(Core::kProjectVersion));
writer.writeStartElement("olive");
writer.writeTextElement("url", project_->filename());
+1 -1
View File
@@ -25,7 +25,7 @@
namespace olive {
RenderTask::RenderTask(ViewerOutput* viewer, const VideoParams &vparams, const AudioParams &aparams) :
RenderTask::RenderTask(Sequence* viewer, const VideoParams &vparams, const AudioParams &aparams) :
viewer_(viewer),
video_params_(vparams),
audio_params_(aparams),
+3 -3
View File
@@ -35,7 +35,7 @@ class RenderTask : public Task
{
Q_OBJECT
public:
RenderTask(ViewerOutput* viewer, const VideoParams &vparams, const AudioParams &aparams);
RenderTask(Sequence* viewer, const VideoParams &vparams, const AudioParams &aparams);
virtual ~RenderTask() override;
@@ -53,7 +53,7 @@ protected:
virtual void AudioDownloaded(const TimeRange& range, SampleBufferPtr samples, qint64 job_time) = 0;
ViewerOutput* viewer() const
Sequence* viewer() const
{
return viewer_;
}
@@ -85,7 +85,7 @@ private:
void IncrementRunningTickets();
ViewerOutput* viewer_;
Sequence* viewer_;
VideoParams video_params_;