Skip to main content

ExactFrameReader

Struct ExactFrameReader 

Source
pub struct ExactFrameReader { /* private fields */ }
Expand description

Presentation-indexed exact-frame access over decode-order compressed samples.

Implementations§

Source§

impl ExactFrameReader

Source

pub fn new( factory: &dyn VideoDecoderFactory, configuration: VideoDecoderConfig, samples: Vec<EncodedVideoSample>, limits: Limits, ) -> Result<Self>

Source

pub fn from_provider( factory: &dyn VideoDecoderFactory, configuration: VideoDecoderConfig, samples: Box<dyn SampleProvider>, limits: Limits, ) -> Result<Self>

Builds a reader over any SampleProvider, such as one that reads compressed bytes from a container track and a crate::io::ByteSource on demand instead of owning every sample.

Behaves exactly as Self::new, which is this constructor with an owned Vec<EncodedVideoSample> as the provider.

Source

pub fn set_seek_previews( &mut self, previews: Option<Arc<dyn SeekPreviewSource>>, )

Attaches (or, with None, detaches) the preview source Self::seek answers from.

The source is normally a zvidlib::previews::PreviewIndex filling itself on a decoder of its own, and it is shared rather than owned so a reader can start answering seeks from it while its pass is still walking the track.

Source

pub fn seek(&mut self, presentation_index: FrameIndex) -> Seek

Answers “what is at this position of the timeline” without decoding anything.

This is the seek path, and it is bounded by ARCHITECTURE.md section 3.2: it takes the same time whichever position of whatever track it is asked about, because it only ever looks at pictures that are already decoded. It reads the presentation cache first - a seek back to somewhere the reader has just been is exact for nothing - and then the attached seek preview index, and it returns Seek::Pending rather than blocking when neither holds anything.

Reaching the exact frame is Self::get, which is unbounded by construction: the frame depends on every frame back to its random-access point and they all have to be decoded. A caller that wants both draws what this returns and walks to the exact frame behind it.

Source

pub fn get( &mut self, presentation_index: FrameIndex, cancellation: &CancellationToken, ) -> Result<VideoFrame>

Returns exactly the requested presentation frame, and the frames behind it that the cache can hold, so a request that comes back for one of those is answered for nothing.

This is the destination of a seek. A walk that is going to keep walking forwards should ask for its intermediate frames with get_step instead, which converts the frame it was asked for and nothing else.

Source

pub fn get_step( &mut self, presentation_index: FrameIndex, cancellation: &CancellationToken, ) -> Result<VideoFrame>

Returns exactly the requested presentation frame and converts nothing else.

A step is a picture on the way to somewhere, not somewhere: the caller is going to ask for a frame further forward next, so the frames behind this one that get would keep are converted for a request that never comes. That tail is bounded per call and so is affordable for one seek, but a walk that publishes as it goes pays it once per published picture, and once the stride is shorter than the tail the tails overlap and the walk converts every picture it passes rather than the few it publishes (issue #402).

Frames at or after the target in presentation order are still kept, exactly as get keeps them: on a stream with B-pictures those are the reordered frames the next request asks for, and dropping them would reset the decoder and re-walk the group of pictures.

Source

pub fn decode_positions_for( &self, presentation_index: FrameIndex, ) -> Result<Range<usize>>

The decode-order positions whose samples Self::get of presentation_index reads from the provider, as far as the index can tell, so a caller can load them before asking.

This is empty for a cached frame. Otherwise it runs from where the walk starts - the open session’s next position when the walk continues it, or the frame’s random-access point when it resets - through the last sample of the frame’s group of pictures presented no later than the frame, since a reordering decoder holds the frame back until those have been submitted. A decoder may still want a sample or two past that before it releases the frame; a provider reports ErrorKind::WouldBlock for any it does not have, and the request is resumable, so this is a prefetch hint rather than a guarantee.

Source

pub fn drain(&mut self, cancellation: &CancellationToken) -> Result<usize>

Drains delayed output into the bounded presentation cache.

Source

pub fn reset(&mut self) -> Result<()>

Clears decoder, reorder, and frame-cache state.

Source

pub const fn statistics(&self) -> DecodeStatistics

Source

pub fn cached_frames(&self) -> usize

Auto Trait Implementations§

§

impl !RefUnwindSafe for ExactFrameReader

§

impl !Sync for ExactFrameReader

§

impl !UnwindSafe for ExactFrameReader

§

impl Forget for ExactFrameReader

§

impl Freeze for ExactFrameReader

§

impl Move for ExactFrameReader

§

impl Send for ExactFrameReader
where RawVecInner: Send, BoxRaw<dyn VideoDecoder>: Send, BoxRaw<dyn SampleProvider>: Send, RawTable<(FrameIndex, usize)>: Send, NodeRef<Owned, FrameIndex, VideoFrame, LeafOrInternal>: Send, BoxRaw<(FrameIndex, VideoFrame)>: Send, RawTable<(FrameIndex, ())>: Send, Arc<dyn SeekPreviewSource>: Send,

§

impl Unpin for ExactFrameReader

§

impl UnsafeUnpin for ExactFrameReader

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.