summaryrefslogtreecommitdiff
path: root/src/lib/player.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-10-29 18:40:48 +0000
committerCarl Hetherington <cth@carlh.net>2013-10-29 18:40:48 +0000
commit8053593f2ccff66287c43d20a8f28be9919bff75 (patch)
tree135be0576c45556f6b19b6746a9d9e0a1a957245 /src/lib/player.cc
parent8d31298c71df875d88e9f22061645d54309875eb (diff)
Seek past trim on setting up player pieces.
Diffstat (limited to 'src/lib/player.cc')
-rw-r--r--src/lib/player.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 8370a3f9f..53186af6e 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -102,7 +102,9 @@ public:
shared_ptr<Content> content;
shared_ptr<Decoder> decoder;
+ /** Time of the last video we emitted relative to the start of the DCP */
Time video_position;
+ /** Time of the last audio we emitted relative to the start of the DCP */
Time audio_position;
IncomingVideo repeat_video;
@@ -408,20 +410,19 @@ Player::seek (Time t, bool accurate)
if (!vc) {
continue;
}
-
+
+ /* s is the offset of t from the start position of this content */
Time s = t - vc->position ();
s = max (static_cast<Time> (0), s);
s = min (vc->length_after_trim(), s);
+ /* Hence set the piece positions to the `global' time */
(*i)->video_position = (*i)->audio_position = vc->position() + s;
- FrameRateConversion frc (vc->video_frame_rate(), _film->video_frame_rate());
- /* Here we are converting from time (in the DCP) to a frame number in the content.
- Hence we need to use the DCP's frame rate and the double/skip correction, not
- the source's rate.
- */
- VideoContent::Frame f = (s + vc->trim_start ()) * _film->video_frame_rate() / (frc.factor() * TIME_HZ);
- dynamic_pointer_cast<VideoDecoder>((*i)->decoder)->seek (f, accurate);
+ /* And seek the decoder */
+ dynamic_pointer_cast<VideoDecoder>((*i)->decoder)->seek (
+ vc->time_to_content_video_frames (s + vc->trim_start ()), accurate
+ );
(*i)->reset_repeat ();
}
@@ -455,6 +456,7 @@ Player::setup_pieces ()
fd->Audio.connect (bind (&Player::process_audio, this, piece, _1, _2));
fd->Subtitle.connect (bind (&Player::process_subtitle, this, piece, _1, _2, _3, _4));
+ fd->seek (fc->time_to_content_video_frames (fc->trim_start ()), true);
piece->decoder = fd;
}