diff --git a/Cargo.toml b/Cargo.toml index 60dc90c..cca2af2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,6 @@ edition = "2024" repository = "https://github.com/rust-av/v_frame" include = ["Cargo.toml", "README.md", "LICENSE", "src"] -[dependencies] -num-traits = "0.2.19" - [features] padding_api = [] diff --git a/src/pixel.rs b/src/pixel.rs index f8a1c0e..e60c492 100644 --- a/src/pixel.rs +++ b/src/pixel.rs @@ -22,7 +22,6 @@ //! - 8-bit frames must use `u8` //! - 9-16 bit frames must use `u16` -use num_traits::PrimInt; use std::fmt::Debug; mod private { @@ -56,7 +55,19 @@ mod private { /// i.e. using [`std::mem::zeroed`] must __not__ cause undefined behavior for /// implementing types. pub unsafe trait Pixel: - Debug + Copy + Clone + Default + Send + Sync + PrimInt + 'static + private::Sealed + Sized + + Debug + + Copy + + Clone + + Default + + Send + + Sync + + TryInto + + Into + + From + + TryFrom + + 'static + + private::Sealed { } diff --git a/src/plane.rs b/src/plane.rs index bf701ee..b5eeb23 100644 --- a/src/plane.rs +++ b/src/plane.rs @@ -317,18 +317,8 @@ impl Plane { let total = self.width().get() * self.height().get() * byte_width; ExactSizeWrapper { iter: self.pixels().flat_map(move |pix| { - let bytes: [u8; 2] = if byte_width == 1 { - [ - pix.to_u8() - .expect("Pixel::byte_data only supports u8 and u16 pixels"), - 0, - ] - } else { - pix.to_u16() - .expect("Pixel::byte_data only supports u8 and u16 pixels") - .to_le_bytes() - }; - bytes.into_iter().take(byte_width) + let pix: u16 = pix.into(); + pix.to_le_bytes().into_iter().take(byte_width) }), len: total, }