Logging improvements to allow prettier displays in the server GUI.
[dcpomatic.git] / src / lib / frame_rate_change.h
1 /*
2     Copyright (C) 2012-2015 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 #ifndef DCPOMATIC_FRAME_RATE_CHANGE_H
21 #define DCPOMATIC_FRAME_RATE_CHANGE_H
22
23 #include <string>
24
25 struct FrameRateChange
26 {
27         FrameRateChange (double, int);
28
29         /** @return factor by which to multiply a source frame rate
30             to get the effective rate after any skip or repeat has happened.
31         */
32         double factor () const {
33                 if (skip) {
34                         return 0.5;
35                 }
36
37                 return repeat;
38         }
39
40         double source;
41         int dcp;
42
43         /** true to skip every other frame */
44         bool skip;
45         /** number of times to use each frame (e.g. 1 is normal, 2 means repeat each frame once, and so on) */
46         int repeat;
47         /** true if this DCP will run its video faster or slower than the source
48          *  without taking into account `repeat' nor `skip'.
49          *  (e.g. change_speed will be true if
50          *          source is 29.97fps, DCP is 30fps
51          *          source is 14.50fps, DCP is 30fps
52          *  but not if
53          *          source is 15.00fps, DCP is 30fps
54          *          source is 12.50fps, DCP is 25fps)
55          */
56         bool change_speed;
57
58         /** Amount by which the video is being sped-up in the DCP; e.g. for a
59          *  24fps source in a 25fps DCP this would be 25/24.
60          */
61         double speed_up;
62
63         std::string description () const;
64 };
65
66 #endif