Merge master.
[dcpomatic.git] / src / lib / frame_rate_change.h
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <string>
21
22 struct FrameRateChange
23 {
24         FrameRateChange (float, int);
25
26         /** @return factor by which to multiply a source frame rate
27             to get the effective rate after any skip or repeat has happened.
28         */
29         float factor () const {
30                 if (skip) {
31                         return 0.5;
32                 }
33
34                 return repeat;
35         }
36
37         /** true to skip every other frame */
38         bool skip;
39         /** number of times to use each frame (e.g. 1 is normal, 2 means repeat each frame once, and so on) */
40         int repeat;
41         /** true if this DCP will run its video faster or slower than the source
42          *  without taking into account `repeat' nor `skip'.
43          *  (e.g. change_speed will be true if
44          *          source is 29.97fps, DCP is 30fps
45          *          source is 14.50fps, DCP is 30fps
46          *  but not if
47          *          source is 15.00fps, DCP is 30fps
48          *          source is 12.50fps, DCP is 25fps)
49          */
50         bool change_speed;
51
52         /** Amount by which the video is being sped-up in the DCP; e.g. for a
53          *  24fps source in a 25fps DCP this would be 25/24.
54          */
55         float speed_up;
56
57         std::string description;
58 };