diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 4ee74f96..3e20d9ac 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -62,10 +62,10 @@ 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 @@ -73,12 +73,12 @@ jobs: 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 diff --git a/src/rdp.rs b/src/rdp.rs index dfb479d9..7ce9fddf 100644 --- a/src/rdp.rs +++ b/src/rdp.rs @@ -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(); + } +} \ No newline at end of file diff --git a/src/yuv_error.rs b/src/yuv_error.rs index 5250e151..f09dad63 100644 --- a/src/yuv_error.rs +++ b/src/yuv_error.rs @@ -128,7 +128,7 @@ pub(crate) fn check_rgba_destination( 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(),