From 15a83d720780d58f905d40f8493cdcb86596eaee Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 10 May 2020 01:57:20 +0200 Subject: Change video content scaling so that it either: 1. scales the content up to fit the DCP container, preserving aspect ratio, or 2. stretches the content to a custom aspect ratio, or 3. scales the content to some custom size. --- src/lib/util.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/lib/util.cc') diff --git a/src/lib/util.cc b/src/lib/util.cc index d04bbdf24..c1ef4245f 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -394,7 +394,6 @@ dcpomatic_setup () Ratio::setup_ratios (); PresetColourConversion::setup_colour_conversion_presets (); - VideoContentScale::setup_scales (); DCPContentType::setup_dcp_content_types (); Filter::setup_filters (); CinemaSoundProcessor::setup_cinema_sound_processors (); @@ -1184,3 +1183,21 @@ linear_to_db (double linear) return 20 * log10(linear); } + +dcp::Size +scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container) +{ + /* Now scale it down if the display container is smaller than the film container */ + if (display_container != film_container) { + float const scale = min ( + float (display_container.width) / film_container.width, + float (display_container.height) / film_container.height + ); + + s.width = lrintf (s.width * scale); + s.height = lrintf (s.height * scale); + } + + return s; +} + -- cgit v1.2.3