Decide best DCP rate based on the largest difference between a particular content...
[dcpomatic.git] / src / lib / playlist.cc
index 9e7f7f5f50f7770503e47b635c550093558a630b..703a14663448c5468dc10910a3ca5c978d3a96df 100644 (file)
@@ -221,7 +221,7 @@ Playlist::best_dcp_frame_rate () const
                candidates.push_back (FrameRateCandidate (float (*i) * 2, *i));
        }
 
-       /* Pick the best one, bailing early if we hit an exact match */
+       /* Pick the best one */
        float error = std::numeric_limits<float>::max ();
        optional<FrameRateCandidate> best;
        list<FrameRateCandidate>::iterator i = candidates.begin();
@@ -234,7 +234,8 @@ Playlist::best_dcp_frame_rate () const
                                continue;
                        }
 
-                       this_error += fabs (i->source - vc->video_frame_rate ());
+                       /* Use the largest difference between DCP and source as the "error" */
+                       this_error = max (this_error, float (fabs (i->source - vc->video_frame_rate ())));
                }
 
                if (this_error < error) {