Skip to content

Commit

Permalink
run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
darioalessandro committed Dec 26, 2024
1 parent 9552a9c commit ac3fbfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
18 changes: 7 additions & 11 deletions nokhwa-core/src/pixel_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
}
}
}
Expand Down Expand Up @@ -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
);
}
}
Expand Down
9 changes: 4 additions & 5 deletions nokhwa-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,6 @@ pub fn buf_nv12_to_rgb(
Ok(())
}


#[allow(clippy::similar_names)]
#[inline]
pub fn buf_bgra_to_rgb(
Expand All @@ -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,
Expand Down Expand Up @@ -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(())
Expand Down

0 comments on commit ac3fbfb

Please sign in to comment.