rewrote hashing
This commit is contained in:
+43
-54
@@ -84,22 +84,26 @@ NodeValue NodeTraverser::GenerateRowValue(const Node *node, const QString &input
|
||||
|
||||
NodeValue NodeTraverser::GenerateRowValueElement(const Node *node, const QString &input, int element, NodeValueTable *table)
|
||||
{
|
||||
int value_index = GenerateRowValueElementIndex(node, input, element, table);
|
||||
|
||||
if (value_index == -1) {
|
||||
return NodeValue();
|
||||
} else {
|
||||
return table->TakeAt(value_index);
|
||||
}
|
||||
return GenerateRowValueElement(node->GetValueHintForInput(input, element), node->GetInputDataType(input), table);
|
||||
}
|
||||
|
||||
int NodeTraverser::GenerateRowValueElementIndex(const Node *node, const QString &input, int element, const NodeValueTable *table)
|
||||
NodeValue NodeTraverser::GenerateRowValueElement(const Node::ValueHint &hint, NodeValue::Type preferred_type, NodeValueTable *table)
|
||||
{
|
||||
int value_index = GenerateRowValueElementIndex(hint, preferred_type, table);
|
||||
|
||||
if (value_index == -1) {
|
||||
value_index = table->Count() - 1;
|
||||
}
|
||||
|
||||
return table->TakeAt(value_index);
|
||||
}
|
||||
|
||||
int NodeTraverser::GenerateRowValueElementIndex(const Node::ValueHint &hint, NodeValue::Type preferred_type, const NodeValueTable *table)
|
||||
{
|
||||
Node::ValueHint hint = node->GetValueHintForInput(input, element);
|
||||
QVector<NodeValue::Type> types = hint.type;
|
||||
|
||||
if (types.isEmpty()) {
|
||||
types.append(node->GetInputDataType(input));
|
||||
types.append(preferred_type);
|
||||
}
|
||||
|
||||
if (hint.index == -1) {
|
||||
@@ -124,6 +128,11 @@ int NodeTraverser::GenerateRowValueElementIndex(const Node *node, const QString
|
||||
}
|
||||
}
|
||||
|
||||
int NodeTraverser::GenerateRowValueElementIndex(const Node *node, const QString &input, int element, const NodeValueTable *table)
|
||||
{
|
||||
return GenerateRowValueElementIndex(node->GetValueHintForInput(input, element), node->GetInputDataType(input), table);
|
||||
}
|
||||
|
||||
NodeGlobals NodeTraverser::GenerateGlobals(const VideoParams ¶ms, const TimeRange &time)
|
||||
{
|
||||
return NodeGlobals(QVector2D(params.width(), params.height()), time);
|
||||
@@ -248,23 +257,23 @@ NodeValueTable NodeTraverser::GenerateBlockTable(const Track *track, const TimeR
|
||||
return table;
|
||||
}
|
||||
|
||||
QVariant NodeTraverser::ProcessVideoFootage(const FootageJob &stream, const rational &input_time)
|
||||
TexturePtr NodeTraverser::ProcessVideoFootage(const FootageJob &stream, const rational &input_time)
|
||||
{
|
||||
Q_UNUSED(input_time)
|
||||
|
||||
// Create dummy texture with footage params
|
||||
return QVariant::fromValue(std::make_shared<Texture>(stream.video_params()));
|
||||
return std::make_shared<Texture>(stream.video_params());
|
||||
}
|
||||
|
||||
QVariant NodeTraverser::ProcessAudioFootage(const FootageJob& stream, const TimeRange &input_time)
|
||||
SampleBufferPtr NodeTraverser::ProcessAudioFootage(const FootageJob& stream, const TimeRange &input_time)
|
||||
{
|
||||
Q_UNUSED(stream)
|
||||
Q_UNUSED(input_time)
|
||||
|
||||
return QVariant::fromValue(SampleBuffer::Create());
|
||||
return SampleBuffer::Create();
|
||||
}
|
||||
|
||||
QVariant NodeTraverser::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
|
||||
TexturePtr NodeTraverser::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
|
||||
{
|
||||
Q_UNUSED(node)
|
||||
Q_UNUSED(range)
|
||||
@@ -273,19 +282,19 @@ QVariant NodeTraverser::ProcessShader(const Node *node, const TimeRange &range,
|
||||
// Create dummy texture with sequence params
|
||||
VideoParams tex_params = video_params_;
|
||||
tex_params.set_channel_count(GetChannelCountFromJob(job));
|
||||
return QVariant::fromValue(std::make_shared<Texture>(tex_params));
|
||||
return std::make_shared<Texture>(tex_params);
|
||||
}
|
||||
|
||||
QVariant NodeTraverser::ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job)
|
||||
SampleBufferPtr NodeTraverser::ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job)
|
||||
{
|
||||
Q_UNUSED(node)
|
||||
Q_UNUSED(range)
|
||||
Q_UNUSED(job)
|
||||
|
||||
return QVariant::fromValue(SampleBuffer::Create());
|
||||
return SampleBuffer::Create();
|
||||
}
|
||||
|
||||
QVariant NodeTraverser::ProcessFrameGeneration(const Node *node, const GenerateJob &job)
|
||||
TexturePtr NodeTraverser::ProcessFrameGeneration(const Node *node, const GenerateJob &job)
|
||||
{
|
||||
Q_UNUSED(node)
|
||||
Q_UNUSED(job)
|
||||
@@ -293,20 +302,20 @@ QVariant NodeTraverser::ProcessFrameGeneration(const Node *node, const GenerateJ
|
||||
// Create dummy texture with sequence params
|
||||
VideoParams tex_params = video_params_;
|
||||
tex_params.set_channel_count(GetChannelCountFromJob(job));
|
||||
return QVariant::fromValue(std::make_shared<Texture>(tex_params));
|
||||
return std::make_shared<Texture>(tex_params);
|
||||
}
|
||||
|
||||
void NodeTraverser::SaveCachedTexture(const QByteArray &hash, const QVariant &texture)
|
||||
void NodeTraverser::SaveCachedTexture(const QByteArray &hash, TexturePtr texture)
|
||||
{
|
||||
Q_UNUSED(hash)
|
||||
Q_UNUSED(texture)
|
||||
}
|
||||
|
||||
QVariant NodeTraverser::GetCachedTexture(const QByteArray& hash)
|
||||
TexturePtr NodeTraverser::GetCachedTexture(const QByteArray& hash)
|
||||
{
|
||||
Q_UNUSED(hash)
|
||||
|
||||
return QVariant();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QVector2D NodeTraverser::GenerateResolution() const
|
||||
@@ -320,18 +329,18 @@ void NodeTraverser::PostProcessTable(const Node *node, const Node::ValueHint &hi
|
||||
QByteArray cached_node_hash;
|
||||
|
||||
// Convert footage to image/sample buffers
|
||||
if (CanCacheFrames() && node->GetCacheTextures()) {
|
||||
/*if (CanCacheFrames() && node->GetCacheTextures()) {
|
||||
// This node is set to cache the result, see if we can retrieved a previously cached version
|
||||
cached_node_hash = RenderManager::Hash(node, hint, GetCacheVideoParams(), range.in());
|
||||
|
||||
QVariant cached_frame = GetCachedTexture(cached_node_hash);
|
||||
if (!cached_frame.isNull()) {
|
||||
output_params.Push(NodeValue::kTexture, cached_frame, node);
|
||||
TexturePtr cached_frame = GetCachedTexture(cached_node_hash);
|
||||
if (cached_frame) {
|
||||
output_params.Push(NodeValue::kTexture, QVariant::fromValue(cached_frame), node);
|
||||
|
||||
// No more to do here
|
||||
got_cached_frame = true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// Strip out any jobs or footage
|
||||
QList<NodeValue> footage_jobs_to_run;
|
||||
@@ -369,31 +378,19 @@ void NodeTraverser::PostProcessTable(const Node *node, const Node::ValueHint &hi
|
||||
rational footage_time = Footage::AdjustTimeByLoopMode(range.in(), job.loop_mode(), job.length(), job.video_params().video_type(), job.video_params().frame_rate_as_time_base());
|
||||
|
||||
if (!footage_time.isNaN()) {
|
||||
QVariant value = ProcessVideoFootage(job, footage_time);
|
||||
|
||||
if (!value.isNull()) {
|
||||
output_params.Push(NodeValue::kTexture, value, node);
|
||||
}
|
||||
output_params.Push(NodeValue::kTexture, QVariant::fromValue(ProcessVideoFootage(job, footage_time)), node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run shaders
|
||||
foreach (const NodeValue& v, shader_jobs_to_run) {
|
||||
QVariant value = ProcessShader(node, range, v.data().value<ShaderJob>());
|
||||
|
||||
if (!value.isNull()) {
|
||||
output_params.Push(NodeValue::kTexture, value, node);
|
||||
}
|
||||
output_params.Push(NodeValue::kTexture, QVariant::fromValue(ProcessShader(node, range, v.data().value<ShaderJob>())), node);
|
||||
}
|
||||
|
||||
// Run generate jobs
|
||||
foreach (const NodeValue& v, generate_jobs_to_run) {
|
||||
QVariant value = ProcessFrameGeneration(node, v.data().value<GenerateJob>());
|
||||
|
||||
if (!value.isNull()) {
|
||||
output_params.Push(NodeValue::kTexture, value, node);
|
||||
}
|
||||
output_params.Push(NodeValue::kTexture, QVariant::fromValue(ProcessFrameGeneration(node, v.data().value<GenerateJob>())), node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,26 +400,18 @@ void NodeTraverser::PostProcessTable(const Node *node, const Node::ValueHint &hi
|
||||
FootageJob job = v.data().value<FootageJob>();
|
||||
|
||||
if (job.type() == Track::kAudio) {
|
||||
QVariant value = ProcessAudioFootage(job, range);
|
||||
|
||||
if (!value.isNull()) {
|
||||
output_params.Push(NodeValue::kSamples, value, node);
|
||||
}
|
||||
output_params.Push(NodeValue::kSamples, QVariant::fromValue(ProcessAudioFootage(job, range)), node);
|
||||
}
|
||||
}
|
||||
|
||||
// Run any accelerated shader jobs
|
||||
foreach (const NodeValue& v, sample_jobs_to_run) {
|
||||
QVariant value = ProcessSamples(node, range, v.data().value<SampleJob>());
|
||||
|
||||
if (!value.isNull()) {
|
||||
output_params.Push(NodeValue::kSamples, value, node);
|
||||
}
|
||||
output_params.Push(NodeValue::kSamples, QVariant::fromValue(ProcessSamples(node, range, v.data().value<SampleJob>())), node);
|
||||
}
|
||||
|
||||
if (CanCacheFrames() && node->GetCacheTextures() && !got_cached_frame) {
|
||||
// Save cached texture
|
||||
SaveCachedTexture(cached_node_hash, output_params.Get(NodeValue::kTexture));
|
||||
SaveCachedTexture(cached_node_hash, output_params.Get(NodeValue::kTexture).value<TexturePtr>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user