viewer: store video/audio length outside of cache

This commit is contained in:
itsmattkc
2021-04-13 15:39:45 +10:00
parent f9c145b4d4
commit 46e00c0099
3 changed files with 12 additions and 13 deletions
+6 -11
View File
@@ -258,11 +258,6 @@ QVector<QString> ViewerOutput::inputs_for_output(const QString &output) const
return inputs;
}
const rational& ViewerOutput::GetLength() const
{
return last_length_;
}
QVector<Track::Reference> ViewerOutput::GetEnabledStreamsAsReferences() const
{
QVector<Track::Reference> refs;
@@ -303,21 +298,21 @@ void ViewerOutput::Retranslate()
void ViewerOutput::VerifyLength()
{
rational video_length, audio_length, subtitle_length;
rational subtitle_length;
video_length = VerifyLengthInternal(Track::kVideo);
video_length_ = VerifyLengthInternal(Track::kVideo);
if (cache_enabled_) {
video_frame_cache_.SetLength(video_length);
video_frame_cache_.SetLength(video_length_);
}
audio_length = VerifyLengthInternal(Track::kAudio);
audio_length_ = VerifyLengthInternal(Track::kAudio);
if (cache_enabled_) {
audio_playback_cache_.SetLength(audio_length);
audio_playback_cache_.SetLength(audio_length_);
}
subtitle_length = VerifyLengthInternal(Track::kSubtitle);
rational real_length = qMax(subtitle_length, qMax(video_length, audio_length));
rational real_length = qMax(subtitle_length, qMax(video_length_, audio_length_));
if (real_length != last_length_) {
last_length_ = real_length;
+5 -1
View File
@@ -111,7 +111,9 @@ public:
VideoParams GetFirstEnabledVideoStream() const;
AudioParams GetFirstEnabledAudioStream() const;
const rational &GetLength() const;
const rational &GetLength() const { return last_length_; }
const rational &GetVideoLength() const { return video_length_; }
const rational &GetAudioLength() const { return audio_length_; }
FrameHashCache* video_frame_cache()
{
@@ -192,6 +194,8 @@ protected:
private:
rational last_length_;
rational video_length_;
rational audio_length_;
FrameHashCache video_frame_cache_;
+1 -1
View File
@@ -594,7 +594,7 @@ QString ViewerWidget::GetCachedFilenameFromTime(const rational &time)
bool ViewerWidget::FrameExistsAtTime(const rational &time)
{
return GetConnectedNode() && time >= 0 && time < GetConnectedNode()->video_frame_cache()->GetLength();
return GetConnectedNode() && time >= 0 && time < GetConnectedNode()->GetVideoLength();
}
void ViewerWidget::SetDisplayImage(FramePtr frame, bool main_only)