diff --git a/src/avx512bw/rgba_to_yuv.rs b/src/avx512bw/rgba_to_yuv.rs index e828793..d6d4d01 100644 --- a/src/avx512bw/rgba_to_yuv.rs +++ b/src/avx512bw/rgba_to_yuv.rs @@ -28,8 +28,8 @@ */ use crate::avx512bw::avx512_utils::{ - avx512_deinterleave_rgb, avx512_deinterleave_rgba, avx512_pack_u16, avx512_pairwise_widen_avg, - avx512_rgb_to_ycbcr, + avx512_deinterleave_rgb, avx512_deinterleave_rgba, avx512_pack_u16, avx512_pairwise_widen_avg + , }; use crate::internals::ProcessedOffset; use crate::yuv_support::{ diff --git a/src/avx512bw/yuv_to_rgba_alpha.rs b/src/avx512bw/yuv_to_rgba_alpha.rs index 6a3700c..03a8e5a 100644 --- a/src/avx512bw/yuv_to_rgba_alpha.rs +++ b/src/avx512bw/yuv_to_rgba_alpha.rs @@ -179,7 +179,7 @@ pub unsafe fn avx512_yuv_to_rgba_alpha { diff --git a/src/images.rs b/src/images.rs index 5546f83..d02cefb 100644 --- a/src/images.rs +++ b/src/images.rs @@ -38,6 +38,7 @@ pub enum BufferStoreMut<'a, T: Copy + Debug> { } impl BufferStoreMut<'_, T> { + #[allow(clippy::should_implement_trait)] pub fn borrow(&self) -> &[T] { match self { Self::Borrowed(p_ref) => p_ref, @@ -45,7 +46,8 @@ impl BufferStoreMut<'_, T> { } } - pub fn as_mut(&mut self) -> &mut [T] { + #[allow(clippy::should_implement_trait)] + pub fn borrow_mut(&mut self) -> &mut [T] { match self { Self::Borrowed(p_ref) => p_ref, Self::Owned(vec) => vec, diff --git a/src/lib.rs b/src/lib.rs index b2af11c..eca12e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,6 +30,7 @@ #![allow(clippy::manual_clamp)] #![cfg_attr(feature = "nightly_avx512", feature(cfg_version))] #![cfg_attr(feature = "nightly_avx512", feature(avx512_target_feature))] +#![cfg_attr(feature = "nightly_avx512", feature(stdarch_x86_avx512))] extern crate core; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/src/rgb_to_nv_p16.rs b/src/rgb_to_nv_p16.rs index 7d7160b..957be7e 100644 --- a/src/rgb_to_nv_p16.rs +++ b/src/rgb_to_nv_p16.rs @@ -92,8 +92,8 @@ fn rgbx_to_yuv_bi_planar_10_impl< #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] let _use_sse = std::arch::is_x86_feature_detected!("sse4.1"); - let y_plane = bi_planar_image.y_plane.as_mut(); - let uv_plane = bi_planar_image.uv_plane.as_mut(); + let y_plane = bi_planar_image.y_plane.borrow_mut(); + let uv_plane = bi_planar_image.uv_plane.borrow_mut(); let height = bi_planar_image.height; let width = bi_planar_image.width; let y_stride = bi_planar_image.y_stride * 2; diff --git a/src/rgb_to_y.rs b/src/rgb_to_y.rs index 2760b9f..41cb33d 100644 --- a/src/rgb_to_y.rs +++ b/src/rgb_to_y.rs @@ -99,7 +99,7 @@ fn rgbx_to_y( { iter = gray_image .y_plane - .as_mut() + .borrow_mut() .par_chunks_exact_mut(gray_image.y_stride as usize) .zip(rgba.par_chunks_exact(rgba_stride as usize)); } @@ -107,7 +107,7 @@ fn rgbx_to_y( { iter = gray_image .y_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(gray_image.y_stride as usize) .zip(rgba.chunks_exact(rgba_stride as usize)); } diff --git a/src/rgb_to_yuv_p16.rs b/src/rgb_to_yuv_p16.rs index bd5c6bb..b8b55ad 100644 --- a/src/rgb_to_yuv_p16.rs +++ b/src/rgb_to_yuv_p16.rs @@ -119,9 +119,9 @@ fn rgbx_to_yuv_impl< let rgba_offset = rgba_stride as usize * y; let rgba = &rgba[rgba_offset..]; - let y_plane = &mut planar_image.y_plane.as_mut()[y_offset..]; - let u_plane = &mut planar_image.u_plane.as_mut()[u_offset..]; - let v_plane = &mut planar_image.v_plane.as_mut()[v_offset..]; + let y_plane = &mut planar_image.y_plane.borrow_mut()[y_offset..]; + let u_plane = &mut planar_image.u_plane.borrow_mut()[u_offset..]; + let v_plane = &mut planar_image.v_plane.borrow_mut()[v_offset..]; let mut _cx = 0usize; let mut _ux = 0usize; diff --git a/src/rgba_to_nv.rs b/src/rgba_to_nv.rs index 71f4007..5823f19 100644 --- a/src/rgba_to_nv.rs +++ b/src/rgba_to_nv.rs @@ -95,9 +95,9 @@ fn rgbx_to_nv let height = bi_planar_image.height; let width = bi_planar_image.width; - let y_plane = bi_planar_image.y_plane.as_mut(); + let y_plane = bi_planar_image.y_plane.borrow_mut(); let y_stride = bi_planar_image.y_stride; - let uv_plane = bi_planar_image.uv_plane.as_mut(); + let uv_plane = bi_planar_image.uv_plane.borrow_mut(); let uv_stride = bi_planar_image.uv_stride; for y in 0..height as usize { diff --git a/src/rgba_to_yuv.rs b/src/rgba_to_yuv.rs index c8a81fe..5930c9e 100644 --- a/src/rgba_to_yuv.rs +++ b/src/rgba_to_yuv.rs @@ -107,9 +107,9 @@ fn rgbx_to_yuv8( ))] let mut _use_avx512 = std::arch::is_x86_feature_detected!("avx512bw"); - let y_plane = planar_image.y_plane.as_mut(); - let u_plane = planar_image.u_plane.as_mut(); - let v_plane = planar_image.v_plane.as_mut(); + let y_plane = planar_image.y_plane.borrow_mut(); + let u_plane = planar_image.u_plane.borrow_mut(); + let v_plane = planar_image.v_plane.borrow_mut(); let width = planar_image.width; let y_stride = planar_image.y_stride; let u_stride = planar_image.u_stride; diff --git a/src/sharpyuv/sharp_rgba_to_yuv.rs b/src/sharpyuv/sharp_rgba_to_yuv.rs index d7672bc..504c8cb 100644 --- a/src/sharpyuv/sharp_rgba_to_yuv.rs +++ b/src/sharpyuv/sharp_rgba_to_yuv.rs @@ -400,15 +400,15 @@ fn rgbx_to_sharp_yuv( { y_iter = planar_image .y_plane - .as_mut() + .borrow_mut() .par_chunks_exact_mut(planar_image.y_stride as usize * 2); u_iter = planar_image .u_plane - .as_mut() + .borrow_mut() .par_chunks_exact_mut(planar_image.u_stride as usize); v_iter = planar_image .v_plane - .as_mut() + .borrow_mut() .par_chunks_exact_mut(planar_image.v_stride as usize); rgb_iter = rgba.par_chunks_exact(rgba_stride as usize * 2); } @@ -416,15 +416,15 @@ fn rgbx_to_sharp_yuv( { y_iter = planar_image .y_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.y_stride as usize * 2); u_iter = planar_image .u_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.u_stride as usize); v_iter = planar_image .v_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.v_stride as usize); rgb_iter = rgba.chunks_exact(rgba_stride as usize * 2); } @@ -433,15 +433,15 @@ fn rgbx_to_sharp_yuv( { y_iter = planar_image .y_plane - .as_mut() + .borrow_mut() .par_chunks_exact_mut(planar_image.y_stride as usize); u_iter = planar_image .u_plane - .as_mut() + .borrow_mut() .par_chunks_exact_mut(planar_image.u_stride as usize); v_iter = planar_image .v_plane - .as_mut() + .borrow_mut() .par_chunks_exact_mut(planar_image.v_stride as usize); rgb_iter = rgba.par_chunks_exact(rgba_stride as usize); } @@ -449,15 +449,15 @@ fn rgbx_to_sharp_yuv( { y_iter = planar_image .y_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.y_stride as usize); u_iter = planar_image .u_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.u_stride as usize); v_iter = planar_image .v_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.v_stride as usize); rgb_iter = rgba.chunks_exact(rgba_stride as usize); } @@ -524,19 +524,19 @@ fn rgbx_to_sharp_yuv( if planar_image.height & 1 != 0 && chroma_subsampling == YuvChromaSample::Yuv420 { let y_iter = planar_image .y_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.y_stride as usize) .rev() .take(1); let u_iter = planar_image .u_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.u_stride as usize) .rev() .take(1); let v_iter = planar_image .v_plane - .as_mut() + .borrow_mut() .chunks_exact_mut(planar_image.v_stride as usize) .rev() .take(1); diff --git a/src/to_identity.rs b/src/to_identity.rs index 09a8ba0..4beffba 100644 --- a/src/to_identity.rs +++ b/src/to_identity.rs @@ -69,9 +69,9 @@ where image.check_constraints(YuvChromaSample::Yuv444)?; check_rgba_destination(rgba, rgba_stride, image.width, image.height, channels)?; - let y_plane = image.y_plane.as_mut(); - let u_plane = image.u_plane.as_mut(); - let v_plane = image.v_plane.as_mut(); + let y_plane = image.y_plane.borrow_mut(); + let u_plane = image.u_plane.borrow_mut(); + let v_plane = image.v_plane.borrow_mut(); let y_stride = image.y_stride as usize; let u_stride = image.u_stride as usize; let v_stride = image.v_stride as usize; diff --git a/src/yuy2_to_yuv.rs b/src/yuy2_to_yuv.rs index c84d650..ebdcbdc 100644 --- a/src/yuy2_to_yuv.rs +++ b/src/yuy2_to_yuv.rs @@ -57,9 +57,9 @@ fn yuy2_to_yuv_impl( #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] let mut _use_avx2 = std::arch::is_x86_feature_detected!("avx2"); - let y_plane = planar_image.y_plane.as_mut(); - let u_plane = planar_image.u_plane.as_mut(); - let v_plane = planar_image.v_plane.as_mut(); + let y_plane = planar_image.y_plane.borrow_mut(); + let u_plane = planar_image.u_plane.borrow_mut(); + let v_plane = planar_image.v_plane.borrow_mut(); let y_stride = planar_image.y_stride; let u_stride = planar_image.u_stride; let v_stride = planar_image.v_stride; diff --git a/src/yuy2_to_yuv_p16.rs b/src/yuy2_to_yuv_p16.rs index 844c69f..ed317db 100644 --- a/src/yuy2_to_yuv_p16.rs +++ b/src/yuy2_to_yuv_p16.rs @@ -46,11 +46,11 @@ fn yuy2_to_yuv_impl( let width = planar_image.width; let height = planar_image.height; - let y_plane = planar_image.y_plane.as_mut(); + let y_plane = planar_image.y_plane.borrow_mut(); let y_stride = planar_image.y_stride * 2; - let u_plane = planar_image.u_plane.as_mut(); + let u_plane = planar_image.u_plane.borrow_mut(); let u_stride = planar_image.u_stride * 2; - let v_plane = planar_image.v_plane.as_mut(); + let v_plane = planar_image.v_plane.borrow_mut(); let v_stride = planar_image.v_stride * 2; for y in 0..height as usize {