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 /src | |
| parent | 62ee85a258aa9329544d8542dfbcc40ce8177a7a (diff) | |
Use new Size struct.
Diffstat (limited to 'src')
| -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 |
6 files changed, 53 insertions, 53 deletions
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 |
