summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2026-02-28 00:57:06 +0100
committerCarl Hetherington <cth@carlh.net>2026-02-28 09:07:06 +0100
commit5e11e66f63f10af97c8366bb76b3f1e2005753d5 (patch)
tree4571a7a3fce6284d4adb211aacfcb47409d084c8
parentcbe615367e5e137d909387aec7993fc89fe1905d (diff)
White space: dcpomatic_time.{cc,h}
-rw-r--r--src/lib/dcpomatic_time.cc34
-rw-r--r--src/lib/dcpomatic_time.h196
2 files changed, 115 insertions, 115 deletions
diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc
index 60fc5342a..c9c4e75a4 100644
--- a/src/lib/dcpomatic_time.cc
+++ b/src/lib/dcpomatic_time.cc
@@ -47,23 +47,23 @@ dcpomatic::operator<=(HMSF const& a, HMSF const& b)
template <>
-Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRateChange f)
- : _t (llrint(d.get() * f.speed_up))
+Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time(DCPTime d, FrameRateChange f)
+ : _t(llrint(d.get() * f.speed_up))
{
}
template <>
-Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time (ContentTime d, FrameRateChange f)
- : _t (llrint(d.get() / f.speed_up))
+Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time(ContentTime d, FrameRateChange f)
+ : _t(llrint(d.get() / f.speed_up))
{
}
DCPTime
-dcpomatic::min (DCPTime a, DCPTime b)
+dcpomatic::min(DCPTime a, DCPTime b)
{
if (a < b) {
return a;
@@ -74,7 +74,7 @@ dcpomatic::min (DCPTime a, DCPTime b)
DCPTime
-dcpomatic::max (DCPTime a, DCPTime b)
+dcpomatic::max(DCPTime a, DCPTime b)
{
if (a > b) {
return a;
@@ -85,7 +85,7 @@ dcpomatic::max (DCPTime a, DCPTime b)
ContentTime
-dcpomatic::min (ContentTime a, ContentTime b)
+dcpomatic::min(ContentTime a, ContentTime b)
{
if (a < b) {
return a;
@@ -96,7 +96,7 @@ dcpomatic::min (ContentTime a, ContentTime b)
ContentTime
-dcpomatic::max (ContentTime a, ContentTime b)
+dcpomatic::max(ContentTime a, ContentTime b)
{
if (a > b) {
return a;
@@ -107,39 +107,39 @@ dcpomatic::max (ContentTime a, ContentTime b)
string
-dcpomatic::to_string (ContentTime t)
+dcpomatic::to_string(ContentTime t)
{
char buffer[64];
#ifdef DCPOMATIC_WINDOWS
- __mingw_snprintf (buffer, sizeof(buffer), "[CONT %" PRId64 " %fs]", t.get(), t.seconds());
+ __mingw_snprintf(buffer, sizeof(buffer), "[CONT %" PRId64 " %fs]", t.get(), t.seconds());
#else
- snprintf (buffer, sizeof(buffer), "[CONT %" PRId64 " %fs]", t.get(), t.seconds());
+ snprintf(buffer, sizeof(buffer), "[CONT %" PRId64 " %fs]", t.get(), t.seconds());
#endif
return buffer;
}
string
-dcpomatic::to_string (DCPTime t)
+dcpomatic::to_string(DCPTime t)
{
char buffer[64];
#ifdef DCPOMATIC_WINDOWS
- __mingw_snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs]", t.get(), t.seconds());
+ __mingw_snprintf(buffer, sizeof(buffer), "[DCP %" PRId64 " %fs]", t.get(), t.seconds());
#else
- snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs]", t.get(), t.seconds());
+ snprintf(buffer, sizeof(buffer), "[DCP %" PRId64 " %fs]", t.get(), t.seconds());
#endif
return buffer;
}
string
-dcpomatic::to_string (DCPTimePeriod p)
+dcpomatic::to_string(DCPTimePeriod p)
{
char buffer[64];
#ifdef DCPOMATIC_WINDOWS
- __mingw_snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs -> %" PRId64 " %fs]", p.from.get(), p.from.seconds(), p.to.get(), p.to.seconds());
+ __mingw_snprintf(buffer, sizeof(buffer), "[DCP %" PRId64 " %fs -> %" PRId64 " %fs]", p.from.get(), p.from.seconds(), p.to.get(), p.to.seconds());
#else
- snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs -> %" PRId64 " %fs]", p.from.get(), p.from.seconds(), p.to.get(), p.to.seconds());
+ snprintf(buffer, sizeof(buffer), "[DCP %" PRId64 " %fs -> %" PRId64 " %fs]", p.from.get(), p.from.seconds(), p.to.get(), p.to.seconds());
#endif
return buffer;
}
diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h
index 6de576246..e137b48ae 100644
--- a/src/lib/dcpomatic_time.h
+++ b/src/lib/dcpomatic_time.h
@@ -49,9 +49,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_)
@@ -79,136 +79,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.
@@ -216,12 +216,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);
@@ -231,39 +231,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;
@@ -283,10 +283,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 */
@@ -298,11 +298,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 */
@@ -310,41 +310,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 {
- return (from <= other && other < to);
+ 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);
}
};
@@ -354,35 +354,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;
@@ -396,13 +396,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);
}