Guess a better optimum frame rate when there is content at 24 and 48 fps (#633).
authorCarl Hetherington <cth@carlh.net>
Thu, 9 Jul 2015 19:36:17 +0000 (20:36 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 9 Jul 2015 19:36:17 +0000 (20:36 +0100)
ChangeLog
src/lib/playlist.cc
test/frame_rate_test.cc

index 8d9815b4352613d4bad20fd8c89e20d9c04db017..20f9a74d8331fab73abb2a0eb85936ebbc39a351 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2015-07-09  Carl Hetherington  <cth@carlh.net>
 
+       * Improve 'best' frame rate guess in some cases (#633).
+
        * Version 2.1.20 released.
 
 2015-07-09  c.hetherington  <cth@carlh.net>
index a0afae0adf70888315aadda255695d209dd50e6a..e2135a60ed6a9479450f0991430aab819fc16ec6 100644 (file)
@@ -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) {
index 0133431eea78234b4197fbb292be9b3271fbb98f..b9fd51391e043a926530cb2b52d16cd7c9a6ac28 100644 (file)
@@ -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)