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.h
21 * @brief Classes to describe a format (aspect ratio) that a Film should
34 Format (libdcp::Size dcp, std::string id, std::string n, std::string d, std::string e)
42 /** @return the aspect ratio multiplied by 100
43 * (e.g. 239 for Cinemascope 2.39:1)
45 virtual int ratio_as_integer (boost::shared_ptr<const Film> f) const = 0;
47 /** @return the ratio as a floating point number */
48 virtual float ratio_as_float (boost::shared_ptr<const Film> f) const = 0;
50 /** @return the ratio of the container (including any padding) as a floating point number */
51 float container_ratio_as_float () const;
53 int dcp_padding (boost::shared_ptr<const Film> f) const;
55 /** @return size in pixels of the images that we should
56 * put in a DCP for this ratio. This size will not correspond
57 * to the ratio when we are doing things like 16:9 in a Flat frame.
59 libdcp::Size dcp_size () const {
63 std::string id () const {
67 /** @return Full name to present to the user */
68 virtual std::string name () const = 0;
70 /** @return Nickname (e.g. Flat, Scope) */
71 std::string nickname () const {
75 std::string dci_name () const {
79 std::string description () const {
83 std::string as_metadata () const;
85 static Format const * from_nickname (std::string n);
86 static Format const * from_metadata (std::string m);
87 static Format const * from_id (std::string i);
88 static std::vector<Format const *> all ();
89 static void setup_formats ();
92 /** libdcp::Size in pixels of the images that we should
93 * put in a DCP for this ratio. This size will not correspond
94 * to the ratio when we are doing things like 16:9 in a Flat frame.
96 libdcp::Size _dcp_size;
97 /** id for use in metadata */
99 /** nickname (e.g. Flat, Scope) */
100 std::string _nickname;
101 std::string _dci_name;
102 std::string _description;
105 /** all available formats */
106 static std::vector<Format const *> _formats;
109 /** @class FixedFormat
110 * @brief Class to describe a format whose ratio is fixed regardless
113 class FixedFormat : public Format
116 FixedFormat (int, libdcp::Size, std::string, std::string, std::string, std::string);
118 int ratio_as_integer (boost::shared_ptr<const Film>) const {
122 float ratio_as_float (boost::shared_ptr<const Film>) const {
123 return _ratio / 100.0;
126 std::string name () const;
130 /** Ratio expressed as the actual ratio multiplied by 100 */
134 class VariableFormat : public Format
137 VariableFormat (libdcp::Size, std::string, std::string, std::string, std::string);
139 int ratio_as_integer (boost::shared_ptr<const Film> f) const;
140 float ratio_as_float (boost::shared_ptr<const Film> f) const;
142 std::string name () const;