summaryrefslogtreecommitdiff
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
parent8d31298c71df875d88e9f22061645d54309875eb (diff)
Seek past trim on setting up player pieces.
-rw-r--r--ChangeLog3
-rw-r--r--src/lib/player.cc18
-rw-r--r--src/lib/video_content.cc20
-rw-r--r--src/lib/video_content.h2
4 files changed, 35 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index af3093205..3a3dffd12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2013-10-29 Carl Hetherington <cth@carlh.net>
+ * Improve performance when start-trimming
+ large files.
+
* Fix audio problems when start-trimming.
2013-10-28 Carl Hetherington <cth@carlh.net>
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;
}
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index 347836855..d0eab4dbf 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -26,6 +26,8 @@
#include "compose.hpp"
#include "config.h"
#include "colour_conversion.h"
+#include "util.h"
+#include "film.h"
#include "i18n.h"
@@ -289,3 +291,21 @@ VideoContent::video_size_after_crop () const
{
return crop().apply (video_size_after_3d_split ());
}
+
+/** @param t A time offset from the start of this piece of content.
+ * @return Corresponding frame index.
+ */
+VideoContent::Frame
+VideoContent::time_to_content_video_frames (Time t) const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ FrameRateConversion frc (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.
+ */
+ return t * film->video_frame_rate() / (frc.factor() * TIME_HZ);
+}
diff --git a/src/lib/video_content.h b/src/lib/video_content.h
index 369209776..6f80536fe 100644
--- a/src/lib/video_content.h
+++ b/src/lib/video_content.h
@@ -101,6 +101,8 @@ public:
libdcp::Size video_size_after_3d_split () const;
libdcp::Size video_size_after_crop () const;
+ VideoContent::Frame time_to_content_video_frames (Time) const;
+
protected:
void take_from_video_examiner (boost::shared_ptr<VideoExaminer>);