X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcpomatic_time.h;h=3d792467b465d4a433b5425942018b0e7b06d78b;hb=422eb00b446d90e3588ae6793f676917ee195cca;hp=cc31755cb6c3e2f84d79ef62f7c20cb9640c8f3c;hpb=58dce923b9d438a27ce1cd7e3125370f74d46e3a;p=dcpomatic.git diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index cc31755cb..3d792467b 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2017 Carl Hetherington + Copyright (C) 2014-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -35,8 +35,6 @@ #include #include -class dcpomatic_round_up_test; - /** A time in seconds, expressed as a number scaled up by Time::HZ. We want two different * versions of this class, ContentTime and DCPTime, and we want it to be impossible to * convert implicitly between the two. Hence there's this template hack. I'm not @@ -119,12 +117,16 @@ public: * at some sampling rate. * @param r Sampling rate. */ - Time ceil (float r) const { - return Time (llrint (HZ * frames_ceil(r) / double(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 (float r) const { - return Time (llrint (HZ * frames_floor(r) / double(r))); + Time round (double r) const { + return Time (llrint (HZ * frames_round(r) / r)); } double seconds () const { @@ -158,7 +160,13 @@ public: return ::ceil (_t * double(r) / HZ); } - /** @param r Frames per second */ + /** Split a time into hours, minutes, seconds and frames. + * @param r Frames per second. + * @param h Returned hours. + * @param m Returned minutes. + * @param s Returned seconds. + * @param f Returned frames. + */ template void split (T r, int& h, int& m, int& s, int& f) const { @@ -214,8 +222,8 @@ public: } private: - friend struct dcptime_ceil_test; - friend struct dcptime_floor_test; + friend struct dcpomatic_time_ceil_test; + friend struct dcpomatic_time_floor_test; Type _t; static const int HZ = 96000; @@ -292,7 +300,9 @@ public: } }; -/** @param B Periods to subtract from `A', must be in ascending order of start time and must not overlap */ +/** @param A Period which is subtracted from. + * @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) {