2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/format.cc
21 * @brief Class to describe a format (aspect ratio) that a Film should
37 using std::setprecision;
38 using std::stringstream;
40 using boost::shared_ptr;
43 vector<Format const *> Format::_formats;
45 /** @return A name to be presented to the user */
50 if (!_nickname.empty ()) {
51 s << _nickname << N_(" (");
54 s << setprecision(3) << ratio() << N_(":1");
56 if (!_nickname.empty ()) {
63 /** Fill our _formats vector with all available formats */
65 Format::setup_formats ()
67 /// TRANSLATORS: these are film picture aspect ratios; "Academy" means 1.37, "Flat" 1.85 and "Scope" 2.39.
68 _formats.push_back (new Format (libdcp::Size (1285, 1080), "119", _("1.19")));
69 _formats.push_back (new Format (libdcp::Size (1436, 1080), "133", _("4:3")));
70 _formats.push_back (new Format (libdcp::Size (1485, 1080), "138", _("1.375")));
71 _formats.push_back (new Format (libdcp::Size (1480, 1080), "137", _("Academy")));
72 _formats.push_back (new Format (libdcp::Size (1793, 1080), "166", _("1.66")));
73 _formats.push_back (new Format (libdcp::Size (1920, 1080), "178", _("16:9")));
74 _formats.push_back (new Format (libdcp::Size (1998, 1080), "185", _("Flat")));
75 _formats.push_back (new Format (libdcp::Size (2048, 858), "239", _("Scope")));
76 _formats.push_back (new Format (libdcp::Size (2048, 1080), "full-frame", _("Full frame")));
79 /** @param n Nickname.
80 * @return Matching Format, or 0.
83 Format::from_nickname (string n)
85 vector<Format const *>::iterator i = _formats.begin ();
86 while (i != _formats.end() && (*i)->nickname() != n) {
90 if (i == _formats.end ()) {
98 * @return Matching Format, or 0.
101 Format::from_id (string i)
103 vector<Format const *>::iterator j = _formats.begin ();
104 while (j != _formats.end() && (*j)->id() != i) {
108 if (j == _formats.end ()) {
115 /** @return All available formats */
116 vector<Format const *>
123 Format::ratio () const
125 return static_cast<float> (_dcp_size.width) / _dcp_size.height;