diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-12-04 20:11:29 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-12-04 20:11:29 +0000 |
| commit | 689d56339857b0a82156641f28392b8d2f11beea (patch) | |
| tree | 9cb15585f2122c79d8b4a0a44fae830cee3eaa32 | |
| parent | fa2900fedac1030141c56b691c7f6e0f7e629424 (diff) | |
Fix incorrect reading of ScreenAspectRatio.
| -rw-r--r-- | src/reel_picture_asset.cc | 12 | ||||
| -rw-r--r-- | test/reel_asset_test.cc | 47 | ||||
| -rw-r--r-- | test/wscript | 1 |
3 files changed, 54 insertions, 6 deletions
diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index ccb4bd56..096d3476 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -60,13 +60,13 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node) try { _screen_aspect_ratio = Fraction (node->string_child ("ScreenAspectRatio")); } catch (XMLError& e) { - /* Maybe it's not a fraction */ - } - try { - float f = node->number_child<float> ("ScreenAspectRatio"); - _screen_aspect_ratio = Fraction (f * 1000, 1000); - } catch (bad_cast& e) { + /* It's not a fraction */ + try { + float f = node->number_child<float> ("ScreenAspectRatio"); + _screen_aspect_ratio = Fraction (f * 1000, 1000); + } catch (bad_cast& e) { + } } } diff --git a/test/reel_asset_test.cc b/test/reel_asset_test.cc new file mode 100644 index 00000000..bdbd68ea --- /dev/null +++ b/test/reel_asset_test.cc @@ -0,0 +1,47 @@ +/* + Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + + This program 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, + 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. + +*/ + +#include "reel_mono_picture_asset.h" +#include <libcxml/cxml.h> +#include <boost/test/unit_test.hpp> + +using boost::shared_ptr; + +/** Test the XML constructor of ReelPictureAsset */ +BOOST_AUTO_TEST_CASE (reel_picture_asset_test) +{ + shared_ptr<cxml::Document> doc (new cxml::Document ("MainPicture")); + + doc->read_string ( + "<MainPicture>" + "<Id>urn:uuid:06ac1ca7-9c46-4107-8864-a6448e24b04b</Id>" + "<AnnotationText></AnnotationText>" + "<EditRate>24 1</EditRate>" + "<IntrinsicDuration>187048</IntrinsicDuration>" + "<EntryPoint>0</EntryPoint>" + "<Duration>187048</Duration>" + "<Hash>6EQX4NjG8vxIWhLUtHhrGSyLgOY=</Hash>" + "<FrameRate>24 1</FrameRate>" + "<ScreenAspectRatio>2048 858</ScreenAspectRatio>" + "</MainPicture>" + ); + + dcp::ReelMonoPictureAsset pa (doc); + BOOST_CHECK_EQUAL (pa.screen_aspect_ratio(), dcp::Fraction (2048, 858)); +} diff --git a/test/wscript b/test/wscript index 7e6e48ed..e10bef9d 100644 --- a/test/wscript +++ b/test/wscript @@ -48,6 +48,7 @@ def build(bld): read_dcp_test.cc read_interop_subtitle_test.cc read_smpte_subtitle_test.cc + reel_asset_test.cc recovery_test.cc rgb_xyz_test.cc round_trip_test.cc |
