From c49e5ef1b325b1fc6b2744487ff2455061076fdb Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 14 Apr 2021 13:46:53 +1000 Subject: [PATCH] footage: don't disable audio cache --- app/node/output/viewer/viewer.cpp | 40 ++++++++++++---------------- app/node/output/viewer/viewer.h | 6 +++-- app/node/project/footage/footage.cpp | 2 +- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/app/node/output/viewer/viewer.cpp b/app/node/output/viewer/viewer.cpp index 785764422..e8c16848e 100644 --- a/app/node/output/viewer/viewer.cpp +++ b/app/node/output/viewer/viewer.cpp @@ -39,7 +39,8 @@ const uint64_t ViewerOutput::kVideoParamEditMask = VideoParamEdit::kWidthHeight ViewerOutput::ViewerOutput(bool create_default_streams) : video_frame_cache_(this), audio_playback_cache_(this), - cache_enabled_(true) + video_cache_enabled_(true), + audio_cache_enabled_(true) { AddInput(kVideoParamsInput, NodeValue::kVideoParams, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | kInputFlagArray)); SetInputProperty(kVideoParamsInput, QStringLiteral("mask"), QVariant::fromValue(kVideoParamEditMask)); @@ -197,7 +198,7 @@ void ViewerOutput::set_default_parameters() void ViewerOutput::ShiftVideoCache(const rational &from, const rational &to) { - if (cache_enabled_) { + if (video_cache_enabled_) { video_frame_cache_.Shift(from, to); } @@ -206,7 +207,7 @@ void ViewerOutput::ShiftVideoCache(const rational &from, const rational &to) void ViewerOutput::ShiftAudioCache(const rational &from, const rational &to) { - if (cache_enabled_) { + if (audio_cache_enabled_) { audio_playback_cache_.Shift(from, to); } @@ -223,18 +224,16 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from, { Q_UNUSED(element) - if (cache_enabled_) { - if (from == kTextureInput || from == kSamplesInput - || from == kVideoParamsInput || from == kAudioParamsInput) { - TimeRange invalidated_range(qMax(rational(), range.in()), - qMin(GetLength(), range.out())); + if ((video_cache_enabled_ && (from == kTextureInput || from == kVideoParamsInput)) + || (audio_cache_enabled_ && (from == kSamplesInput || from == kAudioParamsInput))) { + TimeRange invalidated_range(qMax(rational(), range.in()), + qMin(GetLength(), range.out())); - if (invalidated_range.in() != invalidated_range.out()) { - if (from == kTextureInput || from == kVideoParamsInput) { - video_frame_cache_.Invalidate(invalidated_range, job_time); - } else { - audio_playback_cache_.Invalidate(invalidated_range, job_time); - } + if (invalidated_range.in() != invalidated_range.out()) { + if (from == kTextureInput || from == kVideoParamsInput) { + video_frame_cache_.Invalidate(invalidated_range, job_time); + } else { + audio_playback_cache_.Invalidate(invalidated_range, job_time); } } } @@ -301,12 +300,12 @@ void ViewerOutput::VerifyLength() rational subtitle_length; video_length_ = VerifyLengthInternal(Track::kVideo); - if (cache_enabled_) { + if (video_cache_enabled_) { video_frame_cache_.SetLength(video_length_); } audio_length_ = VerifyLengthInternal(Track::kAudio); - if (cache_enabled_) { + if (audio_cache_enabled_) { audio_playback_cache_.SetLength(audio_length_); } @@ -400,7 +399,7 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element) } if (frame_rate_changed) { - if (cache_enabled_) { + if (video_cache_enabled_) { video_frame_cache_.SetTimebase(new_video_params.frame_rate_as_time_base()); } emit FrameRateChanged(new_video_params.frame_rate()); @@ -422,7 +421,7 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element) emit AudioParamsChanged(); - if (cache_enabled_) { + if (audio_cache_enabled_) { audio_playback_cache_.SetParameters(GetAudioParams()); } @@ -526,11 +525,6 @@ int ViewerOutput::AddStream(Track::Type type, const QVariant& value) return index; } -void ViewerOutput::SetViewerCacheEnabled(bool e) -{ - cache_enabled_ = e; -} - void ViewerOutput::InputResized(const QString &input, int old_size, int new_size) { if (input == kVideoParamsInput || input == kAudioParamsInput) { diff --git a/app/node/output/viewer/viewer.h b/app/node/output/viewer/viewer.h index 820c9b934..3e25c5e55 100644 --- a/app/node/output/viewer/viewer.h +++ b/app/node/output/viewer/viewer.h @@ -202,7 +202,8 @@ protected: int AddStream(Track::Type type, const QVariant &value); - void SetViewerCacheEnabled(bool e); + void SetViewerVideoCacheEnabled(bool e) { video_cache_enabled_ = e; } + void SetViewerAudioCacheEnabled(bool e) { audio_cache_enabled_ = e; } private: rational last_length_; @@ -221,7 +222,8 @@ private: TimelinePoints timeline_points_; - bool cache_enabled_; + bool video_cache_enabled_; + bool audio_cache_enabled_; private slots: void InputResized(const QString& input, int old_size, int new_size); diff --git a/app/node/project/footage/footage.cpp b/app/node/project/footage/footage.cpp index c6a2699de..dc7e112c8 100644 --- a/app/node/project/footage/footage.cpp +++ b/app/node/project/footage/footage.cpp @@ -44,7 +44,7 @@ Footage::Footage(const QString &filename) : cancelled_(nullptr) { SetCacheTextures(true); - SetViewerCacheEnabled(false); + SetViewerVideoCacheEnabled(false); PrependInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));