diff --git a/app/node/block/block.cpp b/app/node/block/block.cpp index bfa72f403..9a88b4f36 100644 --- a/app/node/block/block.cpp +++ b/app/node/block/block.cpp @@ -40,6 +40,7 @@ Block::Block() : length_input_->SetConnectable(false); length_input_->set_is_keyframable(false); AddInput(length_input_); + disconnect(length_input_, &NodeInput::ValueChanged, this, &Block::InputChanged); connect(length_input_, &NodeInput::ValueChanged, this, &Block::LengthInputChanged); media_in_input_ = new NodeInput("media_in_in", NodeParam::kRational); @@ -374,17 +375,17 @@ NodeInput *Block::speed_input() const void Block::InvalidateCache(const TimeRange &range, NodeInput *from, NodeInput *source) { - // We ignore length changes since they don't have an effect on our frames - if (from == length_input_) { + if (range.out() <= in() || range.in() >= out()) { + // Ignore this range return; } - Node::InvalidateCache(range, from, source); + Node::InvalidateCache(TimeRange(qMax(range.in(), in()), qMin(range.out(), out())), from, source); } void Block::Hash(QCryptographicHash &, const rational &) const { - // A block does nothing by default + // A block does nothing by default, so we hash nothing } OLIVE_NAMESPACE_EXIT diff --git a/app/node/block/clip/clip.cpp b/app/node/block/clip/clip.cpp index 04205c192..604ce0204 100644 --- a/app/node/block/clip/clip.cpp +++ b/app/node/block/clip/clip.cpp @@ -82,23 +82,15 @@ void ClipBlock::LengthChangedEvent(const rational &old_length, const rational &n void ClipBlock::InvalidateCache(const TimeRange &range, NodeInput *from, NodeInput *source) { // If signal is from texture input, transform all times from media time to sequence time - if (from == texture_input_ || from == media_in_input()) { + if (from == texture_input_) { + // Adjust range from media time to sequence time rational start = MediaToSequenceTime(range.in()); rational end = MediaToSequenceTime(range.out()); - // Ensure range actually covers this clip's area - if (!(end < in() || start > out())) { - - // Limit cache invalidation to clip lengths - start = qMax(start, in()); - end = qMin(end, out()); - - Node::InvalidateCache(TimeRange(start, end), from, source); - - } + Block::InvalidateCache(TimeRange(start, end), from, source); } else { // Otherwise, pass signal along normally - Node::InvalidateCache(range, from, source); + Block::InvalidateCache(range, from, source); } } diff --git a/app/node/output/track/track.cpp b/app/node/output/track/track.cpp index 7e6b37aaa..992a4683e 100644 --- a/app/node/output/track/track.cpp +++ b/app/node/output/track/track.cpp @@ -503,12 +503,12 @@ void TrackOutput::SetLengthInternal(const rational &r) } if (r != track_length_) { - rational old_track_length = track_length_; + TimeRange invalidate_range(track_length_, r); track_length_ = r; emit TrackLengthChanged(); - InvalidateCache(TimeRange(qMin(old_track_length, r), qMax(old_track_length, r)), + InvalidateCache(invalidate_range, block_input_, block_input_); } @@ -696,7 +696,15 @@ void TrackOutput::BlockLengthChanged() // Assumes sender is a Block Block* b = static_cast(sender()); + rational old_out = b->out(); + UpdateInOutFrom(block_cache_.indexOf(b)); + + rational new_out = b->out(); + + TimeRange invalidate_region(qMin(old_out, new_out), track_length()); + + InvalidateCache(invalidate_region, block_input_, block_input_); } void TrackOutput::MutedInputValueChanged()