Skip to content

Commit

Permalink
Added RDP tests, changed stride computation
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Feb 4, 2025
1 parent e2cc442 commit beeaf86
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo test
- run: cargo test --no-default-features --features nightly_f16
- run: cargo test --no-default-features --features fast_mode,professional_mode,nightly_f16
- run: cargo test --features fast_mode,professional_mode,nightly_f16
- run: cargo test --features rdp
- run: cargo test --no-default-features --features nightly_f16,rdp
- run: cargo test --no-default-features --features fast_mode,professional_mode,nightly_f16,rdp
- run: cargo test --features fast_mode,professional_mode,nightly_f16,rdp

tests_x86:
name: Testing x86
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo test
- run: cargo test --features fast_mode,professional_mode,nightly_f16
- run: cargo test --no-default-features --features nightly_f16
- run: cargo test --no-default-features --features fast_mode,professional_mode,sse,nightly_f16
- run: cargo test --no-default-features --features fast_mode,professional_mode,avx,nightly_f16
- run: cargo test --no-default-features --features fast_mode,professional_mode,nightly_f16
- run: cargo test --features rdp
- run: cargo test --features fast_mode,professional_mode,nightly_f16,rdp
- run: cargo test --no-default-features --features nightly_f16,rdp
- run: cargo test --no-default-features --features fast_mode,professional_mode,sse,nightly_f16,rdp
- run: cargo test --no-default-features --features fast_mode,professional_mode,avx,nightly_f16,rdp
- run: cargo test --no-default-features --features fast_mode,professional_mode,nightly_f16,rdp

fuzz_arm:
name: Fuzzing ARM
Expand Down
38 changes: 38 additions & 0 deletions src/rdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,41 @@ d_backward!(rdp_yuv444_to_bgra, RdpChannels::Bgra, bgra, bgra_stride);
d_backward!(rdp_yuv444_to_abgr, RdpChannels::Abgr, abgr, abgr_stride);
d_backward!(rdp_yuv444_to_bgr, RdpChannels::Bgr, bgr, bgr_stride);
d_backward!(rdp_yuv444_to_argb, RdpChannels::Argb, argb, argb_stride);

#[cfg(test)]
mod tests {
use crate::BufferStoreMut;
use super::*;
#[test]
fn rgba_to_64x64_yuv() {
const WIDTH: usize = 64;
const HEIGHT: usize = 64;
let mut y = [0i16; WIDTH * HEIGHT];
let mut cb = [0i16; WIDTH * HEIGHT];
let mut cr = [0i16; WIDTH * HEIGHT];
let y_plane = BufferStoreMut::Borrowed(&mut y);
let u_plane = BufferStoreMut::Borrowed(&mut cb);
let v_plane = BufferStoreMut::Borrowed(&mut cr);
let mut plane = YuvPlanarImageMut {
y_plane,
y_stride: 64,
u_plane,
u_stride: 64,
v_plane,
v_stride: 64,
width: 10,
height: 20,
};
let stride = 30 * 4;
let input = vec![
0;
(stride * (plane.height - 1) + plane.width * 4)
.try_into()
.unwrap()
];
rdp_rgba_to_yuv444(&mut plane, &input, stride).unwrap();
rdp_bgra_to_yuv444(&mut plane, &input, stride).unwrap();
rdp_abgr_to_yuv444(&mut plane, &input, stride).unwrap();
rdp_argb_to_yuv444(&mut plane, &input, stride).unwrap();
}
}
2 changes: 1 addition & 1 deletion src/yuv_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub(crate) fn check_rgba_destination<V>(
return Err(YuvError::ZeroBaseSize);
}
check_overflow_v3(width as usize, height as usize, channels)?;
if arr.len() < rgba_stride as usize * height as usize {
if arr.len() < rgba_stride as usize * (height as usize - 1) + width as usize * channels {
return Err(YuvError::DestinationSizeMismatch(MismatchedSize {
expected: rgba_stride as usize * height as usize,
received: arr.len(),
Expand Down

0 comments on commit beeaf86

Please sign in to comment.