diff --git a/app/node/output/viewer/viewer.cpp b/app/node/output/viewer/viewer.cpp index 6b30cd3cc..81c89b383 100644 --- a/app/node/output/viewer/viewer.cpp +++ b/app/node/output/viewer/viewer.cpp @@ -38,7 +38,8 @@ const uint64_t ViewerOutput::kVideoParamEditMask = VideoParamEdit::kWidthHeight ViewerOutput::ViewerOutput(bool create_default_streams) : video_frame_cache_(this), - audio_playback_cache_(this) + audio_playback_cache_(this), + cache_enabled_(true) { AddInput(kVideoParamsInput, NodeValue::kVideoParams, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | kInputFlagArray)); SetInputProperty(kVideoParamsInput, QStringLiteral("mask"), QVariant::fromValue(kVideoParamEditMask)); @@ -195,14 +196,18 @@ void ViewerOutput::set_default_parameters() void ViewerOutput::ShiftVideoCache(const rational &from, const rational &to) { - video_frame_cache_.Shift(from, to); + if (cache_enabled_) { + video_frame_cache_.Shift(from, to); + } ShiftVideoEvent(from, to); } void ViewerOutput::ShiftAudioCache(const rational &from, const rational &to) { - audio_playback_cache_.Shift(from, to); + if (cache_enabled_) { + audio_playback_cache_.Shift(from, to); + } ShiftAudioEvent(from, to); } @@ -217,16 +222,18 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from, { Q_UNUSED(element) - if (from == kTextureInput || from == kSamplesInput - || from == kVideoParamsInput || from == kAudioParamsInput) { - TimeRange invalidated_range(qMax(rational(), range.in()), - qMin(GetLength(), range.out())); + if (cache_enabled_) { + if (from == kTextureInput || from == kSamplesInput + || from == kVideoParamsInput || 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); + } } } } @@ -307,7 +314,9 @@ void ViewerOutput::VerifyLength() video_length = t.Get(NodeValue::kRational, QStringLiteral("length")).value(); } - video_frame_cache_.SetLength(video_length); + if (cache_enabled_) { + video_frame_cache_.SetLength(video_length); + } } { @@ -318,7 +327,9 @@ void ViewerOutput::VerifyLength() audio_length = t.Get(NodeValue::kRational, QStringLiteral("length")).value(); } - audio_playback_cache_.SetLength(audio_length); + if (cache_enabled_) { + audio_playback_cache_.SetLength(audio_length); + } } { @@ -392,7 +403,9 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element) } if (frame_rate_changed) { - video_frame_cache_.SetTimebase(new_video_params.frame_rate_as_time_base()); + if (cache_enabled_) { + video_frame_cache_.SetTimebase(new_video_params.frame_rate_as_time_base()); + } emit FrameRateChanged(new_video_params.frame_rate()); } @@ -412,7 +425,9 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element) emit AudioParamsChanged(); - audio_playback_cache_.SetParameters(GetAudioParams()); + if (cache_enabled_) { + audio_playback_cache_.SetParameters(GetAudioParams()); + } cached_audio_params_ = new_audio_params; @@ -514,6 +529,11 @@ 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 1872df8e8..a56602b49 100644 --- a/app/node/output/viewer/viewer.h +++ b/app/node/output/viewer/viewer.h @@ -188,6 +188,8 @@ protected: int AddStream(Track::Type type, const QVariant &value); + void SetViewerCacheEnabled(bool e); + private: rational last_length_; @@ -203,6 +205,8 @@ private: TimelinePoints timeline_points_; + bool 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 796e96cfe..8344cca0d 100644 --- a/app/node/project/footage/footage.cpp +++ b/app/node/project/footage/footage.cpp @@ -50,6 +50,7 @@ Footage::Footage(const QString &filename) : set_filename(filename); SetCacheTextures(true); + SetViewerCacheEnabled(false); } void Footage::Retranslate()