2 Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "compose.hpp"
23 #include "dcpomatic_assert.h"
24 #include <dcp/raw_convert.h>
25 #include <libxml++/libxml++.h>
26 #include <libcxml/cxml.h>
33 using boost::shared_ptr;
34 using dcp::raw_convert;
36 bool operator== (Crop const & a, Crop const & b)
38 return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom);
41 bool operator!= (Crop const & a, Crop const & b)
46 /** @param r Resolution.
47 * @return Untranslated string representation.
50 resolution_to_string (Resolution r)
59 DCPOMATIC_ASSERT (false);
65 string_to_resolution (string s)
75 DCPOMATIC_ASSERT (false);
79 Crop::Crop (shared_ptr<cxml::Node> node)
81 left = node->number_child<int> ("LeftCrop");
82 right = node->number_child<int> ("RightCrop");
83 top = node->number_child<int> ("TopCrop");
84 bottom = node->number_child<int> ("BottomCrop");
88 Crop::as_xml (xmlpp::Node* node) const
90 node->add_child("LeftCrop")->add_child_text (raw_convert<string> (left));
91 node->add_child("RightCrop")->add_child_text (raw_convert<string> (right));
92 node->add_child("TopCrop")->add_child_text (raw_convert<string> (top));
93 node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom));
97 string_to_caption_type (string s)
101 } else if (s == "closed") {
102 return CAPTION_CLOSED;
104 throw MetadataError (String::compose ("Unknown caption type %1", s));
109 caption_type_to_string (TextType t)
117 DCPOMATIC_ASSERT (false);
122 caption_type_to_name (TextType t)
126 return _("Subtitles");
128 return _("Closed captions");
130 DCPOMATIC_ASSERT (false);
135 video_frame_type_to_string (VideoFrameType t)
138 case VIDEO_FRAME_TYPE_2D:
140 case VIDEO_FRAME_TYPE_3D:
142 case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
143 return "3d-left-right";
144 case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
145 return "3d-top-bottom";
146 case VIDEO_FRAME_TYPE_3D_ALTERNATE:
147 return "3d-alternate";
148 case VIDEO_FRAME_TYPE_3D_LEFT:
150 case VIDEO_FRAME_TYPE_3D_RIGHT:
153 DCPOMATIC_ASSERT (false);
156 DCPOMATIC_ASSERT (false);
160 string_to_video_frame_type (string s)
163 return VIDEO_FRAME_TYPE_2D;
164 } else if (s == "3d") {
165 return VIDEO_FRAME_TYPE_3D;
166 } else if (s == "3d-left-right") {
167 return VIDEO_FRAME_TYPE_3D_LEFT_RIGHT;
168 } else if (s == "3d-top-bottom") {
169 return VIDEO_FRAME_TYPE_3D_TOP_BOTTOM;
170 } else if (s == "3d-alternate") {
171 return VIDEO_FRAME_TYPE_3D_ALTERNATE;
172 } else if (s == "3d-left") {
173 return VIDEO_FRAME_TYPE_3D_LEFT;
174 } else if (s == "3d-right") {
175 return VIDEO_FRAME_TYPE_3D_RIGHT;
178 DCPOMATIC_ASSERT (false);