diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-09-29 10:17:50 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-10-04 01:10:48 +0200 |
| commit | fb2e821b36c4b50709f3a085131325b668d4ed57 (patch) | |
| tree | 009c675884993be8cd77c20080d3fc5b67f16956 /src/lib/video_content.cc | |
| parent | 95469c2bb15f490f7d3fbeaed9903bd0cbc13677 (diff) | |
Change how video timing is done.v2.17.1
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.cc | 22 |
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 |
