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
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();
}
: _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));
return all;
}
-void
-Player::set_approximate_size ()
-{
- _approximate_size = true;
-}
-
shared_ptr<PlayerVideo>
Player::black_player_video_frame (DCPTime time) const
{
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 (
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;
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;
}
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 *
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);
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 (
* @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;
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;
_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 ();
_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);
}
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));
}
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";