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 */
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
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);
+ }