diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-28 16:12:44 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-28 16:12:44 +0100 |
| commit | 706201707778567317c0d023b04be9836fbf77bf (patch) | |
| tree | 8afa5ba0364bcb6dd7c1e80b6e7d13d8e0d3bbb9 /src/lib | |
| parent | d35fa85babb471650e3f5fa7c11b2149c1db91c1 (diff) | |
Remove DCP-specialism from Container and add tests for it.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/container.cc | 43 | ||||
| -rw-r--r-- | src/lib/container.h | 22 | ||||
| -rw-r--r-- | src/lib/encoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 6 | ||||
| -rw-r--r-- | src/lib/film.h | 2 | ||||
| -rw-r--r-- | src/lib/writer.cc | 2 |
6 files changed, 36 insertions, 41 deletions
diff --git a/src/lib/container.cc b/src/lib/container.cc index 6eaea7300..d679e4848 100644 --- a/src/lib/container.cc +++ b/src/lib/container.cc @@ -32,33 +32,22 @@ vector<Container const *> Container::_containers; void Container::setup_containers () { - _containers.push_back (new Container (libdcp::Size (1285, 1080), "119", _("1.19"), "F")); - _containers.push_back (new Container (libdcp::Size (1436, 1080), "133", _("4:3"), "F")); - _containers.push_back (new Container (libdcp::Size (1480, 1080), "137", _("Academy"), "F")); - _containers.push_back (new Container (libdcp::Size (1485, 1080), "138", _("1.375"), "F")); - _containers.push_back (new Container (libdcp::Size (1793, 1080), "166", _("1.66"), "F")); - _containers.push_back (new Container (libdcp::Size (1920, 1080), "178", _("16:9"), "F")); - _containers.push_back (new Container (libdcp::Size (1998, 1080), "185", _("Flat"), "F")); - _containers.push_back (new Container (libdcp::Size (2048, 858), "239", _("Scope"), "S")); - _containers.push_back (new Container (libdcp::Size (2048, 1080), "full-frame", _("Full frame"), "C")); + _containers.push_back (new Container (float(1285) / 1080, "119", _("1.19"), "F")); + _containers.push_back (new Container (float(1436) / 1080, "133", _("4:3"), "F")); + _containers.push_back (new Container (float(1480) / 1080, "137", _("Academy"), "F")); + _containers.push_back (new Container (float(1485) / 1080, "138", _("1.375"), "F")); + _containers.push_back (new Container (float(1793) / 1080, "166", _("1.66"), "F")); + _containers.push_back (new Container (float(1920) / 1080, "178", _("16:9"), "F")); + _containers.push_back (new Container (float(1998) / 1080, "185", _("Flat"), "F")); + _containers.push_back (new Container (float(2048) / 858, "239", _("Scope"), "S")); + _containers.push_back (new Container (float(2048) / 1080, "full-frame", _("Full frame"), "C")); } /** @return A name to be presented to the user */ string Container::name () const { - stringstream s; - if (!_nickname.empty ()) { - s << _nickname << " ("; - } - - s << _dcp_size.width << "x" << _dcp_size.height; - - if (!_nickname.empty ()) { - s << ")"; - } - - return s.str (); + return _nickname; } Container const * @@ -76,8 +65,14 @@ Container::from_id (string i) return *j; } -float -Container::ratio () const +libdcp::Size +Container::size (libdcp::Size full_frame) const { - return static_cast<float> (_dcp_size.width) / _dcp_size.height; + if (_ratio < static_cast<float>(full_frame.width) / full_frame.height) { + return libdcp::Size (full_frame.height * _ratio, full_frame.height); + } else { + return libdcp::Size (full_frame.width, full_frame.width / _ratio); + } + + return libdcp::Size (); } diff --git a/src/lib/container.h b/src/lib/container.h index fc3c72792..4bf03a3f1 100644 --- a/src/lib/container.h +++ b/src/lib/container.h @@ -23,26 +23,19 @@ class Container { public: - Container (libdcp::Size dcp, std::string id, std::string n, std::string d) - : _dcp_size (dcp) + Container (float ratio, std::string id, std::string n, std::string d) + : _ratio (ratio) , _id (id) , _nickname (n) , _dci_name (d) {} - /** @return size in pixels of the images that we should - * put in a DCP for this ratio. This size will not correspond - * to the ratio when we are doing things like 16:9 in a Flat frame. - */ - libdcp::Size dcp_size () const { - return _dcp_size; - } + libdcp::Size size (libdcp::Size) const; std::string id () const { return _id; } - /** @return Full name to present to the user */ std::string name () const; /** @return Nickname (e.g. Flat, Scope) */ @@ -54,7 +47,9 @@ public: return _dci_name; } - float ratio () const; + float ratio () const { + return _ratio; + } static void setup_containers (); static Container const * from_id (std::string i); @@ -63,10 +58,7 @@ public: } private: - /** libdcp::Size in pixels of the images that we should - * put in a DCP for this container. - */ - libdcp::Size _dcp_size; + float _ratio; /** id for use in metadata */ std::string _id; /** nickname (e.g. Flat, Scope) */ diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 270bf3d43..3152669ad 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -211,7 +211,7 @@ Encoder::process_video (shared_ptr<const Image> image, bool same, shared_ptr<Sub /* XXX: padding */ _queue.push_back (shared_ptr<DCPVideoFrame> ( new DCPVideoFrame ( - image, sub, _film->container()->dcp_size(), 0, + image, sub, _film->container()->size (_film->full_frame()), 0, _film->subtitle_offset(), _film->subtitle_scale(), _film->scaler(), _video_frames_out, _film->dcp_video_frame_rate(), _film->colour_lut(), _film->j2k_bandwidth(), diff --git a/src/lib/film.cc b/src/lib/film.cc index 8eeb4fec5..e76d97b59 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -911,3 +911,9 @@ Film::set_sequence_video (bool s) { _playlist->set_sequence_video (s); } + +libdcp::Size +Film::full_frame () const +{ + return libdcp::Size (2048, 1080); +} diff --git a/src/lib/film.h b/src/lib/film.h index cb970da4d..31454c5a7 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -96,6 +96,8 @@ public: return _dirty; } + libdcp::Size full_frame () const; + bool have_dcp () const; boost::shared_ptr<Player> player () const; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 39b9b9304..22aacb640 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -76,7 +76,7 @@ Writer::Writer (shared_ptr<Film> f, shared_ptr<Job> j) _film->internal_video_mxf_dir (), _film->internal_video_mxf_filename (), _film->dcp_video_frame_rate (), - _film->container()->dcp_size () + _film->container()->size (_film->full_frame ()) ) ); |
