X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fframe_rate_change.cc;h=99424a9c1d55e969245c9c2cec2b2f2581a28b3b;hb=194c2ac76b4bb4fc9fae5bc21d4e221ed194d444;hp=265ed0dbe1093813fea6f75bc68b3eba05da6a33;hpb=12bdca1c0c167e28ef661d897723a01d8552e11d;p=dcpomatic.git diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index 265ed0dbe..99424a9c1 100644 --- a/src/lib/frame_rate_change.cc +++ b/src/lib/frame_rate_change.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,55 +18,38 @@ */ -#include "frame_rate_change.h" -#include "types.h" + +#include "compose.hpp" #include "content.h" #include "film.h" -#include "compose.hpp" +#include "frame_rate_change.h" +#include "types.h" #include #include "i18n.h" + +using std::shared_ptr; using std::string; -using boost::shared_ptr; -static bool -about_equal (double a, double b) -{ - return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON); -} FrameRateChange::FrameRateChange () - : skip (false) - , repeat (1) - , change_speed (false) - , source (24) - , dcp (24) - , speed_up (1) { } -FrameRateChange::FrameRateChange (double source_, int dcp_) - : skip (false) - , repeat (1) - , change_speed (false) -{ - 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. @@ -75,21 +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 film, shared_ptr content) - : repeat (1) + : 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 film, Content const * content) - : repeat (1) + : 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 { @@ -108,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; } }