diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-06-23 00:23:58 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-06-23 00:23:58 +0200 |
| commit | ade7cc821117c2c81321a6503bbef3bac61d6fa1 (patch) | |
| tree | 4176d11463d0c95768bfa96150d053de39f0ce56 | |
| parent | c7dbc5b9e7cd5e7d54b9e46b3db38fae8edad030 (diff) | |
Move two methods into Piece.
| -rw-r--r-- | src/lib/piece.cc | 21 | ||||
| -rw-r--r-- | src/lib/piece.h | 3 | ||||
| -rw-r--r-- | src/lib/player.cc | 23 | ||||
| -rw-r--r-- | src/lib/player.h | 2 |
4 files changed, 27 insertions, 22 deletions
diff --git a/src/lib/piece.cc b/src/lib/piece.cc index f3adc0aef..57e00334b 100644 --- a/src/lib/piece.cc +++ b/src/lib/piece.cc @@ -18,6 +18,8 @@ */ + +#include "film.h" #include "piece.h" @@ -67,3 +69,22 @@ Piece::video_crop () const return content->video->crop (); } + +DCPTime +Piece::resampled_audio_to_dcp (shared_ptr<const Film> film, Frame f) const +{ + /* See notes in content_video_to_dcp */ + return DCPTime::from_frames(f, film->audio_frame_rate()) + - DCPTime(content->trim_start(), frc) + + position(); +} + + +ContentTime +Piece::dcp_to_content_time (shared_ptr<const Film> film, DCPTime t) const +{ + DCPTime s = t - position(); + s = min(content->length_after_trim(film), s); + return max(ContentTime(), ContentTime(s, frc) + content->trim_start()); +} + diff --git a/src/lib/piece.h b/src/lib/piece.h index f6bf4b1b6..aa67316f1 100644 --- a/src/lib/piece.h +++ b/src/lib/piece.h @@ -44,6 +44,9 @@ public: dcpomatic::DCPTime end (boost::shared_ptr<const Film> film) const; dcpomatic::DCPTime content_video_to_dcp (Frame f) const; dcpomatic::DCPTime content_time_to_dcp (dcpomatic::ContentTime t) const; + dcpomatic::DCPTime resampled_audio_to_dcp (boost::shared_ptr<const Film> film, Frame f) const; + dcpomatic::ContentTime dcp_to_content_time (boost::shared_ptr<const Film> film, dcpomatic::DCPTime t) const; + Crop video_crop () const; boost::shared_ptr<Content> content; diff --git a/src/lib/player.cc b/src/lib/player.cc index 62b900459..9630e6a9c 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -379,23 +379,6 @@ Player::black_player_video_frame (Eyes eyes) const } -DCPTime -Player::resampled_audio_to_dcp (shared_ptr<const Piece> piece, Frame f) const -{ - /* See notes in content_video_to_dcp */ - return DCPTime::from_frames (f, _film->audio_frame_rate()) - - DCPTime (piece->content->trim_start(), piece->frc) - + piece->position(); -} - -ContentTime -Player::dcp_to_content_time (shared_ptr<const Piece> piece, DCPTime t) const -{ - DCPTime s = t - piece->position (); - s = min (piece->content->length_after_trim(_film), s); - return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start()); -} - list<shared_ptr<Font> > Player::get_subtitle_fonts () { @@ -871,7 +854,7 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a int const rfr = content->resampled_frame_rate (_film); /* Compute time in the DCP */ - DCPTime time = resampled_audio_to_dcp (piece, content_audio.frame); + DCPTime time = piece->resampled_audio_to_dcp (_film, content_audio.frame); /* And the end of this block in the DCP */ DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), rfr); @@ -1067,11 +1050,11 @@ Player::seek (DCPTime time, bool accurate) content we may not start right at the beginning of the next, causing a gap (if the next content has been trimmed to a point between keyframes, or something). */ - i->decoder->seek (dcp_to_content_time (i, i->content->position()), true); + i->decoder->seek (i->dcp_to_content_time(_film, i->content->position()), true); i->done = false; } else if (i->content->position() <= time && time < i->end(_film)) { /* During; seek to position */ - i->decoder->seek (dcp_to_content_time (i, time), accurate); + i->decoder->seek (i->dcp_to_content_time(_film, time), accurate); i->done = false; } else { /* After; this piece is done */ diff --git a/src/lib/player.h b/src/lib/player.h index 871f58959..dbd5cdf69 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -126,8 +126,6 @@ private: void film_change (ChangeType, Film::Property); void playlist_change (ChangeType); void playlist_content_change (ChangeType, int, bool); - dcpomatic::DCPTime resampled_audio_to_dcp (boost::shared_ptr<const Piece> piece, Frame f) const; - dcpomatic::ContentTime dcp_to_content_time (boost::shared_ptr<const Piece> piece, dcpomatic::DCPTime t) const; boost::shared_ptr<PlayerVideo> black_player_video_frame (Eyes eyes) const; void video (boost::weak_ptr<Piece>, ContentVideo); |
