use std::sync::OnceLock;
#[inline]
pub(crate) fn compound_tmp_len(w: usize, h: usize) -> usize {
(w * h).next_multiple_of(16)
}
#[inline]
pub(crate) fn inter_bilin_8bpc_tmp_len(w: usize, h: usize, mx: i32, my: i32) -> usize {
if mx != 0 && my != 0 {
w.next_multiple_of(16).max(64) * (h + 1)
} else {
0
}
}
#[inline]
pub(crate) fn inter_8tap_8bpc_tmp_len(
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
) -> usize {
if crate::mc::get_h_filter(mx, filter_type, w).is_some()
&& crate::mc::get_v_filter(my, filter_type, h).is_some()
{
w.next_multiple_of(16).max(64) * (h + 7)
} else {
0
}
}
#[inline]
pub(crate) fn inter_bilin_hbd_tmp_len(w: usize, h: usize, mx: i32, my: i32) -> usize {
if mx != 0 && my != 0 {
w.next_multiple_of(16).max(64) * (h + 1)
} else {
0
}
}
#[inline]
pub(crate) fn inter_8tap_hbd_tmp_len(
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
) -> usize {
if crate::mc::get_h_filter(mx, filter_type, w).is_some()
&& crate::mc::get_v_filter(my, filter_type, h).is_some()
{
w.next_multiple_of(16).max(64) * (h + 7)
} else {
0
}
}
#[inline]
fn inter_tmp(scratch: &mut Vec<i16>, len: usize) -> &mut [i16] {
if scratch.len() < len {
scratch.resize(len, 0);
}
&mut scratch[..len]
}
pub(crate) type PrepHbdFn = unsafe fn(&mut [i16], usize, &[u16], usize, usize, usize, u8);
pub(crate) fn prep_hbd_scalar(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_stride: usize,
w: usize,
h: usize,
bitdepth: u8,
) {
crate::mc::prep_scalar(
<crate::pixel::BitDepth16 as crate::pixel::BitDepth>::new(bitdepth),
tmp,
tmp_stride,
src,
src_stride,
w,
h,
);
}
static PREP_HBD: OnceLock<PrepHbdFn> = OnceLock::new();
#[inline]
fn resolve_prep_hbd() -> PrepHbdFn {
*PREP_HBD.get_or_init(|| {
let mut _f = prep_hbd_scalar as PrepHbdFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::prep_hbd_neon as PrepHbdFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = crate::sse::prep_hbd_sse41 as PrepHbdFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::prep_hbd_avx2 as PrepHbdFn;
}
}
_f
})
}
#[inline]
pub(crate) fn prep_hbd(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_stride: usize,
w: usize,
h: usize,
bitdepth: u8,
) {
unsafe { resolve_prep_hbd()(tmp, tmp_stride, src, src_stride, w, h, bitdepth) }
}
pub(crate) type PutBilinHbdFn =
unsafe fn(&mut [u16], usize, &[u16], usize, usize, usize, i32, i32, u8, &mut [i16]);
#[allow(clippy::too_many_arguments)]
pub(crate) fn put_bilin_hbd_scalar(
dst: &mut [u16],
dst_stride: usize,
src: &[u16],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
bitdepth: u8,
_mid_scratch: &mut [i16],
) {
crate::mc::put_bilin_scalar(
<crate::pixel::BitDepth16 as crate::pixel::BitDepth>::new(bitdepth),
dst,
dst_stride,
src,
src_stride,
w,
h,
mx,
my,
);
}
static PUT_BILIN_HBD: OnceLock<PutBilinHbdFn> = OnceLock::new();
#[inline]
fn resolve_put_bilin_hbd() -> PutBilinHbdFn {
*PUT_BILIN_HBD.get_or_init(|| {
let mut _f = put_bilin_hbd_scalar as PutBilinHbdFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::put_bilin_hbd_neon as PutBilinHbdFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = crate::sse::put_bilin_hbd_sse41 as PutBilinHbdFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::put_bilin_hbd_avx2 as PutBilinHbdFn;
}
}
_f
})
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn put_bilin_hbd_with_scratch(
dst: &mut [u16],
dst_stride: usize,
src: &[u16],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
bitdepth: u8,
scratch: &mut Vec<i16>,
) {
let mid = inter_tmp(scratch, inter_bilin_hbd_tmp_len(w, h, mx, my));
unsafe {
resolve_put_bilin_hbd()(
dst, dst_stride, src, src_stride, w, h, mx, my, bitdepth, mid,
)
}
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn put_bilin_hbd(
dst: &mut [u16],
dst_stride: usize,
src: &[u16],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
bitdepth: u8,
) {
let mut scratch = Vec::new();
put_bilin_hbd_with_scratch(
dst,
dst_stride,
src,
src_stride,
w,
h,
mx,
my,
bitdepth,
&mut scratch,
);
}
pub(crate) type PrepBilinHbdFn =
unsafe fn(&mut [i16], usize, &[u16], usize, usize, usize, i32, i32, u8, &mut [i16]);
#[allow(clippy::too_many_arguments)]
pub(crate) fn prep_bilin_hbd_scalar(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
bitdepth: u8,
_mid_scratch: &mut [i16],
) {
crate::mc::prep_bilin_scalar(
<crate::pixel::BitDepth16 as crate::pixel::BitDepth>::new(bitdepth),
tmp,
tmp_stride,
src,
src_stride,
w,
h,
mx,
my,
);
}
static PREP_BILIN_HBD: OnceLock<PrepBilinHbdFn> = OnceLock::new();
#[inline]
fn resolve_prep_bilin_hbd() -> PrepBilinHbdFn {
*PREP_BILIN_HBD.get_or_init(|| {
let mut _f = prep_bilin_hbd_scalar as PrepBilinHbdFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::prep_bilin_hbd_neon as PrepBilinHbdFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = crate::sse::prep_bilin_hbd_sse41 as PrepBilinHbdFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::prep_bilin_hbd_avx2 as PrepBilinHbdFn;
}
}
_f
})
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn prep_bilin_hbd_with_scratch(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
bitdepth: u8,
scratch: &mut Vec<i16>,
) {
let mid = inter_tmp(scratch, inter_bilin_hbd_tmp_len(w, h, mx, my));
unsafe {
resolve_prep_bilin_hbd()(
tmp, tmp_stride, src, src_stride, w, h, mx, my, bitdepth, mid,
)
}
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn prep_bilin_hbd(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
bitdepth: u8,
) {
let mut scratch = Vec::new();
prep_bilin_hbd_with_scratch(
tmp,
tmp_stride,
src,
src_stride,
w,
h,
mx,
my,
bitdepth,
&mut scratch,
);
}
pub(crate) type Put8tapHbdFn =
unsafe fn(&mut [u16], usize, &[u16], usize, usize, usize, usize, i32, i32, i32, u8, &mut [i16]);
#[allow(clippy::too_many_arguments)]
pub(crate) fn put_8tap_hbd_scalar(
dst: &mut [u16],
dst_stride: usize,
src: &[u16],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
bitdepth: u8,
_mid_scratch: &mut [i16],
) {
crate::mc::put_8tap_scalar(
<crate::pixel::BitDepth16 as crate::pixel::BitDepth>::new(bitdepth),
dst,
dst_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
);
}
static PUT_8TAP_HBD: OnceLock<Put8tapHbdFn> = OnceLock::new();
#[inline]
fn resolve_put_8tap_hbd() -> Put8tapHbdFn {
*PUT_8TAP_HBD.get_or_init(|| {
let mut _f = put_8tap_hbd_scalar as Put8tapHbdFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::put_8tap_hbd_neon as Put8tapHbdFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = crate::sse::put_8tap_hbd_sse41 as Put8tapHbdFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::put_8tap_hbd_avx2 as Put8tapHbdFn;
}
}
_f
})
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn put_8tap_hbd_with_scratch(
dst: &mut [u16],
dst_stride: usize,
src: &[u16],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
bitdepth: u8,
scratch: &mut Vec<i16>,
) {
let mid = inter_tmp(scratch, inter_8tap_hbd_tmp_len(w, h, mx, my, filter_type));
unsafe {
resolve_put_8tap_hbd()(
dst,
dst_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
bitdepth,
mid,
)
}
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn put_8tap_hbd(
dst: &mut [u16],
dst_stride: usize,
src: &[u16],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
bitdepth: u8,
) {
let mut scratch = Vec::new();
put_8tap_hbd_with_scratch(
dst,
dst_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
bitdepth,
&mut scratch,
);
}
pub(crate) type Prep8tapHbdFn =
unsafe fn(&mut [i16], usize, &[u16], usize, usize, usize, usize, i32, i32, i32, u8, &mut [i16]);
#[allow(clippy::too_many_arguments)]
pub(crate) fn prep_8tap_hbd_scalar(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
bitdepth: u8,
_mid_scratch: &mut [i16],
) {
crate::mc::prep_8tap_scalar(
<crate::pixel::BitDepth16 as crate::pixel::BitDepth>::new(bitdepth),
tmp,
tmp_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
);
}
static PREP_8TAP_HBD: OnceLock<Prep8tapHbdFn> = OnceLock::new();
#[inline]
fn resolve_prep_8tap_hbd() -> Prep8tapHbdFn {
*PREP_8TAP_HBD.get_or_init(|| {
let mut _f = prep_8tap_hbd_scalar as Prep8tapHbdFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::prep_8tap_hbd_neon as Prep8tapHbdFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = crate::sse::prep_8tap_hbd_sse41 as Prep8tapHbdFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::prep_8tap_hbd_avx2 as Prep8tapHbdFn;
}
}
_f
})
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn prep_8tap_hbd_with_scratch(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
bitdepth: u8,
scratch: &mut Vec<i16>,
) {
let mid = inter_tmp(scratch, inter_8tap_hbd_tmp_len(w, h, mx, my, filter_type));
unsafe {
resolve_prep_8tap_hbd()(
tmp,
tmp_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
bitdepth,
mid,
)
}
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn prep_8tap_hbd(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
bitdepth: u8,
) {
let mut scratch = Vec::new();
prep_8tap_hbd_with_scratch(
tmp,
tmp_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
bitdepth,
&mut scratch,
);
}
pub(crate) type PutBilin8bpcFn =
unsafe fn(&mut [u8], usize, &[u8], usize, usize, usize, i32, i32, &mut [i16]);
pub(crate) type PrepBilin8bpcFn =
unsafe fn(&mut [i16], usize, &[u8], usize, usize, usize, i32, i32, &mut [i16]);
#[allow(clippy::too_many_arguments)]
pub(crate) fn put_bilin_8bpc_scalar_dispatch(
dst: &mut [u8],
dst_stride: usize,
src: &[u8],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
_mid_scratch: &mut [i16],
) {
crate::mc::put_bilin_8bpc(dst, dst_stride, src, src_stride, w, h, mx, my);
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn prep_bilin_8bpc_scalar_dispatch(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u8],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
_mid_scratch: &mut [i16],
) {
crate::mc::prep_bilin_8bpc(tmp, tmp_stride, src, src_stride, w, h, mx, my);
}
static PUT_BILIN_8BPC: OnceLock<PutBilin8bpcFn> = OnceLock::new();
static PREP_BILIN_8BPC: OnceLock<PrepBilin8bpcFn> = OnceLock::new();
#[inline]
fn resolve_put_bilin_8bpc() -> PutBilin8bpcFn {
*PUT_BILIN_8BPC.get_or_init(|| {
let mut _f = put_bilin_8bpc_scalar_dispatch as PutBilin8bpcFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::put_bilin_8bpc_neon as PutBilin8bpcFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = put_bilin_8bpc_scalar_dispatch as PutBilin8bpcFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::put_bilin_8bpc_avx2 as PutBilin8bpcFn;
}
}
_f
})
}
#[inline]
fn resolve_prep_bilin_8bpc() -> PrepBilin8bpcFn {
*PREP_BILIN_8BPC.get_or_init(|| {
let mut _f = prep_bilin_8bpc_scalar_dispatch as PrepBilin8bpcFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::prep_bilin_8bpc_neon as PrepBilin8bpcFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = prep_bilin_8bpc_scalar_dispatch as PrepBilin8bpcFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::prep_bilin_8bpc_avx2 as PrepBilin8bpcFn;
}
}
_f
})
}
pub(crate) type Put8tap8bpcFn =
unsafe fn(&mut [u8], usize, &[u8], usize, usize, usize, usize, i32, i32, i32, &mut [i16]);
pub(crate) type Prep8tap8bpcFn =
unsafe fn(&mut [i16], usize, &[u8], usize, usize, usize, usize, i32, i32, i32, &mut [i16]);
#[allow(clippy::too_many_arguments)]
pub(crate) fn put_8tap_8bpc_scalar_dispatch(
dst: &mut [u8],
dst_stride: usize,
src: &[u8],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
_mid_scratch: &mut [i16],
) {
crate::mc::put_8tap_8bpc(
dst,
dst_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
);
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn prep_8tap_8bpc_scalar_dispatch(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u8],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
_mid_scratch: &mut [i16],
) {
crate::mc::prep_8tap_8bpc(
tmp,
tmp_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
);
}
static PUT_8TAP_8BPC: OnceLock<Put8tap8bpcFn> = OnceLock::new();
static PREP_8TAP_8BPC: OnceLock<Prep8tap8bpcFn> = OnceLock::new();
#[inline]
fn resolve_put_8tap_8bpc() -> Put8tap8bpcFn {
*PUT_8TAP_8BPC.get_or_init(|| {
let mut _f = put_8tap_8bpc_scalar_dispatch as Put8tap8bpcFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::put_8tap_8bpc_neon as Put8tap8bpcFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = put_8tap_8bpc_scalar_dispatch as Put8tap8bpcFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::put_8tap_8bpc_avx2 as Put8tap8bpcFn;
}
}
_f
})
}
#[inline]
fn resolve_prep_8tap_8bpc() -> Prep8tap8bpcFn {
*PREP_8TAP_8BPC.get_or_init(|| {
let mut _f = prep_8tap_8bpc_scalar_dispatch as Prep8tap8bpcFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::prep_8tap_8bpc_neon as Prep8tap8bpcFn;
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "sse"))]
{
if std::is_x86_feature_detected!("sse4.1") {
_f = prep_8tap_8bpc_scalar_dispatch as Prep8tap8bpcFn;
}
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::prep_8tap_8bpc_avx2 as Prep8tap8bpcFn;
}
}
_f
})
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn put_8tap_8bpc_with_scratch(
dst: &mut [u8],
dst_stride: usize,
src: &[u8],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
scratch: &mut Vec<i16>,
) {
let mid = inter_tmp(scratch, inter_8tap_8bpc_tmp_len(w, h, mx, my, filter_type));
unsafe {
resolve_put_8tap_8bpc()(
dst,
dst_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
mid,
)
}
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn prep_8tap_8bpc_with_scratch(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u8],
src_off: usize,
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
filter_type: i32,
scratch: &mut Vec<i16>,
) {
let mid = inter_tmp(scratch, inter_8tap_8bpc_tmp_len(w, h, mx, my, filter_type));
unsafe {
resolve_prep_8tap_8bpc()(
tmp,
tmp_stride,
src,
src_off,
src_stride,
w,
h,
mx,
my,
filter_type,
mid,
)
}
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn put_bilin_8bpc_with_scratch(
dst: &mut [u8],
dst_stride: usize,
src: &[u8],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
scratch: &mut Vec<i16>,
) {
let mid = inter_tmp(scratch, inter_bilin_8bpc_tmp_len(w, h, mx, my));
unsafe { resolve_put_bilin_8bpc()(dst, dst_stride, src, src_stride, w, h, mx, my, mid) }
}
#[allow(clippy::too_many_arguments)]
#[inline]
pub(crate) fn prep_bilin_8bpc_with_scratch(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u8],
src_stride: usize,
w: usize,
h: usize,
mx: i32,
my: i32,
scratch: &mut Vec<i16>,
) {
let mid = inter_tmp(scratch, inter_bilin_8bpc_tmp_len(w, h, mx, my));
unsafe { resolve_prep_bilin_8bpc()(tmp, tmp_stride, src, src_stride, w, h, mx, my, mid) }
}
pub(crate) fn avg_8bpc(
dst: &mut [u8],
dst_stride: usize,
tmp1: &[i16],
tmp2: &[i16],
w: usize,
h: usize,
) {
crate::mc::avg_8bpc(dst, dst_stride, tmp1, tmp2, w, h);
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn w_avg_8bpc(
dst: &mut [u8],
dst_stride: usize,
tmp1: &[i16],
tmp2: &[i16],
w: usize,
h: usize,
weight: i32,
) {
crate::mc::w_avg_8bpc(dst, dst_stride, tmp1, tmp2, w, h, weight);
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn mask_8bpc(
dst: &mut [u8],
dst_stride: usize,
tmp1: &[i16],
tmp2: &[i16],
w: usize,
h: usize,
m: &[u8],
) {
crate::mc::mask_8bpc(dst, dst_stride, tmp1, tmp2, w, h, m);
}
pub(crate) fn blend_8bpc(
dst: &mut [u8],
dst_stride: usize,
tmp: &[u8],
w: usize,
h: usize,
m: &[u8],
) {
crate::mc::blend_8bpc(dst, dst_stride, tmp, w, h, m);
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn w_mask_8bpc(
dst: &mut [u8],
dst_stride: usize,
tmp1: &[i16],
tmp2: &[i16],
w: usize,
h: usize,
m: &mut [u8],
mask_stride: usize,
sign: i32,
ss_hor: bool,
ss_ver: bool,
) {
crate::mc::w_mask_8bpc(
dst,
dst_stride,
tmp1,
tmp2,
w,
h,
m,
mask_stride,
sign,
ss_hor,
ss_ver,
);
}
type Warp8Fn = unsafe fn(&mut [u8], usize, &[u8], usize, usize, &[i16; 4], i32, i32);
type Warp8tFn = unsafe fn(&mut [i16], usize, &[u8], usize, usize, &[i16; 4], i32, i32);
type WarpHbdFn = unsafe fn(&mut [u16], usize, &[u16], usize, usize, &[i16; 4], i32, i32, u8);
type WarpHbdTfn = unsafe fn(&mut [i16], usize, &[u16], usize, usize, &[i16; 4], i32, i32, u8);
#[allow(clippy::too_many_arguments)]
fn warp_affine_8x8_8bpc_scalar(
dst: &mut [u8],
dst_stride: usize,
src: &[u8],
src_stride: usize,
src_off: usize,
abcd: &[i16; 4],
mx: i32,
my: i32,
) {
crate::mc::warp_affine_8x8_8bpc(dst, dst_stride, src, src_stride, src_off, abcd, mx, my);
}
#[allow(clippy::too_many_arguments)]
fn warp_affine_8x8t_8bpc_scalar(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u8],
src_stride: usize,
src_off: usize,
abcd: &[i16; 4],
mx: i32,
my: i32,
) {
crate::mc::warp_affine_8x8t_8bpc(tmp, tmp_stride, src, src_stride, src_off, abcd, mx, my);
}
#[allow(clippy::too_many_arguments)]
fn warp_affine_8x8_hbd_scalar(
dst: &mut [u16],
dst_stride: usize,
src: &[u16],
src_stride: usize,
src_off: usize,
abcd: &[i16; 4],
mx: i32,
my: i32,
bitdepth: u8,
) {
crate::mc::warp_affine_8x8(
<crate::pixel::BitDepth16 as crate::pixel::BitDepth>::new(bitdepth),
dst,
dst_stride,
src,
src_stride,
src_off,
abcd,
mx,
my,
);
}
#[allow(clippy::too_many_arguments)]
fn warp_affine_8x8t_hbd_scalar(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_stride: usize,
src_off: usize,
abcd: &[i16; 4],
mx: i32,
my: i32,
bitdepth: u8,
) {
crate::mc::warp_affine_8x8t(
<crate::pixel::BitDepth16 as crate::pixel::BitDepth>::new(bitdepth),
tmp,
tmp_stride,
src,
src_stride,
src_off,
abcd,
mx,
my,
);
}
static WARP_8BPC: OnceLock<Warp8Fn> = OnceLock::new();
static WARP_T_8BPC: OnceLock<Warp8tFn> = OnceLock::new();
static WARP_HBD: OnceLock<WarpHbdFn> = OnceLock::new();
static WARP_T_HBD: OnceLock<WarpHbdTfn> = OnceLock::new();
#[inline]
fn resolve_warp_8bpc() -> Warp8Fn {
*WARP_8BPC.get_or_init(|| {
let mut _f = warp_affine_8x8_8bpc_scalar as Warp8Fn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::warp_affine_8x8_8bpc_neon as Warp8Fn;
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::warp_affine_8x8_8bpc_avx2 as Warp8Fn;
}
}
_f
})
}
#[inline]
fn resolve_warp_t_8bpc() -> Warp8tFn {
*WARP_T_8BPC.get_or_init(|| {
let mut _f = warp_affine_8x8t_8bpc_scalar as Warp8tFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::warp_affine_8x8t_8bpc_neon as Warp8tFn;
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::warp_affine_8x8t_8bpc_avx2 as Warp8tFn;
}
}
_f
})
}
#[inline]
fn resolve_warp_hbd() -> WarpHbdFn {
*WARP_HBD.get_or_init(|| {
let mut _f = warp_affine_8x8_hbd_scalar as WarpHbdFn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::warp_affine_8x8_hbd_neon as WarpHbdFn;
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::warp_affine_8x8_hbd_avx2 as WarpHbdFn;
}
}
_f
})
}
#[inline]
fn resolve_warp_t_hbd() -> WarpHbdTfn {
*WARP_T_HBD.get_or_init(|| {
let mut _f = warp_affine_8x8t_hbd_scalar as WarpHbdTfn;
#[cfg(target_arch = "aarch64")]
{
_f = crate::neon::warp_affine_8x8t_hbd_neon as WarpHbdTfn;
}
#[cfg(all(target_arch = "x86_64", feature = "avx"))]
{
if std::is_x86_feature_detected!("avx2") {
_f = crate::avx::warp_affine_8x8t_hbd_avx2 as WarpHbdTfn;
}
}
_f
})
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn warp_affine_8x8_8bpc(
dst: &mut [u8],
dst_stride: usize,
src: &[u8],
src_stride: usize,
src_off: usize,
abcd: &[i16; 4],
mx: i32,
my: i32,
) {
unsafe { resolve_warp_8bpc()(dst, dst_stride, src, src_stride, src_off, abcd, mx, my) }
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn warp_affine_8x8t_8bpc(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u8],
src_stride: usize,
src_off: usize,
abcd: &[i16; 4],
mx: i32,
my: i32,
) {
unsafe { resolve_warp_t_8bpc()(tmp, tmp_stride, src, src_stride, src_off, abcd, mx, my) }
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn warp_affine_8x8_hbd(
dst: &mut [u16],
dst_stride: usize,
src: &[u16],
src_stride: usize,
src_off: usize,
abcd: &[i16; 4],
mx: i32,
my: i32,
bitdepth: u8,
) {
unsafe {
resolve_warp_hbd()(
dst, dst_stride, src, src_stride, src_off, abcd, mx, my, bitdepth,
)
}
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn warp_affine_8x8t_hbd(
tmp: &mut [i16],
tmp_stride: usize,
src: &[u16],
src_stride: usize,
src_off: usize,
abcd: &[i16; 4],
mx: i32,
my: i32,
bitdepth: u8,
) {
unsafe {
resolve_warp_t_hbd()(
tmp, tmp_stride, src, src_stride, src_off, abcd, mx, my, bitdepth,
)
}
}