Skip to main content

ParallelConfig

Struct ParallelConfig 

Source
#[non_exhaustive]
pub struct ParallelConfig {
Show 15 fields pub sample_rate: i32, pub channels: usize, pub application: Application, pub bitrate_bps: i32, pub complexity: i32, pub rate_control: RateControl, pub use_inband_fec: bool, pub use_dtx: bool, pub packet_loss_perc: i32, pub force_bandwidth: Option<Bandwidth>, pub signal_type: Option<Signal>, pub max_bandwidth: Bandwidth, pub lsb_depth: i32, pub warmup_ms: u32, pub threads: usize,
}
Expand description

Configuration for a parallel encode.

Every setting OpusEncoder exposes appears here, because a worker’s encoder is built from this struct and nothing else: a setting missing from this list is one the parallel path cannot reach at all. The defaults are OpusEncoder’s own, apart from bitrate_bps and complexity, which have none there.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§sample_rate: i32

Rate of the PCM being encoded, as OpusEncoder::new takes it.

§channels: usize

Channels in that PCM, interleaved. 1 or 2.

§application: Application

What to optimise for, as OpusEncoder::new takes it.

§bitrate_bps: i32

OpusEncoder::bitrate_bps. Defaults to 64000 here, where the encoder itself has no default of its own.

§complexity: i32

OpusEncoder::complexity. Defaults to 9 here, where the encoder itself has no default of its own.

§rate_control: RateControl§use_inband_fec: bool§use_dtx: bool

Discontinuous transmission. Its trigger counts consecutive inactive frames and each worker starts that count at zero, so a chunked encode emits fewer DTX packets than a serial one over the same silence.

§packet_loss_perc: i32§force_bandwidth: Option<Bandwidth>

Pinning this, or Self::signal_type, takes the content analysis out of the coding-mode decision and lets warmup_ms be much shorter.

§signal_type: Option<Signal>§max_bandwidth: Bandwidth

OpusEncoder::max_bandwidth. Unlike Self::force_bandwidth this only caps the automatic choice, so it does not remove the analysis from the decision and does not shorten the warm-up.

§lsb_depth: i32§warmup_ms: u32

Audio each worker re-encodes before its own chunk to prime encoder state, then discards. Milliseconds rather than frames because what it has to cover is a time constant; see DEFAULT_WARMUP_MS. 0 disables priming, which is naive chunking and audibly wrong.

§threads: usize

Worker count; 0 selects available_parallelism. Capped by the redundancy ceiling — ask Self::plan what will actually be used.

Implementations§

Source§

impl ParallelConfig

Source

pub fn new(sample_rate: i32, channels: usize, application: Application) -> Self

A configuration with the defaults described on this type.

The three arguments are the ones OpusEncoder::new fixes for an encoder’s life; the remaining fields are ordinary and can be set on the returned value before it is handed to encode_parallel.

Source

pub fn warmup_frames(&self, frame_size: usize) -> usize

Warm-up expressed in frames of frame_size samples per channel, rounded up so a frame duration that does not divide warmup_ms still covers it.

Source

pub fn plan(&self, total_frames: usize, frame_size: usize) -> ParallelPlan

How encode_parallel will divide total_frames, without encoding anything.

Worth asking before a large job: the worker count is capped by the redundancy ceiling, so a short clip or a long warm-up can leave far fewer threads in use than were requested, or fall back to serial encoding altogether.

Trait Implementations§

Source§

impl Clone for ParallelConfig

Source§

fn clone(&self) -> ParallelConfig

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 Copy for ParallelConfig

Source§

impl Debug for ParallelConfig

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 = !

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.