From 5d9b8579950a4440b43a649c27fa36082144773d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 10 Jan 2025 22:17:00 +0100 Subject: Put open captions into subtitles and closed subtitles into captions. We could write them separately (libdcp supports this, AFAIK) but the Deluxe guidelines suggest not to use ClosedSubtitle or MainCaption. --- src/lib/reel_writer.cc | 8 ++++++++ src/lib/writer.cc | 2 ++ test/open_caption_test.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test/wscript | 1 + 4 files changed, 57 insertions(+) create mode 100644 test/open_caption_test.cc diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index a66ac00a7..ec7fc9e39 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -900,9 +900,15 @@ ReelWriter::write(PlayerText subs, TextType type, optional track, switch (type) { case TextType::OPEN_SUBTITLE: + case TextType::OPEN_CAPTION: + /* We could create a separate MainCaption instead of merging these, but the Deluxe guidelines + * suggest not to use MainCaption. + */ asset = _subtitle_asset; break; case TextType::CLOSED_CAPTION: + case TextType::CLOSED_SUBTITLE: + /* Similarly it is advised by Deluxe not to use ClosedSubtitle */ DCPOMATIC_ASSERT (track); asset = _closed_caption_assets[*track]; break; @@ -916,9 +922,11 @@ ReelWriter::write(PlayerText subs, TextType type, optional track, switch (type) { case TextType::OPEN_SUBTITLE: + case TextType::OPEN_CAPTION: _subtitle_asset = asset; break; case TextType::CLOSED_CAPTION: + case TextType::CLOSED_SUBTITLE: DCPOMATIC_ASSERT (track); _closed_caption_assets[*track] = asset; break; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index f1dceee6e..b1d21cae1 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -828,10 +828,12 @@ Writer::write (PlayerText text, TextType type, optional track, DCP switch (type) { case TextType::OPEN_SUBTITLE: + case TextType::OPEN_CAPTION: reel = &_subtitle_reel; _have_subtitles = true; break; case TextType::CLOSED_CAPTION: + case TextType::CLOSED_SUBTITLE: DCPOMATIC_ASSERT (track); DCPOMATIC_ASSERT (_caption_reels.find(*track) != _caption_reels.end()); reel = &_caption_reels[*track]; diff --git a/test/open_caption_test.cc b/test/open_caption_test.cc new file mode 100644 index 000000000..06b08c151 --- /dev/null +++ b/test/open_caption_test.cc @@ -0,0 +1,46 @@ +/* + Copyright (C) 2025 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/content_factory.h" +#include "lib/text_content.h" +#include "test.h" +#include + + +BOOST_AUTO_TEST_CASE(basic_open_caption_test) +{ + auto content = content_factory("test/data/15s.srt")[0]; + auto film = new_test_film("basic_open_caption_test", { content }); + + content->text[0]->set_type(TextType::OPEN_CAPTION); + + make_and_verify_dcp( + film, + { + dcp::VerificationNote::Code::MISSING_CPL_METADATA, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE + } + ); + +} + diff --git a/test/wscript b/test/wscript index 1cbcab29f..8c02f8ebc 100644 --- a/test/wscript +++ b/test/wscript @@ -127,6 +127,7 @@ def build(bld): map_cli_test.cc mca_subdescriptors_test.cc no_use_video_test.cc + open_caption_test.cc optimise_stills_test.cc overlap_video_test.cc pixel_formats_test.cc -- cgit v1.2.3