implemented separate waveform cache
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_;
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ Node::Node() :
|
||||
video_cache_ = new FrameHashCache(this);
|
||||
thumbnail_cache_ = new FrameHashCache(this);
|
||||
audio_cache_ = new AudioPlaybackCache(this);
|
||||
waveform_cache_ = new AudioWaveformCache(this);
|
||||
}
|
||||
|
||||
Node::~Node()
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "node/param.h"
|
||||
#include "render/audioparams.h"
|
||||
#include "render/audioplaybackcache.h"
|
||||
#include "render/audiowaveformcache.h"
|
||||
#include "render/framehashcache.h"
|
||||
#include "render/job/generatejob.h"
|
||||
#include "render/job/samplejob.h"
|
||||
@@ -236,6 +237,11 @@ public:
|
||||
return audio_cache_;
|
||||
}
|
||||
|
||||
AudioWaveformCache* waveform_cache() const
|
||||
{
|
||||
return waveform_cache_;
|
||||
}
|
||||
|
||||
virtual TimeRange GetVideoCacheRange() const { return TimeRange(); }
|
||||
virtual TimeRange GetAudioCacheRange() const { return TimeRange(); }
|
||||
|
||||
@@ -1413,6 +1419,7 @@ private:
|
||||
FrameHashCache *thumbnail_cache_;
|
||||
|
||||
AudioPlaybackCache *audio_cache_;
|
||||
AudioWaveformCache *waveform_cache_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,9 @@ const QString ViewerOutput::kSamplesInput = QStringLiteral("samples_in");
|
||||
ViewerOutput::ViewerOutput(bool create_buffer_inputs, bool create_default_streams) :
|
||||
last_length_(0),
|
||||
video_length_(0),
|
||||
audio_length_(0)
|
||||
audio_length_(0),
|
||||
autocache_input_video_(false),
|
||||
autocache_input_audio_(false)
|
||||
{
|
||||
AddInput(kVideoParamsInput, NodeValue::kVideoParams, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | kInputFlagArray | kInputFlagHidden));
|
||||
|
||||
@@ -219,6 +221,22 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from,
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (Node *connected = GetConnectedOutput(from, element)) {
|
||||
if (from == kTextureInput) {
|
||||
//emit connected->thumbnail_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
if (autocache_input_video_) {
|
||||
TimeRange max_range = InputTimeAdjustment(from, element, TimeRange(0, GetVideoLength()));
|
||||
emit connected->video_frame_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
}
|
||||
} else if (from == kSamplesInput) {
|
||||
TimeRange max_range = InputTimeAdjustment(from, element, TimeRange(0, GetAudioLength()));
|
||||
emit connected->waveform_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
if (autocache_input_audio_) {
|
||||
emit connected->audio_playback_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VerifyLength();
|
||||
|
||||
super::InvalidateCache(range, from, element, options);
|
||||
@@ -298,6 +316,8 @@ void ViewerOutput::InputConnectedEvent(const QString &input, int element, Node *
|
||||
{
|
||||
if (input == kTextureInput) {
|
||||
emit TextureInputChanged();
|
||||
} else if (input == kSamplesInput) {
|
||||
connect(output->waveform_cache(), &AudioWaveformCache::Validated, this, &ViewerOutput::ConnectedWaveformChanged);
|
||||
}
|
||||
|
||||
super::InputConnectedEvent(input, element, output);
|
||||
@@ -307,6 +327,8 @@ void ViewerOutput::InputDisconnectedEvent(const QString &input, int element, Nod
|
||||
{
|
||||
if (input == kTextureInput) {
|
||||
emit TextureInputChanged();
|
||||
} else if (input == kSamplesInput) {
|
||||
disconnect(output->waveform_cache(), &AudioWaveformCache::Validated, this, &ViewerOutput::ConnectedWaveformChanged);
|
||||
}
|
||||
|
||||
super::InputDisconnectedEvent(input, element, output);
|
||||
@@ -364,6 +386,17 @@ Node::ValueHint ViewerOutput::GetConnectedSampleValueHint()
|
||||
return GetValueHintForInput(kSamplesInput);
|
||||
}
|
||||
|
||||
void ViewerOutput::ConnectedToPreviewEvent()
|
||||
{
|
||||
if (Node *connected = GetConnectedOutput(kSamplesInput)) {
|
||||
TimeRange max_range = InputTimeAdjustment(kSamplesInput, -1, TimeRange(0, GetAudioLength()));
|
||||
TimeRangeList invalid = connected->waveform_cache()->GetInvalidatedRanges(max_range);
|
||||
for (const TimeRange &r : invalid) {
|
||||
emit connected->waveform_cache()->Request(r, PlaybackCache::kPreviewsOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
if (element == 0) {
|
||||
|
||||
@@ -130,6 +130,15 @@ public:
|
||||
return GetVideoStreamCount() + GetAudioStreamCount() + GetSubtitleStreamCount();
|
||||
}
|
||||
|
||||
const AudioWaveformCache *GetConnectedWaveform()
|
||||
{
|
||||
if (Node *n = GetConnectedSampleOutput()) {
|
||||
return n->waveform_cache();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool HasEnabledVideoStreams() const;
|
||||
bool HasEnabledAudioStreams() const;
|
||||
bool HasEnabledSubtitleStreams() const;
|
||||
@@ -173,6 +182,8 @@ public:
|
||||
|
||||
virtual ValueHint GetConnectedSampleValueHint();
|
||||
|
||||
virtual void ConnectedToPreviewEvent() override;
|
||||
|
||||
static const QString kVideoParamsInput;
|
||||
static const QString kAudioParamsInput;
|
||||
static const QString kSubtitleParamsInput;
|
||||
@@ -198,6 +209,8 @@ signals:
|
||||
|
||||
void SampleRateChanged(int sr);
|
||||
|
||||
void ConnectedWaveformChanged();
|
||||
|
||||
public slots:
|
||||
void VerifyLength();
|
||||
|
||||
@@ -224,6 +237,9 @@ private:
|
||||
|
||||
TimelinePoints *timeline_points_;
|
||||
|
||||
bool autocache_input_video_;
|
||||
bool autocache_input_audio_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ Footage::Footage(const QString &filename) :
|
||||
check_timer->setInterval(5000);
|
||||
connect(check_timer, &QTimer::timeout, this, &Footage::CheckFootage);
|
||||
check_timer->start();
|
||||
|
||||
connect(this->waveform_cache(), &AudioWaveformCache::Validated, this, &ViewerOutput::ConnectedWaveformChanged);
|
||||
}
|
||||
|
||||
void Footage::Retranslate()
|
||||
|
||||
@@ -552,6 +552,8 @@ void ProjectSerializer220403::LoadNode(Node *node, XMLNodeData &xml_node_data, Q
|
||||
node->video_frame_cache()->SetUuid(reader->readElementText());
|
||||
} else if (reader->name() == QStringLiteral("thumb")) {
|
||||
node->thumbnail_cache()->SetUuid(reader->readElementText());
|
||||
} else if (reader->name() == QStringLiteral("waveform")) {
|
||||
node->waveform_cache()->SetUuid(reader->readElementText());
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
@@ -616,6 +618,7 @@ void ProjectSerializer220403::SaveNode(Node *node, QXmlStreamWriter *writer) con
|
||||
writer->writeTextElement(QStringLiteral("audio"), node->audio_playback_cache()->GetUuid().toString());
|
||||
writer->writeTextElement(QStringLiteral("video"), node->video_frame_cache()->GetUuid().toString());
|
||||
writer->writeTextElement(QStringLiteral("thumb"), node->thumbnail_cache()->GetUuid().toString());
|
||||
writer->writeTextElement(QStringLiteral("waveform"), node->waveform_cache()->GetUuid().toString());
|
||||
|
||||
writer->writeEndElement(); // caches
|
||||
|
||||
|
||||
Reference in New Issue
Block a user