#[non_exhaustive]pub struct CodecCapabilities {Show 18 fields
pub decode: bool,
pub encode: bool,
pub media_type: MediaType,
pub intra_only: bool,
pub lossy: bool,
pub lossless: bool,
pub hardware_accelerated: bool,
pub implementation: String,
pub max_width: Option<u32>,
pub max_height: Option<u32>,
pub max_bitrate: Option<u64>,
pub max_sample_rate: Option<u32>,
pub max_channels: Option<u16>,
pub priority: i32,
pub accepted_pixel_formats: Vec<PixelFormat>,
pub accepted_sample_rates: Vec<u32>,
pub accepted_sample_formats: Vec<SampleFormat>,
pub embedded_blob_kinds: Vec<BlobKind>,
}Expand description
What an implementation can do plus how it ranks vs alternatives.
#[non_exhaustive]: build it with audio,
video or subtitle and the
with_* builders, then read the public fields. Fields are added
over time (0.1.38 added the accepted sample rates / formats) and a
struct literal in a downstream crate would stop compiling each time.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.decode: boolDecoding supported by this implementation.
encode: boolEncoding supported by this implementation.
media_type: MediaTypeMedia type this implementation handles (audio, video, …).
intra_only: boolEvery coded unit is independently decodable (no inter-frame prediction).
lossy: boolSupports lossy compression.
lossless: boolSupports lossless compression. lossy and lossless may both
be set for codecs that offer both modes.
hardware_accelerated: boolHardware-accelerated implementation (VAAPI/NVENC/QSV/VideoToolbox/…).
implementation: StringShort identifier for this implementation, e.g. “flac_sw”, “h264_qsv”.
max_width: Option<u32>Restrictions — None means “no constraint”.
max_height: Option<u32>Maximum supported frame height in pixels; None = unconstrained.
max_bitrate: Option<u64>Maximum supported bit rate in bits per second; None =
unconstrained.
max_sample_rate: Option<u32>Maximum supported audio sample rate in Hz; None = unconstrained.
max_channels: Option<u16>Maximum supported audio channel count; None = unconstrained.
priority: i32Lower numbers are preferred. HW impls should be ~10, SW impls ~100.
accepted_pixel_formats: Vec<PixelFormat>Pixel formats this implementation accepts (video only). An empty
Vec means “any format” — resolution won’t filter on it. When
populated, the registry can skip impls whose accepted set does not
include the format requested by the caller.
accepted_sample_rates: Vec<u32>Audio sample rates (Hz) this implementation accepts as encoder
input (audio only). An empty Vec means “any rate”. When
populated, a pipeline feeding the encoder is expected to resample
a stream whose rate is not listed to one of these rates (the
listed order is not a preference — consumers pick the closest
rate that does not discard bandwidth).
accepted_sample_formats: Vec<SampleFormat>Audio sample formats this implementation accepts as encoder input
(audio only). An empty Vec means “any format”. When populated,
the first entry is the preferred conversion target for a stream
whose format is not listed.
embedded_blob_kinds: Vec<BlobKind>Metadata blob kinds this implementation’s encoder embeds in
its output: the BlobKinds it reads from the input stream’s
CodecParameters::blobs and
from frame records and writes into the coded output (an ICC
profile into the codestream’s colour box, an Exif block into
its application segment, a format’s own custom kind into its
native chunk). Empty — the default — means “nothing declared”:
a caller cannot tell whether a blob it hands over survives, and
a gateway reports that as pass-through. When populated it is a
promise in both directions: every listed kind is embedded when
present on the input, every unlisted kind is dropped. Lets a
caller answer “will the ICC profile survive this save?” before
encoding a pixel. Attached with
with_embedded_blob_kind /
with_embedded_blob_kinds,
queried with embeds_blob. Decoder-only
registrations leave it empty.
Implementations§
Source§impl CodecCapabilities
impl CodecCapabilities
Sourcepub fn audio(implementation: impl Into<String>) -> Self
pub fn audio(implementation: impl Into<String>) -> Self
Construct a software audio decoder/encoder capability set with sensible defaults — adjust fields after creation.
Sourcepub fn video(implementation: impl Into<String>) -> Self
pub fn video(implementation: impl Into<String>) -> Self
Construct a software video decoder/encoder capability set with sensible defaults — adjust fields after creation.
Sourcepub fn subtitle(implementation: impl Into<String>) -> Self
pub fn subtitle(implementation: impl Into<String>) -> Self
Construct a software subtitle decoder/encoder capability set with
sensible defaults (intra-only, lossless) — adjust with the
with_* builders.
Sourcepub fn with_media_type(self, media_type: MediaType) -> Self
pub fn with_media_type(self, media_type: MediaType) -> Self
Override the media type (for capability sets built from the closest constructor, e.g. data or attachment streams).
Sourcepub fn flag_string(&self) -> String
pub fn flag_string(&self) -> String
6-character capability flag string (see the module docs for the
column layout). Useful for oxideav list-style
output.
Sourcepub fn with_decode(self) -> Self
pub fn with_decode(self) -> Self
Mark this implementation as supporting decode.
Sourcepub fn with_encode(self) -> Self
pub fn with_encode(self) -> Self
Mark this implementation as supporting encode.
Sourcepub fn with_intra_only(self, v: bool) -> Self
pub fn with_intra_only(self, v: bool) -> Self
Set the intra-frame-only flag.
Sourcepub fn with_lossy(self, v: bool) -> Self
pub fn with_lossy(self, v: bool) -> Self
Set the lossy-compression flag.
Sourcepub fn with_lossless(self, v: bool) -> Self
pub fn with_lossless(self, v: bool) -> Self
Set the lossless-compression flag.
Sourcepub fn with_hardware(self, v: bool) -> Self
pub fn with_hardware(self, v: bool) -> Self
Set the hardware-accelerated flag.
Sourcepub fn with_priority(self, p: i32) -> Self
pub fn with_priority(self, p: i32) -> Self
Set the registry ranking priority (lower is preferred; HW ~10, SW ~100).
Sourcepub fn with_max_size(self, w: u32, h: u32) -> Self
pub fn with_max_size(self, w: u32, h: u32) -> Self
Constrain the maximum frame size to w × h pixels.
Sourcepub fn with_max_bitrate(self, br: u64) -> Self
pub fn with_max_bitrate(self, br: u64) -> Self
Constrain the maximum bit rate (bits per second).
Sourcepub fn with_max_sample_rate(self, sr: u32) -> Self
pub fn with_max_sample_rate(self, sr: u32) -> Self
Constrain the maximum audio sample rate (Hz).
Sourcepub fn with_max_channels(self, ch: u16) -> Self
pub fn with_max_channels(self, ch: u16) -> Self
Constrain the maximum audio channel count.
Sourcepub fn with_pixel_format(self, fmt: PixelFormat) -> Self
pub fn with_pixel_format(self, fmt: PixelFormat) -> Self
Add one accepted pixel format. Appends — call multiple times to list several.
Sourcepub fn with_pixel_formats(self, fmts: Vec<PixelFormat>) -> Self
pub fn with_pixel_formats(self, fmts: Vec<PixelFormat>) -> Self
Replace the accepted pixel-format set wholesale.
Sourcepub fn with_sample_rates(self, rates: Vec<u32>) -> Self
pub fn with_sample_rates(self, rates: Vec<u32>) -> Self
Replace the accepted encoder-input sample-rate set wholesale
(see Self::accepted_sample_rates).
Sourcepub fn with_sample_formats(self, fmts: Vec<SampleFormat>) -> Self
pub fn with_sample_formats(self, fmts: Vec<SampleFormat>) -> Self
Replace the accepted encoder-input sample-format set wholesale
(see Self::accepted_sample_formats; the first entry is the
preferred conversion target).
Sourcepub fn with_embedded_blob_kind(self, kind: impl Into<BlobKind>) -> Self
pub fn with_embedded_blob_kind(self, kind: impl Into<BlobKind>) -> Self
Add one metadata blob kind the encoder embeds (see
Self::embedded_blob_kinds). Appends — call several times to
list several; a kind already listed is not added twice.
Sourcepub fn with_embedded_blob_kinds(self, kinds: Vec<BlobKind>) -> Self
pub fn with_embedded_blob_kinds(self, kinds: Vec<BlobKind>) -> Self
Replace the embedded blob-kind set wholesale (see
Self::embedded_blob_kinds). Duplicates are removed, first
occurrence kept.
Sourcepub fn embeds_blob(&self, kind: &BlobKind) -> bool
pub fn embeds_blob(&self, kind: &BlobKind) -> bool
true when the encoder declares that it embeds blobs of kind
(see Self::embedded_blob_kinds). false both for an
unlisted kind and for an encoder that declares nothing — use
declares_embedded_blobs to
tell the two apart.
Sourcepub fn declares_embedded_blobs(&self) -> bool
pub fn declares_embedded_blobs(&self) -> bool
true when the encoder declares its embedded blob kinds at
all, i.e. Self::embedded_blob_kinds is non-empty; false
means every answer from embeds_blob is
“unknown”, not “no”.
Sourcepub fn pick_sample_rate(&self, rate: u32) -> u32
pub fn pick_sample_rate(&self, rate: u32) -> u32
Pick the encoder-input sample rate for a stream at rate Hz:
rate itself when it is accepted (or every rate is), otherwise
the smallest accepted rate above it (no bandwidth is lost), and
failing that the largest accepted rate.
Source§impl CodecCapabilities
impl CodecCapabilities
Sourcepub fn fits_params(&self, p: &CodecParameters, for_encode: bool) -> bool
pub fn fits_params(&self, p: &CodecParameters, for_encode: bool) -> bool
Whether this implementation’s max-* restrictions are compatible
with the requested codec parameters. for_encode is reserved
for restrictions that apply asymmetrically. Used by the
registry’s make_decoder / make_encoder walker and by
out-of-tree selection layers (e.g. oxideav-pipeline’s
CodecPreferences filter).