2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 #ifndef LIBDCP_PICTURE_ASSET_H
21 #define LIBDCP_PICTURE_ASSET_H
23 /** @file src/picture_asset.h
24 * @brief An asset made up of JPEG2000 data
28 #include "mxf_asset.h"
35 class MonoPictureFrame;
36 class StereoPictureFrame;
37 class PictureAssetWriter;
39 /** @brief An asset made up of JPEG2000 data */
40 class PictureAsset : public MXFAsset
43 /** Construct a PictureAsset.
44 * This class will not write anything to disk in this constructor, but subclasses may.
46 * @param directory Directory where MXF file is.
47 * @param mxf_name Name of MXF file.
49 PictureAsset (std::string directory, std::string mxf_name);
51 /** Construct a PictureAsset.
52 * This class will not write anything to disk in this constructor, but subclasses may.
54 * @param directory Directory where MXF file is.
55 * @param mxf_name Name of MXF file.
56 * @param progress Signal to use to inform of progres, or 0.
57 * @param fps Video frames per second.
58 * @param intrinsic_duration Total number of frames in the asset.
59 * @param size Size of video frame images in pixels.
62 std::string directory,
64 boost::signals2::signal<void (float)>* progress,
66 int intrinsic_duration,
71 /** Start a progressive write to this asset.
72 * @param overwrite true to overwrite an existing MXF file; in this mode, writing can be resumed to a partially-written MXF; false if the
73 * MXF file does not exist.
74 * @param metadata MXF metadata to use.
76 virtual boost::shared_ptr<PictureAssetWriter> start_write (bool overwrite, bool interop, MXFMetadata const & metadata = MXFMetadata ()) = 0;
78 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
84 void write_to_cpl (xmlpp::Element *, bool) const;
88 bool frame_buffer_equals (
89 int frame, EqualityOptions opt, boost::function<void (NoteType, std::string)> note,
90 uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
93 /** picture size in pixels */
97 std::string key_type () const;
98 virtual int edit_rate_factor () const = 0;
101 /** A 2D (monoscopic) picture asset */
102 class MonoPictureAsset : public PictureAsset
105 /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
106 * This may take some time; progress is indicated by emission of the Progress signal.
108 * @param files Pathnames of JPEG2000 files, in frame order.
109 * @param directory Directory in which to create MXF file.
110 * @param mxf_name Name of MXF file to create.
111 * @param progress Signal to inform of progress.
112 * @param fps Video frames per second.
113 * @param intrinsic_duration Total number of frames in the asset.
114 * @param size Size of images in pixels.
115 * @param encrypted true if asset should be encrypted.
118 std::vector<std::string> const & files,
119 std::string directory,
120 std::string mxf_name,
121 boost::signals2::signal<void (float)>* progress,
123 int intrinsic_duration,
127 MXFMetadata const & metadata = MXFMetadata ()
130 /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
131 * This may take some time; progress is indicated by emission of the Progress signal.
133 * @param get_path Functor which returns a JPEG2000 file path for a given frame (frames counted from 0).
134 * @param directory Directory in which to create MXF file.
135 * @param mxf_name Name of MXF file to create.
136 * @param progress Signal to inform of progress.
137 * @param fps Video frames per second.
138 * @param intrinsic_duration Total number of frames in the asset.
139 * @param size Size of images in pixels.
140 * @param encrypted true if asset should be encrypted.
143 boost::function<std::string (int)> get_path,
144 std::string directory,
145 std::string mxf_name,
146 boost::signals2::signal<void (float)>* progress,
148 int intrinsic_duration,
152 MXFMetadata const & metadata = MXFMetadata ()
155 /** Construct a MonoPictureAsset, reading the MXF from disk.
156 * @param directory Directory that the MXF is in.
157 * @param mxf_name The filename of the MXF within `directory'.
159 MonoPictureAsset (std::string directory, std::string mxf_name);
161 /** Construct a MonoPictureAsset for progressive writing using
162 * start_write() and a MonoPictureAssetWriter.
164 * @param directory Directory to put the MXF in.
165 * @param mxf_name Filename of the MXF within this directory.
166 * @param fps Video frames per second.
167 * @param size Size in pixels that the picture frames will be.
169 MonoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size);
171 /** Start a progressive write to a MonoPictureAsset */
172 boost::shared_ptr<PictureAssetWriter> start_write (bool, bool, MXFMetadata const & metadata = MXFMetadata ());
174 boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
175 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
178 std::string path_from_list (int f, std::vector<std::string> const & files) const;
179 void construct (boost::function<std::string (int)>, bool, MXFMetadata const &);
180 std::string cpl_node_name () const;
181 int edit_rate_factor () const;
184 /** A 3D (stereoscopic) picture asset */
185 class StereoPictureAsset : public PictureAsset
188 StereoPictureAsset (std::string directory, std::string mxf_name, int fps, int intrinsic_duration);
190 /** Construct a StereoPictureAsset for progressive writing using
191 * start_write() and a StereoPictureAssetWriter.
193 * @param directory Directory to put the MXF in.
194 * @param mxf_name Filename of the MXF within this directory.
195 * @param fps Video frames per second.
196 * @param size Size in pixels that the picture frames will be.
198 StereoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size);
200 /** Start a progressive write to a StereoPictureAsset */
201 boost::shared_ptr<PictureAssetWriter> start_write (bool, bool, MXFMetadata const & metadata = MXFMetadata ());
203 boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
204 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
207 std::string cpl_node_name () const;
208 std::pair<std::string, std::string> cpl_node_attribute (bool) const;
209 int edit_rate_factor () const;