Skip to main content

VpxEncoder

Struct VpxEncoder 

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

One libvpx session for one capture.

Implementations§

Source§

impl VpxEncoder

Source

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

Open a VP8 or VP9 session on host frames in the byte order rgba names.

Source

pub fn codec(&self) -> Codec

Source

pub fn library(&self) -> &'static str

The library behind the session, as the logs name it.

Source

pub fn is_fullcolor(&self) -> bool

Whether the session carries 4:4:4 (VP9 profile 1, or 3 at 10 bits).

Source

pub fn bit_depth(&self) -> u32

The bits per sample the session codes: 10 in VP9 profiles 2 and 3.

Source

pub fn is_full_range(&self) -> bool

VP9 keeps the limited range of its 4:2:0 in profile 1, so the decoder hint a client sends for it stays true; VP8 has no other.

Source

pub fn last_reference(&self) -> Reference

The frame the last encoded frame predicted from.

Source

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

Leave frame frame_id and every frame after it out of the predictions; the next frame predicts from an earlier buffer, or is a key frame when none is left.

Source

pub fn acknowledge_reference(&mut self, frame_id: u16, held: bool)

Every consumer holds frame frame_id, or where not held was sent it (ReferenceSlots::acknowledge).

Source

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

The quality index the rate control last coded a frame at, held frames aside.

Source

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

The bytes of the last frame the rate control coded, held frames aside, where a constant-rate cleanup runs through that rate control (holds_quantizer).

Source

pub fn holds_quantizer(&self) -> bool

Whether the cleanup of a still screen holds a frame at its quantizer: at a constant quantizer, and at a constant rate for VP8, whose rate control leaves a still screen as it is (a screen of text at 2 Mbit/s at 1080p stayed at 33.6 dB, where the held refresh reached 42.8). VP9’s refines one, so its constant-rate cleanup runs through the rate control instead: 43.6 dB in 2.5 s with no frame over 75 kB, where the held refresh was one of 347 kB.

Source

pub fn hold_quantizer(&mut self, crf: u32, band: Option<(f64, f64)>)

Encode the next frame at the quantizer the quality index crf selects, whatever the rate control, and put the session’s own rate control back for the frame after: the cleanup of a still screen. A held key frame of a constant-rate session starts at the quantizer the last one says fits HELD_KEY_BUDGET_S of the target (held_key_start), and one that comes out past it is coded again, as a key frame, at the coarser quantizer held_key_retry picks. band, the share of the picture from and to in raster order, confines the quantizer to the macroblocks it covers where the session holds a band (band_size), and the rest of the frame is left as the reference has it.

Source

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

The bytes of the last held frame (0 before one), where the session holds a band of a frame at a quantizer: VP8, through libvpx’s region-of-interest map (band_roi), at a rate that leaves a band room in a frame. A VP8 frame codes every macroblock’s mode even where it skips them all, about a third of a bit each at 720p and 1080p, so below BAND_BITS_PER_MB of frame budget a band a frame is mostly that and the sweep cannot keep the rate: 1080p text at 0.25 Mbit/s (half a bit) ended at 29.5 dB in bands against 42.0 held whole, where 720p at 0.25 (1.2 bits) ended at 41.5 against 42.0 with the worst wait at the target 5.0 s against 18.5. The refresh is held whole below it.

Source

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

Re-program the rate control when a rate or frame-rate setting changed, live.

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 at the quality index crf, as a key frame when force_idr or when no reference is left to predict from.

Trait Implementations§

Source§

impl Drop for VpxEncoder

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 VpxEncoder

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