Merge branch '1.0' of git.carlh.net:git/libdcp into 1.0
[libdcp.git] / src / picture_asset.h
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp 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     libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
18
19     In addition, as a special exception, the copyright holders give
20     permission to link the code of portions of this program with the
21     OpenSSL library under certain conditions as described in each
22     individual source file, and distribute linked combinations
23     including the two.
24
25     You must obey the GNU General Public License in all respects
26     for all of the code used other than OpenSSL.  If you modify
27     file(s) with this exception, you may extend this exception to your
28     version of the file(s), but you are not obligated to do so.  If you
29     do not wish to do so, delete this exception statement from your
30     version.  If you delete this exception statement from all source
31     files in the program, then also delete it here.
32 */
33
34 #ifndef LIBDCP_PICTURE_ASSET_H
35 #define LIBDCP_PICTURE_ASSET_H
36
37 /** @file  src/picture_asset.h
38  *  @brief PictureAsset class.
39  */
40
41 #include "mxf.h"
42 #include "util.h"
43 #include "metadata.h"
44
45 namespace ASDCP {
46         namespace JP2K {
47                 struct PictureDescriptor;
48         }
49 }
50
51 namespace dcp
52 {
53
54 class MonoPictureFrame;
55 class StereoPictureFrame;
56 class PictureAssetWriter;
57
58 /** @class PictureAsset
59  *  @brief An asset made up of JPEG2000 data.
60  */
61 class PictureAsset : public Asset, public MXF
62 {
63 public:
64         explicit PictureAsset (boost::filesystem::path file);
65         explicit PictureAsset (Fraction edit_rate);
66
67         virtual boost::shared_ptr<PictureAssetWriter> start_write (
68                 boost::filesystem::path file,
69                 Standard standard,
70                 bool overwrite
71                 ) = 0;
72
73         Size size () const {
74                 return _size;
75         }
76
77         void set_size (Size s) {
78                 _size = s;
79         }
80
81         Fraction frame_rate () const {
82                 return _frame_rate;
83         }
84
85         void set_frame_rate (Fraction r) {
86                 _frame_rate = r;
87         }
88
89         Fraction screen_aspect_ratio () const {
90                 return _screen_aspect_ratio;
91         }
92
93         void set_screen_aspect_ratio (Fraction r) {
94                 _screen_aspect_ratio = r;
95         }
96
97         Fraction edit_rate () const {
98                 return _edit_rate;
99         }
100
101         int64_t intrinsic_duration () const {
102                 return _intrinsic_duration;
103         }
104
105 protected:
106         friend class MonoPictureAssetWriter;
107         friend class StereoPictureAssetWriter;
108
109         bool frame_buffer_equals (
110                 int frame, EqualityOptions opt, NoteHandler note,
111                 uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
112                 ) const;
113
114         bool descriptor_equals (
115                 ASDCP::JP2K::PictureDescriptor const & a,
116                 ASDCP::JP2K::PictureDescriptor const & b,
117                 NoteHandler note
118                 ) const;
119
120         void read_picture_descriptor (ASDCP::JP2K::PictureDescriptor const &);
121
122         Fraction _edit_rate;
123         /** The total length of this content in video frames.  The amount of
124          *  content presented may be less than this.
125          */
126         int64_t _intrinsic_duration;
127         /** picture size in pixels */
128         Size _size;
129         Fraction _frame_rate;
130         Fraction _screen_aspect_ratio;
131
132 private:
133         std::string pkl_type (Standard standard) const;
134 };
135
136
137 }
138
139 #endif