pub struct ChromaKeyParams {
pub key_r: f32,
pub key_g: f32,
pub key_b: f32,
pub similarity: f32,
pub blend: f32,
pub spill: f32,
pub bg_r: f32,
pub bg_g: f32,
pub bg_b: f32,
/* private fields */
}Expand description
Parameters for chroma_key. Default keys a pure-green screen and
composites the foreground over black.
similarity and blend use FFmpeg chromakey semantics on FFmpeg’s
scale (the same RGB→CbCr coefficients and √(d²/2) normalization, so
1.0 spans the full CbCr plane diagonal): distance ≤ similarity is
background, the next blend of distance ramps linearly to foreground,
and blend ≈ 0 degenerates to a hard threshold. One structural
difference: FFmpeg compares the source’s RAW chroma plane codes
against a BT.601-converted key, while this shader decodes the pixel to
RGB first and projects both sides through the one BT.601 conversion.
The two agree (within quantization) only on full-range BT.601 input;
on any other range/matrix combination FFmpeg’s raw-code comparison
carries a small built-in bias this implementation does not reproduce —
treat ported ffmpeg -vf chromakey=... values as a close starting
point, not bit-identical.
Fields§
§key_r: f32Key color red, 0.0..=1.0.
key_g: f32Key color green, 0.0..=1.0.
key_b: f32Key color blue, 0.0..=1.0.
similarity: f32Chroma distance keyed as background, 0.00001..=1.0. Larger keys
more; neutral gray sits ≈ 0.38 from pure green on this scale.
blend: f32Width of the soft edge past similarity, 0.0..=1.0; 0.0 is a
hard binary matte.
spill: f32Spill suppression strength, 0.0..=1.0: how strongly the key’s
dominant channel is clamped toward the mean of the other two in
surviving foreground (1.0 = FFmpeg despill defaults).
bg_r: f32Background red, 0.0..=1.0.
bg_g: f32Background green, 0.0..=1.0.
bg_b: f32Background blue, 0.0..=1.0.
Implementations§
Source§impl ChromaKeyParams
impl ChromaKeyParams
Sourcepub fn green_screen() -> Self
pub fn green_screen() -> Self
Keys a pure-green screen (#00FF00) over black.
Sourcepub fn blue_screen() -> Self
pub fn blue_screen() -> Self
Keys a pure-blue screen (#0000FF) over black.
Sourcepub fn with_background(self, r: f32, g: f32, b: f32) -> Self
pub fn with_background(self, r: f32, g: f32, b: f32) -> Self
Replaces the background color the foreground is composited over.
Trait Implementations§
Source§impl Clone for ChromaKeyParams
impl Clone for ChromaKeyParams
Source§fn clone(&self) -> ChromaKeyParams
fn clone(&self) -> ChromaKeyParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ChromaKeyParams
Source§impl Debug for ChromaKeyParams
impl Debug for ChromaKeyParams
Source§impl Default for ChromaKeyParams
impl Default for ChromaKeyParams
Source§impl PartialEq for ChromaKeyParams
impl PartialEq for ChromaKeyParams
impl Pod for ChromaKeyParams
impl StructuralPartialEq for ChromaKeyParams
Auto Trait Implementations§
impl Freeze for ChromaKeyParams
impl RefUnwindSafe for ChromaKeyParams
impl Send for ChromaKeyParams
impl Sync for ChromaKeyParams
impl Unpin for ChromaKeyParams
impl UnsafeUnpin for ChromaKeyParams
impl UnwindSafe for ChromaKeyParams
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.