pub mod scalar;
#[cfg(target_arch = "aarch64")]
pub mod neon;
#[cfg(target_arch = "x86_64")]
pub mod sse2;
#[cfg(target_arch = "x86_64")]
pub mod ssse3;
use edgefirst_tensor::PixelFormat;
pub type ColorConvertFn =
fn(y_row: &[u8], cb_row: &[u8], cr_row: &[u8], output: &mut [u8], width: usize);
pub type GreyCopyFn = fn(y_row: &[u8], output: &mut [u8], width: usize);
pub fn select_color_convert(format: PixelFormat) -> Option<ColorConvertFn> {
match format {
PixelFormat::Rgb => {
#[cfg(target_arch = "aarch64")]
if std::arch::is_aarch64_feature_detected!("neon") {
return Some(neon::ycbcr_to_rgb_neon);
}
#[cfg(target_arch = "x86_64")]
{
if is_x86_feature_detected!("ssse3") {
return Some(ssse3::ycbcr_to_rgb_ssse3);
}
if is_x86_feature_detected!("sse2") {
return Some(sse2::ycbcr_to_rgb_sse2);
}
}
Some(scalar::ycbcr_to_rgb)
}
PixelFormat::Rgba => {
#[cfg(target_arch = "aarch64")]
if std::arch::is_aarch64_feature_detected!("neon") {
return Some(neon::ycbcr_to_rgba_neon);
}
#[cfg(target_arch = "x86_64")]
if is_x86_feature_detected!("sse2") {
return Some(sse2::ycbcr_to_rgba_sse2);
}
Some(scalar::ycbcr_to_rgba)
}
PixelFormat::Bgra => {
#[cfg(target_arch = "aarch64")]
if std::arch::is_aarch64_feature_detected!("neon") {
return Some(neon::ycbcr_to_bgra_neon);
}
#[cfg(target_arch = "x86_64")]
if is_x86_feature_detected!("sse2") {
return Some(sse2::ycbcr_to_bgra_sse2);
}
Some(scalar::ycbcr_to_bgra)
}
_ => None,
}
}
pub fn select_grey_copy() -> GreyCopyFn {
scalar::grey_copy
}