#![cfg_attr(
any(
not(feature = "std"),
not(any(feature = "yuv-planar", feature = "rgb"))
),
allow(dead_code)
)]
pub(crate) fn area_h_reduce_row(
row: &[u8],
channels: usize,
starts: &[usize],
offsets: &[usize],
weights: &[usize],
h_tmp: &mut [u32],
) {
for (j, &start) in starts.iter().enumerate() {
let span = &weights[offsets[j]..offsets[j + 1]];
let base = j * channels;
for ch in 0..channels {
let mut sum = 0u32;
for (i, &w) in span.iter().enumerate() {
sum += w as u32 * u32::from(row[(start + i) * channels + ch]);
}
h_tmp[base + ch] = sum;
}
}
}
pub(crate) fn area_v_accumulate(acc: &mut [u64], h_tmp: &[u32], w: u64) {
for (a, t) in acc.iter_mut().zip(h_tmp.iter()) {
*a += w * u64::from(*t);
}
}
pub(crate) fn area_h_reduce_row_u16(
row: &[u16],
channels: usize,
starts: &[usize],
offsets: &[usize],
weights: &[usize],
h_tmp: &mut [u64],
) {
for (j, &start) in starts.iter().enumerate() {
let span = &weights[offsets[j]..offsets[j + 1]];
let base = j * channels;
for ch in 0..channels {
let mut sum = 0u64;
for (i, &w) in span.iter().enumerate() {
sum += w as u64 * u64::from(row[(start + i) * channels + ch]);
}
h_tmp[base + ch] = sum;
}
}
}
pub(crate) fn area_v_accumulate_u16(acc: &mut [u64], h_tmp: &[u64], w: u64) {
for (a, t) in acc.iter_mut().zip(h_tmp.iter()) {
*a += w * *t;
}
}
pub(crate) fn area_h_reduce_row_u32(
row: &[u32],
channels: usize,
starts: &[usize],
offsets: &[usize],
weights: &[usize],
h_tmp: &mut [u128],
) {
for (j, &start) in starts.iter().enumerate() {
let span = &weights[offsets[j]..offsets[j + 1]];
let base = j * channels;
for ch in 0..channels {
let mut sum = 0u128;
for (i, &w) in span.iter().enumerate() {
sum += w as u128 * u128::from(row[(start + i) * channels + ch]);
}
h_tmp[base + ch] = sum;
}
}
}
pub(crate) fn area_v_accumulate_u32(acc: &mut [u128], h_tmp: &[u128], w: u128) {
for (a, t) in acc.iter_mut().zip(h_tmp.iter()) {
*a += w * *t;
}
}
pub(crate) fn area_h_reduce_row_f32(
row: &[f32],
channels: usize,
starts: &[usize],
offsets: &[usize],
weights: &[usize],
h_tmp: &mut [f64],
) {
for (j, &start) in starts.iter().enumerate() {
let span = &weights[offsets[j]..offsets[j + 1]];
let base = j * channels;
for ch in 0..channels {
let mut sum = 0.0f64;
for (i, &w) in span.iter().enumerate() {
sum += w as f64 * f64::from(row[(start + i) * channels + ch]);
}
h_tmp[base + ch] = sum;
}
}
}
pub(crate) fn area_v_accumulate_f32(acc: &mut [f64], h_tmp: &[f64], w: f64) {
for (a, t) in acc.iter_mut().zip(h_tmp.iter()) {
*a += w * *t;
}
}