X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fcpl_sar_test.cc;h=55c3bcdc477019f4a7b458b902bf3f9fbe020e60;hb=e6bbf120d575c392dd73f036821bba9a8fd4011c;hp=59a91c84b2676ec5ee6b6637b3de4e734091d31c;hpb=194f38bccf78e51de0a35367590c2133bb093020;p=libdcp.git diff --git a/test/cpl_sar_test.cc b/test/cpl_sar_test.cc index 59a91c84..55c3bcdc 100644 --- a/test/cpl_sar_test.cc +++ b/test/cpl_sar_test.cc @@ -1,59 +1,91 @@ /* Copyright (C) 2014 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of libdcp. + + libdcp 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, + libdcp 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. - + along with libdcp. If not, see . */ #include "cpl.h" #include "reel_mono_picture_asset.h" -#include "mono_picture_mxf.h" +#include "mono_picture_asset.h" #include +#include #include +using std::string; using boost::shared_ptr; -/* Test for a reported bug where in Interop files uses - excessive decimal places and (sometimes) the wrong decimal point character. -*/ +static void +check (shared_ptr pa, dcp::Fraction far, string sar) +{ + pa->set_screen_aspect_ratio (far); + xmlpp::Document doc; + xmlpp::Element* el = doc.create_root_node ("Test"); + pa->write_to_cpl (el, dcp::INTEROP); + + cxml::Node node (el); + BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), sar); +} + +/** Test for a reported bug where in Interop files uses + * excessive decimal places and (sometimes) the wrong decimal point character. + * Also check that we correctly use one of the allowed + * values with Interop. + */ BOOST_AUTO_TEST_CASE (cpl_sar) { shared_ptr pa ( new dcp::ReelMonoPictureAsset ( - shared_ptr (new dcp::MonoPictureMXF ("test/ref/DCP/foo/video.mxf")), + shared_ptr (new dcp::MonoPictureAsset ("test/ref/DCP/dcp_test1/video.mxf")), 0 ) ); - { - pa->set_screen_aspect_ratio (dcp::Fraction (1998, 1080)); - xmlpp::Document doc; - xmlpp::Element* el = doc.create_root_node ("Test"); - pa->write_to_cpl (el, dcp::INTEROP); - - cxml::Node node (el); - BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), "1.85"); - } - - { - pa->set_screen_aspect_ratio (dcp::Fraction (2048, 858)); - xmlpp::Document doc; - xmlpp::Element* el = doc.create_root_node ("Test"); - pa->write_to_cpl (el, dcp::INTEROP); - - cxml::Node node (el); - BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), "2.39"); - } + /* Easy ones */ + check (pa, dcp::Fraction (1998, 1080), "1.85"); + check (pa, dcp::Fraction (2048, 858), "2.39"); + + /* Check the use of the allowed values */ + + /* Just less then, equal to and just more than 1.33 */ + check (pa, dcp::Fraction (1200, 1000), "1.33"); + check (pa, dcp::Fraction (1330, 1000), "1.33"); + check (pa, dcp::Fraction (1430, 1000), "1.33"); + + /* Same for 1.66 */ + check (pa, dcp::Fraction (1600, 1000), "1.66"); + check (pa, dcp::Fraction (1660, 1000), "1.66"); + check (pa, dcp::Fraction (1670, 1000), "1.66"); + + /* 1.77 */ + check (pa, dcp::Fraction (1750, 1000), "1.77"); + check (pa, dcp::Fraction (1770, 1000), "1.77"); + check (pa, dcp::Fraction (1800, 1000), "1.77"); + + /* 1.85 */ + check (pa, dcp::Fraction (1820, 1000), "1.85"); + check (pa, dcp::Fraction (1850, 1000), "1.85"); + check (pa, dcp::Fraction (1910, 1000), "1.85"); + + /* 2.00 */ + check (pa, dcp::Fraction (1999, 1000), "2.00"); + check (pa, dcp::Fraction (2000, 1000), "2.00"); + check (pa, dcp::Fraction (2001, 1000), "2.00"); + + /* 2.39 */ + check (pa, dcp::Fraction (2350, 1000), "2.39"); + check (pa, dcp::Fraction (2390, 1000), "2.39"); + check (pa, dcp::Fraction (2500, 1000), "2.39"); }