Fix display of no-scale mode in the player; the image still has to be scaled for...
authorCarl Hetherington <cth@carlh.net>
Sun, 9 Mar 2014 22:03:13 +0000 (22:03 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 9 Mar 2014 22:03:13 +0000 (22:03 +0000)
ChangeLog
src/lib/film.cc
src/lib/film.h
src/lib/player.cc
src/lib/video_content.cc
src/lib/video_content.h
src/lib/writer.cc
src/wx/film_viewer.cc
src/wx/video_panel.cc

index 674e08e0b00b90fc8a0c855da845514599ef0c6f..be3b611e67cb279c44c6bb5da8687a503f867891 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-03-09  Carl Hetherington  <cth@carlh.net>
+
+       * Fix display of no-scale display mode in the player.
+
 2014-03-08  Carl Hetherington  <cth@carlh.net>
 
        * Fix incorrect audio analyses on multiple-stream content.
index da48bc9b2656184a004dd3193e84d32fe6e9c8b2..8aa0deed0c5693cde69acfd25f57f797725feaf6 100644 (file)
@@ -939,6 +939,7 @@ Film::set_sequence_video (bool s)
        signal_changed (SEQUENCE_VIDEO);
 }
 
+/** @return Size of the largest possible image in whatever resolution we are using */
 libdcp::Size
 Film::full_frame () const
 {
@@ -953,6 +954,13 @@ Film::full_frame () const
        return libdcp::Size ();
 }
 
+/** @return Size of the frame */
+libdcp::Size
+Film::frame_size () const
+{
+       return fit_ratio_within (container()->ratio(), full_frame ());
+}
+
 libdcp::KDM
 Film::make_kdm (
        shared_ptr<libdcp::Certificate> target,
index e5840621a1f7475ad1040cbe61fe932858ce7648..de9891c9f33ea2a54d10b65d009572988cdb7d39 100644 (file)
@@ -96,6 +96,7 @@ public:
        }
 
        libdcp::Size full_frame () const;
+       libdcp::Size frame_size () const;
 
        std::list<boost::filesystem::path> dcps () const;
 
index 99aece8d660d5c67c1140410868b6bdd32d3b9f5..d05597dd556540f50839f35fd57510fee75e7243 100644 (file)
@@ -126,7 +126,7 @@ Player::Player (shared_ptr<const Film> f, shared_ptr<const Playlist> p)
        _playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this));
        _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3));
        _film_changed_connection = _film->Changed.connect (bind (&Player::film_changed, this, _1));
-       set_video_container_size (fit_ratio_within (_film->container()->ratio (), _film->full_frame ()));
+       set_video_container_size (_film->frame_size ());
 }
 
 void
@@ -273,7 +273,7 @@ Player::process_video (weak_ptr<Piece> weak_piece, shared_ptr<const Image> image
        }
 
        Time const time = content->position() + relative_time + extra - content->trim_start ();
-       libdcp::Size const image_size = content->scale().size (content, _video_container_size);
+       libdcp::Size const image_size = content->scale().size (content, _video_container_size, _film->frame_size ());
 
        shared_ptr<PlayerImage> pi (
                new PlayerImage (
index 7bf2a6b621284a5c6ea3e3cc31538d2263df0f27..82f817654db3f48575f5cb4bad16cd86e283ee00 100644 (file)
@@ -443,19 +443,28 @@ VideoContentScale::name () const
        return _("No scale");
 }
 
+/** @param display_container Size of the container that we are displaying this content in.
+ *  @param film_container The size of the film's image.
+ */
 libdcp::Size
-VideoContentScale::size (shared_ptr<const VideoContent> c, libdcp::Size container) const
+VideoContentScale::size (shared_ptr<const VideoContent> c, libdcp::Size display_container, libdcp::Size film_container) const
 {
        if (_ratio) {
-               return fit_ratio_within (_ratio->ratio (), container);
+               return fit_ratio_within (_ratio->ratio (), display_container);
        }
 
-       /* Force scale if the container is smaller than the content's image */
-       if (_scale || container.width < c->video_size().width || container.height < c->video_size().height) {
-               return fit_ratio_within (c->video_size().ratio (), container);
+       /* Force scale if the film_container is smaller than the content's image */
+       if (_scale || film_container.width < c->video_size().width || film_container.height < c->video_size().height) {
+               return fit_ratio_within (c->video_size().ratio (), display_container);
        }
 
-       return c->video_size ();
+       /* Scale the image so that it will be in the right place in film_container, even if display_container is a
+          different size.
+       */
+       return libdcp::Size (
+               c->video_size().width  * float(display_container.width)  / film_container.width,
+               c->video_size().height * float(display_container.height) / film_container.height
+               );
 }
 
 void
index c98a52d3a7cc17c842ddcde6634cf7951d362541..ea4676cecbe1607fe4a86e47a71c278e763e86b2 100644 (file)
@@ -45,7 +45,7 @@ public:
        VideoContentScale (bool);
        VideoContentScale (boost::shared_ptr<cxml::Node>);
 
-       libdcp::Size size (boost::shared_ptr<const VideoContent>, libdcp::Size) const;
+       libdcp::Size size (boost::shared_ptr<const VideoContent>, libdcp::Size, libdcp::Size) const;
        std::string id () const;
        std::string name () const;
        void as_xml (xmlpp::Node *) const;
@@ -64,7 +64,9 @@ public:
        }
 
 private:
+       /** a ratio to stretch the content to, or 0 for no stretch */
        Ratio const * _ratio;
+       /** true if we want to scale the content */
        bool _scale;
 
        static std::vector<VideoContentScale> _scales;
index 42187dc6e78616a24673057bb4e9eb87802381aa..f689ace7c633aa6a47a42cf223d710c1b458b32b 100644 (file)
@@ -86,7 +86,7 @@ Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j)
        }
 
        _picture_asset->set_edit_rate (_film->video_frame_rate ());
-       _picture_asset->set_size (fit_ratio_within (_film->container()->ratio(), _film->full_frame ()));
+       _picture_asset->set_size (_film->frame_size ());
        _picture_asset->set_interop (_film->interop ());
 
        if (_film->encrypted ()) {
index e24583d6cfa478ea62a6aefa7740d2fa1c022db2..45372d8111f532495d82cd56409aaa22773af1a1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -404,7 +404,7 @@ FilmViewer::player_changed (bool frequent)
        if (frequent) {
                return;
        }
-       
+
        calculate_sizes ();
        fetch_current_frame_again ();
 }
index 492968f1bea567e35e383a6a3ff55d2b03f5ec7c..aa0f7d019a6af5dd232ed15e2c19ad78dfbb5afa 100644 (file)
@@ -305,8 +305,8 @@ VideoPanel::setup_description ()
                ++lines;
        }
 
-       libdcp::Size const container_size = fit_ratio_within (_editor->film()->container()->ratio (), _editor->film()->full_frame ());
-       libdcp::Size const scaled = vcs->scale().size (vcs, container_size);
+       libdcp::Size const container_size = _editor->film()->frame_size ();
+       libdcp::Size const scaled = vcs->scale().size (vcs, container_size, container_size);
 
        if (scaled != vcs->video_size_after_crop ()) {
                d << wxString::Format (