render: improved overall flow

This commit is contained in:
itsmattkc
2022-05-16 15:41:50 -07:00
parent bfd6a407a5
commit 23973699b4
8 changed files with 62 additions and 47 deletions
+21 -7
View File
@@ -49,16 +49,19 @@ public:
void ValidateTimestamp(const int64_t &ts);
void ValidateTime(const rational &time);
/**
* @brief Return the path of the cached image at this time
*/
QString CachePathName(const int64_t &time) const;
QString CachePathName(const rational &time) const
bool IsFrameCached(const rational &time) const
{
return CachePathName(ToTimestamp(time, Timecode::kFloor));
return GetValidatedRanges().contains(time);
}
static QString CachePathName(const QString& cache_path, const QUuid &cache_id, const int64_t &time);
QString GetValidCacheFilename(const rational &time) const
{
if (IsFrameCached(time)) {
return CachePathName(time);
} else {
return QString();
}
}
static bool SaveCacheFrame(const QString& filename, FramePtr frame);
bool SaveCacheFrame(const int64_t &time, FramePtr frame) const;
@@ -71,6 +74,17 @@ private:
rational ToTime(const int64_t &ts) const;
int64_t ToTimestamp(const rational &ts, Timecode::Rounding rounding = Timecode::kRound) const;
/**
* @brief Return the path of the cached image at this time
*/
QString CachePathName(const int64_t &time) const;
QString CachePathName(const rational &time) const
{
return CachePathName(ToTimestamp(time, Timecode::kRound));
}
static QString CachePathName(const QString& cache_path, const QUuid &cache_id, const int64_t &time);
rational timebase_;
QUuid uuid_;
+2
View File
@@ -59,6 +59,8 @@ public:
void Invalidate(const TimeRange& r, bool signal = true);
const TimeRangeList &GetValidatedRanges() const { return validated_; }
public slots:
void InvalidateAll();
+5 -14
View File
@@ -429,7 +429,7 @@ void PreviewAutoCacher::StartCachingAudioRange(const TimeRange &range)
void PreviewAutoCacher::SetPlayhead(const rational &playhead)
{
cache_range_ = TimeRange(playhead - OLIVE_CONFIG("DiskCacheBehind").value<rational>(),
playhead + OLIVE_CONFIG("DiskCacheAhead").value<rational>());
playhead + OLIVE_CONFIG("DiskCacheAhead").value<rational>());
RequeueFrames();
}
@@ -546,19 +546,10 @@ void PreviewAutoCacher::TryRender()
if (single_frame_render_) {
// Check if already caching this
rational time = single_frame_render_->property("time").value<rational>();
RenderTicketWatcher* watcher;
if ((watcher = video_tasks_.key(time))) {
video_immediate_passthroughs_[watcher].append(single_frame_render_);
} else if ((watcher = video_download_tasks_.key(time))) {
single_frame_render_->Finish(watcher->property("frame"));
} else {
watcher = RenderFrame(single_frame_render_->property("time").value<rational>(),
RenderTicketPriority(single_frame_render_->property("priority").toInt()),
!viewer_node_->GetVideoAutoCacheEnabled());
video_immediate_passthroughs_[watcher].append(single_frame_render_);
}
RenderTicketWatcher *watcher = RenderFrame(single_frame_render_->property("time").value<rational>(),
RenderTicketPriority(single_frame_render_->property("priority").toInt()),
!viewer_node_->GetVideoAutoCacheEnabled());
video_immediate_passthroughs_[watcher].append(single_frame_render_);
single_frame_render_ = nullptr;
}
+2 -2
View File
@@ -164,7 +164,7 @@ void RenderProcessor::Run()
texture = render_ctx_->InterlaceTexture(top, bottom, GetCacheVideoParams());
}
if (ticket_->IsCancelled()) {
if (HeardCancel()) {
// Finish cancelled ticket with nothing since we can't guarantee the frame we generated
// is actually "complete
ticket_->Finish();
@@ -208,7 +208,7 @@ void RenderProcessor::Run()
ticket_->setProperty("waveform", QVariant::fromValue(vis));
}
if (ticket_->IsCancelled()) {
if (HeardCancel()) {
ticket_->Finish();
} else {
ticket_->Finish(QVariant::fromValue(samples));