Skip to content

Commit

Permalink
cielab_to_xyz 70% perf improvement
Browse files Browse the repository at this point in the history
yay fma
  • Loading branch information
Beinsezii committed Jun 26, 2024
1 parent e139854 commit a02481a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,10 +1329,11 @@ pub fn cielab_to_xyz<T: DType, const N: usize>(pixel: &mut [T; N])
where
Channels<N>: ValidChannels,
{
pixel[0] = pixel[0].fma((1.0 / 116.0).to_dt(), (16.0 / 116.0).to_dt());
[pixel[0], pixel[1], pixel[2]] = [
(pixel[0] + 16.0.to_dt()) / 116.0.to_dt() + pixel[1] / 500.0.to_dt(),
(pixel[0] + 16.0.to_dt()) / 116.0.to_dt(),
(pixel[0] + 16.0.to_dt()) / 116.0.to_dt() - pixel[2] / 200.0.to_dt(),
pixel[0] + pixel[1] / 500.0.to_dt(),
pixel[0],
pixel[0] - pixel[2] / 200.0.to_dt(),
];

pixel.iter_mut().take(3).for_each(|c| {
Expand Down

0 comments on commit a02481a

Please sign in to comment.