From f3ab77e34a41ad4d8f5156e9d6598314975b9565 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 6 Aug 2024 23:57:22 +0200 Subject: Adapt to some libdcp class renaming to allow open captions/closed subtitles. --- src/lib/content_factory.cc | 4 +-- src/lib/content_text.h | 2 +- src/lib/dcp_content.cc | 3 +-- src/lib/dcp_decoder.cc | 17 ++++++------ src/lib/dcp_decoder.h | 4 +-- src/lib/dcp_digest_file.cc | 6 ++--- src/lib/dcp_examiner.cc | 7 +++-- src/lib/dcp_subtitle.cc | 12 ++++----- src/lib/dcp_subtitle.h | 4 +-- src/lib/dcp_subtitle_content.cc | 12 ++++----- src/lib/dcp_subtitle_content.h | 2 +- src/lib/dcp_subtitle_decoder.cc | 16 +++++------ src/lib/dcp_subtitle_decoder.h | 8 +++--- src/lib/ffmpeg_decoder.cc | 2 +- src/lib/font_id_allocator.cc | 7 +++-- src/lib/font_id_allocator.h | 4 +-- src/lib/hints.cc | 5 ++-- src/lib/map_cli.cc | 15 +++++------ src/lib/player.cc | 3 +-- src/lib/reel_writer.cc | 53 ++++++++++++++++++++----------------- src/lib/reel_writer.h | 8 +++--- src/lib/referenced_reel_asset.cc | 3 +-- src/lib/string_text.h | 10 +++---- src/lib/string_text_file_decoder.cc | 4 +-- src/lib/subtitle_film_encoder.cc | 18 ++++++------- src/lib/subtitle_film_encoder.h | 4 +-- src/lib/text_decoder.cc | 6 ++--- src/lib/text_decoder.h | 6 ++--- src/lib/text_type.cc | 12 +++++++++ src/lib/text_type.h | 4 +-- src/lib/util.cc | 8 +++--- src/lib/util.h | 8 +++--- src/lib/writer.cc | 31 +++++++++++----------- 33 files changed, 158 insertions(+), 150 deletions(-) (limited to 'src/lib') diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index dfa1ba55e..bac41f940 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -41,7 +41,7 @@ #include "compose.hpp" #include #include -#include +#include #include #include "i18n.h" @@ -178,7 +178,7 @@ content_factory (boost::filesystem::path path) throw KDMAsContentError (); } single = make_shared(path); - } else if (ext == ".mxf" && dcp::SMPTESubtitleAsset::valid_mxf(path)) { + } else if (ext == ".mxf" && dcp::SMPTETextAsset::valid_mxf(path)) { single = make_shared(path); } else if (ext == ".mxf" && VideoMXFContent::valid_mxf(path)) { single = make_shared(path); diff --git a/src/lib/content_text.h b/src/lib/content_text.h index 51d4e8009..4b59ac65f 100644 --- a/src/lib/content_text.h +++ b/src/lib/content_text.h @@ -27,7 +27,7 @@ #include "dcpomatic_time.h" #include "rect.h" #include "string_text.h" -#include +#include #include diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 35b175736..b61138577 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -36,9 +36,8 @@ #include #include #include -#include #include -#include +#include #include #include #include diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index abbaaf15d..cd792c0b7 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -45,17 +45,16 @@ #include #include #include -#include #include #include -#include +#include #include #include #include #include #include #include -#include +#include #include #include "i18n.h" @@ -318,7 +317,7 @@ DCPDecoder::pass_texts (ContentTime next, dcp::Size size) void DCPDecoder::pass_texts ( - ContentTime next, shared_ptr asset, bool reference, int64_t entry_point, shared_ptr decoder, dcp::Size size + ContentTime next, shared_ptr asset, bool reference, int64_t entry_point, shared_ptr decoder, dcp::Size size ) { auto const vfr = _dcp_content->active_video_frame_rate (film()); @@ -326,16 +325,16 @@ DCPDecoder::pass_texts ( auto const frame = next.frames_round (vfr); if (_decode_referenced || !reference) { - auto subs = asset->subtitles_during ( + auto subs = asset->texts_during( dcp::Time (entry_point + frame, vfr, vfr), dcp::Time (entry_point + frame + 1, vfr, vfr), true ); - vector strings; + vector strings; for (auto i: subs) { - auto is = dynamic_pointer_cast(i); + auto is = dynamic_pointer_cast(i); if (is) { if (!strings.empty() && (strings.back().in() != is->in() || strings.back().out() != is->out())) { auto b = strings.back(); @@ -350,7 +349,7 @@ DCPDecoder::pass_texts ( strings.clear (); } - dcp::SubtitleString is_copy = *is; + auto is_copy = *is; if (is_copy.font()) { is_copy.set_font(_font_id_allocator.font_id(_reel - _reels.begin(), asset->id(), is_copy.font().get())); } else { @@ -363,7 +362,7 @@ DCPDecoder::pass_texts ( this would need to be done both here and in DCPSubtitleDecoder. */ - auto ii = dynamic_pointer_cast(i); + auto ii = dynamic_pointer_cast(i); if (ii) { emit_subtitle_image ( ContentTimePeriod ( diff --git a/src/lib/dcp_decoder.h b/src/lib/dcp_decoder.h index ee0f30694..56a13874b 100644 --- a/src/lib/dcp_decoder.h +++ b/src/lib/dcp_decoder.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace dcp { @@ -79,7 +79,7 @@ private: void pass_texts (dcpomatic::ContentTime next, dcp::Size size); void pass_texts ( dcpomatic::ContentTime next, - std::shared_ptr asset, + std::shared_ptr asset, bool reference, int64_t entry_point, std::shared_ptr decoder, diff --git a/src/lib/dcp_digest_file.cc b/src/lib/dcp_digest_file.cc index 4278caa98..57e87bd6f 100644 --- a/src/lib/dcp_digest_file.cc +++ b/src/lib/dcp_digest_file.cc @@ -24,9 +24,9 @@ #include #include #include +#include #include -#include -#include +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -80,7 +80,7 @@ write_dcp_digest_file ( if (in_reel->main_sound()) { add_asset(film_key, in_reel->main_sound(), in_reel->main_sound()->asset(), out_reel, "MainSound"); } - if (auto smpte_sub = dynamic_pointer_cast(in_reel->main_subtitle())) { + if (auto smpte_sub = dynamic_pointer_cast(in_reel->main_subtitle())) { add_asset(film_key, smpte_sub, smpte_sub->smpte_asset(), out_reel, "MainSubtitle"); } } diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index a7af9feca..3f8b4ca90 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -39,11 +39,10 @@ #include #include #include -#include #include #include #include -#include +#include #include #include #include @@ -51,7 +50,7 @@ #include #include #include -#include +#include #include #include "i18n.h" @@ -343,7 +342,7 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) LOG_GENERAL_NC ("Subtitle has no key"); break; } - sub->subtitles (); + sub->texts(); } if (i->atmos() && i->atmos()->asset_ref().resolved()) { diff --git a/src/lib/dcp_subtitle.cc b/src/lib/dcp_subtitle.cc index c2c3f7f70..c2d390b55 100644 --- a/src/lib/dcp_subtitle.cc +++ b/src/lib/dcp_subtitle.cc @@ -22,8 +22,8 @@ #include "dcp_subtitle.h" #include "exceptions.h" #include "compose.hpp" -#include -#include +#include +#include #include #include "i18n.h" @@ -35,22 +35,22 @@ using std::string; using std::make_shared; -shared_ptr +shared_ptr DCPSubtitle::load (boost::filesystem::path file) const { - shared_ptr sc; + shared_ptr sc; string interop_error; string smpte_error; try { - sc = make_shared(file); + sc = make_shared(file); } catch (exception& e) { interop_error = e.what (); } if (!sc) { try { - sc = make_shared(file); + sc = make_shared(file); } catch (exception& e) { smpte_error = e.what(); } diff --git a/src/lib/dcp_subtitle.h b/src/lib/dcp_subtitle.h index 285dd55bc..0f7928103 100644 --- a/src/lib/dcp_subtitle.h +++ b/src/lib/dcp_subtitle.h @@ -28,14 +28,14 @@ namespace dcp { - class SubtitleAsset; + class TextAsset; } class DCPSubtitle { protected: - std::shared_ptr load (boost::filesystem::path) const; + std::shared_ptr load(boost::filesystem::path) const; }; diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index 58007ac34..cbd8638f3 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -25,9 +25,9 @@ #include "font_id_allocator.h" #include "text_content.h" #include -#include +#include #include -#include +#include #include #include "i18n.h" @@ -64,8 +64,8 @@ DCPSubtitleContent::examine (shared_ptr film, shared_ptr job) auto subtitle_asset = load(path(0)); - auto iop = dynamic_pointer_cast(subtitle_asset); - auto smpte = dynamic_pointer_cast(subtitle_asset); + auto iop = dynamic_pointer_cast(subtitle_asset); + auto smpte = dynamic_pointer_cast(subtitle_asset); if (smpte) { set_video_frame_rate(film, smpte->edit_rate().numerator); } @@ -75,7 +75,7 @@ DCPSubtitleContent::examine (shared_ptr film, shared_ptr job) /* Default to turning these subtitles on */ only_text()->set_use (true); - _length = ContentTime::from_seconds(subtitle_asset->latest_subtitle_out().as_seconds()); + _length = ContentTime::from_seconds(subtitle_asset->latest_text_out().as_seconds()); subtitle_asset->fix_empty_font_ids(); add_fonts(only_text(), subtitle_asset); @@ -83,7 +83,7 @@ DCPSubtitleContent::examine (shared_ptr film, shared_ptr job) void -DCPSubtitleContent::add_fonts(shared_ptr content, shared_ptr subtitle_asset) +DCPSubtitleContent::add_fonts(shared_ptr content, shared_ptr subtitle_asset) { FontIDAllocator font_id_allocator; diff --git a/src/lib/dcp_subtitle_content.h b/src/lib/dcp_subtitle_content.h index a3cd78b39..53b2eaf5c 100644 --- a/src/lib/dcp_subtitle_content.h +++ b/src/lib/dcp_subtitle_content.h @@ -42,7 +42,7 @@ public: dcpomatic::DCPTime approximate_length () const override; private: - void add_fonts(std::shared_ptr content, std::shared_ptr subtitle_asset); + void add_fonts(std::shared_ptr content, std::shared_ptr subtitle_asset); dcpomatic::ContentTime _length; }; diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 711dc77f2..95e80ac19 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -25,7 +25,7 @@ #include "font.h" #include "text_content.h" #include "util.h" -#include +#include #include @@ -45,7 +45,7 @@ DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr film, shared_ptr< /* Load the XML or MXF file */ _asset = load(content->path(0)); _asset->fix_empty_font_ids(); - _subtitles = _asset->subtitles(); + _subtitles = _asset->texts(); _next = _subtitles.begin (); _subtitle_standard = _asset->subtitle_standard(); @@ -91,14 +91,14 @@ DCPSubtitleDecoder::pass () time of emitting the first. */ - vector s; - vector i; + vector s; + vector i; auto const p = content_time_period (*_next); while (_next != _subtitles.end () && content_time_period (*_next) == p) { - auto ns = dynamic_pointer_cast(*_next); + auto ns = dynamic_pointer_cast(*_next); if (ns) { - dcp::SubtitleString ns_copy = *ns; + auto ns_copy = *ns; if (ns_copy.font()) { ns_copy.set_font(_font_id_allocator.font_id(0, _asset->id(), ns_copy.font().get())); } else { @@ -111,7 +111,7 @@ DCPSubtitleDecoder::pass () this would need to be done both here and in DCPDecoder. */ - auto ni = dynamic_pointer_cast(*_next); + auto ni = dynamic_pointer_cast(*_next); if (ni) { emit_subtitle_image (p, *ni, film()->frame_size(), only_text()); ++_next; @@ -128,7 +128,7 @@ DCPSubtitleDecoder::pass () ContentTimePeriod -DCPSubtitleDecoder::content_time_period (shared_ptr s) const +DCPSubtitleDecoder::content_time_period(shared_ptr s) const { return { ContentTime::from_seconds(s->in().as_seconds()), diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_subtitle_decoder.h index 9d0851253..f11fc3044 100644 --- a/src/lib/dcp_subtitle_decoder.h +++ b/src/lib/dcp_subtitle_decoder.h @@ -38,14 +38,14 @@ public: boost::optional first () const; private: - dcpomatic::ContentTimePeriod content_time_period (std::shared_ptr s) const; + dcpomatic::ContentTimePeriod content_time_period(std::shared_ptr s) const; void update_position(); - std::vector> _subtitles; - std::vector>::const_iterator _next; + std::vector> _subtitles; + std::vector>::const_iterator _next; dcp::SubtitleStandard _subtitle_standard; - std::shared_ptr _asset; + std::shared_ptr _asset; FontIDAllocator _font_id_allocator; }; diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 29ab5aaf8..9713a26f6 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -45,7 +45,7 @@ #include "util.h" #include "video_decoder.h" #include "video_filter_graph.h" -#include +#include #include #include #include diff --git a/src/lib/font_id_allocator.cc b/src/lib/font_id_allocator.cc index d5430e858..b85fc90dc 100644 --- a/src/lib/font_id_allocator.cc +++ b/src/lib/font_id_allocator.cc @@ -24,9 +24,8 @@ #include "dcpomatic_assert.h" #include "font_id_allocator.h" #include -#include -#include -#include +#include +#include #include #include #include @@ -61,7 +60,7 @@ FontIDAllocator::add_fonts_from_reels(vector> const& reels void -FontIDAllocator::add_fonts_from_asset(int reel_index, shared_ptr asset) +FontIDAllocator::add_fonts_from_asset(int reel_index, shared_ptr asset) { for (auto const& font: asset->font_data()) { add_font(reel_index, asset->id(), font.first); diff --git a/src/lib/font_id_allocator.h b/src/lib/font_id_allocator.h index 6737907c1..2a242a8cf 100644 --- a/src/lib/font_id_allocator.h +++ b/src/lib/font_id_allocator.h @@ -32,7 +32,7 @@ namespace dcp { class Reel; - class SubtitleAsset; + class TextAsset; } @@ -74,7 +74,7 @@ public: } private: - void add_fonts_from_asset(int reel_index, std::shared_ptr asset); + void add_fonts_from_asset(int reel_index, std::shared_ptr asset); struct Font { diff --git a/src/lib/hints.cc b/src/lib/hints.cc index 1114d0acb..9a947f98d 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -42,8 +42,7 @@ #include #include #include -#include -#include +#include #include #include @@ -372,7 +371,7 @@ Hints::check_loudness () static bool -subtitle_mxf_too_big (shared_ptr asset) +subtitle_mxf_too_big(shared_ptr asset) { return asset && asset->file() && dcp::filesystem::file_size(*asset->file()) >= (MAX_TEXT_MXF_SIZE - SIZE_SLACK); } diff --git a/src/lib/map_cli.cc b/src/lib/map_cli.cc index be3841deb..149e09fbc 100644 --- a/src/lib/map_cli.cc +++ b/src/lib/map_cli.cc @@ -24,18 +24,17 @@ #include "util.h" #include #include -#include +#include #include #include #include #include #include -#include #include #include #include -#include -#include +#include +#include #include #include #include @@ -292,16 +291,16 @@ map_cli(int argc, char* argv[], std::function out) } }; - auto maybe_copy_font_and_images = [&maybe_copy, output_dir, copy](shared_ptr asset, bool rename, bool hard_link, bool soft_link) { - auto interop = dynamic_pointer_cast(asset); + auto maybe_copy_font_and_images = [&maybe_copy, output_dir, copy](shared_ptr asset, bool rename, bool hard_link, bool soft_link) { + auto interop = dynamic_pointer_cast(asset); boost::optional extra; if (interop) { extra = interop->id(); for (auto font_asset: interop->font_assets()) { maybe_copy(font_asset->id(), rename, hard_link, soft_link, extra); } - for (auto subtitle: interop->subtitles()) { - if (auto image = dynamic_pointer_cast(subtitle)) { + for (auto subtitle: interop->texts()) { + if (auto image = dynamic_pointer_cast(subtitle)) { auto const output_path = *output_dir / asset->id() / image->file()->filename(); copy(*image->file(), output_path, hard_link, soft_link); } diff --git a/src/lib/player.cc b/src/lib/player.cc index 14cd95906..20792aec4 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -54,10 +54,9 @@ #include "timer.h" #include "video_decoder.h" #include -#include #include #include -#include +#include #include #include #include diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index d8aff1162..5210466b2 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -41,24 +41,22 @@ #include #include #include -#include +#include #include #include #include #include -#include -#include +#include #include #include -#include -#include +#include #include #include -#include +#include #include #include #include -#include +#include #include "i18n.h" @@ -416,12 +414,13 @@ ReelWriter::finish (boost::filesystem::path output_dcp) /** Try to make a ReelAsset for a subtitles or closed captions in a given period in the DCP. - * A SubtitleAsset can be provided, or we will use one from @ref refs if not. + * A TextAsset can be provided, or we will use one from @ref refs if not. */ template shared_ptr maybe_add_text ( - shared_ptr asset, + shared_ptr asset, + dcp::TextType type, int64_t picture_duration, shared_ptr reel, int reel_index, @@ -439,17 +438,18 @@ maybe_add_text ( shared_ptr reel_asset; if (asset) { - if (auto interop = dynamic_pointer_cast(asset)) { + if (auto interop = dynamic_pointer_cast(asset)) { auto directory = output_dcp / interop->id (); dcp::filesystem::create_directories(directory); interop->write (directory / subtitle_asset_filename(asset, reel_index, reel_count, content_summary, ".xml")); reel_asset = make_shared ( + type, interop, dcp::Fraction(film->video_frame_rate(), 1), picture_duration, 0 ); - } else if (auto smpte = dynamic_pointer_cast(asset)) { + } else if (auto smpte = dynamic_pointer_cast(asset)) { /* All our assets should be the same length; use the picture asset length here as a reference to set the subtitle one. We'll use the duration rather than the intrinsic duration; we don't care if the picture asset has been trimmed, we're @@ -460,6 +460,7 @@ maybe_add_text ( output_dcp / subtitle_asset_filename(asset, reel_index, reel_count, content_summary, ".mxf") ); reel_asset = make_shared ( + type, smpte, dcp::Fraction(film->video_frame_rate(), 1), picture_duration, @@ -602,14 +603,15 @@ ReelWriter::create_reel_text ( set ensure_closed_captions ) const { - auto subtitle = maybe_add_text ( - _subtitle_asset, duration, reel, _reel_index, _reel_count, _content_summary, refs, film(), _period, output_dcp, _text_only + auto subtitle = maybe_add_text ( + _subtitle_asset, dcp::TextType::OPEN_SUBTITLE, duration, reel, _reel_index, _reel_count, _content_summary, refs, film(), _period, output_dcp, _text_only ); if (!subtitle && ensure_subtitles) { /* We had no subtitle asset, but we've been asked to make sure there is one */ - subtitle = maybe_add_text ( + subtitle = maybe_add_text( empty_text_asset(TextType::OPEN_SUBTITLE, optional(), true), + dcp::TextType::OPEN_SUBTITLE, duration, reel, _reel_index, @@ -631,8 +633,8 @@ ReelWriter::create_reel_text ( } for (auto const& i: _closed_caption_assets) { - auto a = maybe_add_text ( - i.second, duration, reel, _reel_index, _reel_count, _content_summary, refs, film(), _period, output_dcp, _text_only + auto a = maybe_add_text( + i.second, dcp::TextType::CLOSED_CAPTION, duration, reel, _reel_index, _reel_count, _content_summary, refs, film(), _period, output_dcp, _text_only ); DCPOMATIC_ASSERT (a); a->set_annotation_text (i.first.name); @@ -645,8 +647,9 @@ ReelWriter::create_reel_text ( /* Make empty tracks for anything we've been asked to ensure but that we haven't added */ for (auto i: ensure_closed_captions) { - auto a = maybe_add_text ( + auto a = maybe_add_text( empty_text_asset(TextType::CLOSED_CAPTION, i, true), + dcp::TextType::CLOSED_CAPTION, duration, reel, _reel_index, @@ -791,15 +794,15 @@ ReelWriter::write (shared_ptr audio) } -shared_ptr +shared_ptr ReelWriter::empty_text_asset (TextType type, optional track, bool with_dummy) const { - shared_ptr asset; + shared_ptr asset; optional font; auto lang = film()->subtitle_languages(); if (film()->interop()) { - auto s = make_shared(); + auto s = make_shared(); s->set_movie_title (film()->name()); if (type == TextType::OPEN_SUBTITLE) { s->set_language (lang.first ? lang.first->to_string() : "Unknown"); @@ -809,7 +812,7 @@ ReelWriter::empty_text_asset (TextType type, optional track, bool s->set_reel_number (raw_convert (_reel_index + 1)); asset = s; } else { - auto s = make_shared(); + auto s = make_shared(); s->set_content_title_text (film()->name()); s->set_metadata (mxf_metadata()); if (type == TextType::OPEN_SUBTITLE && lang.first) { @@ -829,7 +832,7 @@ ReelWriter::empty_text_asset (TextType type, optional track, bool if (with_dummy) { asset->add( - std::make_shared( + std::make_shared( font, false, false, @@ -897,7 +900,7 @@ ReelWriter::convert_vertical_position(StringText const& subtitle, dcp::SubtitleS void ReelWriter::write(PlayerText subs, TextType type, optional track, DCPTimePeriod period, FontIdMap const& fonts, shared_ptr chosen_interop_font) { - shared_ptr asset; + shared_ptr asset; switch (type) { case TextType::OPEN_SUBTITLE: @@ -934,7 +937,7 @@ ReelWriter::write(PlayerText subs, TextType type, optional track, i.set_in (dcp::Time(period.from.seconds() - _period.from.seconds(), tcr)); i.set_out (dcp::Time(period.to.seconds() - _period.from.seconds(), tcr)); i.set_v_position(convert_vertical_position(i, film()->interop() ? dcp::SubtitleStandard::INTEROP : dcp::SubtitleStandard::SMPTE_2014)); - auto sub = make_shared(i); + auto sub = make_shared(i); /* i.font is a shared_ptr which uniquely identifies the font we want, * though if we are Interop we can only have one font, so we'll use the chosen * one instead. @@ -951,7 +954,7 @@ ReelWriter::write(PlayerText subs, TextType type, optional track, for (auto i: subs.bitmap) { asset->add ( - make_shared( + make_shared( image_as_png(i.image), dcp::Time(period.from.seconds() - _period.from.seconds(), tcr), dcp::Time(period.to.seconds() - _period.from.seconds(), tcr), diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index 0b243b264..ac6531148 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -57,7 +57,7 @@ namespace dcp { class SoundAssetWriter; class StereoJ2KPictureAsset; class StereoJ2KPictureAssetWriter; - class SubtitleAsset; + class TextAsset; } @@ -107,7 +107,7 @@ private: Frame check_existing_picture_asset (boost::filesystem::path asset); bool existing_picture_frame_ok (dcp::File& asset_file, std::shared_ptr info_file, Frame frame) const; - std::shared_ptr empty_text_asset (TextType type, boost::optional track, bool with_dummy) const; + std::shared_ptr empty_text_asset (TextType type, boost::optional track, bool with_dummy) const; std::shared_ptr create_reel_picture (std::shared_ptr reel, std::list const & refs) const; void create_reel_sound (std::shared_ptr reel, std::list const & refs) const; @@ -145,8 +145,8 @@ private: std::shared_ptr _mpeg2_picture_asset_writer; std::shared_ptr _sound_asset; std::shared_ptr _sound_asset_writer; - std::shared_ptr _subtitle_asset; - std::map> _closed_caption_assets; + std::shared_ptr _subtitle_asset; + std::map> _closed_caption_assets; std::shared_ptr _atmos_asset; std::shared_ptr _atmos_asset_writer; diff --git a/src/lib/referenced_reel_asset.cc b/src/lib/referenced_reel_asset.cc index 3175d772d..5ef3b9ae7 100644 --- a/src/lib/referenced_reel_asset.cc +++ b/src/lib/referenced_reel_asset.cc @@ -27,10 +27,9 @@ #include "referenced_reel_asset.h" #include #include -#include #include #include -#include +#include #include diff --git a/src/lib/string_text.h b/src/lib/string_text.h index 787231b8c..d39a889cf 100644 --- a/src/lib/string_text.h +++ b/src/lib/string_text.h @@ -25,7 +25,7 @@ #include "font.h" #include -#include +#include /** A wrapper for SubtitleString which allows us to: @@ -36,13 +36,13 @@ * - include details of how v_align should be interpreted * * - specify the font by referring to a Font object from the content we came from, rather than - * having to use a DCP ID like in dcp::SubtitleString. + * having to use a DCP ID like in dcp::TextString. */ -class StringText : public dcp::SubtitleString +class StringText : public dcp::TextString { public: - StringText(dcp::SubtitleString dcp_, int outline_width_, std::shared_ptr font_, dcp::SubtitleStandard valign_standard_) - : dcp::SubtitleString (dcp_) + StringText(dcp::TextString dcp_, int outline_width_, std::shared_ptr font_, dcp::SubtitleStandard valign_standard_) + : dcp::TextString(dcp_) , outline_width (outline_width_) , font (font_) , valign_standard (valign_standard_) diff --git a/src/lib/string_text_file_decoder.cc b/src/lib/string_text_file_decoder.cc index 2ec0ec1cb..585d68888 100644 --- a/src/lib/string_text_file_decoder.cc +++ b/src/lib/string_text_file_decoder.cc @@ -19,11 +19,11 @@ */ -#include "string_text_file_decoder.h" #include "string_text_file_content.h" +#include "string_text_file_decoder.h" #include "text_content.h" #include "text_decoder.h" -#include +#include #include diff --git a/src/lib/subtitle_film_encoder.cc b/src/lib/subtitle_film_encoder.cc index 93ccc177b..8356433a8 100644 --- a/src/lib/subtitle_film_encoder.cc +++ b/src/lib/subtitle_film_encoder.cc @@ -25,9 +25,9 @@ #include "player.h" #include "subtitle_film_encoder.h" #include -#include +#include #include -#include +#include #include #include @@ -79,7 +79,7 @@ SubtitleFilmEncoder::SubtitleFilmEncoder(shared_ptr film, shared_ptr } } - _assets.push_back(make_pair(shared_ptr(), dcp::filesystem::change_extension(filename, extension))); + _assets.push_back(make_pair(shared_ptr(), dcp::filesystem::change_extension(filename, extension))); } for (auto i: film->reels()) { @@ -108,12 +108,12 @@ SubtitleFilmEncoder::go() if (!i.first) { /* No subtitles arrived for this asset; make an empty one so we write something to the output */ if (_film->interop()) { - auto s = make_shared(); + auto s = make_shared(); s->set_movie_title (_film->name()); s->set_reel_number (raw_convert(reel + 1)); i.first = s; } else { - auto s = make_shared(); + auto s = make_shared(); s->set_content_title_text (_film->name()); s->set_reel_number (reel + 1); i.first = s; @@ -140,10 +140,10 @@ SubtitleFilmEncoder::text(PlayerText subs, TextType type, optional } if (!_assets[_reel_index].first) { - shared_ptr asset; + shared_ptr asset; auto lang = _film->subtitle_languages (); if (_film->interop ()) { - auto s = make_shared(); + auto s = make_shared(); s->set_movie_title (_film->name()); if (lang.first) { s->set_language (lang.first->to_string()); @@ -151,7 +151,7 @@ SubtitleFilmEncoder::text(PlayerText subs, TextType type, optional s->set_reel_number (raw_convert(_reel_index + 1)); _assets[_reel_index].first = s; } else { - auto s = make_shared(); + auto s = make_shared(); s->set_content_title_text (_film->name()); if (lang.first) { s->set_language (*lang.first); @@ -176,7 +176,7 @@ SubtitleFilmEncoder::text(PlayerText subs, TextType type, optional if (_film->interop() && !_include_font) { i.unset_font (); } - _assets[_reel_index].first->add (make_shared(i)); + _assets[_reel_index].first->add(make_shared(i)); } if (_split_reels && (_reel_index < int(_reels.size()) - 1) && period.from > _reels[_reel_index].from) { diff --git a/src/lib/subtitle_film_encoder.h b/src/lib/subtitle_film_encoder.h index 54231794d..6482916cb 100644 --- a/src/lib/subtitle_film_encoder.h +++ b/src/lib/subtitle_film_encoder.h @@ -26,7 +26,7 @@ namespace dcp { - class SubtitleAsset; + class TextAsset; } @@ -53,7 +53,7 @@ public: private: void text (PlayerText subs, TextType type, boost::optional track, dcpomatic::DCPTimePeriod period); - std::vector, boost::filesystem::path>> _assets; + std::vector, boost::filesystem::path>> _assets; std::vector _reels; bool _split_reels; bool _include_font; diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index 945ffaa03..36909c2ee 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -128,7 +128,7 @@ TextDecoder::remove_invalid_characters_for_xml(string text) void -TextDecoder::emit_plain_start(ContentTime from, vector subtitles, dcp::SubtitleStandard valign_standard) +TextDecoder::emit_plain_start(ContentTime from, vector subtitles, dcp::SubtitleStandard valign_standard) { vector string_texts; @@ -274,7 +274,7 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & sub_subti return dcp::Colour(lrintf(c.r * 255), lrintf(c.g * 255), lrintf(c.b * 255)); }; - auto dcp_subtitle = dcp::SubtitleString( + auto dcp_subtitle = dcp::TextString( optional(), block.italic, block.bold, @@ -337,7 +337,7 @@ TextDecoder::emit_stop (ContentTime to) void -TextDecoder::emit_plain(ContentTimePeriod period, vector subtitles, dcp::SubtitleStandard valign_standard) +TextDecoder::emit_plain(ContentTimePeriod period, vector subtitles, dcp::SubtitleStandard valign_standard) { emit_plain_start (period.from, subtitles, valign_standard); emit_stop (period.to); diff --git a/src/lib/text_decoder.h b/src/lib/text_decoder.h index 1a7632fd8..26248ef06 100644 --- a/src/lib/text_decoder.h +++ b/src/lib/text_decoder.h @@ -30,7 +30,7 @@ #include "content_text.h" #include "types.h" #include -#include +#include #include @@ -52,9 +52,9 @@ public: void emit_bitmap_start (ContentBitmapText const& bitmap); void emit_bitmap (dcpomatic::ContentTimePeriod period, std::shared_ptr image, dcpomatic::Rect rect); - void emit_plain_start(dcpomatic::ContentTime from, std::vector s, dcp::SubtitleStandard valign_standard); + void emit_plain_start(dcpomatic::ContentTime from, std::vector s, dcp::SubtitleStandard valign_standard); void emit_plain_start (dcpomatic::ContentTime from, sub::Subtitle const & subtitle); - void emit_plain(dcpomatic::ContentTimePeriod period, std::vector s, dcp::SubtitleStandard valign_standard); + void emit_plain(dcpomatic::ContentTimePeriod period, std::vector s, dcp::SubtitleStandard valign_standard); void emit_plain (dcpomatic::ContentTimePeriod period, sub::Subtitle const & subtitle); void emit_stop (dcpomatic::ContentTime to); diff --git a/src/lib/text_type.cc b/src/lib/text_type.cc index b1dcfc99c..4f8f50ac5 100644 --- a/src/lib/text_type.cc +++ b/src/lib/text_type.cc @@ -38,6 +38,10 @@ string_to_text_type(string s) return TextType::UNKNOWN; } else if (s == "open-subtitle") { return TextType::OPEN_SUBTITLE; + } else if (s == "open-caption") { + return TextType::OPEN_CAPTION; + } else if (s == "closed-subtitle") { + return TextType::CLOSED_SUBTITLE; } else if (s == "closed-caption") { return TextType::CLOSED_CAPTION; } else { @@ -53,6 +57,10 @@ text_type_to_string(TextType t) return "unknown"; case TextType::OPEN_SUBTITLE: return "open-subtitle"; + case TextType::OPEN_CAPTION: + return "open-caption"; + case TextType::CLOSED_SUBTITLE: + return "closed-subtitle"; case TextType::CLOSED_CAPTION: return "closed-caption"; default: @@ -68,6 +76,10 @@ text_type_to_name(TextType t) return _("Timed text"); case TextType::OPEN_SUBTITLE: return _("Open subtitles"); + case TextType::OPEN_CAPTION: + return _("Open captions"); + case TextType::CLOSED_SUBTITLE: + return _("Closed subtitles"); case TextType::CLOSED_CAPTION: return _("Closed captions"); default: diff --git a/src/lib/text_type.h b/src/lib/text_type.h index d21e03a60..94224af4e 100644 --- a/src/lib/text_type.h +++ b/src/lib/text_type.h @@ -34,8 +34,6 @@ * - open: on-screen * - closed: only visible by some audience members * - * At the moment DoM supports open subtitles and closed captions. - * * There is some use of the word `subtitle' in the code which may mean * caption in some contexts. */ @@ -43,6 +41,8 @@ enum class TextType { UNKNOWN, OPEN_SUBTITLE, + OPEN_CAPTION, + CLOSED_SUBTITLE, CLOSED_CAPTION, COUNT }; diff --git a/src/lib/util.cc b/src/lib/util.cc index 172b8d763..2e3485075 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include LIBDCP_DISABLE_WARNINGS @@ -475,7 +475,7 @@ LIBDCP_ENABLE_WARNINGS #if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX) /* Render something to fontconfig to create its cache */ vector subs; - dcp::SubtitleString ss( + dcp::TextString ss( optional(), false, false, false, dcp::Colour(), 42, 1, dcp::Time(), dcp::Time(), 0, dcp::HAlign::CENTER, 0, dcp::VAlign::CENTER, 0, dcp::Direction::LTR, "Hello dolly", dcp::Effect::NONE, dcp::Colour(), dcp::Time(), dcp::Time(), 0, std::vector() ); @@ -763,7 +763,7 @@ audio_asset_filename (shared_ptr asset, int reel_index, int ree string -subtitle_asset_filename (shared_ptr asset, int reel_index, int reel_count, optional summary, string extension) +subtitle_asset_filename (shared_ptr asset, int reel_index, int reel_count, optional summary, string extension) { return asset_filename(asset, "sub", reel_index, reel_count, summary, extension); } @@ -910,7 +910,7 @@ utf8_strlen (string s) /** @param size Size of picture that the subtitle will be overlaid onto */ void -emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, shared_ptr decoder) +emit_subtitle_image(ContentTimePeriod period, dcp::TextImage sub, dcp::Size size, shared_ptr decoder) { /* XXX: this is rather inefficient; decoding the image just to get its size */ FFmpegImageProxy proxy (sub.png_image()); diff --git a/src/lib/util.h b/src/lib/util.h index 7c40c5ce8..d6ed0bccc 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,7 +50,7 @@ namespace dcp { class PictureAsset; class SoundAsset; - class SubtitleAsset; + class TextAsset; } extern std::string program_name; @@ -82,13 +82,13 @@ extern dcp::Size fit_ratio_within (float ratio, dcp::Size); extern void set_backtrace_file (boost::filesystem::path); extern std::string video_asset_filename (std::shared_ptr asset, int reel_index, int reel_count, boost::optional content_summary); extern std::string audio_asset_filename (std::shared_ptr asset, int reel_index, int reel_count, boost::optional content_summary); -extern std::string subtitle_asset_filename (std::shared_ptr asset, int reel_index, int reel_count, boost::optional content_summary, std::string extension); +extern std::string subtitle_asset_filename (std::shared_ptr asset, int reel_index, int reel_count, boost::optional content_summary, std::string extension); extern std::string atmos_asset_filename (std::shared_ptr asset, int reel_index, int reel_count, boost::optional content_summary); extern std::string careful_string_filter (std::string); extern std::pair audio_channel_types (std::list mapped, int channels); extern std::shared_ptr remap (std::shared_ptr input, int output_channels, AudioMapping map); extern size_t utf8_strlen (std::string s); -extern void emit_subtitle_image (dcpomatic::ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, std::shared_ptr decoder); +extern void emit_subtitle_image (dcpomatic::ContentTimePeriod period, dcp::TextImage sub, dcp::Size size, std::shared_ptr decoder); extern void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function); extern dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta); extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm); diff --git a/src/lib/writer.cc b/src/lib/writer.cc index f9293ed09..29fc543ba 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -43,9 +43,8 @@ #include #include #include -#include #include -#include +#include #include #include #include @@ -945,19 +944,21 @@ Writer::write (ReferencedReelAsset asset) { _reel_assets.push_back (asset); - if (dynamic_pointer_cast(asset.asset)) { - _have_subtitles = true; - } else if (auto ccap = dynamic_pointer_cast(asset.asset)) { - /* This feels quite fragile. We have a referenced reel and want to know if it's - * part of a given closed-caption track so that we can fill if it has any - * missing reels. I guess for that purpose almost any DCPTextTrack values are - * fine so long as they are consistent. - */ - DCPTextTrack track; - track.name = ccap->annotation_text().get_value_or(""); - track.language = dcp::LanguageTag(ccap->language().get_value_or("en-US")); - if (_have_closed_captions.find(track) == _have_closed_captions.end()) { - _have_closed_captions.insert(track); + if (auto text_asset = dynamic_pointer_cast(asset.asset)) { + if (text_asset->type() == dcp::TextType::OPEN_SUBTITLE || text_asset->type() == dcp::TextType::OPEN_CAPTION) { + _have_subtitles = true; + } else { + /* This feels quite fragile. We have a referenced reel and want to know if it's + * part of a given closed-caption track so that we can fill if it has any + * missing reels. I guess for that purpose almost any DCPTextTrack values are + * fine so long as they are consistent. + */ + DCPTextTrack track; + track.name = text_asset->annotation_text().get_value_or(""); + track.language = dcp::LanguageTag(text_asset->language().get_value_or("en-US")); + if (_have_closed_captions.find(track) == _have_closed_captions.end()) { + _have_closed_captions.insert(track); + } } } } -- cgit v1.2.3