frames Previously, when the video renderer received a dirty cache signal, it would proceed to extract all frames from the range and queue them. However, this could be extremely slow for long ranges since it had to iterate through the entire range and calculate the individual frames it contained. Now, we use the same range combining system as audio and automatically calculate the next frame within the range only when necessary. Essentially the same work, but split up over time and done only when needed leading to no discernible UI pause when invalidating cache.
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#ifndef TIMERANGE_H
|
|
#define TIMERANGE_H
|
|
|
|
#include "rational.h"
|
|
|
|
class TimeRange {
|
|
public:
|
|
TimeRange() = default;
|
|
TimeRange(const rational& in, const rational& out);
|
|
|
|
const rational& in() const;
|
|
const rational& out() const;
|
|
const rational& length() const;
|
|
|
|
void set_in(const rational& in);
|
|
void set_out(const rational& out);
|
|
void set_range(const rational& in, const rational& out);
|
|
|
|
bool operator==(const TimeRange& r) const;
|
|
|
|
bool OverlapsWith(const TimeRange& a) const;
|
|
TimeRange CombineWith(const TimeRange& a) const;
|
|
bool Contains(const TimeRange& a, bool inout_inclusive = true) const;
|
|
|
|
static bool Overlap(const TimeRange& a, const TimeRange& b);
|
|
static TimeRange Combine(const TimeRange &a, const TimeRange &b);
|
|
|
|
private:
|
|
void normalize();
|
|
|
|
rational in_;
|
|
rational out_;
|
|
rational length_;
|
|
};
|
|
|
|
uint qHash(const TimeRange& r, uint seed);
|
|
|
|
class TimeRangeList : public QList<TimeRange> {
|
|
public:
|
|
TimeRangeList() = default;
|
|
|
|
void InsertTimeRange(const TimeRange& range);
|
|
|
|
void RemoveTimeRange(const TimeRange& range);
|
|
|
|
bool ContainsTimeRange(const TimeRange& range) const;
|
|
|
|
};
|
|
|
|
#endif // TIMERANGE_H
|