decoder: cache still textures
This commit is contained in:
+12
-2
@@ -37,7 +37,8 @@ namespace olive {
|
|||||||
|
|
||||||
const rational Decoder::kAnyTimecode = RATIONAL_MIN;
|
const rational Decoder::kAnyTimecode = RATIONAL_MIN;
|
||||||
|
|
||||||
Decoder::Decoder()
|
Decoder::Decoder() :
|
||||||
|
cached_texture_(nullptr)
|
||||||
{
|
{
|
||||||
UpdateLastAccessed();
|
UpdateLastAccessed();
|
||||||
}
|
}
|
||||||
@@ -106,7 +107,14 @@ TexturePtr Decoder::RetrieveVideo(Renderer *renderer, const rational &timecode,
|
|||||||
return nullptr;
|
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 ¶ms, const QString& cache_path, LoopMode loop_mode, RenderMode::Mode mode)
|
Decoder::RetrieveAudioStatus Decoder::RetrieveAudio(SampleBuffer &dest, const TimeRange &range, const AudioParams ¶ms, const QString& cache_path, LoopMode loop_mode, RenderMode::Mode mode)
|
||||||
@@ -152,6 +160,8 @@ void Decoder::Close()
|
|||||||
|
|
||||||
UpdateLastAccessed();
|
UpdateLastAccessed();
|
||||||
|
|
||||||
|
cached_texture_ = nullptr;
|
||||||
|
|
||||||
if (stream_.IsValid()) {
|
if (stream_.IsValid()) {
|
||||||
CloseInternal();
|
CloseInternal();
|
||||||
stream_.Reset();
|
stream_.Reset();
|
||||||
|
|||||||
@@ -329,6 +329,9 @@ private:
|
|||||||
|
|
||||||
qint64 last_accessed_;
|
qint64 last_accessed_;
|
||||||
|
|
||||||
|
TexturePtr cached_texture_;
|
||||||
|
rational cached_time_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint qHash(Decoder::CodecStream stream, uint seed = 0);
|
uint qHash(Decoder::CodecStream stream, uint seed = 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user