Merge master.
authorCarl Hetherington <cth@carlh.net>
Wed, 10 Apr 2013 18:43:01 +0000 (19:43 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 10 Apr 2013 18:43:01 +0000 (19:43 +0100)
1  2 
src/lib/format.cc
src/tools/dvdomatic.cc
src/wx/film_editor.cc
src/wx/film_viewer.cc
src/wx/film_viewer.h
test/test.cc
wscript

index 5eda9eb889ef1896b9a86613259b12424a58c49f,faadcd79779edf22b266093c0ce3a4d5015d2f7f..cce8762bdadd51766ef0cf01cd237c30f8892861
@@@ -200,14 -199,14 +200,14 @@@ FixedFormat::FixedFormat (int r, libdcp
  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
@@@ -231,7 -230,8 +231,8 @@@ VariableFormat::ratio_as_integer (share
  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 */
Simple merge
index 9cd10ad615c8344333466593b239aa0166f3c3fa,62eecb70c4758b4104f88e54373c9d80b8a62780..c03a13bfe8cd3bb67c119a6ece24c96d1bb8d8ae
@@@ -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;
 -      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                
        }
  
@@@ -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) {
index d180836941331da2da3863abe7217055b1a07ea3,dbbff37133ff5d7e97ffbacfb8e8e409f06da214..cba19c07c2ba6d093d6e420d33f13f4803bc47e0
@@@ -130,9 -145,14 +130,14 @@@ FilmViewer::set_film (shared_ptr<Film> 
        if (_film == f) {
                return;
        }
 -      
 +
        _film = f;
  
+       _raw_frame.reset ();
+       _display_frame.reset ();
+       _panel->Refresh ();
+       _panel->Update ();
        if (!_film) {
                return;
        }
Simple merge
diff --cc test/test.cc
index 592bad836807a060450f071433974e4892a6490d,d1bb400f98f2d557946b0032656264046c632972..4d25d50f85944fd6162ac5fb1294a53859c3d274
@@@ -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<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";
diff --cc wscript
Simple merge