#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Timescale(pub u32);
impl Timescale {
pub const MPEG_TS: Timescale = Timescale(90_000);
pub fn to_millis(self, ticks: u64) -> u64 {
ticks.saturating_mul(1_000) / u64::from(self.0.max(1))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Scaled {
pub ticks: u64,
pub scale: Timescale,
}
impl Scaled {
pub fn new(ticks: u64, scale: Timescale) -> Self {
Self { ticks, scale }
}
pub fn seconds(self) -> f64 {
self.ticks as f64 / f64::from(self.scale.0.max(1))
}
}