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 files
28 #include "mxf_asset.h"
35 class MonoPictureFrame;
36 class StereoPictureFrame;
37 class MonoPictureAssetWriter;
38 class StereoPictureAssetWriter;
40 /** @brief An asset made up of JPEG2000 files */
41 class PictureAsset : public MXFAsset
44 /** Construct a PictureAsset.
45 * This class will not write anything to disk in this constructor, but subclasses may.
47 * @param directory Directory where MXF file is.
48 * @param mxf_name Name of MXF file.
50 PictureAsset (std::string directory, std::string mxf_name);
52 /** Construct a PictureAsset.
53 * This class will not write anything to disk in this constructor, but subclasses may.
55 * @param directory Directory where MXF file is.
56 * @param mxf_name Name of MXF file.
57 * @param progress Signal to use to inform of progres, or 0.
58 * @param fps Video Frames per second.
59 * @param intrinsic_duration Duration of all the frames in the asset.
60 * @param size Size of video frame images in pixels.
62 PictureAsset (std::string directory, std::string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int intrinsic_duration, bool encrypted, Size);
64 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
70 void write_to_cpl (xmlpp::Node *) const;
74 bool frame_buffer_equals (
75 int frame, EqualityOptions opt, boost::function<void (NoteType, std::string)> note,
76 uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
79 /** picture size in pixels */
83 std::string key_type () const;
84 std::string cpl_node_name () const;
87 class MonoPictureAsset;
90 /** A 2D (monoscopic) picture asset */
91 class MonoPictureAsset : public PictureAsset
94 /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
95 * This may take some time; progress is indicated by emission of the Progress signal.
97 * @param files Pathnames of JPEG2000 files, in frame order.
98 * @param directory Directory in which to create MXF file.
99 * @param mxf_name Name of MXF file to create.
100 * @param progress Signal to inform of progress.
101 * @param fps Video frames per second.
102 * @param intrinsic_duration Length of the whole asset in frames.
103 * @param size Size of images in pixels.
104 * @param encrypted true if asset should be encrypted.
107 std::vector<std::string> const & files,
108 std::string directory,
109 std::string mxf_name,
110 boost::signals2::signal<void (float)>* progress,
112 int intrinsic_duration,
115 MXFMetadata const & metadata = MXFMetadata ()
118 /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
119 * This may take some time; progress is indicated by emission of the Progress signal.
121 * @param get_path Functor which returns a JPEG2000 file path for a given frame (frames counted from 0).
122 * @param directory Directory in which to create MXF file.
123 * @param mxf_name Name of MXF file to create.
124 * @param progress Signal to inform of progress.
125 * @param fps Video frames per second.
126 * @param intrinsic_duration Length of the whole asset in frames.
127 * @param size Size of images in pixels.
128 * @param encrypted true if asset should be encrypted.
131 boost::function<std::string (int)> get_path,
132 std::string directory,
133 std::string mxf_name,
134 boost::signals2::signal<void (float)>* progress,
136 int intrinsic_duration,
139 MXFMetadata const & metadata = MXFMetadata ()
142 /** Construct a MonoPictureAsset, reading the MXF from disk.
143 * @param directory Directory that the MXF is in.
144 * @param mxf_name The filename of the MXF within `directory'.
146 MonoPictureAsset (std::string directory, std::string mxf_name);
148 /** Construct a MonoPictureAsset for progressive writing using
149 * start_write() and a MonoPictureAssetWriter.
151 * @param directory Directory to put the MXF in.
152 * @param mxf_name Filename of the MXF within this directory.
153 * @param fps Video frames per second.
154 * @param size Size in pixels that the picture frames will be.
156 MonoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size);
158 /** Start a progressive write to a MonoPictureAsset */
159 boost::shared_ptr<MonoPictureAssetWriter> start_write (bool, MXFMetadata const & metadata = MXFMetadata ());
161 boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
162 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
165 std::string path_from_list (int f, std::vector<std::string> const & files) const;
166 void construct (boost::function<std::string (int)>, MXFMetadata const &);
169 /** A 3D (stereoscopic) picture asset */
170 class StereoPictureAsset : public PictureAsset
173 StereoPictureAsset (std::string directory, std::string mxf_name, int fps, int intrinsic_duration);
175 /** Construct a StereoPictureAsset for progressive writing using
176 * start_write() and a StereoPictureAssetWriter.
178 * @param directory Directory to put the MXF in.
179 * @param mxf_name Filename of the MXF within this directory.
180 * @param fps Video frames per second.
181 * @param size Size in pixels that the picture frames will be.
183 StereoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size);
185 /** Start a progressive write to a StereoPictureAsset */
186 boost::shared_ptr<StereoPictureAssetWriter> start_write (bool, MXFMetadata const & metadata = MXFMetadata ());
188 boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
189 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;