summaryrefslogtreecommitdiff
path: root/src/lib/video_content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-09-29 10:17:50 +0200
committerCarl Hetherington <cth@carlh.net>2022-10-03 17:53:41 +0200
commit380cda69c5806cd38906ae3bd144e71aa17c38f5 (patch)
tree56f1a2fc63011ef54b6ff55cb957679c9d008190 /src/lib/video_content.cc
parentf1263cd43ad761e63047baf7c674f5de04c0139c (diff)
Change how video timing is done.v2.17.0
This commit changes the approach with video timing. Previously, we would (more-or-less) try to use every video frame from the content in the output, hoping that they come at a constant frame rate. This is not always the case, however. Here we preserve the PTS of video frames, and then when one arrives we output whatever DCP video frames we can (at the regular DCP frame rate). Hopefully this will solve a range of sync problems, but it could also introduce new ones.
Diffstat (limited to 'src/lib/video_content.cc')
-rw-r--r--src/lib/video_content.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index 1d1d010a9..d173b4607 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -417,27 +417,29 @@ VideoContent::size_after_crop () const
}
-/** @param f Frame index within the whole (untrimmed) content.
+/** @param time Time within the whole (untrimmed) content.
* @return Fade factor (between 0 and 1) or unset if there is no fade.
*/
optional<double>
-VideoContent::fade (shared_ptr<const Film> film, Frame f) const
+VideoContent::fade(shared_ptr<const Film> film, ContentTime time) const
{
- DCPOMATIC_ASSERT (f >= 0);
+ DCPOMATIC_ASSERT(time.get() >= 0);
double const vfr = _parent->active_video_frame_rate(film);
- auto const ts = _parent->trim_start().frames_round(vfr);
- if ((f - ts) < fade_in()) {
- return double (f - ts) / fade_in();
+ auto const ts = _parent->trim_start();
+ auto const fade_in_time = ContentTime::from_frames(fade_in(), vfr);
+ if ((time - ts) < fade_in_time) {
+ return double(ContentTime(time - ts).get()) / fade_in_time.get();
}
- auto fade_out_start = length() - _parent->trim_end().frames_round(vfr) - fade_out();
- if (f >= fade_out_start) {
- return 1 - double (f - fade_out_start) / fade_out();
+ auto const fade_out_time = ContentTime::from_frames(fade_out(), vfr);
+ auto fade_out_start = ContentTime::from_frames(length(), vfr) - _parent->trim_end() - fade_out_time;
+ if (time >= fade_out_start) {
+ return 1 - double(ContentTime(time - fade_out_start).get()) / fade_out_time.get();
}
- return optional<double> ();
+ return {};
}
string