Remove approximate size stuff where playback viewer would round
authorCarl Hetherington <cth@carlh.net>
Sat, 2 May 2015 19:20:32 +0000 (20:20 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 2 May 2015 19:20:32 +0000 (20:20 +0100)
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.

12 files changed:
src/lib/film.cc
src/lib/image_filename_sorter.cc
src/lib/player.cc
src/lib/player.h
src/lib/util.cc
src/lib/util.h
src/lib/video_content.cc
src/lib/video_content_scale.cc
src/lib/video_content_scale.h
src/wx/film_viewer.cc
test/ratio_test.cc
test/video_content_scale_test.cc

index 3cdaeb48aa0536af7f6d6b5e9dcc38874fcfa28e..80755a4cb8c20972a415cb66495adba1f4725162 100644 (file)
@@ -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
index 805c469b03f14642218190511bada56aa4bc6500..0cb6adc6bf182705490e44eed16c80b70ccd0741 100644 (file)
@@ -30,7 +30,6 @@ public:
                boost::optional<int> na = extract_number (a);
                boost::optional<int> nb = extract_number (b);
                if (!na || !nb) {
-                       std::cout << a << " " << b << " " << (a.string() < b.string()) << "\n";
                        return a.string() < b.string();
                }
 
index 495d20533b3eb15947f8a199b34901700d07b5f3..436ae3fe88fb33adaee5aacb1c2f3cfd99799b7f 100644 (file)
@@ -71,7 +71,6 @@ Player::Player (shared_ptr<const Film> f, shared_ptr<const Playlist> 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<ImageSubtitle> subs) const
        return all;
 }
 
-void
-Player::set_approximate_size ()
-{
-       _approximate_size = true;
-}
-
 shared_ptr<PlayerVideo>
 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<ContentVideo>::const_iterator i = content_video.begin(); i != content_video.end(); ++i) {
                        pvf.push_back (
index 01439a26f00e2c272c6adf8226f8e50643bb38f6..d8b13ee7bca6e82e444934285bf02b8e87ab5334 100644 (file)
@@ -92,7 +92,6 @@ public:
        std::list<boost::shared_ptr<Font> > 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<Image> _black_image;
 
-       bool _approximate_size;
        /** true if the player should ignore all video; i.e. never produce any */
        bool _ignore_video;
 
index 08683fb7e6b31632b590f5e0af7d550f9e08ceeb..bffbe90d402b2bca5cf8b74852c58556265c03ea 100644 (file)
@@ -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 *
index bf1d0265b0dec3b90da1c0ba57414ed1868f6312..c1f7a78c745318b33a173627c80f3d664128a0bc 100644 (file)
@@ -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);
index bfbcef9bf9cea42a170244239d40827208521a43..68db672f1894275b2ff0bbaedb5ca8c1d95435da 100644 (file)
@@ -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<const VideoContent> (shared_from_this ()), container_size, container_size, 1);
+       dcp::Size const scaled = scale().size (dynamic_pointer_cast<const VideoContent> (shared_from_this ()), container_size, container_size);
 
        if (scaled != video_size_after_crop ()) {
                d << String::compose (
index 14db7b02f7dd6bb97c3724fcccb4fa78c9ac3630..59ff4bd9b663d5fe0084192102668239ca7fc6b6 100644 (file)
@@ -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<const VideoContent> c, dcp::Size display_container, dcp::Size film_container, int round) const
+VideoContentScale::size (shared_ptr<const VideoContent> 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;
index 3053dda43f854ce444a1fc179631db42cb34a9f0..74e91e78f6549c0e85672aa74a987f4f27ecd585 100644 (file)
@@ -43,7 +43,7 @@ public:
        VideoContentScale (bool);
        VideoContentScale (boost::shared_ptr<cxml::Node>);
 
-       dcp::Size size (boost::shared_ptr<const VideoContent>, dcp::Size display_container, dcp::Size film_container, int round) const;
+       dcp::Size size (boost::shared_ptr<const VideoContent>, dcp::Size display_container, dcp::Size film_container) const;
        std::string id () const;
        std::string name () const;
        void as_xml (xmlpp::Node *) const;
index a1cc5dfc4bd37dd1751523895291005069975909..311ec734c45734aff0a5dab1295a8fc5e3178a9c 100644 (file)
@@ -147,7 +147,6 @@ FilmViewer::set_film (shared_ptr<Film> 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);
 }
 
index 5c3df2e35f983f05b2c91482aeb74d94782c6816..5ee8af1371ae5cbc588a2e0b02c9260e9f17dfee 100644 (file)
@@ -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));
 }
 
index a2fb7fd434c400e27a374cced22cb72bcd80167a..d2ee4c0d83c8408b0b98eaf9e2be744279a7668f 100644 (file)
@@ -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";