2 Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "compose.hpp"
25 #include "frame_rate_change.h"
32 using std::shared_ptr;
36 FrameRateChange::FrameRateChange ()
42 FrameRateChange::FrameRateChange (double source_, int dcp_)
47 if (fabs(source / 2.0 - dcp) < fabs(source - dcp)) {
48 /* The difference between source and DCP frame rate will be lower
49 (i.e. better) if we skip.
52 } else if (fabs(source * 2 - dcp) < fabs(source - dcp)) {
53 /* The difference between source and DCP frame rate would be better
54 if we repeated each frame once; it may be better still if we
55 repeated more than once. Work out the required repeat.
57 repeat = round (dcp / source);
60 speed_up = dcp / (source * factor());
62 auto about_equal = [](double a, double b) {
63 return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON);
66 change_speed = !about_equal (speed_up, 1.0);
70 FrameRateChange::FrameRateChange (shared_ptr<const Film> film, shared_ptr<const Content> content)
71 : FrameRateChange (content->active_video_frame_rate(film), film->video_frame_rate())
77 FrameRateChange::FrameRateChange (shared_ptr<const Film> film, Content const * content)
78 : FrameRateChange (content->active_video_frame_rate(film), film->video_frame_rate())
85 FrameRateChange::description () const
89 if (!skip && repeat == 1 && !change_speed) {
90 description = _("Content and DCP have the same rate.\n");
93 description = _("DCP will use every other frame of the content.\n");
94 } else if (repeat == 2) {
95 description = _("Each content frame will be doubled in the DCP.\n");
96 } else if (repeat > 2) {
97 description = String::compose (_("Each content frame will be repeated %1 more times in the DCP.\n"), repeat - 1);
101 double const pc = dcp * 100 / (source * factor());
103 snprintf (buffer, sizeof(buffer), _("DCP will run at %.1f%% of the content speed.\n"), pc);
104 description += buffer;