EncoderConfig

Struct EncoderConfig 

Source
pub struct EncoderConfig<T: YUVPixelType> {
Show 31 fields pub codec: CodecId, pub profile: EncoderProfile, pub flags: EncoderFlags, pub width: u32, pub height: u32, pub timebase: Timebase, pub rate_control: RateControl, pub threads: u32, pub output_bit_depth: vpx_bit_depth, pub error_resilient: ErrorResilient, pub pass: vpx_enc_pass, pub lag_in_frames: u32, pub rc_dropframe_thresh: u32, pub rc_resize_allowed: Option<SpatialResizeParams>, pub rc_twopass_stats_in: Option<FixedBuffer>, pub rc_firstpass_mb_stats_in: Option<FixedBuffer>, pub rc_undershoot_pct: u32, pub rc_overshoot_pct: u32, pub rc_buf_sz: Duration, pub rc_buf_initial_sz: Duration, pub rc_buf_optimal_sz: Duration, pub rc_2pass_vbr_bias_pct: u32, pub rc_2pass_vbr_minsection_pct: u32, pub rc_2pass_vbr_maxsection_pct: u32, pub rc_2pass_vbr_corpus_complexity: u32, pub kf_mode: KeyFrameMode, pub spatial_layers: Vec<SpatialLayer>, pub temporal_layers: Vec<TemporalLayer>, pub temporal_periodicity: Vec<u32>, pub layer_target_bitrate: [u32; 12], pub temporal_layering_mode: Option<vp9e_temporal_layering_mode>, /* private fields */
}
Expand description

Specifies an initial configuration of the encoder. Fields prefixed with rc_ denote rate-control parameters.

Fields§

§codec: CodecId

The codec to utilize when producing a bitstream.

§profile: EncoderProfile

Bitstream profile to use.

§flags: EncoderFlags

Flags to configure on the encoder.

§width: u32

The display width of the video stream in pixels.

§height: u32

The display height of the video stream in pixels.

§timebase: Timebase

The timebase for the presentation timestamps passed to the encoder.

§rate_control: RateControl

The type of rate control to employ.

§threads: u32

Number of threads to employ in encoding.

§output_bit_depth: vpx_bit_depth

Bit-depth of the codec.

This value identifies the bit_depth of the codec and the generated output bitstream. It doesn’t imply a specific input data bit depth (which is defined by the associated generic type of this struct). The default is VPX_BITS_8.

§error_resilient: ErrorResilient

Bitstream error resiliency flags.

§pass: vpx_enc_pass

Multi-pass encoding support:

  • VPX_RC_ONE_PASS: Single-pass mode (default).
  • VPX_RC_FIRST_PASS: First pass of multi-pass mode.
  • VPX_RC_LAST_PASS: Final pass of multi-pass mode.
§lag_in_frames: u32

Allow lagged encoding

If set, this value allows the encoder to consume a number of input frames before producing output frames. This allows the encoder to base decisions for the current frame on future frames. This does increase the latency of the encoding pipeline, so it is not appropriate in all situations (ex: realtime encoding).

Note that this is a maximum value – the encoder may produce frames sooner than the given limit. Set this value to 0 to disable this feature (this is the default).

§rc_dropframe_thresh: u32

Temporal resampling configuration, if supported by the codec.

Temporal resampling allows the codec to “drop” frames as a strategy to meet its target data rate. This can cause temporal discontinuities in the encoded video, which may appear as stuttering during playback. This trade-off is often acceptable, but for many applications is not. It can be disabled in these cases.

This threshold is described as a percentage of the target data buffer. When the data buffer falls below this percentage of fullness, a dropped frame is indicated. Set the threshold to zero (0) to disable this feature.

§rc_resize_allowed: Option<SpatialResizeParams>

Enable/disable spatial resampling, if supported by the codec.

Spatial resampling allows the codec to compress a lower resolution version of the frame, which is then upscaled by the encoder to the correct presentation resolution. This increases visual quality at low data rates, at the expense of CPU time on the encoder/decoder.

If set to None, spatial resizing is disallowed.

§rc_twopass_stats_in: Option<FixedBuffer>

Two-pass stats buffer.

A buffer containing all of the stats packets produced in the first pass, concatenated.

If set to None (the default), no two-pass stats are passed in.

§rc_firstpass_mb_stats_in: Option<FixedBuffer>

First pass mb stats buffer.

A buffer containing all of the first pass mb stats packets produced in the first pass, concatenated.

If set to None (the default), no first-pass MB stats are passed in.

§rc_undershoot_pct: u32

Rate control adaptation undershoot control

VP8: Expressed as a percentage of the target bitrate, controls the maximum allowed adaptation speed of the codec. This factor controls the maximum amount of bits that can be subtracted from the target bitrate in order to compensate for prior overshoot.

VP9: Expressed as a percentage of the target bitrate, a threshold undershoot level (current rate vs target) beyond which more aggressive corrective measures are taken.

