Skip to content

Commit

Permalink
Bugfixes for AVX, RGBA
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Jun 22, 2024
1 parent 630298f commit 3526d1c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace = { members = ["src/app"] }

[package]
name = "colorutils-rs"
version = "0.4.9"
version = "0.4.10"
edition = "2021"
description = "High performance utilities for color format handling and conversion."
readme = "README.md"
Expand Down
12 changes: 6 additions & 6 deletions src/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {
println!("HSL {:?}", hsl);
println!("Back RGB {:?}", hsl.to_rgb8());

let img = ImageReader::open("./assets/asset_2.jpg")
let img = ImageReader::open("./assets/test_image_2.png")
.unwrap()
.decode()
.unwrap();
Expand All @@ -34,7 +34,7 @@ fn main() {
let mut src_bytes = img.as_bytes();
let width = dimensions.0;
let height = dimensions.1;
let components = 3;
let components = 4;
//
// let mut dst_rgba = vec![];
// dst_rgba.resize(4usize * width as usize * height as usize, 0u8);
Expand All @@ -58,14 +58,14 @@ fn main() {
lab_store.resize(width as usize * components * height as usize, 0f32);
let src_stride = width * components as u32;
let start_time = Instant::now();
rgb_to_linear(
rgba_to_linear(
src_bytes,
src_stride,
&mut lab_store,
store_stride as u32,
width,
height,
TransferFunction::Gamma2p2,
TransferFunction::Srgb,
);
let elapsed_time = start_time.elapsed();
// Print the elapsed time in milliseconds
Expand Down Expand Up @@ -93,14 +93,14 @@ fn main() {
// }

let start_time = Instant::now();
linear_to_rgb(
linear_to_rgba(
&lab_store,
store_stride as u32,
&mut dst_slice,
src_stride,
width,
height,
TransferFunction::Gamma2p2,
TransferFunction::Srgb,
);

let elapsed_time = start_time.elapsed();
Expand Down
4 changes: 2 additions & 2 deletions src/avx/to_linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub unsafe fn avx_channels_to_linear<const CHANNELS_CONFIGURATION: u8, const USE
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 64), v0);
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 64 + 8), v1);
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 64 + 16), v2);
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 64 + 32), v3);
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 64 + 24), v3);
} else {
let (v0, v1, v2) = avx2_interleave_rgb_ps(x_high_low, y_high_low, z_high_low);
_mm256_storeu_ps(dst_ptr.add(cx * 3 + 48), v0);
Expand All @@ -192,7 +192,7 @@ pub unsafe fn avx_channels_to_linear<const CHANNELS_CONFIGURATION: u8, const USE
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 96), v0);
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 96 + 8), v1);
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 96 + 16), v2);
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 96 + 32), v3);
_mm256_storeu_ps(dst_ptr.add(cx * 4 + 96 + 24), v3);
} else {
let (v0, v1, v2) = avx2_interleave_rgb_ps(x_high_high, y_high_high, z_high_high);
_mm256_storeu_ps(dst_ptr.add(cx * 3 + 24 * 3), v0);
Expand Down

0 comments on commit 3526d1c

Please sign in to comment.