summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2026-07-21 17:32:14 +0200
committerCarl Hetherington <cth@carlh.net>2026-07-21 17:32:14 +0200
commit9cb3479b8205b534e89175385b765f1e8b1cdf68 (patch)
tree74b7bfd74e98e73059c12d15f1f274c4855302dd
parent55085a7a7d269923f13981d7c2c5ca4f4f2adc08 (diff)
White space: dcpomatic_time.hHEADmain
-rw-r--r--src/lib/dcpomatic_time.h196
1 files changed, 98 insertions, 98 deletions
diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h
index 2adfef87b..b2e563cd6 100644
--- a/src/lib/dcpomatic_time.h
+++ b/src/lib/dcpomatic_time.h
@@ -47,9 +47,9 @@ namespace dcpomatic {
class HMSF
{
public:
- HMSF () {}
+ HMSF() {}
- HMSF (int h_, int m_, int s_, int f_)
+ HMSF(int h_, int m_, int s_, int f_)
: h(h_)
, m(m_)
, s(s_)
@@ -77,136 +77,136 @@ template <class S, class O>
class Time
{
public:
- Time ()
- : _t (0)
+ Time()
+ : _t(0)
{}
typedef int64_t Type;
- explicit Time (Type t)
- : _t (t)
+ explicit Time(Type t)
+ : _t(t)
{}
- explicit Time (Type n, Type d)
- : _t (n * HZ / d)
+ explicit Time(Type n, Type d)
+ : _t(n * HZ / d)
{}
/* Explicit conversion from type O */
- Time (Time<O, S> d, FrameRateChange f);
+ Time(Time<O, S> d, FrameRateChange f);
/** @param hmsf Hours, minutes, seconds, frames.
* @param fps Frame rate
*/
- Time (HMSF const& hmsf, float fps) {
- *this = from_seconds (hmsf.h * 3600)
- + from_seconds (hmsf.m * 60)
- + from_seconds (hmsf.s)
- + from_frames (hmsf.f, fps);
+ Time(HMSF const& hmsf, float fps) {
+ *this = from_seconds(hmsf.h * 3600)
+ + from_seconds(hmsf.m * 60)
+ + from_seconds(hmsf.s)
+ + from_frames(hmsf.f, fps);
}
- Type get () const {
+ Type get() const {
return _t;
}
- bool operator< (Time<S, O> const & o) const {
+ bool operator<(Time<S, O> const & o) const {
return _t < o._t;
}
- bool operator<= (Time<S, O> const & o) const {
+ bool operator<=(Time<S, O> const & o) const {
return _t <= o._t;
}
- bool operator== (Time<S, O> const & o) const {
+ bool operator==(Time<S, O> const & o) const {
return _t == o._t;
}
- bool operator!= (Time<S, O> const & o) const {
+ bool operator!=(Time<S, O> const & o) const {
return _t != o._t;
}
- bool operator>= (Time<S, O> const & o) const {
+ bool operator>=(Time<S, O> const & o) const {
return _t >= o._t;
}
- bool operator> (Time<S, O> const & o) const {
+ bool operator>(Time<S, O> const & o) const {
return _t > o._t;
}
- Time<S, O> operator+ (Time<S, O> const & o) const {
- return Time<S, O> (_t + o._t);
+ Time<S, O> operator+(Time<S, O> const & o) const {
+ return Time<S, O>(_t + o._t);
}
- Time<S, O> & operator+= (Time<S, O> const & o) {
+ Time<S, O> & operator+=(Time<S, O> const & o) {
_t += o._t;
return *this;
}
- Time<S, O> operator- () const {
- return Time<S, O> (-_t);
+ Time<S, O> operator-() const {
+ return Time<S, O>(-_t);
}
- Time<S, O> operator- (Time<S, O> const & o) const {
- return Time<S, O> (_t - o._t);
+ Time<S, O> operator-(Time<S, O> const & o) const {
+ return Time<S, O>(_t - o._t);
}
- Time<S, O> & operator-= (Time<S, O> const & o) {
+ Time<S, O> & operator-=(Time<S, O> const & o) {
_t -= o._t;
return *this;
}
- Time<S, O> operator* (int o) const {
- return Time<S, O> (_t * o);
+ Time<S, O> operator*(int o) const {
+ return Time<S, O>(_t * o);
}
- Time<S, O> operator/ (int o) const {
- return Time<S, O> (_t / o);
+ Time<S, O> operator/(int o) const {
+ return Time<S, O>(_t / o);
}
/** Round up to the nearest sampling interval
* at some sampling rate.
* @param r Sampling rate.
*/
- Time<S, O> ceil (double r) const {
- return Time<S, O> (llrint(HZ * frames_ceil(r) / r));
+ Time<S, O> ceil(double r) const {
+ return Time<S, O>(llrint(HZ * frames_ceil(r) / r));
}
- Time<S, O> floor (double r) const {
- return Time<S, O> (llrint(HZ * frames_floor(r) / r));
+ Time<S, O> floor(double r) const {
+ return Time<S, O>(llrint(HZ * frames_floor(r) / r));
}
- Time<S, O> round (double r) const {
- return Time<S, O> (llrint(HZ * frames_round(r) / r));
+ Time<S, O> round(double r) const {
+ return Time<S, O>(llrint(HZ * frames_round(r) / r));
}
- double seconds () const {
- return double (_t) / HZ;
+ double seconds() const {
+ return double(_t) / HZ;
}
- Time<S, O> abs () const {
- return Time<S, O> (std::abs(_t));
+ Time<S, O> abs() const {
+ return Time<S, O>(std::abs(_t));
}
template <typename T>
- int64_t frames_round (T r) const {
+ int64_t frames_round(T r) const {
/* We must cast to double here otherwise if T is integer
the calculation will round down before we get the chance
to llrint().
*/
- return llrint (_t * double(r) / HZ);
+ return llrint(_t * double(r) / HZ);
}
template <typename T>
- int64_t frames_floor (T r) const {
- return ::floor (_t * r / HZ);
+ int64_t frames_floor(T r) const {
+ return ::floor(_t * r / HZ);
}
template <typename T>
- int64_t frames_ceil (T r) const {
+ int64_t frames_ceil(T r) const {
/* We must cast to double here otherwise if T is integer
the calculation will round down before we get the chance
to ceil().
*/
- return ::ceil (_t * double(r) / HZ);
+ return ::ceil(_t * double(r) / HZ);
}
/** Split a time into hours, minutes, seconds and frames.
@@ -214,12 +214,12 @@ public:
* @return Split time.
*/
template <typename T>
- HMSF split (T r) const
+ HMSF split(T r) const
{
/* Do this calculation with frames so that we can round
to a frame boundary at the start rather than the end.
*/
- auto ff = frames_round (r);
+ auto ff = frames_round(r);
HMSF hmsf;
hmsf.h = ff / (3600 * r);
@@ -229,39 +229,39 @@ public:
hmsf.s = ff / r;
ff -= static_cast<int64_t>(hmsf.s) * r;
- hmsf.f = static_cast<int> (ff);
+ hmsf.f = static_cast<int>(ff);
return hmsf;
}
template <typename T>
- std::string timecode (T r) const {
- auto hmsf = split (r);
+ std::string timecode(T r) const {
+ auto hmsf = split(r);
char buffer[128];
- snprintf (buffer, sizeof(buffer), "%02d:%02d:%02d:%02d", hmsf.h, hmsf.m, hmsf.s, hmsf.f);
+ snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d:%02d", hmsf.h, hmsf.m, hmsf.s, hmsf.f);
return buffer;
}
- static Time<S, O> from_seconds (double s) {
- return Time<S, O> (llrint (s * HZ));
+ static Time<S, O> from_seconds(double s) {
+ return Time<S, O>(llrint(s * HZ));
}
template <class T>
- static Time<S, O> from_frames (int64_t f, T r) {
- DCPOMATIC_ASSERT (r > 0);
- return Time<S, O> (f * HZ / r);
+ static Time<S, O> from_frames(int64_t f, T r) {
+ DCPOMATIC_ASSERT(r > 0);
+ return Time<S, O>(f * HZ / r);
}
- static Time<S, O> delta () {
- return Time<S, O> (1);
+ static Time<S, O> delta() {
+ return Time<S, O>(1);
}
- static Time<S, O> min () {
- return Time<S, O> (-INT64_MAX);
+ static Time<S, O> min() {
+ return Time<S, O>(-INT64_MAX);
}
- static Time<S, O> max () {
- return Time<S, O> (INT64_MAX);
+ static Time<S, O> max() {
+ return Time<S, O>(INT64_MAX);
}
static const int HZ = 96000;
@@ -281,10 +281,10 @@ class DCPTimeDifferentiator {};
/* Specializations for the two allowed explicit conversions */
template<>
-Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (Time<DCPTimeDifferentiator, ContentTimeDifferentiator> d, FrameRateChange f);
+Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time(Time<DCPTimeDifferentiator, ContentTimeDifferentiator> d, FrameRateChange f);
template<>
-Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time (Time<ContentTimeDifferentiator, DCPTimeDifferentiator> d, FrameRateChange f);
+Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time(Time<ContentTimeDifferentiator, DCPTimeDifferentiator> d, FrameRateChange f);
/** Time relative to the start or position of a piece of content in its native frame rate */
@@ -296,11 +296,11 @@ template <class T>
class TimePeriod
{
public:
- TimePeriod () {}
+ TimePeriod() {}
- TimePeriod (T f, T t)
- : from (f)
- , to (t)
+ TimePeriod(T f, T t)
+ : from(f)
+ , to(t)
{}
/** start time of sampling interval that the period is from */
@@ -308,41 +308,41 @@ public:
/** start time of next sampling interval after the period */
T to;
- T duration () const {
+ T duration() const {
return to - from;
}
- TimePeriod<T> operator+ (T const & o) const {
- return TimePeriod<T> (from + o, to + o);
+ TimePeriod<T> operator+(T const & o) const {
+ return TimePeriod<T>(from + o, to + o);
}
- boost::optional<TimePeriod<T>> overlap (TimePeriod<T> const & other) const {
- T const max_from = std::max (from, other.from);
- T const min_to = std::min (to, other.to);
+ boost::optional<TimePeriod<T>> overlap(TimePeriod<T> const & other) const {
+ T const max_from = std::max(from, other.from);
+ T const min_to = std::min(to, other.to);
if (max_from >= min_to) {
return {};
}
- return TimePeriod<T> (max_from, min_to);
+ return TimePeriod<T>(max_from, min_to);
}
- bool contains (T const & other) const {
+ bool contains(T const & other) const {
return (from <= other && other < to);
}
- bool operator< (TimePeriod<T> const & o) const {
+ bool operator<(TimePeriod<T> const & o) const {
if (from != o.from) {
return from < o.from;
}
return to < o.to;
}
- bool operator== (TimePeriod<T> const & other) const {
+ bool operator==(TimePeriod<T> const & other) const {
return from == other.from && to == other.to;
}
- bool operator!= (TimePeriod<T> const & other) const {
+ bool operator!=(TimePeriod<T> const & other) const {
return !(*this == other);
}
};
@@ -352,35 +352,35 @@ public:
* @param B Periods to subtract from `A', must be in ascending order of start time and must not overlap.
*/
template <class T>
-std::list<TimePeriod<T>> subtract (TimePeriod<T> A, std::list<TimePeriod<T>> const & B)
+std::list<TimePeriod<T>> subtract(TimePeriod<T> A, std::list<TimePeriod<T>> const & B)
{
std::list<TimePeriod<T>> result;
- result.push_back (A);
+ result.push_back(A);
for (auto i: B) {
std::list<TimePeriod<T>> new_result;
for (auto j: result) {
- auto ov = i.overlap (j);
+ auto ov = i.overlap(j);
if (ov) {
if (*ov == i) {
/* A contains all of B */
if (i.from != j.from) {
- new_result.push_back (TimePeriod<T>(j.from, i.from));
+ new_result.push_back(TimePeriod<T>(j.from, i.from));
}
if (i.to != j.to) {
- new_result.push_back (TimePeriod<T>(i.to, j.to));
+ new_result.push_back(TimePeriod<T>(i.to, j.to));
}
} else if (*ov == j) {
/* B contains all of A */
} else if (i.from < j.from) {
/* B overlaps start of A */
- new_result.push_back (TimePeriod<T>(i.to, j.to));
+ new_result.push_back(TimePeriod<T>(i.to, j.to));
} else if (i.to > j.to) {
/* B overlaps end of A */
- new_result.push_back (TimePeriod<T>(j.from, i.from));
+ new_result.push_back(TimePeriod<T>(j.from, i.from));
}
} else {
- new_result.push_back (j);
+ new_result.push_back(j);
}
}
result = new_result;
@@ -394,13 +394,13 @@ typedef TimePeriod<ContentTime> ContentTimePeriod;
typedef TimePeriod<DCPTime> DCPTimePeriod;
-DCPTime min (DCPTime a, DCPTime b);
-DCPTime max (DCPTime a, DCPTime b);
-ContentTime min (ContentTime a, ContentTime b);
-ContentTime max (ContentTime a, ContentTime b);
-std::string to_string (ContentTime t);
-std::string to_string (DCPTime t);
-std::string to_string (DCPTimePeriod p);
+DCPTime min(DCPTime a, DCPTime b);
+DCPTime max(DCPTime a, DCPTime b);
+ContentTime min(ContentTime a, ContentTime b);
+ContentTime max(ContentTime a, ContentTime b);
+std::string to_string(ContentTime t);
+std::string to_string(DCPTime t);
+std::string to_string(DCPTimePeriod p);
}