From ac3fbfb16adbb63f4fb362e04024493633752d24 Mon Sep 17 00:00:00 2001 From: Dario Lencina Date: Thu, 26 Dec 2024 07:47:09 -0500 Subject: [PATCH] run fmt --- nokhwa-core/src/pixel_format.rs | 18 +++++++----------- nokhwa-core/src/types.rs | 9 ++++----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/nokhwa-core/src/pixel_format.rs b/nokhwa-core/src/pixel_format.rs index 7eb9c41..b771223 100644 --- a/nokhwa-core/src/pixel_format.rs +++ b/nokhwa-core/src/pixel_format.rs @@ -15,7 +15,8 @@ */ use crate::error::NokhwaError; use crate::types::{ - buf_bgra_to_rgb, buf_mjpeg_to_rgb, buf_nv12_to_rgb, buf_yuyv422_to_rgb, color_frame_formats, frame_formats, mjpeg_to_rgb, nv12_to_rgb, yuyv422_to_rgb, FrameFormat, Resolution + buf_bgra_to_rgb, buf_mjpeg_to_rgb, buf_nv12_to_rgb, buf_yuyv422_to_rgb, color_frame_formats, + frame_formats, mjpeg_to_rgb, nv12_to_rgb, yuyv422_to_rgb, FrameFormat, Resolution, }; use image::{Luma, LumaA, Pixel, Rgb, Rgba}; use std::fmt::Debug; @@ -121,9 +122,7 @@ impl FormatDecoder for RgbFormat { Ok(()) } FrameFormat::NV12 => buf_nv12_to_rgb(resolution, data, dest, false), - FrameFormat::BGRA => { - buf_bgra_to_rgb(resolution, data, dest) - } + FrameFormat::BGRA => buf_bgra_to_rgb(resolution, data, dest), } } } @@ -797,13 +796,10 @@ mod tests { .unwrap(); assert_eq!(actual.len(), expected_rgb.len()); for (i, (&actual, &expected)) in actual.iter().zip(expected_rgb.iter()).enumerate() { - let epsilon = 0; - assert!( - (actual as i32 - expected as i32).abs() <= epsilon as i32, - "data mismatch at index {}: actual = {:#X}, expected = {:#X}", - i, - actual, - expected + assert_eq!( + actual, expected, + "Mismatch at index {} expected {:#X} actual {:#X}", + i, expected, actual ); } } diff --git a/nokhwa-core/src/types.rs b/nokhwa-core/src/types.rs index 4a59b2c..101cd07 100644 --- a/nokhwa-core/src/types.rs +++ b/nokhwa-core/src/types.rs @@ -1822,7 +1822,6 @@ pub fn buf_nv12_to_rgb( Ok(()) } - #[allow(clippy::similar_names)] #[inline] pub fn buf_bgra_to_rgb( @@ -1832,7 +1831,7 @@ pub fn buf_bgra_to_rgb( ) -> Result<(), NokhwaError> { let width = resolution.width(); let height = resolution.height(); - + if width % 2 != 0 || height % 2 != 0 { return Err(NokhwaError::ProcessFrameError { src: FrameFormat::BGRA, @@ -1868,9 +1867,9 @@ pub fn buf_bgra_to_rgb( // let _a = chunk[3]; // Alpha is ignored for RGB let out_idx = idx * 3; // 3 bytes per pixel in RGB - out[out_idx] = r; // Red - out[out_idx + 1] = g; // Green - out[out_idx + 2] = b; // Blue + out[out_idx] = r; // Red + out[out_idx + 1] = g; // Green + out[out_idx + 2] = b; // Blue } Ok(())