summaryrefslogtreecommitdiff
path: root/src/sub_time.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-13 22:59:22 +0200
committerCarl Hetherington <cth@carlh.net>2025-10-13 22:59:22 +0200
commit0225cfa5933cbcb8c236b7cf9dbd05a6260ea911 (patch)
tree97623dd51ba60ed30407a8cb47a1acf7b181e57b /src/sub_time.cc
parentba6765286f5746510cfa731a9312c7f31f723043 (diff)
fixup! WIP: SCC support.scc
Diffstat (limited to 'src/sub_time.cc')
-rw-r--r--src/sub_time.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/sub_time.cc b/src/sub_time.cc
index 763b4e4..6773e67 100644
--- a/src/sub_time.cc
+++ b/src/sub_time.cc
@@ -155,15 +155,17 @@ Time::from_hms (int h, int m, int s, int ms)
return Time (h * 3600 + m * 60 + s, ms, Rational (1000, 1));
}
-/** Create a Time from a number of frames.
- * rate must be integer.
- */
+/** Create a Time from a number of frames */
Time
Time::from_frames (int f, Rational rate)
{
SUB_ASSERT (rate.denominator != 0);
- SUB_ASSERT (rate.integer ());
- return Time (f / rate.integer_fraction(), f % rate.integer_fraction(), rate);
+ if (rate.integer()) {
+ return Time(f / rate.integer_fraction(), f % rate.integer_fraction(), rate);
+ } else {
+ auto const seconds = std::floor(f / rate.fraction());
+ return Time(seconds, std::round(f - seconds * rate.fraction()), rate);
+ }
}
double