Merge master.
authorCarl Hetherington <cth@carlh.net>
Mon, 3 Mar 2014 12:54:07 +0000 (12:54 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 3 Mar 2014 12:54:07 +0000 (12:54 +0000)
1  2 
src/lib/encoder.cc
src/lib/film.cc
src/lib/sndfile_content.cc
src/lib/util.cc
src/lib/util.h
src/wx/timecode.cc
test/util_test.cc

Simple merge
diff --cc src/lib/film.cc
index e463a0e356c950c2886fab844bdadb30a54f3015,13481045200ac26be456979fa5fab70e8d8b40f0..4b3f6a8dd1afe508f90cfde344faf3d3a94ca77c
@@@ -903,31 -897,31 +903,31 @@@ Film::playlist_changed (
        signal_changed (CONTENT);
  }     
  
 -OutputAudioFrame
 -Film::time_to_audio_frames (Time t) const
 +AudioFrame
 +Film::time_to_audio_frames (DCPTime t) const
  {
-       return t * audio_frame_rate () / TIME_HZ;
+       return divide_with_round (t * audio_frame_rate (), TIME_HZ);
  }
  
 -OutputVideoFrame
 -Film::time_to_video_frames (Time t) const
 +VideoFrame
 +Film::time_to_video_frames (DCPTime t) const
  {
-       return t * video_frame_rate () / TIME_HZ;
+       return divide_with_round (t * video_frame_rate (), TIME_HZ);
  }
  
 -Time
 -Film::audio_frames_to_time (OutputAudioFrame f) const
 +DCPTime
 +Film::audio_frames_to_time (AudioFrame f) const
  {
-       return f * TIME_HZ / audio_frame_rate ();
+       return divide_with_round (f * TIME_HZ, audio_frame_rate ());
  }
  
 -Time
 -Film::video_frames_to_time (OutputVideoFrame f) const
 +DCPTime
 +Film::video_frames_to_time (VideoFrame f) const
  {
-       return f * TIME_HZ / video_frame_rate ();
+       return divide_with_round (f * TIME_HZ, video_frame_rate ());
  }
  
 -OutputAudioFrame
 +AudioFrame
  Film::audio_frame_rate () const
  {
        /* XXX */
index d3acc7d2e3662a4261d56e6d077e888da4a50ede,98171a8433ec768fda8ce9bd6bed99ebd8fe9d9f..844f3dd47cff204b411d6a615e4d535d3b4317d3
@@@ -147,7 -147,7 +147,7 @@@ SndfileContent::full_length () cons
        shared_ptr<const Film> film = _film.lock ();
        assert (film);
  
-       AudioFrame const len = audio_length() * output_audio_frame_rate() / content_audio_frame_rate ();
 -      OutputAudioFrame const len = divide_with_round (audio_length() * output_audio_frame_rate(), content_audio_frame_rate ());
++      AudioFrame const len = divide_with_round (audio_length() * output_audio_frame_rate(), content_audio_frame_rate ());
        
        /* XXX: this depends on whether, alongside this audio, we are running video slower or faster than
           it should be.  The calculation above works out the output audio frames assuming that we are just
diff --cc src/lib/util.cc
Simple merge
diff --cc src/lib/util.h
Simple merge
Simple merge
index 5733c7d03d69070b2fa195e43665c1b337f146c7,750023d9f1a689bb4414706b66c352a4b6cda2d8..37dee00c90fcd0ef5714de481ee0830a74362e1c
@@@ -54,16 -54,15 +54,30 @@@ BOOST_AUTO_TEST_CASE (md5_digest_test
        BOOST_CHECK_THROW (md5_digest (p, shared_ptr<Job> ()), std::runtime_error);
  }
  
 +/* Straightforward test of time_round_up_test */
 +BOOST_AUTO_TEST_CASE (time_round_up_test)
 +{
 +      BOOST_CHECK_EQUAL (time_round_up (0, 2), 0);
 +      BOOST_CHECK_EQUAL (time_round_up (1, 2), 2);
 +      BOOST_CHECK_EQUAL (time_round_up (2, 2), 2);
 +      BOOST_CHECK_EQUAL (time_round_up (3, 2), 4);
 +      
 +      BOOST_CHECK_EQUAL (time_round_up (0, 42), 0);
 +      BOOST_CHECK_EQUAL (time_round_up (1, 42), 42);
 +      BOOST_CHECK_EQUAL (time_round_up (42, 42), 42);
 +      BOOST_CHECK_EQUAL (time_round_up (43, 42), 84);
 +}
++
++
+ BOOST_AUTO_TEST_CASE (divide_with_round_test)
+ {
+       BOOST_CHECK_EQUAL (divide_with_round (0, 4), 0);
+       BOOST_CHECK_EQUAL (divide_with_round (1, 4), 0);
+       BOOST_CHECK_EQUAL (divide_with_round (2, 4), 1);
+       BOOST_CHECK_EQUAL (divide_with_round (3, 4), 1);
+       BOOST_CHECK_EQUAL (divide_with_round (4, 4), 1);
+       BOOST_CHECK_EQUAL (divide_with_round (5, 4), 1);
+       BOOST_CHECK_EQUAL (divide_with_round (6, 4), 2);
+       BOOST_CHECK_EQUAL (divide_with_round (1000, 500), 2);
+ }