diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-17 19:44:58 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-17 19:44:58 +0000 |
| commit | 369ba52fe8b3ddeda734692541471c402016a18d (patch) | |
| tree | f140d572d97f1bb27d0713160247457c767cc101 | |
| parent | 62ee85a258aa9329544d8542dfbcc40ce8177a7a (diff) | |
Use new Size struct.
| -rw-r--r-- | examples/make_dcp.cc | 2 | ||||
| -rw-r--r-- | src/argb_frame.cc | 14 | ||||
| -rw-r--r-- | src/argb_frame.h | 14 | ||||
| -rw-r--r-- | src/picture_asset.cc | 24 | ||||
| -rw-r--r-- | src/picture_asset.h | 29 | ||||
| -rw-r--r-- | src/util.cc | 2 | ||||
| -rw-r--r-- | src/util.h | 23 | ||||
| -rw-r--r-- | test/tests.cc | 5 | ||||
| -rw-r--r-- | tools/dcpinfo.cc | 2 |
9 files changed, 57 insertions, 58 deletions
diff --git a/examples/make_dcp.cc b/examples/make_dcp.cc index 68e3f4f9..1f5c74a1 100644 --- a/examples/make_dcp.cc +++ b/examples/make_dcp.cc @@ -73,7 +73,7 @@ main () for 2K projectors. */ boost::shared_ptr<libdcp::MonoPictureAsset> picture_asset ( - new libdcp::MonoPictureAsset (video_frame, "My Film DCP", "video.mxf", 0, 24, 48, 1998, 1080) + new libdcp::MonoPictureAsset (video_frame, "My Film DCP", "video.mxf", 0, 24, 48, libdcp::Size (1998, 1080)) ); /* Now we will create a `sound asset', which is made up of a WAV file for each channel of audio. Here we're using diff --git a/src/argb_frame.cc b/src/argb_frame.cc index 8e54e3b4..a48f80bb 100644 --- a/src/argb_frame.cc +++ b/src/argb_frame.cc @@ -21,16 +21,14 @@ using namespace libdcp; -/** Construct an empty ARGBFrame with a given width and height and with +/** Construct an empty ARGBFrame of a given size and with * undefined contents. - * @param width Width in pixels. - * @param height Height in pixels. + * @param size Size in pixels. */ -ARGBFrame::ARGBFrame (int width, int height) - : _width (width) - , _height (height) +ARGBFrame::ARGBFrame (Size size) + : _size (size) { - _data = new uint8_t[width * height * 4]; + _data = new uint8_t[_size.width * _size.height * 4]; } @@ -43,5 +41,5 @@ ARGBFrame::~ARGBFrame () int ARGBFrame::stride () const { - return _width * 4; + return _size.width * 4; } diff --git a/src/argb_frame.h b/src/argb_frame.h index c5c35768..a9946bb0 100644 --- a/src/argb_frame.h +++ b/src/argb_frame.h @@ -22,6 +22,7 @@ */ #include <stdint.h> +#include "util.h" namespace libdcp { @@ -44,7 +45,7 @@ namespace libdcp class ARGBFrame { public: - ARGBFrame (int width, int height); + ARGBFrame (Size size); ~ARGBFrame (); uint8_t* data () const { @@ -54,17 +55,12 @@ public: /** Length of one picture row in bytes */ int stride () const; - int width () const { - return _width; - } - - int height () const { - return _height; + Size size () const { + return _size; } private: - int _width; - int _height; + Size _size; uint8_t* _data; }; diff --git a/src/picture_asset.cc b/src/picture_asset.cc index ef5d40d4..72c99bc6 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -48,8 +48,6 @@ using namespace libdcp; PictureAsset::PictureAsset (string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int entry_point, int length) : MXFAsset (directory, mxf_name, progress, fps, entry_point, length) - , _width (0) - , _height (0) { } @@ -65,7 +63,7 @@ PictureAsset::write_to_cpl (ostream& s) const << " <EntryPoint>0</EntryPoint>\n" << " <Duration>" << _length << "</Duration>\n" << " <FrameRate>" << _fps << " 1</FrameRate>\n" - << " <ScreenAspectRatio>" << _width << " " << _height << "</ScreenAspectRatio>\n" + << " <ScreenAspectRatio>" << _size.width << " " << _size.height << "</ScreenAspectRatio>\n" << " </MainPicture>\n"; } @@ -137,12 +135,10 @@ MonoPictureAsset::MonoPictureAsset ( boost::signals2::signal<void (float)>* progress, int fps, int length, - int width, - int height) + Size size) : PictureAsset (directory, mxf_name, progress, fps, 0, length) { - _width = width; - _height = height; + _size = size; construct (get_path); } @@ -153,12 +149,10 @@ MonoPictureAsset::MonoPictureAsset ( boost::signals2::signal<void (float)>* progress, int fps, int length, - int width, - int height) + Size size) : PictureAsset (directory, mxf_name, progress, fps, 0, length) { - _width = width; - _height = height; + _size = size; construct (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files)); } @@ -175,8 +169,8 @@ MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name, int fps, throw DCPReadError ("could not read video MXF information"); } - _width = desc.StoredWidth; - _height = desc.StoredHeight; + _size.width = desc.StoredWidth; + _size.height = desc.StoredHeight; } void @@ -375,8 +369,8 @@ StereoPictureAsset::StereoPictureAsset (string directory, string mxf_name, int f throw DCPReadError ("could not read video MXF information"); } - _width = desc.StoredWidth; - _height = desc.StoredHeight; + _size.width = desc.StoredWidth; + _size.height = desc.StoredHeight; } shared_ptr<const StereoPictureFrame> diff --git a/src/picture_asset.h b/src/picture_asset.h index 08eb338a..8bcd0173 100644 --- a/src/picture_asset.h +++ b/src/picture_asset.h @@ -23,6 +23,7 @@ #include <openjpeg.h> #include "mxf_asset.h" +#include "util.h" namespace libdcp { @@ -43,12 +44,8 @@ public: bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const; - int width () const { - return _width; - } - - int height () const { - return _height; + Size size () const { + return _size; } protected: @@ -57,11 +54,9 @@ protected: int frame, EqualityOptions opt, std::list<std::string>& notes, uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B ) const; - - /** picture width in pixels */ - int _width; - /** picture height in pixels */ - int _height; + + /** picture size in pixels */ + Size _size; }; /** A 2D (monoscopic) picture asset */ @@ -76,8 +71,7 @@ public: * @param progress Signal to inform of progress. * @param fps Frames per second. * @param length Length in frames. - * @param width Width of images in pixels. - * @param height Height of images in pixels. + * @param size Size of images in pixels. */ MonoPictureAsset ( std::vector<std::string> const & files, @@ -86,8 +80,7 @@ public: boost::signals2::signal<void (float)>* progress, int fps, int length, - int width, - int height + Size size ); /** Construct a PictureAsset, generating the MXF from the JPEG2000 files. @@ -98,8 +91,7 @@ public: * @param progress Signal to inform of progress. * @param fps Frames per second. * @param length Length in frames. - * @param width Width of images in pixels. - * @param height Height of images in pixels. + * @param size Size of images in pixels. */ MonoPictureAsset ( boost::function<std::string (int)> get_path, @@ -108,8 +100,7 @@ public: boost::signals2::signal<void (float)>* progress, int fps, int length, - int width, - int height + Size size ); MonoPictureAsset (std::string directory, std::string mxf_name, int fps, int entry_point, int length); diff --git a/src/util.cc b/src/util.cc index 6769cc41..4ddb466c 100644 --- a/src/util.cc +++ b/src/util.cc @@ -216,7 +216,7 @@ libdcp::xyz_to_rgb (opj_image_t* xyz_frame) int* xyz_y = xyz_frame->comps[1].data; int* xyz_z = xyz_frame->comps[2].data; - shared_ptr<ARGBFrame> argb_frame (new ARGBFrame (xyz_frame->x1, xyz_frame->y1)); + shared_ptr<ARGBFrame> argb_frame (new ARGBFrame (Size (xyz_frame->x1, xyz_frame->y1))); uint8_t* argb = argb_frame->data (); @@ -17,18 +17,37 @@ */ +#ifndef LIBDCP_UTIL_H +#define LIBDCP_UTIL_H + /** @file src/util.h * @brief Utility methods. */ #include <string> #include <stdint.h> +#include <boost/shared_ptr.hpp> #include <openjpeg.h> #include "types.h" namespace libdcp { -class ARGBFrame; +class ARGBFrame; + +struct Size { + Size () + : width (0) + , height (0) + {} + + Size (int w, int h) + : width (w) + , height (h) + {} + + int width; + int height; +}; extern std::string make_uuid (); extern std::string make_digest (std::string filename); @@ -39,3 +58,5 @@ extern opj_image_t* decompress_j2k (uint8_t* data, int64_t size, int reduce); extern boost::shared_ptr<ARGBFrame> xyz_to_rgb (opj_image_t* xyz_frame); } + +#endif diff --git a/test/tests.cc b/test/tests.cc index be960699..3fb56a28 100644 --- a/test/tests.cc +++ b/test/tests.cc @@ -75,8 +75,7 @@ BOOST_AUTO_TEST_CASE (dcp_test) &d.Progress, 24, 24, - 32, - 32 + libdcp::Size (32, 32) )); shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset ( @@ -102,7 +101,7 @@ BOOST_AUTO_TEST_CASE (error_test) vector<string> p; p.push_back ("frobozz"); - BOOST_CHECK_THROW (new libdcp::MonoPictureAsset (p, "build/test/bar", "video.mxf", &d.Progress, 24, 24, 32, 32), libdcp::FileError); + BOOST_CHECK_THROW (new libdcp::MonoPictureAsset (p, "build/test/bar", "video.mxf", &d.Progress, 24, 24, libdcp::Size (32, 32)), libdcp::FileError); BOOST_CHECK_THROW (new libdcp::SoundAsset (p, "build/test/bar", "audio.mxf", &d.Progress, 24, 24, 0), libdcp::FileError); } diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc index 0c4b9b1a..40e2be99 100644 --- a/tools/dcpinfo.cc +++ b/tools/dcpinfo.cc @@ -91,7 +91,7 @@ main (int argc, char* argv[]) cout << " Reel " << R << "\n"; if ((*j)->main_picture()) { - cout << " Picture: " << (*j)->main_picture()->width() << "x" << (*j)->main_picture()->height() << "\n"; + cout << " Picture: " << (*j)->main_picture()->size().width << "x" << (*j)->main_picture()->size().height << "\n"; } if ((*j)->main_sound()) { cout << " Sound: " << (*j)->main_sound()->channels() << " channels at " << (*j)->main_sound()->sampling_rate() << "Hz\n"; |
