#[cfg(all(target_arch = "x86_64", feature = "simd"))]
mod avx2;
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
mod avx512;
mod rust;
#[cfg(test)]
mod tests;
use std::num::{NonZeroU8, NonZeroUsize};
use crate::util::Pixel;
#[inline]
pub fn refine_horizontal_bilinear<T: Pixel>(
dest: &mut [T],
src: &[T],
pitch: NonZeroUsize,
width: NonZeroUsize,
height: NonZeroUsize,
_bits_per_sample: NonZeroU8,
) {
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
if cpudetect::x86_64::is_znver5_compatible() {
unsafe {
avx512::refine_horizontal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
if cpudetect::x86_64::is_x86_64_v4_compatible() {
cfg_select! {
feature = "experimental" => {
unsafe {
avx512::refine_horizontal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
_ => {
if size_of::<T>() == 1 {
unsafe {
avx512::refine_horizontal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
}
}
}
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
if cpudetect::x86_64::is_x86_64_v3_compatible() {
cfg_select! {
feature = "experimental" => {
unsafe {
avx2::refine_horizontal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
_ => {
if size_of::<T>() == 1 {
unsafe {
avx2::refine_horizontal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
}
}
}
rust::refine_horizontal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
#[inline]
pub fn refine_vertical_bilinear<T: Pixel>(
dest: &mut [T],
src: &[T],
pitch: NonZeroUsize,
width: NonZeroUsize,
height: NonZeroUsize,
_bits_per_sample: NonZeroU8,
) {
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
if cpudetect::x86_64::is_x86_64_v4_compatible() {
cfg_select! {
feature = "experimental" => {
unsafe {
avx512::refine_vertical_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
_ => {}
}
}
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
if cpudetect::x86_64::is_x86_64_v3_compatible() {
cfg_select! {
feature = "experimental" => {
unsafe {
avx2::refine_vertical_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
_ => {
if size_of::<T>() == 1 {
unsafe {
avx2::refine_vertical_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
}
}
}
rust::refine_vertical_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
#[inline]
pub fn refine_diagonal_bilinear<T: Pixel>(
dest: &mut [T],
src: &[T],
pitch: NonZeroUsize,
width: NonZeroUsize,
height: NonZeroUsize,
_bits_per_sample: NonZeroU8,
) {
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
if cpudetect::x86_64::is_x86_64_v4_compatible() {
cfg_select! {
feature = "experimental" => {
unsafe {
avx512::refine_diagonal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
_ => {
if size_of::<T>() == 2 {
unsafe {
avx512::refine_diagonal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
}
}
}
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
if cpudetect::x86_64::is_x86_64_v3_compatible() {
cfg_select! {
feature = "experimental" => {
unsafe {
avx2::refine_diagonal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}
return;
}
_ => {}
}
}
rust::refine_diagonal_bilinear(dest, src, pitch, width, height, _bits_per_sample);
}