decoder: cache still textures

This commit is contained in:
itsmattkc
2022-07-17 15:42:11 -07:00
parent 0d9727b6d2
commit 2a1e87c9a9
2 changed files with 15 additions and 2 deletions
+12 -2
View File
@@ -37,7 +37,8 @@ namespace olive {
const rational Decoder::kAnyTimecode = RATIONAL_MIN;
Decoder::Decoder()
Decoder::Decoder() :
cached_texture_(nullptr)
{
UpdateLastAccessed();
}
@@ -106,7 +107,14 @@ TexturePtr Decoder::RetrieveVideo(Renderer *renderer, const rational &timecode,
return nullptr;
}
return RetrieveVideoInternal(renderer, timecode, divider, cancelled);
if (cached_texture_ && cached_time_ == timecode) {
return cached_texture_;
}
cached_texture_ = RetrieveVideoInternal(renderer, timecode, divider, cancelled);
cached_time_ = timecode;
return cached_texture_;
}
Decoder::RetrieveAudioStatus Decoder::RetrieveAudio(SampleBuffer &dest, const TimeRange &range, const AudioParams &params, const QString& cache_path, LoopMode loop_mode, RenderMode::Mode mode)
@@ -152,6 +160,8 @@ void Decoder::Close()
UpdateLastAccessed();
cached_texture_ = nullptr;
if (stream_.IsValid()) {
CloseInternal();
stream_.Reset();
+3
View File
@@ -329,6 +329,9 @@ private:
qint64 last_accessed_;
TexturePtr cached_texture_;
rational cached_time_;
};
uint qHash(Decoder::CodecStream stream, uint seed = 0);