diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-04-08 20:42:37 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-04-08 20:42:37 +0200 |
| commit | 41b5c9b56a1ef4ac9119c11f166931936632ae0c (patch) | |
| tree | 726384c584afb4bd4c9a09463e6f6da713ab2d84 /src | |
| parent | e6eee05a5daadabbbe829560faf5002adca9f945 (diff) | |
Make FrameRateChange data private.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/audio_content.cc | 8 | ||||
| -rw-r--r-- | src/lib/content.cc | 2 | ||||
| -rw-r--r-- | src/lib/dcpomatic_time.cc | 4 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/frame_rate_change.cc | 32 | ||||
| -rw-r--r-- | src/lib/frame_rate_change.h | 47 | ||||
| -rw-r--r-- | src/lib/hints.cc | 2 | ||||
| -rw-r--r-- | src/lib/player.cc | 4 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 8 | ||||
| -rw-r--r-- | src/wx/text_view.cc | 6 |
11 files changed, 71 insertions, 46 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 50601fc58..bd25593d0 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -212,8 +212,8 @@ AudioContent::resampled_frame_rate(shared_ptr<const Film> film) const look different in the DCP compared to the source (slower or faster). */ - if (frc.change_speed) { - t /= frc.speed_up; + if (frc.change_speed()) { + t /= frc.speed_up(); } return lrint(t); @@ -330,11 +330,11 @@ AudioContent::add_properties(shared_ptr<const Film> film, list<UserProperty>& p) } p.push_back( - UserProperty(UserProperty::LENGTH, _("Full length in video frames at content rate"), c.frames_round(frc.source)) + UserProperty(UserProperty::LENGTH, _("Full length in video frames at content rate"), c.frames_round(frc.source())) ); p.push_back(UserProperty(UserProperty::AUDIO, _("DCP sample rate"), resampled_frame_rate(film), _("Hz"))); - p.push_back(UserProperty(UserProperty::LENGTH, _("Full length in video frames at DCP rate"), c.frames_round(frc.dcp))); + p.push_back(UserProperty(UserProperty::LENGTH, _("Full length in video frames at DCP rate"), c.frames_round(frc.dcp()))); } diff --git a/src/lib/content.cc b/src/lib/content.cc index 8f486380a..067086509 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -431,7 +431,7 @@ Content::active_video_frame_rate(shared_ptr<const Film> film) const prepared for any concurrent video content or perhaps just the DCP rate. */ - return film->active_frame_rate_change(position()).source; + return film->active_frame_rate_change(position()).source(); } diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index 60fc5342a..2b1400ccf 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.cc @@ -48,7 +48,7 @@ dcpomatic::operator<=(HMSF const& a, HMSF const& b) template <> Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRateChange f) - : _t (llrint(d.get() * f.speed_up)) + : _t (llrint(d.get() * f.speed_up())) { } @@ -56,7 +56,7 @@ Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRa template <> Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time (ContentTime d, FrameRateChange f) - : _t (llrint(d.get() / f.speed_up)) + : _t (llrint(d.get() / f.speed_up())) { } diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 322553586..3ab9bfb0c 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -421,7 +421,7 @@ FFmpegContent::full_length(shared_ptr<const Film> film) const if (audio) { DCPTime longest; for (auto i: audio->streams()) { - longest = max(longest, DCPTime::from_frames(llrint(i->length() / frc.speed_up), i->frame_rate())); + longest = max(longest, DCPTime::from_frames(llrint(i->length() / frc.speed_up()), i->frame_rate())); } return longest; } diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 0f38b3247..719406259 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -176,7 +176,7 @@ FFmpegDecoder::flush_fill() auto const frc = film()->active_frame_rate_change(_ffmpeg_content->position()); ContentTime full_length (_ffmpeg_content->full_length(film()), frc); - full_length = full_length.ceil (frc.source); + full_length = full_length.ceil (frc.source()); if (video && !video->ignore()) { double const vfr = _ffmpeg_content->video_frame_rate().get(); auto const v = video->position(film()).get_value_or(ContentTime()) + ContentTime::from_frames(1, vfr); diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index 363858688..d4e51d669 100644 --- a/src/lib/frame_rate_change.cc +++ b/src/lib/frame_rate_change.cc @@ -37,31 +37,31 @@ FrameRateChange::FrameRateChange() } -FrameRateChange::FrameRateChange(double source_, int dcp_) +FrameRateChange::FrameRateChange(double source, int dcp) { - source = source_; - dcp = 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)) { + _skip = true; + } 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. */ - repeat = round(dcp / source); + _repeat = round(_dcp / _source); } - speed_up = dcp / (source * factor()); + _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); + _change_speed = !about_equal(_speed_up, 1.0); } @@ -84,19 +84,19 @@ FrameRateChange::description() const { string description; - if (!skip && repeat == 1 && !change_speed) { + if (!_skip && _repeat == 1 && !_change_speed) { description = _("Content and DCP have the same rate.\n"); } else { - if (skip) { + if (_skip) { description = _("DCP will use every other frame of the content.\n"); - } else if (repeat == 2) { + } else if (_repeat == 2) { description = _("Each content frame will be doubled in the DCP.\n"); - } else if (repeat > 2) { - description = fmt::format(_("Each content frame will be repeated {} more times in the DCP.\n"), repeat - 1); + } else if (_repeat > 2) { + description = fmt::format(_("Each content frame will be repeated {} more times in the DCP.\n"), _repeat - 1); } - if (change_speed) { - double const pc = dcp * 100 / (source * factor()); + if (_change_speed) { + double const pc = _dcp * 100 / (_source * factor()); char buffer[256]; snprintf(buffer, sizeof(buffer), _("DCP will run at %.1f%% of the content speed.\n"), pc); description += buffer; diff --git a/src/lib/frame_rate_change.h b/src/lib/frame_rate_change.h index 84c4c340d..478cadeee 100644 --- a/src/lib/frame_rate_change.h +++ b/src/lib/frame_rate_change.h @@ -27,8 +27,8 @@ #include <string> -class Film; class Content; +class Film; class FrameRateChange @@ -43,20 +43,47 @@ public: to get the effective rate after any skip or repeat has happened. */ double factor() const { - if (skip) { + if (_skip) { return 0.5; } - return repeat; + return _repeat; + } + + std::string description() const; + + bool skip() const { + return _skip; + } + + int repeat() const { + return _repeat; + } + + double speed_up() const { + return _speed_up; } - double source = 24; - int dcp = 24; + bool change_speed() const { + return _change_speed; + } + + double source() const { + return _source; + } + + int dcp() const { + return _dcp; + } + +private: + double _source = 24; + int _dcp = 24; /** true to skip every other frame */ - bool skip = false; + bool _skip = false; /** number of times to use each frame (e.g. 1 is normal, 2 means repeat each frame once, and so on) */ - int repeat = 1; + int _repeat = 1; /** true if this DCP will run its video faster or slower than the source * without taking into account `repeat' nor `skip'. * (e.g. change_speed will be true if @@ -66,14 +93,12 @@ public: * source is 15.00fps, DCP is 30fps * source is 12.50fps, DCP is 25fps) */ - bool change_speed = false; + bool _change_speed = false; /** Amount by which the video is being sped-up in the DCP; e.g. for a * 24fps source in a 25fps DCP this would be 25/24. */ - double speed_up = 1.0; - - std::string description() const; + double _speed_up = 1.0; }; diff --git a/src/lib/hints.cc b/src/lib/hints.cc index 99882ec0e..35eb640d4 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -227,7 +227,7 @@ Hints::check_speed_up() optional<double> lowest_speed_up; optional<double> highest_speed_up; for (auto i: film()->content()) { - double spu = film()->active_frame_rate_change(i->position()).speed_up; + double spu = film()->active_frame_rate_change(i->position()).speed_up(); if (!lowest_speed_up || spu < *lowest_speed_up) { lowest_speed_up = spu; } diff --git a/src/lib/player.cc b/src/lib/player.cc index 7498ca4e7..f93327495 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -542,7 +542,7 @@ Player::dcp_to_content_video(shared_ptr<const Piece> piece, DCPTime t) const Instead we convert the DCPTime using the DCP video rate then account for any skip/repeat. */ - return s.frames_floor(piece->frc.dcp) / piece->frc.factor(); + return s.frames_floor(piece->frc.dcp()) / piece->frc.factor(); } @@ -550,7 +550,7 @@ DCPTime Player::content_video_to_dcp(shared_ptr<const Piece> piece, Frame f) const { /* See comment in dcp_to_content_video */ - auto const d = DCPTime::from_frames(f * piece->frc.factor(), piece->frc.dcp) - DCPTime(piece->content->trim_start(), piece->frc); + auto const d = DCPTime::from_frames(f * piece->frc.factor(), piece->frc.dcp()) - DCPTime(piece->content->trim_start(), piece->frc); return d + piece->content->position(); } diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index d3315a722..05c2a7e9e 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -730,12 +730,12 @@ Playlist::speed_up_range(int dcp_video_frame_rate) const } if (i->video_frame_rate()) { FrameRateChange const frc(i->video_frame_rate().get(), dcp_video_frame_rate); - range.first = min(range.first, frc.speed_up); - range.second = max(range.second, frc.speed_up); + range.first = min(range.first, frc.speed_up()); + range.second = max(range.second, frc.speed_up()); } else { FrameRateChange const frc(dcp_video_frame_rate, dcp_video_frame_rate); - range.first = min(range.first, frc.speed_up); - range.second = max(range.second, frc.speed_up); + range.first = min(range.first, frc.speed_up()); + range.second = max(range.second, frc.speed_up()); } } diff --git a/src/wx/text_view.cc b/src/wx/text_view.cc index bde7b09e9..999fe94ab 100644 --- a/src/wx/text_view.cc +++ b/src/wx/text_view.cc @@ -142,7 +142,7 @@ TextView::data_start (ContentStringText cts) wxListItem list_item; list_item.SetId (_subs); _list->InsertItem (list_item); - _list->SetItem (_subs, 0, std_to_wx (cts.from().timecode (_frc->source))); + _list->SetItem (_subs, 0, std_to_wx (cts.from().timecode (_frc->source()))); _list->SetItem (_subs, 2, std_to_wx (i.text ())); _start_times.push_back (cts.from ()); ++_subs; @@ -160,7 +160,7 @@ TextView::data_stop (ContentTime time) } for (int i = _subs - *_last_count; i < _subs; ++i) { - _list->SetItem (i, 1, std_to_wx (time.timecode (_frc->source))); + _list->SetItem (i, 1, std_to_wx (time.timecode (_frc->source()))); } } @@ -176,5 +176,5 @@ TextView::subtitle_selected (wxListEvent& ev) auto lc = _content.lock (); DCPOMATIC_ASSERT (lc); /* Add on a frame here to work around any rounding errors and make sure we land in the subtitle */ - _film_viewer.seek(lc, _start_times[ev.GetIndex()] + ContentTime::from_frames(1, _frc->source), true); + _film_viewer.seek(lc, _start_times[ev.GetIndex()] + ContentTime::from_frames(1, _frc->source()), true); } |
