block: fixed buggy cache invalidation behavior when resizing blocks

This commit is contained in:
itsmattkc
2020-06-01 17:39:08 +10:00
parent 001b7179c5
commit 644fb7cec8
3 changed files with 19 additions and 18 deletions
+5 -4
View File
@@ -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
+4 -12
View File
@@ -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);
}
}
+10 -2
View File
@@ -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<Block*>(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()