renderer: use shared backend when caching

I think there was an earlier commit with a similar name but turns out
I'd only done foundational work in that commit and never actually
properly set it up. Of course once I did, there were several issues that
needed fixing to make it work correctly, but now it works as expected.

Heavily optimizes larger projects by allowing cache jobs to only copy
what has changed.
This commit is contained in:
itsmattkc
2020-07-10 18:39:47 +10:00
parent 36dd06d2dc
commit efd90d5c8f
10 changed files with 104 additions and 55 deletions
+33 -2
View File
@@ -21,13 +21,13 @@
#include "renderworker.h"
#include <QDir>
#include <QThread>
#include "audio/audiovisualwaveform.h"
#include "common/functiontimer.h"
#include "config/config.h"
#include "node/block/clip/clip.h"
#include "task/conform/conform.h"
#include "renderbackend.h"
OLIVE_NAMESPACE_ENTER
@@ -40,6 +40,37 @@ RenderWorker::RenderWorker(RenderBackend* parent) :
{
}
void RenderWorker::Hash(RenderTicketPtr ticket, ViewerOutput *viewer, const QVector<rational> &times)
{
QVector<QByteArray> hashes(times.size());
for (int i=0;i<hashes.size();i++) {
hashes[i] = HashNode(viewer->texture_input()->get_connected_node(),
video_params_,
times.at(i));
}
ticket->Finish(QVariant::fromValue(hashes));
emit FinishedJob();
}
QByteArray RenderWorker::HashNode(const Node *n, const VideoParams &params, const rational &time)
{
QCryptographicHash hasher(QCryptographicHash::Sha1);
// Embed video parameters into this hash
hasher.addData(reinterpret_cast<const char*>(&params.effective_width()), sizeof(int));
hasher.addData(reinterpret_cast<const char*>(&params.effective_height()), sizeof(int));
hasher.addData(reinterpret_cast<const char*>(&params.format()), sizeof(PixelFormat::Format));
if (n) {
n->Hash(hasher, time);
}
return hasher.result();
}
void RenderWorker::RenderFrame(RenderTicketPtr ticket, ViewerOutput* viewer, const rational &time)
{
NodeValueTable table = ProcessInput(viewer->texture_input(),
@@ -237,7 +268,7 @@ QVariant RenderWorker::ProcessFrameGeneration(const Node* node, const GenerateJo
QVariant RenderWorker::GetCachedFrame(const Node* node, const rational& time)
{
if (node->id() == QStringLiteral("org.olivevideoeditor.Olive.videoinput")) {
QByteArray hash = RenderBackend::HashNode(node, video_params(), time);
QByteArray hash = HashNode(node, video_params(), time);
QString fn = FrameHashCache::CachePathName(hash);