render: avoid hashing null node

This commit is contained in:
itsmattkc
2021-09-21 21:32:20 -07:00
parent 31cb4dd0b1
commit 8277748719
6 changed files with 30 additions and 11 deletions
+10
View File
@@ -370,11 +370,21 @@ Node *ViewerOutput::GetConnectedTextureOutput()
return GetConnectedOutput(kTextureInput);
}
Node::ValueHint ViewerOutput::GetConnectedTextureValueHint()
{
return GetValueHintForInput(kTextureInput);
}
Node *ViewerOutput::GetConnectedSampleOutput()
{
return GetConnectedOutput(kSamplesInput);
}
Node::ValueHint ViewerOutput::GetConnectedSampleValueHint()
{
return GetValueHintForInput(kSamplesInput);
}
void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
{
if (input == kAutoCacheInput) {
+4
View File
@@ -150,8 +150,12 @@ public:
virtual Node *GetConnectedTextureOutput();
virtual ValueHint GetConnectedTextureValueHint();
virtual Node *GetConnectedSampleOutput();
virtual ValueHint GetConnectedSampleValueHint();
void SetViewerVideoCacheEnabled(bool e) { video_cache_enabled_ = e; }
void SetViewerAudioCacheEnabled(bool e) { audio_cache_enabled_ = e; }
+6 -2
View File
@@ -76,7 +76,8 @@ QVector<PreviewAutoCacher::HashData> PreviewAutoCacher::GenerateHashes(ViewerOut
const rational &time = times.at(i);
// See if hash already exists in disk cache
QByteArray hash = RenderManager::Hash(viewer,
QByteArray hash = RenderManager::Hash(viewer->GetConnectedTextureOutput(),
viewer->GetConnectedTextureValueHint(),
viewer->GetVideoParams(),
time);
@@ -84,6 +85,7 @@ QVector<PreviewAutoCacher::HashData> PreviewAutoCacher::GenerateHashes(ViewerOut
bool hash_exists = existing_hashes.contains(hash);
if (!hash_exists) {
// FIXME: Using CachePathName here is NOT thread safe and should be replaced
hash_exists = QFileInfo::exists(cache->CachePathName(hash));
if (hash_exists) {
@@ -545,7 +547,9 @@ void PreviewAutoCacher::TryRender()
// Check for newly invalidated video and hash it
if (!invalidated_video_.isEmpty()) {
if (hash_iterator_.HasNext()) {
if (!copied_viewer_node_->GetConnectedTextureOutput()) {
hash_iterator_.reset();
} else if (hash_iterator_.HasNext()) {
hash_iterator_.insert(invalidated_video_);
} else {
hash_iterator_ = TimeRangeListFrameIterator(invalidated_video_, viewer_node_->GetVideoParams().frame_rate_as_time_base());
+8 -6
View File
@@ -102,13 +102,15 @@ void RenderManager::ClearOldDecoders()
QByteArray RenderManager::Hash(const Node *n, const Node::ValueHint &output, const VideoParams &params, const rational &time)
{
HashTraverser hasher;
return hasher.GetHash(n, output, params, TimeRange(time, time + params.frame_rate_as_time_base()));
}
Q_ASSERT(n);
QByteArray RenderManager::Hash(ViewerOutput *viewer, const VideoParams &params, const rational &time)
{
return Hash(viewer->GetConnectedTextureOutput(), viewer->GetValueHintForInput(ViewerOutput::kTextureInput), params, time);
if (n) {
HashTraverser hasher;
return hasher.GetHash(n, output, params, TimeRange(time, time + params.frame_rate_as_time_base()));
} else {
qCritical() << "Hash called with null node";
return QByteArray();
}
}
RenderTicketPtr RenderManager::RenderFrame(ViewerOutput *viewer, ColorManager* color_manager,
-1
View File
@@ -67,7 +67,6 @@ public:
* @brief Generate a unique identifier for a certain node at a cconst Node *n, const Node::ValueHint &outputertain time
*/
static QByteArray Hash(const Node *n, const Node::ValueHint &output, const VideoParams &params, const rational &time);
static QByteArray Hash(ViewerOutput *viewer, const VideoParams &params, const rational &time);
/**
* @brief Asynchronously generate a frame at a given time
+2 -2
View File
@@ -77,7 +77,7 @@ bool RenderTask::Render(ColorManager* manager,
QMap<QByteArray, QVector<rational> > time_map;
QVector<QPair<rational, QByteArray> > frame_render_order;
if (!video_range.isEmpty()) {
if (!video_range.isEmpty() && viewer()->GetConnectedTextureOutput()) {
// Get list of discrete frames from range
TimeRangeListFrameIterator iterator(video_range, video_params().frame_rate_as_time_base());
QVector<rational> times(iterator.size());
@@ -91,7 +91,7 @@ bool RenderTask::Render(ColorManager* manager,
}
times[i] = r;
hashes[i] = RenderManager::instance()->Hash(viewer(), video_params_, r);
hashes[i] = RenderManager::instance()->Hash(viewer()->GetConnectedTextureOutput(), viewer()->GetConnectedTextureValueHint(), video_params_, r);
}
// Filter out duplicates