pub struct YCbCrPlanarEncoder { /* private fields */ }Expand description
Encoder for planar f32 YCbCr input.
Use when you have pre-converted YCbCr from video decoders, etc. Skips RGB->YCbCr conversion entirely.
Only valid with ColorMode::YCbCr. XYB mode requires RGB input.
§YCbCr Value Range
Input values should be in the centered range:
- Y: 0.0 to 255.0 (luma)
- Cb, Cr: -128.0 to 127.0 (centered chroma)
This matches the output of standard RGB→YCbCr conversion with BT.601 coefficients.
§Streaming
Data can be pushed in any row count - the encoder buffers partial strips internally and flushes when a complete strip is accumulated.
Implementations§
Source§impl YCbCrPlanarEncoder
impl YCbCrPlanarEncoder
Sourcepub fn push(
&mut self,
planes: &YCbCrPlanes<'_>,
rows: usize,
stop: impl Stop,
) -> Result<()>
pub fn push( &mut self, planes: &YCbCrPlanes<'_>, rows: usize, stop: impl Stop, ) -> Result<()>
Push full-resolution planes. Encoder subsamples chroma as needed.
All three planes must be at full luma resolution (width × rows).
The encoder will perform chroma subsampling according to the configured
ChromaSubsampling mode.
Data can be pushed in any amount - the encoder buffers partial strips internally and flushes when a complete strip is accumulated.
§Arguments
planes: Y, Cb, Cr plane data with per-plane stridesrows: Number of luma rows to pushstop: Cancellation token (useUnstoppableif not needed)
§Value Range
- Y: 0.0 to 255.0
- Cb, Cr: -128.0 to 127.0
Sourcepub fn push_subsampled(
&mut self,
planes: &YCbCrPlanes<'_>,
y_rows: usize,
stop: impl Stop,
) -> Result<()>
pub fn push_subsampled( &mut self, planes: &YCbCrPlanes<'_>, y_rows: usize, stop: impl Stop, ) -> Result<()>
Push with pre-subsampled chroma.
Use this when your chroma planes are already at the target subsampled resolution. Y plane is still at full resolution.
Note: Unlike push(), this method does not buffer partial strips.
For best results, push complete strips (multiples of strip_height rows,
which is 8 for 4:4:4 or 16 for 4:2:0).
§Arguments
planes: Y at full resolution, Cb/Cr at subsampled resolutiony_rows: Number of luma rows to pushstop: Cancellation token
§Chroma Dimensions
The expected chroma dimensions depend on the subsampling mode:
- 4:4:4 (None): cb/cr at full width × full height
- 4:2:2 (HalfHorizontal): cb/cr at width/2 × full height
- 4:2:0 (Quarter): cb/cr at width/2 × height/2
Sourcepub fn rows_pushed(&self) -> u32
pub fn rows_pushed(&self) -> u32
Get number of rows pushed so far (including buffered rows).
Sourcepub fn rows_remaining(&self) -> u32
pub fn rows_remaining(&self) -> u32
Get number of rows remaining.