#[repr(u32)]pub enum Codec {
Jpeg = 0,
H264 = 1,
Vp8 = 2,
Vp9 = 3,
Av1 = 4,
H265 = 5,
}Expand description
The picture codec of a capture session, and of a virtual-camera uplink. Jpeg is the
striped still-image mode; the rest are video codecs, which stream as whole frames except
H.264, whose software path may also stripe. The discriminants are the codec ids the
Python API speaks (VirtualCamera.CODEC_*) and the video wire ids.
Variants§
Implementations§
Source§impl Codec
impl Codec
Sourcepub const fn id(self) -> u32
pub const fn id(self) -> u32
The codec’s numeric id, as the Python API and the video wire carry it.
Sourcepub fn parse(name: &str) -> Option<Codec>
pub fn parse(name: &str) -> Option<Codec>
The codec a settings name selects; None for a name no backend serves.
Sourcepub fn is_video(self) -> bool
pub fn is_video(self) -> bool
Whether the session is a video stream rather than striped stills.
Sourcepub fn stripes(self) -> bool
pub fn stripes(self) -> bool
Whether a frame of this codec may be cut into independently encoded stripes: the still-image mode always is, H.264 is on its software path, and every other codec streams whole frames.
Sourcepub fn wire_id(self) -> u8
pub fn wire_id(self) -> u8
The codec’s identity in the high nibble of the video type byte: its id.
Sourcepub fn from_wire_id(id: u8) -> Option<Codec>
pub fn from_wire_id(id: u8) -> Option<Codec>
The video codec a wire id names.
Sourcepub fn is_inter_coded(self) -> bool
pub fn is_inter_coded(self) -> bool
Whether frames depend on earlier ones, so a dropped frame forces a wait for a key frame.
Sourcepub fn fullcolor(self) -> bool
pub fn fullcolor(self) -> bool
Whether the codec can carry 4:4:4 chroma at all (H.264 High 4:4:4, H.265 RExt, VP9 profile 1); whether a given backend does is negotiated by that backend.
Sourcepub fn high_bit_depth(self) -> bool
pub fn high_bit_depth(self) -> bool
Whether the codec has a 10-bit profile a session here can ask for (H.265 Main 10 and its 4:4:4, VP9 profiles 2 and 3, AV1); whether a given backend does is negotiated by that backend.
Sourcepub fn keyframes_self_contained(self) -> bool
pub fn keyframes_self_contained(self) -> bool
Whether a forced key frame of this codec repeats the stream’s parameter sets, so a joining decoder can start there. Every backend is configured to, so the answer is the same for all of them.
Sourcepub fn quantizer_max(self) -> u32
pub fn quantizer_max(self) -> u32
The top of the codec’s quantizer domain: H.26x QP, the VP8 quantizer index, or
the VP9 / AV1 base_q_idx. The value a backend programs never exceeds it.
Sourcepub fn quantizer(self, crf: i32) -> u32
pub fn quantizer(self, crf: i32) -> u32
The quantizer, in this codec’s own domain, that a session quality index (video_crf,
on the H.26x QP scale) selects.
H.26x takes the index as its QP. The VP8, VP9, and AV1 quantizer indices come from
tables measured on the software encoders against libx264 (ultrafast, zerolatency, four
threads) at the same index, every encoder at the settings pixelflux gives it — VP8 at
libvpx speed 16, VP9 at speed 8 with screen tuning, AV1 at SVT-AV1 preset 11 in its
real-time mode — interpolated in between. An AV1 point is the quantizer whose SSIM
matches on a scrolling text desktop. A VP8 or VP9 point is the one whose PSNR matches,
the finest of a text desktop held still, the same scrolled, and a gradient wallpaper,
which agree within two libvpx levels for VP9; VP8 reaches 43 dB at its finest, so
below index 25 it has nothing left to match. Each table ends at the codec’s maximum
quantizer at index 51, since past its last matched point the encoder cannot degrade
as far as x264 does and there is nothing left to match. A hardware session reads
hardware_quantizer. An AV1 index of zero is lossless, so its floor is one; the
SVT-AV1 session floors its level at ten, below which its real-time mode miscodes.
Sourcepub fn quantizer_bound(self, qp: i32) -> u32
pub fn quantizer_bound(self, qp: i32) -> u32
The quantizer a CBR QP clamp (video_min_qp / video_max_qp, on the H.26x scale)
becomes in this codec’s domain; zero stays zero, meaning “the encoder’s default”.
Sourcepub fn hardware_quantizer(self, hw: Hardware, crf: i32) -> u32
pub fn hardware_quantizer(self, hw: Hardware, crf: i32) -> u32
quantizer for a hardware session, matched to libx264 the same way. H.264 is measured on
NVENC (Pascal and Ada) and on AMD’s VA-API, which agree within a step, each coding a
quantizer about three finer than the index to match x264; AMD’s VA-API H.265 follows
the same curve within a step, where NVENC’s H.265 is within two steps of the index from
22 up and keeps it. Intel’s VA-API H.265 matches x264 on a still frame at that curve but
refines a moving picture well past it for fewer bytes (Arc and Alder Lake-N), so it reads
one two steps coarser from index 25 up; below 20 its still frames of text fall 3 to 4 dB
short of x264’s at that curve, so there it reads one finer. AV1 has a curve per backend:
NVENC’s is measured on Ada, and VA-API’s on Intel (Arc) with the in-loop filters its
constant-quantizer frames carry, on a
text desktop and a gradient wallpaper, taking the finer match of the two. VA-API’s VP9
is matched the same way on Intel (Arc), finer than libvpx at the same index on text.
VP8 keeps the software table. NVENC refuses an AV1 index of zero, so the floor stays one.
Sourcepub fn hardware_quantizer_bound(self, hw: Hardware, qp: i32) -> u32
pub fn hardware_quantizer_bound(self, hw: Hardware, qp: i32) -> u32
quantizer_bound for a hardware session.
Sourcepub fn quality_index(self, q: u32) -> u32
pub fn quality_index(self, q: u32) -> u32
The session quality index whose quantizer (quantizer) is nearest q, a quantizer of
this codec’s domain: what a rate-controlled frame’s quantizer amounts to on the H.26x
scale the quality settings use.
Sourcepub fn hardware_quality_index(self, hw: Hardware, q: u32) -> u32
pub fn hardware_quality_index(self, hw: Hardware, q: u32) -> u32
quality_index for a hardware session.
Trait Implementations§
impl Copy for Codec
impl Eq for Codec
impl StructuralPartialEq for Codec
Auto Trait Implementations§
impl Freeze for Codec
impl RefUnwindSafe for Codec
impl Send for Codec
impl Sync for Codec
impl Unpin for Codec
impl UnsafeUnpin for Codec
impl UnwindSafe for Codec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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