From 10e3bfad8164fc1bce19101253cd3bc9a1f973a3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 9 Jul 2015 20:36:17 +0100 Subject: [PATCH] Guess a better optimum frame rate when there is content at 24 and 48 fps (#633). --- ChangeLog | 2 ++ src/lib/playlist.cc | 8 +++++++- test/frame_rate_test.cc | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8d9815b43..20f9a74d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2015-07-09 Carl Hetherington + * Improve 'best' frame rate guess in some cases (#633). + * Version 2.1.20 released. 2015-07-09 c.hetherington diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index a0afae0ad..e2135a60e 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -237,8 +237,14 @@ Playlist::best_dcp_frame_rate () const continue; } + /* Best error for this content; we could use the content as-is or double its rate */ + float best_error = min ( + float (fabs (i->source - vc->video_frame_rate ())), + float (fabs (i->source - vc->video_frame_rate () * 2)) + ); + /* Use the largest difference between DCP and source as the "error" */ - this_error = max (this_error, float (fabs (i->source - vc->video_frame_rate ()))); + this_error = max (this_error, best_error); } if (this_error < error) { diff --git a/test/frame_rate_test.cc b/test/frame_rate_test.cc index 0133431ee..b9fd51391 100644 --- a/test/frame_rate_test.cc +++ b/test/frame_rate_test.cc @@ -235,6 +235,14 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_double) A->_video_frame_rate = 30; B->_video_frame_rate = 24; BOOST_CHECK_EQUAL (film->best_video_frame_rate(), 25); + + A->_video_frame_rate = 24; + B->_video_frame_rate = 24; + BOOST_CHECK_EQUAL (film->best_video_frame_rate(), 24); + + A->_video_frame_rate = 24; + B->_video_frame_rate = 48; + BOOST_CHECK_EQUAL (film->best_video_frame_rate(), 24); } BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) -- 2.30.2