fixed precache task

Fixes #1558
This commit is contained in:
itsmattkc
2021-04-11 18:57:21 +10:00
parent 6c30f8cf46
commit a87adbd801
5 changed files with 30 additions and 27 deletions
-10
View File
@@ -220,16 +220,6 @@ void Project::set_filename(const QString &s)
emit NameChanged(); emit NameChanged();
} }
ColorManager *Project::color_manager()
{
return color_manager_;
}
bool Project::is_modified() const
{
return is_modified_;
}
void Project::set_modified(bool e) void Project::set_modified(bool e)
{ {
is_modified_ = e; is_modified_ = e;
+3 -2
View File
@@ -62,9 +62,10 @@ public:
QString pretty_filename() const; QString pretty_filename() const;
void set_filename(const QString& s); void set_filename(const QString& s);
ColorManager* color_manager(); ColorManager* color_manager() { return color_manager_; }
ProjectSettingsNode* settings() { return settings_; }
bool is_modified() const; bool is_modified() const { return is_modified_; }
void set_modified(bool e); void set_modified(bool e);
bool has_autorecovery_been_saved() const; bool has_autorecovery_been_saved() const;
+14 -6
View File
@@ -27,23 +27,31 @@ namespace olive {
PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence* sequence) : PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence* sequence) :
RenderTask(new ViewerOutput(), sequence->GetVideoParams(), sequence->GetAudioParams()) RenderTask(new ViewerOutput(), sequence->GetVideoParams(), sequence->GetAudioParams())
{ {
// Create new project
project_ = new Project();
// Create viewer with same parameters as the sequence
viewer()->setParent(project_);
viewer()->SetVideoParams(sequence->GetVideoParams()); viewer()->SetVideoParams(sequence->GetVideoParams());
viewer()->SetAudioParams(sequence->GetAudioParams()); viewer()->SetAudioParams(sequence->GetAudioParams());
// Copy project config nodes
Node::CopyInputs(footage->project()->color_manager(), project_->color_manager(), false);
Node::CopyInputs(footage->project()->settings(), project_->settings(), false);
// Copy footage node so it can precache without any modifications from the user screwing it up // Copy footage node so it can precache without any modifications from the user screwing it up
footage_ = static_cast<Footage*>(footage->copy()); footage_ = static_cast<Footage*>(footage->copy());
index_ = index; footage_->setParent(project_);
Node::CopyInputs(footage, footage_, false); Node::CopyInputs(footage, footage_, false);
Node::ConnectEdge(NodeOutput(footage_, Track::Reference(Track::kVideo, index).ToString()), NodeInput(viewer(), ViewerOutput::kTextureInput));
Node::ConnectEdge(NodeOutput(footage_, Track::Reference(Track::kVideo, 0).ToString()), NodeInput(viewer(), ViewerOutput::kTextureInput)); SetTitle(tr("Pre-caching %1:%2").arg(footage_->filename(), index));
SetTitle(tr("Pre-caching %1:%2").arg(footage_->filename()));
} }
PreCacheTask::~PreCacheTask() PreCacheTask::~PreCacheTask()
{ {
// We created this viewer node ourselves, so now we should delete it // This should delete the footage we copied and the viewer we created
delete viewer(); delete project_;
} }
bool PreCacheTask::Run() bool PreCacheTask::Run()
+2 -2
View File
@@ -43,9 +43,9 @@ protected:
virtual void AudioDownloaded(const TimeRange& range, SampleBufferPtr samples, qint64 job_time) override; virtual void AudioDownloaded(const TimeRange& range, SampleBufferPtr samples, qint64 job_time) override;
private: private:
Footage* footage_; Project* project_;
int index_; Footage* footage_;
}; };
+11 -7
View File
@@ -490,15 +490,19 @@ void ProjectExplorer::ContextMenuStartProxy(QAction *a)
Sequence* sequence = Node::ValueToPtr<Sequence>(a->data()); Sequence* sequence = Node::ValueToPtr<Sequence>(a->data());
// To get here, the `context_menu_items_` must be all kFootage // To get here, the `context_menu_items_` must be all kFootage
foreach (Node* i, context_menu_items_) { foreach (Node* item, context_menu_items_) {
Footage* f = static_cast<Footage*>(i); Footage* f = static_cast<Footage*>(item);
QVector<VideoParams> enabled_streams = f->GetEnabledVideoStreams(); int sz = f->InputArraySize(Footage::kVideoParamsInput);
foreach (const VideoParams& stream, enabled_streams) { for (int j=0; j<sz; j++) {
// Start a background task for proxying VideoParams vp = f->GetVideoParams(j);
PreCacheTask* proxy_task = new PreCacheTask(f, stream.stream_index(), sequence);
TaskManager::instance()->AddTask(proxy_task); if (vp.enabled()) {
// Start a background task for proxying
PreCacheTask* proxy_task = new PreCacheTask(f, j, sequence);
TaskManager::instance()->AddTask(proxy_task);
}
} }
} }
} }