Valid values in the range VP8:0-100 VP9: 0-100.

§rc_overshoot_pct: u32

Rate control adaptation overshoot control

VP8: Expressed as a percentage of the target bitrate, controls the maximum allowed adaptation speed of the codec. This factor controls the maximum amount of bits that can be added to the target bitrate in order to compensate for prior undershoot.

VP9: Expressed as a percentage of the target bitrate, a threshold overshoot level (current rate vs target) beyond which more aggressive corrective measures are taken.

Valid values in the range VP8:0-100 VP9: 0-100.

§rc_buf_sz: Duration

Decoder Buffer Size

This value indicates the amount of data that may be buffered by the decoding application. Note that this value is expressed in units of time.

§rc_buf_initial_sz: Duration

Decoder Buffer Initial Size

This value indicates the amount of data that will be buffered by the decoding application prior to beginning playback. This value is expressed in units of time

§rc_buf_optimal_sz: Duration

Decoder Buffer Optimal Size

This value indicates the amount of data that the encoder should try to maintain in the decoder’s buffer. This value is expressed in units of time.

§rc_2pass_vbr_bias_pct: u32

Two-pass mode CBR/VBR bias

Bias, expressed on a scale of 0 to 100, for determining target size for the current frame. The value 0 indicates the optimal CBR mode value should be used. The value 100 indicates the optimal VBR mode value should be used. Values in between indicate which way the encoder should “lean.”

§rc_2pass_vbr_minsection_pct: u32

Two-pass mode per-GOP minimum bitrate

This value, expressed as a percentage of the target bitrate, indicates the minimum bitrate to be used for a single GOP (aka “section”)

§rc_2pass_vbr_maxsection_pct: u32

Two-pass mode per-GOP maximum bitrate

This value, expressed as a percentage of the target bitrate, indicates the maximum bitrate to be used for a single GOP (aka “section”)

§rc_2pass_vbr_corpus_complexity: u32

Two-pass corpus vbr mode complexity control

Used only in VP9: A value representing the corpus midpoint complexity for corpus vbr mode. This value defaults to 0 which disables corpus vbr mode in favour of normal vbr mode.

§kf_mode: KeyFrameMode

Keyframe placement mode

This value indicates whether the encoder should place keyframes at a fixed interval, or determine the optimal placement automatically (as governed by the min_dist and max_dist parameters).

§spatial_layers: Vec<SpatialLayer>

Configures the spatial coding layers to be used by the encoder.

§temporal_layers: Vec<TemporalLayer>

Temporal coding layers.

This vector MUST NOT contain more than vpx_sys::VPX_TS_MAX_LAYERS temporal layers.

§temporal_periodicity: Vec<u32>

Template defining the membership of frames to temporal layers.

This vector defines the membership of frames to temporal coding layers. For a 2-layer encoding that assigns even numbered frames to one temporal layer (0) and odd numbered frames to a second temporal layer (1), then cfg.temporal_periodicity = vec![0,1,0,1,0,1,0,1].

This vector MUST NOT contain more than vpx_sys::VPX_TS_MAX_PERIODICITY items.

§layer_target_bitrate: [u32; 12]

Target bitrate for each spatial/temporal layer.

These values specify the target coding bitrate to be used for each spatial/temporal layer (in kbps).

§temporal_layering_mode: Option<vp9e_temporal_layering_mode>

Temporal layering mode indicating which temporal layering scheme to use.

This enum will only be populated when using VP9, since VP8 doesn't support defining the temporal layering mode.

If this is set to None, the codec-default layering mode is used.

Implementations§

Source§

impl<T: YUVPixelType> EncoderConfig<T>

Source

pub fn new( codec: CodecId, width: u32, height: u32, timebase: Timebase, rate_control: RateControl, ) -> Result<Self>

Constructs a new EncoderConfig, with most values set to their defaults.

Note: all bitrates are in kbit/s.

Trait Implementations§

Source§

impl<T: Clone + YUVPixelType> Clone for EncoderConfig<T>

Source§

fn clone(&self) -> EncoderConfig<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + YUVPixelType> Debug for EncoderConfig<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Hash + YUVPixelType> Hash for EncoderConfig<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq + YUVPixelType> PartialEq for EncoderConfig<T>

Source§

fn eq(&self, other: &EncoderConfig<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq + YUVPixelType> Eq for EncoderConfig<T>

Source§

impl<T: YUVPixelType> StructuralPartialEq for EncoderConfig<T>

Auto Trait Implementations§

§

impl<T> Freeze for EncoderConfig<T>

§

impl<T> RefUnwindSafe for EncoderConfig<T>
where T: RefUnwindSafe,

§

impl<T> Send for EncoderConfig<T>
where T: Send,

§

impl<T> Sync for EncoderConfig<T>
where T: Sync,

§

impl<T> Unpin for EncoderConfig<T>
where T: Unpin,

§

impl<T> UnwindSafe for EncoderConfig<T>
where T: UnwindSafe,

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.