Don't use pointless scale_for_display() (#2485).
authorCarl Hetherington <cth@carlh.net>
Wed, 15 Mar 2023 23:28:27 +0000 (00:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 15 Mar 2023 23:44:42 +0000 (00:44 +0100)
Not only is it much more complicated than it needs to be, but it
also meant that for a PlayerVideo _inter_size and _out_size are
calculated slightly differently, meaning that when trying to
put a full-frame image into the output there could sometimes be
small differences between the two, meaning small gaps.

src/lib/player.cc
src/lib/player_video.cc
src/lib/util.cc
src/lib/util.h

index 610d7748dd131bd062d812bb3862281850ed5841..aad423094e191750b72adae3d29183faa975d1b1 100644 (file)
@@ -1093,12 +1093,7 @@ Player::video (weak_ptr<Piece> weak_piece, ContentVideo video)
                        video.image,
                        content_video->actual_crop(),
                        content_video->fade(film, video.frame),
-                       scale_for_display(
-                               content_video->scaled_size(film->frame_size()),
-                               _video_container_size,
-                               film->frame_size(),
-                               content_video->pixel_quanta()
-                               ),
+                       content_video->scaled_size(_video_container_size),
                        _video_container_size,
                        eyes,
                        video.part,
index d45bf9f432b90c996feb870baf1580fc3a5796a4..37fc817d17fac3f4df6b36ee8cadcb9651b4dff1 100644 (file)
@@ -362,12 +362,7 @@ PlayerVideo::reset_metadata (shared_ptr<const Film> film, dcp::Size player_video
 
        _crop = content->video->actual_crop();
        _fade = content->video->fade(film, _video_frame.get());
-       _inter_size = scale_for_display(
-               content->video->scaled_size(film->frame_size()),
-               player_video_container_size,
-               film->frame_size(),
-               content->video->pixel_quanta()
-               );
+       _inter_size = content->video->scaled_size(player_video_container_size);
        _out_size = player_video_container_size;
        _colour_conversion = content->video->colour_conversion();
        _video_range = content->video->range();
index 20a96578144109bd613cbf2a98f6f5cb6df0ff18..9e077c7e0d6d7b01c009cb1c6988aa6c2a1e3f3f 100644 (file)
@@ -980,25 +980,6 @@ copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::fun
 }
 
 
-dcp::Size
-scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta)
-{
-       /* 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);
-               s = quanta.round (s);
-       }
-
-       return s;
-}
-
-
 dcp::DecryptedKDM
 decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm)
 {
index 4c8a2b1b7f4bba978c05c1a1f13ad9c41e6d66b3..26698af02d5d9bd309327fad74353a3fa6cd25bc 100644 (file)
@@ -89,7 +89,6 @@ extern std::shared_ptr<AudioBuffers> remap (std::shared_ptr<const AudioBuffers>
 extern size_t utf8_strlen (std::string s);
 extern void emit_subtitle_image (dcpomatic::ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, std::shared_ptr<TextDecoder> decoder);
 extern void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function<void (float)>);
-extern dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta);
 extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm);
 extern boost::filesystem::path default_font_file ();
 extern void start_of_thread (std::string name);