#[cfg(any(
target_arch = "aarch64",
target_arch = "x86_64",
target_arch = "wasm32"
))]
use crate::row::arch;
#[cfg(target_arch = "aarch64")]
use crate::row::neon_available;
#[cfg(target_arch = "wasm32")]
use crate::row::simd128_available;
#[cfg(target_arch = "x86_64")]
use crate::row::{avx2_available, avx512_available, sse41_available};
use crate::{
ColorMatrix,
row::{rgb_row_bytes, rgb_row_elems, scalar},
};
#[cfg_attr(not(tarpaulin), inline(always))]
#[allow(clippy::too_many_arguments)]
pub(crate) fn yuv_444p_n_to_rgb_row<const BITS: u32, const BE: bool>(
y: &[u16],
u: &[u16],
v: &[u16],
rgb_out: &mut [u8],
width: usize,
matrix: ColorMatrix,
full_range: bool,
use_simd: bool,
) {
let rgb_min = rgb_row_bytes(width);
assert!(y.len() >= width, "y row too short");
assert!(u.len() >= width, "u row too short");
assert!(v.len() >= width, "v row too short");
assert!(rgb_out.len() >= rgb_min, "rgb_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe {
arch::neon::yuv_444p_n_to_rgb_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::yuv_444p_n_to_rgb_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::yuv_444p_n_to_rgb_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::yuv_444p_n_to_rgb_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::yuv_444p_n_to_rgb_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
},
_ => {}
}
}
scalar::yuv_444p_n_to_rgb_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
#[cfg_attr(not(tarpaulin), inline(always))]
#[allow(clippy::too_many_arguments)]
pub(crate) fn yuv_444p_n_to_rgb_u16_row<const BITS: u32, const BE: bool>(
y: &[u16],
u: &[u16],
v: &[u16],
rgb_out: &mut [u16],
width: usize,
matrix: ColorMatrix,
full_range: bool,
use_simd: bool,
) {
let rgb_min = rgb_row_elems(width);
assert!(y.len() >= width, "y row too short");
assert!(u.len() >= width, "u row too short");
assert!(v.len() >= width, "v row too short");
assert!(rgb_out.len() >= rgb_min, "rgb_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe {
arch::neon::yuv_444p_n_to_rgb_u16_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::yuv_444p_n_to_rgb_u16_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::yuv_444p_n_to_rgb_u16_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::yuv_444p_n_to_rgb_u16_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::yuv_444p_n_to_rgb_u16_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
return;
}
},
_ => {}
}
}
scalar::yuv_444p_n_to_rgb_u16_row::<BITS, BE>(y, u, v, rgb_out, width, matrix, full_range);
}
pub(super) mod yuv444p10;
pub(super) mod yuv444p12;
pub(super) mod yuv444p14;
pub(super) mod yuv444p16;
pub(super) mod yuv444p9;
pub(super) mod yuv_444;
pub use yuv_444::*;
pub use yuv444p9::*;
pub use yuv444p10::*;
pub use yuv444p12::*;
pub use yuv444p14::*;
pub use yuv444p16::*;