+12
-13
@@ -47,7 +47,8 @@ Node::Node(bool create_default_output) :
|
||||
can_be_deleted_(true),
|
||||
override_color_(-1),
|
||||
last_change_time_(0),
|
||||
folder_(nullptr)
|
||||
folder_(nullptr),
|
||||
operation_stack_(0)
|
||||
{
|
||||
if (create_default_output) {
|
||||
AddOutput();
|
||||
@@ -1027,18 +1028,14 @@ void Node::InvalidateCache(const TimeRange &range, const QString &from, int elem
|
||||
|
||||
void Node::BeginOperation()
|
||||
{
|
||||
// Ripple through graph
|
||||
for (const std::pair<NodeOutput, NodeInput>& output : output_connections_) {
|
||||
output.second.node()->BeginOperation();
|
||||
}
|
||||
// Increase operation stack
|
||||
operation_stack_++;
|
||||
}
|
||||
|
||||
void Node::EndOperation()
|
||||
{
|
||||
// Ripple through graph
|
||||
for (const std::pair<NodeOutput, NodeInput>& output : output_connections_) {
|
||||
output.second.node()->EndOperation();
|
||||
}
|
||||
// Decrease operation stack
|
||||
operation_stack_--;
|
||||
}
|
||||
|
||||
TimeRange Node::InputTimeAdjustment(const QString &, int, const TimeRange &input_time) const
|
||||
@@ -1177,11 +1174,13 @@ Node *Node::CopyNodeInGraph(const Node *node, MultiUndoCommand *command)
|
||||
|
||||
void Node::SendInvalidateCache(const TimeRange &range, qint64 job_time)
|
||||
{
|
||||
for (const OutputConnection& conn : output_connections_) {
|
||||
// Send clear cache signal to the Node
|
||||
const NodeInput& in = conn.second;
|
||||
if (GetOperationStack() == 0) {
|
||||
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(), job_time);
|
||||
in.node()->InvalidateCache(range, in.input(), in.element(), job_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -816,6 +816,11 @@ protected:
|
||||
|
||||
void IgnoreHashingFrom(const QString& input_id);
|
||||
|
||||
int GetOperationStack() const
|
||||
{
|
||||
return operation_stack_;
|
||||
}
|
||||
|
||||
virtual bool LoadCustom(QXmlStreamReader* reader, XMLNodeData& xml_node_data, uint version, const QAtomicInt* cancelled);
|
||||
|
||||
virtual void SaveCustom(QXmlStreamWriter* writer) const;
|
||||
@@ -1179,6 +1184,8 @@ private:
|
||||
|
||||
Folder* folder_;
|
||||
|
||||
int operation_stack_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Slot when a keyframe's time changes to keep the keyframes correctly sorted by time
|
||||
|
||||
@@ -417,6 +417,10 @@ QVector<Block *> Track::BlocksAtTimeRange(const TimeRange &range) const
|
||||
|
||||
void Track::InvalidateCache(const TimeRange& range, const QString& from, int element, qint64 job_time)
|
||||
{
|
||||
if (GetOperationStack() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
TimeRange limited;
|
||||
|
||||
const Block* b;
|
||||
@@ -431,8 +435,8 @@ void Track::InvalidateCache(const TimeRange& range, const QString& from, int ele
|
||||
|
||||
limited = TimeRange(qMax(range.in(), b->in()), qMin(range.out(), b->out()));
|
||||
} else {
|
||||
limited = TimeRange(qMax(range.in(), rational(0)), qMin(range.out(), qMax(last_invalidated_length_, track_length())));
|
||||
last_invalidated_length_ = track_length();
|
||||
limited = TimeRange(qMax(range.in(), rational(0)), qMin(range.out(), qMax(preop_track_length_, track_length())));
|
||||
preop_track_length_ = track_length_;
|
||||
}
|
||||
|
||||
Node::InvalidateCache(limited, from, element, job_time);
|
||||
@@ -578,6 +582,15 @@ void Track::Hash(const QString &output, QCryptographicHash &hash, const rational
|
||||
}
|
||||
}
|
||||
|
||||
void Track::EndOperation()
|
||||
{
|
||||
super::EndOperation();
|
||||
|
||||
if (track_length_ != midop_track_length_) {
|
||||
SetLengthInternal(midop_track_length_);
|
||||
}
|
||||
}
|
||||
|
||||
void Track::SetMuted(bool e)
|
||||
{
|
||||
SetStandardValue(kMutedInput, e);
|
||||
@@ -629,13 +642,13 @@ int Track::GetCacheIndexFromArrayIndex(int index) const
|
||||
|
||||
void Track::SetLengthInternal(const rational &r, bool invalidate)
|
||||
{
|
||||
if (r != track_length_) {
|
||||
// TimeRange will automatically normalize so that the shorter number is the in and the longer
|
||||
// is the out
|
||||
TimeRange invalidate_range(track_length_, r);
|
||||
// Hold track length until operation stack is empty
|
||||
midop_track_length_ = r;
|
||||
|
||||
if (GetOperationStack() == 0 && track_length_ != r) {
|
||||
TimeRange invalidate_range(track_length_, r);
|
||||
track_length_ = r;
|
||||
last_invalidated_length_ = qMax(last_invalidated_length_, track_length_);
|
||||
preop_track_length_ = qMax(preop_track_length_, track_length_);
|
||||
emit TrackLengthChanged();
|
||||
|
||||
if (invalidate) {
|
||||
|
||||
@@ -343,6 +343,8 @@ public:
|
||||
return waveform_;
|
||||
}
|
||||
|
||||
virtual void EndOperation() override;
|
||||
|
||||
static const double kTrackHeightDefault;
|
||||
static const double kTrackHeightMinimum;
|
||||
static const double kTrackHeightInterval;
|
||||
@@ -425,7 +427,9 @@ private:
|
||||
|
||||
rational track_length_;
|
||||
|
||||
rational last_invalidated_length_;
|
||||
rational midop_track_length_;
|
||||
|
||||
rational preop_track_length_;
|
||||
|
||||
double track_height_;
|
||||
|
||||
|
||||
@@ -38,8 +38,7 @@ const uint64_t ViewerOutput::kVideoParamEditMask = VideoParamEdit::kWidthHeight
|
||||
|
||||
ViewerOutput::ViewerOutput(bool create_default_streams) :
|
||||
video_frame_cache_(this),
|
||||
audio_playback_cache_(this),
|
||||
operation_stack_(0)
|
||||
audio_playback_cache_(this)
|
||||
{
|
||||
AddInput(kVideoParamsInput, NodeValue::kVideoParams, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | kInputFlagArray));
|
||||
SetInputProperty(kVideoParamsInput, QStringLiteral("mask"), QVariant::fromValue(kVideoParamEditMask));
|
||||
@@ -218,24 +217,22 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from,
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (operation_stack_ == 0) {
|
||||
if (from == kTextureInput || from == kSamplesInput
|
||||
|| from == kVideoParamsInput || from == kAudioParamsInput) {
|
||||
TimeRange invalidated_range(qMax(rational(), range.in()),
|
||||
qMin(GetLength(), range.out()));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
VerifyLength();
|
||||
}
|
||||
|
||||
VerifyLength();
|
||||
|
||||
super::InvalidateCache(range, from, element, job_time);
|
||||
}
|
||||
|
||||
@@ -298,10 +295,6 @@ void ViewerOutput::Retranslate()
|
||||
|
||||
void ViewerOutput::VerifyLength()
|
||||
{
|
||||
if (operation_stack_ != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NodeTraverser traverser;
|
||||
|
||||
rational video_length, audio_length, subtitle_length;
|
||||
@@ -364,20 +357,6 @@ rational ViewerOutput::GetCustomLength(Track::Type type) const
|
||||
return rational();
|
||||
}
|
||||
|
||||
void ViewerOutput::BeginOperation()
|
||||
{
|
||||
operation_stack_++;
|
||||
|
||||
super::BeginOperation();
|
||||
}
|
||||
|
||||
void ViewerOutput::EndOperation()
|
||||
{
|
||||
operation_stack_--;
|
||||
|
||||
super::EndOperation();
|
||||
}
|
||||
|
||||
NodeOutput ViewerOutput::GetConnectedTextureOutput()
|
||||
{
|
||||
return GetConnectedOutput(kTextureInput);
|
||||
|
||||
@@ -136,10 +136,6 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual void BeginOperation() override;
|
||||
|
||||
virtual void EndOperation() override;
|
||||
|
||||
virtual NodeOutput GetConnectedTextureOutput();
|
||||
|
||||
virtual NodeOutput GetConnectedSampleOutput();
|
||||
|
||||
Reference in New Issue
Block a user