cache: implemented base functionality for clip cache

This commit is contained in:
itsmattkc
2022-06-04 17:29:09 -07:00
parent 7a8794fe88
commit 13299d0a3b
9 changed files with 127 additions and 18 deletions
+9
View File
@@ -234,6 +234,14 @@ void Node::DisconnectEdge(Node *output, const NodeInput &input)
}
}
void Node::CopyCacheUuidsFrom(Node *n)
{
video_cache_->SetUuid(n->video_cache_->GetUuid());
audio_cache_->SetUuid(n->audio_cache_->GetUuid());
thumbnail_cache_->SetUuid(n->thumbnail_cache_->GetUuid());
waveform_cache_->SetUuid(n->waveform_cache_->GetUuid());
}
QString Node::GetInputName(const QString &id) const
{
const Input* i = GetInternalInputData(id);
@@ -943,6 +951,7 @@ void Node::InvalidateCache(const TimeRange &range, const QString &from, int elem
TimeRange ar = range.Intersected(GetAudioCacheRange());
if (ar.length() != 0) {
audio_playback_cache()->Invalidate(ar);
waveform_cache()->Invalidate(ar);
}
}
+2
View File
@@ -353,6 +353,8 @@ public:
static void DisconnectEdge(Node *output, const NodeInput& input);
void CopyCacheUuidsFrom(Node *n);
virtual QString GetInputName(const QString& id) const;
void SetInputName(const QString& id, const QString& name);
+31 -12
View File
@@ -48,7 +48,7 @@ NodeValueRow NodeTraverser::GenerateRow(NodeValueDatabase *database, const Node
NodeValueRow row;
for (auto it=database->begin(); it!=database->end(); it++) {
// Get hint for which value should be pulled
NodeValue value = GenerateRowValue(node, it.key(), &it.value());
NodeValue value = GenerateRowValue(node, it.key(), &it.value(), range);
row.insert(it.key(), value);
}
@@ -65,9 +65,9 @@ NodeValueRow NodeTraverser::GenerateRow(const Node *node, const TimeRange &range
return GenerateRow(&database, node, range);
}
NodeValue NodeTraverser::GenerateRowValue(const Node *node, const QString &input, NodeValueTable *table)
NodeValue NodeTraverser::GenerateRowValue(const Node *node, const QString &input, NodeValueTable *table, const TimeRange &time)
{
NodeValue value = GenerateRowValueElement(node, input, -1, table);
NodeValue value = GenerateRowValueElement(node, input, -1, table, time);
if (value.array()) {
// Resolve each element of array
@@ -75,7 +75,7 @@ NodeValue NodeTraverser::GenerateRowValue(const Node *node, const QString &input
QVector<NodeValue> output(tables.size());
for (int i=0; i<tables.size(); i++) {
output[i] = GenerateRowValueElement(node, input, i, &tables[i]);
output[i] = GenerateRowValueElement(node, input, i, &tables[i], time);
}
value = NodeValue(value.type(), QVariant::fromValue(output), value.source(), value.array(), value.tag());
@@ -84,14 +84,9 @@ NodeValue NodeTraverser::GenerateRowValue(const Node *node, const QString &input
return value;
}
NodeValue NodeTraverser::GenerateRowValueElement(const Node *node, const QString &input, int element, NodeValueTable *table)
NodeValue NodeTraverser::GenerateRowValueElement(const Node *node, const QString &input, int element, NodeValueTable *table, const TimeRange &time)
{
return GenerateRowValueElement(node->GetValueHintForInput(input, element), node->GetInputDataType(input), table);
}
NodeValue NodeTraverser::GenerateRowValueElement(const Node::ValueHint &hint, NodeValue::Type preferred_type, NodeValueTable *table)
{
int value_index = GenerateRowValueElementIndex(hint, preferred_type, table);
int value_index = GenerateRowValueElementIndex(node->GetValueHintForInput(input, element), node->GetInputDataType(input), table);
if (value_index == -1) {
// If value was -1, try getting the last value
@@ -103,7 +98,17 @@ NodeValue NodeTraverser::GenerateRowValueElement(const Node::ValueHint &hint, No
return NodeValue();
}
return table->TakeAt(value_index);
NodeValue value = table->TakeAt(value_index);
if (value.type() == NodeValue::kTexture) {
QString cache = node->video_frame_cache()->GetValidCacheFilename(time.in());
if (!cache.isEmpty()) {
qDebug() << "pushing cache job";
value.set_value(CacheJob(cache, value.data()));
}
}
return value;
}
int NodeTraverser::GenerateRowValueElementIndex(const Node::ValueHint &hint, NodeValue::Type preferred_type, const NodeValueTable *table)
@@ -358,6 +363,10 @@ NodeValueTable NodeTraverser::GenerateBlockTable(const Track *track, const TimeR
return table;
}
TexturePtr NodeTraverser::ProcessVideoCacheJob(const CacheJob &val)
{
return nullptr;
}
QVector2D NodeTraverser::GenerateResolution() const
{
@@ -367,6 +376,16 @@ QVector2D NodeTraverser::GenerateResolution() const
void NodeTraverser::ResolveJobs(NodeValue &val, const TimeRange &range)
{
if (val.type() == NodeValue::kTexture || val.type() == NodeValue::kSamples) {
if (val.canConvert<CacheJob>()) {
CacheJob job = val.value<CacheJob>();
TexturePtr tex = ProcessVideoCacheJob(job);
if (tex) {
val.set_value(tex);
} else {
val.set_value(job.GetFallback());
}
}
if (val.canConvert<ShaderJob>()) {
ShaderJob job = val.value<ShaderJob>();
+6 -4
View File
@@ -26,8 +26,9 @@
#include "codec/decoder.h"
#include "common/cancelableobject.h"
#include "node/output/track/track.h"
#include "render/job/footagejob.h"
#include "render/job/cachejob.h"
#include "render/job/colortransformjob.h"
#include "render/job/footagejob.h"
#include "value.h"
namespace olive {
@@ -44,9 +45,8 @@ public:
NodeValueRow GenerateRow(NodeValueDatabase *database, const Node *node, const TimeRange &range);
NodeValueRow GenerateRow(const Node *node, const TimeRange &range);
NodeValue GenerateRowValue(const Node *node, const QString &input, NodeValueTable *table);
NodeValue GenerateRowValueElement(const Node *node, const QString &input, int element, NodeValueTable *table);
NodeValue GenerateRowValueElement(const Node::ValueHint &hint, NodeValue::Type preferred_type, NodeValueTable *table);
NodeValue GenerateRowValue(const Node *node, const QString &input, NodeValueTable *table, const TimeRange &time);
NodeValue GenerateRowValueElement(const Node *node, const QString &input, int element, NodeValueTable *table, const TimeRange &time);
int GenerateRowValueElementIndex(const Node::ValueHint &hint, NodeValue::Type preferred_type, const NodeValueTable *table);
int GenerateRowValueElementIndex(const Node *node, const QString &input, int element, const NodeValueTable *table);
@@ -101,6 +101,8 @@ protected:
virtual void ConvertToReferenceSpace(TexturePtr destination, TexturePtr source, const QString &input_cs){}
virtual TexturePtr ProcessVideoCacheJob(const CacheJob &val);
virtual TexturePtr CreateTexture(const VideoParams &p)
{
return CreateDummyTexture(p);
+2
View File
@@ -225,6 +225,8 @@ public:
data_ = QVariant::fromValue(v);
}
const QVariant &data() const { return data_; }
template <typename T>
bool canConvert() const
{