Merge branch 'master' into 1.0
[libdcp.git] / src / picture_mxf.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 #ifndef LIBDCP_PICTURE_MXF_H
21 #define LIBDCP_PICTURE_MXF_H
22
23 /** @file  src/picture_mxf.h
24  *  @brief PictureMXF class.
25  */
26
27 #include "mxf.h"
28 #include "util.h"
29 #include "metadata.h"
30 #include <openjpeg.h>
31
32 namespace ASDCP {
33         namespace JP2K {
34                 class PictureDescriptor;
35         }
36 }
37
38 namespace dcp
39 {
40
41 class MonoPictureFrame; 
42 class StereoPictureFrame;
43 class PictureMXFWriter;
44
45 /** @class PictureMXF
46  *  @brief An asset made up of JPEG2000 data.
47  */
48 class PictureMXF : public MXF
49 {
50 public:
51         PictureMXF (boost::filesystem::path file);
52         PictureMXF (Fraction edit_rate);
53
54         virtual boost::shared_ptr<PictureMXFWriter> start_write (
55                 boost::filesystem::path file,
56                 Standard standard,
57                 bool overwrite
58                 ) = 0;
59
60         Size size () const {
61                 return _size;
62         }
63
64         void set_size (Size s) {
65                 _size = s;
66         }
67
68         Fraction frame_rate () const {
69                 return _frame_rate;
70         }
71
72         void set_frame_rate (Fraction r) {
73                 _frame_rate = r;
74         }
75
76         Fraction screen_aspect_ratio () const {
77                 return _screen_aspect_ratio;
78         }
79
80         void set_screen_aspect_ratio (Fraction r) {
81                 _screen_aspect_ratio = r;
82         }
83
84 protected:
85
86         bool frame_buffer_equals (
87                 int frame, EqualityOptions opt, boost::function<void (NoteType, std::string)> note,
88                 uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
89                 ) const;
90
91         bool descriptor_equals (
92                 ASDCP::JP2K::PictureDescriptor const & a,
93                 ASDCP::JP2K::PictureDescriptor const & b,
94                 boost::function<void (NoteType, std::string)>
95                 ) const;
96
97         void read_picture_descriptor (ASDCP::JP2K::PictureDescriptor const &);
98
99         /** picture size in pixels */
100         Size _size;
101         Fraction _frame_rate;
102         Fraction _screen_aspect_ratio;
103
104 private:
105         std::string key_type () const;
106         std::string asdcp_kind () const {
107                 return "Picture";
108         }
109 };
110         
111
112 }
113
114 #endif