2 Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp 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 libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
21 #include "reel_mono_picture_asset.h"
22 #include "mono_picture_asset.h"
23 #include <libcxml/cxml.h>
24 #include <libxml++/libxml++.h>
25 #include <boost/test/unit_test.hpp>
28 using boost::shared_ptr;
31 check (shared_ptr<dcp::ReelMonoPictureAsset> pa, dcp::Fraction far, string sar)
33 pa->set_screen_aspect_ratio (far);
35 xmlpp::Element* el = doc.create_root_node ("Test");
36 pa->write_to_cpl (el, dcp::INTEROP);
39 BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), sar);
42 /** Test for a reported bug where <ScreenAspectRatio> in Interop files uses
43 * excessive decimal places and (sometimes) the wrong decimal point character.
44 * Also check that we correctly use one of the allowed <ScreenAspectRatio>
45 * values with Interop.
47 BOOST_AUTO_TEST_CASE (cpl_sar)
49 shared_ptr<dcp::ReelMonoPictureAsset> pa (
50 new dcp::ReelMonoPictureAsset (
51 shared_ptr<dcp::MonoPictureAsset> (new dcp::MonoPictureAsset ("test/ref/DCP/dcp_test1/video.mxf")),
57 check (pa, dcp::Fraction (1998, 1080), "1.85");
58 check (pa, dcp::Fraction (2048, 858), "2.39");
60 /* Check the use of the allowed values */
62 /* Just less then, equal to and just more than 1.33 */
63 check (pa, dcp::Fraction (1200, 1000), "1.33");
64 check (pa, dcp::Fraction (1330, 1000), "1.33");
65 check (pa, dcp::Fraction (1430, 1000), "1.33");
68 check (pa, dcp::Fraction (1600, 1000), "1.66");
69 check (pa, dcp::Fraction (1660, 1000), "1.66");
70 check (pa, dcp::Fraction (1670, 1000), "1.66");
73 check (pa, dcp::Fraction (1750, 1000), "1.77");
74 check (pa, dcp::Fraction (1770, 1000), "1.77");
75 check (pa, dcp::Fraction (1800, 1000), "1.77");
78 check (pa, dcp::Fraction (1820, 1000), "1.85");
79 check (pa, dcp::Fraction (1850, 1000), "1.85");
80 check (pa, dcp::Fraction (1910, 1000), "1.85");
83 check (pa, dcp::Fraction (1999, 1000), "2.00");
84 check (pa, dcp::Fraction (2000, 1000), "2.00");
85 check (pa, dcp::Fraction (2001, 1000), "2.00");
88 check (pa, dcp::Fraction (2350, 1000), "2.39");
89 check (pa, dcp::Fraction (2390, 1000), "2.39");
90 check (pa, dcp::Fraction (2500, 1000), "2.39");