pub mod scalar;
#[cfg(target_arch = "aarch64")]
pub mod aarch64;
#[cfg(target_arch = "x86_64")]
pub mod x86_64;
pub struct SimdRoutines {
pub idct_islow: fn(coeffs: &[i16; 64], quant: &[u16; 64], output: &mut [u8; 64]),
#[allow(clippy::type_complexity)]
pub ycbcr_to_rgb_row: fn(y: &[u8], cb: &[u8], cr: &[u8], rgb: &mut [u8], width: usize),
pub fancy_upsample_h2v1: fn(input: &[u8], in_width: usize, output: &mut [u8]),
}
pub struct QuantDivisors {
pub divisors: [u16; 64],
pub reciprocals: [u16; 64],
pub divisors_zigzag: [u16; 64],
pub reciprocals_zigzag: [u16; 64],
}
pub struct EncoderSimdRoutines {
#[allow(clippy::type_complexity)]
pub rgb_to_ycbcr_row: fn(rgb: &[u8], y: &mut [u8], cb: &mut [u8], cr: &mut [u8], width: usize),
pub fdct_quantize: fn(input: &mut [i16; 64], quant: &QuantDivisors, output: &mut [i16; 64]),
}
pub fn detect() -> SimdRoutines {
if std::env::var("JSIMD_FORCENONE").ok().as_deref() == Some("1") {
return scalar::routines();
}
#[cfg(all(target_arch = "aarch64", feature = "simd"))]
{
return aarch64::routines();
}
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
{
return x86_64::routines();
}
#[allow(unreachable_code)]
scalar::routines()
}
pub fn detect_encoder() -> EncoderSimdRoutines {
if std::env::var("JSIMD_FORCENONE").ok().as_deref() == Some("1") {
return scalar::encoder_routines();
}
#[cfg(all(target_arch = "aarch64", feature = "simd"))]
{
return aarch64::encoder_routines();
}
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
{
return x86_64::encoder_routines();
}
#[allow(unreachable_code)]
scalar::encoder_routines()
}