cache waveforms at clip level
This commit is contained in:
@@ -96,6 +96,7 @@ public:
|
||||
void set_track(Track* track)
|
||||
{
|
||||
track_ = track;
|
||||
emit TrackChanged(track_);
|
||||
}
|
||||
|
||||
bool is_enabled() const;
|
||||
@@ -126,6 +127,8 @@ signals:
|
||||
|
||||
void PreviewChanged();
|
||||
|
||||
void TrackChanged(Track *track);
|
||||
|
||||
protected:
|
||||
virtual void InputValueChangedEvent(const QString& input, int element) override;
|
||||
|
||||
|
||||
@@ -105,13 +105,7 @@ void ClipBlock::set_length_and_media_in(const rational &length)
|
||||
if (!reverse()) {
|
||||
// Calculate media_in adjustment
|
||||
rational proposed_media_in = SequenceToMediaTime(this->length() - length, false, true);
|
||||
|
||||
waveform_.TrimIn(proposed_media_in - media_in());
|
||||
|
||||
set_media_in(proposed_media_in);
|
||||
} else {
|
||||
// Trim waveform out point
|
||||
waveform_.TrimIn(this->length() - length);
|
||||
}
|
||||
|
||||
super::set_length_and_media_in(length);
|
||||
@@ -187,6 +181,19 @@ void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int
|
||||
|
||||
// If signal is from texture input, transform all times from media time to sequence time
|
||||
if (from == kBufferIn) {
|
||||
Track::Type type = GetTrackType();
|
||||
|
||||
if (type == Track::kVideo || type == Track::kAudio) {
|
||||
if (Node *connected = GetConnectedOutput(from, element)) {
|
||||
TimeRange max_range = InputTimeAdjustment(from, element, TimeRange(0, length()));
|
||||
if (type == Track::kVideo) {
|
||||
emit connected->video_frame_cache()->Request(range.Intersected(max_range), true);
|
||||
} else if (type == Track::kAudio) {
|
||||
emit connected->audio_playback_cache()->Request(range.Intersected(max_range), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust range from media time to sequence time
|
||||
TimeRange adj;
|
||||
double speed_value = speed();
|
||||
@@ -238,6 +245,24 @@ void ClipBlock::LinkChangeEvent()
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::InputConnectedEvent(const QString &input, int element, Node *output)
|
||||
{
|
||||
super::InputConnectedEvent(input, element, output);
|
||||
|
||||
if (input == kBufferIn) {
|
||||
connect(output->audio_playback_cache(), &AudioPlaybackCache::WaveformUpdated, this, &Block::PreviewChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::InputDisconnectedEvent(const QString &input, int element, Node *output)
|
||||
{
|
||||
super::InputDisconnectedEvent(input, element, output);
|
||||
|
||||
if (input == kBufferIn) {
|
||||
disconnect(output->audio_playback_cache(), &AudioPlaybackCache::WaveformUpdated, this, &Block::PreviewChanged);
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange ClipBlock::InputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
#include "node/block/block.h"
|
||||
#include "node/output/track/track.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -46,6 +47,15 @@ public:
|
||||
virtual void set_length_and_media_out(const rational &length) override;
|
||||
virtual void set_length_and_media_in(const rational &length) override;
|
||||
|
||||
Track::Type GetTrackType() const
|
||||
{
|
||||
if (track()) {
|
||||
return track()->type();
|
||||
} else {
|
||||
return Track::kNone;
|
||||
}
|
||||
}
|
||||
|
||||
rational media_in() const;
|
||||
void set_media_in(const rational& media_in);
|
||||
|
||||
@@ -109,9 +119,19 @@ public:
|
||||
return block_links_;
|
||||
}
|
||||
|
||||
AudioVisualWaveform& waveform()
|
||||
const AudioVisualWaveform *waveform()
|
||||
{
|
||||
return waveform_;
|
||||
if (Node *n = GetConnectedOutput(kBufferIn)) {
|
||||
return &n->audio_playback_cache()->visual();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void set_waveform(const AudioVisualWaveform *w)
|
||||
{
|
||||
qDebug() << "WAVEFORM COPY STUB";
|
||||
//audio_playback_cache()->set_visual(w);
|
||||
}
|
||||
|
||||
ViewerOutput *connected_viewer() const
|
||||
@@ -119,6 +139,16 @@ public:
|
||||
return connected_viewer_;
|
||||
}
|
||||
|
||||
virtual TimeRange GetVideoCacheRange() const override
|
||||
{
|
||||
return TimeRange(0, length());
|
||||
}
|
||||
|
||||
virtual TimeRange GetAudioCacheRange() const override
|
||||
{
|
||||
return TimeRange(0, length());
|
||||
}
|
||||
|
||||
static const QString kBufferIn;
|
||||
static const QString kMediaInInput;
|
||||
static const QString kSpeedInput;
|
||||
@@ -128,6 +158,10 @@ public:
|
||||
protected:
|
||||
virtual void LinkChangeEvent() override;
|
||||
|
||||
virtual void InputConnectedEvent(const QString& input, int element, Node *output) override;
|
||||
|
||||
virtual void InputDisconnectedEvent(const QString& input, int element, Node *output) override;
|
||||
|
||||
private:
|
||||
rational SequenceToMediaTime(const rational& sequence_time, bool ignore_reverse = false, bool ignore_speed = false) const;
|
||||
|
||||
@@ -141,11 +175,8 @@ private:
|
||||
ViewerOutput *connected_viewer_;
|
||||
|
||||
private:
|
||||
AudioVisualWaveform waveform_;
|
||||
|
||||
rational last_media_in_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+6
-4
@@ -933,11 +933,13 @@ void Node::InvalidateCache(const TimeRange &range, const QString &from, int elem
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (range.in() != range.out()) {
|
||||
if (video_cache_->IsEnabled()) {
|
||||
video_frame_cache()->Invalidate(range);
|
||||
TimeRange vr = range.Intersected(GetVideoCacheRange());
|
||||
if (vr.length() != 0) {
|
||||
video_frame_cache()->Invalidate(vr);
|
||||
}
|
||||
if (audio_cache_->IsEnabled()) {
|
||||
audio_playback_cache()->Invalidate(range);
|
||||
TimeRange ar = range.Intersected(GetAudioCacheRange());
|
||||
if (ar.length() != 0) {
|
||||
audio_playback_cache()->Invalidate(ar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -231,6 +231,9 @@ public:
|
||||
return audio_cache_;
|
||||
}
|
||||
|
||||
virtual TimeRange GetVideoCacheRange() const { return TimeRange(); }
|
||||
virtual TimeRange GetAudioCacheRange() const { return TimeRange(); }
|
||||
|
||||
struct Position
|
||||
{
|
||||
Position(const QPointF &p = QPointF(0, 0), bool e = false)
|
||||
|
||||
@@ -147,6 +147,16 @@ public:
|
||||
return timeline_points_;
|
||||
}
|
||||
|
||||
virtual TimeRange GetVideoCacheRange() const override
|
||||
{
|
||||
return TimeRange(0, GetVideoLength());
|
||||
}
|
||||
|
||||
virtual TimeRange GetAudioCacheRange() const override
|
||||
{
|
||||
return TimeRange(0, GetAudioLength());
|
||||
}
|
||||
|
||||
QVector<Track::Reference> GetEnabledStreamsAsReferences() const;
|
||||
|
||||
QVector<VideoParams> GetEnabledVideoStreams() const;
|
||||
|
||||
Reference in New Issue
Block a user