Fix the build for older macOS.
[dcpomatic.git] / src / lib / frame_rate_change.cc
index 456b4151e1a11accef6e1d6b481955c65e71a4c2..a1ff2ae650a93d7ec19782763f359b4b6a0c883a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -18,6 +18,7 @@
 
 */
 
+
 #include "frame_rate_change.h"
 #include "types.h"
 #include "content.h"
 
 #include "i18n.h"
 
+
 using std::string;
-using boost::shared_ptr;
+using std::shared_ptr;
 
-static bool
-about_equal (double a, double b)
-{
-       return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON);
-}
 
-FrameRateChange::FrameRateChange (double source_, int dcp_)
-       : skip (false)
-       , repeat (1)
-       , change_speed (false)
+FrameRateChange::FrameRateChange ()
 {
-       construct (source_, dcp_);
+
 }
 
-void
-FrameRateChange::construct (double source_, int dcp_)
+
+FrameRateChange::FrameRateChange (double source_, int dcp_)
 {
        source = source_;
        dcp = dcp_;
 
-       if (fabs (source / 2.0 - dcp) < fabs (source - dcp)) {
+       if (fabs(source / 2.0 - dcp) < fabs(source - dcp)) {
                /* The difference between source and DCP frame rate will be lower
                   (i.e. better) if we skip.
                */
                skip = true;
-       } else if (fabs (source * 2 - dcp) < fabs (source - dcp)) {
+       } else if (fabs(source * 2 - dcp) < fabs(source - dcp)) {
                /* The difference between source and DCP frame rate would be better
                   if we repeated each frame once; it may be better still if we
                   repeated more than once.  Work out the required repeat.
@@ -64,19 +58,29 @@ FrameRateChange::construct (double source_, int dcp_)
        }
 
        speed_up = dcp / (source * factor());
+
+       auto about_equal = [](double a, double b) {
+               return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON);
+       };
+
        change_speed = !about_equal (speed_up, 1.0);
 }
 
+
 FrameRateChange::FrameRateChange (shared_ptr<const Film> film, shared_ptr<const Content> content)
+       : FrameRateChange (content->active_video_frame_rate(film), film->video_frame_rate())
 {
-       construct (content->active_video_frame_rate(film), film->video_frame_rate());
+
 }
 
+
 FrameRateChange::FrameRateChange (shared_ptr<const Film> film, Content const * content)
+       : FrameRateChange (content->active_video_frame_rate(film), film->video_frame_rate())
 {
-       construct (content->active_video_frame_rate(film), film->video_frame_rate());
+
 }
 
+
 string
 FrameRateChange::description () const
 {
@@ -95,7 +99,9 @@ FrameRateChange::description () const
 
                if (change_speed) {
                        double const pc = dcp * 100 / (source * factor());
-                       description += String::compose (_("DCP will run at %1%% of the content speed.\n"), pc);
+                       char buffer[256];
+                       snprintf (buffer, sizeof(buffer), _("DCP will run at %.1f%% of the content speed.\n"), pc);
+                       description += buffer;
                }
        }