summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-22 00:09:57 +0100
committerCarl Hetherington <cth@carlh.net>2025-09-02 22:40:13 +0200
commit33b0928b20618da5bc295711bfdf3d638863afa5 (patch)
tree24af21c6a7b863d914991ae837c36b6b9b50bcce /src/wx
parent6784eb8de2451afd2dedc15c05eac043011b5afb (diff)
Untested conversion to num/den DCPTime.arbitrary-hz
Summary of required changes: Replace ::from_frames with a constructor that takes num/den. Provide and use member to_debug_string() instead of to_string(). Provide and use member to_serializable_string() and string constructor instead of fmt::to_string on .get() and number constructor. Provide and use content_time() member instead of ContentTime constructor from DCPTime. Use frames_round(96000) instead of get() when comparing times to see if they are "close enough". Provide and use DCPTime(x, FrameRateChange) constructor when converting from ContentTime. Use .seconds() when calculating proportions or sometimes when dividing by HZ. Provide and use operator bool(). Pass explicit 96000 denominator in a lot of places. Add member max() and use it instead of static max() Change BOOST_CHECK_EQUAL to BOOST_CHECK Provide operator/ and use it instead of .get() / 2.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/audio_dialog.cc2
-rw-r--r--src/wx/audio_plot.cc4
-rw-r--r--src/wx/content_view.cc2
-rw-r--r--src/wx/controls.cc6
-rw-r--r--src/wx/dcp_timeline.cc2
-rw-r--r--src/wx/film_viewer.cc4
-rw-r--r--src/wx/markers_dialog.cc2
-rw-r--r--src/wx/markers_panel.cc2
-rw-r--r--src/wx/playhead_to_frame_dialog.cc2
-rw-r--r--src/wx/text_view.cc4
-rw-r--r--src/wx/timecode.h6
-rw-r--r--src/wx/timeline_reels_view.cc4
-rw-r--r--src/wx/timing_panel.cc8
-rw-r--r--src/wx/video_view.cc2
14 files changed, 25 insertions, 25 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc
index 795a39a44..b60ecb738 100644
--- a/src/wx/audio_dialog.cc
+++ b/src/wx/audio_dialog.cc
@@ -473,5 +473,5 @@ AudioDialog::set_cursor (optional<DCPTime> time, optional<float> db)
auto film = _film.lock();
DCPOMATIC_ASSERT (film);
- _cursor->SetLabel(wxString::Format(_("Cursor: %.1fdB at %s"), *db, std_to_wx(time->timecode(film->video_frame_rate()))));
+ _cursor->SetLabel(wxString::Format(_("Cursor: %.1fdB at %s"), *db, std_to_wx(time->timecodeX(film->video_frame_rate()))));
}
diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc
index 3982f9705..356cf49b6 100644
--- a/src/wx/audio_plot.cc
+++ b/src/wx/audio_plot.cc
@@ -319,7 +319,7 @@ AudioPlot::plot_peak (wxGraphicsPath& path, int channel, Metrics const & metrics
_peak[channel].push_back (
Point (
wxPoint (metrics.db_label_width + i * metrics.x_scale, y_for_linear (peak, metrics)),
- DCPTime::from_frames (i * _analysis->samples_per_point(), _analysis->sample_rate()),
+ DCPTime(i * _analysis->samples_per_point(), _analysis->sample_rate()),
linear_to_db(peak)
)
);
@@ -389,7 +389,7 @@ AudioPlot::plot_rms (wxGraphicsPath& path, int channel, Metrics const & metrics)
_rms[channel].push_back (
Point (
wxPoint (metrics.db_label_width + i * metrics.x_scale, y_for_linear (p, metrics)),
- DCPTime::from_frames (i * _analysis->samples_per_point(), _analysis->sample_rate()),
+ DCPTime(i * _analysis->samples_per_point(), _analysis->sample_rate()),
linear_to_db(p)
)
);
diff --git a/src/wx/content_view.cc b/src/wx/content_view.cc
index 0bbc80535..005f98d87 100644
--- a/src/wx/content_view.cc
+++ b/src/wx/content_view.cc
@@ -164,7 +164,7 @@ ContentView::add (shared_ptr<Content> content)
it.SetId(N);
it.SetColumn(0);
auto length = content->approximate_length ();
- auto const hmsf = length.split (24);
+ auto const hmsf = length.splitX(24);
it.SetText(wxString::Format(char_to_wx("%02d:%02d:%02d"), hmsf.h, hmsf.m, hmsf.s));
InsertItem(it);
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index a452e1d13..8619b6b4a 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -227,7 +227,7 @@ Controls::slider_moved (bool page)
_slider_being_moved = true;
}
- DCPTime t (_slider->GetValue() * _film->length().get() / 4096);
+ auto t = DCPTime::from_seconds(_slider->GetValue() * _film->length().seconds() / 4096);
t = t.round (_film->video_frame_rate());
/* Ensure that we hit the end of the film at the end of the slider. In particular, we
need to do an accurate seek in case there isn't a keyframe near the end.
@@ -265,8 +265,8 @@ Controls::update_position_slider ()
auto const len = _film->length ();
- if (len.get ()) {
- int const new_slider_position = 4096 * _viewer.position().get() / len.get();
+ if (len) {
+ int const new_slider_position = 4096 * _viewer.position().seconds() / len.seconds();
if (new_slider_position != _slider->GetValue()) {
_slider->SetValue (new_slider_position);
}
diff --git a/src/wx/dcp_timeline.cc b/src/wx/dcp_timeline.cc
index 6ea91a060..a70fa8618 100644
--- a/src/wx/dcp_timeline.cc
+++ b/src/wx/dcp_timeline.cc
@@ -75,7 +75,7 @@ public:
sizer->Add(_label, wxGBPosition(index, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
sizer->Add(_timecode, wxGBPosition(index, 1));
- _timecode->set_maximum(maximum.split(fps));
+ _timecode->set_maximum(maximum.splitX(fps));
_timecode->set_editable(editable);
_timecode->Changed.connect(boost::bind(&ReelBoundary::timecode_changed, this));
}
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 45476c75d..b9c63d05d 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -713,7 +713,7 @@ FilmViewer::audio_time() const
}
return DCPTime::from_seconds(audio.getStreamTime()) -
- DCPTime::from_frames(average_latency(), _film->audio_frame_rate());
+ DCPTime(average_latency(), _film->audio_frame_rate());
}
@@ -795,7 +795,7 @@ FilmViewer::position_in_content(shared_ptr<const Content> content) const
DCPTime
FilmViewer::one_video_frame() const
{
- return DCPTime::from_frames(1, _film ? _film->video_frame_rate() : 24);
+ return DCPTime(1, _film ? _film->video_frame_rate() : 24);
}
diff --git a/src/wx/markers_dialog.cc b/src/wx/markers_dialog.cc
index 98cfc5367..90eab98f0 100644
--- a/src/wx/markers_dialog.cc
+++ b/src/wx/markers_dialog.cc
@@ -103,7 +103,7 @@ private:
auto vfr = f->video_frame_rate();
auto tc = _timecode->get(vfr);
if (tc >= f->length()) {
- tc = f->length() - DCPTime::from_frames(1, vfr);
+ tc = f->length() - DCPTime(1, vfr);
_timecode->set(tc, vfr);
}
if (_checkbox->GetValue()) {
diff --git a/src/wx/markers_panel.cc b/src/wx/markers_panel.cc
index 3ce9cd5a5..4c5fe10dd 100644
--- a/src/wx/markers_panel.cc
+++ b/src/wx/markers_panel.cc
@@ -136,7 +136,7 @@ MarkersPanel::position (dcpomatic::DCPTime time, int width) const
return 0;
}
- return end_gap + time.get() * (width - end_gap * 2) / film->length().get();
+ return end_gap + time.seconds() * (width - end_gap * 2) / film->length().seconds();
}
diff --git a/src/wx/playhead_to_frame_dialog.cc b/src/wx/playhead_to_frame_dialog.cc
index e307fa6b1..099c451c9 100644
--- a/src/wx/playhead_to_frame_dialog.cc
+++ b/src/wx/playhead_to_frame_dialog.cc
@@ -41,5 +41,5 @@ PlayheadToFrameDialog::PlayheadToFrameDialog (wxWindow* parent, DCPTime time, in
DCPTime
PlayheadToFrameDialog::get () const
{
- return DCPTime::from_frames (locale_convert<Frame> (wx_to_std (_frame->GetValue ())) - 1, _fps);
+ return DCPTime(locale_convert<Frame>(wx_to_std(_frame->GetValue())) - 1, _fps);
}
diff --git a/src/wx/text_view.cc b/src/wx/text_view.cc
index bde7b09e9..c7412327b 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().timecodeX(_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.timecodeX(_frc->source)));
}
}
diff --git a/src/wx/timecode.h b/src/wx/timecode.h
index 53cd93694..e74127622 100644
--- a/src/wx/timecode.h
+++ b/src/wx/timecode.h
@@ -81,19 +81,19 @@ public:
void set (T t, float fps)
{
- auto const hmsf = t.split (fps);
+ auto const hmsf = t.splitX(fps);
checked_set(_hours, fmt::to_string(hmsf.h));
checked_set(_minutes, fmt::to_string(hmsf.m));
checked_set(_seconds, fmt::to_string(hmsf.s));
checked_set(_frames, fmt::to_string(hmsf.f));
- checked_set (_fixed, t.timecode (fps));
+ checked_set(_fixed, t.timecodeX(fps));
}
void set_hint (T t, float fps)
{
- auto hmsf = t.split (fps);
+ auto hmsf = t.splitX(fps);
_hours->SetHint(std_to_wx(fmt::to_string(hmsf.h)));
_minutes->SetHint(std_to_wx(fmt::to_string(hmsf.m)));
diff --git a/src/wx/timeline_reels_view.cc b/src/wx/timeline_reels_view.cc
index 5f2a78079..ba98797ef 100644
--- a/src/wx/timeline_reels_view.cc
+++ b/src/wx/timeline_reels_view.cc
@@ -100,10 +100,10 @@ TimelineReelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>>)
wxDouble str_leading;
gc->GetTextExtent (str, &str_width, &str_height, &str_descent, &str_leading);
- int const available_width = time_x(DCPTime(i.to.get())) - time_x(DCPTime(i.from.get()));
+ int const available_width = time_x(i.to) - time_x(i.from);
if (available_width > str_width) {
- gc->DrawText (str, time_x(DCPTime(i.from.get())) + (available_width - str_width) / 2, _y + 4);
+ gc->DrawText (str, time_x(i.from) + (available_width - str_width) / 2, _y + 4);
}
}
}
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index 3b33808d3..43e7fbc95 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -391,7 +391,7 @@ TimingPanel::trim_end_changed()
/* XXX: maybe playhead-off-the-end-of-the-film should be handled elsewhere */
if (_viewer.position() >= _parent->film()->length()) {
- _viewer.seek(_parent->film()->length() - DCPTime::from_frames(1, _parent->film()->video_frame_rate()), true);
+ _viewer.seek(_parent->film()->length() - DCPTime(1, _parent->film()->video_frame_rate()), true);
}
_viewer.set_coalesce_player_changes(false);
@@ -405,7 +405,7 @@ TimingPanel::play_length_changed()
for (auto i: _parent->selected()) {
auto const frc = _parent->film()->active_frame_rate_change(i->position());
auto dcp = max(DCPTime(), i->full_length(_parent->film()) - play_length);
- i->set_trim_end(max(ContentTime(), ContentTime(dcp, frc) - i->trim_start()));
+ i->set_trim_end(max(ContentTime(), dcp.content_time(frc) - i->trim_start()));
}
}
@@ -443,7 +443,7 @@ TimingPanel::trim_start_to_playhead_clicked()
for (auto i: _parent->selected()) {
if (i->position() < ph && ph < i->end(film)) {
auto const frc = film->active_frame_rate_change(i->position());
- i->set_trim_start(film, i->trim_start() + ContentTime(ph - i->position(), frc));
+ i->set_trim_start(film, i->trim_start() + DCPTime(ph - i->position()).content_time(frc));
new_ph = i->position();
}
}
@@ -463,7 +463,7 @@ TimingPanel::trim_end_to_playhead_clicked()
for (auto i: _parent->selected()) {
if (i->position() < ph && ph < i->end(film)) {
auto const frc = film->active_frame_rate_change(i->position());
- i->set_trim_end(ContentTime(i->position() + i->full_length(film) - ph, frc) - i->trim_start());
+ i->set_trim_end(DCPTime(i->position() + i->full_length(film) - ph).content_time(frc) - i->trim_start());
}
}
}
diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc
index c658e3663..a8429743d 100644
--- a/src/wx/video_view.cc
+++ b/src/wx/video_view.cc
@@ -101,7 +101,7 @@ VideoView::get_next_frame (bool non_blocking)
dcpomatic::DCPTime
VideoView::one_video_frame () const
{
- return dcpomatic::DCPTime::from_frames (1, video_frame_rate());
+ return dcpomatic::DCPTime(1, video_frame_rate());
}