Merge master; fix crash on new film.
[dcpomatic.git] / src / lib / types.h
1 /*
2     Copyright (C) 2013 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_TYPES_H
21 #define DCPOMATIC_TYPES_H
22
23 #include <vector>
24 #include <boost/shared_ptr.hpp>
25 #include <libdcp/util.h>
26
27 class Content;
28
29 typedef std::vector<boost::shared_ptr<Content> > ContentList;
30 typedef int64_t ContentAudioFrame;
31 typedef int ContentVideoFrame;
32
33 /** @struct Crop
34  *  @brief A description of the crop of an image or video.
35  */
36 struct Crop
37 {
38         Crop () : left (0), right (0), top (0), bottom (0) {}
39
40         /** Number of pixels to remove from the left-hand side */
41         int left;
42         /** Number of pixels to remove from the right-hand side */
43         int right;
44         /** Number of pixels to remove from the top */
45         int top;
46         /** Number of pixels to remove from the bottom */
47         int bottom;
48 };
49
50 extern bool operator== (Crop const & a, Crop const & b);
51 extern bool operator!= (Crop const & a, Crop const & b);
52
53 /** @struct Position
54  *  @brief A position.
55  */
56 struct Position
57 {
58         Position ()
59                 : x (0)
60                 , y (0)
61         {}
62
63         Position (int x_, int y_)
64                 : x (x_)
65                 , y (y_)
66         {}
67
68         /** x coordinate */
69         int x;
70         /** y coordinate */
71         int y;
72 };
73
74 /** @struct Rect
75  *  @brief A rectangle.
76  */
77 struct Rect
78 {
79         Rect ()
80                 : x (0)
81                 , y (0)
82                 , width (0)
83                 , height (0)
84         {}
85
86         Rect (int x_, int y_, int w_, int h_)
87                 : x (x_)
88                 , y (y_)
89                 , width (w_)
90                 , height (h_)
91         {}
92
93         int x;
94         int y;
95         int width;
96         int height;
97
98         Position position () const {
99                 return Position (x, y);
100         }
101
102         libdcp::Size size () const {
103                 return libdcp::Size (width, height);
104         }
105
106         Rect intersection (Rect const & other) const;
107 };
108
109 #endif