Skip to content

Commit

Permalink
Changed str_to_u32 to remove unsafe code. Need to verify Native Endia…
Browse files Browse the repository at this point in the history
…n works on all platforms
  • Loading branch information
apps4uco committed Oct 5, 2023
1 parent 5c0675c commit 2571cf2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ winit = "0.27.5"
[dependencies]
ffimage = "0.9.0"
ffimage_yuv = "0.9.0"
log = "0.4.20"

[profile.test]
opt-level=3
#debug = false
#split-debuginfo = '...' # Platform-specific.
#debug-assertions = false
#overflow-checks = false
#lto = false
#panic = 'unwind'
#incremental = false
#codegen-units = 16
#rpath = false
7 changes: 1 addition & 6 deletions src/mac_avf/video_output_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ pub fn video_settings_rgb24() -> Id<NSMutableDictionary<NSString, NSNumber>> {
fn str_to_u32(string: &str) -> u32 {
assert_eq!(4, string.len());
let bytes = string.as_bytes();
let a = bytes[0];
let b = bytes[1];
let c = bytes[2];
let d = bytes[3];

unsafe { std::mem::transmute::<[u8; 4], u32>([a, b, c, d]) }
u32::from_ne_bytes(bytes[0..4].try_into().unwrap())
}

fn video_settings_with_pixel_format(
Expand Down

0 comments on commit 2571cf2

Please sign in to comment.