diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-07-14 12:43:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-07-14 12:43:08 +0100 |
| commit | a0614e6e3b566827381121fdb4ee73268281a70d (patch) | |
| tree | 97fb96cceb7c776a32775e7e5fde1769c9c837e6 /src | |
| parent | 8843d281ba06613fc92711d2ea824c35502be78e (diff) | |
Tests of Player::dcp_to_content_video, content_video_to_dcp and
dcp_to_content_audio with some subtle and hopefully reasonable
fixes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/audio_stream.h | 1 | ||||
| -rw-r--r-- | src/lib/player.cc | 17 | ||||
| -rw-r--r-- | src/lib/player.h | 5 |
3 files changed, 12 insertions, 11 deletions
diff --git a/src/lib/audio_stream.h b/src/lib/audio_stream.h index 3b236542c..506a3c02d 100644 --- a/src/lib/audio_stream.h +++ b/src/lib/audio_stream.h @@ -50,6 +50,7 @@ protected: private: friend struct audio_sampling_rate_test; + friend struct player_time_calculation_test3; int _frame_rate; AudioMapping _mapping; diff --git a/src/lib/player.cc b/src/lib/player.cc index ed4519aca..83131e200 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -464,10 +464,10 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) request = DCPTime (); } - Frame const content_frame = dcp_to_content_audio (*i, request); - BOOST_FOREACH (AudioStreamPtr j, content->audio_streams ()) { + Frame const content_frame = dcp_to_content_audio (*i, j, request); + if (j->channels() == 0) { /* Some content (e.g. DCPs) can have streams with no channels */ continue; @@ -521,13 +521,12 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) Frame 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 (); + DCPTime s = t - piece->content->position () + piece->content->trim_start (); 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 */ - return DCPTime (s + piece->content->trim_start()).frames (_film->video_frame_rate()) / piece->frc.factor (); + return s.frames (_film->video_frame_rate()) / piece->frc.factor (); } DCPTime @@ -542,15 +541,13 @@ Player::content_video_to_dcp (shared_ptr<const Piece> piece, Frame f) const } Frame -Player::dcp_to_content_audio (shared_ptr<const Piece> piece, DCPTime t) const +Player::dcp_to_content_audio (shared_ptr<const Piece> piece, AudioStreamPtr stream, DCPTime t) const { - /* s is the offset of t from the start position of this content */ - DCPTime s = t - piece->content->position (); + DCPTime s = t - piece->content->position () + piece->content->trim_start (); 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 */ - return DCPTime (s + piece->content->trim_start()).frames (_film->audio_frame_rate()); + return ContentTime (s, piece->frc).frames (stream->frame_rate ()); } ContentTime diff --git a/src/lib/player.h b/src/lib/player.h index 0abb02daa..9b2e27251 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -109,6 +109,9 @@ private: friend class PlayerWrapper; friend class Piece; friend struct player_overlaps_test; + friend struct player_time_calculation_test1; + friend struct player_time_calculation_test2; + friend struct player_time_calculation_test3; void setup_pieces (); void flush (); @@ -119,7 +122,7 @@ private: void update_subtitle_from_text (); Frame dcp_to_content_video (boost::shared_ptr<const Piece> piece, DCPTime t) const; DCPTime content_video_to_dcp (boost::shared_ptr<const Piece> piece, Frame f) const; - Frame dcp_to_content_audio (boost::shared_ptr<const Piece> piece, DCPTime t) const; + Frame dcp_to_content_audio (boost::shared_ptr<const Piece> piece, AudioStreamPtr stream, DCPTime t) const; ContentTime dcp_to_content_subtitle (boost::shared_ptr<const Piece> piece, DCPTime t) const; boost::shared_ptr<PlayerVideo> black_player_video_frame (DCPTime) const; |
