X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fframe_rate_change.cc;h=99424a9c1d55e969245c9c2cec2b2f2581a28b3b;hb=1a721b82d4094c00ee89574e17c58c23c0de8cdd;hp=456b4151e1a11accef6e1d6b481955c65e71a4c2;hpb=f67bc45820b4e56f90eecb97ba3b7762c119f9b5;p=dcpomatic.git diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index 456b4151e..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,44 +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 (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 film, shared_ptr 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 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; } }