Accessor for ClosedCaptionsDialog.
[dcpomatic.git] / src / lib / frame_rate_change.h
1 /*
2     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #ifndef DCPOMATIC_FRAME_RATE_CHANGE_H
22 #define DCPOMATIC_FRAME_RATE_CHANGE_H
23
24 #include <boost/shared_ptr.hpp>
25 #include <string>
26
27 class Film;
28 class Content;
29
30 class FrameRateChange
31 {
32 public:
33         FrameRateChange ();
34         FrameRateChange (double, int);
35         FrameRateChange (boost::shared_ptr<const Film> film, boost::shared_ptr<const Content> content);
36         FrameRateChange (boost::shared_ptr<const Film> film, Content const * content);
37
38         /** @return factor by which to multiply a source frame rate
39             to get the effective rate after any skip or repeat has happened.
40         */
41         double factor () const {
42                 if (skip) {
43                         return 0.5;
44                 }
45
46                 return repeat;
47         }
48
49         double source;
50         int dcp;
51
52         /** true to skip every other frame */
53         bool skip;
54         /** number of times to use each frame (e.g. 1 is normal, 2 means repeat each frame once, and so on) */
55         int repeat;
56         /** true if this DCP will run its video faster or slower than the source
57          *  without taking into account `repeat' nor `skip'.
58          *  (e.g. change_speed will be true if
59          *          source is 29.97fps, DCP is 30fps
60          *          source is 14.50fps, DCP is 30fps
61          *  but not if
62          *          source is 15.00fps, DCP is 30fps
63          *          source is 12.50fps, DCP is 25fps)
64          */
65         bool change_speed;
66
67         /** Amount by which the video is being sped-up in the DCP; e.g. for a
68          *  24fps source in a 25fps DCP this would be 25/24.
69          */
70         double speed_up;
71
72         std::string description () const;
73
74 private:
75         void construct (double source_, int dcp_);
76 };
77
78 #endif