From 5e11e66f63f10af97c8366bb76b3f1e2005753d5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 28 Feb 2026 00:57:06 +0100 Subject: White space: dcpomatic_time.{cc,h} --- src/lib/dcpomatic_time.cc | 34 ++++---- src/lib/dcpomatic_time.h | 196 +++++++++++++++++++++++----------------------- 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::Time (DCPTime d, FrameRateChange f) - : _t (llrint(d.get() * f.speed_up)) +Time::Time(DCPTime d, FrameRateChange f) + : _t(llrint(d.get() * f.speed_up)) { } template <> -Time::Time (ContentTime d, FrameRateChange f) - : _t (llrint(d.get() / f.speed_up)) +Time::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 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 d, FrameRateChange f); + Time(Time 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 const & o) const { + bool operator<(Time const & o) const { return _t < o._t; } - bool operator<= (Time const & o) const { + bool operator<=(Time const & o) const { return _t <= o._t; } - bool operator== (Time const & o) const { + bool operator==(Time const & o) const { return _t == o._t; } - bool operator!= (Time const & o) const { + bool operator!=(Time const & o) const { return _t != o._t; } - bool operator>= (Time const & o) const { + bool operator>=(Time const & o) const { return _t >= o._t; } - bool operator> (Time const & o) const { + bool operator>(Time const & o) const { return _t > o._t; } - Time operator+ (Time const & o) const { - return Time (_t + o._t); + Time operator+(Time const & o) const { + return Time(_t + o._t); } - Time & operator+= (Time const & o) { + Time & operator+=(Time const & o) { _t += o._t; return *this; } - Time operator- () const { - return Time (-_t); + Time operator-() const { + return Time(-_t); } - Time operator- (Time const & o) const { - return Time (_t - o._t); + Time operator-(Time const & o) const { + return Time(_t - o._t); } - Time & operator-= (Time const & o) { + Time & operator-=(Time const & o) { _t -= o._t; return *this; } - Time operator* (int o) const { - return Time (_t * o); + Time operator*(int o) const { + return Time(_t * o); } - Time operator/ (int o) const { - return Time (_t / o); + Time operator/(int o) const { + return Time(_t / o); } /** Round up to the nearest sampling interval * at some sampling rate. * @param r Sampling rate. */ - Time ceil (double r) const { - return Time (llrint(HZ * frames_ceil(r) / r)); + Time ceil(double r) const { + return Time(llrint(HZ * frames_ceil(r) / r)); } - Time floor (double r) const { - return Time (llrint(HZ * frames_floor(r) / r)); + Time floor(double r) const { + return Time(llrint(HZ * frames_floor(r) / r)); } - Time round (double r) const { - return Time (llrint(HZ * frames_round(r) / r)); + Time round(double r) const { + return Time(llrint(HZ * frames_round(r) / r)); } - double seconds () const { - return double (_t) / HZ; + double seconds() const { + return double(_t) / HZ; } - Time abs () const { - return Time (std::abs(_t)); + Time abs() const { + return Time(std::abs(_t)); } template - 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 - 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 - 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 - 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(hmsf.s) * r; - hmsf.f = static_cast (ff); + hmsf.f = static_cast(ff); return hmsf; } template - 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 from_seconds (double s) { - return Time (llrint (s * HZ)); + static Time from_seconds(double s) { + return Time(llrint(s * HZ)); } template - static Time from_frames (int64_t f, T r) { - DCPOMATIC_ASSERT (r > 0); - return Time (f * HZ / r); + static Time from_frames(int64_t f, T r) { + DCPOMATIC_ASSERT(r > 0); + return Time(f * HZ / r); } - static Time delta () { - return Time (1); + static Time delta() { + return Time(1); } - static Time min () { - return Time (-INT64_MAX); + static Time min() { + return Time(-INT64_MAX); } - static Time max () { - return Time (INT64_MAX); + static Time max() { + return Time(INT64_MAX); } static const int HZ = 96000; @@ -283,10 +283,10 @@ class DCPTimeDifferentiator {}; /* Specializations for the two allowed explicit conversions */ template<> -Time::Time (Time d, FrameRateChange f); +Time::Time(Time d, FrameRateChange f); template<> -Time::Time (Time d, FrameRateChange f); +Time::Time(Time 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 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 operator+ (T const & o) const { - return TimePeriod (from + o, to + o); + TimePeriod operator+(T const & o) const { + return TimePeriod(from + o, to + o); } - boost::optional> overlap (TimePeriod const & other) const { - T const max_from = std::max (from, other.from); - T const min_to = std::min (to, other.to); + boost::optional> overlap(TimePeriod 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 (max_from, min_to); + return TimePeriod(max_from, min_to); } bool contains (T const & other) const { - return (from <= other && other < to); + return(from <= other && other < to); } - bool operator< (TimePeriod const & o) const { + bool operator<(TimePeriod const & o) const { if (from != o.from) { return from < o.from; } return to < o.to; } - bool operator== (TimePeriod const & other) const { + bool operator==(TimePeriod const & other) const { return from == other.from && to == other.to; } - bool operator!= (TimePeriod const & other) const { + bool operator!=(TimePeriod 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 -std::list> subtract (TimePeriod A, std::list> const & B) +std::list> subtract(TimePeriod A, std::list> const & B) { std::list> result; - result.push_back (A); + result.push_back(A); for (auto i: B) { std::list> 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(j.from, i.from)); + new_result.push_back(TimePeriod(j.from, i.from)); } if (i.to != j.to) { - new_result.push_back (TimePeriod(i.to, j.to)); + new_result.push_back(TimePeriod(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(i.to, j.to)); + new_result.push_back(TimePeriod(i.to, j.to)); } else if (i.to > j.to) { /* B overlaps end of A */ - new_result.push_back (TimePeriod(j.from, i.from)); + new_result.push_back(TimePeriod(j.from, i.from)); } } else { - new_result.push_back (j); + new_result.push_back(j); } } result = new_result; @@ -396,13 +396,13 @@ typedef TimePeriod ContentTimePeriod; typedef TimePeriod 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); } -- cgit v1.2.3