use yuv::{
bgra_to_ycgco444, rgb_to_ycgco444, rgba_to_ycgco444, ycgco444_alpha_to_bgra,
ycgco444_alpha_to_rgba, ycgco444_to_rgb, YuvError, YuvPlanarImage, YuvPlanarImageWithAlpha,
YuvRange,
};
use crate::clahe_yuv_impl::clahe_yuv_impl;
use crate::hist_support::AheImplementation;
use crate::ClaheGridSize;
pub(crate) fn ycgco444_skip_alpha_to_rgb(
image_with_alpha: &YuvPlanarImageWithAlpha<u8>,
rgba: &mut [u8],
rgba_stride: u32,
range: YuvRange,
) -> Result<(), YuvError> {
let image = YuvPlanarImage {
y_plane: image_with_alpha.y_plane,
y_stride: image_with_alpha.y_stride,
u_plane: image_with_alpha.u_plane,
u_stride: image_with_alpha.u_stride,
v_plane: image_with_alpha.v_plane,
v_stride: image_with_alpha.v_stride,
width: image_with_alpha.width,
height: image_with_alpha.height,
};
ycgco444_to_rgb(&image, rgba, rgba_stride, range)
}
pub fn clahe_yuv_rgb(
src: &[u8],
src_stride: u32,
dst: &mut [u8],
dst_stride: u32,
width: u32,
height: u32,
threshold: f32,
grid_size: ClaheGridSize,
) {
clahe_yuv_impl::<3, { AheImplementation::Clahe as u8 }>(
src,
src_stride,
dst,
dst_stride,
width,
height,
threshold,
grid_size,
rgb_to_ycgco444,
ycgco444_skip_alpha_to_rgb,
);
}
pub fn ahe_yuv_rgb(
src: &[u8],
src_stride: u32,
dst: &mut [u8],
dst_stride: u32,
width: u32,
height: u32,
grid_size: ClaheGridSize,
) {
clahe_yuv_impl::<3, { AheImplementation::Ahe as u8 }>(
src,
src_stride,
dst,
dst_stride,
width,
height,
0f32,
grid_size,
rgb_to_ycgco444,
ycgco444_skip_alpha_to_rgb,
);
}
pub fn clahe_yuv_rgba(
src: &[u8],
src_stride: u32,
dst: &mut [u8],
dst_stride: u32,
width: u32,
height: u32,
threshold: f32,
grid_size: ClaheGridSize,
) {
clahe_yuv_impl::<4, { AheImplementation::Clahe as u8 }>(
src,
src_stride,
dst,
dst_stride,
width,
height,
threshold,
grid_size,
rgba_to_ycgco444,
ycgco444_alpha_to_rgba,
);
}
pub fn ahe_yuv_rgba(
src: &[u8],
src_stride: u32,
dst: &mut [u8],
dst_stride: u32,
width: u32,
height: u32,
grid_size: ClaheGridSize,
) {
clahe_yuv_impl::<4, { AheImplementation::Ahe as u8 }>(
src,
src_stride,
dst,
dst_stride,
width,
height,
0f32,
grid_size,
rgba_to_ycgco444,
ycgco444_alpha_to_rgba,
);
}
pub fn clahe_yuv_bgra(
src: &[u8],
src_stride: u32,
dst: &mut [u8],
dst_stride: u32,
width: u32,
height: u32,
threshold: f32,
grid_size: ClaheGridSize,
) {
clahe_yuv_impl::<4, { AheImplementation::Clahe as u8 }>(
src,
src_stride,
dst,
dst_stride,
width,
height,
threshold,
grid_size,
bgra_to_ycgco444,
ycgco444_alpha_to_bgra,
);
}
pub fn ahe_yuv_bgra(
src: &[u8],
src_stride: u32,
dst: &mut [u8],
dst_stride: u32,
width: u32,
height: u32,
grid_size: ClaheGridSize,
) {
clahe_yuv_impl::<4, { AheImplementation::Ahe as u8 }>(
src,
src_stride,
dst,
dst_stride,
width,
height,
0f32,
grid_size,
bgra_to_ycgco444,
ycgco444_alpha_to_bgra,
);
}