From 2d791b7d7612f63d91c087974d6360c75bbcf0fe Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Wed, 1 Feb 2023 14:22:53 +0100 Subject: [PATCH] Mark ffimage and ffimage-yuv #![no_std] Fix remaining clippy warnings while we're at it. Signed-off-by: Christopher N. Hesse --- ffimage-yuv/src/yuv.rs | 6 +++--- ffimage-yuv/src/yuv422.rs | 12 ++++-------- ffimage-yuv/tests/convert.rs | 2 +- ffimage/src/lib.rs | 2 ++ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ffimage-yuv/src/yuv.rs b/ffimage-yuv/src/yuv.rs index 43e404a..5c49abe 100644 --- a/ffimage-yuv/src/yuv.rs +++ b/ffimage-yuv/src/yuv.rs @@ -86,9 +86,9 @@ where let d = u - 128; let e = v - 128; - let r = ((298 * c + 409 * e + 128) >> 8).min(255).max(0); - let g = ((298 * c - 100 * d - 208 * e + 128) >> 8).min(255).max(0); - let b = ((298 * c + 516 * d + 128) >> 8).min(255).max(0); + let r = ((298 * c + 409 * e + 128) >> 8).clamp(0, 255); + let g = ((298 * c - 100 * d - 208 * e + 128) >> 8).clamp(0, 255); + let b = ((298 * c + 516 * d + 128) >> 8).clamp(0, 255); let mut rgb = Rgb::::default(); rgb[R] = T::from_i32(r).unwrap(); diff --git a/ffimage-yuv/src/yuv422.rs b/ffimage-yuv/src/yuv422.rs index d59a4f6..62d2fd5 100644 --- a/ffimage-yuv/src/yuv422.rs +++ b/ffimage-yuv/src/yuv422.rs @@ -54,14 +54,10 @@ where T: Copy, { fn from(pix: Yuv422) -> Self { - let sub1 = Yuv { - 0: [pix[Y0], pix[U], pix[V]], - }; - let sub2 = Yuv { - 0: [pix[Y1], pix[U], pix[V]], - }; - - [sub1, sub2] + [ + Yuv([pix[Y0], pix[U], pix[V]]), + Yuv([pix[Y1], pix[U], pix[V]]), + ] } } diff --git a/ffimage-yuv/tests/convert.rs b/ffimage-yuv/tests/convert.rs index f6ddf59..27caa63 100644 --- a/ffimage-yuv/tests/convert.rs +++ b/ffimage-yuv/tests/convert.rs @@ -1,4 +1,4 @@ -use std::ops::RangeInclusive; +use core::ops::RangeInclusive; use ffimage::color::Rgb; diff --git a/ffimage/src/lib.rs b/ffimage/src/lib.rs index 6eb0c54..0088b6c 100644 --- a/ffimage/src/lib.rs +++ b/ffimage/src/lib.rs @@ -40,6 +40,8 @@ //! .collect(); //!``` +#![no_std] + /// Generic pixel attributes pub trait Pixel { /// Number of channels for this pixel