pub struct TcMath;Expand description
Stateless utility for timecode mathematical operations.
§Example
use oximedia_timecode::tc_math::{TcMath, TcDuration};
let dur = TcDuration::from_hmsf(0, 1, 0, 0, 25); // 1 minute
let mid = TcMath::midpoint_between_durations(&TcDuration::from_frames(0, 25), &dur);
assert_eq!(mid.frames, 750); // 30 seconds at 25fpsImplementations§
Source§impl TcMath
impl TcMath
Sourcepub fn duration_between(a: &Timecode, b: &Timecode) -> TcDuration
pub fn duration_between(a: &Timecode, b: &Timecode) -> TcDuration
Compute the duration between two timecodes (absolute value).
Sourcepub fn midpoint(
a: &Timecode,
b: &Timecode,
rate: FrameRate,
) -> Result<Timecode, TimecodeError>
pub fn midpoint( a: &Timecode, b: &Timecode, rate: FrameRate, ) -> Result<Timecode, TimecodeError>
Compute the midpoint timecode between two timecodes.
Sourcepub fn offset_by_percentage(
tc: &Timecode,
duration: &TcDuration,
pct: f64,
rate: FrameRate,
) -> Result<Timecode, TimecodeError>
pub fn offset_by_percentage( tc: &Timecode, duration: &TcDuration, pct: f64, rate: FrameRate, ) -> Result<Timecode, TimecodeError>
Offset a timecode by a percentage of a duration.
Sourcepub fn midpoint_between_durations(a: &TcDuration, b: &TcDuration) -> TcDuration
pub fn midpoint_between_durations(a: &TcDuration, b: &TcDuration) -> TcDuration
Compute the midpoint between two durations (not anchored to a TOD).
Sourcepub fn position_percentage(
tc: &Timecode,
start: &Timecode,
end: &Timecode,
) -> f64
pub fn position_percentage( tc: &Timecode, start: &Timecode, end: &Timecode, ) -> f64
Compute a percentage position of a timecode within a range.
Sourcepub fn rate_conversion_factor(from: FrameRate, to: FrameRate) -> f64
pub fn rate_conversion_factor(from: FrameRate, to: FrameRate) -> f64
Compute the frame rate conversion factor between two rates.
Auto Trait Implementations§
impl Freeze for TcMath
impl RefUnwindSafe for TcMath
impl Send for TcMath
impl Sync for TcMath
impl Unpin for TcMath
impl UnsafeUnpin for TcMath
impl UnwindSafe for TcMath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more