Skip to main content

EncoderConfig

Struct EncoderConfig 

Source
pub struct EncoderConfig {
    pub width: usize,
    pub height: usize,
    pub profile: Profile,
    pub chroma: ChromaFormat,
    pub level_idc: u8,
    pub qp: u8,
    pub gop_size: u32,
    pub bitrate: u32,
    pub framerate: f32,
    pub num_ref_frames: u32,
    pub preset: Preset,
}
Expand description

Configuration for an crate::Encoder.

Fields§

§width: usize

Picture width in luma samples. Arbitrary (not restricted to /16).

§height: usize

Picture height in luma samples.

§profile: Profile

Target profile. Only Profile::ConstrainedBaseline is implemented.

§chroma: ChromaFormat

Chroma format. Only ChromaFormat::Yuv420 is implemented.

§level_idc: u8

level_idc (e.g. 30 = level 3.0). Caller is responsible for choosing a level that admits the resolution/bitrate; not yet validated.

§qp: u8

Quantization parameter (0..=51). With rate control off this is the fixed QP for every frame; with it on, the base/fallback QP and pic_init_qp.

§gop_size: u32

Frames between IDR pictures. 1 = all-intra (every frame an IDR).

§bitrate: u32

Target bitrate in bits per second. 0 disables rate control (constant QP); any positive value enables average-bitrate control, which varies the per-frame QP around qp to converge on this rate.

§framerate: f32

Frame rate (frames per second), used by rate control to turn the bitrate target into a per-frame bit budget.

§num_ref_frames: u32

Number of reference frames the encoder may use for P-pictures (1..=16). 1 keeps the single-reference bitstream; higher values let P-macroblocks pick an older reference (ref_idx), helping occlusion/periodic motion.

§preset: Preset

Speed/quality trade-off. Defaults to Preset::Fast.

Implementations§

Source§

impl EncoderConfig

Source

pub fn new(width: usize, height: usize) -> Self

A minimal all-intra Constrained Baseline configuration at the given size.

Source

pub fn mb_width(&self) -> usize

Picture width rounded up to whole macroblocks.

Source

pub fn mb_height(&self) -> usize

Picture height rounded up to whole macroblocks.

Trait Implementations§

Source§

impl Clone for EncoderConfig

Source§

fn clone(&self) -> EncoderConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EncoderConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.