diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-03-09 22:03:13 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-03-09 22:03:13 +0000 |
| commit | 3a9bea8c3727af6ebbce860b8223371cd7f87b3f (patch) | |
| tree | 4c2afdd6badac88017ed42c3cd971821e2f3a201 /src | |
| parent | 3190fb98298ebdd29c41b2cf6019a381e71a6248 (diff) | |
Fix display of no-scale mode in the player; the image still has to be scaled for the film viewer as its image must represent a (scaled down) version of the film's frame.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/film.cc | 8 | ||||
| -rw-r--r-- | src/lib/film.h | 1 | ||||
| -rw-r--r-- | src/lib/player.cc | 4 | ||||
| -rw-r--r-- | src/lib/video_content.cc | 21 | ||||
| -rw-r--r-- | src/lib/video_content.h | 4 | ||||
| -rw-r--r-- | src/lib/writer.cc | 2 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 4 | ||||
| -rw-r--r-- | src/wx/video_panel.cc | 4 |
8 files changed, 34 insertions, 14 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index da48bc9b2..8aa0deed0 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -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, diff --git a/src/lib/film.h b/src/lib/film.h index e5840621a..de9891c9f 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -96,6 +96,7 @@ public: } libdcp::Size full_frame () const; + libdcp::Size frame_size () const; std::list<boost::filesystem::path> dcps () const; diff --git a/src/lib/player.cc b/src/lib/player.cc index 99aece8d6..d05597dd5 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -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 ( diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 7bf2a6b62..82f817654 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -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 diff --git a/src/lib/video_content.h b/src/lib/video_content.h index c98a52d3a..ea4676cec 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -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; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 42187dc6e..f689ace7c 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -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 ()) { diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index e24583d6c..45372d811 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -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 (); } diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 492968f1b..aa0f7d019 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -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 ( |
