From: Carl Hetherington Date: Wed, 7 Jun 2017 11:12:23 +0000 (+0100) Subject: Fix incorrect reel numbers in subtitle XML/MXF. X-Git-Tag: v2.11.11~21 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=563ffc8c14b9db24c828c85c6590d0ece9ed19bc;hp=222d4bf6d69ea03ecef28aebbe64719efc352bef;p=dcpomatic.git Fix incorrect reel numbers in subtitle XML/MXF. --- diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 27f10d1ed..8334dc477 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "i18n.h" @@ -57,6 +58,7 @@ using boost::shared_ptr; using boost::optional; using boost::dynamic_pointer_cast; using dcp::Data; +using dcp::raw_convert; int const ReelWriter::_info_size = 48; @@ -521,14 +523,14 @@ ReelWriter::write (PlayerSubtitles subs) shared_ptr s (new dcp::InteropSubtitleAsset ()); s->set_movie_title (_film->name ()); s->set_language (lang); - s->set_reel_number ("1"); + s->set_reel_number (raw_convert (_reel_index + 1)); _subtitle_asset = s; } else { shared_ptr s (new dcp::SMPTESubtitleAsset ()); s->set_content_title_text (_film->name ()); s->set_language (lang); s->set_edit_rate (dcp::Fraction (_film->video_frame_rate (), 1)); - s->set_reel_number (1); + s->set_reel_number (_reel_index + 1); s->set_time_code_rate (_film->video_frame_rate ()); s->set_start_time (dcp::Time ()); if (_film->encrypted ()) { diff --git a/test/data b/test/data index e4609c383..c48444d72 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit e4609c3834cebb4732614c16f6167457c8ac9a3e +Subproject commit c48444d72505fbbf32dd65cdbe402174995e03aa diff --git a/test/subtitle_reel_number_test.cc b/test/subtitle_reel_number_test.cc new file mode 100644 index 000000000..3eede3a88 --- /dev/null +++ b/test/subtitle_reel_number_test.cc @@ -0,0 +1,72 @@ +/* + Copyright (C) 2017 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see . + +*/ + +#include "lib/text_subtitle_content.h" +#include "lib/film.h" +#include "lib/ratio.h" +#include "lib/subtitle_content.h" +#include "lib/dcp_content_type.h" +#include "test.h" +#include +#include +#include +#include +#include +#include +#include + +using std::string; +using boost::shared_ptr; +using boost::dynamic_pointer_cast; + +/* Check that ReelNumber is setup correctly when making multi-reel subtitled DCPs */ +BOOST_AUTO_TEST_CASE (subtitle_reel_number_test) +{ + shared_ptr film = new_test_film ("subtitle_reel_number_test"); + film->set_container (Ratio::from_id ("185")); + film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); + film->set_name ("frobozz"); + shared_ptr content (new TextSubtitleContent (film, "test/data/subrip5.srt")); + film->examine_and_add_content (content); + BOOST_REQUIRE (!wait_for_jobs ()); + content->subtitle->set_use (true); + content->subtitle->set_burn (false); + film->set_reel_type (REELTYPE_BY_LENGTH); + film->set_interop (true); + film->set_reel_length (1024 * 1024 * 512); + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs ()); + + dcp::DCP dcp ("build/test/subtitle_reel_number_test/" + film->dcp_name()); + dcp.read (); + BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1); + shared_ptr cpl = dcp.cpls().front(); + BOOST_REQUIRE_EQUAL (cpl->reels().size(), 6); + + int n = 1; + BOOST_FOREACH (shared_ptr i, cpl->reels()) { + if (i->main_subtitle()) { + shared_ptr ass = dynamic_pointer_cast(i->main_subtitle()->asset()); + BOOST_REQUIRE (ass); + BOOST_CHECK_EQUAL (ass->reel_number(), dcp::raw_convert(n)); + ++n; + } + } +} diff --git a/test/wscript b/test/wscript index 3ccc64423..c90f9bdfa 100644 --- a/test/wscript +++ b/test/wscript @@ -91,6 +91,7 @@ def build(bld): srt_subtitle_test.cc ssa_subtitle_test.cc stream_test.cc + subtitle_reel_number_test.cc test.cc threed_test.cc time_calculation_test.cc