From ae15eeca8588c6928d7671894db98c2e289fa601 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 2 May 2015 20:20:32 +0100 Subject: [PATCH] Remove approximate size stuff where playback viewer would round down to nearest 4 pixels to try and speed up scaling. It didn't work as the two estimates of what would be scaled didn't always agree. It could probably be resurrected. --- src/lib/film.cc | 2 +- src/lib/image_filename_sorter.cc | 1 - src/lib/player.cc | 9 +-------- src/lib/player.h | 2 -- src/lib/util.cc | 6 +++--- src/lib/util.h | 2 +- src/lib/video_content.cc | 2 +- src/lib/video_content_scale.cc | 10 +++++----- src/lib/video_content_scale.h | 2 +- src/wx/film_viewer.cc | 8 -------- test/ratio_test.cc | 16 ++++++++-------- test/video_content_scale_test.cc | 2 +- 12 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index 3cdaeb48a..80755a4cb 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1041,7 +1041,7 @@ Film::full_frame () const dcp::Size Film::frame_size () const { - return fit_ratio_within (container()->ratio(), full_frame (), 1); + return fit_ratio_within (container()->ratio(), full_frame ()); } dcp::EncryptedKDM diff --git a/src/lib/image_filename_sorter.cc b/src/lib/image_filename_sorter.cc index 805c469b0..0cb6adc6b 100644 --- a/src/lib/image_filename_sorter.cc +++ b/src/lib/image_filename_sorter.cc @@ -30,7 +30,6 @@ public: boost::optional na = extract_number (a); boost::optional nb = extract_number (b); if (!na || !nb) { - std::cout << a << " " << b << " " << (a.string() < b.string()) << "\n"; return a.string() < b.string(); } diff --git a/src/lib/player.cc b/src/lib/player.cc index 495d20533..436ae3fe8 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -71,7 +71,6 @@ Player::Player (shared_ptr f, shared_ptr p) : _film (f) , _playlist (p) , _have_valid_pieces (false) - , _approximate_size (false) , _ignore_video (false) { _playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this)); @@ -295,12 +294,6 @@ Player::transform_image_subtitles (list subs) const return all; } -void -Player::set_approximate_size () -{ - _approximate_size = true; -} - shared_ptr Player::black_player_video_frame (DCPTime time) const { @@ -352,7 +345,7 @@ Player::get_video (DCPTime time, bool accurate) return pvf; } - dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size (), _approximate_size ? 4 : 1); + dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size ()); for (list::const_iterator i = content_video.begin(); i != content_video.end(); ++i) { pvf.push_back ( diff --git a/src/lib/player.h b/src/lib/player.h index 01439a26f..d8b13ee7b 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -92,7 +92,6 @@ public: std::list > get_subtitle_fonts (); void set_video_container_size (dcp::Size); - void set_approximate_size (); void set_ignore_video (); PlayerStatistics const & statistics () const; @@ -157,7 +156,6 @@ private: dcp::Size _video_container_size; boost::shared_ptr _black_image; - bool _approximate_size; /** true if the player should ignore all video; i.e. never produce any */ bool _ignore_video; diff --git a/src/lib/util.cc b/src/lib/util.cc index 08683fb7e..bffbe90d4 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -546,13 +546,13 @@ tidy_for_filename (string f) } dcp::Size -fit_ratio_within (float ratio, dcp::Size full_frame, int round) +fit_ratio_within (float ratio, dcp::Size full_frame) { if (ratio < full_frame.ratio ()) { - return dcp::Size (round_to (full_frame.height * ratio, round), full_frame.height); + return dcp::Size (rint (full_frame.height * ratio), full_frame.height); } - return dcp::Size (full_frame.width, round_to (full_frame.width / ratio, round)); + return dcp::Size (full_frame.width, rint (full_frame.width / ratio)); } void * diff --git a/src/lib/util.h b/src/lib/util.h index bf1d0265b..c1f7a78c7 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -69,7 +69,7 @@ extern bool valid_j2k_file (boost::filesystem::path); extern boost::filesystem::path mo_path (); #endif extern std::string tidy_for_filename (std::string); -extern dcp::Size fit_ratio_within (float ratio, dcp::Size, int); +extern dcp::Size fit_ratio_within (float ratio, dcp::Size); extern int dcp_audio_frame_rate (int); extern int stride_round_up (int, int const *, int); extern int round_to (float n, int r); diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index bfbcef9bf..68db672f1 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -540,7 +540,7 @@ VideoContent::processing_description () const DCPOMATIC_ASSERT (film); dcp::Size const container_size = film->frame_size (); - dcp::Size const scaled = scale().size (dynamic_pointer_cast (shared_from_this ()), container_size, container_size, 1); + dcp::Size const scaled = scale().size (dynamic_pointer_cast (shared_from_this ()), container_size, container_size); if (scaled != video_size_after_crop ()) { d << String::compose ( diff --git a/src/lib/video_content_scale.cc b/src/lib/video_content_scale.cc index 14db7b02f..59ff4bd9b 100644 --- a/src/lib/video_content_scale.cc +++ b/src/lib/video_content_scale.cc @@ -127,22 +127,22 @@ VideoContentScale::from_id (string id) * @param film_container The size of the film's image. */ dcp::Size -VideoContentScale::size (shared_ptr c, dcp::Size display_container, dcp::Size film_container, int round) const +VideoContentScale::size (shared_ptr c, dcp::Size display_container, dcp::Size film_container) const { /* Work out the size of the content if it were put inside film_container */ - dcp::Size video_size_after_crop = c->video_size_after_crop (); - + dcp::Size const video_size_after_crop = c->video_size_after_crop (); + dcp::Size size; if (_ratio) { /* Stretch to fit the requested ratio */ - size = fit_ratio_within (_ratio->ratio (), film_container, round); + size = fit_ratio_within (_ratio->ratio (), film_container); } else if (_scale || video_size_after_crop.width > film_container.width || video_size_after_crop.height > film_container.height) { /* Scale, preserving aspect ratio; this is either if we have been asked to scale with no stretch or if the unscaled content is too big for film_container. */ - size = fit_ratio_within (video_size_after_crop.ratio(), film_container, round); + size = fit_ratio_within (video_size_after_crop.ratio(), film_container); } else { /* No stretch nor scale */ size = video_size_after_crop; diff --git a/src/lib/video_content_scale.h b/src/lib/video_content_scale.h index 3053dda43..74e91e78f 100644 --- a/src/lib/video_content_scale.h +++ b/src/lib/video_content_scale.h @@ -43,7 +43,7 @@ public: VideoContentScale (bool); VideoContentScale (boost::shared_ptr); - dcp::Size size (boost::shared_ptr, dcp::Size display_container, dcp::Size film_container, int round) const; + dcp::Size size (boost::shared_ptr, dcp::Size display_container, dcp::Size film_container) const; std::string id () const; std::string name () const; void as_xml (xmlpp::Node *) const; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index a1cc5dfc4..311ec734c 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -147,7 +147,6 @@ FilmViewer::set_film (shared_ptr f) _film_connection = _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1)); - _player->set_approximate_size (); _player_connection = _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1)); calculate_sizes (); @@ -320,13 +319,6 @@ FilmViewer::calculate_sizes () _out_size.width = max (64, _out_size.width); _out_size.height = max (64, _out_size.height); - /* The player will round its image size down to the next lowest 4 pixels - to speed up its scale, so do similar here to avoid black borders - around things. This is a bit of a hack. - */ - _out_size.width &= ~3; - _out_size.height &= ~3; - _player->set_video_container_size (_out_size); } diff --git a/test/ratio_test.cc b/test/ratio_test.cc index 5c3df2e35..5ee8af137 100644 --- a/test/ratio_test.cc +++ b/test/ratio_test.cc @@ -35,34 +35,34 @@ BOOST_AUTO_TEST_CASE (ratio_test) Ratio const * r = Ratio::from_id ("119"); BOOST_CHECK (r); - BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080), 1), dcp::Size (1290, 1080)); + BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (1290, 1080)); r = Ratio::from_id ("133"); BOOST_CHECK (r); - BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080), 1), dcp::Size (1440, 1080)); + BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (1440, 1080)); r = Ratio::from_id ("138"); BOOST_CHECK (r); - BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080), 1), dcp::Size (1485, 1080)); + BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (1485, 1080)); r = Ratio::from_id ("166"); BOOST_CHECK (r); - BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080), 1), dcp::Size (1800, 1080)); + BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (1800, 1080)); r = Ratio::from_id ("178"); BOOST_CHECK (r); - BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080), 1), dcp::Size (1920, 1080)); + BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (1920, 1080)); r = Ratio::from_id ("185"); BOOST_CHECK (r); - BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080), 1), dcp::Size (1998, 1080)); + BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (1998, 1080)); r = Ratio::from_id ("239"); BOOST_CHECK (r); - BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080), 1), dcp::Size (2048, 858)); + BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (2048, 858)); r = Ratio::from_id ("full-frame"); BOOST_CHECK (r); - BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080), 1), dcp::Size (2048, 1080)); + BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (2048, 1080)); } diff --git a/test/video_content_scale_test.cc b/test/video_content_scale_test.cc index a2fb7fd43..d2ee4c0d8 100644 --- a/test/video_content_scale_test.cc +++ b/test/video_content_scale_test.cc @@ -97,7 +97,7 @@ test (dcp::Size content_size, dcp::Size display_size, dcp::Size film_size, Crop sc = VideoContentScale (scale); } - dcp::Size answer = sc.get().size (vc, display_size, film_size, 1); + dcp::Size answer = sc.get().size (vc, display_size, film_size); if (answer != correct) { cerr << "Testing " << vc->video_size().width << "x" << vc->video_size().height << "\n"; cerr << "Testing " << display_size.width << "x" << display_size.height << "\n"; -- 2.30.2