render: avoid hashing null node
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -102,13 +102,15 @@ void RenderManager::ClearOldDecoders()
|
||||
|
||||
QByteArray RenderManager::Hash(const Node *n, const Node::ValueHint &output, const VideoParams ¶ms, 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 ¶ms, 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,
|
||||
|
||||
@@ -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 ¶ms, const rational &time);
|
||||
static QByteArray Hash(ViewerOutput *viewer, const VideoParams ¶ms, const rational &time);
|
||||
|
||||
/**
|
||||
* @brief Asynchronously generate a frame at a given time
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user