Struct MfVideo

Source
struct MfVideo {
Show 29 fields reader: IMFSourceReader, stream: u32, native_w: u32, native_h: u32, scale_ok: bool, req_last: (u32, u32), req_streak: u32, negotiated: bool, width: u32, height: u32, stride: i32, frame_hns: i64, native: Vec<u8>, have: bool, pts: i64, end: i64, rpts: i64, last_end: Option<i64>, eof_at: Option<i64>, origin: i64, mp4: bool, scaled: Vec<u8>, svalid: bool, sw: u32, sh: u32, xs: Vec<u32>, ys: Vec<u32>, acc: Vec<u32>, tab_key: (u32, u32, u32, u32),
}

Fields§

§reader: IMFSourceReader§stream: u32§native_w: u32

True source dimensions (from the first negotiated type, before any decode-size scaling). Reported by size() — placement/export/asset math must see native size regardless of what the decoder is currently asked to output.

§native_h: u32§scale_ok: bool

False once a scaled MF_MT_FRAME_SIZE negotiation has failed once: some decoders reject an arbitrary output size, so we stop retrying and decode at native size for the rest of the session.

§req_last: (u32, u32)

Last even-aligned request size and how many consecutive calls asked for it (see ensure_decode_size: only a settled request is worth a ~100 ms renegotiation).

§req_streak: u32§negotiated: bool

True after the first SetCurrentMediaType size negotiation (successful or not).

§width: u32§height: u32§stride: i32

MF_MT_DEFAULT_STRIDE of the current type (0 = unknown; negative = bottom-up).

§frame_hns: i64

Fallback frame duration when a sample has none.

§native: Vec<u8>

Native-size top-down RGBA of the cached frame.

§have: bool§pts: i64

Cached frame covers [pts, end) (pts may be pulled back to the requested t when the reader returned a later frame); rpts is the real sample time.

§end: i64§rpts: i64§last_end: Option<i64>

End of the last sample seen from the reader since the last seek.

§eof_at: Option<i64>

Where the stream ends (known once EOF was hit).

§origin: i64

MF time of the first frame = content t=0. MF keeps container time (mp4 initial empty edit, MKV offset), ffmpeg/ffprobe are content-relative; requests are shifted into MF time.

§mp4: bool

MPEG-4 source: SetCurrentPosition takes content-relative time while samples carry container time.

§scaled: Vec<u8>§svalid: bool§sw: u32§sh: u32§xs: Vec<u32>§ys: Vec<u32>§acc: Vec<u32>§tab_key: (u32, u32, u32, u32)

Implementations§

Source§

impl MfVideo

Source

fn refresh_type(&mut self) -> bool

Re-read size/stride from the current output type (after open or CURRENTMEDIATYPECHANGED).

Source

fn ensure_decode_size(&mut self, req_w: u32, req_h: u32)

Ask MF to decode+scale straight to the requested size instead of always paying for a full native-resolution decode + copy + Rust rescale. MF_SOURCE_READER_ENABLE_ADVANCED_VIDEO_ PROCESSING (set at open) lets the reader’s video processor MFT do this — hardware-accelerated when DXVA is active — so a 4K source previewed at 1280 wide never copies a 4K (or even half-4K) frame to system memory at all: the sample that crosses the bus already is preview-sized.

A renegotiation (SetCurrentMediaType mid-stream) costs ~100 ms, so only a settled request is followed: the same size on STABLE_REQS consecutive calls. A clip animating its on-screen scale asks for a different size every call, never settles, and keeps decoding at the last settled size with the CPU scaler covering the difference. The very first request after open negotiates at once — that is the everyday “open a 4K file, preview it small” case, and warm-up frames at native 4K would cost more than the negotiation.

Source

fn seek(&mut self, tt: i64) -> bool

Source

fn read_until(&mut self, tt: i64) -> bool

Read forward until a sample whose end is past tt; cache it. False at EOF / error.

Source

fn copy_sample(&mut self, sample: &IMFSample) -> bool

BGRX sample -> top-down RGBA native.

Source

fn emit(&mut self, w: u32, h: u32, out: &mut Frame)

Write the cached frame at (w,h) into out.

Source

fn rescale(&mut self, w: u32, h: u32)

Trait Implementations§

Source§

impl VideoSource for MfVideo

Source§

fn size(&self) -> (u32, u32)

Native (coded) size.
Source§

fn frame_at(&mut self, t: f64, w: u32, h: u32, out: &mut Frame) -> bool

Decode the frame displayed at source time t, scaled (aspect-ignorant, caller picks w/h; the compositor never asks for more than native size, so upscaling need only be correct) into out. Returns false at/after EOF or on error (then out is untouched). Must be cheap for sequential increasing t (playback: keep decoding forward); may seek for other jumps.
Source§

impl Send for MfVideo

Auto Trait Implementations§

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.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> MaybeSend for T

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,