cache: fixed on-demand cache

This commit is contained in:
itsmattkc
2021-10-09 19:13:11 -07:00
parent eba2ca55d4
commit 4125f41d1f
5 changed files with 29 additions and 14 deletions
+2 -1
View File
@@ -296,7 +296,8 @@ TimeRangeListFrameIterator::TimeRangeListFrameIterator(const TimeRangeList &list
list_(list),
timebase_(timebase),
index_(-1),
size_(-1)
size_(-1),
custom_range_(false)
{
if (!list_.isEmpty() && timebase_.isNull()) {
qCritical() << "TimeRangeListFrameIterator created with null timebase but non-empty list, this will likely lead to infinite loops";
+12
View File
@@ -228,6 +228,16 @@ public:
list_.insert(list);
}
bool IsCustomRange() const
{
return custom_range_;
}
void SetCustomRange(bool e)
{
custom_range_ = e;
}
private:
void UpdateIndexIfNecessary();
@@ -241,6 +251,8 @@ private:
int size_;
bool custom_range_;
};
uint qHash(const TimeRange& r, uint seed = 0);
+9 -12
View File
@@ -487,8 +487,6 @@ void PreviewAutoCacher::SetPlayhead(const rational &playhead)
cache_range_ = TimeRange(playhead - Config::Current()[QStringLiteral("DiskCacheBehind")].value<rational>(),
playhead + Config::Current()[QStringLiteral("DiskCacheAhead")].value<rational>());
use_custom_range_ = false;
RequeueFrames();
}
@@ -717,19 +715,17 @@ void PreviewAutoCacher::RequeueFrames()
if (viewer_node_
&& viewer_node_->video_frame_cache()->HasInvalidatedRanges(viewer_node_->GetVideoLength())
&& hash_tasks_.isEmpty()
&& (viewer_node_->GetVideoAutoCacheEnabled() || use_custom_range_)) {
TimeRange using_range;
if (use_custom_range_) {
using_range = custom_autocache_range_;
use_custom_range_ = false;
} else {
using_range = cache_range_;
}
&& (viewer_node_->GetVideoAutoCacheEnabled() || use_custom_range_)
&& !IsRenderingCustomRange()) {
TimeRange using_range = use_custom_range_ ? custom_autocache_range_ : cache_range_;
TimeRangeList invalidated = viewer_node_->video_frame_cache()->GetInvalidatedRanges(using_range);
queued_frame_iterator_ = TimeRangeListFrameIterator(invalidated, viewer_node_->video_frame_cache()->GetTimebase());
queued_frame_iterator_.SetCustomRange(use_custom_range_);
use_custom_range_ = false;
TryRender();
}
}
@@ -773,7 +769,8 @@ void PreviewAutoCacher::ForceCacheRange(const TimeRange &range)
use_custom_range_ = true;
custom_autocache_range_ = range;
RequeueFrames();
// Re-hash these frames and start rendering
StartCachingVideoRange(range);
}
void PreviewAutoCacher::SetViewerNode(ViewerOutput *viewer_node)
+5
View File
@@ -94,6 +94,11 @@ public:
void CancelVideoTasks(bool and_wait_for_them_to_finish = false);
void CancelAudioTasks(bool and_wait_for_them_to_finish = false);
bool IsRenderingCustomRange() const
{
return queued_frame_iterator_.IsCustomRange() && queued_frame_iterator_.HasNext();
}
private:
void TryRender();
+1 -1
View File
@@ -600,7 +600,7 @@ void ViewerWidget::UpdateTextureFromNode()
nonqueue_watchers_.append(watcher);
// Clear queue because we want this frame more than any others
if (!GetConnectedNode()->GetVideoAutoCacheEnabled()) {
if (!GetConnectedNode()->GetVideoAutoCacheEnabled() && !auto_cacher_.IsRenderingCustomRange()) {
ClearVideoAutoCacherQueue();
}