Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
15 changes: 13 additions & 2 deletions src/pixel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<u8, Error: core::error::Error>
+ Into<u16>
+ From<u8>
+ TryFrom<u16, Error: core::error::Error>
+ 'static
+ private::Sealed
{
}

Expand Down
14 changes: 2 additions & 12 deletions src/plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,8 @@ impl<T: Pixel> Plane<T> {
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,
}
Expand Down