diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-01-04 23:37:15 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-01-04 23:37:15 +0100 |
| commit | 9289657288a73a32063db6703792a60bf60e66a4 (patch) | |
| tree | 7d0e39b4e69689e59fe1b80ad82987aafffe7dde /src/lib | |
| parent | 1c1395154a67ddad9c576d613138897b39851e08 (diff) | |
| parent | ebecf95d5f3bd55fcf65535fe3e509a5e24c6438 (diff) | |
Merge branch '2694-remove-odd-check'
Allow referring to OVs where not every reel has a subtitle/ccap,
fixing it if required by adding our own reels.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dcp_content.cc | 19 | ||||
| -rw-r--r-- | src/lib/font_id_allocator.cc | 8 | ||||
| -rw-r--r-- | src/lib/referenced_reel_asset.cc | 2 | ||||
| -rw-r--r-- | src/lib/writer.cc | 18 |
4 files changed, 26 insertions, 21 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 2d441353a..b9b64149f 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -720,14 +720,6 @@ DCPContent::can_reference_audio (shared_ptr<const Film> film, string& why_not) c return false; } - for (auto i: decoder->reels()) { - if (!i->main_sound()) { - /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - why_not = _("it does not have sound in all its reels."); - return false; - } - } - /// TRANSLATORS: this string will follow "Cannot reference this DCP: " return can_reference( film, [](shared_ptr<const Content> c) { @@ -755,22 +747,13 @@ DCPContent::can_reference_text (shared_ptr<const Film> film, TextType type, stri for (auto i: decoder->reels()) { if (type == TextType::OPEN_SUBTITLE) { - if (!i->main_subtitle()) { - /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - why_not = _("it does not have open subtitles in all its reels."); - return false; - } else if (i->main_subtitle()->entry_point().get_value_or(0) != 0) { + if (i->main_subtitle() && i->main_subtitle()->entry_point().get_value_or(0) != 0) { /// TRANSLATORS: this string will follow "Cannot reference this DCP: " why_not = _("one of its subtitle reels has a non-zero entry point so it must be re-written."); return false; } } if (type == TextType::CLOSED_CAPTION) { - if (i->closed_captions().empty()) { - /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - why_not = _("it does not have closed captions in all its reels."); - return false; - } for (auto j: i->closed_captions()) { if (j->entry_point().get_value_or(0) != 0) { /// TRANSLATORS: this string will follow "Cannot reference this DCP: " diff --git a/src/lib/font_id_allocator.cc b/src/lib/font_id_allocator.cc index 70eda2b06..c566c3676 100644 --- a/src/lib/font_id_allocator.cc +++ b/src/lib/font_id_allocator.cc @@ -44,11 +44,15 @@ FontIDAllocator::add_fonts_from_reels(vector<shared_ptr<dcp::Reel>> const& reels int reel_index = 0; for (auto reel: reels) { if (auto sub = reel->main_subtitle()) { - add_fonts_from_asset(reel_index, sub->asset()); + if (sub->asset_ref().resolved()) { + add_fonts_from_asset(reel_index, sub->asset()); + } } for (auto ccap: reel->closed_captions()) { - add_fonts_from_asset(reel_index, ccap->asset()); + if (ccap->asset_ref().resolved()) { + add_fonts_from_asset(reel_index, ccap->asset()); + } } ++reel_index; diff --git a/src/lib/referenced_reel_asset.cc b/src/lib/referenced_reel_asset.cc index bd87b905a..3175d772d 100644 --- a/src/lib/referenced_reel_asset.cc +++ b/src/lib/referenced_reel_asset.cc @@ -116,7 +116,7 @@ get_referenced_reel_assets(shared_ptr<const Film> film, shared_ptr<const Playlis maybe_add_asset (reel_assets, reel->main_sound(), reel_trim_start, reel_trim_end, from, frame_rate); } - if (dcp->reference_text(TextType::OPEN_SUBTITLE)) { + if (dcp->reference_text(TextType::OPEN_SUBTITLE) && reel->main_subtitle()) { maybe_add_asset (reel_assets, reel->main_subtitle(), reel_trim_start, reel_trim_end, from, frame_rate); } diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 8863816e8..fbe2d248d 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -41,7 +41,9 @@ #include <dcp/cpl.h> #include <dcp/locale_convert.h> #include <dcp/raw_convert.h> +#include <dcp/reel_closed_caption_asset.h> #include <dcp/reel_file_asset.h> +#include <dcp/reel_subtitle_asset.h> #include <cerrno> #include <cfloat> #include <set> @@ -930,6 +932,22 @@ void Writer::write (ReferencedReelAsset asset) { _reel_assets.push_back (asset); + + if (dynamic_pointer_cast<dcp::ReelSubtitleAsset>(asset.asset)) { + _have_subtitles = true; + } else if (auto ccap = dynamic_pointer_cast<dcp::ReelClosedCaptionAsset>(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); + } + } } |
