-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed bsz-shared. filmic_chroma FFI.
Filmic chroma now depends on a pure rust libary using no crates for maximum portability. Its loaded using python's ctypes and operates directly on the raw bytestring, so it's about as fast as can be. Currently releases compiled for linux & windows (mingw). Native python fallback still present for those weirdos that have MacOS but not Photoshop.
- Loading branch information
Showing
9 changed files
with
61 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[flake8] | ||
ignore = E402, C901 | ||
ignore = E402, C901, W504 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cd "${0%/*}" | ||
rustc --crate-type cdylib -O filmic-chroma.rs | ||
mv libfilmic_chroma.so filmic_chroma.so | ||
strip filmic_chroma.so | ||
rustc --crate-type cdylib -O --target x86_64-pc-windows-gnu filmic-chroma.rs | ||
rm libfilmic_chroma.dll.a | ||
strip filmic_chroma.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::convert::TryInto; | ||
use std::os::raw; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn filmic_chroma( | ||
scale: f64, | ||
offset: f64, | ||
invert: bool, | ||
bytes: *mut raw::c_char, | ||
len: usize) { | ||
let pixels = unsafe { | ||
std::slice::from_raw_parts_mut(bytes.cast::<u8>(), len) | ||
}; | ||
for chunk in pixels.chunks_exact_mut(32) { | ||
let l = f64::from_le_bytes(chunk[0..8].try_into().expect("bytefail")); | ||
let c = f64::from_le_bytes(chunk[8..16].try_into().expect("bytefail2")); | ||
|
||
let c = match invert { | ||
false => c * (offset - l / scale), | ||
true => c * (offset - (100.0 - l) / scale) | ||
}; | ||
let c = c.to_le_bytes(); | ||
|
||
for x in 0..8 { | ||
chunk[x+8] = c[x]; | ||
}; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters