#[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::{
DcpTargetGamut,
row::{
rgb_row_bytes, rgb_row_elems, rgba_row_bytes, rgba_row_elems, scalar::xyz12 as scalar_xyz12,
},
};
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_to_rgb_row<const BE: bool>(
xyz: &[u16],
rgb_out: &mut [u8],
width: usize,
target_gamut: DcpTargetGamut,
use_simd: bool,
) {
let xyz_in_min = rgb_row_elems(width);
let rgb_out_min = rgb_row_bytes(width);
assert!(xyz.len() >= xyz_in_min, "xyz row too short");
assert!(rgb_out.len() >= rgb_out_min, "rgb_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe { arch::neon::xyz12::xyz12_to_rgb_row::<BE>(xyz, rgb_out, width, target_gamut); }
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::xyz12::xyz12_to_rgb_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::xyz12::xyz12_to_rgb_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::xyz12::xyz12_to_rgb_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::xyz12::xyz12_to_rgb_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
},
_ => {}
}
}
scalar_xyz12::xyz12_to_rgb_row::<BE>(xyz, rgb_out, width, target_gamut);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_to_rgba_row<const BE: bool>(
xyz: &[u16],
rgba_out: &mut [u8],
width: usize,
target_gamut: DcpTargetGamut,
use_simd: bool,
) {
let xyz_in_min = rgb_row_elems(width);
let rgba_out_min = rgba_row_bytes(width);
assert!(xyz.len() >= xyz_in_min, "xyz row too short");
assert!(rgba_out.len() >= rgba_out_min, "rgba_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe { arch::neon::xyz12::xyz12_to_rgba_row::<BE>(xyz, rgba_out, width, target_gamut); }
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::xyz12::xyz12_to_rgba_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::xyz12::xyz12_to_rgba_row::<BE>(xyz, rgba_out, width, target_gamut);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::xyz12::xyz12_to_rgba_row::<BE>(xyz, rgba_out, width, target_gamut);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::xyz12::xyz12_to_rgba_row::<BE>(xyz, rgba_out, width, target_gamut);
}
return;
}
},
_ => {}
}
}
scalar_xyz12::xyz12_to_rgba_row::<BE>(xyz, rgba_out, width, target_gamut);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_to_rgb_u16_row<const BE: bool>(
xyz: &[u16],
rgb_out: &mut [u16],
width: usize,
target_gamut: DcpTargetGamut,
use_simd: bool,
) {
let xyz_in_min = rgb_row_elems(width);
let rgb_out_min = rgb_row_elems(width);
assert!(xyz.len() >= xyz_in_min, "xyz row too short");
assert!(rgb_out.len() >= rgb_out_min, "rgb_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe {
arch::neon::xyz12::xyz12_to_rgb_u16_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::xyz12::xyz12_to_rgb_u16_row::<BE>(
xyz, rgb_out, width, target_gamut,
);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::xyz12::xyz12_to_rgb_u16_row::<BE>(
xyz, rgb_out, width, target_gamut,
);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::xyz12::xyz12_to_rgb_u16_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::xyz12::xyz12_to_rgb_u16_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
},
_ => {}
}
}
scalar_xyz12::xyz12_to_rgb_u16_row::<BE>(xyz, rgb_out, width, target_gamut);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_to_rgba_u16_row<const BE: bool>(
xyz: &[u16],
rgba_out: &mut [u16],
width: usize,
target_gamut: DcpTargetGamut,
use_simd: bool,
) {
let xyz_in_min = rgb_row_elems(width);
let rgba_out_min = rgba_row_elems(width);
assert!(xyz.len() >= xyz_in_min, "xyz row too short");
assert!(rgba_out.len() >= rgba_out_min, "rgba_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe {
arch::neon::xyz12::xyz12_to_rgba_u16_row::<BE>(xyz, rgba_out, width, target_gamut);
}
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::xyz12::xyz12_to_rgba_u16_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::xyz12::xyz12_to_rgba_u16_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::xyz12::xyz12_to_rgba_u16_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::xyz12::xyz12_to_rgba_u16_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
},
_ => {}
}
}
scalar_xyz12::xyz12_to_rgba_u16_row::<BE>(xyz, rgba_out, width, target_gamut);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_to_rgb_f32_row<const BE: bool>(
xyz: &[u16],
rgb_out: &mut [f32],
width: usize,
target_gamut: DcpTargetGamut,
use_simd: bool,
) {
let xyz_in_min = rgb_row_elems(width);
let rgb_out_min = rgb_row_elems(width);
assert!(xyz.len() >= xyz_in_min, "xyz row too short");
assert!(rgb_out.len() >= rgb_out_min, "rgb_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe {
arch::neon::xyz12::xyz12_to_rgb_f32_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::xyz12::xyz12_to_rgb_f32_row::<BE>(
xyz, rgb_out, width, target_gamut,
);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::xyz12::xyz12_to_rgb_f32_row::<BE>(
xyz, rgb_out, width, target_gamut,
);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::xyz12::xyz12_to_rgb_f32_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::xyz12::xyz12_to_rgb_f32_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
},
_ => {}
}
}
scalar_xyz12::xyz12_to_rgb_f32_row::<BE>(xyz, rgb_out, width, target_gamut);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_to_xyz_f32_row<const BE: bool>(
xyz: &[u16],
xyz_out: &mut [f32],
width: usize,
use_simd: bool,
) {
let xyz_in_min = rgb_row_elems(width);
let xyz_out_min = rgb_row_elems(width);
assert!(xyz.len() >= xyz_in_min, "xyz row too short");
assert!(xyz_out.len() >= xyz_out_min, "xyz_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe {
arch::neon::xyz12::xyz12_to_xyz_f32_row::<BE>(xyz, xyz_out, width);
}
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::xyz12::xyz12_to_xyz_f32_row::<BE>(xyz, xyz_out, width);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::xyz12::xyz12_to_xyz_f32_row::<BE>(xyz, xyz_out, width);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::xyz12::xyz12_to_xyz_f32_row::<BE>(xyz, xyz_out, width);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::xyz12::xyz12_to_xyz_f32_row::<BE>(xyz, xyz_out, width);
}
return;
}
},
_ => {}
}
}
scalar_xyz12::xyz12_to_xyz_f32_row::<BE>(xyz, xyz_out, width);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_to_rgb_f16_row<const BE: bool>(
xyz: &[u16],
rgb_out: &mut [half::f16],
width: usize,
target_gamut: DcpTargetGamut,
use_simd: bool,
) {
let xyz_in_min = rgb_row_elems(width);
let rgb_out_min = rgb_row_elems(width);
assert!(xyz.len() >= xyz_in_min, "xyz row too short");
assert!(rgb_out.len() >= rgb_out_min, "rgb_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe {
arch::neon::xyz12::xyz12_to_rgb_f16_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::xyz12::xyz12_to_rgb_f16_row::<BE>(
xyz, rgb_out, width, target_gamut,
);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::xyz12::xyz12_to_rgb_f16_row::<BE>(
xyz, rgb_out, width, target_gamut,
);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::xyz12::xyz12_to_rgb_f16_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::xyz12::xyz12_to_rgb_f16_row::<BE>(xyz, rgb_out, width, target_gamut);
}
return;
}
},
_ => {}
}
}
scalar_xyz12::xyz12_to_rgb_f16_row::<BE>(xyz, rgb_out, width, target_gamut);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_to_rgba_f16_row<const BE: bool>(
xyz: &[u16],
rgba_out: &mut [half::f16],
width: usize,
target_gamut: DcpTargetGamut,
use_simd: bool,
) {
let xyz_in_min = rgb_row_elems(width);
let rgba_out_min = rgba_row_elems(width);
assert!(xyz.len() >= xyz_in_min, "xyz row too short");
assert!(rgba_out.len() >= rgba_out_min, "rgba_out row too short");
if use_simd {
cfg_select! {
target_arch = "aarch64" => {
if neon_available() {
unsafe {
arch::neon::xyz12::xyz12_to_rgba_f16_row::<BE>(xyz, rgba_out, width, target_gamut);
}
return;
}
},
target_arch = "wasm32" => {
if simd128_available() {
unsafe {
arch::wasm_simd128::xyz12::xyz12_to_rgba_f16_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
},
target_arch = "x86_64" => {
if avx512_available() {
unsafe {
arch::x86_avx512::xyz12::xyz12_to_rgba_f16_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
if avx2_available() {
unsafe {
arch::x86_avx2::xyz12::xyz12_to_rgba_f16_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
if sse41_available() {
unsafe {
arch::x86_sse41::xyz12::xyz12_to_rgba_f16_row::<BE>(
xyz, rgba_out, width, target_gamut,
);
}
return;
}
},
_ => {}
}
}
scalar_xyz12::xyz12_to_rgba_f16_row::<BE>(xyz, rgba_out, width, target_gamut);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_rgb_to_luma_row(
rgb: &[u8],
luma_out: &mut [u8],
width: usize,
luma_q15: (i32, i32, i32),
_use_simd: bool,
) {
let rgb_min = rgb_row_bytes(width);
assert!(rgb.len() >= rgb_min, "rgb row too short");
assert!(luma_out.len() >= width, "luma row too short");
scalar_xyz12::xyz12_rgb_to_luma_row(rgb, luma_out, width, luma_q15);
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub fn xyz12_rgb_to_luma_u16_row(
rgb: &[u8],
luma_out: &mut [u16],
width: usize,
luma_q15: (i32, i32, i32),
_use_simd: bool,
) {
let rgb_min = rgb_row_bytes(width);
assert!(rgb.len() >= rgb_min, "rgb row too short");
assert!(luma_out.len() >= width, "luma row too short");
scalar_xyz12::xyz12_rgb_to_luma_u16_row(rgb, luma_out, width, luma_q15);
}