X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fframe_rate_change.cc;h=8372493ef71e04c4ffe51cf7338d547c36986664;hb=refs%2Fheads%2F2493-player-export-frame;hp=80a167029009349913b21e15c35d6aa0c760b4f2;hpb=6a18a737ef8dfbfbe909afe8266f104a2125b5fb;p=dcpomatic.git diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index 80a167029..8372493ef 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,35 +18,37 @@ */ -#include "frame_rate_change.h" -#include "types.h" + #include "compose.hpp" +#include "content.h" +#include "film.h" +#include "frame_rate_change.h" #include #include "i18n.h" + +using std::shared_ptr; using std::string; -static bool -about_equal (double a, double b) + +FrameRateChange::FrameRateChange () { - return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON); + } FrameRateChange::FrameRateChange (double source_, int dcp_) - : source (source_) - , dcp (dcp_) - , skip (false) - , repeat (1) - , change_speed (false) { - if (fabs (source / 2.0 - dcp) < fabs (source - dcp)) { + source = source_; + dcp = 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. @@ -55,9 +57,29 @@ FrameRateChange::FrameRateChange (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()) +{ + +} + + +FrameRateChange::FrameRateChange (shared_ptr film, Content const * content) + : FrameRateChange (content->active_video_frame_rate(film), film->video_frame_rate()) +{ + +} + + string FrameRateChange::description () const { @@ -76,7 +98,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; } }