implemented separate waveform cache

This commit is contained in:
itsmattkc
2022-05-29 17:52:35 -07:00
parent 826090b621
commit 2f7dc3c98b
28 changed files with 381 additions and 178 deletions
+15 -5
View File
@@ -38,7 +38,8 @@ const QString ClipBlock::kMaintainAudioPitchInput = QStringLiteral("maintain_aud
ClipBlock::ClipBlock() :
in_transition_(nullptr),
out_transition_(nullptr),
connected_viewer_(nullptr)
connected_viewer_(nullptr),
autocache_(false)
{
AddInput(kMediaInInput, NodeValue::kRational, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
SetInputProperty(kMediaInInput, QStringLiteral("view"), RationalSlider::kTime);
@@ -188,8 +189,14 @@ void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int
TimeRange max_range = InputTimeAdjustment(from, element, TimeRange(0, length()));
if (type == Track::kVideo) {
emit connected->thumbnail_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
if (autocache_) {
emit connected->video_frame_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
}
} else if (type == Track::kAudio) {
emit connected->audio_playback_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
emit connected->waveform_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
if (autocache_) {
emit connected->audio_playback_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
}
}
}
}
@@ -251,7 +258,7 @@ void ClipBlock::InputConnectedEvent(const QString &input, int element, Node *out
if (input == kBufferIn) {
connect(output->thumbnail_cache(), &FrameHashCache::Validated, this, &Block::PreviewChanged);
connect(output->audio_playback_cache(), &AudioPlaybackCache::WaveformUpdated, this, &Block::PreviewChanged);
connect(output->waveform_cache(), &AudioPlaybackCache::Validated, this, &Block::PreviewChanged);
}
}
@@ -261,7 +268,7 @@ void ClipBlock::InputDisconnectedEvent(const QString &input, int element, Node *
if (input == kBufferIn) {
disconnect(output->thumbnail_cache(), &FrameHashCache::Validated, this, &Block::PreviewChanged);
disconnect(output->audio_playback_cache(), &AudioPlaybackCache::WaveformUpdated, this, &Block::PreviewChanged);
disconnect(output->waveform_cache(), &AudioPlaybackCache::Validated, this, &Block::PreviewChanged);
}
}
@@ -324,7 +331,10 @@ void ClipBlock::ConnectedToPreviewEvent()
emit connected->thumbnail_cache()->Request(r, PlaybackCache::kPreviewsOnly);
}
} else if (type == Track::kAudio) {
//emit connected->audio_playback_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
TimeRangeList invalid = connected->waveform_cache()->GetInvalidatedRanges(max_range);
for (const TimeRange &r : invalid) {
emit connected->waveform_cache()->Request(r, PlaybackCache::kPreviewsOnly);
}
}
}
}
+4 -2
View File
@@ -128,10 +128,10 @@ public:
}
}
const AudioVisualWaveform *waveform()
const AudioWaveformCache *waveform()
{
if (Node *n = GetConnectedOutput(kBufferIn)) {
return &n->audio_playback_cache()->visual();
return n->waveform_cache();
} else {
return nullptr;
}
@@ -185,6 +185,8 @@ private:
ViewerOutput *connected_viewer_;
bool autocache_;
private:
rational last_media_in_;