From 3433dfa45f15e40ed9d5f5d17045f02bb6fd01ce Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 14 Jan 2025 10:51:04 +0100 Subject: Extract dcpomatic::film::is_vf(). --- src/lib/film.cc | 21 ++------------------- src/lib/film_util.cc | 28 ++++++++++++++++++++++++++++ src/lib/film_util.h | 1 + 3 files changed, 31 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/lib/film.cc b/src/lib/film.cc index 6c5aa0cbb..e2df95e32 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -46,6 +46,7 @@ #include "ffmpeg_subtitle_stream.h" #include "file_log.h" #include "film.h" +#include "film_util.h" #include "font.h" #include "job.h" #include "job_manager.h" @@ -1108,25 +1109,7 @@ Film::isdcf_name (bool if_created_now) const isdcf_name += "-3D"; } - auto vf = false; - for (auto content: content_list) { - auto dcp = dynamic_pointer_cast(content); - if (!dcp) { - continue; - } - - bool any_text = false; - for (int i = 0; i < static_cast(TextType::COUNT); ++i) { - if (dcp->reference_text(static_cast(i))) { - any_text = true; - } - } - if (dcp->reference_video() || dcp->reference_audio() || any_text) { - vf = true; - } - } - - if (vf) { + if (dcpomatic::film::is_vf(shared_from_this())) { isdcf_name += "_VF"; } else { isdcf_name += "_OV"; diff --git a/src/lib/film_util.cc b/src/lib/film_util.cc index e5bc30db4..13068e91d 100644 --- a/src/lib/film_util.cc +++ b/src/lib/film_util.cc @@ -20,10 +20,13 @@ #include "config.h" +#include "content.h" +#include "dcp_content.h" #include "film.h" #include "film_util.h" +using std::dynamic_pointer_cast; using std::shared_ptr; using boost::optional; @@ -45,3 +48,28 @@ dcpomatic::film::add_files_override_path(shared_ptr film) : boost::optional(); } + + +bool +dcpomatic::film::is_vf(shared_ptr film) +{ + for (auto content: film->content()) { + auto dcp = dynamic_pointer_cast(content); + if (!dcp) { + continue; + } + + bool any_text = false; + for (int i = 0; i < static_cast(TextType::COUNT); ++i) { + if (dcp->reference_text(static_cast(i))) { + any_text = true; + } + } + if (dcp->reference_video() || dcp->reference_audio() || any_text) { + return true; + } + } + + return false; +} + diff --git a/src/lib/film_util.h b/src/lib/film_util.h index 958c2c3cc..50fbf22bd 100644 --- a/src/lib/film_util.h +++ b/src/lib/film_util.h @@ -33,6 +33,7 @@ namespace film bool channel_is_mapped(std::shared_ptr film, dcp::Channel channel); boost::optional add_files_override_path(std::shared_ptr film); +bool is_vf(std::shared_ptr film); } -- cgit v1.2.3