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 *
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 ();
}
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) */
return _dci_name;
}
- float ratio () const;
+ float ratio () const {
+ return _ratio;
+ }
static void setup_containers ();
static Container const * from_id (std::string i);
}
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) */
/* 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(),
{
_playlist->set_sequence_video (s);
}
+
+libdcp::Size
+Film::full_frame () const
+{
+ return libdcp::Size (2048, 1080);
+}
return _dirty;
}
+ libdcp::Size full_frame () const;
+
bool have_dcp () const;
boost::shared_ptr<Player> player () const;
_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 ())
)
);
--- /dev/null
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+using std::ostream;
+
+namespace libdcp {
+
+ostream&
+operator<< (ostream& s, libdcp::Size const & t)
+{
+ s << t.width << "x" << t.height;
+ return s;
+}
+
+}
+
+BOOST_AUTO_TEST_CASE (container_test)
+{
+ Container::setup_containers ();
+
+ Container const * c = Container::from_id ("119");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1285, 1080));
+
+ c = Container::from_id ("133");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1436, 1080));
+
+ c = Container::from_id ("137");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1480, 1080));
+
+ c = Container::from_id ("138");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1485, 1080));
+
+ c = Container::from_id ("166");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1793, 1080));
+
+ c = Container::from_id ("178");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1920, 1080));
+
+ c = Container::from_id ("185");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1998, 1080));
+
+ c = Container::from_id ("239");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (2048, 858));
+
+ c = Container::from_id ("full-frame");
+ BOOST_CHECK (c);
+ BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (2048, 1080));
+}
+
return f;
}
+#include "container_test.cc"
#include "pixel_formats_test.cc"
#include "make_black_test.cc"
#include "film_metadata_test.cc"