2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3 Taken from code Copyright (C) 2010-2011 Terrence Meiczinger
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /** @file src/dcp_video_frame.h
25 * @brief A single frame of video destined for a DCP.
30 class ServerDescription;
36 /** @class EncodedData
37 * @brief Container for J2K-encoded data.
42 /** @param s Size of data, in bytes.
46 virtual ~EncodedData ();
48 void send (boost::shared_ptr<Socket> socket);
49 void write (boost::shared_ptr<const Film>, int);
52 uint8_t* data () const {
56 /** @return data size, in bytes */
62 uint8_t* _data; ///< data
63 int _size; ///< data size in bytes
66 /* No copy construction */
67 EncodedData (EncodedData const &);
70 /** @class LocallyEncodedData
71 * @brief EncodedData that was encoded locally; this class
72 * just keeps a pointer to the data, but does no memory
75 class LocallyEncodedData : public EncodedData
78 /** @param d Data (which will be copied by this class)
79 * @param s Size of data, in bytes.
81 LocallyEncodedData (uint8_t* d, int s);
84 /** @class RemotelyEncodedData
85 * @brief EncodedData that is being read from a remote server;
86 * this class allocates and manages memory for the data.
88 class RemotelyEncodedData : public EncodedData
91 RemotelyEncodedData (int s);
94 /** @class DCPVideoFrame
95 * @brief A single frame of video destined for a DCP.
97 * Given an Image and some settings, this class knows how to encode
98 * the image to J2K either on the local host or on a remote server.
100 * Objects of this class are used for the queue that we keep
101 * of images that require encoding.
107 boost::shared_ptr<const Image>, boost::shared_ptr<Subtitle>, libdcp::Size,
108 int, int, float, Scaler const *, int, float, std::string, int, int, Log *
111 virtual ~DCPVideoFrame ();
113 boost::shared_ptr<EncodedData> encode_locally ();
114 boost::shared_ptr<EncodedData> encode_remotely (ServerDescription const *);
121 void create_openjpeg_container ();
123 boost::shared_ptr<const Image> _input; ///< the input image
124 boost::shared_ptr<Subtitle> _subtitle; ///< any subtitle that should be on the image
125 libdcp::Size _out_size; ///< the required size of the output, in pixels
127 int _subtitle_offset;
128 float _subtitle_scale;
129 Scaler const * _scaler; ///< scaler to use
130 int _frame; ///< frame index within the DCP's intrinsic duration
131 int _frames_per_second; ///< Frames per second that we will use for the DCP (rounded)
132 std::string _post_process; ///< FFmpeg post-processing string to use
133 int _colour_lut; ///< Colour look-up table to use
134 int _j2k_bandwidth; ///< J2K bandwidth to use
138 opj_image_cmptparm_t _cmptparm[3]; ///< libopenjpeg's opj_image_cmptparm_t
139 opj_image* _image; ///< libopenjpeg's image container
140 opj_cparameters_t* _parameters; ///< libopenjpeg's parameters
141 opj_cinfo_t* _cinfo; ///< libopenjpeg's opj_cinfo_t
142 opj_cio_t* _cio; ///< libopenjpeg's opj_cio_t