[−][src]Trait spectrusty_core::clock::FrameTimestamp
A trait providing simple calculation methods for frame-aware timestamps.
This allows BusDevice implementations to depend on a generic timestamp type avoiding unnecessary VideoFrame dependency.
Required methods
fn from_tstates(ts: FTs) -> Self
Returns a normalized timestamp from the given count of T-states.
Panics
Panics when the given ts overflows the capacity of the timestamp.
fn into_tstates(self) -> FTs
Returns the number of T-states measured from the start of the frame.
The frame starts when the horizontal and vertical counter are both 0.
The returned value can be negative as well as exceeding the VideoFrame::FRAME_TSTATES_COUNT.
This function should be used to ensure that a single frame event, timestamped with T-states, will be always in the ascending order.
fn into_frame_tstates(self, frames: u64) -> (u64, FTs)
Returns a tuple with an adjusted frame counter and with the frame-normalized timestamp as the number of T-states measured from the start of the frame.
The frame starts when the horizontal and vertical counter are both 0.
The returned timestamp value is in the range [0, VideoFrame::FRAME_TSTATES_COUNT).
fn max_value() -> Self
Returns the largest value that can be represented by a normalized timestamp.
fn min_value() -> Self
Returns the smallest value that can be represented by a normalized timestamp.
fn is_eof(self) -> bool
Returns true if the counter value is past or near the end of a frame. Otherwise returns false.
Specifically, the condition is met if the vertical counter is equal to or greater than VideoFrame::VSL_COUNT.
fn diff_from(self, vts_from: Self) -> FTs
Returns the difference between self and vts_from video timestamps in T-states.
fn saturating_sub_frame(self) -> Self
Returns a video timestamp after subtracting the total number of frame video scanlines from the scan line counter.
fn saturating_sub(self, other: Self) -> Self
Returns a normalized video timestamp after subtracting an other from it.
Saturates at FrameTimestamp::min_value or FrameTimestamp::max_value.
fn saturating_add(self, other: Self) -> Self
Returns a normalized video timestamp after adding an other to it.
Saturates at FrameTimestamp::min_value or FrameTimestamp::max_value.
fn wrap_frame(&mut self)
Ensures the vertical counter is in the range: (-VSL_COUNT, VSL_COUNT) by calculating
a remainder of the division of the vertical counter by VideoFrame::VSL_COUNT.
Provided methods
fn min_tstates() -> FTs
Returns the smallest value that can be represented by a normalized timestamp as the number of T-states.
fn max_tstates() -> FTs
Returns the largest value that can be represented by a normalized timestamp as the number of T-states.