diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-07-01 14:13:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-07-01 14:13:10 +0100 |
| commit | 45e6a6df959188bfdb8dfc4906c35d1a3c234b0a (patch) | |
| tree | 4cb99aaf4d8ec3d2c6f157d5315887319de5c0d8 /src/lib | |
| parent | 05654d0e1799746a9df3ccab040c92e0ed825cac (diff) | |
Add a Type to Time.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dcpomatic_time.h | 22 | ||||
| -rw-r--r-- | src/lib/ffmpeg_examiner.cc | 2 | ||||
| -rw-r--r-- | src/lib/player.cc | 6 | ||||
| -rw-r--r-- | src/lib/sndfile_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/subrip_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/video_content.cc | 2 |
6 files changed, 19 insertions, 17 deletions
diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index 4afc9ab40..7f5379595 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -39,13 +39,15 @@ public: : _t (0) {} - explicit Time (int64_t t) + typedef int64_t Type; + + explicit Time (Type t) : _t (t) {} virtual ~Time () {} - int64_t get () const { + Type get () const { return _t; } @@ -97,7 +99,7 @@ public: protected: friend class dcptime_round_up_test; - int64_t _t; + Type _t; static const int HZ = 96000; }; @@ -107,8 +109,8 @@ class ContentTime : public Time { public: ContentTime () : Time () {} - explicit ContentTime (int64_t t) : Time (t) {} - ContentTime (int64_t n, int64_t d) : Time (n * HZ / d) {} + explicit ContentTime (Type t) : Time (t) {} + ContentTime (Type n, Type d) : Time (n * HZ / d) {} ContentTime (DCPTime d, FrameRateChange f); bool operator< (ContentTime const & o) const { @@ -162,8 +164,8 @@ public: * @param r Sampling rate. */ ContentTime round_up (float r) { - int64_t const n = rint (HZ / r); - int64_t const a = _t + n - 1; + Type const n = rint (HZ / r); + Type const a = _t + n - 1; return ContentTime (a - (a % n)); } @@ -207,7 +209,7 @@ class DCPTime : public Time { public: DCPTime () : Time () {} - explicit DCPTime (int64_t t) : Time (t) {} + explicit DCPTime (Type t) : Time (t) {} DCPTime (ContentTime t, FrameRateChange c) : Time (rint (t.get() / c.speed_up)) {} bool operator< (DCPTime const & o) const { @@ -261,8 +263,8 @@ public: * @param r Sampling rate. */ DCPTime round_up (float r) { - int64_t const n = rint (HZ / r); - int64_t const a = _t + n - 1; + Type const n = rint (HZ / r); + Type const a = _t + n - 1; return DCPTime (a - (a % n)); } diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 949062f5b..62b909b1d 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -177,7 +177,7 @@ ContentTime FFmpegExaminer::video_length () const { ContentTime const length = ContentTime::from_seconds (double (_format_context->duration - _format_context->start_time) / AV_TIME_BASE); - return ContentTime (max (int64_t (1), length.get ())); + return ContentTime (max (ContentTime::Type (1), length.get ())); } string diff --git a/src/lib/player.cc b/src/lib/player.cc index bb1a4cdeb..380133b61 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -501,7 +501,7 @@ Player::dcp_to_content_video (shared_ptr<const Piece> piece, DCPTime t) const { /* s is the offset of t from the start position of this content */ DCPTime s = t - piece->content->position (); - s = DCPTime (max (int64_t (0), s.get ())); + s = DCPTime (max (DCPTime::Type (0), s.get ())); s = DCPTime (min (piece->content->length_after_trim().get(), s.get())); /* Convert this to the content frame */ @@ -513,7 +513,7 @@ Player::dcp_to_content_audio (shared_ptr<const Piece> piece, DCPTime t) const { /* s is the offset of t from the start position of this content */ DCPTime s = t - piece->content->position (); - s = DCPTime (max (int64_t (0), s.get ())); + s = DCPTime (max (DCPTime::Type (0), s.get ())); s = DCPTime (min (piece->content->length_after_trim().get(), s.get())); /* Convert this to the content frame */ @@ -525,7 +525,7 @@ Player::dcp_to_content_subtitle (shared_ptr<const Piece> piece, DCPTime t) const { /* s is the offset of t from the start position of this content */ DCPTime s = t - piece->content->position (); - s = DCPTime (max (int64_t (0), s.get ())); + s = DCPTime (max (DCPTime::Type (0), s.get ())); s = DCPTime (min (piece->content->length_after_trim().get(), s.get())); return ContentTime (s + piece->content->trim_start(), piece->frc); diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index 37f205535..aab69f306 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -50,7 +50,7 @@ SndfileContent::SndfileContent (shared_ptr<const Film> f, cxml::ConstNodePtr nod , _audio_mapping (node->node_child ("AudioMapping"), version) { _audio_channels = node->number_child<int> ("AudioChannels"); - _audio_length = ContentTime (node->number_child<int64_t> ("AudioLength")); + _audio_length = ContentTime (node->number_child<ContentTime::Type> ("AudioLength")); _audio_frame_rate = node->number_child<int> ("AudioFrameRate"); } diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc index 892578ade..455bd1e8f 100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@ -42,7 +42,7 @@ SubRipContent::SubRipContent (shared_ptr<const Film> film, boost::filesystem::pa SubRipContent::SubRipContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version) : Content (film, node) , SubtitleContent (film, node, version) - , _length (node->number_child<int64_t> ("Length")) + , _length (node->number_child<DCPTime::Type> ("Length")) { } diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index f52a75e70..97e7915df 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -96,7 +96,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, i /* DCP-o-matic 1.0 branch */ _video_length = ContentTime::from_frames (node->number_child<int64_t> ("VideoLength"), _video_frame_rate); } else { - _video_length = ContentTime (node->number_child<int64_t> ("VideoLength")); + _video_length = ContentTime (node->number_child<ContentTime::Type> ("VideoLength")); } _video_frame_type = static_cast<VideoFrameType> (node->number_child<int> ("VideoFrameType")); |
