Skip to content

Commit

Permalink
Get rid of #[repr(C)] attribute on types
Browse files Browse the repository at this point in the history
Callers are expected to copy the bytes into our structures before
converting the pixels, and back out of our structures afterwards.

Signed-off-by: Christopher N. Hesse <[email protected]>
  • Loading branch information
raymanfx committed Oct 28, 2023
1 parent 2d791b7 commit 5e4f338
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ffimage-yuv/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#![no_std]

pub mod yuv;
pub mod yuv422;
1 change: 0 additions & 1 deletion ffimage-yuv/src/yuv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use ffimage::color::rgb::*;
use ffimage::Pixel;

/// YUV pixel
#[repr(C)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Yuv<T, const Y: usize = 0, const U: usize = 1, const V: usize = 2>(pub [T; 3]);

Expand Down
1 change: 0 additions & 1 deletion ffimage-yuv/src/yuv422.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::yuv::*;
pub type Yuyv<T> = Yuv422<T, 0, 2, 1, 3>;
pub type Uyvy<T> = Yuv422<T, 1, 3, 0, 2>;

#[repr(C)]
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
pub struct Yuv422<
T,
Expand Down
1 change: 0 additions & 1 deletion ffimage/src/color/gray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use num::FromPrimitive;
use crate::{color::rgb::Rgb, Pixel};

/// Grayscale pixel
#[repr(C)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Gray<T>(pub [T; 1]);

Expand Down
2 changes: 0 additions & 2 deletions ffimage/src/color/rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use num::FromPrimitive;
use crate::Pixel;

/// RGB pixel
#[repr(C)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Rgb<T, const R: usize = 0, const G: usize = 1, const B: usize = 2>(pub [T; 3]);

Expand Down Expand Up @@ -81,7 +80,6 @@ where
}

/// RGB pixel with alpha channel
#[repr(C)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Rgba<T, const R: usize = 0, const G: usize = 1, const B: usize = 2, const A: usize = 3>(
pub [T; 4],
Expand Down

0 comments on commit 5e4f338

Please sign in to comment.