int
Format::dcp_padding (shared_ptr<const Film> f) const
{
- int pad = rint ((_dcp_size.width - (_dcp_size.height * ratio_as_integer(f) / 100.0)) / 2.0);
- int p = rint ((_dcp_size.width - (_dcp_size.height * ratio_as_float(f))) / 2.0);
++ int p = rint ((_dcp_size.width - (_dcp_size.height * ratio(f))) / 2.0);
/* This comes out -ve for Scope; bodge it */
- if (pad < 0) {
- pad = 0;
+ if (p < 0) {
+ p = 0;
}
- return pad;
+ return p;
}
float
float
VariableFormat::ratio_as_float (shared_ptr<const Film> f) const
{
- return float (f->video_size().width) / f->video_size().height;
- libdcp::Size const c = f->cropped_size (f->size ());
++ libdcp::Size const c = f->cropped_size (f->video_size ());
+ return float (c.width) / c.height;
}
/** @return A name to be presented to the user */
}
++r;
- _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT (" \n \n "), wxDefaultPosition, wxDefaultSize);
+ _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT ("\n \n "), wxDefaultPosition, wxDefaultSize);
- grid->Add (video_control (_frame_rate_description), wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
+ grid->Add (_frame_rate_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
wxFont font = _frame_rate_description->GetFont();
font.SetStyle(wxFONTSTYLE_ITALIC);
font.SetPointSize(font.GetPointSize() - 1);
FilmEditor::setup_frame_rate_description ()
{
wxString d;
- if (_film->source_frame_rate()) {
- d << std_to_wx (FrameRateConversion (_film->source_frame_rate(), _film->dcp_frame_rate()).description);
+ int lines = 0;
+
+ if (_film->video_frame_rate()) {
+ d << std_to_wx (FrameRateConversion (_film->video_frame_rate(), _film->dcp_frame_rate()).description);
+ ++lines;
#ifdef HAVE_SWRESAMPLE
- if (_film->audio_stream() && _film->audio_stream()->sample_rate() != _film->target_audio_sample_rate ()) {
+ if (_film->audio_frame_rate() && _film->audio_frame_rate() != _film->target_audio_sample_rate ()) {
d << wxString::Format (
_("Audio will be resampled from %dHz to %dHz\n"),
- _film->audio_stream()->sample_rate(),
+ _film->audio_frame_rate(),
_film->target_audio_sample_rate()
);
- } else {
- d << wxT ("\n");
+ ++lines;
}
- #else
- d << wxT ("\n");
#endif
}
int lines = 0;
- d << wxString::Format (
- _("Original video is %dx%d (%.2f:1)\n"),
- _film->video_size().width, _film->video_size().height,
- float (_film->video_size().width) / _film->video_size().height
- );
-
- ++lines;
- if (_film->size().width && _film->size().height) {
++ if (_film->video_size().width && _film->video_size().height) {
+ d << wxString::Format (
+ _("Original video is %dx%d (%.2f:1)\n"),
- _film->size().width, _film->size().height,
- float (_film->size().width) / _film->size().height
++ _film->video_size().width, _film->video_size().height,
++ float (_film->video_size().width) / _film->video_size().height
+ );
+ ++lines;
+ }
Crop const crop = _film->crop ();
if (crop.left || crop.right || crop.top || crop.bottom) {
f = Format::from_nickname ("Scope");
BOOST_CHECK (f);
- BOOST_CHECK_EQUAL (f->ratio_as_integer(shared_ptr<const Film> ()), 239);
+// BOOST_CHECK_EQUAL (f->ratio_as_integer(shared_ptr<const Film> ()), 239);
}
+ /* Test VariableFormat-based scaling of content */
+ BOOST_AUTO_TEST_CASE (scaling_test)
+ {
+ shared_ptr<Film> film (new Film (test_film_dir ("scaling_test").string(), false));
+
+ /* 4:3 ratio */
+ film->set_size (libdcp::Size (320, 240));
+
+ /* This format should preserve aspect ratio of the source */
+ Format const * format = Format::from_id ("var-185");
+
+ /* We should have enough padding that the result is 4:3,
+ which would be 1440 pixels.
+ */
+ BOOST_CHECK_EQUAL (format->dcp_padding (film), (1998 - 1440) / 2);
+
+ /* This crops it to 1.291666667 */
+ film->set_left_crop (5);
+ film->set_right_crop (5);
+
+ /* We should now have enough padding that the result is 1.29166667,
+ which would be 1395 pixels.
+ */
+ BOOST_CHECK_EQUAL (format->dcp_padding (film), rint ((1998 - 1395) / 2.0));
+ }
+
BOOST_AUTO_TEST_CASE (util_test)
{
string t = "Hello this is a string \"with quotes\" and indeed without them";