From 3ffd0163026be24e5373e0674c3301ed37546e44 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 21 Feb 2024 10:47:38 +0100 Subject: Make DCPExaminer::size() optional and deal with the consequences. This means we can fix the case of a VF having no known size in a nice way, in turn fixing problems caused by the fix to #2775. --- src/lib/film.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/lib/film.cc') diff --git a/src/lib/film.cc b/src/lib/film.cc index 0bba13e28..d9ab6e2a3 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -943,10 +943,12 @@ Film::isdcf_name (bool if_created_now) const if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::ContentKind::TRAILER) { auto first_video = std::find_if(content_list.begin(), content_list.end(), [](shared_ptr c) { return static_cast(c->video); }); if (first_video != content_list.end()) { - auto first_ratio = lrintf((*first_video)->video->scaled_size(frame_size()).ratio() * 100); - auto container_ratio = lrintf(container()->ratio() * 100); - if (first_ratio != container_ratio) { - isdcf_name += "-" + dcp::raw_convert(first_ratio); + if (auto scaled_size = (*first_video)->video->scaled_size(frame_size())) { + auto first_ratio = lrintf(scaled_size->ratio() * 100); + auto container_ratio = lrintf(container()->ratio() * 100); + if (first_ratio != container_ratio) { + isdcf_name += "-" + dcp::raw_convert(first_ratio); + } } } } @@ -1435,13 +1437,13 @@ Film::maybe_set_container_and_resolution () } } - if (video) { + if (video && video->size()) { /* This is the only piece of video content in this Film. Use it to make a guess for * DCP container size and resolution, unless the user has already explicitly set these * things. */ if (!_user_explicit_container) { - if (video->size().ratio() > 2.3) { + if (video->size()->ratio() > 2.3) { set_container (Ratio::from_id("239"), false); } else { set_container (Ratio::from_id("185"), false); @@ -1449,7 +1451,7 @@ Film::maybe_set_container_and_resolution () } if (!_user_explicit_resolution) { - if (video->size_after_crop().width > 2048 || video->size_after_crop().height > 1080) { + if (video->size_after_crop()->width > 2048 || video->size_after_crop()->height > 1080) { set_resolution (Resolution::FOUR_K, false); } else { set_resolution (Resolution::TWO_K, false); @@ -1647,9 +1649,10 @@ Film::active_area () const for (auto i: content()) { if (i->video) { - dcp::Size s = i->video->scaled_size (frame); - active.width = max(active.width, s.width); - active.height = max(active.height, s.height); + if (auto s = i->video->scaled_size(frame)) { + active.width = max(active.width, s->width); + active.height = max(active.height, s->height); + } } } -- cgit v1.2.3