From: Carl Hetherington Date: Wed, 10 Apr 2013 18:43:01 +0000 (+0100) Subject: Merge master. X-Git-Tag: v2.0.48~1337^2~458 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=9bdd8cc51942a13e360dde4efc04b3ca417c8b94 Merge master. --- 9bdd8cc51942a13e360dde4efc04b3ca417c8b94 diff --cc src/lib/format.cc index 5eda9eb88,faadcd797..cce8762bd --- a/src/lib/format.cc +++ b/src/lib/format.cc @@@ -200,14 -199,14 +200,14 @@@ FixedFormat::FixedFormat (int r, libdcp int Format::dcp_padding (shared_ptr 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 @@@ -231,7 -230,8 +231,8 @@@ VariableFormat::ratio_as_integer (share float VariableFormat::ratio_as_float (shared_ptr 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 */ diff --cc src/wx/film_editor.cc index 9cd10ad61,62eecb70c..c03a13bfe --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@@ -146,8 -148,8 +146,8 @@@ FilmEditor::make_film_panel ( } ++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); @@@ -785,20 -812,20 +785,20 @@@ voi FilmEditor::setup_frame_rate_description () { wxString d; + int lines = 0; + - if (_film->source_frame_rate()) { - d << std_to_wx (FrameRateConversion (_film->source_frame_rate(), _film->dcp_frame_rate()).description); + 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 } @@@ -1402,13 -1352,14 +1406,14 @@@ FilmEditor::setup_scaling_description ( 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) { diff --cc src/wx/film_viewer.cc index d18083694,dbbff3713..cba19c07c --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@@ -130,9 -145,14 +130,14 @@@ FilmViewer::set_film (shared_ptr if (_film == f) { return; } - + _film = f; + _raw_frame.reset (); + _display_frame.reset (); + _panel->Refresh (); + _panel->Update (); + if (!_film) { return; } diff --cc test/test.cc index 592bad836,d1bb400f9..4d25d50f8 --- a/test/test.cc +++ b/test/test.cc @@@ -194,9 -226,35 +194,35 @@@ BOOST_AUTO_TEST_CASE (format_test f = Format::from_nickname ("Scope"); BOOST_CHECK (f); - BOOST_CHECK_EQUAL (f->ratio_as_integer(shared_ptr ()), 239); +// BOOST_CHECK_EQUAL (f->ratio_as_integer(shared_ptr ()), 239); } + /* Test VariableFormat-based scaling of content */ + BOOST_AUTO_TEST_CASE (scaling_test) + { + shared_ptr 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";