X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fread_smpte_subtitle_test.cc;h=3f7850013d359ddf92e8aa1270713ba3c91384ca;hb=refs%2Fheads%2Fvideocon-1;hp=81749a15d13a7f541fe302ccc86ae02643e59572;hpb=43515be4f21d92d66f28588bcd0dc93ee517d301;p=libdcp.git diff --git a/test/read_smpte_subtitle_test.cc b/test/read_smpte_subtitle_test.cc index 81749a15..3f785001 100644 --- a/test/read_smpte_subtitle_test.cc +++ b/test/read_smpte_subtitle_test.cc @@ -1,27 +1,30 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2018 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 "smpte_subtitle_asset.h" #include "test.h" #include "local_time.h" #include "smpte_load_font_node.h" +#include "subtitle_image.h" #include +#include +#include using std::list; using boost::shared_ptr; @@ -30,31 +33,87 @@ using boost::dynamic_pointer_cast; /** Check reading of a SMPTE subtitle file */ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test) { - dcp::SMPTESubtitleAsset sc (private_test / "8dfafe11-2bd1-4206-818b-afc109cfe7f6_reel1.xml", false); + dcp::SMPTESubtitleAsset sc ( + private_test / + "data" / + "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV" / + "8b48f6ae-c74b-4b80-b994-a8236bbbad74_sub.mxf" + ); - BOOST_CHECK_EQUAL (sc.id(), "8dfafe11-2bd1-4206-818b-afc109cfe7f6"); - BOOST_CHECK_EQUAL (sc.content_title_text(), "Violet"); + BOOST_CHECK_EQUAL (sc.id(), "8b48f6ae-c74b-4b80-b994-a8236bbbad74"); + BOOST_CHECK_EQUAL (sc.content_title_text(), "Journey to Jah"); BOOST_REQUIRE (sc.annotation_text()); - BOOST_CHECK_EQUAL (sc.annotation_text().get(), "Violet"); - BOOST_CHECK_EQUAL (sc.issue_date(), dcp::LocalTime ("2014-12-23T22:30:07.000-00:00")); + BOOST_CHECK_EQUAL (sc.annotation_text().get(), "Journey to Jah"); + BOOST_CHECK_EQUAL (sc.issue_date(), dcp::LocalTime ("2014-02-25T11:22:48.000-00:00")); BOOST_REQUIRE (sc.reel_number()); BOOST_CHECK_EQUAL (sc.reel_number().get(), 1); BOOST_REQUIRE (sc.language ()); - BOOST_CHECK_EQUAL (sc.language().get (), "Dutch"); - BOOST_CHECK_EQUAL (sc.edit_rate(), dcp::Fraction (24, 1)); - BOOST_CHECK_EQUAL (sc.time_code_rate(), 24); - BOOST_CHECK_EQUAL (sc.start_time(), dcp::Time (0, 0, 0, 23, 24)); + BOOST_CHECK_EQUAL (sc.language().get (), "de"); + BOOST_CHECK_EQUAL (sc.edit_rate(), dcp::Fraction (25, 1)); + BOOST_CHECK_EQUAL (sc.time_code_rate(), 25); + BOOST_CHECK_EQUAL (sc.start_time(), dcp::Time (0, 0, 0, 0, 25)); list > lfn = sc.load_font_nodes (); BOOST_REQUIRE_EQUAL (lfn.size(), 1); shared_ptr smpte_lfn = dynamic_pointer_cast (lfn.front ()); BOOST_REQUIRE (smpte_lfn); BOOST_CHECK_EQUAL (smpte_lfn->id, "theFontId"); - BOOST_CHECK_EQUAL (smpte_lfn->urn, "3dec6dc0-39d0-498d-97d0-928d2eb78391"); - BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 159); - BOOST_CHECK_EQUAL (sc.subtitles().front().text(), "Jonas ?"); - BOOST_CHECK_EQUAL (sc.subtitles().front().in(), dcp::Time (0, 7, 6, 20, 24)); - BOOST_CHECK_EQUAL (sc.subtitles().front().out(), dcp::Time (0, 7, 7, 20, 24)); - BOOST_CHECK_EQUAL (sc.subtitles().back().text(), "Come on."); - BOOST_CHECK_EQUAL (sc.subtitles().back().in(), dcp::Time (1, 13, 37, 11, 24)); - BOOST_CHECK_EQUAL (sc.subtitles().back().out(), dcp::Time (1, 13, 38, 11, 24)); + BOOST_CHECK_EQUAL (smpte_lfn->urn, "9118bbce-4105-4a05-b37c-a5a6f75e1fea"); + BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 63); + BOOST_REQUIRE (dynamic_pointer_cast(sc.subtitles().front())); + BOOST_CHECK_EQUAL (dynamic_pointer_cast(sc.subtitles().front())->text(), "Noch mal."); + BOOST_CHECK_EQUAL (sc.subtitles().front()->in(), dcp::Time (0, 0, 25, 12, 25)); + BOOST_CHECK_EQUAL (sc.subtitles().front()->out(), dcp::Time (0, 0, 26, 4, 25)); + BOOST_REQUIRE (dynamic_pointer_cast(sc.subtitles().back())); + BOOST_CHECK_EQUAL (dynamic_pointer_cast(sc.subtitles().back())->text(), "Prochainement"); + BOOST_CHECK_EQUAL (sc.subtitles().back()->in(), dcp::Time (0, 1, 57, 17, 25)); + BOOST_CHECK_EQUAL (sc.subtitles().back()->out(), dcp::Time (0, 1, 58, 12, 25)); +} + +/** And another one featuring within */ +BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test2) +{ + dcp::SMPTESubtitleAsset sc (private_test / "olsson.xml"); + + BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 6); + list >::const_iterator i = sc.subtitles().begin(); + shared_ptr is = dynamic_pointer_cast(*i); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), "Testing is "); + BOOST_CHECK (!is->italic()); + ++i; + is = dynamic_pointer_cast(*i); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), "really"); + BOOST_CHECK (is->italic()); + ++i; + is = dynamic_pointer_cast(*i); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), " fun!"); + BOOST_CHECK (!is->italic()); + ++i; + is = dynamic_pointer_cast(*i); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), "This is the "); + BOOST_CHECK (!is->italic()); + ++i; + is = dynamic_pointer_cast(*i); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), "second"); + BOOST_CHECK (is->italic()); + ++i; + is = dynamic_pointer_cast(*i); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), " line!"); + BOOST_CHECK (!is->italic()); +} + +/** And another one featuring image subtitles */ +BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test3) +{ + dcp::SMPTESubtitleAsset subs ("test/data/subs.mxf"); + + BOOST_REQUIRE_EQUAL (subs.subtitles().size(), 1); + shared_ptr si = dynamic_pointer_cast(subs.subtitles().front()); + BOOST_REQUIRE (si); + BOOST_CHECK (si->png_image() == dcp::Data("test/data/sub.png")); }