use crate::dsp::dec_clip_tables::{VP8KABS0, VP8KCLIP1, VP8KSCLIP1, VP8KSCLIP2};
use crate::dsp::dsp::{
BPS, VP8_DITHER_AMP_CENTER, VP8_DITHER_DESCALE, VP8_DITHER_DESCALE_ROUNDER,
webp_transform_ac3_mul1, webp_transform_ac3_mul2,
};
use crate::utils::utils::webp_uint32_to_mem;
const BPS_U: usize = BPS as usize;
fn at(pos: usize, delta: i32) -> usize {
pos.checked_add_signed(isize::try_from(delta).expect("an i32 fits in isize"))
.expect("a position before the start of the buffer")
}
fn clip_8b(v: i32) -> u8 {
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "C returns the int in [0, 255] as uint8_t"
)]
if (v & !0xff) == 0 {
v as u8
} else if v < 0 {
0
} else {
255
}
}
fn store(dst: &mut [u8], x: usize, y: usize, v: i32) {
let i = x + y * BPS_U;
dst[i] = clip_8b(i32::from(dst[i]) + (v >> 3));
}
fn store2(dst: &mut [u8], y: usize, dc: i32, d: i32, c: i32) {
store(dst, 0, y, dc + d);
store(dst, 1, y, dc + c);
store(dst, 2, y, dc - c);
store(dst, 3, y, dc - d);
}
fn transform_one_c(input: &[i16], dst: &mut [u8]) {
let mut c = [0i32; 4 * 4];
let mut tmp = 0;
for i in 0..4 {
let a = i32::from(input[i]) + i32::from(input[i + 8]); let b = i32::from(input[i]) - i32::from(input[i + 8]); let cc = webp_transform_ac3_mul2(i32::from(input[i + 4]))
- webp_transform_ac3_mul1(i32::from(input[i + 12])); let d = webp_transform_ac3_mul1(i32::from(input[i + 4]))
+ webp_transform_ac3_mul2(i32::from(input[i + 12])); c[tmp] = a + d; c[tmp + 1] = b + cc; c[tmp + 2] = b - cc; c[tmp + 3] = a - d; tmp += 4;
}
for i in 0..4 {
let dc = c[i] + 4;
let a = dc + c[i + 8];
let b = dc - c[i + 8];
let cc = webp_transform_ac3_mul2(c[i + 4]) - webp_transform_ac3_mul1(c[i + 12]);
let d = webp_transform_ac3_mul1(c[i + 4]) + webp_transform_ac3_mul2(c[i + 12]);
let row = &mut dst[i * BPS_U..];
store(row, 0, 0, a + d);
store(row, 1, 0, b + cc);
store(row, 2, 0, b - cc);
store(row, 3, 0, a - d);
}
}
pub fn transform_ac3_c(input: &[i16], dst: &mut [u8]) {
let a = i32::from(input[0]) + 4;
let c4 = webp_transform_ac3_mul2(i32::from(input[4]));
let d4 = webp_transform_ac3_mul1(i32::from(input[4]));
let c1 = webp_transform_ac3_mul2(i32::from(input[1]));
let d1 = webp_transform_ac3_mul1(i32::from(input[1]));
store2(dst, 0, a + d4, d1, c1);
store2(dst, 1, a + c4, d1, c1);
store2(dst, 2, a - c4, d1, c1);
store2(dst, 3, a - d4, d1, c1);
}
pub fn transform_two_c(input: &[i16], dst: &mut [u8], do_two: bool) {
transform_one_c(input, dst);
if do_two {
transform_one_c(&input[16..], &mut dst[4..]);
}
}
fn transform_uv_c(input: &[i16], dst: &mut [u8]) {
vp8_transform(input, dst, true);
vp8_transform(&input[2 * 16..], &mut dst[4 * BPS_U..], true);
}
pub fn transform_dc_c(input: &[i16], dst: &mut [u8]) {
let dc = i32::from(input[0]) + 4;
for j in 0..4 {
for i in 0..4 {
store(dst, i, j, dc);
}
}
}
fn transform_dcuv_c(input: &[i16], dst: &mut [u8]) {
if input[0] != 0 {
vp8_transform_dc(input, dst);
}
if input[16] != 0 {
vp8_transform_dc(&input[16..], &mut dst[4..]);
}
if input[2 * 16] != 0 {
vp8_transform_dc(&input[2 * 16..], &mut dst[4 * BPS_U..]);
}
if input[3 * 16] != 0 {
vp8_transform_dc(&input[3 * 16..], &mut dst[4 * BPS_U + 4..]);
}
}
pub fn transform_wht_c(input: &[i16], out: &mut [i16]) {
let mut tmp = [0i32; 16];
for i in 0..4 {
let a0 = i32::from(input[i]) + i32::from(input[12 + i]);
let a1 = i32::from(input[4 + i]) + i32::from(input[8 + i]);
let a2 = i32::from(input[4 + i]) - i32::from(input[8 + i]);
let a3 = i32::from(input[i]) - i32::from(input[12 + i]);
tmp[i] = a0 + a1;
tmp[8 + i] = a0 - a1;
tmp[4 + i] = a3 + a2;
tmp[12 + i] = a3 - a2;
}
let mut out_pos = 0;
for i in 0..4 {
let dc = tmp[i * 4] + 3; let a0 = dc + tmp[3 + i * 4];
let a1 = tmp[1 + i * 4] + tmp[2 + i * 4];
let a2 = tmp[1 + i * 4] - tmp[2 + i * 4];
let a3 = dc - tmp[3 + i * 4];
#[expect(
clippy::cast_possible_truncation,
reason = "C stores the int results in int16_t"
)]
{
out[out_pos] = ((a0 + a1) >> 3) as i16;
out[out_pos + 16] = ((a3 + a2) >> 3) as i16;
out[out_pos + 32] = ((a0 - a1) >> 3) as i16;
out[out_pos + 48] = ((a3 - a2) >> 3) as i16;
}
out_pos += 64;
}
}
pub type VP8DecIdct2 = fn(&[i16], &mut [u8], bool);
pub type VP8DecIdct = fn(&[i16], &mut [u8]);
pub fn vp8_transform(input: &[i16], dst: &mut [u8], do_two: bool) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::transform(input, dst, do_two);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::transform_two(input, dst, do_two);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
transform_two_c(input, dst, do_two);
}
pub fn vp8_transform_ac3(input: &[i16], dst: &mut [u8]) {
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::transform_ac3(input, dst);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
transform_ac3_c(input, dst);
}
pub fn vp8_transform_uv(input: &[i16], dst: &mut [u8]) {
transform_uv_c(input, dst);
}
pub fn vp8_transform_dc(input: &[i16], dst: &mut [u8]) {
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::transform_dc(input, dst);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
transform_dc_c(input, dst);
}
pub fn vp8_transform_dcuv(input: &[i16], dst: &mut [u8]) {
transform_dcuv_c(input, dst);
}
pub fn vp8_transform_wht(input: &[i16], out: &mut [i16]) {
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::transform_wht(input, out);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
transform_wht_c(input, out);
}
const fn dst_at(dst: usize, x: usize, y: usize) -> usize {
dst + x + y * BPS_U
}
fn true_motion(buf: &mut [u8], dst: usize, size: usize) {
let top = dst - BPS_U;
let top_left = i32::from(buf[top - 1]);
let mut row = dst;
for _ in 0..size {
let left = i32::from(buf[row - 1]);
for x in 0..size {
buf[row + x] = VP8KCLIP1[i32::from(buf[top + x]) + left - top_left];
}
row += BPS_U;
}
}
pub fn tm4_c(buf: &mut [u8], dst: usize) {
true_motion(buf, dst, 4);
}
pub fn tm8uv_c(buf: &mut [u8], dst: usize) {
true_motion(buf, dst, 8);
}
pub fn tm16_c(buf: &mut [u8], dst: usize) {
true_motion(buf, dst, 16);
}
pub fn ve16_c(buf: &mut [u8], dst: usize) {
for j in 0..16 {
buf.copy_within(dst - BPS_U..dst - BPS_U + 16, dst + j * BPS_U);
}
}
pub fn he16_c(buf: &mut [u8], dst: usize) {
let mut row = dst;
for _ in 0..16 {
let left = buf[row - 1];
buf[row..row + 16].fill(left);
row += BPS_U;
}
}
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "memset converts the int value to unsigned char"
)]
fn put16(v: i32, buf: &mut [u8], dst: usize) {
for j in 0..16 {
let row = dst + j * BPS_U;
buf[row..row + 16].fill(v as u8);
}
}
pub fn dc16_c(buf: &mut [u8], dst: usize) {
let mut dc = 16;
for j in 0..16 {
dc += i32::from(buf[dst - 1 + j * BPS_U]) + i32::from(buf[dst + j - BPS_U]);
}
put16(dc >> 5, buf, dst);
}
pub fn dc16_no_top_c(buf: &mut [u8], dst: usize) {
let mut dc = 8;
for j in 0..16 {
dc += i32::from(buf[dst - 1 + j * BPS_U]);
}
put16(dc >> 4, buf, dst);
}
pub fn dc16_no_left_c(buf: &mut [u8], dst: usize) {
let mut dc = 8;
for i in 0..16 {
dc += i32::from(buf[dst + i - BPS_U]);
}
put16(dc >> 4, buf, dst);
}
pub fn dc16_no_top_left_c(buf: &mut [u8], dst: usize) {
put16(0x80, buf, dst);
}
pub type VP8PredFunc = fn(&mut [u8], usize);
static VP8_PRED_LUMA16: [VP8PredFunc; 7] = [
dc16_c,
tm16_c,
ve16_c,
he16_c,
dc16_no_top_c,
dc16_no_left_c,
dc16_no_top_left_c,
];
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
static VP8_PRED_LUMA16_NEON: [VP8PredFunc; 7] = [
crate::dsp::dec_neon::dc16_top_left,
crate::dsp::dec_neon::tm16,
crate::dsp::dec_neon::ve16,
crate::dsp::dec_neon::he16,
crate::dsp::dec_neon::dc16_no_top,
crate::dsp::dec_neon::dc16_no_left,
crate::dsp::dec_neon::dc16_no_top_left,
];
pub fn vp8_pred_luma16(mode: i32, buf: &mut [u8], dst: usize) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 && features.sse4_1 && mode == 3 {
return crate::dsp::dec_sse41::he16(buf, dst);
}
if features.sse2 {
match mode {
0 => return crate::dsp::dec_sse2::dc16(buf, dst),
1 => return crate::dsp::dec_sse2::tm16(buf, dst),
2 => return crate::dsp::dec_sse2::ve16(buf, dst),
3 => return crate::dsp::dec_sse2::he16(buf, dst),
4 => return crate::dsp::dec_sse2::dc16_no_top(buf, dst),
5 => return crate::dsp::dec_sse2::dc16_no_left(buf, dst),
6 => return crate::dsp::dec_sse2::dc16_no_top_left(buf, dst),
_ => {}
}
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return VP8_PRED_LUMA16_NEON[usize::try_from(mode).expect("a non-negative mode")](buf, dst);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
VP8_PRED_LUMA16[usize::try_from(mode).expect("a non-negative mode")](buf, dst);
}
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "the C macro casts the average to uint8_t"
)]
fn avg3(a: i32, b: i32, c: i32) -> u8 {
((a + 2 * b + c + 2) >> 2) as u8
}
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "C stores the int average in uint8_t"
)]
fn avg2(a: i32, b: i32) -> u8 {
((a + b + 1) >> 1) as u8
}
pub fn ve4_c(buf: &mut [u8], dst: usize) {
let top = dst - BPS_U;
let t = |k: usize| i32::from(buf[top - 1 + k]);
let vals = [
avg3(t(0), t(1), t(2)),
avg3(t(1), t(2), t(3)),
avg3(t(2), t(3), t(4)),
avg3(t(3), t(4), t(5)),
];
for i in 0..4 {
let row = dst + i * BPS_U;
buf[row..row + 4].copy_from_slice(&vals);
}
}
#[expect(clippy::many_single_char_names, reason = "the C sample names")]
fn he4_c(buf: &mut [u8], dst: usize) {
let a = i32::from(buf[dst - 1 - BPS_U]);
let b = i32::from(buf[dst - 1]);
let c = i32::from(buf[dst - 1 + BPS_U]);
let d = i32::from(buf[dst - 1 + 2 * BPS_U]);
let e = i32::from(buf[dst - 1 + 3 * BPS_U]);
webp_uint32_to_mem(&mut buf[dst..], 0x0101_0101_u32 * u32::from(avg3(a, b, c)));
webp_uint32_to_mem(
&mut buf[dst + BPS_U..],
0x0101_0101_u32 * u32::from(avg3(b, c, d)),
);
webp_uint32_to_mem(
&mut buf[dst + 2 * BPS_U..],
0x0101_0101_u32 * u32::from(avg3(c, d, e)),
);
webp_uint32_to_mem(
&mut buf[dst + 3 * BPS_U..],
0x0101_0101_u32 * u32::from(avg3(d, e, e)),
);
}
pub fn dc4_c(buf: &mut [u8], dst: usize) {
let mut dc: u32 = 4;
for i in 0..4 {
dc += u32::from(buf[dst + i - BPS_U]) + u32::from(buf[dst - 1 + i * BPS_U]);
}
dc >>= 3;
#[expect(
clippy::cast_possible_truncation,
reason = "memset converts the value to unsigned char"
)]
let value = dc as u8;
for i in 0..4 {
let row = dst + i * BPS_U;
buf[row..row + 4].fill(value);
}
}
#[expect(clippy::many_single_char_names, reason = "the C sample names")]
pub fn rd4_c(buf: &mut [u8], dst: usize) {
let i = i32::from(buf[dst - 1]);
let j = i32::from(buf[dst - 1 + BPS_U]);
let k = i32::from(buf[dst - 1 + 2 * BPS_U]);
let l = i32::from(buf[dst - 1 + 3 * BPS_U]);
let x = i32::from(buf[dst - 1 - BPS_U]);
let a = i32::from(buf[dst - BPS_U]);
let b = i32::from(buf[dst + 1 - BPS_U]);
let c = i32::from(buf[dst + 2 - BPS_U]);
let d = i32::from(buf[dst + 3 - BPS_U]);
let mut put = |pos: &[(usize, usize)], v: u8| {
for &(px, py) in pos {
buf[dst_at(dst, px, py)] = v;
}
};
put(&[(0, 3)], avg3(j, k, l));
put(&[(1, 3), (0, 2)], avg3(i, j, k));
put(&[(2, 3), (1, 2), (0, 1)], avg3(x, i, j));
put(&[(3, 3), (2, 2), (1, 1), (0, 0)], avg3(a, x, i));
put(&[(3, 2), (2, 1), (1, 0)], avg3(b, a, x));
put(&[(3, 1), (2, 0)], avg3(c, b, a));
put(&[(3, 0)], avg3(d, c, b));
}
#[expect(clippy::many_single_char_names, reason = "the C sample names")]
pub fn ld4_c(buf: &mut [u8], dst: usize) {
let a = i32::from(buf[dst - BPS_U]);
let b = i32::from(buf[dst + 1 - BPS_U]);
let c = i32::from(buf[dst + 2 - BPS_U]);
let d = i32::from(buf[dst + 3 - BPS_U]);
let e = i32::from(buf[dst + 4 - BPS_U]);
let f = i32::from(buf[dst + 5 - BPS_U]);
let g = i32::from(buf[dst + 6 - BPS_U]);
let h = i32::from(buf[dst + 7 - BPS_U]);
let mut put = |pos: &[(usize, usize)], v: u8| {
for &(px, py) in pos {
buf[dst_at(dst, px, py)] = v;
}
};
put(&[(0, 0)], avg3(a, b, c));
put(&[(1, 0), (0, 1)], avg3(b, c, d));
put(&[(2, 0), (1, 1), (0, 2)], avg3(c, d, e));
put(&[(3, 0), (2, 1), (1, 2), (0, 3)], avg3(d, e, f));
put(&[(3, 1), (2, 2), (1, 3)], avg3(e, f, g));
put(&[(3, 2), (2, 3)], avg3(f, g, h));
put(&[(3, 3)], avg3(g, h, h));
}
#[expect(clippy::many_single_char_names, reason = "the C sample names")]
fn vr4_c(buf: &mut [u8], dst: usize) {
let i = i32::from(buf[dst - 1]);
let j = i32::from(buf[dst - 1 + BPS_U]);
let k = i32::from(buf[dst - 1 + 2 * BPS_U]);
let x = i32::from(buf[dst - 1 - BPS_U]);
let a = i32::from(buf[dst - BPS_U]);
let b = i32::from(buf[dst + 1 - BPS_U]);
let c = i32::from(buf[dst + 2 - BPS_U]);
let d = i32::from(buf[dst + 3 - BPS_U]);
let mut put = |pos: &[(usize, usize)], v: u8| {
for &(px, py) in pos {
buf[dst_at(dst, px, py)] = v;
}
};
put(&[(0, 0), (1, 2)], avg2(x, a));
put(&[(1, 0), (2, 2)], avg2(a, b));
put(&[(2, 0), (3, 2)], avg2(b, c));
put(&[(3, 0)], avg2(c, d));
put(&[(0, 3)], avg3(k, j, i));
put(&[(0, 2)], avg3(j, i, x));
put(&[(0, 1), (1, 3)], avg3(i, x, a));
put(&[(1, 1), (2, 3)], avg3(x, a, b));
put(&[(2, 1), (3, 3)], avg3(a, b, c));
put(&[(3, 1)], avg3(b, c, d));
}
#[expect(clippy::many_single_char_names, reason = "the C sample names")]
fn vl4_c(buf: &mut [u8], dst: usize) {
let a = i32::from(buf[dst - BPS_U]);
let b = i32::from(buf[dst + 1 - BPS_U]);
let c = i32::from(buf[dst + 2 - BPS_U]);
let d = i32::from(buf[dst + 3 - BPS_U]);
let e = i32::from(buf[dst + 4 - BPS_U]);
let f = i32::from(buf[dst + 5 - BPS_U]);
let g = i32::from(buf[dst + 6 - BPS_U]);
let h = i32::from(buf[dst + 7 - BPS_U]);
let mut put = |pos: &[(usize, usize)], v: u8| {
for &(px, py) in pos {
buf[dst_at(dst, px, py)] = v;
}
};
put(&[(0, 0)], avg2(a, b));
put(&[(1, 0), (0, 2)], avg2(b, c));
put(&[(2, 0), (1, 2)], avg2(c, d));
put(&[(3, 0), (2, 2)], avg2(d, e));
put(&[(0, 1)], avg3(a, b, c));
put(&[(1, 1), (0, 3)], avg3(b, c, d));
put(&[(2, 1), (1, 3)], avg3(c, d, e));
put(&[(3, 1), (2, 3)], avg3(d, e, f));
put(&[(3, 2)], avg3(e, f, g));
put(&[(3, 3)], avg3(f, g, h));
}
fn hu4_c(buf: &mut [u8], dst: usize) {
let i = i32::from(buf[dst - 1]);
let j = i32::from(buf[dst - 1 + BPS_U]);
let k = i32::from(buf[dst - 1 + 2 * BPS_U]);
let l = buf[dst - 1 + 3 * BPS_U];
let li = i32::from(l);
let mut put = |pos: &[(usize, usize)], v: u8| {
for &(px, py) in pos {
buf[dst_at(dst, px, py)] = v;
}
};
put(&[(0, 0)], avg2(i, j));
put(&[(2, 0), (0, 1)], avg2(j, k));
put(&[(2, 1), (0, 2)], avg2(k, li));
put(&[(1, 0)], avg3(i, j, k));
put(&[(3, 0), (1, 1)], avg3(j, k, li));
put(&[(3, 1), (1, 2)], avg3(k, li, li));
put(&[(3, 2), (2, 2), (0, 3), (1, 3), (2, 3), (3, 3)], l);
}
#[expect(clippy::many_single_char_names, reason = "the C sample names")]
fn hd4_c(buf: &mut [u8], dst: usize) {
let i = i32::from(buf[dst - 1]);
let j = i32::from(buf[dst - 1 + BPS_U]);
let k = i32::from(buf[dst - 1 + 2 * BPS_U]);
let l = i32::from(buf[dst - 1 + 3 * BPS_U]);
let x = i32::from(buf[dst - 1 - BPS_U]);
let a = i32::from(buf[dst - BPS_U]);
let b = i32::from(buf[dst + 1 - BPS_U]);
let c = i32::from(buf[dst + 2 - BPS_U]);
let mut put = |pos: &[(usize, usize)], v: u8| {
for &(px, py) in pos {
buf[dst_at(dst, px, py)] = v;
}
};
put(&[(0, 0), (2, 1)], avg2(i, x));
put(&[(0, 1), (2, 2)], avg2(j, i));
put(&[(0, 2), (2, 3)], avg2(k, j));
put(&[(0, 3)], avg2(l, k));
put(&[(3, 0)], avg3(a, b, c));
put(&[(2, 0)], avg3(x, a, b));
put(&[(1, 0), (3, 1)], avg3(i, x, a));
put(&[(1, 1), (3, 2)], avg3(j, i, x));
put(&[(1, 2), (3, 3)], avg3(k, j, i));
put(&[(1, 3)], avg3(l, k, j));
}
static VP8_PRED_LUMA4: [VP8PredFunc; 10] = [
dc4_c, tm4_c, ve4_c, he4_c, rd4_c, vr4_c, ld4_c, vl4_c, hd4_c, hu4_c,
];
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
static VP8_PRED_LUMA4_NEON: [VP8PredFunc; 10] = [
crate::dsp::dec_neon::dc4,
crate::dsp::dec_neon::tm4,
crate::dsp::dec_neon::ve4,
he4_c,
crate::dsp::dec_neon::rd4,
vr4_c,
crate::dsp::dec_neon::ld4,
vl4_c,
hd4_c,
hu4_c,
];
pub fn vp8_pred_luma4(mode: i32, buf: &mut [u8], dst: usize) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
match mode {
1 => return crate::dsp::dec_sse2::tm4(buf, dst),
2 => return crate::dsp::dec_sse2::ve4(buf, dst),
4 => return crate::dsp::dec_sse2::rd4(buf, dst),
5 => return crate::dsp::dec_sse2::vr4(buf, dst),
6 => return crate::dsp::dec_sse2::ld4(buf, dst),
7 => return crate::dsp::dec_sse2::vl4(buf, dst),
_ => {}
}
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return VP8_PRED_LUMA4_NEON[usize::try_from(mode).expect("a non-negative mode")](buf, dst);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
VP8_PRED_LUMA4[usize::try_from(mode).expect("a non-negative mode")](buf, dst);
}
pub fn ve8uv_c(buf: &mut [u8], dst: usize) {
for j in 0..8 {
buf.copy_within(dst - BPS_U..dst - BPS_U + 8, dst + j * BPS_U);
}
}
pub fn he8uv_c(buf: &mut [u8], dst: usize) {
let mut row = dst;
for _ in 0..8 {
let left = buf[row - 1];
buf[row..row + 8].fill(left);
row += BPS_U;
}
}
fn put8x8uv(value: u8, buf: &mut [u8], dst: usize) {
for j in 0..8 {
let row = dst + j * BPS_U;
buf[row..row + 8].fill(value);
}
}
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "C converts the int argument to the uint8_t parameter"
)]
fn to_u8(v: i32) -> u8 {
v as u8
}
pub fn dc8uv_c(buf: &mut [u8], dst: usize) {
let mut dc0 = 8;
for i in 0..8 {
dc0 += i32::from(buf[dst + i - BPS_U]) + i32::from(buf[dst - 1 + i * BPS_U]);
}
put8x8uv(to_u8(dc0 >> 4), buf, dst);
}
pub fn dc8uv_no_left_c(buf: &mut [u8], dst: usize) {
let mut dc0 = 4;
for i in 0..8 {
dc0 += i32::from(buf[dst + i - BPS_U]);
}
put8x8uv(to_u8(dc0 >> 3), buf, dst);
}
pub fn dc8uv_no_top_c(buf: &mut [u8], dst: usize) {
let mut dc0 = 4;
for i in 0..8 {
dc0 += i32::from(buf[dst - 1 + i * BPS_U]);
}
put8x8uv(to_u8(dc0 >> 3), buf, dst);
}
pub fn dc8uv_no_top_left_c(buf: &mut [u8], dst: usize) {
put8x8uv(0x80, buf, dst);
}
static VP8_PRED_CHROMA8: [VP8PredFunc; 7] = [
dc8uv_c,
tm8uv_c,
ve8uv_c,
he8uv_c,
dc8uv_no_top_c,
dc8uv_no_left_c,
dc8uv_no_top_left_c,
];
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
static VP8_PRED_CHROMA8_NEON: [VP8PredFunc; 7] = [
crate::dsp::dec_neon::dc8uv,
crate::dsp::dec_neon::tm8uv,
crate::dsp::dec_neon::ve8uv,
crate::dsp::dec_neon::he8uv,
crate::dsp::dec_neon::dc8uv_no_top,
crate::dsp::dec_neon::dc8uv_no_left,
crate::dsp::dec_neon::dc8uv_no_top_left,
];
pub fn vp8_pred_chroma8(mode: i32, buf: &mut [u8], dst: usize) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
match mode {
0 => return crate::dsp::dec_sse2::dc8uv(buf, dst),
1 => return crate::dsp::dec_sse2::tm8uv(buf, dst),
2 => return crate::dsp::dec_sse2::ve8uv(buf, dst),
4 => return crate::dsp::dec_sse2::dc8uv_no_top(buf, dst),
5 => return crate::dsp::dec_sse2::dc8uv_no_left(buf, dst),
6 => return crate::dsp::dec_sse2::dc8uv_no_top_left(buf, dst),
_ => {}
}
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return VP8_PRED_CHROMA8_NEON[usize::try_from(mode).expect("a non-negative mode")](
buf, dst,
);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
VP8_PRED_CHROMA8[usize::try_from(mode).expect("a non-negative mode")](buf, dst);
}
fn sample(p: &[u8], pos: usize, delta: i32) -> i32 {
i32::from(p[at(pos, delta)])
}
fn do_filter2_c(p: &mut [u8], pos: usize, step: i32) {
let p1 = sample(p, pos, -2 * step);
let p0 = sample(p, pos, -step);
let q0 = sample(p, pos, 0);
let q1 = sample(p, pos, step);
let a = 3 * (q0 - p0) + i32::from(VP8KSCLIP1[p1 - q1]); let a1 = i32::from(VP8KSCLIP2[(a + 4) >> 3]); let a2 = i32::from(VP8KSCLIP2[(a + 3) >> 3]);
p[at(pos, -step)] = VP8KCLIP1[p0 + a2];
p[pos] = VP8KCLIP1[q0 - a1];
}
fn do_filter4_c(p: &mut [u8], pos: usize, step: i32) {
let p1 = sample(p, pos, -2 * step);
let p0 = sample(p, pos, -step);
let q0 = sample(p, pos, 0);
let q1 = sample(p, pos, step);
let a = 3 * (q0 - p0);
let a1 = i32::from(VP8KSCLIP2[(a + 4) >> 3]);
let a2 = i32::from(VP8KSCLIP2[(a + 3) >> 3]);
let a3 = (a1 + 1) >> 1;
p[at(pos, -2 * step)] = VP8KCLIP1[p1 + a3];
p[at(pos, -step)] = VP8KCLIP1[p0 + a2];
p[pos] = VP8KCLIP1[q0 - a1];
p[at(pos, step)] = VP8KCLIP1[q1 - a3];
}
fn do_filter6_c(p: &mut [u8], pos: usize, step: i32) {
let p2 = sample(p, pos, -3 * step);
let p1 = sample(p, pos, -2 * step);
let p0 = sample(p, pos, -step);
let q0 = sample(p, pos, 0);
let q1 = sample(p, pos, step);
let q2 = sample(p, pos, 2 * step);
let a = i32::from(VP8KSCLIP1[3 * (q0 - p0) + i32::from(VP8KSCLIP1[p1 - q1])]);
let a1 = (27 * a + 63) >> 7; let a2 = (18 * a + 63) >> 7; let a3 = (9 * a + 63) >> 7; p[at(pos, -3 * step)] = VP8KCLIP1[p2 + a3];
p[at(pos, -2 * step)] = VP8KCLIP1[p1 + a2];
p[at(pos, -step)] = VP8KCLIP1[p0 + a1];
p[pos] = VP8KCLIP1[q0 - a1];
p[at(pos, step)] = VP8KCLIP1[q1 - a2];
p[at(pos, 2 * step)] = VP8KCLIP1[q2 - a3];
}
fn hev(p: &[u8], pos: usize, step: i32, thresh: i32) -> bool {
let p1 = sample(p, pos, -2 * step);
let p0 = sample(p, pos, -step);
let q0 = sample(p, pos, 0);
let q1 = sample(p, pos, step);
i32::from(VP8KABS0[p1 - p0]) > thresh || i32::from(VP8KABS0[q1 - q0]) > thresh
}
fn needs_filter_c(p: &[u8], pos: usize, step: i32, t: i32) -> bool {
let p1 = sample(p, pos, -2 * step);
let p0 = sample(p, pos, -step);
let q0 = sample(p, pos, 0);
let q1 = sample(p, pos, step);
(4 * i32::from(VP8KABS0[p0 - q0]) + i32::from(VP8KABS0[p1 - q1])) <= t
}
fn needs_filter2_c(p: &[u8], pos: usize, step: i32, t: i32, it: i32) -> bool {
let p3 = sample(p, pos, -4 * step);
let p2 = sample(p, pos, -3 * step);
let p1 = sample(p, pos, -2 * step);
let p0 = sample(p, pos, -step);
let q0 = sample(p, pos, 0);
let q1 = sample(p, pos, step);
let q2 = sample(p, pos, 2 * step);
let q3 = sample(p, pos, 3 * step);
if (4 * i32::from(VP8KABS0[p0 - q0]) + i32::from(VP8KABS0[p1 - q1])) > t {
return false;
}
i32::from(VP8KABS0[p3 - p2]) <= it
&& i32::from(VP8KABS0[p2 - p1]) <= it
&& i32::from(VP8KABS0[p1 - p0]) <= it
&& i32::from(VP8KABS0[q3 - q2]) <= it
&& i32::from(VP8KABS0[q2 - q1]) <= it
&& i32::from(VP8KABS0[q1 - q0]) <= it
}
pub fn simple_v_filter16_c(p: &mut [u8], pos: usize, stride: i32, thresh: i32) {
let thresh2 = 2 * thresh + 1;
for i in 0..16 {
if needs_filter_c(p, pos + i, stride, thresh2) {
do_filter2_c(p, pos + i, stride);
}
}
}
pub fn simple_h_filter16_c(p: &mut [u8], pos: usize, stride: i32, thresh: i32) {
let thresh2 = 2 * thresh + 1;
for i in 0..16 {
let row = at(pos, i * stride);
if needs_filter_c(p, row, 1, thresh2) {
do_filter2_c(p, row, 1);
}
}
}
pub fn simple_v_filter16i_c(p: &mut [u8], pos: usize, stride: i32, thresh: i32) {
let mut pos = pos;
for _ in 0..3 {
pos = at(pos, 4 * stride);
simple_v_filter16_c(p, pos, stride, thresh);
}
}
pub fn simple_h_filter16i_c(p: &mut [u8], pos: usize, stride: i32, thresh: i32) {
let mut pos = pos;
for _ in 0..3 {
pos += 4;
simple_h_filter16_c(p, pos, stride, thresh);
}
}
#[expect(clippy::too_many_arguments, reason = "the C parameters")]
fn filter_loop26_c(
p: &mut [u8],
pos: usize,
hstride: i32,
vstride: i32,
size: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
let thresh2 = 2 * thresh + 1;
let mut pos = pos;
let mut size = size;
while size > 0 {
size -= 1;
if needs_filter2_c(p, pos, hstride, thresh2, ithresh) {
if hev(p, pos, hstride, hev_thresh) {
do_filter2_c(p, pos, hstride);
} else {
do_filter6_c(p, pos, hstride);
}
}
pos = at(pos, vstride);
}
}
#[expect(clippy::too_many_arguments, reason = "the C parameters")]
fn filter_loop24_c(
p: &mut [u8],
pos: usize,
hstride: i32,
vstride: i32,
size: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
let thresh2 = 2 * thresh + 1;
let mut pos = pos;
let mut size = size;
while size > 0 {
size -= 1;
if needs_filter2_c(p, pos, hstride, thresh2, ithresh) {
if hev(p, pos, hstride, hev_thresh) {
do_filter2_c(p, pos, hstride);
} else {
do_filter4_c(p, pos, hstride);
}
}
pos = at(pos, vstride);
}
}
pub fn v_filter16_c(
p: &mut [u8],
pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
filter_loop26_c(p, pos, stride, 1, 16, thresh, ithresh, hev_thresh);
}
pub fn h_filter16_c(
p: &mut [u8],
pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
filter_loop26_c(p, pos, 1, stride, 16, thresh, ithresh, hev_thresh);
}
pub fn v_filter16i_c(
p: &mut [u8],
pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
let mut pos = pos;
for _ in 0..3 {
pos = at(pos, 4 * stride);
filter_loop24_c(p, pos, stride, 1, 16, thresh, ithresh, hev_thresh);
}
}
pub fn h_filter16i_c(
p: &mut [u8],
pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
let mut pos = pos;
for _ in 0..3 {
pos += 4;
filter_loop24_c(p, pos, 1, stride, 16, thresh, ithresh, hev_thresh);
}
}
#[expect(
clippy::too_many_arguments,
reason = "the C parameters with two positions"
)]
pub fn v_filter8_c(
u: &mut [u8],
u_pos: usize,
v: &mut [u8],
v_pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
filter_loop26_c(u, u_pos, stride, 1, 8, thresh, ithresh, hev_thresh);
filter_loop26_c(v, v_pos, stride, 1, 8, thresh, ithresh, hev_thresh);
}
#[expect(
clippy::too_many_arguments,
reason = "the C parameters with two positions"
)]
pub fn h_filter8_c(
u: &mut [u8],
u_pos: usize,
v: &mut [u8],
v_pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
filter_loop26_c(u, u_pos, 1, stride, 8, thresh, ithresh, hev_thresh);
filter_loop26_c(v, v_pos, 1, stride, 8, thresh, ithresh, hev_thresh);
}
#[expect(
clippy::too_many_arguments,
reason = "the C parameters with two positions"
)]
pub fn v_filter8i_c(
u: &mut [u8],
u_pos: usize,
v: &mut [u8],
v_pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
filter_loop24_c(
u,
at(u_pos, 4 * stride),
stride,
1,
8,
thresh,
ithresh,
hev_thresh,
);
filter_loop24_c(
v,
at(v_pos, 4 * stride),
stride,
1,
8,
thresh,
ithresh,
hev_thresh,
);
}
#[expect(
clippy::too_many_arguments,
reason = "the C parameters with two positions"
)]
pub fn h_filter8i_c(
u: &mut [u8],
u_pos: usize,
v: &mut [u8],
v_pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_thresh: i32,
) {
filter_loop24_c(u, u_pos + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
filter_loop24_c(v, v_pos + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
}
fn dither_combine8x8_c(dither: &[u8], dst: &mut [u8], dst_stride: i32) {
let stride = usize::try_from(dst_stride).expect("a non-negative stride");
for j in 0..8 {
let row = &mut dst[j * stride..];
for i in 0..8 {
let delta0 = i32::from(dither[j * 8 + i]) - VP8_DITHER_AMP_CENTER;
let delta1 = (delta0 + VP8_DITHER_DESCALE_ROUNDER) >> VP8_DITHER_DESCALE;
row[i] = clip_8b(i32::from(row[i]) + delta1);
}
}
}
pub type VP8SimpleFilterFunc = fn(&mut [u8], usize, i32, i32);
pub type VP8LumaFilterFunc = fn(&mut [u8], usize, i32, i32, i32, i32);
pub type VP8ChromaFilterFunc = fn(&mut [u8], usize, &mut [u8], usize, i32, i32, i32, i32);
pub fn vp8v_filter16(p: &mut [u8], pos: usize, stride: i32, thresh: i32, ithresh: i32, hev_t: i32) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::v_filter16(p, pos, stride, thresh, ithresh, hev_t);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::v_filter16(p, pos, stride, thresh, ithresh, hev_t);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
v_filter16_c(p, pos, stride, thresh, ithresh, hev_t);
}
pub fn vp8h_filter16(p: &mut [u8], pos: usize, stride: i32, thresh: i32, ithresh: i32, hev_t: i32) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::h_filter16(p, pos, stride, thresh, ithresh, hev_t);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::h_filter16(p, pos, stride, thresh, ithresh, hev_t);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
h_filter16_c(p, pos, stride, thresh, ithresh, hev_t);
}
#[expect(
clippy::too_many_arguments,
reason = "the C parameters with two positions"
)]
pub fn vp8v_filter8(
u: &mut [u8],
u_pos: usize,
v: &mut [u8],
v_pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_t: i32,
) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::v_filter8(
u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t,
);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::v_filter8(u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
v_filter8_c(u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t);
}
#[expect(
clippy::too_many_arguments,
reason = "the C parameters with two positions"
)]
pub fn vp8h_filter8(
u: &mut [u8],
u_pos: usize,
v: &mut [u8],
v_pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_t: i32,
) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::h_filter8(
u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t,
);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::h_filter8(u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
h_filter8_c(u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t);
}
pub fn vp8v_filter16i(
p: &mut [u8],
pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_t: i32,
) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::v_filter16i(p, pos, stride, thresh, ithresh, hev_t);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::v_filter16i(p, pos, stride, thresh, ithresh, hev_t);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
v_filter16i_c(p, pos, stride, thresh, ithresh, hev_t);
}
pub fn vp8h_filter16i(
p: &mut [u8],
pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_t: i32,
) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::h_filter16i(p, pos, stride, thresh, ithresh, hev_t);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::h_filter16i(p, pos, stride, thresh, ithresh, hev_t);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
h_filter16i_c(p, pos, stride, thresh, ithresh, hev_t);
}
#[expect(
clippy::too_many_arguments,
reason = "the C parameters with two positions"
)]
pub fn vp8v_filter8i(
u: &mut [u8],
u_pos: usize,
v: &mut [u8],
v_pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_t: i32,
) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::v_filter8i(
u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t,
);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::v_filter8i(
u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t,
);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
v_filter8i_c(u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t);
}
#[expect(
clippy::too_many_arguments,
reason = "the C parameters with two positions"
)]
pub fn vp8h_filter8i(
u: &mut [u8],
u_pos: usize,
v: &mut [u8],
v_pos: usize,
stride: i32,
thresh: i32,
ithresh: i32,
hev_t: i32,
) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::h_filter8i(
u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t,
);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::h_filter8i(
u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t,
);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
h_filter8i_c(u, u_pos, v, v_pos, stride, thresh, ithresh, hev_t);
}
pub fn vp8_simple_v_filter16(p: &mut [u8], pos: usize, stride: i32, thresh: i32) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::simple_v_filter16(p, pos, stride, thresh);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::simple_v_filter16(p, pos, stride, thresh);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
simple_v_filter16_c(p, pos, stride, thresh);
}
pub fn vp8_simple_h_filter16(p: &mut [u8], pos: usize, stride: i32, thresh: i32) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::simple_h_filter16(p, pos, stride, thresh);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::simple_h_filter16(p, pos, stride, thresh);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
simple_h_filter16_c(p, pos, stride, thresh);
}
pub fn vp8_simple_v_filter16i(p: &mut [u8], pos: usize, stride: i32, thresh: i32) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::simple_v_filter16i(p, pos, stride, thresh);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::simple_v_filter16i(p, pos, stride, thresh);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
simple_v_filter16i_c(p, pos, stride, thresh);
}
pub fn vp8_simple_h_filter16i(p: &mut [u8], pos: usize, stride: i32, thresh: i32) {
#[cfg(all(feature = "simd", any(target_arch = "x86", target_arch = "x86_64")))]
{
let features = crate::dsp::cpu::features();
if features.sse2 {
return crate::dsp::dec_sse2::simple_h_filter16i(p, pos, stride, thresh);
}
}
#[cfg(all(feature = "simd", target_arch = "aarch64"))]
{
return crate::dsp::dec_neon::simple_h_filter16i(p, pos, stride, thresh);
}
#[allow(
unreachable_code,
reason = "the C path is reached only without a SIMD variant"
)]
simple_h_filter16i_c(p, pos, stride, thresh);
}
pub fn vp8_dither_combine8x8(dither: &[u8], dst: &mut [u8], dst_stride: i32) {
dither_combine8x8_c(dither, dst, dst_stride);
}