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: u32True 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: boolFalse 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: boolTrue after the first SetCurrentMediaType size negotiation (successful or not).
width: u32§height: u32§stride: i32MF_MT_DEFAULT_STRIDE of the current type (0 = unknown; negative = bottom-up).
frame_hns: i64Fallback frame duration when a sample has none.
native: Vec<u8>Native-size top-down RGBA of the cached frame.
have: bool§pts: i64Cached 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: i64MF 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: boolMPEG-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
impl MfVideo
Sourcefn refresh_type(&mut self) -> bool
fn refresh_type(&mut self) -> bool
Re-read size/stride from the current output type (after open or CURRENTMEDIATYPECHANGED).
Sourcefn ensure_decode_size(&mut self, req_w: u32, req_h: u32)
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.
fn seek(&mut self, tt: i64) -> bool
Sourcefn read_until(&mut self, tt: i64) -> bool
fn read_until(&mut self, tt: i64) -> bool
Read forward until a sample whose end is past tt; cache it. False at EOF / error.
Sourcefn copy_sample(&mut self, sample: &IMFSample) -> bool
fn copy_sample(&mut self, sample: &IMFSample) -> bool
BGRX sample -> top-down RGBA native.
fn rescale(&mut self, w: u32, h: u32)
Trait Implementations§
Source§impl VideoSource for MfVideo
impl VideoSource for MfVideo
Source§fn frame_at(&mut self, t: f64, w: u32, h: u32, out: &mut Frame) -> bool
fn frame_at(&mut self, t: f64, w: u32, h: u32, out: &mut Frame) -> bool
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.impl Send for MfVideo
Auto Trait Implementations§
impl Freeze for MfVideo
impl RefUnwindSafe for MfVideo
impl !Sync for MfVideo
impl Unpin for MfVideo
impl UnwindSafe for MfVideo
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
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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