Skip to main content

VaapiEncoder

Struct VaapiEncoder 

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

One VA-API encoder session, hardware, for one capture.

Implementations§

Source§

impl VaapiEncoder

Source

pub fn new( settings: &RustCaptureSettings, codec: Codec, input: Input, ) -> Result<Self, String>

Stand up a session for codec on the render node the settings select, fed through input, with the libva of this process.

Source§

impl VaapiEncoder

Source

pub fn codec(&self) -> Codec

Source

pub fn is_fullcolor(&self) -> bool

Whether this session negotiated 4:4:4 chroma.

Source

pub fn bit_depth(&self) -> u32

The bits per sample the session opened at.

Source

pub fn surface_format_name(&self) -> String

The name of the surface format frames reach the codec in, for the session log.

Source

pub fn is_full_range(&self) -> bool

A hardware session converts at limited range.

Source

pub fn vendor(&self) -> &str

The driver behind the session, as libva names it.

Source

pub fn low_power(&self) -> bool

Whether the codec runs on the low-power entry point.

Source

pub fn last_reference(&self) -> Reference

The frame the last encoded frame predicted from.

Source

pub fn take_report(&mut self, report: ReferenceReport) -> bool

Apply what the consumers say of a frame: a loss as invalidate_reference, a frame every one of them holds or was sent (ReferenceWindow::acknowledge, ReferenceSlots::acknowledge).

Source

pub fn invalidate_reference(&mut self, frame_id: u16) -> bool

Leave frame frame_id and every frame after it out of the predictions. False where the session tracks none, and the caller codes a key frame instead.

Source

pub fn reconfigure_rate( &mut self, settings: &RustCaptureSettings, ) -> Result<(), String>

Take a rate or frame-rate change: the next frame opens a sequence with the new rate control, as a key frame.

Source

pub fn is_cbr(&self) -> bool

Whether the session runs a constant rate.

Source

pub fn last_size(&self) -> Option<usize>

The bytes of the last frame coded, the driver’s padding aside: what tells a constant-rate cleanup the rate control has nothing left to refine.

Source

pub fn last_quality(&self) -> Option<u32>

The quality index the rate control last coded a frame at: for H.264 and HEVC where the driver reports a picture’s average quantizer with its coded buffer (iHD does), for AV1 and VP9 the base_q_idx it wrote into the frame header. A picture that is mostly skipped blocks reports near the quantizer its slices open at, so the figure is trusted for having reached a quality, never for the lack of it.

Source

pub fn measures(&self) -> bool

Whether measure yields a measurement: until a surface turns out unreadable, as the reconstruction of iHD’s packed 4:4:4 does, kept at another geometry than its source.

Source

pub fn measure(&mut self)

Measure the next frame’s reconstruction against its source (last_psnr).

Source

pub fn last_psnr(&self) -> Option<f32>

The luma PSNR, in dB, of the last frame measured: its reconstruction against the converted picture it was coded from, both read back on every PSNR_ROW_STEPth row. What tells a constant-rate cleanup whether the driver’s rate control is still refining a still screen, whatever the driver says of its quantizer; None where a surface cannot be read as the picture’s rows.

Source

pub fn hold_quantizer(&mut self, crf: u32)

Encode the next frame at the quantizer the quality index crf selects, and leave the session’s own quantizer for the frame after: the cleanup of a still screen, at a constant quantizer. A constant-rate session codes the frame under its rate control: radeonsi drops per-frame quantizer bounds (a key frame held by them came out starved in the session’s small buffer, 26 dB), and a key frame given a budget of its own through a restarted rate control came out coarser than the picture the driver’s rate control refines a still screen to by itself (51 against 61 dB at 8 Mbit/s), so FrameEncoder::holds_quantizer says no there.

Source

pub fn encode_host( &mut self, pixels: &[u8], stride: usize, rgba: bool, frame_number: u64, crf: u32, force_idr: bool, ) -> Result<Vec<u8>, String>

Encode one packed host frame (stride bytes per row, in the byte order the session was built for) at the quality index crf: uploaded straight from the caller’s rows onto the host surface and converted on the GPU.

Source

pub fn encode_dmabuf( &mut self, dmabuf: &Dmabuf, frame_number: u64, crf: u32, force_idr: bool, ) -> Result<Vec<u8>, String>

Encode one Wayland DRM-PRIME dmabuf: imported as a VA surface in place for the frame and converted on the GPU.

Trait Implementations§

Source§

impl Drop for VaapiEncoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for VaapiEncoder

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
§

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<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

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> Ungil for T
where T: Send,

§

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