pub struct ColorConvertKernel { /* private fields */ }Expand description
GPU-style color space conversion kernel (CPU simulation via Rayon).
All operations work on packed RGBA (4 bytes per pixel) buffers. The alpha channel is always passed through unchanged.
Implementations§
Source§impl ColorConvertKernel
impl ColorConvertKernel
Sourcepub fn new(standard: ColorStandard, range: RangeMode) -> Self
pub fn new(standard: ColorStandard, range: RangeMode) -> Self
Create a new kernel with the given color standard and range mode.
Sourcepub fn standard(&self) -> ColorStandard
pub fn standard(&self) -> ColorStandard
The color standard used by this kernel.
Sourcepub fn rgb_to_yuv(
src: &[u8],
dst: &mut [u8],
width: u32,
height: u32,
standard: ColorStandard,
range: RangeMode,
) -> Result<BatchConvertStats, ColorKernelError>
pub fn rgb_to_yuv( src: &[u8], dst: &mut [u8], width: u32, height: u32, standard: ColorStandard, range: RangeMode, ) -> Result<BatchConvertStats, ColorKernelError>
Convert packed RGBA → packed YUVA (in-place style: src/dst separate).
The A channel is passed through unchanged.
§Errors
Returns ColorKernelError if buffer lengths or dimensions are invalid.
Sourcepub fn matrix(&self) -> &ConversionMatrix
pub fn matrix(&self) -> &ConversionMatrix
The cached ConversionMatrix for this kernel’s standard and range.
Sourcepub fn convert_rgb_to_yuv(
&self,
src: &[u8],
dst: &mut [u8],
width: u32,
height: u32,
) -> Result<BatchConvertStats, ColorKernelError>
pub fn convert_rgb_to_yuv( &self, src: &[u8], dst: &mut [u8], width: u32, height: u32, ) -> Result<BatchConvertStats, ColorKernelError>
Instance method variant of rgb_to_yuv.
Uses the pre-built cached matrix rather than constructing a new one.
Sourcepub fn yuv_to_rgb(
src: &[u8],
dst: &mut [u8],
width: u32,
height: u32,
standard: ColorStandard,
range: RangeMode,
) -> Result<BatchConvertStats, ColorKernelError>
pub fn yuv_to_rgb( src: &[u8], dst: &mut [u8], width: u32, height: u32, standard: ColorStandard, range: RangeMode, ) -> Result<BatchConvertStats, ColorKernelError>
Convert packed YUVA → packed RGBA.
The A channel is passed through unchanged.
§Errors
Returns ColorKernelError if buffer lengths or dimensions are invalid.
Sourcepub fn convert_yuv_to_rgb(
&self,
src: &[u8],
dst: &mut [u8],
width: u32,
height: u32,
) -> Result<BatchConvertStats, ColorKernelError>
pub fn convert_yuv_to_rgb( &self, src: &[u8], dst: &mut [u8], width: u32, height: u32, ) -> Result<BatchConvertStats, ColorKernelError>
Instance method variant of yuv_to_rgb.
Uses the pre-built cached matrix rather than constructing a new one.
Sourcepub fn expand_limited_to_full(
src: &[u8],
dst: &mut [u8],
width: u32,
height: u32,
) -> Result<BatchConvertStats, ColorKernelError>
pub fn expand_limited_to_full( src: &[u8], dst: &mut [u8], width: u32, height: u32, ) -> Result<BatchConvertStats, ColorKernelError>
Expand a limited-range (studio swing) packed RGBA buffer to full range.
Y channel: [16, 235] → [0, 255].
Cb/Cr channels: [16, 240] → [0, 255].
§Errors
Returns ColorKernelError on dimension or size mismatch.
Sourcepub fn compress_full_to_limited(
src: &[u8],
dst: &mut [u8],
width: u32,
height: u32,
) -> Result<BatchConvertStats, ColorKernelError>
pub fn compress_full_to_limited( src: &[u8], dst: &mut [u8], width: u32, height: u32, ) -> Result<BatchConvertStats, ColorKernelError>
Compress a full-range packed YUVA buffer to limited (studio swing) range.
Y channel: [0, 255] → [16, 235].
Cb/Cr channels: [0, 255] → [16, 240].
§Errors
Returns ColorKernelError on dimension or size mismatch.
Sourcepub fn rgba_to_planar_yuv444(
src: &[u8],
width: u32,
height: u32,
standard: ColorStandard,
range: RangeMode,
) -> Result<(Vec<u8>, Vec<u8>, Vec<u8>), ColorKernelError>
pub fn rgba_to_planar_yuv444( src: &[u8], width: u32, height: u32, standard: ColorStandard, range: RangeMode, ) -> Result<(Vec<u8>, Vec<u8>, Vec<u8>), ColorKernelError>
Convert packed RGBA to planar YUV 4:4:4 (separate Y, Cb, Cr planes).
Returns (Y_plane, Cb_plane, Cr_plane), each width * height bytes.
§Errors
Returns ColorKernelError on dimension or size mismatch.
Sourcepub fn planar_yuv444_to_rgba(
y_plane: &[u8],
cb_plane: &[u8],
cr_plane: &[u8],
width: u32,
height: u32,
standard: ColorStandard,
range: RangeMode,
) -> Result<Vec<u8>, ColorKernelError>
pub fn planar_yuv444_to_rgba( y_plane: &[u8], cb_plane: &[u8], cr_plane: &[u8], width: u32, height: u32, standard: ColorStandard, range: RangeMode, ) -> Result<Vec<u8>, ColorKernelError>
Convert planar YUV 4:4:4 to packed RGBA.
Alpha channel is set to 255.
§Errors
Returns ColorKernelError if any plane size or dimensions are invalid.
Trait Implementations§
Source§impl Clone for ColorConvertKernel
impl Clone for ColorConvertKernel
Source§fn clone(&self) -> ColorConvertKernel
fn clone(&self) -> ColorConvertKernel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ColorConvertKernel
impl RefUnwindSafe for ColorConvertKernel
impl Send for ColorConvertKernel
impl Sync for ColorConvertKernel
impl Unpin for ColorConvertKernel
impl UnsafeUnpin for ColorConvertKernel
impl UnwindSafe for ColorConvertKernel
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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