diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-05-14 23:01:34 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-01-28 02:01:58 +0100 |
| commit | db63785a521d31a6bb1e7109e83768880fefa783 (patch) | |
| tree | d88a1c4f8a62beaf7314bec77fb46beac676b196 /src/lib/dcp_content.cc | |
| parent | b24eb0e8fbad6779c77f7015d3a8c8c5cf206706 (diff) | |
Cleanup: rearrange how overlap checking is done in can_reference().
Diffstat (limited to 'src/lib/dcp_content.cc')
| -rw-r--r-- | src/lib/dcp_content.cc | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index f3751b1d8..80cb67839 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -612,7 +612,7 @@ DCPContent::reel_split_points (shared_ptr<const Film> film) const } bool -DCPContent::can_reference (shared_ptr<const Film> film, function<bool (shared_ptr<const Content>)> part, string overlapping, string& why_not) const +DCPContent::can_reference(shared_ptr<const Film> film, string& why_not) const { /* We must be using the same standard as the film */ if (_standard) { @@ -658,15 +658,16 @@ DCPContent::can_reference (shared_ptr<const Film> film, function<bool (shared_pt } } - auto a = overlaps (film, film->content(), part, position(), end(film)); - if (a.size() != 1 || a.front().get() != this) { - why_not = overlapping; - return false; - } - return true; } +bool +DCPContent::overlaps(shared_ptr<const Film> film, function<bool (shared_ptr<const Content>)> part) const +{ + auto const a = dcpomatic::overlaps(film, film->content(), part, position(), end(film)); + return a.size() != 1 || a.front().get() != this; +} + bool DCPContent::can_reference_video (shared_ptr<const Film> film, string& why_not) const @@ -691,15 +692,17 @@ DCPContent::can_reference_video (shared_ptr<const Film> film, string& why_not) c return false; } - /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - return can_reference( - film, - [](shared_ptr<const Content> c) { - return static_cast<bool>(c->video) && c->video->use(); - }, - _("it overlaps other video content; remove the other content."), - why_not - ); + auto part = [](shared_ptr<const Content> c) { + return static_cast<bool>(c->video) && c->video->use(); + }; + + if (overlaps(film, part)) { + /// TRANSLATORS: this string will follow "Cannot reference this DCP: " + why_not = _("it overlaps other video content; remove the other content."); + return false; + } + + return can_reference(film, why_not); } @@ -720,14 +723,17 @@ DCPContent::can_reference_audio (shared_ptr<const Film> film, string& why_not) c return false; } - /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - return can_reference( - film, [](shared_ptr<const Content> c) { - return static_cast<bool>(c->audio) && !c->audio->mapping().mapped_output_channels().empty(); - }, - _("it overlaps other audio content; remove the other content."), - why_not - ); + auto part = [](shared_ptr<const Content> c) { + return static_cast<bool>(c->audio) && !c->audio->mapping().mapped_output_channels().empty(); + }; + + if (overlaps(film, part)) { + /// TRANSLATORS: this string will follow "Cannot reference this DCP: " + why_not = _("it overlaps other audio content; remove the other content."); + return false; + } + + return can_reference(film, why_not); } @@ -770,15 +776,17 @@ DCPContent::can_reference_text (shared_ptr<const Film> film, TextType type, stri return false; } - /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - return can_reference( - film, - [type](shared_ptr<const Content> c) { - return std::find_if(c->text.begin(), c->text.end(), [type](shared_ptr<const TextContent> t) { return t->type() == type; }) != c->text.end(); - }, - _("they overlap other text content; remove the other content."), - why_not - ); + auto part = [type](shared_ptr<const Content> c) { + return std::find_if(c->text.begin(), c->text.end(), [type](shared_ptr<const TextContent> t) { return t->type() == type; }) != c->text.end(); + }; + + if (overlaps(film, part)) { + /// TRANSLATORS: this string will follow "Cannot reference this DCP: " + why_not = _("it overlaps other text content; remove the other content."); + return false; + } + + return can_reference(film, why_not); } void |
