render: further simplified job times

Outside of silly mistakes, this should be significantly faster and more stable.
This commit is contained in:
itsmattkc
2021-07-12 15:14:37 -07:00
parent dc34f80386
commit c374a03e9d
15 changed files with 300 additions and 190 deletions
+7 -25
View File
@@ -199,30 +199,7 @@ void TimeRangeList::insert(TimeRange range_to_add)
void TimeRangeList::remove(const TimeRange &remove)
{
int sz = this->size();
for (int i=0;i<sz;i++) {
TimeRange& compare = array_[i];
if (remove.Contains(compare)) {
// This element is entirely encompassed in this range, remove it
array_.removeAt(i);
i--;
sz--;
} else if (compare.Contains(remove, false, false)) {
// The remove range is within this element, only choice is to split the element into two
TimeRange new_range(remove.out(), compare.out());
compare.set_out(remove.in());
insert(new_range);
break;
} else if (compare.in() < remove.in() && compare.out() > remove.in()) {
// This element's out point overlaps the range's in, we'll trim it
compare.set_out(remove.in());
} else if (compare.in() < remove.out() && compare.out() > remove.out()) {
// This element's in point overlaps the range's out, we'll trim it
compare.set_in(remove.out());
}
}
util_remove(&array_, remove);
}
bool TimeRangeList::contains(const TimeRange &range, bool in_inclusive, bool out_inclusive) const
@@ -312,7 +289,7 @@ TimeRangeListFrameIterator::TimeRangeListFrameIterator(const TimeRangeList &list
bool TimeRangeListFrameIterator::GetNext(rational *out)
{
if (index_ == list_.size()) {
if (!HasNext()) {
return false;
}
@@ -328,6 +305,11 @@ bool TimeRangeListFrameIterator::GetNext(rational *out)
return true;
}
bool TimeRangeListFrameIterator::HasNext() const
{
return index_ < list_.size();
}
int TimeRangeListFrameIterator::size()
{
if (size_ == -1) {
+32
View File
@@ -81,6 +81,36 @@ public:
void remove(const TimeRange& remove);
template <typename T>
static void util_remove(QVector<T> *list, const TimeRange &remove)
{
int sz = list->size();
for (int i=0;i<sz;i++) {
T& compare = (*list)[i];
if (remove.Contains(compare)) {
// This element is entirely encompassed in this range, remove it
list->removeAt(i);
i--;
sz--;
} else if (compare.Contains(remove, false, false)) {
// The remove range is within this element, only choice is to split the element into two
T new_range = compare;
new_range.set_in(remove.out());
compare.set_out(remove.in());
list->append(new_range);
break;
} else if (compare.in() < remove.in() && compare.out() > remove.in()) {
// This element's out point overlaps the range's in, we'll trim it
compare.set_out(remove.in());
} else if (compare.in() < remove.out() && compare.out() > remove.out()) {
// This element's in point overlaps the range's out, we'll trim it
compare.set_in(remove.out());
}
}
}
bool contains(const TimeRange& range, bool in_inclusive = true, bool out_inclusive = true) const;
bool isEmpty() const
@@ -156,6 +186,8 @@ public:
bool GetNext(rational *out);
bool HasNext() const;
QVector<rational> ToVector() const
{
TimeRangeListFrameIterator copy(list_, timebase_);