diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-02-28 09:06:44 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-02-28 09:08:46 +0100 |
| commit | bcf62b5e4a268554b7960e5f739b24f9eafb38a5 (patch) | |
| tree | 904fb5959dcd2401daba2d42c53d3a0736604bff /src/lib/frame_rate_change.cc | |
| parent | bb04b67f593c1da37b76af9507f3e28e9ab15f74 (diff) | |
WIP: use fraction for DCP frame rate.archive-frame-rates
This will allow archival rates to be expressed precisely.
Diffstat (limited to 'src/lib/frame_rate_change.cc')
| -rw-r--r-- | src/lib/frame_rate_change.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index 48f5b9881..8f6397d56 100644 --- a/src/lib/frame_rate_change.cc +++ b/src/lib/frame_rate_change.cc @@ -22,6 +22,7 @@ #include "content.h" #include "film.h" #include "frame_rate_change.h" +#include <dcp/types.h> #include <cmath> #include "i18n.h" @@ -32,29 +33,30 @@ using std::string; FrameRateChange::FrameRateChange() + : dcp(24, 1) { } -FrameRateChange::FrameRateChange(double source_, int dcp_) +FrameRateChange::FrameRateChange(double source_, dcp::Fraction dcp_) : source(source_) , dcp(dcp_) { - if (fabs(source / 2.0 - dcp) < fabs(source - dcp)) { + if (fabs(source / 2.0 - dcp.as_float()) < fabs(source - dcp.as_float())) { /* 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.as_float()) < fabs(source - dcp.as_float())) { /* 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. */ - repeat = round(dcp / source); + repeat = round(dcp.as_float() / source); } - speed_up = dcp / (source * factor()); + speed_up = dcp.as_float() / (source * factor()); auto about_equal = [](double a, double b) { return (fabs(a - b) < VIDEO_FRAME_RATE_EPSILON); @@ -95,7 +97,7 @@ FrameRateChange::description() const } if (change_speed) { - double const pc = dcp * 100 / (source * factor()); + double const pc = dcp.as_float() * 100 / (source * factor()); char buffer[256]; snprintf(buffer, sizeof(buffer), _("DCP will run at %.1f%% of the content speed.\n"), pc); description += buffer; |
