remove shifts, operations, and make caches node-agnostic
This commit is contained in:
+7
-19
@@ -48,11 +48,13 @@ Node::Node() :
|
||||
can_be_deleted_(true),
|
||||
override_color_(-1),
|
||||
folder_(nullptr),
|
||||
operation_stack_(0),
|
||||
cache_result_(false),
|
||||
flags_(kNone)
|
||||
{
|
||||
AddInput(kEnabledInput, NodeValue::kBoolean, true);
|
||||
|
||||
video_cache_ = new FrameHashCache(this);
|
||||
audio_cache_ = new AudioPlaybackCache(this);
|
||||
}
|
||||
|
||||
Node::~Node()
|
||||
@@ -933,18 +935,6 @@ void Node::InvalidateCache(const TimeRange &range, const QString &from, int elem
|
||||
SendInvalidateCache(range, options);
|
||||
}
|
||||
|
||||
void Node::BeginOperation()
|
||||
{
|
||||
// Increase operation stack
|
||||
operation_stack_++;
|
||||
}
|
||||
|
||||
void Node::EndOperation()
|
||||
{
|
||||
// Decrease operation stack
|
||||
operation_stack_--;
|
||||
}
|
||||
|
||||
TimeRange Node::InputTimeAdjustment(const QString &, int, const TimeRange &input_time) const
|
||||
{
|
||||
// Default behavior is no time adjustment at all
|
||||
@@ -1118,13 +1108,11 @@ Node *Node::CopyNodeInGraph(Node *node, MultiUndoCommand *command)
|
||||
|
||||
void Node::SendInvalidateCache(const TimeRange &range, const InvalidateCacheOptions &options)
|
||||
{
|
||||
if (GetOperationStack() == 0) {
|
||||
for (const OutputConnection& conn : output_connections_) {
|
||||
// Send clear cache signal to the Node
|
||||
const NodeInput& in = conn.second;
|
||||
for (const OutputConnection& conn : output_connections_) {
|
||||
// Send clear cache signal to the Node
|
||||
const NodeInput& in = conn.second;
|
||||
|
||||
in.node()->InvalidateCache(range, in.input(), in.element(), options);
|
||||
}
|
||||
in.node()->InvalidateCache(range, in.input(), in.element(), options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-20
@@ -39,6 +39,8 @@
|
||||
#include "node/inputimmediate.h"
|
||||
#include "node/param.h"
|
||||
#include "render/audioparams.h"
|
||||
#include "render/audioplaybackcache.h"
|
||||
#include "render/framehashcache.h"
|
||||
#include "render/job/generatejob.h"
|
||||
#include "render/job/samplejob.h"
|
||||
#include "render/job/shaderjob.h"
|
||||
@@ -219,6 +221,16 @@ public:
|
||||
return HasInputWithID(id);
|
||||
}
|
||||
|
||||
FrameHashCache* video_frame_cache() const
|
||||
{
|
||||
return video_cache_;
|
||||
}
|
||||
|
||||
AudioPlaybackCache* audio_playback_cache() const
|
||||
{
|
||||
return audio_cache_;
|
||||
}
|
||||
|
||||
struct Position
|
||||
{
|
||||
Position(const QPointF &p = QPointF(0, 0), bool e = false)
|
||||
@@ -798,19 +810,6 @@ public:
|
||||
InvalidateCache(range, from.input(), from.element(), options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Limits cache invalidation temporarily
|
||||
*
|
||||
* If you intend to do a number of operations in quick succession, you can optimize it by running
|
||||
* this function with EndOperation().
|
||||
*/
|
||||
virtual void BeginOperation();
|
||||
|
||||
/**
|
||||
* @brief Stops limiting cache invalidation and flushes changes
|
||||
*/
|
||||
virtual void EndOperation();
|
||||
|
||||
/**
|
||||
* @brief Adjusts time that should be sent to nodes connected to certain inputs.
|
||||
*
|
||||
@@ -1030,11 +1029,6 @@ protected:
|
||||
*/
|
||||
void IgnoreInvalidationsFrom(const QString &input_id);
|
||||
|
||||
int GetOperationStack() const
|
||||
{
|
||||
return operation_stack_;
|
||||
}
|
||||
|
||||
enum GizmoScaleHandles {
|
||||
kGizmoScaleTopLeft,
|
||||
kGizmoScaleTopCenter,
|
||||
@@ -1392,8 +1386,6 @@ private:
|
||||
|
||||
Folder* folder_;
|
||||
|
||||
int operation_stack_;
|
||||
|
||||
bool cache_result_;
|
||||
|
||||
QMap<InputElementPair, ValueHint> value_hints_;
|
||||
@@ -1406,6 +1398,10 @@ private:
|
||||
|
||||
QString effect_input_;
|
||||
|
||||
FrameHashCache *video_cache_;
|
||||
|
||||
AudioPlaybackCache *audio_cache_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Slot when a keyframe's time changes to keep the keyframes correctly sorted by time
|
||||
|
||||
@@ -406,10 +406,6 @@ QVector<Block *> Track::BlocksAtTimeRange(const TimeRange &range) const
|
||||
|
||||
void Track::InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options)
|
||||
{
|
||||
if (GetOperationStack() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
TimeRange limited;
|
||||
|
||||
const Block* b;
|
||||
@@ -465,69 +461,49 @@ void Track::InsertBlockAfter(Block *block, Block *before)
|
||||
|
||||
void Track::PrependBlock(Block *block)
|
||||
{
|
||||
BeginOperation();
|
||||
|
||||
InputArrayPrepend(kBlockInput);
|
||||
Node::ConnectEdge(block, NodeInput(this, kBlockInput, 0));
|
||||
|
||||
EndOperation();
|
||||
|
||||
// Everything has shifted at this point
|
||||
Node::InvalidateCache(TimeRange(0, track_length()), kBlockInput);
|
||||
}
|
||||
|
||||
void Track::InsertBlockAtIndex(Block *block, int index)
|
||||
{
|
||||
BeginOperation();
|
||||
|
||||
int insert_index = GetArrayIndexFromCacheIndex(index);
|
||||
InputArrayInsert(kBlockInput, insert_index);
|
||||
Node::ConnectEdge(block, NodeInput(this, kBlockInput, insert_index));
|
||||
|
||||
EndOperation();
|
||||
|
||||
Node::InvalidateCache(TimeRange(block->in(), track_length()), kBlockInput);
|
||||
}
|
||||
|
||||
void Track::AppendBlock(Block *block)
|
||||
{
|
||||
BeginOperation();
|
||||
|
||||
InputArrayAppend(kBlockInput);
|
||||
Node::ConnectEdge(block, NodeInput(this, kBlockInput, InputArraySize(kBlockInput) - 1));
|
||||
|
||||
EndOperation();
|
||||
|
||||
// Invalidate area that block was added to
|
||||
Node::InvalidateCache(TimeRange(block->in(), block->out()), kBlockInput);
|
||||
}
|
||||
|
||||
void Track::RippleRemoveBlock(Block *block)
|
||||
{
|
||||
BeginOperation();
|
||||
|
||||
rational remove_in = block->in();
|
||||
rational remove_out = block->out();
|
||||
|
||||
InputArrayRemove(kBlockInput, GetArrayIndexFromBlock(block));
|
||||
|
||||
EndOperation();
|
||||
|
||||
Node::InvalidateCache(TimeRange(remove_in, qMax(track_length(), remove_out)), kBlockInput);
|
||||
}
|
||||
|
||||
void Track::ReplaceBlock(Block *old, Block *replace)
|
||||
{
|
||||
BeginOperation();
|
||||
|
||||
int index_of_old_block = GetArrayIndexFromBlock(old);
|
||||
|
||||
DisconnectEdge(old, NodeInput(this, kBlockInput, index_of_old_block));
|
||||
|
||||
ConnectEdge(replace, NodeInput(this, kBlockInput, index_of_old_block));
|
||||
|
||||
EndOperation();
|
||||
|
||||
if (old->length() == replace->length()) {
|
||||
Node::InvalidateCache(TimeRange(replace->in(), replace->out()), kBlockInput);
|
||||
} else {
|
||||
|
||||
@@ -40,8 +40,6 @@ ViewerOutput::ViewerOutput(bool create_buffer_inputs, bool create_default_stream
|
||||
last_length_(0),
|
||||
video_length_(0),
|
||||
audio_length_(0),
|
||||
video_frame_cache_(this),
|
||||
audio_playback_cache_(this),
|
||||
video_cache_enabled_(true),
|
||||
audio_cache_enabled_(true)
|
||||
{
|
||||
@@ -229,30 +227,6 @@ void ViewerOutput::set_default_parameters()
|
||||
SetVideoAutoCacheEnabled(OLIVE_CONFIG("DefaultSequenceAutoCache").toBool());
|
||||
}
|
||||
|
||||
void ViewerOutput::ShiftVideoCache(const rational &from, const rational &to)
|
||||
{
|
||||
if (video_cache_enabled_) {
|
||||
video_frame_cache_.Shift(from, to);
|
||||
}
|
||||
|
||||
ShiftVideoEvent(from, to);
|
||||
}
|
||||
|
||||
void ViewerOutput::ShiftAudioCache(const rational &from, const rational &to)
|
||||
{
|
||||
if (audio_cache_enabled_) {
|
||||
audio_playback_cache_.Shift(from, to);
|
||||
}
|
||||
|
||||
ShiftAudioEvent(from, to);
|
||||
}
|
||||
|
||||
void ViewerOutput::ShiftCache(const rational &from, const rational &to)
|
||||
{
|
||||
ShiftVideoCache(from, to);
|
||||
ShiftAudioCache(from, to);
|
||||
}
|
||||
|
||||
void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
@@ -264,9 +238,9 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from,
|
||||
|
||||
if (invalidated_range.in() != invalidated_range.out()) {
|
||||
if (from == kTextureInput || from == kVideoParamsInput) {
|
||||
video_frame_cache_.Invalidate(invalidated_range);
|
||||
video_frame_cache()->Invalidate(invalidated_range);
|
||||
} else {
|
||||
audio_playback_cache_.Invalidate(invalidated_range);
|
||||
audio_playback_cache()->Invalidate(invalidated_range);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -454,7 +428,7 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
|
||||
|
||||
if (frame_rate_changed) {
|
||||
if (video_cache_enabled_) {
|
||||
video_frame_cache_.SetTimebase(new_video_params.frame_rate_as_time_base());
|
||||
video_frame_cache()->SetTimebase(new_video_params.frame_rate_as_time_base());
|
||||
}
|
||||
emit FrameRateChanged(new_video_params.frame_rate());
|
||||
}
|
||||
@@ -476,7 +450,7 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
|
||||
emit AudioParamsChanged();
|
||||
|
||||
if (audio_cache_enabled_) {
|
||||
audio_playback_cache_.SetParameters(GetAudioParams());
|
||||
audio_playback_cache()->SetParameters(GetAudioParams());
|
||||
}
|
||||
|
||||
cached_audio_params_ = new_audio_params;
|
||||
@@ -487,18 +461,6 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
|
||||
super::InputValueChangedEvent(input, element);
|
||||
}
|
||||
|
||||
void ViewerOutput::ShiftVideoEvent(const rational &from, const rational &to)
|
||||
{
|
||||
Q_UNUSED(from)
|
||||
Q_UNUSED(to)
|
||||
}
|
||||
|
||||
void ViewerOutput::ShiftAudioEvent(const rational &from, const rational &to)
|
||||
{
|
||||
Q_UNUSED(from)
|
||||
Q_UNUSED(to)
|
||||
}
|
||||
|
||||
void ViewerOutput::set_parameters_from_footage(const QVector<ViewerOutput *> footage)
|
||||
{
|
||||
foreach (ViewerOutput* f, footage) {
|
||||
|
||||
@@ -60,10 +60,6 @@ public:
|
||||
|
||||
void set_parameters_from_footage(const QVector<ViewerOutput *> footage);
|
||||
|
||||
void ShiftVideoCache(const rational& from, const rational& to);
|
||||
void ShiftAudioCache(const rational& from, const rational& to);
|
||||
void ShiftCache(const rational& from, const rational& to);
|
||||
|
||||
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options) override;
|
||||
|
||||
VideoParams GetVideoParams(int index = 0) const
|
||||
@@ -146,16 +142,6 @@ public:
|
||||
const rational &GetVideoLength() const { return video_length_; }
|
||||
const rational &GetAudioLength() const { return audio_length_; }
|
||||
|
||||
FrameHashCache* video_frame_cache()
|
||||
{
|
||||
return &video_frame_cache_;
|
||||
}
|
||||
|
||||
AudioPlaybackCache* audio_playback_cache()
|
||||
{
|
||||
return &audio_playback_cache_;
|
||||
}
|
||||
|
||||
TimelinePoints* GetTimelinePoints()
|
||||
{
|
||||
return timeline_points_;
|
||||
@@ -253,10 +239,6 @@ protected:
|
||||
|
||||
virtual rational VerifyLengthInternal(Track::Type type) const;
|
||||
|
||||
virtual void ShiftVideoEvent(const rational &from, const rational &to);
|
||||
|
||||
virtual void ShiftAudioEvent(const rational &from, const rational &to);
|
||||
|
||||
virtual void InputValueChangedEvent(const QString& input, int element) override;
|
||||
|
||||
int AddStream(Track::Type type, const QVariant &value);
|
||||
@@ -266,10 +248,6 @@ private:
|
||||
rational video_length_;
|
||||
rational audio_length_;
|
||||
|
||||
FrameHashCache video_frame_cache_;
|
||||
|
||||
AudioPlaybackCache audio_playback_cache_;
|
||||
|
||||
VideoParams cached_video_params_;
|
||||
|
||||
AudioParams cached_audio_params_;
|
||||
|
||||
Reference in New Issue
Block a user