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 (boost::filesystem::path 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 boost::filesystem::path directory,
64 boost::signals2::signal<void (float)>* progress,
66 int intrinsic_duration,
70 /** Start a progressive write to this asset.
71 * @param overwrite true to overwrite an existing MXF file; in this mode, writing can be resumed to a partially-written MXF; false if the
72 * MXF file does not exist.
73 * @param metadata MXF metadata to use.
75 virtual boost::shared_ptr<PictureAssetWriter> start_write (bool overwrite, bool interop, MXFMetadata const & metadata = MXFMetadata ()) = 0;
77 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
83 void write_to_cpl (xmlpp::Element *, bool) const;
87 bool frame_buffer_equals (
88 int frame, EqualityOptions opt, boost::function<void (NoteType, std::string)> note,
89 uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
92 /** picture size in pixels */
96 std::string key_type () const;
97 virtual int edit_rate_factor () const = 0;
100 /** A 2D (monoscopic) picture asset */
101 class MonoPictureAsset : public PictureAsset
104 /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
105 * This may take some time; progress is indicated by emission of the Progress signal.
107 * @param files Pathnames of JPEG2000 files, in frame order.
108 * @param directory Directory in which to create MXF file.
109 * @param mxf_name Name of MXF file to create.
110 * @param progress Signal to inform of progress.
111 * @param fps Video frames per second.
112 * @param intrinsic_duration Total number of frames in the asset.
113 * @param size Size of images in pixels.
116 std::vector<boost::filesystem::path> const & files,
117 boost::filesystem::path directory,
118 std::string mxf_name,
119 boost::signals2::signal<void (float)>* progress,
121 int intrinsic_duration,
124 MXFMetadata const & metadata = MXFMetadata ()
127 /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
128 * This may take some time; progress is indicated by emission of the Progress signal.
130 * @param get_path Functor which returns a JPEG2000 file path for a given frame (frames counted from 0).
131 * @param directory Directory in which to create MXF file.
132 * @param mxf_name Name of MXF file to create.
133 * @param progress Signal to inform of progress.
134 * @param fps Video frames per second.
135 * @param intrinsic_duration Total number of frames in the asset.
136 * @param size Size of images in pixels.
139 boost::function<boost::filesystem::path (int)> get_path,
140 boost::filesystem::path directory,
141 std::string mxf_name,
142 boost::signals2::signal<void (float)>* progress,
144 int intrinsic_duration,
147 MXFMetadata const & metadata = MXFMetadata ()
150 /** Construct a MonoPictureAsset, reading the MXF from disk.
151 * @param directory Directory that the MXF is in.
152 * @param mxf_name The filename of the MXF within `directory'.
154 MonoPictureAsset (boost::filesystem::path directory, std::string mxf_name);
156 /** Construct a MonoPictureAsset for progressive writing using
157 * start_write() and a MonoPictureAssetWriter.
159 * @param directory Directory to put the MXF in.
160 * @param mxf_name Filename of the MXF within this directory.
161 * @param fps Video frames per second.
162 * @param size Size in pixels that the picture frames will be.
164 MonoPictureAsset (boost::filesystem::path directory, std::string mxf_name, int fps, Size size);
166 /** Start a progressive write to a MonoPictureAsset */
167 boost::shared_ptr<PictureAssetWriter> start_write (bool, bool, MXFMetadata const & metadata = MXFMetadata ());
169 boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
170 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
173 boost::filesystem::path path_from_list (int f, std::vector<boost::filesystem::path> const & files) const;
174 void construct (boost::function<boost::filesystem::path (int)>, bool, MXFMetadata const &);
175 std::string cpl_node_name () const;
176 int edit_rate_factor () const;
179 /** A 3D (stereoscopic) picture asset */
180 class StereoPictureAsset : public PictureAsset
183 StereoPictureAsset (boost::filesystem::path directory, std::string mxf_name, int fps, int intrinsic_duration);
185 /** Construct a StereoPictureAsset for progressive writing using
186 * start_write() and a StereoPictureAssetWriter.
188 * @param directory Directory to put the MXF in.
189 * @param mxf_name Filename of the MXF within this directory.
190 * @param fps Video frames per second.
191 * @param size Size in pixels that the picture frames will be.
193 StereoPictureAsset (boost::filesystem::path directory, std::string mxf_name, int fps, Size size);
195 /** Start a progressive write to a StereoPictureAsset */
196 boost::shared_ptr<PictureAssetWriter> start_write (bool, bool, MXFMetadata const & metadata = MXFMetadata ());
198 boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
199 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
202 std::string cpl_node_name () const;
203 std::pair<std::string, std::string> cpl_node_attribute (bool) const;
204 int edit_rate_factor () const;